| Index: vm/dart_api_impl.cc
|
| ===================================================================
|
| --- vm/dart_api_impl.cc (revision 6195)
|
| +++ vm/dart_api_impl.cc (working copy)
|
| @@ -100,6 +100,19 @@
|
| return reinterpret_cast<Dart_Handle>(ref);
|
| }
|
|
|
| +Dart_Handle Api::NewLocalHandle(Isolate* isolate, RawObject* object) {
|
| + ASSERT(isolate != NULL);
|
| + ApiState* state = isolate->api_state();
|
| + ASSERT(state != NULL);
|
| + ApiLocalScope* scope = state->top_scope();
|
| + ASSERT(scope != NULL);
|
| + LocalHandles* local_handles = scope->local_handles();
|
| + ASSERT(local_handles != NULL);
|
| + LocalHandle* ref = local_handles->AllocateHandle();
|
| + ref->set_raw(object);
|
| + return reinterpret_cast<Dart_Handle>(ref);
|
| +}
|
| +
|
| RawObject* Api::UnwrapHandle(Dart_Handle object) {
|
| #ifdef DEBUG
|
| Isolate* isolate = Isolate::Current();
|
| @@ -257,10 +270,22 @@
|
|
|
|
|
| DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
|
| + RawObject* raw_obj = ((LocalHandle*)handle)->raw();
|
| + if (!raw_obj->IsHeapObject()) {
|
| + return false;
|
| + }
|
| + uword raw_addr = RawObject::ToAddr(raw_obj);
|
| + RawClass* header = (RawClass*)*reinterpret_cast<uword*>(raw_addr);
|
| + return (header == Object::language_error_class() ||
|
| + header == Object::api_error_class() ||
|
| + header == Object::unhandled_exception_class() ||
|
| + header == Object::unwind_error_class());
|
| +#if 0
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
|
| return obj.IsError();
|
| +#endif
|
| }
|
|
|
|
|
| @@ -1100,6 +1125,10 @@
|
|
|
|
|
| DART_EXPORT bool Dart_IsInteger(Dart_Handle object) {
|
| + RawObject* raw_obj = ((LocalHandle*)object)->raw();
|
| + if (!raw_obj->IsHeapObject()) {
|
| + return true;
|
| + }
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
|
| @@ -1110,6 +1139,11 @@
|
| DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
|
| bool* fits) {
|
| Isolate* isolate = Isolate::Current();
|
| + RawObject* raw_obj = ((LocalHandle*)integer)->raw();
|
| + if (!raw_obj->IsHeapObject()) {
|
| + *fits = true;
|
| + return Api::Success(isolate);
|
| + }
|
| DARTSCOPE(isolate);
|
| const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer);
|
| if (int_obj.IsNull()) {
|
| @@ -1152,9 +1186,12 @@
|
|
|
| DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value) {
|
| Isolate* isolate = Isolate::Current();
|
| +#if 0
|
| DARTSCOPE(isolate);
|
| const Integer& obj = Integer::Handle(isolate, Integer::New(value));
|
| return Api::NewLocalHandle(isolate, obj);
|
| +#endif
|
| + return Api::NewLocalHandle(isolate, Integer::New(value));
|
| }
|
|
|
|
|
| @@ -1170,6 +1207,11 @@
|
| DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer,
|
| int64_t* value) {
|
| Isolate* isolate = Isolate::Current();
|
| + RawObject* raw_obj = ((LocalHandle*)integer)->raw();
|
| + if (!raw_obj->IsHeapObject()) {
|
| + *value = ((int64_t)raw_obj) >> kSmiTagShift;
|
| + return Api::Success(isolate);
|
| + }
|
| DARTSCOPE(isolate);
|
| const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer);
|
| if (int_obj.IsNull()) {
|
| @@ -3053,9 +3095,13 @@
|
| CURRENT_FUNC, arguments->Count() - 1, index);
|
| }
|
| Isolate* isolate = arguments->isolate();
|
| + return Api::NewLocalHandle(isolate, arguments->At(index));
|
| +#if 0
|
| + Isolate* isolate = arguments->isolate();
|
| DARTSCOPE(isolate);
|
| const Object& obj = Object::Handle(isolate, arguments->At(index));
|
| return Api::NewLocalHandle(isolate, obj);
|
| +#endif
|
| }
|
|
|
|
|
| @@ -3069,9 +3115,12 @@
|
| DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
|
| Dart_Handle retval) {
|
| NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
|
| +#if 0
|
| Isolate* isolate = arguments->isolate();
|
| DARTSCOPE(isolate);
|
| arguments->SetReturn(Object::Handle(isolate, Api::UnwrapHandle(retval)));
|
| +#endif
|
| + arguments->SetReturn(Api::UnwrapHandle(retval));
|
| }
|
|
|
|
|
|
|