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

Side by Side Diff: third_party/WebKit/Source/platform/JSONValues.cpp

Issue 1746283002: Rename enums/functions that collide in chromium style in platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get-names-13-platform: . Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 output->append('\n'); 162 output->append('\n');
163 } 163 }
164 164
165 void JSONValue::prettyWriteJSONInternal(StringBuilder* output, int depth) const 165 void JSONValue::prettyWriteJSONInternal(StringBuilder* output, int depth) const
166 { 166 {
167 writeJSON(output); 167 writeJSON(output);
168 } 168 }
169 169
170 bool JSONBasicValue::asBoolean(bool* output) const 170 bool JSONBasicValue::asBoolean(bool* output) const
171 { 171 {
172 if (type() != TypeBoolean) 172 if (getType() != TypeBoolean)
173 return false; 173 return false;
174 *output = m_boolValue; 174 *output = m_boolValue;
175 return true; 175 return true;
176 } 176 }
177 177
178 bool JSONBasicValue::asNumber(double* output) const 178 bool JSONBasicValue::asNumber(double* output) const
179 { 179 {
180 if (type() != TypeNumber) 180 if (getType() != TypeNumber)
181 return false; 181 return false;
182 *output = m_doubleValue; 182 *output = m_doubleValue;
183 return true; 183 return true;
184 } 184 }
185 185
186 bool JSONBasicValue::asNumber(long* output) const 186 bool JSONBasicValue::asNumber(long* output) const
187 { 187 {
188 if (type() != TypeNumber) 188 if (getType() != TypeNumber)
189 return false; 189 return false;
190 *output = static_cast<long>(m_doubleValue); 190 *output = static_cast<long>(m_doubleValue);
191 return true; 191 return true;
192 } 192 }
193 193
194 bool JSONBasicValue::asNumber(int* output) const 194 bool JSONBasicValue::asNumber(int* output) const
195 { 195 {
196 if (type() != TypeNumber) 196 if (getType() != TypeNumber)
197 return false; 197 return false;
198 *output = static_cast<int>(m_doubleValue); 198 *output = static_cast<int>(m_doubleValue);
199 return true; 199 return true;
200 } 200 }
201 201
202 bool JSONBasicValue::asNumber(unsigned long* output) const 202 bool JSONBasicValue::asNumber(unsigned long* output) const
203 { 203 {
204 if (type() != TypeNumber) 204 if (getType() != TypeNumber)
205 return false; 205 return false;
206 *output = static_cast<unsigned long>(m_doubleValue); 206 *output = static_cast<unsigned long>(m_doubleValue);
207 return true; 207 return true;
208 } 208 }
209 209
210 bool JSONBasicValue::asNumber(unsigned* output) const 210 bool JSONBasicValue::asNumber(unsigned* output) const
211 { 211 {
212 if (type() != TypeNumber) 212 if (getType() != TypeNumber)
213 return false; 213 return false;
214 *output = static_cast<unsigned>(m_doubleValue); 214 *output = static_cast<unsigned>(m_doubleValue);
215 return true; 215 return true;
216 } 216 }
217 217
218 void JSONBasicValue::writeJSON(StringBuilder* output) const 218 void JSONBasicValue::writeJSON(StringBuilder* output) const
219 { 219 {
220 ASSERT(type() == TypeBoolean || type() == TypeNumber); 220 ASSERT(getType() == TypeBoolean || getType() == TypeNumber);
221 if (type() == TypeBoolean) { 221 if (getType() == TypeBoolean) {
222 if (m_boolValue) 222 if (m_boolValue)
223 output->append(trueString, 4); 223 output->append(trueString, 4);
224 else 224 else
225 output->append(falseString, 5); 225 output->append(falseString, 5);
226 } else if (type() == TypeNumber) { 226 } else if (getType() == TypeNumber) {
227 if (!std::isfinite(m_doubleValue)) { 227 if (!std::isfinite(m_doubleValue)) {
228 output->append(nullString, 4); 228 output->append(nullString, 4);
229 return; 229 return;
230 } 230 }
231 output->append(Decimal::fromDouble(m_doubleValue).toString()); 231 output->append(Decimal::fromDouble(m_doubleValue).toString());
232 } 232 }
233 } 233 }
234 234
235 bool JSONString::asString(String* output) const 235 bool JSONString::asString(String* output) const
236 { 236 {
237 *output = m_stringValue; 237 *output = m_stringValue;
238 return true; 238 return true;
239 } 239 }
240 240
241 void JSONString::writeJSON(StringBuilder* output) const 241 void JSONString::writeJSON(StringBuilder* output) const
242 { 242 {
243 ASSERT(type() == TypeString); 243 ASSERT(getType() == TypeString);
244 doubleQuoteStringForJSON(m_stringValue, output); 244 doubleQuoteStringForJSON(m_stringValue, output);
245 } 245 }
246 246
247 JSONObject::~JSONObject() 247 JSONObject::~JSONObject()
248 { 248 {
249 } 249 }
250 250
251 void JSONObject::setBoolean(const String& name, bool value) 251 void JSONObject::setBoolean(const String& name, bool value)
252 { 252 {
253 setValue(name, JSONBasicValue::create(value)); 253 setValue(name, JSONBasicValue::create(value));
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 (*it)->writeJSON(output); 399 (*it)->writeJSON(output);
400 } 400 }
401 output->append(']'); 401 output->append(']');
402 } 402 }
403 403
404 void JSONArray::prettyWriteJSONInternal(StringBuilder* output, int depth) const 404 void JSONArray::prettyWriteJSONInternal(StringBuilder* output, int depth) const
405 { 405 {
406 output->append('['); 406 output->append('[');
407 bool lastInsertedNewLine = false; 407 bool lastInsertedNewLine = false;
408 for (Vector<RefPtr<JSONValue>>::const_iterator it = m_data.begin(); it != m_ data.end(); ++it) { 408 for (Vector<RefPtr<JSONValue>>::const_iterator it = m_data.begin(); it != m_ data.end(); ++it) {
409 bool insertNewLine = (*it)->type() == JSONValue::TypeObject || (*it)->ty pe() == JSONValue::TypeArray || (*it)->type() == JSONValue::TypeString; 409 bool insertNewLine = (*it)->getType() == JSONValue::TypeObject || (*it)- >getType() == JSONValue::TypeArray || (*it)->getType() == JSONValue::TypeString;
410 if (it == m_data.begin()) { 410 if (it == m_data.begin()) {
411 if (insertNewLine) { 411 if (insertNewLine) {
412 output->append('\n'); 412 output->append('\n');
413 writeIndent(depth + 1, output); 413 writeIndent(depth + 1, output);
414 } 414 }
415 } else { 415 } else {
416 output->append(','); 416 output->append(',');
417 if (lastInsertedNewLine) { 417 if (lastInsertedNewLine) {
418 output->append('\n'); 418 output->append('\n');
419 writeIndent(depth + 1, output); 419 writeIndent(depth + 1, output);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 m_data.append(value); 475 m_data.append(value);
476 } 476 }
477 477
478 PassRefPtr<JSONValue> JSONArray::get(size_t index) 478 PassRefPtr<JSONValue> JSONArray::get(size_t index)
479 { 479 {
480 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); 480 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size());
481 return m_data[index]; 481 return m_data[index];
482 } 482 }
483 483
484 } // namespace blink 484 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/JSONValues.h ('k') | third_party/WebKit/Source/platform/Length.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698