Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl.cc (revision 31244) |
| +++ runtime/vm/dart_api_impl.cc (working copy) |
| @@ -293,6 +293,27 @@ |
| } |
| +bool Api::GetNativeBooleanArgument(Dart_NativeArguments args, |
| + int arg_index, |
| + bool* value) { |
| + NoGCScope no_gc_scope; |
| + NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| + RawObject* raw_obj = arguments->NativeArgAt(arg_index); |
| + if (raw_obj->IsHeapObject()) { |
| + intptr_t cid = raw_obj->GetClassId(); |
| + if (cid == kBoolCid) { |
| + *value = (raw_obj == Object::bool_true().raw()); |
| + return true; |
| + } |
| + if (cid == kNullCid) { |
| + *value = false; |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |
| + |
| + |
| void Api::SetWeakHandleReturnValue(NativeArguments* args, |
| Dart_WeakPersistentHandle retval) { |
| args->SetReturnUnsafe(Api::UnwrapAsWeakPersistentHandle(retval)->raw()); |
| @@ -3857,21 +3878,10 @@ |
| "%s: argument 'index' out of range. Expected 0..%d but saw %d.", |
| CURRENT_FUNC, arguments->NativeArgCount() - 1, index); |
| } |
| - Isolate* isolate = arguments->isolate(); |
| - ReusableObjectHandleScope reused_obj_handle(isolate); |
| - Object& obj = reused_obj_handle.Handle(); |
| - obj = arguments->NativeArgAt(index); |
| - intptr_t cid = obj.GetClassId(); |
| - if (cid == kBoolCid) { |
| - *value = Bool::Cast(obj).value(); |
| + if (Api::GetNativeBooleanArgument(args, index, value)) { |
| return Api::Success(); |
| } |
| - if (obj.IsNull()) { |
|
rmacnak
2013/12/19 19:36:38
We've been interpreting null as false?
|
| - *value = false; |
| - return Api::Success(); |
| - } |
| - return Api::NewError( |
| - "%s: argument %d is not a Boolean argument.", |
| + return Api::NewError("%s: argument %d is not a Boolean argument.", |
| CURRENT_FUNC, index); |
| } |