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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 8888031: Use specialized unwrapping methods for reading Double and Bool values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/include/dart_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index e5e2cc9cf5b187a4199e5c937be7385e32bb043c..240580cc5a659eccf43941fd843e9db7f37c49f1 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1054,17 +1054,15 @@ DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) {
}
-DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object,
+DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj,
bool* value) {
DARTSCOPE(Isolate::Current());
- const Object& obj = Object::Handle(Api::UnwrapHandle(bool_object));
- if (obj.IsBool()) {
- Bool& bool_obj = Bool::Handle();
- bool_obj ^= obj.raw();
- *value = bool_obj.value();
- return Api::Success();
+ const Bool& obj = Api::UnwrapBoolHandle(boolean_obj);
+ if (obj.IsNull()) {
+ RETURN_TYPE_ERROR(boolean_obj, Bool);
}
- return Api::Error("Object is not a Boolean");
+ *value = obj.value();
+ return Api::Success();
}
@@ -1085,16 +1083,15 @@ DART_EXPORT Dart_Handle Dart_NewDouble(double value) {
}
-DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result) {
+DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj,
+ double* value) {
DARTSCOPE(Isolate::Current());
- const Object& obj = Object::Handle(Api::UnwrapHandle(integer));
- if (obj.IsDouble()) {
- Double& double_obj = Double::Handle();
- double_obj ^= obj.raw();
- *result = double_obj.value();
- return Api::Success();
+ const Double& obj = Api::UnwrapDoubleHandle(double_obj);
+ if (obj.IsNull()) {
+ RETURN_TYPE_ERROR(double_obj, Double);
}
- return Api::Error("Object is not a Double");
+ *value = obj.value();
+ return Api::Success();
}
« no previous file with comments | « runtime/include/dart_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698