| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 static Dart_NativeFunction native_lookup(Dart_Handle name, | 79 static Dart_NativeFunction native_lookup(Dart_Handle name, |
| 80 int argument_count) { | 80 int argument_count) { |
| 81 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); | 81 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); |
| 82 ASSERT(obj.IsString()); | 82 ASSERT(obj.IsString()); |
| 83 const char* function_name = obj.ToCString(); | 83 const char* function_name = obj.ToCString(); |
| 84 ASSERT(function_name != NULL); | 84 ASSERT(function_name != NULL); |
| 85 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); | 85 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); |
| 86 for (int i = 0; i < num_entries; i++) { | 86 for (int i = 0; i < num_entries; i++) { |
| 87 struct NativeEntries* entry = &(BuiltinEntries[i]); | 87 struct NativeEntries* entry = &(BuiltinEntries[i]); |
| 88 if (!strcmp(function_name, entry->name_)) { | 88 if (!strcmp(function_name, entry->name_) && |
| 89 (argument_count == entry->argument_count_)) { |
| 89 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 90 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 return NULL; | 93 return NULL; |
| 93 } | 94 } |
| 94 | 95 |
| 95 | 96 |
| 96 // Unit test case to verify unhandled exceptions. | 97 // Unit test case to verify unhandled exceptions. |
| 97 TEST_CASE(UnhandledExceptions) { | 98 TEST_CASE(UnhandledExceptions) { |
| 98 const char* kScriptChars = | 99 const char* kScriptChars = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 124 " UnhandledExceptions.equals(3, Second.method3(1));\n" | 125 " UnhandledExceptions.equals(3, Second.method3(1));\n" |
| 125 "}"; | 126 "}"; |
| 126 Dart_Handle lib = TestCase::LoadTestScript( | 127 Dart_Handle lib = TestCase::LoadTestScript( |
| 127 kScriptChars, | 128 kScriptChars, |
| 128 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); | 129 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); |
| 129 EXPECT_VALID(Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL)); | 130 EXPECT_VALID(Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL)); |
| 130 } | 131 } |
| 131 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 132 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 132 | 133 |
| 133 } // namespace dart | 134 } // namespace dart |
| OLD | NEW |