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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 19563005: Add a new Dart API call Dart_GetNativeFieldOfArgument (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/include/dart_api.h ('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 25350)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -3550,6 +3550,42 @@
}
+DART_EXPORT Dart_Handle Dart_GetNativeFieldOfArgument(Dart_NativeArguments args,
+ int arg_index,
+ int fld_index,
+ intptr_t* value) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ if ((arg_index < 0) || (arg_index >= arguments->NativeArgCount())) {
+ return Api::NewError(
+ "%s: argument 'arg_index' out of range. Expected 0..%d but saw %d.",
+ CURRENT_FUNC, arguments->NativeArgCount() - 1, arg_index);
+ }
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ const Object& obj = Object::Handle(isolate,
+ arguments->NativeArgAt(arg_index));
+ if (!obj.IsInstance()) {
+ return Api::NewError("%s expects argument at index '%d' to be of"
+ " type Instance.", CURRENT_FUNC, arg_index);
+ }
+ if (obj.IsNull()) {
+ return Api::NewError("%s expects argument at index '%d' to be non-null.",
+ CURRENT_FUNC, arg_index);
+ }
+ const Instance& instance = Instance::Cast(obj);
+ if (!instance.IsValidNativeIndex(fld_index)) {
+ return Api::NewError(
+ "%s: invalid index %d passed in to access native instance field",
+ CURRENT_FUNC, fld_index);
+ }
+ if (value == NULL) {
+ RETURN_NULL_ERROR(value);
+ }
+ *value = instance.GetNativeField(isolate, fld_index);
+ return Api::Success();
+}
+
+
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
Dart_Handle retval) {
const Object& ret_obj = Object::Handle(Api::UnwrapHandle(retval));
« no previous file with comments | « runtime/include/dart_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698