summaryrefslogtreecommitdiffstats
path: root/base/values.cc
diff options
context:
space:
mode:
authoryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-02 01:59:21 +0000
committeryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-02 01:59:21 +0000
commitd3accda938cb8e5417515820b882a539664ac6e3 (patch)
tree0041ae1e871dacc42ddf8bbad65bead7a7eae2d7 /base/values.cc
parent2cd8023ba7173fc6070a48d5cee7e390dd2e9ebd (diff)
downloadchromium_src-d3accda938cb8e5417515820b882a539664ac6e3.zip
chromium_src-d3accda938cb8e5417515820b882a539664ac6e3.tar.gz
chromium_src-d3accda938cb8e5417515820b882a539664ac6e3.tar.bz2
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
Diffstat (limited to 'base/values.cc')
-rw-r--r--base/values.cc4
1 files changed, 3 insertions, 1 deletions
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 {