| 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 "bin/builtin.h" | 5 #include "bin/builtin.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, | 82 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, |
| 83 int argument_count) { | 83 int argument_count) { |
| 84 const char* function_name = NULL; | 84 const char* function_name = NULL; |
| 85 Dart_Handle result = Dart_StringToCString(name, &function_name); | 85 Dart_Handle result = Dart_StringToCString(name, &function_name); |
| 86 DART_CHECK_VALID(result); | 86 DART_CHECK_VALID(result); |
| 87 ASSERT(function_name != NULL); | 87 ASSERT(function_name != NULL); |
| 88 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); | 88 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); |
| 89 for (int i = 0; i < num_entries; i++) { | 89 for (int i = 0; i < num_entries; i++) { |
| 90 struct NativeEntries* entry = &(BuiltinEntries[i]); | 90 struct NativeEntries* entry = &(BuiltinEntries[i]); |
| 91 if (!strcmp(function_name, entry->name_)) { | 91 if (!strcmp(function_name, entry->name_) && |
| 92 if (entry->argument_count_ == argument_count) { | 92 (entry->argument_count_ == argument_count)) { |
| 93 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 93 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
| 94 } else { | |
| 95 // Wrong number of arguments. | |
| 96 // TODO(regis): Should we pass a buffer for error reporting? | |
| 97 return NULL; | |
| 98 } | |
| 99 } | 94 } |
| 100 } | 95 } |
| 101 return NULL; | 96 return NULL; |
| 102 } | 97 } |
| 103 | 98 |
| 104 | 99 |
| 105 // Implementation of native functions which are used for some | 100 // Implementation of native functions which are used for some |
| 106 // test/debug functionality in standalone dart mode. | 101 // test/debug functionality in standalone dart mode. |
| 107 | 102 |
| 108 void Builtin::PrintString(FILE* out, Dart_Handle str) { | 103 void Builtin::PrintString(FILE* out, Dart_Handle str) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 Dart_Handle isolate_lib = Dart_LookupLibrary(url); | 140 Dart_Handle isolate_lib = Dart_LookupLibrary(url); |
| 146 DART_CHECK_VALID(isolate_lib); | 141 DART_CHECK_VALID(isolate_lib); |
| 147 Dart_Handle timer_closure = | 142 Dart_Handle timer_closure = |
| 148 Dart_Invoke(io_lib, Dart_NewString("_getTimerFactoryClosure"), 0, NULL); | 143 Dart_Invoke(io_lib, Dart_NewString("_getTimerFactoryClosure"), 0, NULL); |
| 149 Dart_Handle args[1]; | 144 Dart_Handle args[1]; |
| 150 args[0] = timer_closure; | 145 args[0] = timer_closure; |
| 151 DART_CHECK_VALID(Dart_Invoke(isolate_lib, | 146 DART_CHECK_VALID(Dart_Invoke(isolate_lib, |
| 152 Dart_NewString("_setTimerFactoryClosure"), | 147 Dart_NewString("_setTimerFactoryClosure"), |
| 153 1, args)); | 148 1, args)); |
| 154 } | 149 } |
| OLD | NEW |