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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 21986002: Add Dart_GetNativeReceiver to special case access to the native field (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/benchmark_test.cc ('k') | no next file » | 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 25740)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -3623,7 +3623,31 @@
return Api::Success();
}
+DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args,
+ intptr_t* value) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ Isolate* isolate = arguments->isolate();
+ DARTSCOPE(isolate);
+ const Object& obj = Object::Handle(isolate, arguments->NativeArgAt(0));
+ intptr_t cid = obj.GetClassId();
+ if (cid <= kNumPredefinedCids) {
+ if (cid == kNullCid) {
+ return Api::NewError("%s expects receiver argument to be non-null.",
+ CURRENT_FUNC);
+ }
+ return Api::NewError("%s expects receiver argument to be of"
+ " type Instance.", CURRENT_FUNC);
+ }
+ const Instance& instance = Instance::Cast(obj);
+ ASSERT(instance.IsValidNativeIndex(0));
+ if (value == NULL) {
+ RETURN_NULL_ERROR(value);
+ }
+ *value = instance.GetNativeField(isolate, 0);
+ return Api::Success();
+}
+
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
Dart_Handle retval) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698