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 21 matching lines...) Expand all Loading... |
32 V(ServerSocket_Accept, 2) \ | 32 V(ServerSocket_Accept, 2) \ |
33 V(Socket_CreateConnect, 3) \ | 33 V(Socket_CreateConnect, 3) \ |
34 V(Socket_Available, 1) \ | 34 V(Socket_Available, 1) \ |
35 V(Socket_Read, 2) \ | 35 V(Socket_Read, 2) \ |
36 V(Socket_ReadList, 4) \ | 36 V(Socket_ReadList, 4) \ |
37 V(Socket_WriteList, 4) \ | 37 V(Socket_WriteList, 4) \ |
38 V(Socket_GetPort, 1) \ | 38 V(Socket_GetPort, 1) \ |
39 V(Socket_GetRemotePeer, 1) \ | 39 V(Socket_GetRemotePeer, 1) \ |
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 | 43 V(TlsSocket_Connect, 3) \ |
| 44 V(TlsSocket_Destroy, 1) \ |
| 45 V(TlsSocket_Handshake, 1) \ |
| 46 V(TlsSocket_Init, 1) \ |
| 47 V(TlsSocket_ProcessBuffer, 2) \ |
| 48 V(TlsSocket_RegisterHandshakeCompleteCallback, 2) \ |
| 49 V(TlsSocket_SetCertificateDatabase, 1) |
44 | 50 |
45 IO_NATIVE_LIST(DECLARE_FUNCTION); | 51 IO_NATIVE_LIST(DECLARE_FUNCTION); |
46 | 52 |
47 static struct NativeEntries { | 53 static struct NativeEntries { |
48 const char* name_; | 54 const char* name_; |
49 Dart_NativeFunction function_; | 55 Dart_NativeFunction function_; |
50 int argument_count_; | 56 int argument_count_; |
51 } IOEntries[] = { | 57 } IOEntries[] = { |
52 IO_NATIVE_LIST(REGISTER_FUNCTION) | 58 IO_NATIVE_LIST(REGISTER_FUNCTION) |
53 }; | 59 }; |
54 | 60 |
55 | 61 |
56 Dart_NativeFunction IONativeLookup(Dart_Handle name, | 62 Dart_NativeFunction IONativeLookup(Dart_Handle name, |
57 int argument_count) { | 63 int argument_count) { |
58 const char* function_name = NULL; | 64 const char* function_name = NULL; |
59 Dart_Handle result = Dart_StringToCString(name, &function_name); | 65 Dart_Handle result = Dart_StringToCString(name, &function_name); |
60 DART_CHECK_VALID(result); | 66 DART_CHECK_VALID(result); |
61 ASSERT(function_name != NULL); | 67 ASSERT(function_name != NULL); |
62 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); | 68 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); |
63 for (int i = 0; i < num_entries; i++) { | 69 for (int i = 0; i < num_entries; i++) { |
64 struct NativeEntries* entry = &(IOEntries[i]); | 70 struct NativeEntries* entry = &(IOEntries[i]); |
65 if (!strcmp(function_name, entry->name_) && | 71 if (!strcmp(function_name, entry->name_) && |
66 (entry->argument_count_ == argument_count)) { | 72 (entry->argument_count_ == argument_count)) { |
67 return reinterpret_cast<Dart_NativeFunction>(entry->function_); | 73 return reinterpret_cast<Dart_NativeFunction>(entry->function_); |
68 } | 74 } |
69 } | 75 } |
70 return NULL; | 76 return NULL; |
71 } | 77 } |
OLD | NEW |