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/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 29 matching lines...) Expand all Loading... |
40 V(Socket_GetError, 1) \ | 40 V(Socket_GetError, 1) \ |
41 V(Socket_GetStdioHandle, 2) \ | 41 V(Socket_GetStdioHandle, 2) \ |
42 V(Socket_NewServicePort, 0) \ | 42 V(Socket_NewServicePort, 0) \ |
43 V(SecureSocket_Connect, 5) \ | 43 V(SecureSocket_Connect, 5) \ |
44 V(SecureSocket_Destroy, 1) \ | 44 V(SecureSocket_Destroy, 1) \ |
45 V(SecureSocket_Handshake, 1) \ | 45 V(SecureSocket_Handshake, 1) \ |
46 V(SecureSocket_Init, 1) \ | 46 V(SecureSocket_Init, 1) \ |
47 V(SecureSocket_ProcessBuffer, 2) \ | 47 V(SecureSocket_ProcessBuffer, 2) \ |
48 V(SecureSocket_RegisterBadCertificateCallback, 2) \ | 48 V(SecureSocket_RegisterBadCertificateCallback, 2) \ |
49 V(SecureSocket_RegisterHandshakeCompleteCallback, 2) \ | 49 V(SecureSocket_RegisterHandshakeCompleteCallback, 2) \ |
50 V(SecureSocket_InitializeLibrary, 3) | 50 V(SecureSocket_InitializeLibrary, 3) \ |
| 51 V(SystemEncodingToString, 1) \ |
| 52 V(StringToSystemEncoding, 1) |
| 53 |
51 | 54 |
52 IO_NATIVE_LIST(DECLARE_FUNCTION); | 55 IO_NATIVE_LIST(DECLARE_FUNCTION); |
53 | 56 |
54 static struct NativeEntries { | 57 static struct NativeEntries { |
55 const char* name_; | 58 const char* name_; |
56 Dart_NativeFunction function_; | 59 Dart_NativeFunction function_; |
57 int argument_count_; | 60 int argument_count_; |
58 } IOEntries[] = { | 61 } IOEntries[] = { |
59 IO_NATIVE_LIST(REGISTER_FUNCTION) | 62 IO_NATIVE_LIST(REGISTER_FUNCTION) |
60 }; | 63 }; |
61 | 64 |
62 | 65 |
63 Dart_NativeFunction IONativeLookup(Dart_Handle name, | 66 Dart_NativeFunction IONativeLookup(Dart_Handle name, |
64 int argument_count) { | 67 int argument_count) { |
65 const char* function_name = NULL; | 68 const char* function_name = NULL; |
66 Dart_Handle result = Dart_StringToCString(name, &function_name); | 69 Dart_Handle result = Dart_StringToCString(name, &function_name); |
67 DART_CHECK_VALID(result); | 70 DART_CHECK_VALID(result); |
68 ASSERT(function_name != NULL); | 71 ASSERT(function_name != NULL); |
69 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); | 72 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); |
70 for (int i = 0; i < num_entries; i++) { | 73 for (int i = 0; i < num_entries; i++) { |
71 struct NativeEntries* entry = &(IOEntries[i]); | 74 struct NativeEntries* entry = &(IOEntries[i]); |
72 if (!strcmp(function_name, entry->name_) && | 75 if (!strcmp(function_name, entry->name_) && |
73 (entry->argument_count_ == argument_count)) { | 76 (entry->argument_count_ == argument_count)) { |
74 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 77 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
75 } | 78 } |
76 } | 79 } |
77 return NULL; | 80 return NULL; |
78 } | 81 } |
OLD | NEW |