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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 static struct NativeEntries { | 22 static struct NativeEntries { |
23 const char* name_; | 23 const char* name_; |
24 Dart_NativeFunction function_; | 24 Dart_NativeFunction function_; |
25 int argument_count_; | 25 int argument_count_; |
26 } BuiltinEntries[] = { | 26 } BuiltinEntries[] = { |
27 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) | 27 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) |
28 }; | 28 }; |
29 | 29 |
30 | 30 |
31 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, | 31 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, |
32 int argument_count) { | 32 int argument_count, |
| 33 bool* auto_setup_scope) { |
33 const char* function_name = NULL; | 34 const char* function_name = NULL; |
34 Dart_Handle result = Dart_StringToCString(name, &function_name); | 35 Dart_Handle result = Dart_StringToCString(name, &function_name); |
35 DART_CHECK_VALID(result); | 36 DART_CHECK_VALID(result); |
36 ASSERT(function_name != NULL); | 37 ASSERT(function_name != NULL); |
| 38 ASSERT(auto_setup_scope != NULL); |
| 39 *auto_setup_scope = true; |
37 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); | 40 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); |
38 for (int i = 0; i < num_entries; i++) { | 41 for (int i = 0; i < num_entries; i++) { |
39 struct NativeEntries* entry = &(BuiltinEntries[i]); | 42 struct NativeEntries* entry = &(BuiltinEntries[i]); |
40 if (!strcmp(function_name, entry->name_) && | 43 if (!strcmp(function_name, entry->name_) && |
41 (entry->argument_count_ == argument_count)) { | 44 (entry->argument_count_ == argument_count)) { |
42 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 45 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
43 } | 46 } |
44 } | 47 } |
45 return NULL; | 48 return NULL; |
46 } | 49 } |
(...skipping 16 matching lines...) Expand all Loading... |
63 } else { | 66 } else { |
64 fwrite(chars, sizeof(*chars), length, stdout); | 67 fwrite(chars, sizeof(*chars), length, stdout); |
65 } | 68 } |
66 fputc('\n', stdout); | 69 fputc('\n', stdout); |
67 fflush(stdout); | 70 fflush(stdout); |
68 Dart_ExitScope(); | 71 Dart_ExitScope(); |
69 } | 72 } |
70 | 73 |
71 } // namespace bin | 74 } // namespace bin |
72 } // namespace dart | 75 } // namespace dart |
OLD | NEW |