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 /* Handle error handles returned from Dart API functions. If a value |
| 14 * is an error, use Dart_PropagateError to throw it to the enclosing |
| 15 * Dart activation. Otherwise, return the original handle. |
| 16 * This function can be used to wrap most API functions, but API |
| 17 * functions can also be nested without this error check, since all |
| 18 * API functions return any error handles passed in as arguments, unchanged. |
| 19 */ |
| 20 static Dart_Handle ThrowIfError(Dart_Handle handle) { |
| 21 if (Dart_IsError(handle)) Dart_PropagateError(handle); |
| 22 return handle; |
| 23 } |
| 24 |
13 class CommandLineOptions { | 25 class CommandLineOptions { |
14 public: | 26 public: |
15 explicit CommandLineOptions(int max_count) | 27 explicit CommandLineOptions(int max_count) |
16 : count_(0), max_count_(max_count), arguments_(NULL) { | 28 : count_(0), max_count_(max_count), arguments_(NULL) { |
17 static const int kWordSize = sizeof(intptr_t); | 29 static const int kWordSize = sizeof(intptr_t); |
18 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize)); | 30 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize)); |
19 if (arguments_ == NULL) { | 31 if (arguments_ == NULL) { |
20 max_count_ = 0; | 32 max_count_ = 0; |
21 } | 33 } |
22 } | 34 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Dart_Handle library, | 110 Dart_Handle library, |
99 Dart_Handle url, | 111 Dart_Handle url, |
100 Dart_LibraryTag tag, | 112 Dart_LibraryTag tag, |
101 const char* filename); | 113 const char* filename); |
102 static Dart_Handle PrepareForScriptLoading(const char* package_root, | 114 static Dart_Handle PrepareForScriptLoading(const char* package_root, |
103 Dart_Handle builtin_lib); | 115 Dart_Handle builtin_lib); |
104 | 116 |
105 static bool PostNull(Dart_Port port_id); | 117 static bool PostNull(Dart_Port port_id); |
106 static bool PostInt32(Dart_Port port_id, int32_t value); | 118 static bool PostInt32(Dart_Port port_id, int32_t value); |
107 | 119 |
| 120 static Dart_Handle GetDartClass(const char* library_url, |
| 121 const char* class_name); |
108 // Create a new Dart OSError object with the current OS error. | 122 // Create a new Dart OSError object with the current OS error. |
109 static Dart_Handle NewDartOSError(); | 123 static Dart_Handle NewDartOSError(); |
110 // Create a new Dart OSError object with the provided OS error. | 124 // Create a new Dart OSError object with the provided OS error. |
111 static Dart_Handle NewDartOSError(OSError* os_error); | 125 static Dart_Handle NewDartOSError(OSError* os_error); |
| 126 static Dart_Handle NewDartExceptionWithMessage(const char* library_url, |
| 127 const char* exception_name, |
| 128 const char* message); |
| 129 static Dart_Handle NewDartArgumentError(const char* message); |
112 | 130 |
113 static void SetOriginalWorkingDirectory(); | 131 static void SetOriginalWorkingDirectory(); |
114 | 132 |
115 // Global state that stores the original working directory.. | 133 // Global state that stores the original working directory.. |
116 static const char* original_working_directory; | 134 static const char* original_working_directory; |
117 | 135 |
118 static const char* kDartScheme; | 136 static const char* kDartScheme; |
119 static const char* kDartExtensionScheme; | 137 static const char* kDartExtensionScheme; |
120 static const char* kBuiltinLibURL; | 138 static const char* kBuiltinLibURL; |
121 static const char* kCoreLibURL; | 139 static const char* kCoreLibURL; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 void* Peer() const { return cobject_->value.as_external_byte_array.peer; } | 381 void* Peer() const { return cobject_->value.as_external_byte_array.peer; } |
364 Dart_PeerFinalizer Callback() const { | 382 Dart_PeerFinalizer Callback() const { |
365 return cobject_->value.as_external_byte_array.callback; | 383 return cobject_->value.as_external_byte_array.callback; |
366 } | 384 } |
367 | 385 |
368 private: | 386 private: |
369 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); | 387 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); |
370 }; | 388 }; |
371 | 389 |
372 #endif // BIN_DARTUTILS_H_ | 390 #endif // BIN_DARTUTILS_H_ |
OLD | NEW |