| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 return obj.IsBool(); | 1047 return obj.IsBool(); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 | 1050 |
| 1051 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) { | 1051 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) { |
| 1052 CHECK_ISOLATE_SCOPE(Isolate::Current()); | 1052 CHECK_ISOLATE_SCOPE(Isolate::Current()); |
| 1053 return value ? Api::True() : Api::False(); | 1053 return value ? Api::True() : Api::False(); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 | 1056 |
| 1057 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object, | 1057 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, |
| 1058 bool* value) { | 1058 bool* value) { |
| 1059 DARTSCOPE(Isolate::Current()); | 1059 DARTSCOPE(Isolate::Current()); |
| 1060 const Object& obj = Object::Handle(Api::UnwrapHandle(bool_object)); | 1060 const Bool& obj = Api::UnwrapBoolHandle(boolean_obj); |
| 1061 if (obj.IsBool()) { | 1061 if (obj.IsNull()) { |
| 1062 Bool& bool_obj = Bool::Handle(); | 1062 RETURN_TYPE_ERROR(boolean_obj, Bool); |
| 1063 bool_obj ^= obj.raw(); | |
| 1064 *value = bool_obj.value(); | |
| 1065 return Api::Success(); | |
| 1066 } | 1063 } |
| 1067 return Api::Error("Object is not a Boolean"); | 1064 *value = obj.value(); |
| 1065 return Api::Success(); |
| 1068 } | 1066 } |
| 1069 | 1067 |
| 1070 | 1068 |
| 1071 // --- Doubles --- | 1069 // --- Doubles --- |
| 1072 | 1070 |
| 1073 | 1071 |
| 1074 DART_EXPORT bool Dart_IsDouble(Dart_Handle object) { | 1072 DART_EXPORT bool Dart_IsDouble(Dart_Handle object) { |
| 1075 DARTSCOPE(Isolate::Current()); | 1073 DARTSCOPE(Isolate::Current()); |
| 1076 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); | 1074 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| 1077 return obj.IsDouble(); | 1075 return obj.IsDouble(); |
| 1078 } | 1076 } |
| 1079 | 1077 |
| 1080 | 1078 |
| 1081 DART_EXPORT Dart_Handle Dart_NewDouble(double value) { | 1079 DART_EXPORT Dart_Handle Dart_NewDouble(double value) { |
| 1082 DARTSCOPE(Isolate::Current()); | 1080 DARTSCOPE(Isolate::Current()); |
| 1083 const Double& obj = Double::Handle(Double::New(value)); | 1081 const Double& obj = Double::Handle(Double::New(value)); |
| 1084 return Api::NewLocalHandle(obj); | 1082 return Api::NewLocalHandle(obj); |
| 1085 } | 1083 } |
| 1086 | 1084 |
| 1087 | 1085 |
| 1088 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result) { | 1086 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, |
| 1087 double* value) { |
| 1089 DARTSCOPE(Isolate::Current()); | 1088 DARTSCOPE(Isolate::Current()); |
| 1090 const Object& obj = Object::Handle(Api::UnwrapHandle(integer)); | 1089 const Double& obj = Api::UnwrapDoubleHandle(double_obj); |
| 1091 if (obj.IsDouble()) { | 1090 if (obj.IsNull()) { |
| 1092 Double& double_obj = Double::Handle(); | 1091 RETURN_TYPE_ERROR(double_obj, Double); |
| 1093 double_obj ^= obj.raw(); | |
| 1094 *result = double_obj.value(); | |
| 1095 return Api::Success(); | |
| 1096 } | 1092 } |
| 1097 return Api::Error("Object is not a Double"); | 1093 *value = obj.value(); |
| 1094 return Api::Success(); |
| 1098 } | 1095 } |
| 1099 | 1096 |
| 1100 | 1097 |
| 1101 // --- Strings --- | 1098 // --- Strings --- |
| 1102 | 1099 |
| 1103 | 1100 |
| 1104 DART_EXPORT bool Dart_IsString(Dart_Handle object) { | 1101 DART_EXPORT bool Dart_IsString(Dart_Handle object) { |
| 1105 DARTSCOPE(Isolate::Current()); | 1102 DARTSCOPE(Isolate::Current()); |
| 1106 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); | 1103 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| 1107 return obj.IsString(); | 1104 return obj.IsString(); |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2470 } | 2467 } |
| 2471 delete debug_region; | 2468 delete debug_region; |
| 2472 } else { | 2469 } else { |
| 2473 *buffer = NULL; | 2470 *buffer = NULL; |
| 2474 *buffer_size = 0; | 2471 *buffer_size = 0; |
| 2475 } | 2472 } |
| 2476 } | 2473 } |
| 2477 | 2474 |
| 2478 | 2475 |
| 2479 } // namespace dart | 2476 } // namespace dart |
| OLD | NEW |