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

Unified Diff: generated_files_will_not_submit/simple_api.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/simple_api.h ('k') | generated_files_will_not_submit/tabs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: generated_files_will_not_submit/simple_api.cc
diff --git a/generated_files_will_not_submit/simple_api.cc b/generated_files_will_not_submit/simple_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b7f35ea55b5a7046a4ce7c9aa59ed0c713b1ba43
--- /dev/null
+++ b/generated_files_will_not_submit/simple_api.cc
@@ -0,0 +1,157 @@
+// 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/simple_api.json
+// DO NOT EDIT.
+
+#include "tools/json_schema_compiler/util.h"
+#include "tools/json_schema_compiler/test/simple_api.h"
+
+using base::Value;
+using base::DictionaryValue;
+using base::ListValue;
+
+namespace test {
+namespace api {
+namespace simple_api {
+
+//
+// Types
+//
+
+TestType::TestType() {}
+TestType::~TestType() {}
+
+// static
+bool TestType::Populate(const Value& value, TestType* out) {
+ if (!value.IsType(Value::TYPE_DICTIONARY))
+ return false;
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
+
+ Value* integer_value = NULL;
+ if (!dict->GetWithoutPathExpansion("integer", &integer_value))
+ return false;
+ {
+ if (!integer_value->IsType(Value::TYPE_INTEGER))
+ return false;
+ if (!integer_value->GetAsInteger(&out->integer))
+ return false;
+ }
+
+ Value* boolean_value = NULL;
+ if (!dict->GetWithoutPathExpansion("boolean", &boolean_value))
+ return false;
+ {
+ if (!boolean_value->IsType(Value::TYPE_BOOLEAN))
+ return false;
+ if (!boolean_value->GetAsBoolean(&out->boolean))
+ return false;
+ }
+
+ Value* string_value = NULL;
+ if (!dict->GetWithoutPathExpansion("string", &string_value))
+ return false;
+ {
+ if (!string_value->IsType(Value::TYPE_STRING))
+ return false;
+ if (!string_value->GetAsString(&out->string))
+ return false;
+ }
+
+ Value* number_value = NULL;
+ if (!dict->GetWithoutPathExpansion("number", &number_value))
+ return false;
+ {
+ if (!number_value->IsType(Value::TYPE_DOUBLE))
+ return false;
+ if (!number_value->GetAsDouble(&out->number))
+ return false;
+ }
+
+ return true;
+}
+
+scoped_ptr<DictionaryValue> TestType::ToValue() const {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+
+ value->SetWithoutPathExpansion("integer", Value::CreateIntegerValue(integer));
+ value->SetWithoutPathExpansion("boolean", Value::CreateBooleanValue(boolean));
+ value->SetWithoutPathExpansion("string", Value::CreateStringValue(string));
+ value->SetWithoutPathExpansion("number", Value::CreateDoubleValue(number));
+
+ return value.Pass();
+}
+
+
+//
+// Functions
+//
+
+OptionalString::Params::Params() {}
+OptionalString::Params::~Params() {}
+
+// static
+scoped_ptr<OptionalString::Params> OptionalString::Params::Create(const ListValue& args) {
+ if (args.GetSize() > 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* str_value = NULL;
+ if (!args.Get(0, &str_value) || str_value->IsType(Value::TYPE_NULL))
+ return params.Pass();
+ {
+ if (!str_value->IsType(Value::TYPE_STRING))
+ return scoped_ptr<Params>();
+ std::string temp;
+ if (str_value->GetAsString(&temp))
+ params->str.reset(new std::string(temp));
+ }
+
+ return params.Pass();
+}
+
+
+Value* OptionalString::Result::Create() {
+ return Value::CreateNullValue();
+}
+
+Value* GetTestType::Result::Create(const TestType& result) {
+ return result.ToValue().release();
+}
+
+Value* OptionalCallbackParams::Result::Create(const TestType& result) {
+ return result.ToValue().release();
+}
+
+IncrementInteger::Params::Params() {}
+IncrementInteger::Params::~Params() {}
+
+// static
+scoped_ptr<IncrementInteger::Params> IncrementInteger::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* num_value = NULL;
+ if (!args.Get(0, &num_value) || num_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!num_value->IsType(Value::TYPE_INTEGER))
+ return scoped_ptr<Params>();
+ if (!num_value->GetAsInteger(&params->num))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* IncrementInteger::Result::Create(const int result) {
+ return Value::CreateIntegerValue(result);
+}
+
+} // simple_api
+} // api
+} // test
« no previous file with comments | « generated_files_will_not_submit/simple_api.h ('k') | generated_files_will_not_submit/tabs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698