| Index: runtime/vm/dart_api_impl.cc
|
| ===================================================================
|
| --- runtime/vm/dart_api_impl.cc (revision 1035)
|
| +++ runtime/vm/dart_api_impl.cc (working copy)
|
| @@ -436,6 +436,11 @@
|
| }
|
|
|
|
|
| +DART_EXPORT Dart_Handle Dart_Null() {
|
| + return Api::Null();
|
| +}
|
| +
|
| +
|
| DART_EXPORT bool Dart_IsNull(Dart_Handle object) {
|
| Zone zone; // Setup a VM zone as we are creating some handles.
|
| HandleScope scope; // Setup a VM handle scope.
|
| @@ -637,6 +642,16 @@
|
| }
|
|
|
|
|
| +DART_EXPORT Dart_Handle Dart_True() {
|
| + return Api::True();
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_False() {
|
| + return Api::False();
|
| +}
|
| +
|
| +
|
| DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) {
|
| Zone zone; // Setup a VM zone as we are creating some handles.
|
| HandleScope scope; // Setup a VM handle scope.
|
| @@ -646,10 +661,7 @@
|
|
|
|
|
| DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) {
|
| - Zone zone; // Setup a VM zone as we are creating some handles.
|
| - HandleScope scope; // Setup a VM handle scope.
|
| - const Bool& obj = Bool::Handle(Bool::Get(value));
|
| - return Api::NewLocalHandle(obj);
|
| + return value ? Api::True() : Api::False();
|
| }
|
|
|
|
|
| @@ -1522,14 +1534,16 @@
|
|
|
|
|
| DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object) {
|
| + Zone zone; // Setup a VM zone as we are creating some handles.
|
| + HandleScope scope; // Setup a VM handle scope.
|
| Isolate* isolate = Isolate::Current();
|
| ASSERT(isolate != NULL);
|
| ApiState* state = isolate->api_state();
|
| ASSERT(state != NULL);
|
| - LocalHandle* local_ref = Api::UnwrapAsLocalHandle(*state, object);
|
| - PersistentHandle* ref = state->persistent_handles().AllocateHandle();
|
| - ref->set_raw(*local_ref);
|
| - return reinterpret_cast<Dart_Handle>(ref);
|
| + const Object& old_ref = Object::Handle(Api::UnwrapHandle(object));
|
| + PersistentHandle* new_ref = state->persistent_handles().AllocateHandle();
|
| + new_ref->set_raw(old_ref);
|
| + return reinterpret_cast<Dart_Handle>(new_ref);
|
| }
|
|
|
|
|
| @@ -1551,7 +1565,10 @@
|
| ApiState* state = isolate->api_state();
|
| ASSERT(state != NULL);
|
| PersistentHandle* ref = Api::UnwrapAsPersistentHandle(*state, object);
|
| - state->persistent_handles().FreeHandle(ref);
|
| + ASSERT(!ref->IsProtected());
|
| + if (!ref->IsProtected()) {
|
| + state->persistent_handles().FreeHandle(ref);
|
| + }
|
| }
|
|
|
|
|
| @@ -1983,6 +2000,36 @@
|
| }
|
|
|
|
|
| +Dart_Handle Api::Null() {
|
| + Isolate* isolate = Isolate::Current();
|
| + ASSERT(isolate != NULL);
|
| + ApiState* state = isolate->api_state();
|
| + ASSERT(state != NULL);
|
| + PersistentHandle* null_handle = state->Null();
|
| + return reinterpret_cast<Dart_Handle>(null_handle);
|
| +}
|
| +
|
| +
|
| +Dart_Handle Api::True() {
|
| + Isolate* isolate = Isolate::Current();
|
| + ASSERT(isolate != NULL);
|
| + ApiState* state = isolate->api_state();
|
| + ASSERT(state != NULL);
|
| + PersistentHandle* true_handle = state->True();
|
| + return reinterpret_cast<Dart_Handle>(true_handle);
|
| +}
|
| +
|
| +
|
| +Dart_Handle Api::False() {
|
| + Isolate* isolate = Isolate::Current();
|
| + ASSERT(isolate != NULL);
|
| + ApiState* state = isolate->api_state();
|
| + ASSERT(state != NULL);
|
| + PersistentHandle* false_handle = state->False();
|
| + return reinterpret_cast<Dart_Handle>(false_handle);
|
| +}
|
| +
|
| +
|
| uword Api::Allocate(intptr_t size) {
|
| Isolate* isolate = Isolate::Current();
|
| ASSERT(isolate != NULL);
|
|
|