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

Side by Side Diff: runtime/vm/dart_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: UnwrapTypeHandle, ClassName->TypeName 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/include/dart_mirrors_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return instance.raw(); 73 return instance.raw();
74 } 74 }
75 } 75 }
76 return Instance::null(); 76 return Instance::null();
77 } 77 }
78 78
79 79
80 Dart_Handle Api::NewHandle(Isolate* isolate, RawObject* raw) { 80 Dart_Handle Api::NewHandle(Isolate* isolate, RawObject* raw) {
81 LocalHandles* local_handles = Api::TopScope(isolate)->local_handles(); 81 LocalHandles* local_handles = Api::TopScope(isolate)->local_handles();
82 ASSERT(local_handles != NULL); 82 ASSERT(local_handles != NULL);
83 ASSERT(!raw->IsRawClass());
83 LocalHandle* ref = local_handles->AllocateHandle(); 84 LocalHandle* ref = local_handles->AllocateHandle();
84 ref->set_raw(raw); 85 ref->set_raw(raw);
85 return reinterpret_cast<Dart_Handle>(ref); 86 return reinterpret_cast<Dart_Handle>(ref);
86 } 87 }
87 88
88 89
89 RawObject* Api::UnwrapHandle(Dart_Handle object) { 90 RawObject* Api::UnwrapHandle(Dart_Handle object) {
90 #if defined(DEBUG) 91 #if defined(DEBUG)
91 Isolate* isolate = Isolate::Current(); 92 Isolate* isolate = Isolate::Current();
92 ASSERT(isolate != NULL); 93 ASSERT(isolate != NULL);
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 TRACE_API_CALL(CURRENT_FUNC); 1297 TRACE_API_CALL(CURRENT_FUNC);
1297 return Api::ClassId(object) == kLibraryCid; 1298 return Api::ClassId(object) == kLibraryCid;
1298 } 1299 }
1299 1300
1300 1301
1301 DART_EXPORT bool Dart_IsType(Dart_Handle handle) { 1302 DART_EXPORT bool Dart_IsType(Dart_Handle handle) {
1302 TRACE_API_CALL(CURRENT_FUNC); 1303 TRACE_API_CALL(CURRENT_FUNC);
1303 return Api::ClassId(handle) == kTypeCid; 1304 return Api::ClassId(handle) == kTypeCid;
1304 } 1305 }
1305 1306
1306 1307
siva 2013/09/19 20:15:01 Dart_IsClass needs to be removed from dart_api.h
1307 DART_EXPORT bool Dart_IsClass(Dart_Handle handle) {
1308 Isolate* isolate = Isolate::Current();
1309 DARTSCOPE(isolate);
1310 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
1311 return obj.IsClass();
1312 }
1313
1314
1315 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) { 1308 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) {
1316 TRACE_API_CALL(CURRENT_FUNC); 1309 TRACE_API_CALL(CURRENT_FUNC);
1317 return Api::ClassId(handle) == kFunctionCid; 1310 return Api::ClassId(handle) == kFunctionCid;
1318 } 1311 }
1319 1312
1320 1313
1321 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle) { 1314 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle) {
1322 TRACE_API_CALL(CURRENT_FUNC); 1315 TRACE_API_CALL(CURRENT_FUNC);
1323 return Api::ClassId(handle) == kFieldCid; 1316 return Api::ClassId(handle) == kFieldCid;
1324 } 1317 }
(...skipping 24 matching lines...) Expand all
1349 if (obj.IsNull()) { 1342 if (obj.IsNull()) {
1350 return Api::NewHandle(isolate, isolate->object_store()->null_type()); 1343 return Api::NewHandle(isolate, isolate->object_store()->null_type());
1351 } 1344 }
1352 if (!obj.IsInstance()) { 1345 if (!obj.IsInstance()) {
1353 RETURN_TYPE_ERROR(isolate, instance, Instance); 1346 RETURN_TYPE_ERROR(isolate, instance, Instance);
1354 } 1347 }
1355 const Type& type = Type::Handle(Instance::Cast(obj).GetType()); 1348 const Type& type = Type::Handle(Instance::Cast(obj).GetType());
1356 return Api::NewHandle(isolate, type.Canonicalize()); 1349 return Api::NewHandle(isolate, type.Canonicalize());
1357 } 1350 }
1358 1351
1359 // TODO(asiva): Deprecate this method.
1360 DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance) {
1361 Isolate* isolate = Isolate::Current();
1362 DARTSCOPE(isolate);
1363 const Instance& obj = Api::UnwrapInstanceHandle(isolate, instance);
1364 if (obj.IsNull()) {
1365 RETURN_TYPE_ERROR(isolate, instance, Instance);
1366 }
1367 return Api::NewHandle(isolate, obj.clazz());
1368 }
1369
1370 1352
1371 // --- Numbers, Integers and Doubles ---- 1353 // --- Numbers, Integers and Doubles ----
1372 1354
1373 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, 1355 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
1374 bool* fits) { 1356 bool* fits) {
1375 // Fast path for Smis and Mints. 1357 // Fast path for Smis and Mints.
1376 Isolate* isolate = Isolate::Current(); 1358 Isolate* isolate = Isolate::Current();
1377 CHECK_ISOLATE(isolate); 1359 CHECK_ISOLATE(isolate);
1378 intptr_t class_id = Api::ClassId(integer); 1360 intptr_t class_id = Api::ClassId(integer);
1379 if (class_id == kSmiCid || class_id == kMintCid) { 1361 if (class_id == kSmiCid || class_id == kMintCid) {
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 CHECK_CALLBACK_STATE(isolate); 2816 CHECK_CALLBACK_STATE(isolate);
2835 Object& result = Object::Handle(isolate); 2817 Object& result = Object::Handle(isolate);
2836 2818
2837 if (number_of_arguments < 0) { 2819 if (number_of_arguments < 0) {
2838 return Api::NewError( 2820 return Api::NewError(
2839 "%s expects argument 'number_of_arguments' to be non-negative.", 2821 "%s expects argument 'number_of_arguments' to be non-negative.",
2840 CURRENT_FUNC); 2822 CURRENT_FUNC);
2841 } 2823 }
2842 2824
2843 // Get the class to instantiate. 2825 // Get the class to instantiate.
2844 result = Api::UnwrapHandle(type); 2826 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type);
2845 if (result.IsNull()) { 2827 if (type_obj.IsNull()) {
2846 RETURN_TYPE_ERROR(isolate, type, Type); 2828 RETURN_TYPE_ERROR(isolate, type, Type);
2847 } 2829 }
2848 Class& cls = Class::Handle(isolate); 2830 Class& cls = Class::Handle(isolate, type_obj.type_class());
2849 AbstractTypeArguments& type_arguments = 2831 const AbstractTypeArguments& type_arguments =
2850 AbstractTypeArguments::Handle(isolate); 2832 AbstractTypeArguments::Handle(isolate, type_obj.arguments());
2851 2833
2852 if (result.IsType()) { 2834 const String& base_constructor_name = String::Handle(isolate, cls.Name());
2853 cls = Type::Cast(result).type_class();
2854 type_arguments = Type::Cast(result).arguments();
2855 } else if (result.IsClass()) {
2856 // For backwards compatibility we allow class objects to be passed in
2857 // for now. This needs to be removed once all code that uses class
2858 // objects to invoke Dart_New is removed.
2859 cls ^= result.raw();
2860 type_arguments = Type::Handle(cls.RareType()).arguments();
2861 } else {
2862 RETURN_TYPE_ERROR(isolate, type, Type);
2863 }
2864
2865 String& base_constructor_name = String::Handle();
2866 base_constructor_name = cls.Name();
2867 2835
2868 // And get the name of the constructor to invoke. 2836 // And get the name of the constructor to invoke.
2869 String& dot_name = String::Handle(isolate); 2837 String& dot_name = String::Handle(isolate);
2870 result = Api::UnwrapHandle(constructor_name); 2838 result = Api::UnwrapHandle(constructor_name);
2871 if (result.IsNull()) { 2839 if (result.IsNull()) {
2872 dot_name = Symbols::Dot().raw(); 2840 dot_name = Symbols::Dot().raw();
2873 } else if (result.IsString()) { 2841 } else if (result.IsString()) {
2874 dot_name = String::Concat(Symbols::Dot(), String::Cast(result)); 2842 dot_name = String::Concat(Symbols::Dot(), String::Cast(result));
2875 } else { 2843 } else {
2876 RETURN_TYPE_ERROR(isolate, constructor_name, String); 2844 RETURN_TYPE_ERROR(isolate, constructor_name, String);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 new_object ^= result.raw(); 2926 new_object ^= result.raw();
2959 } 2927 }
2960 return Api::NewHandle(isolate, new_object.raw()); 2928 return Api::NewHandle(isolate, new_object.raw());
2961 } 2929 }
2962 2930
2963 2931
2964 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { 2932 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) {
2965 Isolate* isolate = Isolate::Current(); 2933 Isolate* isolate = Isolate::Current();
2966 DARTSCOPE(isolate); 2934 DARTSCOPE(isolate);
2967 CHECK_CALLBACK_STATE(isolate); 2935 CHECK_CALLBACK_STATE(isolate);
2968 const Object& result = Object::Handle(isolate, Api::UnwrapHandle(type));
2969 2936
2937 const Type& type_obj = Api::UnwrapTypeHandle(isolate, type);
2970 // Get the class to instantiate. 2938 // Get the class to instantiate.
2971 if (result.IsNull()) { 2939 if (type_obj.IsNull()) {
2972 RETURN_TYPE_ERROR(isolate, type, Type); 2940 RETURN_TYPE_ERROR(isolate, type, Type);
2973 } 2941 }
2974 Class& cls = Class::Handle(isolate); 2942 const Class& cls = Class::Handle(isolate, type_obj.type_class());
2975 if (result.IsType()) {
2976 cls = Type::Cast(result).type_class();
2977 } else if (result.IsClass()) {
2978 // For backwards compatibility we allow class objects to be passed in
2979 // for now. This needs to be removed once all code that uses class
2980 // objects to invoke Dart_New is removed.
2981 cls ^= result.raw();
2982 } else {
2983 RETURN_TYPE_ERROR(isolate, type, Type);
2984 }
2985 2943
2986 // Allocate an object for the given class. 2944 // Allocate an object for the given class.
2987 return Api::NewHandle(isolate, Instance::New(cls)); 2945 return Api::NewHandle(isolate, Instance::New(cls));
2988 } 2946 }
2989 2947
2990 2948
2991 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, 2949 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
2992 Dart_Handle name, 2950 Dart_Handle name,
2993 int number_of_arguments, 2951 int number_of_arguments,
2994 Dart_Handle* arguments) { 2952 Dart_Handle* arguments) {
(...skipping 28 matching lines...) Expand all
3023 return Api::NewHandle(isolate, arg.raw()); 2981 return Api::NewHandle(isolate, arg.raw());
3024 } else { 2982 } else {
3025 return Api::NewError( 2983 return Api::NewError(
3026 "%s expects arguments[%d] to be an Instance handle.", 2984 "%s expects arguments[%d] to be an Instance handle.",
3027 CURRENT_FUNC, i); 2985 CURRENT_FUNC, i);
3028 } 2986 }
3029 } 2987 }
3030 args.SetAt((i + num_receiver), arg); 2988 args.SetAt((i + num_receiver), arg);
3031 } 2989 }
3032 2990
3033 if (obj.IsType() || obj.IsClass()) { 2991 if (obj.IsType()) {
3034 // Finalize all classes. 2992 // Finalize all classes.
3035 Dart_Handle state = Api::CheckIsolateState(isolate); 2993 Dart_Handle state = Api::CheckIsolateState(isolate);
3036 if (::Dart_IsError(state)) { 2994 if (::Dart_IsError(state)) {
3037 return state; 2995 return state;
3038 } 2996 }
3039 2997
3040 // For backwards compatibility we allow class objects to be passed in 2998 const Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class());
3041 // for now. This needs to be removed once all code that uses class
3042 // objects to invoke Dart_Invoke is removed.
3043 Class& cls = Class::Handle();
3044 if (obj.IsType()) {
3045 cls = Type::Cast(obj).type_class();
3046 } else {
3047 cls = Class::Cast(obj).raw();
3048 }
3049 const Function& function = Function::Handle( 2999 const Function& function = Function::Handle(
3050 isolate, 3000 isolate,
3051 Resolver::ResolveStatic(cls, 3001 Resolver::ResolveStatic(cls,
3052 function_name, 3002 function_name,
3053 number_of_arguments, 3003 number_of_arguments,
3054 Object::empty_array(), 3004 Object::empty_array(),
3055 Resolver::kIsQualified)); 3005 Resolver::kIsQualified));
3056 if (function.IsNull()) { 3006 if (function.IsNull()) {
3057 const String& cls_name = String::Handle(isolate, cls.Name()); 3007 const String& cls_name = String::Handle(isolate, cls.Name());
3058 return Api::NewError("%s: did not find static method '%s.%s'.", 3008 return Api::NewError("%s: did not find static method '%s.%s'.",
(...skipping 26 matching lines...) Expand all
3085 } else if (obj.IsLibrary()) { 3035 } else if (obj.IsLibrary()) {
3086 // Check whether class finalization is needed. 3036 // Check whether class finalization is needed.
3087 const Library& lib = Library::Cast(obj); 3037 const Library& lib = Library::Cast(obj);
3088 3038
3089 // Finalize all classes if needed. 3039 // Finalize all classes if needed.
3090 Dart_Handle state = Api::CheckIsolateState(isolate); 3040 Dart_Handle state = Api::CheckIsolateState(isolate);
3091 if (::Dart_IsError(state)) { 3041 if (::Dart_IsError(state)) {
3092 return state; 3042 return state;
3093 } 3043 }
3094 3044
3095 Function& function = Function::Handle(isolate); 3045 const Function& function =
3096 function = lib.LookupFunctionAllowPrivate(function_name); 3046 Function::Handle(isolate,
3047 lib.LookupFunctionAllowPrivate(function_name));
3097 if (function.IsNull()) { 3048 if (function.IsNull()) {
3098 return Api::NewError("%s: did not find top-level function '%s'.", 3049 return Api::NewError("%s: did not find top-level function '%s'.",
3099 CURRENT_FUNC, 3050 CURRENT_FUNC,
3100 function_name.ToCString()); 3051 function_name.ToCString());
3101 } 3052 }
3102 // LookupFunctionAllowPrivate does not check argument arity, so we 3053 // LookupFunctionAllowPrivate does not check argument arity, so we
3103 // do it here. 3054 // do it here.
3104 String& error_message = String::Handle(); 3055 String& error_message = String::Handle();
3105 if (!function.AreValidArgumentCounts(number_of_arguments, 3056 if (!function.AreValidArgumentCounts(number_of_arguments,
3106 0, 3057 0,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 if (::Dart_IsError(state)) { 3132 if (::Dart_IsError(state)) {
3182 return state; 3133 return state;
3183 } 3134 }
3184 3135
3185 Field& field = Field::Handle(isolate); 3136 Field& field = Field::Handle(isolate);
3186 Function& getter = Function::Handle(isolate); 3137 Function& getter = Function::Handle(isolate);
3187 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container)); 3138 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container));
3188 if (obj.IsNull()) { 3139 if (obj.IsNull()) {
3189 return Api::NewError("%s expects argument 'container' to be non-null.", 3140 return Api::NewError("%s expects argument 'container' to be non-null.",
3190 CURRENT_FUNC); 3141 CURRENT_FUNC);
3191 } else if (obj.IsType() || obj.IsClass()) { 3142 } else if (obj.IsType()) {
3192 // To access a static field we may need to use the Field or the 3143 // To access a static field we may need to use the Field or the
3193 // getter Function. 3144 // getter Function.
3194 // For backwards compatibility we allow class objects to be passed in 3145 Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class());
3195 // for now. This needs to be removed once all code that uses class 3146
3196 // objects to invoke Dart_GetField is removed.
3197 Class& cls = Class::Handle();
3198 if (obj.IsType()) {
3199 cls = Type::Cast(obj).type_class();
3200 } else {
3201 cls = Class::Cast(obj).raw();
3202 }
3203 field = cls.LookupStaticField(field_name); 3147 field = cls.LookupStaticField(field_name);
3204 if (field.IsNull() || FieldIsUninitialized(isolate, field)) { 3148 if (field.IsNull() || FieldIsUninitialized(isolate, field)) {
3205 const String& getter_name = 3149 const String& getter_name =
3206 String::Handle(isolate, Field::GetterName(field_name)); 3150 String::Handle(isolate, Field::GetterName(field_name));
3207 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); 3151 getter = cls.LookupStaticFunctionAllowPrivate(getter_name);
3208 } 3152 }
3209 3153
3210 if (!getter.IsNull()) { 3154 if (!getter.IsNull()) {
3211 // Invoke the getter and return the result. 3155 // Invoke the getter and return the result.
3212 return Api::NewHandle( 3156 return Api::NewHandle(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 Dart_Handle state = Api::CheckIsolateState(isolate); 3257 Dart_Handle state = Api::CheckIsolateState(isolate);
3314 if (::Dart_IsError(state)) { 3258 if (::Dart_IsError(state)) {
3315 return state; 3259 return state;
3316 } 3260 }
3317 Field& field = Field::Handle(isolate); 3261 Field& field = Field::Handle(isolate);
3318 Function& setter = Function::Handle(isolate); 3262 Function& setter = Function::Handle(isolate);
3319 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container)); 3263 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container));
3320 if (obj.IsNull()) { 3264 if (obj.IsNull()) {
3321 return Api::NewError("%s expects argument 'container' to be non-null.", 3265 return Api::NewError("%s expects argument 'container' to be non-null.",
3322 CURRENT_FUNC); 3266 CURRENT_FUNC);
3323 } else if (obj.IsType() || obj.IsClass()) { 3267 } else if (obj.IsType()) {
3324 // To access a static field we may need to use the Field or the 3268 // To access a static field we may need to use the Field or the
3325 // setter Function. 3269 // setter Function.
3326 // For backwards compatibility we allow class objects to be passed in 3270 Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class());
3327 // for now. This needs to be removed once all code that uses class 3271
3328 // objects to invoke Dart_SetField is removed.
3329 Class& cls = Class::Handle();
3330 if (obj.IsType()) {
3331 cls = Type::Cast(obj).type_class();
3332 } else {
3333 cls = Class::Cast(obj).raw();
3334 }
3335 field = cls.LookupStaticField(field_name); 3272 field = cls.LookupStaticField(field_name);
3336 if (field.IsNull()) { 3273 if (field.IsNull()) {
3337 String& setter_name = 3274 String& setter_name =
3338 String::Handle(isolate, Field::SetterName(field_name)); 3275 String::Handle(isolate, Field::SetterName(field_name));
3339 setter = cls.LookupStaticFunctionAllowPrivate(setter_name); 3276 setter = cls.LookupStaticFunctionAllowPrivate(setter_name);
3340 } 3277 }
3341 3278
3342 if (!setter.IsNull()) { 3279 if (!setter.IsNull()) {
3343 // Invoke the setter and return the result. 3280 // Invoke the setter and return the result.
3344 const int kNumArgs = 1; 3281 const int kNumArgs = 1;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 } 3480 }
3544 CHECK_CALLBACK_STATE(isolate); 3481 CHECK_CALLBACK_STATE(isolate);
3545 3482
3546 String& cls_symbol = String::Handle(isolate, Symbols::New(cls_name)); 3483 String& cls_symbol = String::Handle(isolate, Symbols::New(cls_name));
3547 const Class& cls = Class::Handle( 3484 const Class& cls = Class::Handle(
3548 isolate, Class::NewNativeWrapper(lib, cls_symbol, field_count)); 3485 isolate, Class::NewNativeWrapper(lib, cls_symbol, field_count));
3549 if (cls.IsNull()) { 3486 if (cls.IsNull()) {
3550 return Api::NewError( 3487 return Api::NewError(
3551 "Unable to create native wrapper class : already exists"); 3488 "Unable to create native wrapper class : already exists");
3552 } 3489 }
3553 return Api::NewHandle(isolate, cls.raw()); 3490 return Api::NewHandle(isolate, cls.RareType());
3554 } 3491 }
3555 3492
3556 3493
3557 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj, 3494 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj,
3558 int* count) { 3495 int* count) {
3559 Isolate* isolate = Isolate::Current(); 3496 Isolate* isolate = Isolate::Current();
3560 DARTSCOPE(isolate); 3497 DARTSCOPE(isolate);
3561 const Instance& instance = Api::UnwrapInstanceHandle(isolate, obj); 3498 const Instance& instance = Api::UnwrapInstanceHandle(isolate, obj);
3562 if (instance.IsNull()) { 3499 if (instance.IsNull()) {
3563 RETURN_TYPE_ERROR(isolate, obj, Instance); 3500 RETURN_TYPE_ERROR(isolate, obj, Instance);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
4027 RETURN_TYPE_ERROR(isolate, class_name, String); 3964 RETURN_TYPE_ERROR(isolate, class_name, String);
4028 } 3965 }
4029 const Class& cls = Class::Handle( 3966 const Class& cls = Class::Handle(
4030 isolate, lib.LookupClassAllowPrivate(cls_name)); 3967 isolate, lib.LookupClassAllowPrivate(cls_name));
4031 if (cls.IsNull()) { 3968 if (cls.IsNull()) {
4032 // TODO(turnidge): Return null or error in this case? 3969 // TODO(turnidge): Return null or error in this case?
4033 const String& lib_name = String::Handle(isolate, lib.name()); 3970 const String& lib_name = String::Handle(isolate, lib.name());
4034 return Api::NewError("Class '%s' not found in library '%s'.", 3971 return Api::NewError("Class '%s' not found in library '%s'.",
4035 cls_name.ToCString(), lib_name.ToCString()); 3972 cls_name.ToCString(), lib_name.ToCString());
4036 } 3973 }
4037 return Api::NewHandle(isolate, cls.raw()); 3974 return Api::NewHandle(isolate, cls.RareType());
4038 } 3975 }
4039 3976
4040 3977
4041 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, 3978 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library,
4042 Dart_Handle class_name, 3979 Dart_Handle class_name,
4043 intptr_t number_of_type_arguments, 3980 intptr_t number_of_type_arguments,
4044 Dart_Handle* type_arguments) { 3981 Dart_Handle* type_arguments) {
4045 Isolate* isolate = Isolate::Current(); 3982 Isolate* isolate = Isolate::Current();
4046 DARTSCOPE(isolate); 3983 DARTSCOPE(isolate);
4047 3984
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 } 4274 }
4338 { 4275 {
4339 NoGCScope no_gc; 4276 NoGCScope no_gc;
4340 RawObject* raw_obj = obj.raw(); 4277 RawObject* raw_obj = obj.raw();
4341 isolate->heap()->SetPeer(raw_obj, peer); 4278 isolate->heap()->SetPeer(raw_obj, peer);
4342 } 4279 }
4343 return Api::Success(); 4280 return Api::Success();
4344 } 4281 }
4345 4282
4346 } // namespace dart 4283 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_mirrors_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698