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 0ba963874243a898bbf5c806f178c2eddd889f34..4d7a19e6b875e40605510777229f2ef95664b36e 100644 |
| --- a/runtime/vm/dart_api_impl.cc |
| +++ b/runtime/vm/dart_api_impl.cc |
| @@ -80,6 +80,7 @@ static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) { |
| Dart_Handle Api::NewHandle(Isolate* isolate, RawObject* raw) { |
| LocalHandles* local_handles = Api::TopScope(isolate)->local_handles(); |
| ASSERT(local_handles != NULL); |
| + ASSERT(!raw->IsRawClass()); |
| LocalHandle* ref = local_handles->AllocateHandle(); |
| ref->set_raw(raw); |
| return reinterpret_cast<Dart_Handle>(ref); |
| @@ -1304,14 +1305,6 @@ DART_EXPORT bool Dart_IsType(Dart_Handle handle) { |
| } |
| -DART_EXPORT bool Dart_IsClass(Dart_Handle handle) { |
| - Isolate* isolate = Isolate::Current(); |
| - DARTSCOPE(isolate); |
| - const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); |
| - return obj.IsClass(); |
| -} |
| - |
| - |
| DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) { |
| TRACE_API_CALL(CURRENT_FUNC); |
| return Api::ClassId(handle) == kFunctionCid; |
| @@ -1356,17 +1349,6 @@ DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance) { |
| return Api::NewHandle(isolate, type.Canonicalize()); |
| } |
| -// TODO(asiva): Deprecate this method. |
| -DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance) { |
| - Isolate* isolate = Isolate::Current(); |
| - DARTSCOPE(isolate); |
| - const Instance& obj = Api::UnwrapInstanceHandle(isolate, instance); |
| - if (obj.IsNull()) { |
| - RETURN_TYPE_ERROR(isolate, instance, Instance); |
| - } |
| - return Api::NewHandle(isolate, obj.clazz()); |
| -} |
| - |
| // --- Numbers, Integers and Doubles ---- |
| @@ -2852,12 +2834,6 @@ DART_EXPORT Dart_Handle Dart_New(Dart_Handle type, |
| if (result.IsType()) { |
| cls = Type::Cast(result).type_class(); |
|
siva
2013/09/19 03:16:58
cls = type_obj.type_class();
|
| type_arguments = Type::Cast(result).arguments(); |
| - } else if (result.IsClass()) { |
| - // For backwards compatibility we allow class objects to be passed in |
| - // for now. This needs to be removed once all code that uses class |
| - // objects to invoke Dart_New is removed. |
| - cls ^= result.raw(); |
| - type_arguments = Type::Handle(cls.RareType()).arguments(); |
| } else { |
| RETURN_TYPE_ERROR(isolate, type, Type); |
| } |
| @@ -2974,11 +2950,6 @@ DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { |
| Class& cls = Class::Handle(isolate); |
| if (result.IsType()) { |
| cls = Type::Cast(result).type_class(); |
|
siva
2013/09/19 03:16:58
const Class& cls = Class::Handle(isolate, result.t
|
| - } else if (result.IsClass()) { |
| - // For backwards compatibility we allow class objects to be passed in |
| - // for now. This needs to be removed once all code that uses class |
| - // objects to invoke Dart_New is removed. |
| - cls ^= result.raw(); |
| } else { |
| RETURN_TYPE_ERROR(isolate, type, Type); |
| } |
| @@ -3030,22 +3001,14 @@ DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, |
| args.SetAt((i + num_receiver), arg); |
| } |
| - if (obj.IsType() || obj.IsClass()) { |
| + if (obj.IsType()) { |
| // Finalize all classes. |
| Dart_Handle state = Api::CheckIsolateState(isolate); |
| if (::Dart_IsError(state)) { |
| return state; |
| } |
| - // For backwards compatibility we allow class objects to be passed in |
| - // for now. This needs to be removed once all code that uses class |
| - // objects to invoke Dart_Invoke is removed. |
| - Class& cls = Class::Handle(); |
| - if (obj.IsType()) { |
| - cls = Type::Cast(obj).type_class(); |
| - } else { |
| - cls = Class::Cast(obj).raw(); |
| - } |
| + const Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class()); |
| const Function& function = Function::Handle( |
| isolate, |
| Resolver::ResolveStatic(cls, |
| @@ -3092,8 +3055,9 @@ DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, |
| return state; |
| } |
| - Function& function = Function::Handle(isolate); |
| - function = lib.LookupFunctionAllowPrivate(function_name); |
| + const Function& function = |
| + Function::Handle(isolate, |
| + lib.LookupFunctionAllowPrivate(function_name)); |
| if (function.IsNull()) { |
| return Api::NewError("%s: did not find top-level function '%s'.", |
| CURRENT_FUNC, |
| @@ -3188,18 +3152,11 @@ DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name) { |
| if (obj.IsNull()) { |
| return Api::NewError("%s expects argument 'container' to be non-null.", |
| CURRENT_FUNC); |
| - } else if (obj.IsType() || obj.IsClass()) { |
| + } else if (obj.IsType()) { |
| // To access a static field we may need to use the Field or the |
| // getter Function. |
| - // For backwards compatibility we allow class objects to be passed in |
| - // for now. This needs to be removed once all code that uses class |
| - // objects to invoke Dart_GetField is removed. |
| - Class& cls = Class::Handle(); |
| - if (obj.IsType()) { |
| - cls = Type::Cast(obj).type_class(); |
| - } else { |
| - cls = Class::Cast(obj).raw(); |
| - } |
| + Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class()); |
| + |
| field = cls.LookupStaticField(field_name); |
| if (field.IsNull() || FieldIsUninitialized(isolate, field)) { |
| const String& getter_name = |
| @@ -3320,18 +3277,11 @@ DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, |
| if (obj.IsNull()) { |
| return Api::NewError("%s expects argument 'container' to be non-null.", |
| CURRENT_FUNC); |
| - } else if (obj.IsType() || obj.IsClass()) { |
| + } else if (obj.IsType()) { |
| // To access a static field we may need to use the Field or the |
| // setter Function. |
| - // For backwards compatibility we allow class objects to be passed in |
| - // for now. This needs to be removed once all code that uses class |
| - // objects to invoke Dart_SetField is removed. |
| - Class& cls = Class::Handle(); |
| - if (obj.IsType()) { |
| - cls = Type::Cast(obj).type_class(); |
| - } else { |
| - cls = Class::Cast(obj).raw(); |
| - } |
| + Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class()); |
| + |
| field = cls.LookupStaticField(field_name); |
| if (field.IsNull()) { |
| String& setter_name = |
| @@ -3550,7 +3500,7 @@ DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library, |
| return Api::NewError( |
| "Unable to create native wrapper class : already exists"); |
| } |
| - return Api::NewHandle(isolate, cls.raw()); |
| + return Api::NewHandle(isolate, cls.RareType()); |
| } |
| @@ -4034,7 +3984,7 @@ DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, |
| return Api::NewError("Class '%s' not found in library '%s'.", |
| cls_name.ToCString(), lib_name.ToCString()); |
| } |
| - return Api::NewHandle(isolate, cls.raw()); |
| + return Api::NewHandle(isolate, cls.RareType()); |
| } |