| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 ASSERT(type() == TypeString); | 258 ASSERT(type() == TypeString); |
| 259 doubleQuoteString(m_stringValue, output); | 259 doubleQuoteString(m_stringValue, output); |
| 260 } | 260 } |
| 261 | 261 |
| 262 JSONObjectBase::~JSONObjectBase() | 262 JSONObjectBase::~JSONObjectBase() |
| 263 { | 263 { |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool JSONObjectBase::asObject(RefPtr<JSONObject>* output) | 266 bool JSONObjectBase::asObject(RefPtr<JSONObject>* output) |
| 267 { | 267 { |
| 268 COMPILE_ASSERT(sizeof(JSONObject) == sizeof(JSONObjectBase), cannot_cast); | 268 static_assert(sizeof(JSONObject) == sizeof(JSONObjectBase), "cannot cast"); |
| 269 *output = static_cast<JSONObject*>(this); | 269 *output = static_cast<JSONObject*>(this); |
| 270 return true; | 270 return true; |
| 271 } | 271 } |
| 272 | 272 |
| 273 PassRefPtr<JSONObject> JSONObjectBase::asObject() | 273 PassRefPtr<JSONObject> JSONObjectBase::asObject() |
| 274 { | 274 { |
| 275 return openAccessors(); | 275 return openAccessors(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void JSONObjectBase::setBoolean(const String& name, bool value) | 278 void JSONObjectBase::setBoolean(const String& name, bool value) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 306 | 306 |
| 307 void JSONObjectBase::setArray(const String& name, PassRefPtr<JSONArray> value) | 307 void JSONObjectBase::setArray(const String& name, PassRefPtr<JSONArray> value) |
| 308 { | 308 { |
| 309 ASSERT(value); | 309 ASSERT(value); |
| 310 if (m_data.set(name, value).isNewEntry) | 310 if (m_data.set(name, value).isNewEntry) |
| 311 m_order.append(name); | 311 m_order.append(name); |
| 312 } | 312 } |
| 313 | 313 |
| 314 JSONObject* JSONObjectBase::openAccessors() | 314 JSONObject* JSONObjectBase::openAccessors() |
| 315 { | 315 { |
| 316 COMPILE_ASSERT(sizeof(JSONObject) == sizeof(JSONObjectBase), cannot_cast); | 316 static_assert(sizeof(JSONObject) == sizeof(JSONObjectBase), "cannot cast"); |
| 317 return static_cast<JSONObject*>(this); | 317 return static_cast<JSONObject*>(this); |
| 318 } | 318 } |
| 319 | 319 |
| 320 JSONObjectBase::iterator JSONObjectBase::find(const String& name) | 320 JSONObjectBase::iterator JSONObjectBase::find(const String& name) |
| 321 { | 321 { |
| 322 return m_data.find(name); | 322 return m_data.find(name); |
| 323 } | 323 } |
| 324 | 324 |
| 325 JSONObjectBase::const_iterator JSONObjectBase::find(const String& name) const | 325 JSONObjectBase::const_iterator JSONObjectBase::find(const String& name) const |
| 326 { | 326 { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 , m_order() | 417 , m_order() |
| 418 { | 418 { |
| 419 } | 419 } |
| 420 | 420 |
| 421 JSONArrayBase::~JSONArrayBase() | 421 JSONArrayBase::~JSONArrayBase() |
| 422 { | 422 { |
| 423 } | 423 } |
| 424 | 424 |
| 425 bool JSONArrayBase::asArray(RefPtr<JSONArray>* output) | 425 bool JSONArrayBase::asArray(RefPtr<JSONArray>* output) |
| 426 { | 426 { |
| 427 COMPILE_ASSERT(sizeof(JSONArrayBase) == sizeof(JSONArray), cannot_cast); | 427 static_assert(sizeof(JSONArrayBase) == sizeof(JSONArray), "cannot cast"); |
| 428 *output = static_cast<JSONArray*>(this); | 428 *output = static_cast<JSONArray*>(this); |
| 429 return true; | 429 return true; |
| 430 } | 430 } |
| 431 | 431 |
| 432 PassRefPtr<JSONArray> JSONArrayBase::asArray() | 432 PassRefPtr<JSONArray> JSONArrayBase::asArray() |
| 433 { | 433 { |
| 434 COMPILE_ASSERT(sizeof(JSONArrayBase) == sizeof(JSONArray), cannot_cast); | 434 static_assert(sizeof(JSONArrayBase) == sizeof(JSONArray), "cannot cast"); |
| 435 return static_cast<JSONArray*>(this); | 435 return static_cast<JSONArray*>(this); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void JSONArrayBase::writeJSON(StringBuilder* output) const | 438 void JSONArrayBase::writeJSON(StringBuilder* output) const |
| 439 { | 439 { |
| 440 output->append('['); | 440 output->append('['); |
| 441 for (Vector<RefPtr<JSONValue> >::const_iterator it = m_data.begin(); it != m
_data.end(); ++it) { | 441 for (Vector<RefPtr<JSONValue> >::const_iterator it = m_data.begin(); it != m
_data.end(); ++it) { |
| 442 if (it != m_data.begin()) | 442 if (it != m_data.begin()) |
| 443 output->append(','); | 443 output->append(','); |
| 444 (*it)->writeJSON(output); | 444 (*it)->writeJSON(output); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 m_data.append(value); | 520 m_data.append(value); |
| 521 } | 521 } |
| 522 | 522 |
| 523 PassRefPtr<JSONValue> JSONArrayBase::get(size_t index) | 523 PassRefPtr<JSONValue> JSONArrayBase::get(size_t index) |
| 524 { | 524 { |
| 525 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); | 525 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); |
| 526 return m_data[index]; | 526 return m_data[index]; |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace blink | 529 } // namespace blink |
| OLD | NEW |