| OLD | NEW |
| 1 /* Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 /* Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 * for details. All rights reserved. Use of this source code is governed by a | 2 * for details. All rights reserved. Use of this source code is governed by a |
| 3 * BSD-style license that can be found in the LICENSE file. | 3 * BSD-style license that can be found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #include <assert.h> | 5 #include <assert.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 | 27 |
| 28 void ThrowMeTheBall(Dart_NativeArguments arguments) { | 28 void ThrowMeTheBall(Dart_NativeArguments arguments) { |
| 29 Dart_Handle object = Dart_GetNativeArgument(arguments, 0); | 29 Dart_Handle object = Dart_GetNativeArgument(arguments, 0); |
| 30 Dart_ThrowException(object); | 30 Dart_ThrowException(object); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 /* Native resolver for the extension library. */ | 34 /* Native resolver for the extension library. */ |
| 35 Dart_NativeFunction ResolveName(Dart_Handle name, int argc) { | 35 Dart_NativeFunction ResolveName(Dart_Handle name, int argc) { |
| 36 assert(Dart_IsString(name)); | 36 /* assert(Dart_IsString(name)); */ |
| 37 const char* cname; | 37 const char* c_name; |
| 38 Dart_Handle check_error; | 38 Dart_Handle check_error; |
| 39 | 39 |
| 40 check_error = Dart_StringToCString(name, &cname); | 40 check_error = Dart_StringToCString(name, &c_name); |
| 41 if (Dart_IsError(check_error)) { | 41 if (Dart_IsError(check_error)) { |
| 42 Dart_PropagateError(check_error); | 42 Dart_PropagateError(check_error); |
| 43 } | 43 } |
| 44 if ((strcmp("TestExtension_IfNull", cname) == 0) && (argc == 2)) { | 44 if ((strcmp("TestExtension_IfNull", c_name) == 0) && (argc == 2)) { |
| 45 return IfNull; | 45 return IfNull; |
| 46 } | 46 } |
| 47 if ((strcmp("TestExtension_ThrowMeTheBall", cname) == 0) && (argc == 1)) { | 47 if ((strcmp("TestExtension_ThrowMeTheBall", c_name) == 0) && (argc == 1)) { |
| 48 return ThrowMeTheBall; | 48 return ThrowMeTheBall; |
| 49 } | 49 } |
| 50 return NULL; | 50 return NULL; |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 /* Native entry point for the extension library. */ | 54 /* Native entry point for the extension library. */ |
| 55 DART_EXPORT Dart_Handle test_extension_Init(Dart_Handle parent_library) { | 55 DART_EXPORT Dart_Handle test_extension_Init(Dart_Handle parent_library) { |
| 56 if (Dart_IsError(parent_library)) { return parent_library; } | 56 if (Dart_IsError(parent_library)) { return parent_library; } |
| 57 | 57 |
| 58 Dart_Handle result_code = Dart_SetNativeResolver(parent_library, ResolveName); | 58 Dart_Handle result_code = Dart_SetNativeResolver(parent_library, ResolveName); |
| 59 if (Dart_IsError(result_code)) return result_code; | 59 if (Dart_IsError(result_code)) return result_code; |
| 60 | 60 |
| 61 return parent_library; | 61 return parent_library; |
| 62 } | 62 } |
| 63 | 63 |
| OLD | NEW |