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

Unified Diff: tools/json_schema_compiler/util.cc

Issue 9491002: json_schema_compiler: any, additionalProperties, functions on types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add any in arrays to util.h Created 8 years, 10 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 | « tools/json_schema_compiler/util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/util.cc
diff --git a/tools/json_schema_compiler/util.cc b/tools/json_schema_compiler/util.cc
index 468df83b297ab0407c3983e4cdf5eb109ef78fd2..9d8abd5cdab51e75e72ce5e9dc54089e8109d1fa 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
« no previous file with comments | « tools/json_schema_compiler/util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698