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 "include/dart_api.h" | 10 #include "include/dart_api.h" |
10 #include "platform/globals.h" | 11 #include "platform/globals.h" |
11 | 12 |
12 class CommandLineOptions { | 13 class CommandLineOptions { |
13 public: | 14 public: |
14 explicit CommandLineOptions(int max_count) | 15 explicit CommandLineOptions(int max_count) |
15 : count_(0), max_count_(max_count), arguments_(NULL) { | 16 : count_(0), max_count_(max_count), arguments_(NULL) { |
16 static const int kWordSize = sizeof(intptr_t); | 17 static const int kWordSize = sizeof(intptr_t); |
17 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize)); | 18 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize)); |
18 if (arguments_ == NULL) { | 19 if (arguments_ == NULL) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 static Dart_Handle ReadStringFromFile(const char* filename); | 82 static Dart_Handle ReadStringFromFile(const char* filename); |
82 static Dart_Handle LoadSource(CommandLineOptions* url_mapping, | 83 static Dart_Handle LoadSource(CommandLineOptions* url_mapping, |
83 Dart_Handle library, | 84 Dart_Handle library, |
84 Dart_Handle url, | 85 Dart_Handle url, |
85 Dart_LibraryTag tag, | 86 Dart_LibraryTag tag, |
86 const char* filename, | 87 const char* filename, |
87 Dart_Handle import_map); | 88 Dart_Handle import_map); |
88 static bool PostNull(Dart_Port port_id); | 89 static bool PostNull(Dart_Port port_id); |
89 static bool PostInt32(Dart_Port port_id, int32_t value); | 90 static bool PostInt32(Dart_Port port_id, int32_t value); |
90 | 91 |
| 92 // Create a new Dart OSError object with the current OS error. |
| 93 static Dart_Handle NewDartOSError(); |
| 94 // Create a new Dart OSError object with the provided OS error. |
| 95 static Dart_Handle NewDartOSError(OSError* os_error); |
| 96 |
91 static const char* kDartScheme; | 97 static const char* kDartScheme; |
92 static const char* kDartExtensionScheme; | 98 static const char* kDartExtensionScheme; |
93 static const char* kBuiltinLibURL; | 99 static const char* kBuiltinLibURL; |
94 static const char* kCoreLibURL; | 100 static const char* kCoreLibURL; |
95 static const char* kCoreImplLibURL; | 101 static const char* kCoreImplLibURL; |
96 static const char* kIOLibURL; | 102 static const char* kIOLibURL; |
97 static const char* kJsonLibURL; | 103 static const char* kJsonLibURL; |
98 static const char* kUriLibURL; | 104 static const char* kUriLibURL; |
99 static const char* kUtfLibURL; | 105 static const char* kUtfLibURL; |
100 static const char* kIsolateLibURL; | 106 static const char* kIsolateLibURL; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 static Dart_CObject* NewIntptr(intptr_t value); | 154 static Dart_CObject* NewIntptr(intptr_t value); |
149 // TODO(sgjesse): Add support for kBigint. | 155 // TODO(sgjesse): Add support for kBigint. |
150 static Dart_CObject* NewDouble(double value); | 156 static Dart_CObject* NewDouble(double value); |
151 static Dart_CObject* NewString(int length); | 157 static Dart_CObject* NewString(int length); |
152 static Dart_CObject* NewString(const char* str); | 158 static Dart_CObject* NewString(const char* str); |
153 static Dart_CObject* NewArray(int length); | 159 static Dart_CObject* NewArray(int length); |
154 static Dart_CObject* NewByteArray(int length); | 160 static Dart_CObject* NewByteArray(int length); |
155 | 161 |
156 Dart_CObject* AsApiCObject() { return cobject_; } | 162 Dart_CObject* AsApiCObject() { return cobject_; } |
157 | 163 |
| 164 // Create a new CObject array with an illegal arguments error. |
| 165 static CObject* IllegalArgumentError(); |
| 166 // Create a new CObject array with the current OS error. |
| 167 static CObject* NewOSError(); |
| 168 |
158 protected: | 169 protected: |
159 CObject() : cobject_(NULL) {} | 170 CObject() : cobject_(NULL) {} |
160 Dart_CObject* cobject_; | 171 Dart_CObject* cobject_; |
161 | 172 |
162 private: | 173 private: |
163 static Dart_CObject* New(Dart_CObject::Type type, int additional_bytes = 0); | 174 static Dart_CObject* New(Dart_CObject::Type type, int additional_bytes = 0); |
164 | 175 |
165 static Dart_CObject api_null_; | 176 static Dart_CObject api_null_; |
166 static Dart_CObject api_true_; | 177 static Dart_CObject api_true_; |
167 static Dart_CObject api_false_; | 178 static Dart_CObject api_false_; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 284 |
274 class CObjectByteArray : public CObject { | 285 class CObjectByteArray : public CObject { |
275 public: | 286 public: |
276 DECLARE_COBJECT_CONSTRUCTORS(ByteArray) | 287 DECLARE_COBJECT_CONSTRUCTORS(ByteArray) |
277 | 288 |
278 int Length() const { return cobject_->value.as_byte_array.length; } | 289 int Length() const { return cobject_->value.as_byte_array.length; } |
279 uint8_t* Buffer() const { return cobject_->value.as_byte_array.values; } | 290 uint8_t* Buffer() const { return cobject_->value.as_byte_array.values; } |
280 }; | 291 }; |
281 | 292 |
282 #endif // BIN_DARTUTILS_H_ | 293 #endif // BIN_DARTUTILS_H_ |
OLD | NEW |