OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 4725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4736 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 4736 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
4737 arguments->SetReturn(Bool::Get(retval)); | 4737 arguments->SetReturn(Bool::Get(retval)); |
4738 } | 4738 } |
4739 | 4739 |
4740 | 4740 |
4741 DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, | 4741 DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, |
4742 int64_t retval) { | 4742 int64_t retval) { |
4743 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 4743 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
4744 ASSERT(arguments->isolate() == Isolate::Current()); | 4744 ASSERT(arguments->isolate() == Isolate::Current()); |
4745 if (Smi::IsValid(retval)) { | 4745 if (Smi::IsValid(retval)) { |
4746 Api::SetSmiReturnValue(arguments, retval); | 4746 Api::SetSmiReturnValue(arguments, static_cast<intptr_t>(retval)); |
4747 } else { | 4747 } else { |
4748 // Slow path for Mints and Bigints. | 4748 // Slow path for Mints and Bigints. |
4749 ASSERT_CALLBACK_STATE(arguments->isolate()); | 4749 ASSERT_CALLBACK_STATE(arguments->isolate()); |
4750 Api::SetIntegerReturnValue(arguments, retval); | 4750 Api::SetIntegerReturnValue(arguments, retval); |
4751 } | 4751 } |
4752 } | 4752 } |
4753 | 4753 |
4754 | 4754 |
4755 DART_EXPORT void Dart_SetDoubleReturnValue(Dart_NativeArguments args, | 4755 DART_EXPORT void Dart_SetDoubleReturnValue(Dart_NativeArguments args, |
4756 double retval) { | 4756 double retval) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4855 RETURN_NULL_ERROR(buffer); | 4855 RETURN_NULL_ERROR(buffer); |
4856 } | 4856 } |
4857 NoHeapGrowthControlScope no_growth_control; | 4857 NoHeapGrowthControlScope no_growth_control; |
4858 | 4858 |
4859 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 4859 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
4860 if (!snapshot->IsScriptSnapshot()) { | 4860 if (!snapshot->IsScriptSnapshot()) { |
4861 return Api::NewError("%s expects parameter 'buffer' to be a script type" | 4861 return Api::NewError("%s expects parameter 'buffer' to be a script type" |
4862 " snapshot.", CURRENT_FUNC); | 4862 " snapshot.", CURRENT_FUNC); |
4863 } | 4863 } |
4864 if (snapshot->length() != buffer_len) { | 4864 if (snapshot->length() != buffer_len) { |
4865 return Api::NewError("%s: 'buffer_len' of %" Pd " is not equal to %" Pd64 | 4865 return Api::NewError("%s: 'buffer_len' of %" Pd " is not equal to %" Pd |
4866 " which is the expected length in the snapshot.", | 4866 " which is the expected length in the snapshot.", |
4867 CURRENT_FUNC, buffer_len, snapshot->length()); | 4867 CURRENT_FUNC, buffer_len, snapshot->length()); |
4868 } | 4868 } |
4869 Library& library = | 4869 Library& library = |
4870 Library::Handle(isolate, isolate->object_store()->root_library()); | 4870 Library::Handle(isolate, isolate->object_store()->root_library()); |
4871 if (!library.IsNull()) { | 4871 if (!library.IsNull()) { |
4872 const String& library_url = String::Handle(isolate, library.url()); | 4872 const String& library_url = String::Handle(isolate, library.url()); |
4873 return Api::NewError("%s: A script has already been loaded from '%s'.", | 4873 return Api::NewError("%s: A script has already been loaded from '%s'.", |
4874 CURRENT_FUNC, library_url.ToCString()); | 4874 CURRENT_FUNC, library_url.ToCString()); |
4875 } | 4875 } |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5302 | 5302 |
5303 | 5303 |
5304 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5304 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
5305 const char* name, | 5305 const char* name, |
5306 Dart_ServiceRequestCallback callback, | 5306 Dart_ServiceRequestCallback callback, |
5307 void* user_data) { | 5307 void* user_data) { |
5308 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5308 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
5309 } | 5309 } |
5310 | 5310 |
5311 } // namespace dart | 5311 } // namespace dart |
OLD | NEW |