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

Side by Side Diff: base/values.cc

Issue 6893089: Modified Value::GetAsDouble so the function returns true when the object holds an Integer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 9 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/values_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/values.h" 5 #include "base/values.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 bool FundamentalValue::GetAsInteger(int* out_value) const { 173 bool FundamentalValue::GetAsInteger(int* out_value) const {
174 if (out_value && IsType(TYPE_INTEGER)) 174 if (out_value && IsType(TYPE_INTEGER))
175 *out_value = integer_value_; 175 *out_value = integer_value_;
176 return (IsType(TYPE_INTEGER)); 176 return (IsType(TYPE_INTEGER));
177 } 177 }
178 178
179 bool FundamentalValue::GetAsDouble(double* out_value) const { 179 bool FundamentalValue::GetAsDouble(double* out_value) const {
180 if (out_value && IsType(TYPE_DOUBLE)) 180 if (out_value && IsType(TYPE_DOUBLE))
181 *out_value = double_value_; 181 *out_value = double_value_;
182 return (IsType(TYPE_DOUBLE)); 182 else if (out_value && IsType(TYPE_INTEGER))
183 *out_value = integer_value_;
184 return (IsType(TYPE_DOUBLE) || IsType(TYPE_INTEGER));
183 } 185 }
184 186
185 FundamentalValue* FundamentalValue::DeepCopy() const { 187 FundamentalValue* FundamentalValue::DeepCopy() const {
186 switch (GetType()) { 188 switch (GetType()) {
187 case TYPE_BOOLEAN: 189 case TYPE_BOOLEAN:
188 return CreateBooleanValue(boolean_value_); 190 return CreateBooleanValue(boolean_value_);
189 191
190 case TYPE_INTEGER: 192 case TYPE_INTEGER:
191 return CreateIntegerValue(integer_value_); 193 return CreateIntegerValue(integer_value_);
192 194
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 return false; 889 return false;
888 } 890 }
889 if (lhs_it != end() || rhs_it != other_list->end()) 891 if (lhs_it != end() || rhs_it != other_list->end())
890 return false; 892 return false;
891 893
892 return true; 894 return true;
893 } 895 }
894 896
895 ValueSerializer::~ValueSerializer() { 897 ValueSerializer::~ValueSerializer() {
896 } 898 }
OLDNEW
« no previous file with comments | « no previous file | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698