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

Unified Diff: generated_files_will_not_submit/array.cc

Issue 9309044: Supporting more APIs with json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rework, add a couple of tests 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 | « generated_files_will_not_submit/array.h ('k') | generated_files_will_not_submit/choices.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: generated_files_will_not_submit/array.cc
diff --git a/generated_files_will_not_submit/array.cc b/generated_files_will_not_submit/array.cc
new file mode 100644
index 0000000000000000000000000000000000000000..87b6a0cf1c5716ca78ed0dab11e59fb7b32a9432
--- /dev/null
+++ b/generated_files_will_not_submit/array.cc
@@ -0,0 +1,201 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// GENERATED FROM THE API DEFINITION IN
+// tools/json_schema_compiler/test/array.json
+// DO NOT EDIT.
+
+#include "tools/json_schema_compiler/util.h"
+#include "tools/json_schema_compiler/test/array.h"
+
+using base::Value;
+using base::DictionaryValue;
+using base::ListValue;
+
+namespace test {
+namespace api {
+namespace array {
+
+//
+// Types
+//
+
+Item::Item() {}
+Item::~Item() {}
+
+// static
+bool Item::Populate(const Value& value, Item* out) {
+ if (!value.IsType(Value::TYPE_DICTIONARY))
+ return false;
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
+
+ Value* val_value = NULL;
+ if (!dict->GetWithoutPathExpansion("val", &val_value))
+ return false;
+ {
+ if (!val_value->IsType(Value::TYPE_INTEGER))
+ return false;
+ if (!val_value->GetAsInteger(&out->val))
+ return false;
+ }
+
+ return true;
+}
+
+scoped_ptr<DictionaryValue> Item::ToValue() const {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+
+ value->SetWithoutPathExpansion("val", Value::CreateIntegerValue(val));
+
+ return value.Pass();
+}
+
+
+BasicArrayType::BasicArrayType() {}
+BasicArrayType::~BasicArrayType() {}
+
+// static
+bool BasicArrayType::Populate(const Value& value, BasicArrayType* out) {
+ if (!value.IsType(Value::TYPE_DICTIONARY))
+ return false;
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
+
+ Value* integers_value = NULL;
+ if (!dict->GetWithoutPathExpansion("integers", &integers_value))
+ return false;
+ {
+ if (!integers_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!integers_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->integers))
+ return false;
+ }
+
+ Value* booleans_value = NULL;
+ if (!dict->GetWithoutPathExpansion("booleans", &booleans_value))
+ return false;
+ {
+ if (!booleans_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!booleans_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->booleans))
+ return false;
+ }
+
+ Value* numbers_value = NULL;
+ if (!dict->GetWithoutPathExpansion("numbers", &numbers_value))
+ return false;
+ {
+ if (!numbers_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!numbers_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->numbers))
+ return false;
+ }
+
+ Value* strings_value = NULL;
+ if (!dict->GetWithoutPathExpansion("strings", &strings_value))
+ return false;
+ {
+ if (!strings_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!strings_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->strings))
+ return false;
+ }
+
+ return true;
+}
+
+scoped_ptr<DictionaryValue> BasicArrayType::ToValue() const {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+
+ json_schema_compiler::util::PopulateDictionaryFromArray(integers, "integers", value.get());
+ json_schema_compiler::util::PopulateDictionaryFromArray(booleans, "booleans", value.get());
+ json_schema_compiler::util::PopulateDictionaryFromArray(numbers, "numbers", value.get());
+ json_schema_compiler::util::PopulateDictionaryFromArray(strings, "strings", value.get());
+
+ return value.Pass();
+}
+
+
+RefArrayType::RefArrayType() {}
+RefArrayType::~RefArrayType() {}
+
+// static
+bool RefArrayType::Populate(const Value& value, RefArrayType* out) {
+ if (!value.IsType(Value::TYPE_DICTIONARY))
+ return false;
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
+
+ Value* refs_value = NULL;
+ if (!dict->GetWithoutPathExpansion("refs", &refs_value))
+ return false;
+ {
+ if (!refs_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!refs_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->refs))
+ return false;
+ }
+
+ return true;
+}
+
+scoped_ptr<DictionaryValue> RefArrayType::ToValue() const {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+
+ json_schema_compiler::util::PopulateDictionaryFromArray(refs, "refs", value.get());
+
+ return value.Pass();
+}
+
+
+//
+// Functions
+//
+
+IntegerArray::Params::Params() {}
+IntegerArray::Params::~Params() {}
+
+// static
+scoped_ptr<IntegerArray::Params> IntegerArray::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* nums_value = NULL;
+ if (!args.Get(0, &nums_value) || nums_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!nums_value->IsType(Value::TYPE_LIST))
+ return scoped_ptr<Params>();
+ ListValue* list = NULL;
+ if (!nums_value->GetAsList(&list))
+ return scoped_ptr<Params>();
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &params->nums))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* IntegerArray::Result::Create() {
+ return Value::CreateNullValue();
+}
+
+} // array
+} // api
+} // test
« no previous file with comments | « generated_files_will_not_submit/array.h ('k') | generated_files_will_not_submit/choices.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698