summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/util.cc
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 15:05:27 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 15:05:27 +0000
commitfeba21e3dd6f25b0927817bdad749e47490e2798 (patch)
treeda16581c8c1658b385d6230423cc726df04cf4b7 /tools/json_schema_compiler/util.cc
parent7ae87817552c6e8608f62304354fd88cb921a31c (diff)
downloadchromium_src-feba21e3dd6f25b0927817bdad749e47490e2798.zip
chromium_src-feba21e3dd6f25b0927817bdad749e47490e2798.tar.gz
chromium_src-feba21e3dd6f25b0927817bdad749e47490e2798.tar.bz2
json_schema_compiler: any, additionalProperties, functions on types
Add support and tests for more json types. Also fixed a number of API jsons. BUG= TEST= Review URL: http://codereview.chromium.org/9491002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/util.cc')
-rw-r--r--tools/json_schema_compiler/util.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/json_schema_compiler/util.cc b/tools/json_schema_compiler/util.cc
index 468df83..9d8abd5 100644
--- a/tools/json_schema_compiler/util.cc
+++ b/tools/json_schema_compiler/util.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "tools/json_schema_compiler/any.h"
#include "tools/json_schema_compiler/util.h"
#include "base/values.h"
@@ -26,11 +27,21 @@ bool GetItemFromList(const ListValue& from, int index, std::string* out) {
}
bool GetItemFromList(const ListValue& from, int index,
+ linked_ptr<any::Any>* out) {
+ Value* value = NULL;
+ if (!from.Get(index, &value))
+ return false;
+ scoped_ptr<any::Any> any_object(new any::Any());
+ any_object->Init(*value);
+ *out = linked_ptr<any::Any>(any_object.release());
+ return true;
+}
+
+bool GetItemFromList(const ListValue& from, int index,
linked_ptr<base::DictionaryValue>* out) {
DictionaryValue* dict = NULL;
- if (!from.GetDictionary(index, &dict)) {
+ if (!from.GetDictionary(index, &dict))
return false;
- }
*out = linked_ptr<DictionaryValue>(dict->DeepCopy());
return true;
}
@@ -51,6 +62,10 @@ void AddItemToList(const linked_ptr<base::DictionaryValue>& from,
base::ListValue* out) {
out->Append(static_cast<Value*>(from->DeepCopy()));
}
+void AddItemToList(const linked_ptr<any::Any>& from,
+ base::ListValue* out) {
+ out->Append(from->value().DeepCopy());
+}
} // namespace api_util
} // namespace extensions