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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 V(File_Delete, 1) \ | 57 V(File_Delete, 1) \ |
58 V(File_DeleteLink, 1) \ | 58 V(File_DeleteLink, 1) \ |
59 V(File_Rename, 2) \ | 59 V(File_Rename, 2) \ |
60 V(File_Copy, 2) \ | 60 V(File_Copy, 2) \ |
61 V(File_RenameLink, 2) \ | 61 V(File_RenameLink, 2) \ |
62 V(File_ResolveSymbolicLinks, 1) \ | 62 V(File_ResolveSymbolicLinks, 1) \ |
63 V(File_OpenStdio, 1) \ | 63 V(File_OpenStdio, 1) \ |
64 V(File_GetStdioHandleType, 1) \ | 64 V(File_GetStdioHandleType, 1) \ |
65 V(File_GetType, 2) \ | 65 V(File_GetType, 2) \ |
66 V(File_AreIdentical, 2) \ | 66 V(File_AreIdentical, 2) \ |
67 V(Logger_PrintString, 1) \ | 67 V(Builtin_PrintString, 1) \ |
68 V(Builtin_LoadScript, 4) \ | 68 V(Builtin_LoadSource, 4) \ |
69 V(Builtin_AsyncLoadError, 3) \ | 69 V(Builtin_AsyncLoadError, 3) \ |
70 V(Builtin_DoneLoading, 0) \ | 70 V(Builtin_DoneLoading, 0) \ |
71 V(Builtin_NativeLibraryExtension, 0) \ | 71 V(Builtin_NativeLibraryExtension, 0) \ |
72 V(Builtin_GetCurrentDirectory, 0) \ | 72 V(Builtin_GetCurrentDirectory, 0) \ |
73 | 73 |
74 | 74 |
75 BUILTIN_NATIVE_LIST(DECLARE_FUNCTION); | 75 BUILTIN_NATIVE_LIST(DECLARE_FUNCTION); |
76 | 76 |
77 static struct NativeEntries { | 77 static struct NativeEntries { |
78 const char* name_; | 78 const char* name_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { | 114 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { |
115 return reinterpret_cast<const uint8_t*>(entry->name_); | 115 return reinterpret_cast<const uint8_t*>(entry->name_); |
116 } | 116 } |
117 } | 117 } |
118 return IONativeSymbol(nf); | 118 return IONativeSymbol(nf); |
119 } | 119 } |
120 | 120 |
121 | 121 |
122 // Implementation of native functions which are used for some | 122 // Implementation of native functions which are used for some |
123 // test/debug functionality in standalone dart mode. | 123 // test/debug functionality in standalone dart mode. |
124 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { | 124 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) { |
125 intptr_t length = 0; | 125 intptr_t length = 0; |
126 uint8_t* chars = NULL; | 126 uint8_t* chars = NULL; |
127 Dart_Handle str = Dart_GetNativeArgument(args, 0); | 127 Dart_Handle str = Dart_GetNativeArgument(args, 0); |
128 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); | 128 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); |
129 if (Dart_IsError(result)) { | 129 if (Dart_IsError(result)) { |
130 // TODO(turnidge): Consider propagating some errors here. What if | 130 // TODO(turnidge): Consider propagating some errors here. What if |
131 // an isolate gets interrupted by the embedder in the middle of | 131 // an isolate gets interrupted by the embedder in the middle of |
132 // Dart_StringToUTF8? We need to make sure not to swallow the | 132 // Dart_StringToUTF8? We need to make sure not to swallow the |
133 // interrupt. | 133 // interrupt. |
134 fprintf(stdout, "%s\n", Dart_GetError(result)); | 134 fprintf(stdout, "%s\n", Dart_GetError(result)); |
135 } else { | 135 } else { |
136 // Uses fwrite to support printing NUL bytes. | 136 // Uses fwrite to support printing NUL bytes. |
137 fwrite(chars, 1, length, stdout); | 137 fwrite(chars, 1, length, stdout); |
138 fputs("\n", stdout); | 138 fputs("\n", stdout); |
139 } | 139 } |
140 fflush(stdout); | 140 fflush(stdout); |
141 } | 141 } |
142 | 142 |
143 } // namespace bin | 143 } // namespace bin |
144 } // namespace dart | 144 } // namespace dart |
OLD | NEW |