OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/io_natives.h" | 5 #include "bin/io_natives.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "bin/builtin.h" | 10 #include "bin/builtin.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 V(X509_EndValidity, 1) | 170 V(X509_EndValidity, 1) |
171 | 171 |
172 IO_NATIVE_LIST(DECLARE_FUNCTION); | 172 IO_NATIVE_LIST(DECLARE_FUNCTION); |
173 | 173 |
174 static struct NativeEntries { | 174 static struct NativeEntries { |
175 const char* name_; | 175 const char* name_; |
176 Dart_NativeFunction function_; | 176 Dart_NativeFunction function_; |
177 int argument_count_; | 177 int argument_count_; |
178 } IOEntries[] = {IO_NATIVE_LIST(REGISTER_FUNCTION)}; | 178 } IOEntries[] = {IO_NATIVE_LIST(REGISTER_FUNCTION)}; |
179 | 179 |
180 | |
181 Dart_NativeFunction IONativeLookup(Dart_Handle name, | 180 Dart_NativeFunction IONativeLookup(Dart_Handle name, |
182 int argument_count, | 181 int argument_count, |
183 bool* auto_setup_scope) { | 182 bool* auto_setup_scope) { |
184 const char* function_name = NULL; | 183 const char* function_name = NULL; |
185 Dart_Handle result = Dart_StringToCString(name, &function_name); | 184 Dart_Handle result = Dart_StringToCString(name, &function_name); |
186 DART_CHECK_VALID(result); | 185 DART_CHECK_VALID(result); |
187 ASSERT(function_name != NULL); | 186 ASSERT(function_name != NULL); |
188 ASSERT(auto_setup_scope != NULL); | 187 ASSERT(auto_setup_scope != NULL); |
189 *auto_setup_scope = true; | 188 *auto_setup_scope = true; |
190 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); | 189 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); |
191 for (int i = 0; i < num_entries; i++) { | 190 for (int i = 0; i < num_entries; i++) { |
192 struct NativeEntries* entry = &(IOEntries[i]); | 191 struct NativeEntries* entry = &(IOEntries[i]); |
193 if ((strcmp(function_name, entry->name_) == 0) && | 192 if ((strcmp(function_name, entry->name_) == 0) && |
194 (entry->argument_count_ == argument_count)) { | 193 (entry->argument_count_ == argument_count)) { |
195 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 194 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
196 } | 195 } |
197 } | 196 } |
198 return NULL; | 197 return NULL; |
199 } | 198 } |
200 | 199 |
201 | |
202 const uint8_t* IONativeSymbol(Dart_NativeFunction nf) { | 200 const uint8_t* IONativeSymbol(Dart_NativeFunction nf) { |
203 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); | 201 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); |
204 for (int i = 0; i < num_entries; i++) { | 202 for (int i = 0; i < num_entries; i++) { |
205 struct NativeEntries* entry = &(IOEntries[i]); | 203 struct NativeEntries* entry = &(IOEntries[i]); |
206 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { | 204 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { |
207 return reinterpret_cast<const uint8_t*>(entry->name_); | 205 return reinterpret_cast<const uint8_t*>(entry->name_); |
208 } | 206 } |
209 } | 207 } |
210 return NULL; | 208 return NULL; |
211 } | 209 } |
212 | 210 |
213 } // namespace bin | 211 } // namespace bin |
214 } // namespace dart | 212 } // namespace dart |
OLD | NEW |