| OLD | NEW |
| 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 4452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4463 | 4463 |
| 4464 | 4464 |
| 4465 // --- Peer support --- | 4465 // --- Peer support --- |
| 4466 | 4466 |
| 4467 | 4467 |
| 4468 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { | 4468 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { |
| 4469 if (peer == NULL) { | 4469 if (peer == NULL) { |
| 4470 RETURN_NULL_ERROR(peer); | 4470 RETURN_NULL_ERROR(peer); |
| 4471 } | 4471 } |
| 4472 Isolate* isolate = Isolate::Current(); | 4472 Isolate* isolate = Isolate::Current(); |
| 4473 DARTSCOPE(isolate); |
| 4473 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | 4474 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
| 4474 if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) { | 4475 if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) { |
| 4475 const char* msg = | 4476 const char* msg = |
| 4476 "%s: argument 'object' cannot be a subtype of Null, num, or bool"; | 4477 "%s: argument 'object' cannot be a subtype of Null, num, or bool"; |
| 4477 return Api::NewError(msg, CURRENT_FUNC); | 4478 return Api::NewError(msg, CURRENT_FUNC); |
| 4478 } | 4479 } |
| 4479 { | 4480 { |
| 4480 NoGCScope no_gc; | 4481 NoGCScope no_gc; |
| 4481 RawObject* raw_obj = obj.raw(); | 4482 RawObject* raw_obj = obj.raw(); |
| 4482 *peer = isolate->heap()->GetPeer(raw_obj); | 4483 *peer = isolate->heap()->GetPeer(raw_obj); |
| 4483 } | 4484 } |
| 4484 return Api::Success(isolate); | 4485 return Api::Success(isolate); |
| 4485 } | 4486 } |
| 4486 | 4487 |
| 4487 | 4488 |
| 4488 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer) { | 4489 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer) { |
| 4489 Isolate* isolate = Isolate::Current(); | 4490 Isolate* isolate = Isolate::Current(); |
| 4491 DARTSCOPE(isolate); |
| 4490 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | 4492 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
| 4491 if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) { | 4493 if (obj.IsNull() || obj.IsNumber() || obj.IsBool()) { |
| 4492 const char* msg = | 4494 const char* msg = |
| 4493 "%s: argument 'object' cannot be a subtype of Null, num, or bool"; | 4495 "%s: argument 'object' cannot be a subtype of Null, num, or bool"; |
| 4494 return Api::NewError(msg, CURRENT_FUNC); | 4496 return Api::NewError(msg, CURRENT_FUNC); |
| 4495 } | 4497 } |
| 4496 { | 4498 { |
| 4497 NoGCScope no_gc; | 4499 NoGCScope no_gc; |
| 4498 RawObject* raw_obj = obj.raw(); | 4500 RawObject* raw_obj = obj.raw(); |
| 4499 isolate->heap()->SetPeer(raw_obj, peer); | 4501 isolate->heap()->SetPeer(raw_obj, peer); |
| 4500 } | 4502 } |
| 4501 return Api::Success(isolate); | 4503 return Api::Success(isolate); |
| 4502 } | 4504 } |
| 4503 | 4505 |
| 4504 } // namespace dart | 4506 } // namespace dart |
| OLD | NEW |