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