Flutter Engine
The Flutter Engine
dartutils.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_BIN_DARTUTILS_H_
6#define RUNTIME_BIN_DARTUTILS_H_
7
8#include "bin/isolate_data.h"
9#include "include/dart_api.h"
11#include "platform/assert.h"
12#include "platform/globals.h"
13#include "platform/hashmap.h"
14#include "platform/syslog.h"
15
16namespace dart {
17namespace bin {
18
19// Forward declarations.
20class File;
21class OSError;
22
23/* Handles error handles returned from Dart API functions. If a value
24 * is an error, uses Dart_PropagateError to throw it to the enclosing
25 * Dart activation. Otherwise, returns the original handle.
26 *
27 * This function can be used to wrap most API functions, but API
28 * functions can also be nested without this error check, since all
29 * API functions return any error handles passed in as arguments, unchanged.
30 */
31static inline Dart_Handle ThrowIfError(Dart_Handle handle) {
32 if (Dart_IsError(handle)) {
33 Dart_PropagateError(handle);
34 }
35 return handle;
36}
37
38static inline void* GetHashmapKeyFromString(char* key) {
39 return reinterpret_cast<void*>(key);
40}
41
43 public:
45 : count_(0), max_count_(max_count), arguments_(nullptr) {
46 const int kWordSize = sizeof(intptr_t);
47 arguments_ = reinterpret_cast<const char**>(malloc(max_count * kWordSize));
48 if (arguments_ == nullptr) {
49 max_count_ = 0;
50 }
51 }
53 free(arguments_);
54 count_ = 0;
55 max_count_ = 0;
56 arguments_ = nullptr;
57 }
58
59 void Reset() { count_ = 0; }
60
61 int count() const { return count_; }
62 int max_count() const { return max_count_; }
63 const char** arguments() const { return arguments_; }
64
65 const char* GetArgument(int index) const {
66 return (index >= 0 && index < count_) ? arguments_[index] : nullptr;
67 }
68 void AddArgument(const char* argument) {
69 if (count_ < max_count_) {
70 arguments_[count_] = argument;
71 count_ += 1;
72 } else {
73 abort(); // We should never get into this situation.
74 }
75 }
76
77 void AddArguments(const char** argv, int argc) {
78 if (count_ + argc >= max_count_) {
79 abort(); // We should never get into this situation.
80 }
81 for (int i = 0; i < argc; ++i) {
82 arguments_[count_++] = argv[i];
83 }
84 }
85
87
88#if defined(DEBUG)
89 void DebugPrint() const {
90 for (int i = 0; i < count(); ++i) {
91 Syslog::PrintErr("[%d] = %s\n", i, GetArgument(i));
92 }
93 }
94#endif // defined(DEBUG)
95
96 void operator delete(void* pointer) { abort(); }
97
98 private:
99 void* operator new(size_t size);
100
101 int count_;
102 int max_count_;
103 const char** arguments_;
104
105 DISALLOW_COPY_AND_ASSIGN(CommandLineOptions);
106};
107
109 public:
110 // Returns the integer value of a Dart object. If the object is not
111 // an integer value an API error is propagated.
112 static int64_t GetIntegerValue(Dart_Handle value_obj);
113 // Returns the integer value of a Dart object. If the object is not
114 // an integer value or outside the requested range an API error is
115 // propagated.
116 static int64_t GetInt64ValueCheckRange(Dart_Handle value_obj,
117 int64_t lower,
118 int64_t upper);
119 // Returns the intptr_t value of a Dart object. If the object is not
120 // an integer value or the value is outside the intptr_t range an
121 // API error is propagated.
122 static intptr_t GetIntptrValue(Dart_Handle value_obj);
123 // Checks that the value object is an integer object that fits in a
124 // signed 64-bit integer. If it is, the value is returned in the
125 // value out parameter and true is returned. Otherwise, false is
126 // returned.
127 static bool GetInt64Value(Dart_Handle value_obj, int64_t* value);
128 // Returns the string value of a Dart object. If the object is not
129 // a string value an API error is propagated.
130 static const char* GetStringValue(Dart_Handle str_obj);
131 // Returns the boolean value of a Dart object. If the object is not
132 // a boolean value an API error is propagated.
133 static bool GetBooleanValue(Dart_Handle bool_obj);
134 // Returns the boolean value of the argument at index. If the argument
135 // is not a boolean value an API error is propagated.
137 intptr_t index);
138 // Returns the integer value of the argument at index. If the argument
139 // is not an integer value an API error is propagated.
141 intptr_t index);
142 // Returns the intptr_t value of the argument at index. If the argument
143 // is not an integer value or the value is outside the intptr_t range an
144 // API error is propagated.
146 intptr_t index);
147 // Returns the string value of the argument at index. If the argument
148 // is not a string value an API error is propagated.
150 intptr_t index);
152 intptr_t index);
154 const char* name,
155 int64_t val);
157 const char* name,
158 const char* val);
159 static bool IsDartSchemeURL(const char* url_name);
160 static bool IsDartIOLibURL(const char* url_name);
161 static bool IsDartCLILibURL(const char* url_name);
162 static bool IsDartHttpLibURL(const char* url_name);
163 static bool IsDartBuiltinLibURL(const char* url_name);
164 static bool IsHttpSchemeURL(const char* url_name);
165 static const char* RemoveScheme(const char* url);
166
167 // Returns directory name including the last path separator.
168 //
169 // The return value must be `free`d by the caller.
170 static char* DirName(const char* url);
171 static void* MapExecutable(const char* name, intptr_t* file_len);
172 static void* OpenFile(const char* name, bool write);
173 static void* OpenFileUri(const char* uri, bool write);
174 static void ReadFile(uint8_t** data, intptr_t* file_len, void* stream);
175 static void WriteFile(const void* buffer, intptr_t num_bytes, void* stream);
176 static void CloseFile(void* stream);
177 static bool EntropySource(uint8_t* buffer, intptr_t length);
178 static Dart_Handle ReadStringFromFile(const char* filename);
179 static Dart_Handle MakeUint8Array(const void* buffer, intptr_t length);
180 static Dart_Handle PrepareForScriptLoading(bool is_service_isolate,
181 bool trace_loading);
182 static Dart_Handle SetupPackageConfig(const char* packages_file);
183
184 static Dart_Handle SetupIOLibrary(const char* namespc_path,
185 const char* script_uri,
186 bool disable_exit);
187
188 static bool PostNull(Dart_Port port_id);
189 static bool PostInt32(Dart_Port port_id, int32_t value);
190 static bool PostInt64(Dart_Port port_id, int64_t value);
191 static bool PostString(Dart_Port port_id, const char* value);
192
193 static Dart_Handle GetDartType(const char* library_url,
194 const char* class_name);
195 // Create a new Dart OSError object with the current OS error.
197 // Create a new Dart OSError object with the provided OS error.
198 static Dart_Handle NewDartOSError(OSError* os_error);
199 static Dart_Handle NewDartExceptionWithOSError(const char* library_url,
200 const char* exception_name,
201 const char* message,
202 Dart_Handle os_error);
203 static Dart_Handle NewDartExceptionWithMessage(const char* library_url,
204 const char* exception_name,
205 const char* message);
206 static Dart_Handle NewDartArgumentError(const char* message);
207 static Dart_Handle NewDartFormatException(const char* message);
208 static Dart_Handle NewDartUnsupportedError(const char* message);
209 static Dart_Handle NewDartIOException(const char* exception_name,
210 const char* message,
211 Dart_Handle os_error);
212
213 // Create a new Dart String object from a UTF8 encoded C String.
214 static Dart_Handle NewString(const char* str) {
215 ASSERT(str != nullptr);
216 return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str),
217 strlen(str));
218 }
219
220 // Create a new Dart String object from a formatted string.
221 static Dart_Handle NewStringFormatted(const char* format, ...);
222
223 // Allocate length bytes for a C string with Dart_ScopeAllocate.
224 static char* ScopedCString(intptr_t length) {
225 char* result = nullptr;
226 result =
227 reinterpret_cast<char*>(Dart_ScopeAllocate(length * sizeof(*result)));
228 return result;
229 }
230
231 // Copy str into a buffer allocated with Dart_ScopeAllocate.
232 static char* ScopedCopyCString(const char* str) {
233 size_t str_len = strlen(str);
234 char* result = ScopedCString(str_len + 1);
235 memmove(result, str, str_len);
236 result[str_len] = '\0';
237 return result;
238 }
239
240 static char* ScopedCStringFormatted(const char* format, ...)
241 PRINTF_ATTRIBUTE(1, 2);
242 static char* ScopedCStringVFormatted(const char* format, va_list args);
243
244 // Create a new Dart InternalError object with the provided message.
245 static Dart_Handle NewError(const char* format, ...);
246 static Dart_Handle NewInternalError(const char* message);
247
250 }
251
252 static bool SetOriginalWorkingDirectory();
253
255
270 };
271 static constexpr int64_t kMaxMagicNumberSize = 8;
272
273 // Note: The check for AOT magic number must match up with the enum
274 // order above.
275 static bool IsAotMagicNumber(MagicNumber number) {
276 return (number >= DartUtils::kAotELFMagicNumber) &&
278 }
279
280 // Checks if the buffer is a script snapshot, kernel file, or gzip file.
281 static MagicNumber SniffForMagicNumber(const char* filename);
282
283 // Checks if the buffer is a script snapshot, kernel file, or gzip file.
284 static MagicNumber SniffForMagicNumber(const uint8_t* text_buffer,
285 intptr_t buffer_len);
286
287 // Global state that stores the original working directory..
288 static const char* original_working_directory;
289
290 static constexpr const char* kDartScheme = "dart:";
291 static constexpr const char* kAsyncLibURL = "dart:async";
292 static constexpr const char* kBuiltinLibURL = "dart:_builtin";
293 static constexpr const char* kCoreLibURL = "dart:core";
294 static constexpr const char* kInternalLibURL = "dart:_internal";
295 static constexpr const char* kIsolateLibURL = "dart:isolate";
296 static constexpr const char* kHttpLibURL = "dart:_http";
297 static constexpr const char* kIOLibURL = "dart:io";
298 static constexpr const char* kIOLibPatchURL = "dart:io-patch";
299 static constexpr const char* kCLILibURL = "dart:cli";
300 static constexpr const char* kCLILibPatchURL = "dart:cli-patch";
301 static constexpr const char* kUriLibURL = "dart:uri";
302 static constexpr const char* kHttpScheme = "http:";
303 static constexpr const char* kVMServiceLibURL = "dart:vmservice";
304
307
308 private:
309 static Dart_Handle SetWorkingDirectory();
310 static Dart_Handle PrepareBuiltinLibrary(Dart_Handle builtin_lib,
311 Dart_Handle internal_lib,
312 bool is_service_isolate,
313 bool trace_loading);
314 static Dart_Handle PrepareCoreLibrary(Dart_Handle core_lib,
315 Dart_Handle io_lib,
316 bool is_service_isolate);
317 static Dart_Handle PrepareAsyncLibrary(Dart_Handle async_lib,
318 Dart_Handle isolate_lib);
319 static Dart_Handle PrepareIOLibrary(Dart_Handle io_lib);
320 static Dart_Handle PrepareIsolateLibrary(Dart_Handle isolate_lib);
321 static Dart_Handle PrepareCLILibrary(Dart_Handle cli_lib);
322
323 static dart::SimpleHashMap* environment_;
324
325 DISALLOW_ALLOCATION();
326 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils);
327};
328
329class CObject {
330 public:
331 // These match the constants in sdk/lib/io/common.dart.
332 static constexpr int kSuccess = 0;
333 static constexpr int kArgumentError = 1;
334 static constexpr int kOSError = 2;
335 static constexpr int kFileClosedError = 3;
336
337 explicit CObject(Dart_CObject* cobject) : cobject_(cobject) {}
343 }
344
345 bool IsNull() { return type() == Dart_CObject_kNull; }
346 bool IsBool() { return type() == Dart_CObject_kBool; }
347 bool IsInt32() { return type() == Dart_CObject_kInt32; }
348 bool IsInt64() { return type() == Dart_CObject_kInt64; }
349 bool IsInt32OrInt64() { return IsInt32() || IsInt64(); }
350 bool IsIntptr() { return IsInt32OrInt64(); }
351 bool IsDouble() { return type() == Dart_CObject_kDouble; }
352 bool IsString() { return type() == Dart_CObject_kString; }
353 bool IsArray() { return type() == Dart_CObject_kArray; }
356 return type() == Dart_CObject_kTypedData &&
358 }
359 bool IsSendPort() { return type() == Dart_CObject_kSendPort; }
360
361 bool IsTrue() {
363 }
364
365 bool IsFalse() {
367 }
368
369 void* operator new(size_t size) { return Dart_ScopeAllocate(size); }
370
371 static CObject* Null();
372 static CObject* True();
373 static CObject* False();
374 static CObject* Bool(bool value);
375 static Dart_CObject* NewInt32(int32_t value);
376 static Dart_CObject* NewInt64(int64_t value);
377 static Dart_CObject* NewIntptr(intptr_t value);
378 static Dart_CObject* NewDouble(double value);
379 static Dart_CObject* NewString(const char* str);
380 static Dart_CObject* NewArray(intptr_t length);
381 static Dart_CObject* NewUint8Array(const void* data, intptr_t length);
383 uint8_t* data,
384 void* peer,
386 static Dart_CObject* NewNativePointer(intptr_t ptr,
387 intptr_t size,
389
390 static Dart_CObject* NewIOBuffer(int64_t length);
391 static void ShrinkIOBuffer(Dart_CObject* cobject, int64_t new_length);
392 static void FreeIOBufferData(Dart_CObject* object);
393
395
396 // Create a new CObject array with an illegal arguments error.
398 // Create a new CObject array with a file closed error.
399 static CObject* FileClosedError();
400 // Create a new CObject array with the current OS error.
401 static CObject* NewOSError();
402 // Create a new CObject array with the specified OS error.
403 static CObject* NewOSError(OSError* os_error);
404
405 protected:
406 CObject() : cobject_(nullptr) {}
408
409 private:
410 static Dart_CObject* New(Dart_CObject_Type type, int additional_bytes = 0);
411
412 static Dart_CObject api_null_;
413 static Dart_CObject api_true_;
414 static Dart_CObject api_false_;
415 static CObject null_;
416 static CObject true_;
417 static CObject false_;
418
419 private:
420 DISALLOW_COPY_AND_ASSIGN(CObject);
421};
422
423#define DECLARE_COBJECT_CONSTRUCTORS(t) \
424 explicit CObject##t(Dart_CObject* cobject) : CObject(cobject) { \
425 ASSERT(type() == Dart_CObject_k##t); \
426 cobject_ = cobject; \
427 } \
428 explicit CObject##t(CObject* cobject) : CObject() { \
429 ASSERT(cobject != nullptr); \
430 ASSERT(cobject->type() == Dart_CObject_k##t); \
431 cobject_ = cobject->AsApiCObject(); \
432 }
433
434#define DECLARE_COBJECT_TYPED_DATA_CONSTRUCTORS(t) \
435 explicit CObject##t##Array(Dart_CObject* cobject) : CObject(cobject) { \
436 ASSERT(type() == Dart_CObject_kTypedData); \
437 ASSERT(byte_array_type() == Dart_TypedData_k##t); \
438 cobject_ = cobject; \
439 } \
440 explicit CObject##t##Array(CObject* cobject) : CObject() { \
441 ASSERT(cobject != nullptr); \
442 ASSERT(cobject->type() == Dart_CObject_kTypedData); \
443 ASSERT(cobject->byte_array_type() == Dart_TypedData_k##t); \
444 cobject_ = cobject->AsApiCObject(); \
445 }
446
447#define DECLARE_COBJECT_EXTERNAL_TYPED_DATA_CONSTRUCTORS(t) \
448 explicit CObjectExternal##t##Array(Dart_CObject* cobject) \
449 : CObject(cobject) { \
450 ASSERT(type() == Dart_CObject_kExternalTypedData); \
451 ASSERT(byte_array_type() == Dart_TypedData_k##t); \
452 cobject_ = cobject; \
453 } \
454 explicit CObjectExternal##t##Array(CObject* cobject) : CObject() { \
455 ASSERT(cobject != nullptr); \
456 ASSERT(cobject->type() == Dart_CObject_kExternalTypedData); \
457 ASSERT(cobject->byte_array_type() == Dart_TypedData_k##t); \
458 cobject_ = cobject->AsApiCObject(); \
459 }
460
461class CObjectBool : public CObject {
462 public:
464
465 bool Value() const { return cobject_->value.as_bool; }
466
467 private:
468 DISALLOW_COPY_AND_ASSIGN(CObjectBool);
469};
470
471class CObjectInt32 : public CObject {
472 public:
474
475 int32_t Value() const { return cobject_->value.as_int32; }
476
477 private:
478 DISALLOW_COPY_AND_ASSIGN(CObjectInt32);
479};
480
481class CObjectInt64 : public CObject {
482 public:
484
485 int64_t Value() const { return cobject_->value.as_int64; }
486
487 private:
488 DISALLOW_COPY_AND_ASSIGN(CObjectInt64);
489};
490
491class CObjectIntptr : public CObject {
492 public:
493 explicit CObjectIntptr(Dart_CObject* cobject) : CObject(cobject) {
495 cobject_ = cobject;
496 }
497 explicit CObjectIntptr(CObject* cobject) : CObject() {
498 ASSERT(cobject != nullptr);
499 ASSERT(cobject->type() == Dart_CObject_kInt64 ||
500 cobject->type() == Dart_CObject_kInt32);
501 cobject_ = cobject->AsApiCObject();
502 }
503
504 intptr_t Value() {
505 intptr_t result;
506 if (type() == Dart_CObject_kInt32) {
508 } else {
509 ASSERT(sizeof(result) == 8);
510 result = static_cast<intptr_t>(cobject_->value.as_int64);
511 }
512 return result;
513 }
514
515 private:
516 DISALLOW_COPY_AND_ASSIGN(CObjectIntptr);
517};
518
519class CObjectDouble : public CObject {
520 public:
522
523 double Value() const { return cobject_->value.as_double; }
524
525 private:
526 DISALLOW_COPY_AND_ASSIGN(CObjectDouble);
527};
528
529class CObjectString : public CObject {
530 public:
532
533 intptr_t Length() const { return strlen(cobject_->value.as_string); }
534 const char* CString() const { return cobject_->value.as_string; }
535
536 private:
537 DISALLOW_COPY_AND_ASSIGN(CObjectString);
538};
539
540class CObjectArray : public CObject {
541 public:
543
544 intptr_t Length() const { return cobject_->value.as_array.length; }
545 CObject* operator[](intptr_t index) const {
546 return new CObject(cobject_->value.as_array.values[index]);
547 }
548 void SetAt(intptr_t index, CObject* value) {
549 cobject_->value.as_array.values[index] = value->AsApiCObject();
550 }
551
552 private:
553 DISALLOW_COPY_AND_ASSIGN(CObjectArray);
554};
555
556class CObjectSendPort : public CObject {
557 public:
559
562
563 private:
564 DISALLOW_COPY_AND_ASSIGN(CObjectSendPort);
565};
566
567class CObjectTypedData : public CObject {
568 public:
569 explicit CObjectTypedData(Dart_CObject* cobject) : CObject(cobject) {
571 cobject_ = cobject;
572 }
573 explicit CObjectTypedData(CObject* cobject) : CObject() {
574 ASSERT(cobject != nullptr);
575 ASSERT(cobject->type() == Dart_CObject_kTypedData);
576 cobject_ = cobject->AsApiCObject();
577 }
578
581 }
582 intptr_t Length() const { return cobject_->value.as_typed_data.length; }
583 const uint8_t* Buffer() const { return cobject_->value.as_typed_data.values; }
584
585 private:
586 DISALLOW_COPY_AND_ASSIGN(CObjectTypedData);
587};
588
590 public:
592
593 intptr_t Length() const { return cobject_->value.as_typed_data.length; }
594 const uint8_t* Buffer() const { return cobject_->value.as_typed_data.values; }
595
596 private:
597 DISALLOW_COPY_AND_ASSIGN(CObjectUint8Array);
598};
599
601 public:
603
604 intptr_t Length() const {
606 }
607 uint8_t* Data() const { return cobject_->value.as_external_typed_data.data; }
608 void* Peer() const { return cobject_->value.as_external_typed_data.peer; }
611 }
612
613 private:
614 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array);
615};
616
617/***
618 * This class is intended for internal use by dart:io implementation and
619 * has no connection to dart:ffi Pointer class.
620 *
621 * It represents a pointer to a native resource of a known type.
622 *
623 * The receiving side will only see this pointer as an integer and will not
624 * see the specified finalizer.
625 *
626 * The specified finalizer will only be invoked if the message is not delivered.
627 **/
629 public:
630 DECLARE_COBJECT_CONSTRUCTORS(NativePointer)
631
632 intptr_t Ptr() const { return cobject_->value.as_native_pointer.ptr; }
633 intptr_t Size() const { return cobject_->value.as_native_pointer.size; }
636 }
637
638 private:
639 DISALLOW_COPY_AND_ASSIGN(CObjectNativePointer);
640};
641
643 public:
645
647
648 private:
649 DISALLOW_ALLOCATION();
650 DISALLOW_COPY_AND_ASSIGN(ScopedBlockingCall);
651};
652
654 static constexpr intptr_t kMaxLength = 8;
655
656 intptr_t length;
657 const uint8_t bytes[kMaxLength];
658};
659
665
666} // namespace bin
667} // namespace dart
668
669#endif // RUNTIME_BIN_DARTUTILS_H_
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: il.h:75
void SetAt(intptr_t index, CObject *value)
Definition: dartutils.h:548
intptr_t Length() const
Definition: dartutils.h:544
CObject * operator[](intptr_t index) const
Definition: dartutils.h:545
Dart_HandleFinalizer Callback() const
Definition: dartutils.h:609
CObjectIntptr(CObject *cobject)
Definition: dartutils.h:497
CObjectIntptr(Dart_CObject *cobject)
Definition: dartutils.h:493
Dart_HandleFinalizer Callback() const
Definition: dartutils.h:634
Dart_Port OriginId() const
Definition: dartutils.h:561
const char * CString() const
Definition: dartutils.h:534
intptr_t Length() const
Definition: dartutils.h:533
const uint8_t * Buffer() const
Definition: dartutils.h:583
Dart_TypedData_Type Type() const
Definition: dartutils.h:579
intptr_t Length() const
Definition: dartutils.h:582
CObjectTypedData(Dart_CObject *cobject)
Definition: dartutils.h:569
CObjectTypedData(CObject *cobject)
Definition: dartutils.h:573
const uint8_t * Buffer() const
Definition: dartutils.h:594
intptr_t Length() const
Definition: dartutils.h:593
Dart_CObject_Type type()
Definition: dartutils.h:338
static Dart_CObject * NewString(const char *str)
Definition: dartutils.cc:927
static CObject * IllegalArgumentError()
Definition: dartutils.cc:1026
static CObject * FileClosedError()
Definition: dartutils.cc:1032
static Dart_CObject * NewExternalUint8Array(intptr_t length, uint8_t *data, void *peer, Dart_HandleFinalizer callback)
Definition: dartutils.cc:955
static void FreeIOBufferData(Dart_CObject *object)
Definition: dartutils.cc:1019
bool IsInt32OrInt64()
Definition: dartutils.h:349
static Dart_CObject * NewIntptr(intptr_t value)
Definition: dartutils.cc:914
static constexpr int kOSError
Definition: dartutils.h:334
static constexpr int kFileClosedError
Definition: dartutils.h:335
static Dart_CObject * NewIOBuffer(int64_t length)
Definition: dartutils.cc:978
static CObject * Bool(bool value)
Definition: dartutils.cc:891
Dart_CObject * AsApiCObject()
Definition: dartutils.h:394
static Dart_CObject * NewArray(intptr_t length)
Definition: dartutils.cc:936
Dart_TypedData_Type byte_array_type()
Definition: dartutils.h:339
static CObject * True()
Definition: dartutils.cc:883
Dart_CObject * cobject_
Definition: dartutils.h:407
static Dart_CObject * NewUint8Array(const void *data, intptr_t length)
Definition: dartutils.cc:945
static constexpr int kSuccess
Definition: dartutils.h:332
static constexpr int kArgumentError
Definition: dartutils.h:333
CObject(Dart_CObject *cobject)
Definition: dartutils.h:337
static Dart_CObject * NewNativePointer(intptr_t ptr, intptr_t size, Dart_HandleFinalizer callback)
Definition: dartutils.cc:968
static Dart_CObject * NewInt32(int32_t value)
Definition: dartutils.cc:902
static Dart_CObject * NewInt64(int64_t value)
Definition: dartutils.cc:908
static Dart_CObject * NewDouble(double value)
Definition: dartutils.cc:921
static CObject * NewOSError()
Definition: dartutils.cc:1038
static void ShrinkIOBuffer(Dart_CObject *cobject, int64_t new_length)
Definition: dartutils.cc:993
static CObject * Null()
Definition: dartutils.cc:879
static CObject * False()
Definition: dartutils.cc:887
const char ** arguments() const
Definition: dartutils.h:63
void AddArguments(const char **argv, int argc)
Definition: dartutils.h:77
void AddArgument(const char *argument)
Definition: dartutils.h:68
CommandLineOptions(int max_count)
Definition: dartutils.h:44
Dart_Handle CreateRuntimeOptions()
Definition: dartutils.cc:58
const char * GetArgument(int index) const
Definition: dartutils.h:65
static constexpr const char * kDartScheme
Definition: dartutils.h:290
static constexpr const char * kCLILibURL
Definition: dartutils.h:299
static constexpr const char * kCLILibPatchURL
Definition: dartutils.h:300
static int64_t GetNativeIntegerArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:156
static Dart_Handle NewDartFormatException(const char *message)
Definition: dartutils.cc:750
static char static char * ScopedCStringVFormatted(const char *format, va_list args)
Definition: dartutils.cc:793
static int64_t GetIntegerValue(Dart_Handle value_obj)
Definition: dartutils.cc:81
static Dart_Handle SetupPackageConfig(const char *packages_file)
Definition: dartutils.cc:555
static int64_t GetInt64ValueCheckRange(Dart_Handle value_obj, int64_t lower, int64_t upper)
Definition: dartutils.cc:90
static Dart_Handle NewDartExceptionWithMessage(const char *library_url, const char *exception_name, const char *message)
Definition: dartutils.cc:731
static Dart_Handle LookupBuiltinLib()
Definition: dartutils.h:248
static constexpr const char * kIOLibURL
Definition: dartutils.h:297
static const char * GetNativeTypedDataArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:195
static constexpr const char * kVMServiceLibURL
Definition: dartutils.h:303
static Dart_Handle NewDartOSError()
Definition: dartutils.cc:702
static constexpr const char * kAsyncLibURL
Definition: dartutils.h:291
static constexpr const char * kIsolateLibURL
Definition: dartutils.h:295
static char * DirName(const char *url)
Definition: dartutils.cc:252
static void ReadFile(uint8_t **data, intptr_t *file_len, void *stream)
Definition: dartutils.cc:273
static Dart_Handle ReadStringFromFile(const char *filename)
Definition: dartutils.cc:348
static bool GetBooleanValue(Dart_Handle bool_obj)
Definition: dartutils.cc:137
static bool GetInt64Value(Dart_Handle value_obj, int64_t *value)
Definition: dartutils.cc:112
static bool IsHttpSchemeURL(const char *url_name)
Definition: dartutils.cc:222
static const char * GetStringValue(Dart_Handle str_obj)
Definition: dartutils.cc:128
static void * OpenFileUri(const char *uri, bool write)
Definition: dartutils.cc:267
static Dart_Handle NewDartExceptionWithOSError(const char *library_url, const char *exception_name, const char *message, Dart_Handle os_error)
Definition: dartutils.cc:718
static Dart_Handle MakeUint8Array(const void *buffer, intptr_t length)
Definition: dartutils.cc:360
static void * MapExecutable(const char *name, intptr_t *file_len)
static bool IsDartBuiltinLibURL(const char *url_name)
Definition: dartutils.cc:239
static constexpr const char * kInternalLibURL
Definition: dartutils.h:294
static Dart_Handle SetupIOLibrary(const char *namespc_path, const char *script_uri, bool disable_exit)
Definition: dartutils.cc:617
static bool PostInt32(Dart_Port port_id, int32_t value)
Definition: dartutils.cc:672
static Dart_Handle NewStringFormatted(const char *format,...)
Definition: dartutils.cc:785
static constexpr const char * kIOLibPatchURL
Definition: dartutils.h:298
static const char * original_working_directory
Definition: dartutils.h:288
static bool SetOriginalWorkingDirectory()
Definition: dartutils.cc:821
static bool PostNull(Dart_Port port_id)
Definition: dartutils.cc:667
static Dart_Handle NewError(const char *format,...)
Definition: dartutils.cc:766
static char * ScopedCStringFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: dartutils.cc:813
static bool EntropySource(uint8_t *buffer, intptr_t length)
Definition: dartutils.cc:308
static Dart_Handle EnvironmentCallback(Dart_Handle name)
Definition: dartutils.cc:835
static Dart_Handle NewDartIOException(const char *exception_name, const char *message, Dart_Handle os_error)
Definition: dartutils.cc:758
static char * ScopedCopyCString(const char *str)
Definition: dartutils.h:232
static bool PostString(Dart_Port port_id, const char *value)
Definition: dartutils.cc:691
static constexpr const char * kHttpLibURL
Definition: dartutils.h:296
static constexpr const char * kCoreLibURL
Definition: dartutils.h:293
static bool PostInt64(Dart_Port port_id, int64_t value)
Definition: dartutils.cc:683
static Dart_Handle NewDartUnsupportedError(const char *message)
Definition: dartutils.cc:754
static intptr_t GetNativeIntptrArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:166
static char * ScopedCString(intptr_t length)
Definition: dartutils.h:224
static Dart_Handle NewString(const char *str)
Definition: dartutils.h:214
static Dart_Handle PrepareForScriptLoading(bool is_service_isolate, bool trace_loading)
Definition: dartutils.cc:570
static void SetEnvironment(dart::SimpleHashMap *environment)
Definition: dartutils.cc:831
static Dart_Handle SetIntegerField(Dart_Handle handle, const char *name, int64_t val)
Definition: dartutils.cc:203
static void CloseFile(void *stream)
Definition: dartutils.cc:303
static Dart_Handle NewDartArgumentError(const char *message)
Definition: dartutils.cc:746
static MagicNumber SniffForMagicNumber(const char *filename)
Definition: dartutils.cc:403
static void * OpenFile(const char *name, bool write)
Definition: dartutils.cc:261
static Dart_Handle NewInternalError(const char *message)
Definition: dartutils.cc:781
static const char * RemoveScheme(const char *url)
Definition: dartutils.cc:243
static bool IsDartCLILibURL(const char *url_name)
Definition: dartutils.cc:231
static constexpr const char * kBuiltinLibURL
Definition: dartutils.h:292
static bool IsDartSchemeURL(const char *url_name)
Definition: dartutils.cc:215
static Dart_Handle SetStringField(Dart_Handle handle, const char *name, const char *val)
Definition: dartutils.cc:209
static bool IsDartHttpLibURL(const char *url_name)
Definition: dartutils.cc:235
static bool IsAotMagicNumber(MagicNumber number)
Definition: dartutils.h:275
static constexpr int64_t kMaxMagicNumberSize
Definition: dartutils.h:271
static Dart_Handle ResolveScript(Dart_Handle url)
Definition: dartutils.cc:386
static bool IsDartIOLibURL(const char *url_name)
Definition: dartutils.cc:227
static Dart_Handle GetDartType(const char *library_url, const char *class_name)
Definition: dartutils.cc:696
static intptr_t GetIntptrValue(Dart_Handle value_obj)
Definition: dartutils.cc:100
static constexpr const char * kHttpScheme
Definition: dartutils.h:302
static constexpr const char * kUriLibURL
Definition: dartutils.h:301
static const char * GetNativeStringArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:175
static void WriteFile(const void *buffer, intptr_t num_bytes, void *stream)
Definition: dartutils.cc:294
static bool GetNativeBooleanArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:146
int64_t Dart_Port
Definition: dart_api.h:1525
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
void(* Dart_HandleFinalizer)(void *isolate_callback_data, void *peer)
Definition: dart_api.h:265
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
Dart_TypedData_Type
Definition: dart_api.h:2612
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
Dart_CObject_Type
@ Dart_CObject_kInt64
@ Dart_CObject_kDouble
@ Dart_CObject_kTypedData
@ Dart_CObject_kSendPort
@ Dart_CObject_kString
@ Dart_CObject_kArray
@ Dart_CObject_kNull
@ Dart_CObject_kExternalTypedData
@ Dart_CObject_kInt32
@ Dart_CObject_kBool
#define DECLARE_COBJECT_TYPED_DATA_CONSTRUCTORS(t)
Definition: dartutils.h:434
#define DECLARE_COBJECT_CONSTRUCTORS(t)
Definition: dartutils.h:423
#define DECLARE_COBJECT_EXTERNAL_TYPED_DATA_CONSTRUCTORS(t)
Definition: dartutils.h:447
#define ASSERT(E)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value
GAsyncResult * result
uint32_t uint32_t * format
size_t length
Win32Message message
char ** argv
Definition: library.h:9
MagicNumberData gzip_magic_number
Definition: dartutils.cc:48
MagicNumberData appjit_magic_number
Definition: dartutils.cc:35
static Dart_Handle ThrowIfError(Dart_Handle handle)
Definition: dartutils.h:31
static void * GetHashmapKeyFromString(char *key)
Definition: dartutils.h:38
MagicNumberData kernel_list_magic_number
Definition: dartutils.cc:45
MagicNumberData aotelf_magic_number
Definition: dartutils.cc:36
MagicNumberData kernel_magic_number
Definition: dartutils.cc:44
PRINTF_ATTRIBUTE(1, 2) static void PrintErrAndExit(const char *format
static dart::SimpleHashMap * environment
Definition: gen_snapshot.cc:59
Definition: dart_vm.cc:33
const char *const name
DART_EXPORT void Dart_ThreadEnableProfiling()
void * malloc(size_t size)
Definition: allocation.cc:19
const char *const class_name
DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t *utf8_array, intptr_t length)
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT void Dart_ThreadDisableProfiling()
constexpr intptr_t kWordSize
Definition: globals.h:509
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
static int8_t data[kExtLength]
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
void write(SkWStream *wStream, const T &text)
Definition: skqp.cpp:188
struct _Dart_CObject::@86::@87 as_send_port
Dart_HandleFinalizer callback
union _Dart_CObject::@86 value
Dart_CObject_Type type
uint8_t * data
struct _Dart_CObject::@86::@90 as_typed_data
const char * as_string
struct _Dart_CObject::@86::@91 as_external_typed_data
struct _Dart_CObject::@86::@89 as_array
struct _Dart_CObject ** values
Dart_Port origin_id
struct _Dart_CObject::@86::@92 as_native_pointer
const uint8_t bytes[kMaxLength]
Definition: dartutils.h:657
static constexpr intptr_t kMaxLength
Definition: dartutils.h:654