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

Side by Side Diff: vm/dart_api_impl.cc

Issue 10827209: Unify class ids and snapshot object ids list so that we don't have disparate and sometimes confusin… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 | « vm/dart_api_impl.h ('k') | vm/dart_api_message.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 // --- Handles --- 263 // --- Handles ---
264 264
265 265
266 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { 266 DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
267 return RawObject::IsErrorClassId(Api::ClassId(handle)); 267 return RawObject::IsErrorClassId(Api::ClassId(handle));
268 } 268 }
269 269
270 270
271 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { 271 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) {
272 return Api::ClassId(object) == kApiError; 272 return Api::ClassId(object) == kApiErrorCid;
273 } 273 }
274 274
275 275
276 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) { 276 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) {
277 return Api::ClassId(object) == kUnhandledException; 277 return Api::ClassId(object) == kUnhandledExceptionCid;
278 } 278 }
279 279
280 280
281 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) { 281 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) {
282 return Api::ClassId(object) == kLanguageError; 282 return Api::ClassId(object) == kLanguageErrorCid;
283 } 283 }
284 284
285 285
286 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) { 286 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) {
287 return Api::ClassId(object) == kUnwindError; 287 return Api::ClassId(object) == kUnwindErrorCid;
288 } 288 }
289 289
290 290
291 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) { 291 DART_EXPORT const char* Dart_GetError(Dart_Handle handle) {
292 Isolate* isolate = Isolate::Current(); 292 Isolate* isolate = Isolate::Current();
293 DARTSCOPE(isolate); 293 DARTSCOPE(isolate);
294 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); 294 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
295 if (obj.IsError()) { 295 if (obj.IsError()) {
296 const Error& error = Error::Cast(obj); 296 const Error& error = Error::Cast(obj);
297 const char* str = error.ToErrorCString(); 297 const char* str = error.ToErrorCString();
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1108
1109 1109
1110 DART_EXPORT Dart_Handle Dart_Null() { 1110 DART_EXPORT Dart_Handle Dart_Null() {
1111 Isolate* isolate = Isolate::Current(); 1111 Isolate* isolate = Isolate::Current();
1112 CHECK_ISOLATE_SCOPE(isolate); 1112 CHECK_ISOLATE_SCOPE(isolate);
1113 return Api::Null(isolate); 1113 return Api::Null(isolate);
1114 } 1114 }
1115 1115
1116 1116
1117 DART_EXPORT bool Dart_IsNull(Dart_Handle object) { 1117 DART_EXPORT bool Dart_IsNull(Dart_Handle object) {
1118 return Api::ClassId(object) == kNullClassId; 1118 return Api::ClassId(object) == kNullCid;
1119 } 1119 }
1120 1120
1121 1121
1122 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2, 1122 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2,
1123 bool* value) { 1123 bool* value) {
1124 Isolate* isolate = Isolate::Current(); 1124 Isolate* isolate = Isolate::Current();
1125 DARTSCOPE(isolate); 1125 DARTSCOPE(isolate);
1126 const Instance& expected = 1126 const Instance& expected =
1127 Instance::CheckedHandle(isolate, Api::UnwrapHandle(obj1)); 1127 Instance::CheckedHandle(isolate, Api::UnwrapHandle(obj1));
1128 const Instance& actual = 1128 const Instance& actual =
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 return RawObject::IsIntegerClassId(Api::ClassId(object)); 1219 return RawObject::IsIntegerClassId(Api::ClassId(object));
1220 } 1220 }
1221 1221
1222 1222
1223 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, 1223 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
1224 bool* fits) { 1224 bool* fits) {
1225 // Fast path for Smis and Mints. 1225 // Fast path for Smis and Mints.
1226 Isolate* isolate = Isolate::Current(); 1226 Isolate* isolate = Isolate::Current();
1227 CHECK_ISOLATE(isolate); 1227 CHECK_ISOLATE(isolate);
1228 intptr_t class_id = Api::ClassId(integer); 1228 intptr_t class_id = Api::ClassId(integer);
1229 if (class_id == kSmi || class_id == kMint) { 1229 if (class_id == kSmiCid || class_id == kMintCid) {
1230 *fits = true; 1230 *fits = true;
1231 return Api::Success(isolate); 1231 return Api::Success(isolate);
1232 } 1232 }
1233 1233
1234 DARTSCOPE_NOCHECKS(isolate); 1234 DARTSCOPE_NOCHECKS(isolate);
1235 const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer); 1235 const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer);
1236 if (int_obj.IsNull()) { 1236 if (int_obj.IsNull()) {
1237 RETURN_TYPE_ERROR(isolate, integer, Integer); 1237 RETURN_TYPE_ERROR(isolate, integer, Integer);
1238 } 1238 }
1239 ASSERT(!BigintOperations::FitsIntoMint(Bigint::Cast(int_obj))); 1239 ASSERT(!BigintOperations::FitsIntoMint(Bigint::Cast(int_obj)));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 1389
1390 1390
1391 DART_EXPORT Dart_Handle Dart_False() { 1391 DART_EXPORT Dart_Handle Dart_False() {
1392 Isolate* isolate = Isolate::Current(); 1392 Isolate* isolate = Isolate::Current();
1393 CHECK_ISOLATE_SCOPE(isolate); 1393 CHECK_ISOLATE_SCOPE(isolate);
1394 return Api::False(isolate); 1394 return Api::False(isolate);
1395 } 1395 }
1396 1396
1397 1397
1398 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) { 1398 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) {
1399 return Api::ClassId(object) == kBool; 1399 return Api::ClassId(object) == kBoolCid;
1400 } 1400 }
1401 1401
1402 1402
1403 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) { 1403 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) {
1404 Isolate* isolate = Isolate::Current(); 1404 Isolate* isolate = Isolate::Current();
1405 CHECK_ISOLATE_SCOPE(isolate); 1405 CHECK_ISOLATE_SCOPE(isolate);
1406 return value ? Api::True(isolate) : Api::False(isolate); 1406 return value ? Api::True(isolate) : Api::False(isolate);
1407 } 1407 }
1408 1408
1409 1409
1410 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, 1410 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj,
1411 bool* value) { 1411 bool* value) {
1412 Isolate* isolate = Isolate::Current(); 1412 Isolate* isolate = Isolate::Current();
1413 DARTSCOPE(isolate); 1413 DARTSCOPE(isolate);
1414 const Bool& obj = Api::UnwrapBoolHandle(isolate, boolean_obj); 1414 const Bool& obj = Api::UnwrapBoolHandle(isolate, boolean_obj);
1415 if (obj.IsNull()) { 1415 if (obj.IsNull()) {
1416 RETURN_TYPE_ERROR(isolate, boolean_obj, Bool); 1416 RETURN_TYPE_ERROR(isolate, boolean_obj, Bool);
1417 } 1417 }
1418 *value = obj.value(); 1418 *value = obj.value();
1419 return Api::Success(isolate); 1419 return Api::Success(isolate);
1420 } 1420 }
1421 1421
1422 1422
1423 // --- Doubles --- 1423 // --- Doubles ---
1424 1424
1425 1425
1426 DART_EXPORT bool Dart_IsDouble(Dart_Handle object) { 1426 DART_EXPORT bool Dart_IsDouble(Dart_Handle object) {
1427 return Api::ClassId(object) == kDouble; 1427 return Api::ClassId(object) == kDoubleCid;
1428 } 1428 }
1429 1429
1430 1430
1431 DART_EXPORT Dart_Handle Dart_NewDouble(double value) { 1431 DART_EXPORT Dart_Handle Dart_NewDouble(double value) {
1432 Isolate* isolate = Isolate::Current(); 1432 Isolate* isolate = Isolate::Current();
1433 DARTSCOPE(isolate); 1433 DARTSCOPE(isolate);
1434 return Api::NewHandle(isolate, Double::New(value)); 1434 return Api::NewHandle(isolate, Double::New(value));
1435 } 1435 }
1436 1436
1437 1437
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 func_kind == RawFunction::kGetterFunction || 2653 func_kind == RawFunction::kGetterFunction ||
2654 func_kind == RawFunction::kSetterFunction || 2654 func_kind == RawFunction::kSetterFunction ||
2655 func_kind == RawFunction::kConstructor); 2655 func_kind == RawFunction::kConstructor);
2656 } 2656 }
2657 #endif 2657 #endif
2658 return Api::NewHandle(isolate, func.raw()); 2658 return Api::NewHandle(isolate, func.raw());
2659 } 2659 }
2660 2660
2661 2661
2662 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) { 2662 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle) {
2663 return Api::ClassId(handle) == kFunction; 2663 return Api::ClassId(handle) == kFunctionCid;
2664 } 2664 }
2665 2665
2666 2666
2667 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function) { 2667 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function) {
2668 Isolate* isolate = Isolate::Current(); 2668 Isolate* isolate = Isolate::Current();
2669 DARTSCOPE(isolate); 2669 DARTSCOPE(isolate);
2670 const Function& func = Api::UnwrapFunctionHandle(isolate, function); 2670 const Function& func = Api::UnwrapFunctionHandle(isolate, function);
2671 if (func.IsNull()) { 2671 if (func.IsNull()) {
2672 RETURN_TYPE_ERROR(isolate, function, Function); 2672 RETURN_TYPE_ERROR(isolate, function, Function);
2673 } 2673 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 const Library& lib = Library::Cast(obj); 2885 const Library& lib = Library::Cast(obj);
2886 return Api::NewHandle(isolate, lib.LookupFieldAllowPrivate(var_name)); 2886 return Api::NewHandle(isolate, lib.LookupFieldAllowPrivate(var_name));
2887 } 2887 }
2888 return Api::NewError( 2888 return Api::NewError(
2889 "%s expects argument 'target' to be a class or library.", 2889 "%s expects argument 'target' to be a class or library.",
2890 CURRENT_FUNC); 2890 CURRENT_FUNC);
2891 } 2891 }
2892 2892
2893 2893
2894 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle) { 2894 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle) {
2895 return Api::ClassId(handle) == kField; 2895 return Api::ClassId(handle) == kFieldCid;
2896 } 2896 }
2897 2897
2898 2898
2899 DART_EXPORT Dart_Handle Dart_VariableName(Dart_Handle variable) { 2899 DART_EXPORT Dart_Handle Dart_VariableName(Dart_Handle variable) {
2900 Isolate* isolate = Isolate::Current(); 2900 Isolate* isolate = Isolate::Current();
2901 DARTSCOPE(isolate); 2901 DARTSCOPE(isolate);
2902 const Field& var = Api::UnwrapFieldHandle(isolate, variable); 2902 const Field& var = Api::UnwrapFieldHandle(isolate, variable);
2903 if (var.IsNull()) { 2903 if (var.IsNull()) {
2904 RETURN_TYPE_ERROR(isolate, variable, Field); 2904 RETURN_TYPE_ERROR(isolate, variable, Field);
2905 } 2905 }
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 const char* msg = CheckIsolateState(isolate); 3835 const char* msg = CheckIsolateState(isolate);
3836 if (msg != NULL) { 3836 if (msg != NULL) {
3837 return Api::NewError(msg); 3837 return Api::NewError(msg);
3838 } 3838 }
3839 CompileAll(isolate, &result); 3839 CompileAll(isolate, &result);
3840 return result; 3840 return result;
3841 } 3841 }
3842 3842
3843 3843
3844 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) { 3844 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) {
3845 return Api::ClassId(object) == kLibrary; 3845 return Api::ClassId(object) == kLibraryCid;
3846 } 3846 }
3847 3847
3848 3848
3849 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, 3849 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library,
3850 Dart_Handle class_name) { 3850 Dart_Handle class_name) {
3851 Isolate* isolate = Isolate::Current(); 3851 Isolate* isolate = Isolate::Current();
3852 DARTSCOPE(isolate); 3852 DARTSCOPE(isolate);
3853 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); 3853 const Library& lib = Api::UnwrapLibraryHandle(isolate, library);
3854 if (lib.IsNull()) { 3854 if (lib.IsNull()) {
3855 RETURN_TYPE_ERROR(isolate, library, Library); 3855 RETURN_TYPE_ERROR(isolate, library, Library);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
4081 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4081 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4082 Dart::set_perf_events_writer(function); 4082 Dart::set_perf_events_writer(function);
4083 } 4083 }
4084 4084
4085 4085
4086 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4086 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4087 Dart::set_flow_graph_writer(function); 4087 Dart::set_flow_graph_writer(function);
4088 } 4088 }
4089 4089
4090 } // namespace dart 4090 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.h ('k') | vm/dart_api_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698