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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 23453035: 1. Add flag --trace-api to trace API function invocation (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/native_arguments.h » ('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 20 matching lines...) Expand all
31 #include "vm/symbols.h" 31 #include "vm/symbols.h"
32 #include "vm/timer.h" 32 #include "vm/timer.h"
33 #include "vm/unicode.h" 33 #include "vm/unicode.h"
34 #include "vm/verifier.h" 34 #include "vm/verifier.h"
35 #include "vm/version.h" 35 #include "vm/version.h"
36 36
37 namespace dart { 37 namespace dart {
38 38
39 DECLARE_FLAG(bool, print_class_table); 39 DECLARE_FLAG(bool, print_class_table);
40 DECLARE_FLAG(bool, verify_handles); 40 DECLARE_FLAG(bool, verify_handles);
41 DEFINE_FLAG(bool, trace_api, false,
42 "Trace invocation of API calls (debug mode only)");
41 43
42 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey; 44 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey;
43 Dart_Handle Api::true_handle_ = NULL; 45 Dart_Handle Api::true_handle_ = NULL;
44 Dart_Handle Api::false_handle_ = NULL; 46 Dart_Handle Api::false_handle_ = NULL;
45 Dart_Handle Api::null_handle_ = NULL; 47 Dart_Handle Api::null_handle_ = NULL;
46 48
47 49
48 const char* CanonicalFunction(const char* func) { 50 const char* CanonicalFunction(const char* func) {
49 if (strncmp(func, "dart::", 6) == 0) { 51 if (strncmp(func, "dart::", 6) == 0) {
50 return func + 6; 52 return func + 6;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 274
273 void Api::SetWeakHandleReturnValue(NativeArguments* args, 275 void Api::SetWeakHandleReturnValue(NativeArguments* args,
274 Dart_WeakPersistentHandle retval) { 276 Dart_WeakPersistentHandle retval) {
275 args->SetReturnUnsafe(Api::UnwrapAsWeakPersistentHandle(retval)->raw()); 277 args->SetReturnUnsafe(Api::UnwrapAsWeakPersistentHandle(retval)->raw());
276 } 278 }
277 279
278 280
279 // --- Handles --- 281 // --- Handles ---
280 282
281 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { 283 DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
284 TRACE_API_CALL(CURRENT_FUNC);
282 return RawObject::IsErrorClassId(Api::ClassId(handle)); 285 return RawObject::IsErrorClassId(Api::ClassId(handle));
283 } 286 }
284 287
285 288
286 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { 289 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) {
290 TRACE_API_CALL(CURRENT_FUNC);
287 return Api::ClassId(object) == kApiErrorCid; 291 return Api::ClassId(object) == kApiErrorCid;
288 } 292 }
289 293
290 294
291 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) { 295 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) {
296 TRACE_API_CALL(CURRENT_FUNC);
292 return Api::ClassId(object) == kUnhandledExceptionCid; 297 return Api::ClassId(object) == kUnhandledExceptionCid;
293 } 298 }
294 299
295 300
296 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) { 301 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) {
302 TRACE_API_CALL(CURRENT_FUNC);
297 return Api::ClassId(object) == kLanguageErrorCid; 303 return Api::ClassId(object) == kLanguageErrorCid;
298 } 304 }
299 305
300 306
301 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) { 307 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) {
308 TRACE_API_CALL(CURRENT_FUNC);
302 return Api::ClassId(object) == kUnwindErrorCid; 309 return Api::ClassId(object) == kUnwindErrorCid;
303 } 310 }
304 311
305 312
306 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) { 313 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) {
307 Isolate* isolate = Isolate::Current(); 314 Isolate* isolate = Isolate::Current();
308 DARTSCOPE(isolate); 315 DARTSCOPE(isolate);
309 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); 316 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
310 if (obj.IsError()) { 317 if (obj.IsError()) {
311 const Error& error = Error::Cast(obj); 318 const Error& error = Error::Cast(obj);
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 OS::SNPrint(chars, len, "%s$%s", script_uri, main); 793 OS::SNPrint(chars, len, "%s$%s", script_uri, main);
787 return chars; 794 return chars;
788 } 795 }
789 796
790 797
791 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri, 798 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
792 const char* main, 799 const char* main,
793 const uint8_t* snapshot, 800 const uint8_t* snapshot,
794 void* callback_data, 801 void* callback_data,
795 char** error) { 802 char** error) {
803 TRACE_API_CALL(CURRENT_FUNC);
796 char* isolate_name = BuildIsolateName(script_uri, main); 804 char* isolate_name = BuildIsolateName(script_uri, main);
797 Isolate* isolate = Dart::CreateIsolate(isolate_name); 805 Isolate* isolate = Dart::CreateIsolate(isolate_name);
798 free(isolate_name); 806 free(isolate_name);
799 { 807 {
800 StackZone zone(isolate); 808 StackZone zone(isolate);
801 HANDLESCOPE(isolate); 809 HANDLESCOPE(isolate);
802 const Error& error_obj = 810 const Error& error_obj =
803 Error::Handle(isolate, 811 Error::Handle(isolate,
804 Dart::InitializeIsolate(snapshot, callback_data)); 812 Dart::InitializeIsolate(snapshot, callback_data));
805 if (error_obj.IsNull()) { 813 if (error_obj.IsNull()) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 CURRENT_FUNC); 922 CURRENT_FUNC);
915 } 923 }
916 ScriptSnapshotWriter writer(buffer, ApiReallocate); 924 ScriptSnapshotWriter writer(buffer, ApiReallocate);
917 writer.WriteScriptSnapshot(library); 925 writer.WriteScriptSnapshot(library);
918 *size = writer.BytesWritten(); 926 *size = writer.BytesWritten();
919 return Api::Success(); 927 return Api::Success();
920 } 928 }
921 929
922 930
923 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) { 931 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) {
932 TRACE_API_CALL(CURRENT_FUNC);
924 if (isolate == NULL) { 933 if (isolate == NULL) {
925 FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); 934 FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
926 } 935 }
927 Isolate* iso = reinterpret_cast<Isolate*>(isolate); 936 Isolate* iso = reinterpret_cast<Isolate*>(isolate);
928 iso->ScheduleInterrupts(Isolate::kApiInterrupt); 937 iso->ScheduleInterrupts(Isolate::kApiInterrupt);
929 } 938 }
930 939
931 940
932 DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate) { 941 DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate) {
933 CHECK_NO_ISOLATE(Isolate::Current()); 942 CHECK_NO_ISOLATE(Isolate::Current());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1232
1224 DART_EXPORT bool Dart_IsInstance(Dart_Handle object) { 1233 DART_EXPORT bool Dart_IsInstance(Dart_Handle object) {
1225 Isolate* isolate = Isolate::Current(); 1234 Isolate* isolate = Isolate::Current();
1226 DARTSCOPE(isolate); 1235 DARTSCOPE(isolate);
1227 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); 1236 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
1228 return obj.IsInstance(); 1237 return obj.IsInstance();
1229 } 1238 }
1230 1239
1231 1240
1232 DART_EXPORT bool Dart_IsNumber(Dart_Handle object) { 1241 DART_EXPORT bool Dart_IsNumber(Dart_Handle object) {
1242 TRACE_API_CALL(CURRENT_FUNC);
1233 return RawObject::IsNumberClassId(Api::ClassId(object)); 1243 return RawObject::IsNumberClassId(Api::ClassId(object));
1234 } 1244 }
1235 1245
1236 1246
1237 DART_EXPORT bool Dart_IsInteger(Dart_Handle object) { 1247 DART_EXPORT bool Dart_IsInteger(Dart_Handle object) {
1248 TRACE_API_CALL(CURRENT_FUNC);
1238 return RawObject::IsIntegerClassId(Api::ClassId(object)); 1249 return RawObject::IsIntegerClassId(Api::ClassId(object));
1239 } 1250 }
1240 1251
1241 1252
1242 DART_EXPORT bool Dart_IsDouble(Dart_Handle object) { 1253 DART_EXPORT bool Dart_IsDouble(Dart_Handle object) {
1254 TRACE_API_CALL(CURRENT_FUNC);
1243 return Api::ClassId(object) == kDoubleCid; 1255 return Api::ClassId(object) == kDoubleCid;
1244 } 1256 }
1245 1257
1246 1258
1247 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) { 1259 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) {
1260 TRACE_API_CALL(CURRENT_FUNC);
1248 return Api::ClassId(object) == kBoolCid; 1261 return Api::ClassId(object) == kBoolCid;
1249 } 1262 }
1250 1263
1251 1264
1252 DART_EXPORT bool Dart_IsString(Dart_Handle object) { 1265 DART_EXPORT bool Dart_IsString(Dart_Handle object) {
1266 TRACE_API_CALL(CURRENT_FUNC);
1253 return RawObject::IsStringClassId(Api::ClassId(object)); 1267 return RawObject::IsStringClassId(Api::ClassId(object));
1254 } 1268 }
1255 1269
1256 1270
1257 DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object) { 1271 DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object) {
1272 TRACE_API_CALL(CURRENT_FUNC);
1258 return RawObject::IsOneByteStringClassId(Api::ClassId(object)); 1273 return RawObject::IsOneByteStringClassId(Api::ClassId(object));
1259 } 1274 }
1260 1275
1261 1276
1262 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) { 1277 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) {
1278 TRACE_API_CALL(CURRENT_FUNC);
1263 return RawObject::IsExternalStringClassId(Api::ClassId(object)); 1279 return RawObject::IsExternalStringClassId(Api::ClassId(object));
1264 } 1280 }
1265 1281
1266 1282
1267 DART_EXPORT bool Dart_IsList(Dart_Handle object) { 1283 DART_EXPORT bool Dart_IsList(Dart_Handle object) {
1268 if (RawObject::IsBuiltinListClassId(Api::ClassId(object))) { 1284 if (RawObject::IsBuiltinListClassId(Api::ClassId(object))) {
1285 TRACE_API_CALL(CURRENT_FUNC);
1269 return true; 1286 return true;
1270 } 1287 }
1271 1288
1272 Isolate* isolate = Isolate::Current(); 1289 Isolate* isolate = Isolate::Current();
1273 DARTSCOPE(isolate); 1290 DARTSCOPE(isolate);
1274 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); 1291 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
1275 return GetListInstance(isolate, obj) != Instance::null(); 1292 return GetListInstance(isolate, obj) != Instance::null();
1276 } 1293 }
1277 1294
1278 1295
1279 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) { 1296 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) {
1297 TRACE_API_CALL(CURRENT_FUNC);
1280 return Api::ClassId(object) == kLibraryCid; 1298 return Api::ClassId(object) == kLibraryCid;
1281 } 1299 }
1282 1300
1283 1301
1284 DART_EXPORT bool Dart_IsType(Dart_Handle handle) { 1302 DART_EXPORT bool Dart_IsType(Dart_Handle handle) {
1303 TRACE_API_CALL(CURRENT_FUNC);
1285 return Api::ClassId(handle) == kTypeCid; 1304 return Api::ClassId(handle) == kTypeCid;
1286 } 1305 }
1287 1306
1288 1307
1289 DART_EXPORT bool Dart_IsClass(Dart_Handle handle) { 1308 DART_EXPORT bool Dart_IsClass(Dart_Handle handle) {
1290 Isolate* isolate = Isolate::Current(); 1309 Isolate* isolate = Isolate::Current();
1291 DARTSCOPE(isolate); 1310 DARTSCOPE(isolate);
1292 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); 1311 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
1293 return obj.IsClass(); 1312 return obj.IsClass();
1294 } 1313 }
1295 1314
1296 1315
1297 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) { 1316 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) {
1317 TRACE_API_CALL(CURRENT_FUNC);
1298 return Api::ClassId(handle) == kFunctionCid; 1318 return Api::ClassId(handle) == kFunctionCid;
1299 } 1319 }
1300 1320
1301 1321
1302 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle) { 1322 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle) {
1323 TRACE_API_CALL(CURRENT_FUNC);
1303 return Api::ClassId(handle) == kFieldCid; 1324 return Api::ClassId(handle) == kFieldCid;
1304 } 1325 }
1305 1326
1306 1327
1307 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle) { 1328 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle) {
1329 TRACE_API_CALL(CURRENT_FUNC);
1308 return Api::ClassId(handle) == kTypeParameterCid; 1330 return Api::ClassId(handle) == kTypeParameterCid;
1309 } 1331 }
1310 1332
1311 1333
1312 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) { 1334 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) {
1313 // We can't use a fast class index check here because there are many 1335 // We can't use a fast class index check here because there are many
1314 // different signature classes for closures. 1336 // different signature classes for closures.
1315 Isolate* isolate = Isolate::Current(); 1337 Isolate* isolate = Isolate::Current();
1316 DARTSCOPE(isolate); 1338 DARTSCOPE(isolate);
1317 const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, object); 1339 const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, object);
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 break; 2452 break;
2431 default: 2453 default:
2432 type = Dart_TypedData_kInvalid; 2454 type = Dart_TypedData_kInvalid;
2433 break; 2455 break;
2434 } 2456 }
2435 return type; 2457 return type;
2436 } 2458 }
2437 2459
2438 2460
2439 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object) { 2461 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object) {
2462 TRACE_API_CALL(CURRENT_FUNC);
2440 intptr_t class_id = Api::ClassId(object); 2463 intptr_t class_id = Api::ClassId(object);
2441 if (RawObject::IsTypedDataClassId(class_id) || 2464 if (RawObject::IsTypedDataClassId(class_id) ||
2442 RawObject::IsTypedDataViewClassId(class_id)) { 2465 RawObject::IsTypedDataViewClassId(class_id)) {
2443 return GetType(class_id); 2466 return GetType(class_id);
2444 } 2467 }
2445 return Dart_TypedData_kInvalid; 2468 return Dart_TypedData_kInvalid;
2446 } 2469 }
2447 2470
2448 2471
2449 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData( 2472 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData(
2450 Dart_Handle object) { 2473 Dart_Handle object) {
2474 TRACE_API_CALL(CURRENT_FUNC);
2451 intptr_t class_id = Api::ClassId(object); 2475 intptr_t class_id = Api::ClassId(object);
2452 if (RawObject::IsExternalTypedDataClassId(class_id) || 2476 if (RawObject::IsExternalTypedDataClassId(class_id) ||
2453 RawObject::IsTypedDataViewClassId(class_id)) { 2477 RawObject::IsTypedDataViewClassId(class_id)) {
2454 return GetType(class_id); 2478 return GetType(class_id);
2455 } 2479 }
2456 return Dart_TypedData_kInvalid; 2480 return Dart_TypedData_kInvalid;
2457 } 2481 }
2458 2482
2459 2483
2460 static RawObject* GetByteDataConstructor(Isolate* isolate, 2484 static RawObject* GetByteDataConstructor(Isolate* isolate,
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 "%s: invalid index %d passed in to set native instance field", 3606 "%s: invalid index %d passed in to set native instance field",
3583 CURRENT_FUNC, index); 3607 CURRENT_FUNC, index);
3584 } 3608 }
3585 instance.SetNativeField(index, value); 3609 instance.SetNativeField(index, value);
3586 return Api::Success(); 3610 return Api::Success();
3587 } 3611 }
3588 3612
3589 3613
3590 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, 3614 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
3591 int index) { 3615 int index) {
3616 TRACE_API_CALL(CURRENT_FUNC);
3592 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3617 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3593 if ((index < 0) || (index >= arguments->NativeArgCount())) { 3618 if ((index < 0) || (index >= arguments->NativeArgCount())) {
3594 return Api::NewError( 3619 return Api::NewError(
3595 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 3620 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
3596 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 3621 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
3597 } 3622 }
3598 return Api::NewHandle(arguments->isolate(), arguments->NativeArgAt(index)); 3623 return Api::NewHandle(arguments->isolate(), arguments->NativeArgAt(index));
3599 } 3624 }
3600 3625
3601 3626
3602 DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) { 3627 DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) {
3628 TRACE_API_CALL(CURRENT_FUNC);
3603 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3629 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3604 return arguments->NativeArgCount(); 3630 return arguments->NativeArgCount();
3605 } 3631 }
3606 3632
3607 3633
3608 DART_EXPORT Dart_Handle Dart_GetNativeFieldOfArgument(Dart_NativeArguments args, 3634 DART_EXPORT Dart_Handle Dart_GetNativeFieldOfArgument(Dart_NativeArguments args,
3609 int arg_index, 3635 int arg_index,
3610 int fld_index, 3636 int fld_index,
3611 intptr_t* value) { 3637 intptr_t* value) {
3612 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3638 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3685 return Api::NewHandle(isolate, obj.raw()); 3711 return Api::NewHandle(isolate, obj.raw());
3686 } 3712 }
3687 return Api::NewError("%s expects argument to be of" 3713 return Api::NewError("%s expects argument to be of"
3688 " type String.", CURRENT_FUNC); 3714 " type String.", CURRENT_FUNC);
3689 } 3715 }
3690 3716
3691 3717
3692 DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, 3718 DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args,
3693 int index, 3719 int index,
3694 int64_t* value) { 3720 int64_t* value) {
3721 TRACE_API_CALL(CURRENT_FUNC);
3695 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3722 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3696 if ((index < 0) || (index >= arguments->NativeArgCount())) { 3723 if ((index < 0) || (index >= arguments->NativeArgCount())) {
3697 return Api::NewError( 3724 return Api::NewError(
3698 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 3725 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
3699 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 3726 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
3700 } 3727 }
3701 Isolate* isolate = arguments->isolate(); 3728 Isolate* isolate = arguments->isolate();
3702 ReusableObjectHandleScope reused_obj_handle(isolate); 3729 ReusableObjectHandleScope reused_obj_handle(isolate);
3703 Object& obj = reused_obj_handle.Handle(); 3730 Object& obj = reused_obj_handle.Handle();
3704 obj = arguments->NativeArgAt(index); 3731 obj = arguments->NativeArgAt(index);
(...skipping 18 matching lines...) Expand all
3723 } 3750 }
3724 return Api::NewError( 3751 return Api::NewError(
3725 "%s: argument %d is not an Integer argument.", 3752 "%s: argument %d is not an Integer argument.",
3726 CURRENT_FUNC, index); 3753 CURRENT_FUNC, index);
3727 } 3754 }
3728 3755
3729 3756
3730 DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, 3757 DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args,
3731 int index, 3758 int index,
3732 bool* value) { 3759 bool* value) {
3760 TRACE_API_CALL(CURRENT_FUNC);
3733 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3761 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3734 if ((index < 0) || (index >= arguments->NativeArgCount())) { 3762 if ((index < 0) || (index >= arguments->NativeArgCount())) {
3735 return Api::NewError( 3763 return Api::NewError(
3736 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 3764 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
3737 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 3765 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
3738 } 3766 }
3739 Isolate* isolate = arguments->isolate(); 3767 Isolate* isolate = arguments->isolate();
3740 ReusableObjectHandleScope reused_obj_handle(isolate); 3768 ReusableObjectHandleScope reused_obj_handle(isolate);
3741 Object& obj = reused_obj_handle.Handle(); 3769 Object& obj = reused_obj_handle.Handle();
3742 obj = arguments->NativeArgAt(index); 3770 obj = arguments->NativeArgAt(index);
3743 intptr_t cid = obj.GetClassId(); 3771 intptr_t cid = obj.GetClassId();
3744 if (cid == kBoolCid) { 3772 if (cid == kBoolCid) {
3745 *value = Bool::Cast(obj).value(); 3773 *value = Bool::Cast(obj).value();
3746 return Api::Success(); 3774 return Api::Success();
3747 } 3775 }
3748 if (obj.IsNull()) { 3776 if (obj.IsNull()) {
3749 *value = false; 3777 *value = false;
3750 return Api::Success(); 3778 return Api::Success();
3751 } 3779 }
3752 return Api::NewError( 3780 return Api::NewError(
3753 "%s: argument %d is not a Boolean argument.", 3781 "%s: argument %d is not a Boolean argument.",
3754 CURRENT_FUNC, index); 3782 CURRENT_FUNC, index);
3755 } 3783 }
3756 3784
3757 3785
3758 DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args, 3786 DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args,
3759 int index, 3787 int index,
3760 double* value) { 3788 double* value) {
3789 TRACE_API_CALL(CURRENT_FUNC);
3761 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3790 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3762 if ((index < 0) || (index >= arguments->NativeArgCount())) { 3791 if ((index < 0) || (index >= arguments->NativeArgCount())) {
3763 return Api::NewError( 3792 return Api::NewError(
3764 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 3793 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
3765 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 3794 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
3766 } 3795 }
3767 Isolate* isolate = arguments->isolate(); 3796 Isolate* isolate = arguments->isolate();
3768 ReusableObjectHandleScope reused_obj_handle(isolate); 3797 ReusableObjectHandleScope reused_obj_handle(isolate);
3769 Object& obj = reused_obj_handle.Handle(); 3798 Object& obj = reused_obj_handle.Handle();
3770 obj = arguments->NativeArgAt(index); 3799 obj = arguments->NativeArgAt(index);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3813 CHECK_ISOLATE(isolate); 3842 CHECK_ISOLATE(isolate);
3814 ASSERT(isolate->api_state() != NULL && 3843 ASSERT(isolate->api_state() != NULL &&
3815 (isolate->api_state()->IsValidWeakPersistentHandle(rval) || 3844 (isolate->api_state()->IsValidWeakPersistentHandle(rval) ||
3816 isolate->api_state()->IsValidPrologueWeakPersistentHandle(rval))); 3845 isolate->api_state()->IsValidPrologueWeakPersistentHandle(rval)));
3817 Api::SetWeakHandleReturnValue(arguments, rval); 3846 Api::SetWeakHandleReturnValue(arguments, rval);
3818 } 3847 }
3819 3848
3820 3849
3821 DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, 3850 DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args,
3822 bool retval) { 3851 bool retval) {
3852 TRACE_API_CALL(CURRENT_FUNC);
3823 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3853 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3824 arguments->SetReturn(Bool::Get(retval)); 3854 arguments->SetReturn(Bool::Get(retval));
3825 } 3855 }
3826 3856
3827 3857
3828 DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, 3858 DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args,
3829 int64_t retval) { 3859 int64_t retval) {
3830 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 3860 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
3831 Isolate* isolate = arguments->isolate(); 3861 Isolate* isolate = arguments->isolate();
3832 CHECK_ISOLATE(isolate); 3862 CHECK_ISOLATE(isolate);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
4321 } 4351 }
4322 { 4352 {
4323 NoGCScope no_gc; 4353 NoGCScope no_gc;
4324 RawObject* raw_obj = obj.raw(); 4354 RawObject* raw_obj = obj.raw();
4325 isolate->heap()->SetPeer(raw_obj, peer); 4355 isolate->heap()->SetPeer(raw_obj, peer);
4326 } 4356 }
4327 return Api::Success(); 4357 return Api::Success();
4328 } 4358 }
4329 4359
4330 } // namespace dart 4360 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/native_arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698