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..09390bfcb093090633ea765d459971826511b03e 100644 |
--- a/runtime/vm/dart_api_impl.cc |
+++ b/runtime/vm/dart_api_impl.cc |
@@ -1304,14 +1304,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 +1348,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 ---- |
@@ -2841,29 +2822,15 @@ DART_EXPORT Dart_Handle Dart_New(Dart_Handle type, |
} |
// Get the class to instantiate. |
- result = Api::UnwrapHandle(type); |
- if (result.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, type, Type); |
- } |
- Class& cls = Class::Handle(isolate); |
- AbstractTypeArguments& type_arguments = |
- AbstractTypeArguments::Handle(isolate); |
- |
- if (result.IsType()) { |
- cls = Type::Cast(result).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 { |
+ const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); |
+ if (type_obj.IsNull()) { |
RETURN_TYPE_ERROR(isolate, type, Type); |
} |
+ Class& cls = Class::Handle(isolate, type_obj.type_class()); |
+ const AbstractTypeArguments& type_arguments = |
+ AbstractTypeArguments::Handle(isolate, type_obj.arguments()); |
- String& base_constructor_name = String::Handle(); |
- base_constructor_name = cls.Name(); |
+ const String& base_constructor_name = String::Handle(isolate, cls.Name()); |
// And get the name of the constructor to invoke. |
String& dot_name = String::Handle(isolate); |
@@ -2965,23 +2932,13 @@ DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { |
Isolate* isolate = Isolate::Current(); |
DARTSCOPE(isolate); |
CHECK_CALLBACK_STATE(isolate); |
- const Object& result = Object::Handle(isolate, Api::UnwrapHandle(type)); |
+ const Type& type_obj = Api::UnwrapTypeHandle(isolate, type); |
// Get the class to instantiate. |
- if (result.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, type, Type); |
- } |
- Class& cls = Class::Handle(isolate); |
- if (result.IsType()) { |
- cls = Type::Cast(result).type_class(); |
- } 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 { |
+ if (type_obj.IsNull()) { |
RETURN_TYPE_ERROR(isolate, type, Type); |
} |
+ const Class& cls = Class::Handle(isolate, type_obj.type_class()); |
// Allocate an object for the given class. |
return Api::NewHandle(isolate, Instance::New(cls)); |
@@ -3030,22 +2987,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 +3041,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 +3138,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 +3263,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 +3486,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 +3970,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()); |
} |