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 23 matching lines...) Expand all Loading... |
34 bool* auto_setup_scope) { | 34 bool* auto_setup_scope) { |
35 const char* function_name = NULL; | 35 const char* function_name = NULL; |
36 Dart_Handle result = Dart_StringToCString(name, &function_name); | 36 Dart_Handle result = Dart_StringToCString(name, &function_name); |
37 DART_CHECK_VALID(result); | 37 DART_CHECK_VALID(result); |
38 ASSERT(function_name != NULL); | 38 ASSERT(function_name != NULL); |
39 ASSERT(auto_setup_scope != NULL); | 39 ASSERT(auto_setup_scope != NULL); |
40 *auto_setup_scope = true; | 40 *auto_setup_scope = true; |
41 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); | 41 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); |
42 for (int i = 0; i < num_entries; i++) { | 42 for (int i = 0; i < num_entries; i++) { |
43 struct NativeEntries* entry = &(BuiltinEntries[i]); | 43 struct NativeEntries* entry = &(BuiltinEntries[i]); |
44 if (!strcmp(function_name, entry->name_) && | 44 if ((strcmp(function_name, entry->name_) == 0) && |
45 (entry->argument_count_ == argument_count)) { | 45 (entry->argument_count_ == argument_count)) { |
46 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 46 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
47 } | 47 } |
48 } | 48 } |
49 return IONativeLookup(name, argument_count, auto_setup_scope); | 49 return IONativeLookup(name, argument_count, auto_setup_scope); |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) { | 53 const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) { |
54 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); | 54 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); |
(...skipping 24 matching lines...) Expand all Loading... |
79 } else { | 79 } else { |
80 fwrite(chars, sizeof(*chars), length, stdout); | 80 fwrite(chars, sizeof(*chars), length, stdout); |
81 } | 81 } |
82 fputc('\n', stdout); | 82 fputc('\n', stdout); |
83 fflush(stdout); | 83 fflush(stdout); |
84 Dart_ExitScope(); | 84 Dart_ExitScope(); |
85 } | 85 } |
86 | 86 |
87 } // namespace bin | 87 } // namespace bin |
88 } // namespace dart | 88 } // namespace dart |
OLD | NEW |