Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 21319002: - Add following additional methods to the API to make returning values (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/native_arguments.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 25657)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -3565,7 +3565,7 @@
"%s: argument 'arg_index' out of range. Expected 0..%d but saw %d.",
CURRENT_FUNC, arguments->NativeArgCount() - 1, arg_index);
}
- Isolate* isolate = Isolate::Current();
+ Isolate* isolate = arguments->isolate();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(isolate,
arguments->NativeArgAt(arg_index));
@@ -3593,17 +3593,50 @@
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
Dart_Handle retval) {
- const Object& ret_obj = Object::Handle(Api::UnwrapHandle(retval));
- if (!ret_obj.IsNull() && !ret_obj.IsInstance()) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ Isolate* isolate = arguments->isolate();
+ CHECK_ISOLATE(isolate);
+ if (retval != Api::Null() && !Api::IsInstance(retval)) {
srdjan 2013/07/31 14:27:31 Add parenthesis
siva 2013/07/31 16:23:03 Done.
+ const Object& ret_obj = Object::Handle(Api::UnwrapHandle(retval));
FATAL1("Return value check failed: saw '%s' expected a dart Instance.",
ret_obj.ToCString());
}
- NoGCScope no_gc_scope;
+ Api::SetReturnValue(arguments, retval);
+}
+
+
+DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args,
+ bool retval) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
- arguments->SetReturn(ret_obj);
+ arguments->SetReturn(retval ? Bool::True() : Bool::False());
}
+DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args,
+ intptr_t retval) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ Isolate* isolate = arguments->isolate();
+ CHECK_ISOLATE(isolate);
+ if (Smi::IsValid64(retval)) {
+ Api::SetSmiReturnValue(arguments, retval);
+ } else {
+ // Slow path for Mints and Bigints.
+ ASSERT_CALLBACK_STATE(isolate);
+ Api::SetIntegerReturnValue(arguments, retval);
+ }
+}
+
+
+DART_EXPORT void Dart_SetDoubleReturnValue(Dart_NativeArguments args,
+ double retval) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ Isolate* isolate = arguments->isolate();
+ CHECK_ISOLATE(isolate);
+ ASSERT_CALLBACK_STATE(isolate);
+ Api::SetDoubleReturnValue(arguments, retval);
+}
+
+
// --- Scripts and Libraries ---
DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/native_arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698