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

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: . 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
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 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 result = Api::UnwrapHandle(type);
siva 2013/09/19 03:16:58 You should be able to use const Type& type_obj =
2845 if (result.IsNull()) { 2827 if (result.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);
2849 AbstractTypeArguments& type_arguments = 2831 AbstractTypeArguments& type_arguments =
2850 AbstractTypeArguments::Handle(isolate); 2832 AbstractTypeArguments::Handle(isolate);
2851 2833
2852 if (result.IsType()) { 2834 if (result.IsType()) {
2853 cls = Type::Cast(result).type_class(); 2835 cls = Type::Cast(result).type_class();
siva 2013/09/19 03:16:58 cls = type_obj.type_class();
2854 type_arguments = Type::Cast(result).arguments(); 2836 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 { 2837 } else {
2862 RETURN_TYPE_ERROR(isolate, type, Type); 2838 RETURN_TYPE_ERROR(isolate, type, Type);
2863 } 2839 }
2864 2840
2865 String& base_constructor_name = String::Handle(); 2841 String& base_constructor_name = String::Handle();
2866 base_constructor_name = cls.Name(); 2842 base_constructor_name = cls.Name();
2867 2843
2868 // And get the name of the constructor to invoke. 2844 // And get the name of the constructor to invoke.
2869 String& dot_name = String::Handle(isolate); 2845 String& dot_name = String::Handle(isolate);
2870 result = Api::UnwrapHandle(constructor_name); 2846 result = Api::UnwrapHandle(constructor_name);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 new_object ^= result.raw(); 2934 new_object ^= result.raw();
2959 } 2935 }
2960 return Api::NewHandle(isolate, new_object.raw()); 2936 return Api::NewHandle(isolate, new_object.raw());
2961 } 2937 }
2962 2938
2963 2939
2964 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) { 2940 DART_EXPORT Dart_Handle Dart_Allocate(Dart_Handle type) {
2965 Isolate* isolate = Isolate::Current(); 2941 Isolate* isolate = Isolate::Current();
2966 DARTSCOPE(isolate); 2942 DARTSCOPE(isolate);
2967 CHECK_CALLBACK_STATE(isolate); 2943 CHECK_CALLBACK_STATE(isolate);
2968 const Object& result = Object::Handle(isolate, Api::UnwrapHandle(type)); 2944 const Object& result = Object::Handle(isolate, Api::UnwrapHandle(type));
siva 2013/09/19 03:16:58 Ditto comment about const Type& result = Api::Unwr
2969 2945
2970 // Get the class to instantiate. 2946 // Get the class to instantiate.
2971 if (result.IsNull()) { 2947 if (result.IsNull()) {
2972 RETURN_TYPE_ERROR(isolate, type, Type); 2948 RETURN_TYPE_ERROR(isolate, type, Type);
2973 } 2949 }
2974 Class& cls = Class::Handle(isolate); 2950 Class& cls = Class::Handle(isolate);
2975 if (result.IsType()) { 2951 if (result.IsType()) {
2976 cls = Type::Cast(result).type_class(); 2952 cls = Type::Cast(result).type_class();
siva 2013/09/19 03:16:58 const Class& cls = Class::Handle(isolate, result.t
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 { 2953 } else {
2983 RETURN_TYPE_ERROR(isolate, type, Type); 2954 RETURN_TYPE_ERROR(isolate, type, Type);
2984 } 2955 }
2985 2956
2986 // Allocate an object for the given class. 2957 // Allocate an object for the given class.
2987 return Api::NewHandle(isolate, Instance::New(cls)); 2958 return Api::NewHandle(isolate, Instance::New(cls));
2988 } 2959 }
2989 2960
2990 2961
2991 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, 2962 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 return Api::NewHandle(isolate, arg.raw()); 2994 return Api::NewHandle(isolate, arg.raw());
3024 } else { 2995 } else {
3025 return Api::NewError( 2996 return Api::NewError(
3026 "%s expects arguments[%d] to be an Instance handle.", 2997 "%s expects arguments[%d] to be an Instance handle.",
3027 CURRENT_FUNC, i); 2998 CURRENT_FUNC, i);
3028 } 2999 }
3029 } 3000 }
3030 args.SetAt((i + num_receiver), arg); 3001 args.SetAt((i + num_receiver), arg);
3031 } 3002 }
3032 3003
3033 if (obj.IsType() || obj.IsClass()) { 3004 if (obj.IsType()) {
3034 // Finalize all classes. 3005 // Finalize all classes.
3035 Dart_Handle state = Api::CheckIsolateState(isolate); 3006 Dart_Handle state = Api::CheckIsolateState(isolate);
3036 if (::Dart_IsError(state)) { 3007 if (::Dart_IsError(state)) {
3037 return state; 3008 return state;
3038 } 3009 }
3039 3010
3040 // For backwards compatibility we allow class objects to be passed in 3011 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( 3012 const Function& function = Function::Handle(
3050 isolate, 3013 isolate,
3051 Resolver::ResolveStatic(cls, 3014 Resolver::ResolveStatic(cls,
3052 function_name, 3015 function_name,
3053 number_of_arguments, 3016 number_of_arguments,
3054 Object::empty_array(), 3017 Object::empty_array(),
3055 Resolver::kIsQualified)); 3018 Resolver::kIsQualified));
3056 if (function.IsNull()) { 3019 if (function.IsNull()) {
3057 const String& cls_name = String::Handle(isolate, cls.Name()); 3020 const String& cls_name = String::Handle(isolate, cls.Name());
3058 return Api::NewError("%s: did not find static method '%s.%s'.", 3021 return Api::NewError("%s: did not find static method '%s.%s'.",
(...skipping 26 matching lines...) Expand all
3085 } else if (obj.IsLibrary()) { 3048 } else if (obj.IsLibrary()) {
3086 // Check whether class finalization is needed. 3049 // Check whether class finalization is needed.
3087 const Library& lib = Library::Cast(obj); 3050 const Library& lib = Library::Cast(obj);
3088 3051
3089 // Finalize all classes if needed. 3052 // Finalize all classes if needed.
3090 Dart_Handle state = Api::CheckIsolateState(isolate); 3053 Dart_Handle state = Api::CheckIsolateState(isolate);
3091 if (::Dart_IsError(state)) { 3054 if (::Dart_IsError(state)) {
3092 return state; 3055 return state;
3093 } 3056 }
3094 3057
3095 Function& function = Function::Handle(isolate); 3058 const Function& function =
3096 function = lib.LookupFunctionAllowPrivate(function_name); 3059 Function::Handle(isolate,
3060 lib.LookupFunctionAllowPrivate(function_name));
3097 if (function.IsNull()) { 3061 if (function.IsNull()) {
3098 return Api::NewError("%s: did not find top-level function '%s'.", 3062 return Api::NewError("%s: did not find top-level function '%s'.",
3099 CURRENT_FUNC, 3063 CURRENT_FUNC,
3100 function_name.ToCString()); 3064 function_name.ToCString());
3101 } 3065 }
3102 // LookupFunctionAllowPrivate does not check argument arity, so we 3066 // LookupFunctionAllowPrivate does not check argument arity, so we
3103 // do it here. 3067 // do it here.
3104 String& error_message = String::Handle(); 3068 String& error_message = String::Handle();
3105 if (!function.AreValidArgumentCounts(number_of_arguments, 3069 if (!function.AreValidArgumentCounts(number_of_arguments,
3106 0, 3070 0,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 if (::Dart_IsError(state)) { 3145 if (::Dart_IsError(state)) {
3182 return state; 3146 return state;
3183 } 3147 }
3184 3148
3185 Field& field = Field::Handle(isolate); 3149 Field& field = Field::Handle(isolate);
3186 Function& getter = Function::Handle(isolate); 3150 Function& getter = Function::Handle(isolate);
3187 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container)); 3151 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container));
3188 if (obj.IsNull()) { 3152 if (obj.IsNull()) {
3189 return Api::NewError("%s expects argument 'container' to be non-null.", 3153 return Api::NewError("%s expects argument 'container' to be non-null.",
3190 CURRENT_FUNC); 3154 CURRENT_FUNC);
3191 } else if (obj.IsType() || obj.IsClass()) { 3155 } else if (obj.IsType()) {
3192 // To access a static field we may need to use the Field or the 3156 // To access a static field we may need to use the Field or the
3193 // getter Function. 3157 // getter Function.
3194 // For backwards compatibility we allow class objects to be passed in 3158 Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class());
3195 // for now. This needs to be removed once all code that uses class 3159
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); 3160 field = cls.LookupStaticField(field_name);
3204 if (field.IsNull() || FieldIsUninitialized(isolate, field)) { 3161 if (field.IsNull() || FieldIsUninitialized(isolate, field)) {
3205 const String& getter_name = 3162 const String& getter_name =
3206 String::Handle(isolate, Field::GetterName(field_name)); 3163 String::Handle(isolate, Field::GetterName(field_name));
3207 getter = cls.LookupStaticFunctionAllowPrivate(getter_name); 3164 getter = cls.LookupStaticFunctionAllowPrivate(getter_name);
3208 } 3165 }
3209 3166
3210 if (!getter.IsNull()) { 3167 if (!getter.IsNull()) {
3211 // Invoke the getter and return the result. 3168 // Invoke the getter and return the result.
3212 return Api::NewHandle( 3169 return Api::NewHandle(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 Dart_Handle state = Api::CheckIsolateState(isolate); 3270 Dart_Handle state = Api::CheckIsolateState(isolate);
3314 if (::Dart_IsError(state)) { 3271 if (::Dart_IsError(state)) {
3315 return state; 3272 return state;
3316 } 3273 }
3317 Field& field = Field::Handle(isolate); 3274 Field& field = Field::Handle(isolate);
3318 Function& setter = Function::Handle(isolate); 3275 Function& setter = Function::Handle(isolate);
3319 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container)); 3276 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container));
3320 if (obj.IsNull()) { 3277 if (obj.IsNull()) {
3321 return Api::NewError("%s expects argument 'container' to be non-null.", 3278 return Api::NewError("%s expects argument 'container' to be non-null.",
3322 CURRENT_FUNC); 3279 CURRENT_FUNC);
3323 } else if (obj.IsType() || obj.IsClass()) { 3280 } else if (obj.IsType()) {
3324 // To access a static field we may need to use the Field or the 3281 // To access a static field we may need to use the Field or the
3325 // setter Function. 3282 // setter Function.
3326 // For backwards compatibility we allow class objects to be passed in 3283 Class& cls = Class::Handle(isolate, Type::Cast(obj).type_class());
3327 // for now. This needs to be removed once all code that uses class 3284
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); 3285 field = cls.LookupStaticField(field_name);
3336 if (field.IsNull()) { 3286 if (field.IsNull()) {
3337 String& setter_name = 3287 String& setter_name =
3338 String::Handle(isolate, Field::SetterName(field_name)); 3288 String::Handle(isolate, Field::SetterName(field_name));
3339 setter = cls.LookupStaticFunctionAllowPrivate(setter_name); 3289 setter = cls.LookupStaticFunctionAllowPrivate(setter_name);
3340 } 3290 }
3341 3291
3342 if (!setter.IsNull()) { 3292 if (!setter.IsNull()) {
3343 // Invoke the setter and return the result. 3293 // Invoke the setter and return the result.
3344 const int kNumArgs = 1; 3294 const int kNumArgs = 1;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 } 3493 }
3544 CHECK_CALLBACK_STATE(isolate); 3494 CHECK_CALLBACK_STATE(isolate);
3545 3495
3546 String& cls_symbol = String::Handle(isolate, Symbols::New(cls_name)); 3496 String& cls_symbol = String::Handle(isolate, Symbols::New(cls_name));
3547 const Class& cls = Class::Handle( 3497 const Class& cls = Class::Handle(
3548 isolate, Class::NewNativeWrapper(lib, cls_symbol, field_count)); 3498 isolate, Class::NewNativeWrapper(lib, cls_symbol, field_count));
3549 if (cls.IsNull()) { 3499 if (cls.IsNull()) {
3550 return Api::NewError( 3500 return Api::NewError(
3551 "Unable to create native wrapper class : already exists"); 3501 "Unable to create native wrapper class : already exists");
3552 } 3502 }
3553 return Api::NewHandle(isolate, cls.raw()); 3503 return Api::NewHandle(isolate, cls.RareType());
3554 } 3504 }
3555 3505
3556 3506
3557 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj, 3507 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj,
3558 int* count) { 3508 int* count) {
3559 Isolate* isolate = Isolate::Current(); 3509 Isolate* isolate = Isolate::Current();
3560 DARTSCOPE(isolate); 3510 DARTSCOPE(isolate);
3561 const Instance& instance = Api::UnwrapInstanceHandle(isolate, obj); 3511 const Instance& instance = Api::UnwrapInstanceHandle(isolate, obj);
3562 if (instance.IsNull()) { 3512 if (instance.IsNull()) {
3563 RETURN_TYPE_ERROR(isolate, obj, Instance); 3513 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); 3977 RETURN_TYPE_ERROR(isolate, class_name, String);
4028 } 3978 }
4029 const Class& cls = Class::Handle( 3979 const Class& cls = Class::Handle(
4030 isolate, lib.LookupClassAllowPrivate(cls_name)); 3980 isolate, lib.LookupClassAllowPrivate(cls_name));
4031 if (cls.IsNull()) { 3981 if (cls.IsNull()) {
4032 // TODO(turnidge): Return null or error in this case? 3982 // TODO(turnidge): Return null or error in this case?
4033 const String& lib_name = String::Handle(isolate, lib.name()); 3983 const String& lib_name = String::Handle(isolate, lib.name());
4034 return Api::NewError("Class '%s' not found in library '%s'.", 3984 return Api::NewError("Class '%s' not found in library '%s'.",
4035 cls_name.ToCString(), lib_name.ToCString()); 3985 cls_name.ToCString(), lib_name.ToCString());
4036 } 3986 }
4037 return Api::NewHandle(isolate, cls.raw()); 3987 return Api::NewHandle(isolate, cls.RareType());
4038 } 3988 }
4039 3989
4040 3990
4041 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, 3991 DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library,
4042 Dart_Handle class_name, 3992 Dart_Handle class_name,
4043 intptr_t number_of_type_arguments, 3993 intptr_t number_of_type_arguments,
4044 Dart_Handle* type_arguments) { 3994 Dart_Handle* type_arguments) {
4045 Isolate* isolate = Isolate::Current(); 3995 Isolate* isolate = Isolate::Current();
4046 DARTSCOPE(isolate); 3996 DARTSCOPE(isolate);
4047 3997
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 } 4287 }
4338 { 4288 {
4339 NoGCScope no_gc; 4289 NoGCScope no_gc;
4340 RawObject* raw_obj = obj.raw(); 4290 RawObject* raw_obj = obj.raw();
4341 isolate->heap()->SetPeer(raw_obj, peer); 4291 isolate->heap()->SetPeer(raw_obj, peer);
4342 } 4292 }
4343 return Api::Success(); 4293 return Api::Success();
4344 } 4294 }
4345 4295
4346 } // namespace dart 4296 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698