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

Unified Diff: Source/platform/JSONValues.cpp

Issue 247573009: Uninline JSON{Array,Object}Base methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/JSONValues.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/JSONValues.cpp
diff --git a/Source/platform/JSONValues.cpp b/Source/platform/JSONValues.cpp
index 505dd8e53c8b3d279b8becb55b00c9866bb27b46..074fd77c8e9f307ac898fa1c1bfb9a369d51defd 100644
--- a/Source/platform/JSONValues.cpp
+++ b/Source/platform/JSONValues.cpp
@@ -264,12 +264,58 @@ PassRefPtr<JSONObject> JSONObjectBase::asObject()
return openAccessors();
}
+void JSONObjectBase::setBoolean(const String& name, bool value)
+{
+ setValue(name, JSONBasicValue::create(value));
+}
+
+void JSONObjectBase::setNumber(const String& name, double value)
+{
+ setValue(name, JSONBasicValue::create(value));
+}
+
+void JSONObjectBase::setString(const String& name, const String& value)
+{
+ setValue(name, JSONString::create(value));
+}
+
+void JSONObjectBase::setValue(const String& name, PassRefPtr<JSONValue> value)
+{
+ ASSERT(value);
+ if (m_data.set(name, value).isNewEntry)
+ m_order.append(name);
+}
+
+void JSONObjectBase::setObject(const String& name, PassRefPtr<JSONObject> value)
+{
+ ASSERT(value);
+ if (m_data.set(name, value).isNewEntry)
+ m_order.append(name);
+}
+
+void JSONObjectBase::setArray(const String& name, PassRefPtr<JSONArray> value)
+{
+ ASSERT(value);
+ if (m_data.set(name, value).isNewEntry)
+ m_order.append(name);
+}
+
JSONObject* JSONObjectBase::openAccessors()
{
COMPILE_ASSERT(sizeof(JSONObject) == sizeof(JSONObjectBase), cannot_cast);
return static_cast<JSONObject*>(this);
}
+JSONObjectBase::iterator JSONObjectBase::find(const String& name)
+{
+ return m_data.find(name);
+}
+
+JSONObjectBase::const_iterator JSONObjectBase::find(const String& name) const
+{
+ return m_data.find(name);
+}
+
bool JSONObjectBase::getBoolean(const String& name, bool* output) const
{
RefPtr<JSONValue> value = get(name);
@@ -377,6 +423,44 @@ JSONArrayBase::JSONArrayBase()
{
}
+void JSONArrayBase::pushBoolean(bool value)
+{
+ m_data.append(JSONBasicValue::create(value));
+}
+
+void JSONArrayBase::pushInt(int value)
+{
+ m_data.append(JSONBasicValue::create(value));
+}
+
+void JSONArrayBase::pushNumber(double value)
+{
+ m_data.append(JSONBasicValue::create(value));
+}
+
+void JSONArrayBase::pushString(const String& value)
+{
+ m_data.append(JSONString::create(value));
+}
+
+void JSONArrayBase::pushValue(PassRefPtr<JSONValue> value)
+{
+ ASSERT(value);
+ m_data.append(value);
+}
+
+void JSONArrayBase::pushObject(PassRefPtr<JSONObject> value)
+{
+ ASSERT(value);
+ m_data.append(value);
+}
+
+void JSONArrayBase::pushArray(PassRefPtr<JSONArray> value)
+{
+ ASSERT(value);
+ m_data.append(value);
+}
+
PassRefPtr<JSONValue> JSONArrayBase::get(size_t index)
{
ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size());
« no previous file with comments | « Source/platform/JSONValues.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698