Chromium Code Reviews| 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 |