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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 8446009: Add Dart_Null, Dart_True, and Dart_False. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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
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();
turnidge 2011/11/03 20:54:27 How do you feel about this? Does it violate expec
siva 2011/11/03 21:45:25 I think this is fine the only thing we may have to
turnidge 2011/11/04 00:03:17 Okay. Added code to protect against one of these
}
@@ -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);
}
@@ -1983,6 +1997,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);

Powered by Google App Engine
This is Rietveld 408576698