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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 10905251: Lazy peer API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 4426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 4437
4438 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4438 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4439 Dart::set_perf_events_writer(function); 4439 Dart::set_perf_events_writer(function);
4440 } 4440 }
4441 4441
4442 4442
4443 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4443 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4444 Dart::set_flow_graph_writer(function); 4444 Dart::set_flow_graph_writer(function);
4445 } 4445 }
4446 4446
4447
4448 // --- Peer support ---
4449
4450
4451 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) {
4452 if (peer == NULL) {
4453 RETURN_NULL_ERROR(peer);
4454 }
4455 Isolate* isolate = Isolate::Current();
4456 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
Anton Muhin 2012/10/10 14:54:08 isn't DARTSCOPE(isolate) missing here and in the s
siva 2012/10/10 15:01:28 Yes. And a test case that will exercise a path wh
cshapiro 2012/10/10 16:39:07 Thanks. I will add that today to both GetPeer and
4457 if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) {
4458 const char* msg =
4459 "%s: argument 'object' cannot be a subtype of Null, num, or bool";
4460 return Api::NewError(msg, CURRENT_FUNC);
4461 }
4462 {
4463 NoGCScope no_gc;
4464 RawObject* raw_obj = obj.raw();
4465 *peer = isolate->heap()->GetPeer(raw_obj);
4466 }
4467 return Api::Success(isolate);
4468 }
4469
4470
4471 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer) {
4472 Isolate* isolate = Isolate::Current();
4473 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
4474 if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) {
4475 const char* msg =
4476 "%s: argument 'object' cannot be a subtype of Null, num, or bool";
4477 return Api::NewError(msg, CURRENT_FUNC);
4478 }
4479 {
4480 NoGCScope no_gc;
4481 RawObject* raw_obj = obj.raw();
4482 isolate->heap()->SetPeer(raw_obj, peer);
4483 }
4484 return Api::Success(isolate);
4485 }
4486
4447 } // namespace dart 4487 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698