| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 #include "bin/builtin.h" | 10 #include "bin/builtin.h" |
| 11 #include "bin/dartutils.h" | 11 #include "bin/dartutils.h" |
| 12 | 12 |
| 13 // The string on the next line will be filled in with the contents of the | 13 // The string on the next line will be filled in with the contents of the |
| 14 // builtin.dart file. | 14 // builtin.dart file. |
| 15 // This string forms the content of builtin functionality which is injected | 15 // This string forms the content of builtin functionality which is injected |
| 16 // into standalone dart to provide some test/debug functionality. | 16 // into standalone dart to provide some test/debug functionality. |
| 17 static const char Builtin_source_[] = { | 17 static const char Builtin_source_[] = { |
| 18 {{DART_SOURCE}} | 18 {{DART_SOURCE}} |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 | 21 |
| 22 // List all native functions implemented in standalone dart that is used | 22 // List all native functions implemented in standalone dart that is used |
| 23 // to inject additional functionality e.g: Logger, file I/O, socket I/O etc. | 23 // to inject additional functionality e.g: Logger, file I/O, socket I/O etc. |
| 24 #define BUILTIN_NATIVE_LIST(V) \ | 24 #define BUILTIN_NATIVE_LIST(V) \ |
| 25 V(Logger_PrintString, 1) \ | |
| 26 V(Exit, 1) \ | |
| 27 V(Directory_List, 7) \ | 25 V(Directory_List, 7) \ |
| 28 V(Directory_Exists, 2) \ | 26 V(Directory_Exists, 2) \ |
| 29 V(Directory_Create, 2) \ | 27 V(Directory_Create, 2) \ |
| 30 V(Directory_Delete, 2) \ | 28 V(Directory_Delete, 2) \ |
| 29 V(EventHandler_Start, 1) \ |
| 30 V(EventHandler_SendData, 4) \ |
| 31 V(Exit, 1) \ |
| 31 V(File_Open, 2) \ | 32 V(File_Open, 2) \ |
| 32 V(File_Exists, 1) \ | 33 V(File_Exists, 1) \ |
| 33 V(File_Close, 1) \ | 34 V(File_Close, 1) \ |
| 34 V(File_ReadByte, 1) \ | 35 V(File_ReadByte, 1) \ |
| 35 V(File_WriteByte, 2) \ | 36 V(File_WriteByte, 2) \ |
| 36 V(File_WriteString, 2) \ | 37 V(File_WriteString, 2) \ |
| 37 V(File_ReadList, 4) \ | 38 V(File_ReadList, 4) \ |
| 38 V(File_WriteList, 4) \ | 39 V(File_WriteList, 4) \ |
| 39 V(File_Position, 1) \ | 40 V(File_Position, 1) \ |
| 40 V(File_Length, 1) \ | 41 V(File_Length, 1) \ |
| 41 V(File_Flush, 1) \ | 42 V(File_Flush, 1) \ |
| 42 V(File_Create, 1) \ | 43 V(File_Create, 1) \ |
| 43 V(File_FullPath, 1) \ | 44 V(File_FullPath, 1) \ |
| 44 V(EventHandler_Start, 1) \ | 45 V(Logger_PrintString, 1) \ |
| 45 V(EventHandler_SendData, 4) \ | 46 V(Platform_NumberOfProcessors, 0) \ |
| 47 V(Platform_OperatingSystem, 0) \ |
| 48 V(Platform_PathSeparator, 0) \ |
| 46 V(Process_Start, 8) \ | 49 V(Process_Start, 8) \ |
| 47 V(Process_Kill, 2) \ | 50 V(Process_Kill, 2) \ |
| 48 V(Process_Exit, 2) \ | 51 V(Process_Exit, 2) \ |
| 52 V(ServerSocket_CreateBindListen, 4) \ |
| 53 V(ServerSocket_Accept, 2) \ |
| 49 V(Socket_CreateConnect, 3) \ | 54 V(Socket_CreateConnect, 3) \ |
| 50 V(Socket_Available, 1) \ | 55 V(Socket_Available, 1) \ |
| 51 V(Socket_ReadList, 4) \ | 56 V(Socket_ReadList, 4) \ |
| 52 V(Socket_WriteList, 4) \ | 57 V(Socket_WriteList, 4) \ |
| 53 V(Socket_GetPort, 1) \ | 58 V(Socket_GetPort, 1) |
| 54 V(ServerSocket_CreateBindListen, 4) \ | |
| 55 V(ServerSocket_Accept, 2) \ | |
| 56 | 59 |
| 57 | 60 |
| 58 BUILTIN_NATIVE_LIST(DECLARE_FUNCTION); | 61 BUILTIN_NATIVE_LIST(DECLARE_FUNCTION); |
| 59 | 62 |
| 60 static struct NativeEntries { | 63 static struct NativeEntries { |
| 61 const char* name_; | 64 const char* name_; |
| 62 Dart_NativeFunction function_; | 65 Dart_NativeFunction function_; |
| 63 int argument_count_; | 66 int argument_count_; |
| 64 } BuiltinEntries[] = { | 67 } BuiltinEntries[] = { |
| 65 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) | 68 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 142 } |
| 140 | 143 |
| 141 | 144 |
| 142 void Builtin_SetNativeResolver() { | 145 void Builtin_SetNativeResolver() { |
| 143 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); | 146 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); |
| 144 Dart_Handle builtin_lib = Dart_LookupLibrary(url); | 147 Dart_Handle builtin_lib = Dart_LookupLibrary(url); |
| 145 ASSERT(Dart_IsValid(builtin_lib)); | 148 ASSERT(Dart_IsValid(builtin_lib)); |
| 146 Dart_Handle result = Dart_SetNativeResolver(builtin_lib, native_lookup); | 149 Dart_Handle result = Dart_SetNativeResolver(builtin_lib, native_lookup); |
| 147 ASSERT(Dart_IsValid(result)); | 150 ASSERT(Dart_IsValid(result)); |
| 148 } | 151 } |
| OLD | NEW |