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

Unified Diff: runtime/vm/mirrors_api_impl.cc

Issue 24210003: Never return a Dart_Handle on a dart::Class from the embedding API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove Dart_IsClass from header. remove demo assert Created 7 years, 3 months 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
« no previous file with comments | « runtime/vm/debugger_api_impl_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/mirrors_api_impl.cc
diff --git a/runtime/vm/mirrors_api_impl.cc b/runtime/vm/mirrors_api_impl.cc
index 673621dfa15de79dc7d696932cda209907417806..74c38576fd17bb349c198b85fa3bbb7aeaf2fd05 100644
--- a/runtime/vm/mirrors_api_impl.cc
+++ b/runtime/vm/mirrors_api_impl.cc
@@ -22,20 +22,23 @@ namespace dart {
// --- Classes and Interfaces Reflection ---
-DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle object) {
+DART_EXPORT Dart_Handle Dart_TypeName(Dart_Handle object) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
- if (obj.IsType() || obj.IsClass()) {
- const Class& cls = (obj.IsType()) ?
- Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj);
+ if (obj.IsType()) {
+ const Class& cls = Class::Handle(Type::Cast(obj).type_class());
return Api::NewHandle(isolate, cls.UserVisibleName());
} else {
RETURN_TYPE_ERROR(isolate, object, Class/Type);
}
}
-DART_EXPORT Dart_Handle Dart_QualifiedClassName(Dart_Handle object) {
+DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle object) {
+ return Dart_TypeName(object);
+}
+
+DART_EXPORT Dart_Handle Dart_QualifiedTypeName(Dart_Handle object) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
@@ -48,6 +51,10 @@ DART_EXPORT Dart_Handle Dart_QualifiedClassName(Dart_Handle object) {
}
}
+DART_EXPORT Dart_Handle Dart_QualifiedClassName(Dart_Handle object) {
+ return Dart_QualifiedTypeName(object);
+}
+
// --- Function and Variable Reflection ---
// Outside of the vm, we expose setter names with a trailing '='.
@@ -75,12 +82,8 @@ DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target) {
Function& func = Function::Handle();
String& name = String::Handle();
- if (obj.IsType() || obj.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_Invoke is removed.
- const Class& cls = (obj.IsType()) ?
- Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj);
+ if (obj.IsType()) {
+ const Class& cls = Class::Handle(Type::Cast(obj).type_class());
const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate));
if (!error.IsNull()) {
return Api::NewHandle(isolate, error.raw());
@@ -141,12 +144,8 @@ DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target,
Function& func = Function::Handle(isolate);
String& tmp_name = String::Handle(isolate);
- if (obj.IsType() || obj.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_Invoke is removed.
- const Class& cls = (obj.IsType()) ?
- Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj);
+ if (obj.IsType()) {
+ const Class& cls = Class::Handle(Type::Cast(obj).type_class());
// Case 1. Lookup the unmodified function name.
func = cls.LookupFunctionAllowPrivate(func_name);
« no previous file with comments | « runtime/vm/debugger_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698