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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index dbb20cc14f6f9328958283ea5f6f4169cf3ae3fa..63d1a0279e40f8401024f6948ab1f0f5451f8b9d 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -4444,4 +4444,44 @@ DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
Dart::set_flow_graph_writer(function);
}
+
+// --- Peer support ---
+
+
+DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) {
+ if (peer == NULL) {
+ RETURN_NULL_ERROR(peer);
+ }
+ Isolate* isolate = Isolate::Current();
+ 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
+ if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) {
+ const char* msg =
+ "%s: argument 'object' cannot be a subtype of Null, num, or bool";
+ return Api::NewError(msg, CURRENT_FUNC);
+ }
+ {
+ NoGCScope no_gc;
+ RawObject* raw_obj = obj.raw();
+ *peer = isolate->heap()->GetPeer(raw_obj);
+ }
+ return Api::Success(isolate);
+}
+
+
+DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer) {
+ Isolate* isolate = Isolate::Current();
+ const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
+ if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) {
+ const char* msg =
+ "%s: argument 'object' cannot be a subtype of Null, num, or bool";
+ return Api::NewError(msg, CURRENT_FUNC);
+ }
+ {
+ NoGCScope no_gc;
+ RawObject* raw_obj = obj.raw();
+ isolate->heap()->SetPeer(raw_obj, peer);
+ }
+ return Api::Success(isolate);
+}
+
} // namespace dart
« 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