| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/bootstrap.h" | 5 #include "vm/bootstrap.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/bootstrap_natives.h" | 9 #include "vm/bootstrap_natives.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 int argument_count) { | 29 int argument_count) { |
| 30 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); | 30 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); |
| 31 if (!obj.IsString()) { | 31 if (!obj.IsString()) { |
| 32 return NULL; | 32 return NULL; |
| 33 } | 33 } |
| 34 const char* function_name = obj.ToCString(); | 34 const char* function_name = obj.ToCString(); |
| 35 ASSERT(function_name != NULL); | 35 ASSERT(function_name != NULL); |
| 36 int num_entries = sizeof(BootStrapEntries) / sizeof(struct NativeEntries); | 36 int num_entries = sizeof(BootStrapEntries) / sizeof(struct NativeEntries); |
| 37 for (int i = 0; i < num_entries; i++) { | 37 for (int i = 0; i < num_entries; i++) { |
| 38 struct NativeEntries* entry = &(BootStrapEntries[i]); | 38 struct NativeEntries* entry = &(BootStrapEntries[i]); |
| 39 if (!strncmp(function_name, entry->name_, strlen(entry->name_))) { | 39 if (!strncmp(function_name, entry->name_, strlen(entry->name_)) && |
| 40 if (entry->argument_count_ == argument_count) { | 40 (entry->argument_count_ == argument_count)) { |
| 41 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 41 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
| 42 } else { | |
| 43 // Wrong number of arguments. | |
| 44 // TODO(regis): Should we pass a buffer for error reporting? | |
| 45 return NULL; | |
| 46 } | |
| 47 } | 42 } |
| 48 } | 43 } |
| 49 return NULL; | 44 return NULL; |
| 50 } | 45 } |
| 51 | 46 |
| 52 | 47 |
| 53 void Bootstrap::SetupNativeResolver() { | 48 void Bootstrap::SetupNativeResolver() { |
| 54 Library& library = Library::Handle(); | 49 Library& library = Library::Handle(); |
| 55 | 50 |
| 56 library = Library::CoreLibrary(); | 51 library = Library::CoreLibrary(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 68 library.set_native_entry_resolver( | 63 library.set_native_entry_resolver( |
| 69 reinterpret_cast<Dart_NativeEntryResolver>(NativeLookup)); | 64 reinterpret_cast<Dart_NativeEntryResolver>(NativeLookup)); |
| 70 | 65 |
| 71 library = Library::IsolateLibrary(); | 66 library = Library::IsolateLibrary(); |
| 72 ASSERT(!library.IsNull()); | 67 ASSERT(!library.IsNull()); |
| 73 library.set_native_entry_resolver( | 68 library.set_native_entry_resolver( |
| 74 reinterpret_cast<Dart_NativeEntryResolver>(NativeLookup)); | 69 reinterpret_cast<Dart_NativeEntryResolver>(NativeLookup)); |
| 75 } | 70 } |
| 76 | 71 |
| 77 } // namespace dart | 72 } // namespace dart |
| OLD | NEW |