| 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" |
| 11 #include "bin/dartutils.h" | 11 #include "bin/dartutils.h" |
| 12 #include "include/dart_api.h" | 12 #include "include/dart_api.h" |
| 13 #include "platform/assert.h" | 13 #include "platform/assert.h" |
| 14 | 14 |
| 15 | |
| 16 namespace dart { | 15 namespace dart { |
| 17 namespace bin { | 16 namespace bin { |
| 18 | 17 |
| 19 // Lists the native functions implementing advanced dart:io classes. | 18 // Lists the native functions implementing advanced dart:io classes. |
| 20 // Some classes, like File and Directory, list their implementations in | 19 // Some classes, like File and Directory, list their implementations in |
| 21 // builtin_natives.cc instead. | 20 // builtin_natives.cc instead. |
| 22 #define IO_NATIVE_LIST(V) \ | 21 #define IO_NATIVE_LIST(V) \ |
| 23 V(Crypto_GetRandomBytes, 1) \ | 22 V(Crypto_GetRandomBytes, 1) \ |
| 24 V(Directory_Exists, 1) \ | 23 V(Directory_Exists, 1) \ |
| 25 V(Directory_Create, 1) \ | 24 V(Directory_Create, 1) \ |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 bool* auto_setup_scope) { | 161 bool* auto_setup_scope) { |
| 163 const char* function_name = NULL; | 162 const char* function_name = NULL; |
| 164 Dart_Handle result = Dart_StringToCString(name, &function_name); | 163 Dart_Handle result = Dart_StringToCString(name, &function_name); |
| 165 DART_CHECK_VALID(result); | 164 DART_CHECK_VALID(result); |
| 166 ASSERT(function_name != NULL); | 165 ASSERT(function_name != NULL); |
| 167 ASSERT(auto_setup_scope != NULL); | 166 ASSERT(auto_setup_scope != NULL); |
| 168 *auto_setup_scope = true; | 167 *auto_setup_scope = true; |
| 169 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); | 168 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); |
| 170 for (int i = 0; i < num_entries; i++) { | 169 for (int i = 0; i < num_entries; i++) { |
| 171 struct NativeEntries* entry = &(IOEntries[i]); | 170 struct NativeEntries* entry = &(IOEntries[i]); |
| 172 if (!strcmp(function_name, entry->name_) && | 171 if ((strcmp(function_name, entry->name_) == 0) && |
| 173 (entry->argument_count_ == argument_count)) { | 172 (entry->argument_count_ == argument_count)) { |
| 174 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 173 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
| 175 } | 174 } |
| 176 } | 175 } |
| 177 return NULL; | 176 return NULL; |
| 178 } | 177 } |
| 179 | 178 |
| 180 | 179 |
| 181 const uint8_t* IONativeSymbol(Dart_NativeFunction nf) { | 180 const uint8_t* IONativeSymbol(Dart_NativeFunction nf) { |
| 182 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); | 181 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); |
| 183 for (int i = 0; i < num_entries; i++) { | 182 for (int i = 0; i < num_entries; i++) { |
| 184 struct NativeEntries* entry = &(IOEntries[i]); | 183 struct NativeEntries* entry = &(IOEntries[i]); |
| 185 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { | 184 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { |
| 186 return reinterpret_cast<const uint8_t*>(entry->name_); | 185 return reinterpret_cast<const uint8_t*>(entry->name_); |
| 187 } | 186 } |
| 188 } | 187 } |
| 189 return NULL; | 188 return NULL; |
| 190 } | 189 } |
| 191 | 190 |
| 192 } // namespace bin | 191 } // namespace bin |
| 193 } // namespace dart | 192 } // namespace dart |
| OLD | NEW |