Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: dart/runtime/bin/test_extension.c

Issue 15793010: Version 0.5.14.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/runtime/bin/test_extension.c
===================================================================
--- dart/runtime/bin/test_extension.c (revision 0)
+++ dart/runtime/bin/test_extension.c (revision 0)
@@ -0,0 +1,67 @@
+/* Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "include/dart_api.h"
+
+#if defined(ASSERT)
+#error ASSERT already defined!
+#endif
+
+
+/* Native methods. */
+void IfNull(Dart_NativeArguments arguments) {
+ Dart_Handle object = Dart_GetNativeArgument(arguments, 0);
+ if (Dart_IsNull(object)) {
+ Dart_SetReturnValue(arguments, Dart_GetNativeArgument(arguments, 1));
+ } else {
+ Dart_SetReturnValue(arguments, object);
+ }
+}
+
+
+void ThrowMeTheBall(Dart_NativeArguments arguments) {
+ Dart_Handle object = Dart_GetNativeArgument(arguments, 0);
+ Dart_ThrowException(object);
+}
+
+
+/* Native resolver for the extension library. */
+Dart_NativeFunction ResolveName(Dart_Handle name, int argc) {
+ /* assert(Dart_IsString(name)); */
+ const char* c_name;
+ Dart_Handle check_error;
+
+ check_error = Dart_StringToCString(name, &c_name);
+ if (Dart_IsError(check_error)) {
+ Dart_PropagateError(check_error);
+ }
+ if ((strcmp("TestExtension_IfNull", c_name) == 0) && (argc == 2)) {
+ return IfNull;
+ }
+ if ((strcmp("TestExtension_ThrowMeTheBall", c_name) == 0) && (argc == 1)) {
+ return ThrowMeTheBall;
+ }
+ return NULL;
+}
+
+
+/* Native entry point for the extension library. */
+DART_EXPORT Dart_Handle test_extension_Init(Dart_Handle parent_library) {
+ Dart_Handle result_code;
+ if (Dart_IsError(parent_library)) {
+ return parent_library;
+ }
+
+ result_code = Dart_SetNativeResolver(parent_library, ResolveName);
+ if (Dart_IsError(result_code)) {
+ return result_code;
+ }
+
+ return parent_library;
+}
Property changes on: dart/runtime/bin/test_extension.c
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698