| 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 #ifndef BIN_DARTUTILS_H_ | 5 #ifndef BIN_DARTUTILS_H_ |
| 6 #define BIN_DARTUTILS_H_ | 6 #define BIN_DARTUTILS_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 static void* OpenFile(const char* name, bool write); | 116 static void* OpenFile(const char* name, bool write); |
| 117 static void ReadFile(const uint8_t** data, intptr_t* file_len, void* stream); | 117 static void ReadFile(const uint8_t** data, intptr_t* file_len, void* stream); |
| 118 static void WriteFile(const void* buffer, intptr_t num_bytes, void* stream); | 118 static void WriteFile(const void* buffer, intptr_t num_bytes, void* stream); |
| 119 static void CloseFile(void* stream); | 119 static void CloseFile(void* stream); |
| 120 static bool EntropySource(uint8_t* buffer, intptr_t length); | 120 static bool EntropySource(uint8_t* buffer, intptr_t length); |
| 121 static Dart_Handle ReadStringFromFile(const char* filename); | 121 static Dart_Handle ReadStringFromFile(const char* filename); |
| 122 static Dart_Handle MakeUint8Array(const uint8_t* buffer, intptr_t length); | 122 static Dart_Handle MakeUint8Array(const uint8_t* buffer, intptr_t length); |
| 123 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, | 123 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
| 124 Dart_Handle library, | 124 Dart_Handle library, |
| 125 Dart_Handle url); | 125 Dart_Handle url); |
| 126 static Dart_Handle LoadScript(const char* script_uri, | 126 static Dart_Handle LoadScript(const char* script_uri); |
| 127 Dart_Handle builtin_lib); | 127 static Dart_Handle PrepareForScriptLoading(bool is_service_isolate, |
| 128 static Dart_Handle PrepareBuiltinLibrary(Dart_Handle builtin_lib, | 128 bool trace_loading); |
| 129 Dart_Handle internal_lib, | 129 static Dart_Handle SetupServiceLoadPort(); |
| 130 bool is_service_isolate, | 130 static Dart_Handle SetupPackageRoot(const char* package_root, |
| 131 bool trace_loading, | 131 const char* packages_file); |
| 132 const char* package_root, | |
| 133 const char* packages_file); | |
| 134 static Dart_Handle PrepareCoreLibrary(Dart_Handle core_lib, | |
| 135 Dart_Handle builtin_lib, | |
| 136 bool is_service_isolate); | |
| 137 static Dart_Handle PrepareAsyncLibrary(Dart_Handle async_lib, | |
| 138 Dart_Handle isolate_lib); | |
| 139 static Dart_Handle PrepareIOLibrary(Dart_Handle io_lib); | |
| 140 static Dart_Handle PrepareIsolateLibrary(Dart_Handle isolate_lib); | |
| 141 static Dart_Handle PrepareForScriptLoading(const char* package_root, | |
| 142 const char* packages_file, | |
| 143 bool is_service_isolate, | |
| 144 bool trace_loading, | |
| 145 Dart_Handle builtin_lib); | |
| 146 static Dart_Handle SetupIOLibrary(const char* script_uri); | 132 static Dart_Handle SetupIOLibrary(const char* script_uri); |
| 147 | 133 |
| 148 static bool PostNull(Dart_Port port_id); | 134 static bool PostNull(Dart_Port port_id); |
| 149 static bool PostInt32(Dart_Port port_id, int32_t value); | 135 static bool PostInt32(Dart_Port port_id, int32_t value); |
| 150 static bool PostInt64(Dart_Port port_id, int64_t value); | 136 static bool PostInt64(Dart_Port port_id, int64_t value); |
| 151 | 137 |
| 152 static Dart_Handle GetDartType(const char* library_url, | 138 static Dart_Handle GetDartType(const char* library_url, |
| 153 const char* class_name); | 139 const char* class_name); |
| 154 // Create a new Dart OSError object with the current OS error. | 140 // Create a new Dart OSError object with the current OS error. |
| 155 static Dart_Handle NewDartOSError(); | 141 static Dart_Handle NewDartOSError(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 177 | 163 |
| 178 // Create a new Dart InternalError object with the provided message. | 164 // Create a new Dart InternalError object with the provided message. |
| 179 static Dart_Handle NewError(const char* format, ...); | 165 static Dart_Handle NewError(const char* format, ...); |
| 180 static Dart_Handle NewInternalError(const char* message); | 166 static Dart_Handle NewInternalError(const char* message); |
| 181 | 167 |
| 182 static bool SetOriginalWorkingDirectory(); | 168 static bool SetOriginalWorkingDirectory(); |
| 183 | 169 |
| 184 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, | 170 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, |
| 185 const char* url_string); | 171 const char* url_string); |
| 186 | 172 |
| 187 static Dart_Handle SetWorkingDirectory(Dart_Handle builtin_lib); | 173 static Dart_Handle ResolveUriInWorkingDirectory(Dart_Handle script_uri); |
| 188 | 174 static Dart_Handle FilePathFromUri(Dart_Handle script_uri); |
| 189 static Dart_Handle ResolveUriInWorkingDirectory(Dart_Handle script_uri, | 175 static Dart_Handle ResolveUri(Dart_Handle library_url, Dart_Handle url); |
| 190 Dart_Handle builtin_lib); | |
| 191 | |
| 192 static Dart_Handle FilePathFromUri(Dart_Handle script_uri, | |
| 193 Dart_Handle builtin_lib); | |
| 194 | |
| 195 static Dart_Handle ExtensionPathFromUri(Dart_Handle extension_uri, | |
| 196 Dart_Handle builtin_lib); | |
| 197 | |
| 198 static Dart_Handle ResolveUri(Dart_Handle library_url, | |
| 199 Dart_Handle url, | |
| 200 Dart_Handle builtin_lib); | |
| 201 | 176 |
| 202 // Sniffs the specified text_buffer to see if it contains the magic number | 177 // Sniffs the specified text_buffer to see if it contains the magic number |
| 203 // representing a script snapshot. If the text_buffer is a script snapshot | 178 // representing a script snapshot. If the text_buffer is a script snapshot |
| 204 // the return value is an updated pointer to the text_buffer pointing past | 179 // the return value is an updated pointer to the text_buffer pointing past |
| 205 // the magic number value. The 'buffer_len' parameter is also appropriately | 180 // the magic number value. The 'buffer_len' parameter is also appropriately |
| 206 // adjusted. | 181 // adjusted. |
| 207 static const uint8_t* SniffForMagicNumber(const uint8_t* text_buffer, | 182 static const uint8_t* SniffForMagicNumber(const uint8_t* text_buffer, |
| 208 intptr_t* buffer_len, | 183 intptr_t* buffer_len, |
| 209 bool* is_snapshot); | 184 bool* is_snapshot); |
| 210 | 185 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 223 static const char* const kIsolateLibURL; | 198 static const char* const kIsolateLibURL; |
| 224 static const char* const kIOLibURL; | 199 static const char* const kIOLibURL; |
| 225 static const char* const kIOLibPatchURL; | 200 static const char* const kIOLibPatchURL; |
| 226 static const char* const kUriLibURL; | 201 static const char* const kUriLibURL; |
| 227 static const char* const kHttpScheme; | 202 static const char* const kHttpScheme; |
| 228 static const char* const kVMServiceLibURL; | 203 static const char* const kVMServiceLibURL; |
| 229 | 204 |
| 230 static const uint8_t magic_number[]; | 205 static const uint8_t magic_number[]; |
| 231 | 206 |
| 232 private: | 207 private: |
| 208 static Dart_Handle SetWorkingDirectory(); |
| 209 static Dart_Handle ExtensionPathFromUri(Dart_Handle extension_uri); |
| 210 |
| 211 static Dart_Handle PrepareBuiltinLibrary(Dart_Handle builtin_lib, |
| 212 Dart_Handle internal_lib, |
| 213 bool is_service_isolate, |
| 214 bool trace_loading); |
| 215 static Dart_Handle PrepareCoreLibrary(Dart_Handle core_lib, |
| 216 Dart_Handle builtin_lib, |
| 217 bool is_service_isolate); |
| 218 static Dart_Handle PrepareAsyncLibrary(Dart_Handle async_lib, |
| 219 Dart_Handle isolate_lib); |
| 220 static Dart_Handle PrepareIOLibrary(Dart_Handle io_lib); |
| 221 static Dart_Handle PrepareIsolateLibrary(Dart_Handle isolate_lib); |
| 222 |
| 233 DISALLOW_ALLOCATION(); | 223 DISALLOW_ALLOCATION(); |
| 234 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); | 224 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); |
| 235 }; | 225 }; |
| 236 | 226 |
| 237 | 227 |
| 238 class CObject { | 228 class CObject { |
| 239 public: | 229 public: |
| 240 // These match the constants in sdk/lib/io/common.dart. | 230 // These match the constants in sdk/lib/io/common.dart. |
| 241 static const int kSuccess = 0; | 231 static const int kSuccess = 0; |
| 242 static const int kArgumentError = 1; | 232 static const int kArgumentError = 1; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 574 |
| 585 ~ScopedBlockingCall() { | 575 ~ScopedBlockingCall() { |
| 586 Dart_ThreadEnableProfiling(); | 576 Dart_ThreadEnableProfiling(); |
| 587 } | 577 } |
| 588 }; | 578 }; |
| 589 | 579 |
| 590 } // namespace bin | 580 } // namespace bin |
| 591 } // namespace dart | 581 } // namespace dart |
| 592 | 582 |
| 593 #endif // BIN_DARTUTILS_H_ | 583 #endif // BIN_DARTUTILS_H_ |
| OLD | NEW |