| Index: runtime/bin/dartutils.cc
|
| diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
|
| index a07306dadec3e7cf78bd683471a94bbdc8125774..b8f49b1893296f600b19ea4a561f19c6af62f11b 100644
|
| --- a/runtime/bin/dartutils.cc
|
| +++ b/runtime/bin/dartutils.cc
|
| @@ -47,7 +47,6 @@ const char* const DartUtils::kUriLibURL = "dart:uri";
|
| const char* const DartUtils::kHttpScheme = "http:";
|
| const char* const DartUtils::kVMServiceLibURL = "dart:vmservice";
|
|
|
| -
|
| struct MagicNumberData {
|
| static const intptr_t kLength = 4;
|
|
|
| @@ -55,11 +54,9 @@ struct MagicNumberData {
|
| bool should_skip;
|
| };
|
|
|
| -
|
| MagicNumberData snapshot_magic_number = {{0xf5, 0xf5, 0xdc, 0xdc}, true};
|
| MagicNumberData kernel_magic_number = {{0x90, 0xab, 0xcd, 0xef}, false};
|
|
|
| -
|
| static bool IsWindowsHost() {
|
| #if defined(HOST_OS_WINDOWS)
|
| return true;
|
| @@ -68,7 +65,6 @@ static bool IsWindowsHost() {
|
| #endif // defined(HOST_OS_WINDOWS)
|
| }
|
|
|
| -
|
| const char* DartUtils::MapLibraryUrl(const char* url_string) {
|
| ASSERT(url_mapping != NULL);
|
| // We need to check if the passed in url is found in the url_mapping array,
|
| @@ -86,7 +82,6 @@ const char* DartUtils::MapLibraryUrl(const char* url_string) {
|
| return NULL; // Did not find a mapping for this URL.
|
| }
|
|
|
| -
|
| int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
|
| int64_t value = 0;
|
| Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
|
| @@ -94,7 +89,6 @@ int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
|
| return value;
|
| }
|
|
|
| -
|
| int64_t DartUtils::GetInt64ValueCheckRange(Dart_Handle value_obj,
|
| int64_t lower,
|
| int64_t upper) {
|
| @@ -105,7 +99,6 @@ int64_t DartUtils::GetInt64ValueCheckRange(Dart_Handle value_obj,
|
| return value;
|
| }
|
|
|
| -
|
| intptr_t DartUtils::GetIntptrValue(Dart_Handle value_obj) {
|
| int64_t value = 0;
|
| Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
|
| @@ -116,7 +109,6 @@ intptr_t DartUtils::GetIntptrValue(Dart_Handle value_obj) {
|
| return static_cast<intptr_t>(value);
|
| }
|
|
|
| -
|
| bool DartUtils::GetInt64Value(Dart_Handle value_obj, int64_t* value) {
|
| bool valid = Dart_IsInteger(value_obj);
|
| if (valid) {
|
| @@ -129,7 +121,6 @@ bool DartUtils::GetInt64Value(Dart_Handle value_obj, int64_t* value) {
|
| return true;
|
| }
|
|
|
| -
|
| const char* DartUtils::GetStringValue(Dart_Handle str_obj) {
|
| const char* cstring = NULL;
|
| Dart_Handle result = Dart_StringToCString(str_obj, &cstring);
|
| @@ -137,7 +128,6 @@ const char* DartUtils::GetStringValue(Dart_Handle str_obj) {
|
| return cstring;
|
| }
|
|
|
| -
|
| bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) {
|
| bool value = false;
|
| Dart_Handle result = Dart_BooleanValue(bool_obj, &value);
|
| @@ -145,21 +135,18 @@ bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) {
|
| return value;
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::SetIntegerField(Dart_Handle handle,
|
| const char* name,
|
| int64_t val) {
|
| return Dart_SetField(handle, NewString(name), Dart_NewInteger(val));
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::SetStringField(Dart_Handle handle,
|
| const char* name,
|
| const char* val) {
|
| return Dart_SetField(handle, NewString(name), NewString(val));
|
| }
|
|
|
| -
|
| bool DartUtils::IsDartSchemeURL(const char* url_name) {
|
| static const intptr_t kDartSchemeLen = strlen(kDartScheme);
|
| // If the URL starts with "dart:" then it is considered as a special
|
| @@ -167,13 +154,11 @@ bool DartUtils::IsDartSchemeURL(const char* url_name) {
|
| return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0);
|
| }
|
|
|
| -
|
| bool DartUtils::IsHttpSchemeURL(const char* url_name) {
|
| static const intptr_t kHttpSchemeLen = strlen(kHttpScheme);
|
| return (strncmp(url_name, kHttpScheme, kHttpSchemeLen) == 0);
|
| }
|
|
|
| -
|
| bool DartUtils::IsDartExtensionSchemeURL(const char* url_name) {
|
| static const intptr_t kDartExtensionSchemeLen = strlen(kDartExtensionScheme);
|
| // If the URL starts with "dartext:" then it is considered as a special
|
| @@ -182,17 +167,14 @@ bool DartUtils::IsDartExtensionSchemeURL(const char* url_name) {
|
| 0);
|
| }
|
|
|
| -
|
| bool DartUtils::IsDartIOLibURL(const char* url_name) {
|
| return (strcmp(url_name, kIOLibURL) == 0);
|
| }
|
|
|
| -
|
| bool DartUtils::IsDartBuiltinLibURL(const char* url_name) {
|
| return (strcmp(url_name, kBuiltinLibURL) == 0);
|
| }
|
|
|
| -
|
| const char* DartUtils::RemoveScheme(const char* url) {
|
| const char* colon = strchr(url, ':');
|
| if (colon == NULL) {
|
| @@ -202,7 +184,6 @@ const char* DartUtils::RemoveScheme(const char* url) {
|
| }
|
| }
|
|
|
| -
|
| char* DartUtils::DirName(const char* url) {
|
| const char* slash = strrchr(url, File::PathSeparator()[0]);
|
| if (slash == NULL) {
|
| @@ -212,13 +193,11 @@ char* DartUtils::DirName(const char* url) {
|
| }
|
| }
|
|
|
| -
|
| void* DartUtils::OpenFile(const char* name, bool write) {
|
| File* file = File::Open(name, write ? File::kWriteTruncate : File::kRead);
|
| return reinterpret_cast<void*>(file);
|
| }
|
|
|
| -
|
| void DartUtils::ReadFile(const uint8_t** data, intptr_t* len, void* stream) {
|
| ASSERT(data != NULL);
|
| ASSERT(len != NULL);
|
| @@ -241,7 +220,6 @@ void DartUtils::ReadFile(const uint8_t** data, intptr_t* len, void* stream) {
|
| *data = text_buffer;
|
| }
|
|
|
| -
|
| void DartUtils::WriteFile(const void* buffer,
|
| intptr_t num_bytes,
|
| void* stream) {
|
| @@ -251,18 +229,15 @@ void DartUtils::WriteFile(const void* buffer,
|
| ASSERT(bytes_written);
|
| }
|
|
|
| -
|
| void DartUtils::CloseFile(void* stream) {
|
| File* file = reinterpret_cast<File*>(stream);
|
| file->Release();
|
| }
|
|
|
| -
|
| bool DartUtils::EntropySource(uint8_t* buffer, intptr_t length) {
|
| return Crypto::GetRandomBytes(length, buffer);
|
| }
|
|
|
| -
|
| static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib,
|
| const char* method,
|
| Dart_Handle arg) {
|
| @@ -272,7 +247,6 @@ static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib,
|
| return Dart_Invoke(lib, DartUtils::NewString(method), kNumArgs, dart_args);
|
| }
|
|
|
| -
|
| // TODO(iposva): Allocate from the zone instead of leaking error string
|
| // here. On the other hand the binary is about to exit anyway.
|
| #define SET_ERROR_MSG(error_msg, format, ...) \
|
| @@ -281,7 +255,6 @@ static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib,
|
| snprintf(msg, len + 1, format, __VA_ARGS__); \
|
| *error_msg = msg
|
|
|
| -
|
| static const uint8_t* ReadFileFully(const char* filename,
|
| intptr_t* file_len,
|
| const char** error_msg) {
|
| @@ -301,7 +274,6 @@ static const uint8_t* ReadFileFully(const char* filename,
|
| return text_buffer;
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::ReadStringFromFile(const char* filename) {
|
| const char* error_msg = NULL;
|
| intptr_t len;
|
| @@ -314,7 +286,6 @@ Dart_Handle DartUtils::ReadStringFromFile(const char* filename) {
|
| return str;
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::MakeUint8Array(const uint8_t* buffer, intptr_t len) {
|
| Dart_Handle array = Dart_NewTypedData(Dart_TypedData_kUint8, len);
|
| RETURN_IF_ERROR(array);
|
| @@ -335,7 +306,6 @@ Dart_Handle DartUtils::MakeUint8Array(const uint8_t* buffer, intptr_t len) {
|
| return array;
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::SetWorkingDirectory() {
|
| IsolateData* isolate_data =
|
| reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
|
| @@ -344,7 +314,6 @@ Dart_Handle DartUtils::SetWorkingDirectory() {
|
| return SingleArgDart_Invoke(builtin_lib, "_setWorkingDirectory", directory);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::ResolveUriInWorkingDirectory(Dart_Handle script_uri) {
|
| const int kNumArgs = 1;
|
| Dart_Handle dart_args[kNumArgs];
|
| @@ -354,7 +323,6 @@ Dart_Handle DartUtils::ResolveUriInWorkingDirectory(Dart_Handle script_uri) {
|
| dart_args);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::LibraryFilePath(Dart_Handle library_uri) {
|
| const int kNumArgs = 1;
|
| Dart_Handle dart_args[kNumArgs];
|
| @@ -363,7 +331,6 @@ Dart_Handle DartUtils::LibraryFilePath(Dart_Handle library_uri) {
|
| kNumArgs, dart_args);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::ResolveScript(Dart_Handle url) {
|
| const int kNumArgs = 1;
|
| Dart_Handle dart_args[kNumArgs];
|
| @@ -372,7 +339,6 @@ Dart_Handle DartUtils::ResolveScript(Dart_Handle url) {
|
| kNumArgs, dart_args);
|
| }
|
|
|
| -
|
| static Dart_Handle LoadDataAsync_Invoke(Dart_Handle tag,
|
| Dart_Handle url,
|
| Dart_Handle library_url) {
|
| @@ -386,7 +352,6 @@ static Dart_Handle LoadDataAsync_Invoke(Dart_Handle tag,
|
| dart_args);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag,
|
| Dart_Handle library,
|
| Dart_Handle url) {
|
| @@ -471,7 +436,6 @@ Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag,
|
| return LoadDataAsync_Invoke(Dart_NewInteger(tag), url, library_url);
|
| }
|
|
|
| -
|
| static bool CheckMagicNumber(const uint8_t** buf,
|
| intptr_t* len,
|
| const MagicNumberData& magic_number) {
|
| @@ -486,7 +450,6 @@ static bool CheckMagicNumber(const uint8_t** buf,
|
| return false;
|
| }
|
|
|
| -
|
| DartUtils::MagicNumber DartUtils::SniffForMagicNumber(const uint8_t** buf,
|
| intptr_t* len) {
|
| if (CheckMagicNumber(buf, len, snapshot_magic_number)) {
|
| @@ -500,7 +463,6 @@ DartUtils::MagicNumber DartUtils::SniffForMagicNumber(const uint8_t** buf,
|
| return kUnknownMagicNumber;
|
| }
|
|
|
| -
|
| void DartUtils::WriteMagicNumber(File* file) {
|
| // Write a magic number and version information into the snapshot file.
|
| bool bytes_written =
|
| @@ -508,7 +470,6 @@ void DartUtils::WriteMagicNumber(File* file) {
|
| ASSERT(bytes_written);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::LoadScript(const char* script_uri) {
|
| Dart_TimelineEvent("LoadScript", Dart_TimelineGetMicros(),
|
| Dart_GetMainPortId(), Dart_Timeline_Event_Async_Begin, 0,
|
| @@ -517,7 +478,6 @@ Dart_Handle DartUtils::LoadScript(const char* script_uri) {
|
| return LoadDataAsync_Invoke(Dart_Null(), uri, Dart_Null());
|
| }
|
|
|
| -
|
| void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) {
|
| const char* current = Directory::Current();
|
| if (current != NULL) {
|
| @@ -528,7 +488,6 @@ void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) {
|
| }
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
|
| Dart_Handle internal_lib,
|
| bool is_service_isolate,
|
| @@ -558,7 +517,6 @@ Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
|
| return Dart_True();
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::PrepareCoreLibrary(Dart_Handle core_lib,
|
| Dart_Handle builtin_lib,
|
| bool is_service_isolate) {
|
| @@ -574,7 +532,6 @@ Dart_Handle DartUtils::PrepareCoreLibrary(Dart_Handle core_lib,
|
| return Dart_True();
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib,
|
| Dart_Handle isolate_lib) {
|
| Dart_Handle schedule_immediate_closure = Dart_Invoke(
|
| @@ -586,17 +543,14 @@ Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib,
|
| args);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::PrepareIOLibrary(Dart_Handle io_lib) {
|
| return Dart_Invoke(io_lib, NewString("_setupHooks"), 0, NULL);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) {
|
| return Dart_Invoke(isolate_lib, NewString("_setupHooks"), 0, NULL);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::SetupServiceLoadPort() {
|
| // Wait for the service isolate to initialize the load port.
|
| Dart_Port load_port = Dart_ServiceWaitForLoadPort();
|
| @@ -607,7 +561,6 @@ Dart_Handle DartUtils::SetupServiceLoadPort() {
|
| return Builtin::SetLoadPort(load_port);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::SetupPackageRoot(const char* package_root,
|
| const char* packages_config) {
|
| // Set up package root if specified.
|
| @@ -634,7 +587,6 @@ Dart_Handle DartUtils::SetupPackageRoot(const char* package_root,
|
| return Dart_True();
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::PrepareForScriptLoading(bool is_service_isolate,
|
| bool trace_loading) {
|
| // First ensure all required libraries are available.
|
| @@ -686,7 +638,6 @@ Dart_Handle DartUtils::PrepareForScriptLoading(bool is_service_isolate,
|
| return result;
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::SetupIOLibrary(const char* script_uri) {
|
| Dart_Handle io_lib_url = NewString(kIOLibURL);
|
| RETURN_IF_ERROR(io_lib_url);
|
| @@ -704,13 +655,11 @@ Dart_Handle DartUtils::SetupIOLibrary(const char* script_uri) {
|
| return Dart_Null();
|
| }
|
|
|
| -
|
| bool DartUtils::PostNull(Dart_Port port_id) {
|
| // Post a message with just the null object.
|
| return Dart_PostCObject(port_id, CObject::Null()->AsApiCObject());
|
| }
|
|
|
| -
|
| bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) {
|
| // Post a message with the integer value.
|
| int32_t min = 0xc0000000; // -1073741824
|
| @@ -722,7 +671,6 @@ bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) {
|
| return Dart_PostCObject(port_id, &object);
|
| }
|
|
|
| -
|
| bool DartUtils::PostInt64(Dart_Port port_id, int64_t value) {
|
| // Post a message with the integer value.
|
| Dart_CObject object;
|
| @@ -731,21 +679,18 @@ bool DartUtils::PostInt64(Dart_Port port_id, int64_t value) {
|
| return Dart_PostCObject(port_id, &object);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::GetDartType(const char* library_url,
|
| const char* class_name) {
|
| return Dart_GetType(Dart_LookupLibrary(NewString(library_url)),
|
| NewString(class_name), 0, NULL);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartOSError() {
|
| // Extract the current OS error.
|
| OSError os_error;
|
| return NewDartOSError(&os_error);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartOSError(OSError* os_error) {
|
| // Create a dart:io OSError object with the information retrieved from the OS.
|
| Dart_Handle type = GetDartType(kIOLibURL, "OSError");
|
| @@ -756,7 +701,6 @@ Dart_Handle DartUtils::NewDartOSError(OSError* os_error) {
|
| return Dart_New(type, Dart_Null(), 2, args);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartExceptionWithOSError(const char* library_url,
|
| const char* exception_name,
|
| const char* message,
|
| @@ -770,7 +714,6 @@ Dart_Handle DartUtils::NewDartExceptionWithOSError(const char* library_url,
|
| return Dart_New(type, Dart_Null(), 2, args);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url,
|
| const char* exception_name,
|
| const char* message) {
|
| @@ -786,17 +729,14 @@ Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url,
|
| }
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartArgumentError(const char* message) {
|
| return NewDartExceptionWithMessage(kCoreLibURL, "ArgumentError", message);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartUnsupportedError(const char* message) {
|
| return NewDartExceptionWithMessage(kCoreLibURL, "UnsupportedError", message);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewDartIOException(const char* exception_name,
|
| const char* message,
|
| Dart_Handle os_error) {
|
| @@ -805,7 +745,6 @@ Dart_Handle DartUtils::NewDartIOException(const char* exception_name,
|
| os_error);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewError(const char* format, ...) {
|
| va_list args;
|
| va_start(args, format);
|
| @@ -822,18 +761,15 @@ Dart_Handle DartUtils::NewError(const char* format, ...) {
|
| return Dart_NewApiError(buffer);
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::NewInternalError(const char* message) {
|
| return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message);
|
| }
|
|
|
| -
|
| bool DartUtils::SetOriginalWorkingDirectory() {
|
| original_working_directory = Directory::CurrentNoScope();
|
| return original_working_directory != NULL;
|
| }
|
|
|
| -
|
| Dart_Handle DartUtils::GetCanonicalizableWorkingDirectory() {
|
| const char* str = DartUtils::original_working_directory;
|
| intptr_t len = strlen(str);
|
| @@ -845,7 +781,6 @@ Dart_Handle DartUtils::GetCanonicalizableWorkingDirectory() {
|
| return Dart_NewStringFromCString(new_str);
|
| }
|
|
|
| -
|
| // Statically allocated Dart_CObject instances for immutable
|
| // objects. As these will be used by different threads the use of
|
| // these depends on the fact that the marking internally in the
|
| @@ -857,27 +792,22 @@ CObject CObject::null_ = CObject(&api_null_);
|
| CObject CObject::true_ = CObject(&api_true_);
|
| CObject CObject::false_ = CObject(&api_false_);
|
|
|
| -
|
| CObject* CObject::Null() {
|
| return &null_;
|
| }
|
|
|
| -
|
| CObject* CObject::True() {
|
| return &true_;
|
| }
|
|
|
| -
|
| CObject* CObject::False() {
|
| return &false_;
|
| }
|
|
|
| -
|
| CObject* CObject::Bool(bool value) {
|
| return value ? &true_ : &false_;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::New(Dart_CObject_Type type, int additional_bytes) {
|
| Dart_CObject* cobject = reinterpret_cast<Dart_CObject*>(
|
| Dart_ScopeAllocate(sizeof(Dart_CObject) + additional_bytes));
|
| @@ -885,21 +815,18 @@ Dart_CObject* CObject::New(Dart_CObject_Type type, int additional_bytes) {
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewInt32(int32_t value) {
|
| Dart_CObject* cobject = New(Dart_CObject_kInt32);
|
| cobject->value.as_int32 = value;
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewInt64(int64_t value) {
|
| Dart_CObject* cobject = New(Dart_CObject_kInt64);
|
| cobject->value.as_int64 = value;
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewIntptr(intptr_t value) {
|
| // Pointer values passed as intptr_t are always send as int64_t.
|
| Dart_CObject* cobject = New(Dart_CObject_kInt64);
|
| @@ -907,20 +834,17 @@ Dart_CObject* CObject::NewIntptr(intptr_t value) {
|
| return cobject;
|
| }
|
|
|
| -
|
| static bool IsHexDigit(char c) {
|
| return (('0' <= c) && (c <= '9')) || (('A' <= c) && (c <= 'F')) ||
|
| (('a' <= c) && (c <= 'f'));
|
| }
|
|
|
| -
|
| static int HexDigitToInt(char c) {
|
| if (('0' <= c) && (c <= '9')) return c - '0';
|
| if (('A' <= c) && (c <= 'F')) return 10 + (c - 'A');
|
| return 10 + (c - 'a');
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewBigint(const char* hex_value) {
|
| if (hex_value == NULL) {
|
| return NULL;
|
| @@ -976,14 +900,12 @@ Dart_CObject* CObject::NewBigint(const char* hex_value) {
|
| return cobject;
|
| }
|
|
|
| -
|
| static char IntToHexDigit(int i) {
|
| ASSERT(0 <= i && i < 16);
|
| if (i < 10) return static_cast<char>('0' + i);
|
| return static_cast<char>('A' + (i - 10));
|
| }
|
|
|
| -
|
| char* CObject::BigintToHexValue(Dart_CObject* bigint) {
|
| ASSERT(bigint->type == Dart_CObject_kBigint);
|
| const intptr_t used = bigint->value.as_bigint.used;
|
| @@ -1037,21 +959,18 @@ char* CObject::BigintToHexValue(Dart_CObject* bigint) {
|
| return hex_value;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewDouble(double value) {
|
| Dart_CObject* cobject = New(Dart_CObject_kDouble);
|
| cobject->value.as_double = value;
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewString(intptr_t length) {
|
| Dart_CObject* cobject = New(Dart_CObject_kString, length + 1);
|
| cobject->value.as_string = reinterpret_cast<char*>(cobject + 1);
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewString(const char* str) {
|
| intptr_t length = strlen(str);
|
| Dart_CObject* cobject = NewString(length);
|
| @@ -1059,7 +978,6 @@ Dart_CObject* CObject::NewString(const char* str) {
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewArray(intptr_t length) {
|
| Dart_CObject* cobject =
|
| New(Dart_CObject_kArray, length * sizeof(Dart_CObject*)); // NOLINT
|
| @@ -1069,7 +987,6 @@ Dart_CObject* CObject::NewArray(intptr_t length) {
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewUint8Array(intptr_t length) {
|
| Dart_CObject* cobject = New(Dart_CObject_kTypedData, length);
|
| cobject->value.as_typed_data.type = Dart_TypedData_kUint8;
|
| @@ -1078,7 +995,6 @@ Dart_CObject* CObject::NewUint8Array(intptr_t length) {
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewUint32Array(intptr_t length) {
|
| Dart_CObject* cobject = New(Dart_CObject_kTypedData, 4 * length);
|
| cobject->value.as_typed_data.type = Dart_TypedData_kUint32;
|
| @@ -1087,7 +1003,6 @@ Dart_CObject* CObject::NewUint32Array(intptr_t length) {
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewExternalUint8Array(
|
| intptr_t length,
|
| uint8_t* data,
|
| @@ -1102,7 +1017,6 @@ Dart_CObject* CObject::NewExternalUint8Array(
|
| return cobject;
|
| }
|
|
|
| -
|
| Dart_CObject* CObject::NewIOBuffer(int64_t length) {
|
| // Make sure that we do not have an integer overflow here. Actual check
|
| // against max elements will be done at the time of writing, as the constant
|
| @@ -1116,7 +1030,6 @@ Dart_CObject* CObject::NewIOBuffer(int64_t length) {
|
| IOBuffer::Finalizer);
|
| }
|
|
|
| -
|
| void CObject::FreeIOBufferData(Dart_CObject* cobject) {
|
| ASSERT(cobject->type == Dart_CObject_kExternalTypedData);
|
| cobject->value.as_external_typed_data.callback(
|
| @@ -1124,21 +1037,18 @@ void CObject::FreeIOBufferData(Dart_CObject* cobject) {
|
| cobject->value.as_external_typed_data.data = NULL;
|
| }
|
|
|
| -
|
| CObject* CObject::IllegalArgumentError() {
|
| CObjectArray* result = new CObjectArray(CObject::NewArray(1));
|
| result->SetAt(0, new CObjectInt32(CObject::NewInt32(kArgumentError)));
|
| return result;
|
| }
|
|
|
| -
|
| CObject* CObject::FileClosedError() {
|
| CObjectArray* result = new CObjectArray(CObject::NewArray(1));
|
| result->SetAt(0, new CObjectInt32(CObject::NewInt32(kFileClosedError)));
|
| return result;
|
| }
|
|
|
| -
|
| CObject* CObject::NewOSError() {
|
| OSError os_error;
|
| return NewOSError(&os_error);
|
|
|