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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3605 matching lines...) Expand 10 before | Expand all | Expand 10 after
3616 "%s: invalid index %d passed in to access native instance field", 3616 "%s: invalid index %d passed in to access native instance field",
3617 CURRENT_FUNC, fld_index); 3617 CURRENT_FUNC, fld_index);
3618 } 3618 }
3619 if (value == NULL) { 3619 if (value == NULL) {
3620 RETURN_NULL_ERROR(value); 3620 RETURN_NULL_ERROR(value);
3621 } 3621 }
3622 *value = instance.GetNativeField(isolate, fld_index); 3622 *value = instance.GetNativeField(isolate, fld_index);
3623 return Api::Success(); 3623 return Api::Success();
3624 } 3624 }
3625 3625
3626 DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args,
3627 intptr_t* value) {
3628 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3629 Isolate* isolate = arguments->isolate();
3630 DARTSCOPE(isolate);
3631 const Object& obj = Object::Handle(isolate, arguments->NativeArgAt(0));
3632 intptr_t cid = obj.GetClassId();
3633 if (cid <= kNumPredefinedCids) {
3634 if (cid == kNullCid) {
3635 return Api::NewError("%s expects receiver argument to be non-null.",
3636 CURRENT_FUNC);
3637 }
3638 return Api::NewError("%s expects receiver argument to be of"
3639 " type Instance.", CURRENT_FUNC);
3640 }
3641 const Instance& instance = Instance::Cast(obj);
3642 ASSERT(instance.IsValidNativeIndex(0));
3643 if (value == NULL) {
3644 RETURN_NULL_ERROR(value);
3645 }
3646 *value = instance.GetNativeField(isolate, 0);
3647 return Api::Success();
3648 }
3649
3626 3650
3627 DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, 3651 DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
3628 Dart_Handle retval) { 3652 Dart_Handle retval) {
3629 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3653 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3630 Isolate* isolate = arguments->isolate(); 3654 Isolate* isolate = arguments->isolate();
3631 CHECK_ISOLATE(isolate); 3655 CHECK_ISOLATE(isolate);
3632 if ((retval != Api::Null()) && (!Api::IsInstance(retval))) { 3656 if ((retval != Api::Null()) && (!Api::IsInstance(retval))) {
3633 const Object& ret_obj = Object::Handle(Api::UnwrapHandle(retval)); 3657 const Object& ret_obj = Object::Handle(Api::UnwrapHandle(retval));
3634 FATAL1("Return value check failed: saw '%s' expected a dart Instance.", 3658 FATAL1("Return value check failed: saw '%s' expected a dart Instance.",
3635 ret_obj.ToCString()); 3659 ret_obj.ToCString());
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 } 4166 }
4143 { 4167 {
4144 NoGCScope no_gc; 4168 NoGCScope no_gc;
4145 RawObject* raw_obj = obj.raw(); 4169 RawObject* raw_obj = obj.raw();
4146 isolate->heap()->SetPeer(raw_obj, peer); 4170 isolate->heap()->SetPeer(raw_obj, peer);
4147 } 4171 }
4148 return Api::Success(); 4172 return Api::Success();
4149 } 4173 }
4150 4174
4151 } // namespace dart 4175 } // namespace dart
OLDNEW
« 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