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

Unified Diff: generated_files_will_not_submit/choices.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/choices.h ('k') | generated_files_will_not_submit/crossref.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: generated_files_will_not_submit/choices.cc
diff --git a/generated_files_will_not_submit/choices.cc b/generated_files_will_not_submit/choices.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c04a0e9762e1ba41f52ec4a63c45886aed6deaba
--- /dev/null
+++ b/generated_files_will_not_submit/choices.cc
@@ -0,0 +1,229 @@
+// 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/choices.json
+// DO NOT EDIT.
+
+#include "tools/json_schema_compiler/util.h"
+#include "tools/json_schema_compiler/test/choices.h"
+
+using base::Value;
+using base::DictionaryValue;
+using base::ListValue;
+
+namespace test {
+namespace api {
+namespace choices {
+
+//
+// Functions
+//
+
+TakesIntegersOptional::Params::Params() {}
+TakesIntegersOptional::Params::~Params() {}
+
+// static
+scoped_ptr<TakesIntegersOptional::Params> TakesIntegersOptional::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 params.Pass();
+ params->nums_type = NUMS_NONE;
+ switch (nums_value->GetType()) {
+ case Value::TYPE_LIST: {
+ {
+ ListValue* list = NULL;
+ if (!nums_value->GetAsList(&list))
+ return scoped_ptr<Params>();
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &params->nums_array))
+ return scoped_ptr<Params>();
+ }
+ params->nums_type = NUMS_ARRAY;
+ break;
+ }
+ case Value::TYPE_INTEGER: {
+ {
+ int temp;
+ if (nums_value->GetAsInteger(&temp))
+ params->nums_integer.reset(new int(temp));
+ }
+ params->nums_type = NUMS_INTEGER;
+ break;
+ }
+ default:
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* TakesIntegersOptional::Result::Create() {
+ return Value::CreateNullValue();
+}
+
+Value* ReturnChoices::Result::Create(const std::vector<int>& result_array) {
+ ListValue* value = new ListValue();
+ json_schema_compiler::util::PopulateListFromArray(result_array, value);
+ return value;
+}
+Value* ReturnChoices::Result::Create(const int result_integer) {
+ return Value::CreateIntegerValue(result_integer);
+}
+
+TakesIntegers::Params::Params() {}
+TakesIntegers::Params::~Params() {}
+
+// static
+scoped_ptr<TakesIntegers::Params> TakesIntegers::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>();
+ params->nums_type = NUMS_NONE;
+ switch (nums_value->GetType()) {
+ case Value::TYPE_LIST: {
+ {
+ ListValue* list = NULL;
+ if (!nums_value->GetAsList(&list))
+ return scoped_ptr<Params>();
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &params->nums_array))
+ return scoped_ptr<Params>();
+ }
+ params->nums_type = NUMS_ARRAY;
+ break;
+ }
+ case Value::TYPE_INTEGER: {
+ {
+ int temp;
+ if (nums_value->GetAsInteger(&temp))
+ params->nums_integer.reset(new int(temp));
+ }
+ params->nums_type = NUMS_INTEGER;
+ break;
+ }
+ default:
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* TakesIntegers::Result::Create() {
+ return Value::CreateNullValue();
+}
+
+ObjectWithChoices::Params::StringInfo::StringInfo() {}
+ObjectWithChoices::Params::StringInfo::~StringInfo() {}
+
+// static
+bool ObjectWithChoices::Params::StringInfo::Populate(const Value& value, StringInfo* 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)) {
+ out->integers_type = INTEGERS_NONE;
+ switch (integers_value->GetType()) {
+ case Value::TYPE_LIST: {
+ {
+ ListValue* list = NULL;
+ if (!integers_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out->integers_array))
+ return false;
+ }
+ out->integers_type = INTEGERS_ARRAY;
+ break;
+ }
+ case Value::TYPE_INTEGER: {
+ {
+ int temp;
+ if (integers_value->GetAsInteger(&temp))
+ out->integers_integer.reset(new int(temp));
+ }
+ out->integers_type = INTEGERS_INTEGER;
+ break;
+ }
+ default:
+ return false;
+ }
+ }
+
+ Value* strings_value = NULL;
+ if (!dict->GetWithoutPathExpansion("strings", &strings_value))
+ return false;
+ out->strings_type = STRINGS_NONE;
+ switch (strings_value->GetType()) {
+ case Value::TYPE_LIST: {
+ {
+ ListValue* list = NULL;
+ if (!strings_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out->strings_array))
+ return false;
+ }
+ out->strings_type = STRINGS_ARRAY;
+ break;
+ }
+ case Value::TYPE_STRING: {
+ {
+ std::string temp;
+ if (strings_value->GetAsString(&temp))
+ out->strings_string.reset(new std::string(temp));
+ }
+ out->strings_type = STRINGS_STRING;
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+
+
+ObjectWithChoices::Params::Params() {}
+ObjectWithChoices::Params::~Params() {}
+
+// static
+scoped_ptr<ObjectWithChoices::Params> ObjectWithChoices::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* string_info_value = NULL;
+ if (!args.Get(0, &string_info_value) || string_info_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!string_info_value->IsType(Value::TYPE_DICTIONARY))
+ return scoped_ptr<Params>();
+ DictionaryValue* dictionary = NULL;
+ if (!string_info_value->GetAsDictionary(&dictionary))
+ return scoped_ptr<Params>();
+ if (!StringInfo::Populate(*dictionary, &params->string_info))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* ObjectWithChoices::Result::Create() {
+ return Value::CreateNullValue();
+}
+
+} // choices
+} // api
+} // test
« no previous file with comments | « generated_files_will_not_submit/choices.h ('k') | generated_files_will_not_submit/crossref.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698