From d3accda938cb8e5417515820b882a539664ac6e3 Mon Sep 17 00:00:00 2001 From: "yusukes@google.com" Date: Mon, 2 May 2011 01:59:21 +0000 Subject: Modified Value::GetAsDouble so the function returns true when the object holds an Integer. This should be useful when implementing an extension API in C++ since chrome.api.call(1.0); call in JS passes a Value of Integer to the C++ code while chrome.api.call(1.1); does a Value of Double. I'm working on this following Mihai's suggestion in http://codereview.chromium.org/6905053/. BUG=chromium-os:14421 TEST=ran try Review URL: http://codereview.chromium.org/6893089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83705 0039d316-1c4b-4281-b951-d872f2087c98 --- base/values.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'base/values.cc') diff --git a/base/values.cc b/base/values.cc index 9f2816a..0f30e379 100644 --- a/base/values.cc +++ b/base/values.cc @@ -179,7 +179,9 @@ bool FundamentalValue::GetAsInteger(int* out_value) const { bool FundamentalValue::GetAsDouble(double* out_value) const { if (out_value && IsType(TYPE_DOUBLE)) *out_value = double_value_; - return (IsType(TYPE_DOUBLE)); + else if (out_value && IsType(TYPE_INTEGER)) + *out_value = integer_value_; + return (IsType(TYPE_DOUBLE) || IsType(TYPE_INTEGER)); } FundamentalValue* FundamentalValue::DeepCopy() const { -- cgit v1.1