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 "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
12 | 12 |
| 13 // Forward declarations. |
| 14 class File; |
| 15 |
13 /* Handles error handles returned from Dart API functions. If a value | 16 /* Handles error handles returned from Dart API functions. If a value |
14 * is an error, uses Dart_PropagateError to throw it to the enclosing | 17 * is an error, uses Dart_PropagateError to throw it to the enclosing |
15 * Dart activation. Otherwise, returns the original handle. | 18 * Dart activation. Otherwise, returns the original handle. |
16 * | 19 * |
17 * This function can be used to wrap most API functions, but API | 20 * This function can be used to wrap most API functions, but API |
18 * functions can also be nested without this error check, since all | 21 * functions can also be nested without this error check, since all |
19 * API functions return any error handles passed in as arguments, unchanged. | 22 * API functions return any error handles passed in as arguments, unchanged. |
20 */ | 23 */ |
21 static inline Dart_Handle ThrowIfError(Dart_Handle handle) { | 24 static inline Dart_Handle ThrowIfError(Dart_Handle handle) { |
22 if (Dart_IsError(handle)) Dart_PropagateError(handle); | 25 if (Dart_IsError(handle)) Dart_PropagateError(handle); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 static Dart_Handle ResolveScriptUri(Dart_Handle script_uri, | 153 static Dart_Handle ResolveScriptUri(Dart_Handle script_uri, |
151 Dart_Handle builtin_lib); | 154 Dart_Handle builtin_lib); |
152 | 155 |
153 static Dart_Handle FilePathFromUri(Dart_Handle script_uri, | 156 static Dart_Handle FilePathFromUri(Dart_Handle script_uri, |
154 Dart_Handle builtin_lib); | 157 Dart_Handle builtin_lib); |
155 | 158 |
156 static Dart_Handle ResolveUri(Dart_Handle library_url, | 159 static Dart_Handle ResolveUri(Dart_Handle library_url, |
157 Dart_Handle url, | 160 Dart_Handle url, |
158 Dart_Handle builtin_lib); | 161 Dart_Handle builtin_lib); |
159 | 162 |
| 163 // Sniffs the specified text_buffer to see if it contains the magic number |
| 164 // representing a script snapshot. If the text_buffer is a script snapshot |
| 165 // the return value is an updated pointer to the text_buffer pointing past |
| 166 // the magic number value. |
| 167 static const uint8_t* SniffForMagicNumber(const uint8_t* text_buffer, |
| 168 bool* is_snapshot); |
| 169 |
| 170 // Write a magic number to indicate a script snapshot file. |
| 171 static void WriteMagicNumber(File* file); |
| 172 |
160 // Global state that stores the original working directory.. | 173 // Global state that stores the original working directory.. |
161 static const char* original_working_directory; | 174 static const char* original_working_directory; |
162 | 175 |
163 static const char* kDartScheme; | 176 static const char* kDartScheme; |
164 static const char* kDartExtensionScheme; | 177 static const char* kDartExtensionScheme; |
165 static const char* kAsyncLibURL; | 178 static const char* kAsyncLibURL; |
166 static const char* kBuiltinLibURL; | 179 static const char* kBuiltinLibURL; |
167 static const char* kCoreLibURL; | 180 static const char* kCoreLibURL; |
168 static const char* kIOLibURL; | 181 static const char* kIOLibURL; |
169 static const char* kIOLibPatchURL; | 182 static const char* kIOLibPatchURL; |
170 static const char* kUriLibURL; | 183 static const char* kUriLibURL; |
171 static const char* kUtfLibURL; | 184 static const char* kUtfLibURL; |
172 static const char* kIsolateLibURL; | 185 static const char* kIsolateLibURL; |
173 static const char* kScalarlistLibURL; | 186 static const char* kScalarlistLibURL; |
174 static const char* kWebLibURL; | 187 static const char* kWebLibURL; |
175 | 188 |
176 static const char* kIdFieldName; | 189 static const char* kIdFieldName; |
177 | 190 |
| 191 static uint8_t magic_number[]; |
| 192 |
178 private: | 193 private: |
179 static const char* GetCanonicalPath(const char* reference_dir, | 194 static const char* GetCanonicalPath(const char* reference_dir, |
180 const char* filename); | 195 const char* filename); |
181 | 196 |
182 DISALLOW_ALLOCATION(); | 197 DISALLOW_ALLOCATION(); |
183 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); | 198 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); |
184 }; | 199 }; |
185 | 200 |
186 | 201 |
187 class CObject { | 202 class CObject { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 void* Peer() const { return cobject_->value.as_external_byte_array.peer; } | 426 void* Peer() const { return cobject_->value.as_external_byte_array.peer; } |
412 Dart_WeakPersistentHandleFinalizer Callback() const { | 427 Dart_WeakPersistentHandleFinalizer Callback() const { |
413 return cobject_->value.as_external_byte_array.callback; | 428 return cobject_->value.as_external_byte_array.callback; |
414 } | 429 } |
415 | 430 |
416 private: | 431 private: |
417 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); | 432 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); |
418 }; | 433 }; |
419 | 434 |
420 #endif // BIN_DARTUTILS_H_ | 435 #endif // BIN_DARTUTILS_H_ |
OLD | NEW |