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

Unified Diff: generated_files_will_not_submit/experimental.declarative.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
Index: generated_files_will_not_submit/experimental.declarative.cc
diff --git a/generated_files_will_not_submit/experimental.declarative.cc b/generated_files_will_not_submit/experimental.declarative.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c471d81ee9a330b171f50401602e5887bac24e1
--- /dev/null
+++ b/generated_files_will_not_submit/experimental.declarative.cc
@@ -0,0 +1,228 @@
+// 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
+// chrome/common/extensions/api/experimental.declarative.json
+// DO NOT EDIT.
+
+#include "tools/json_schema_compiler/util.h"
+#include "chrome/common/extensions/api/experimental.declarative.h"
+
+using base::Value;
+using base::DictionaryValue;
+using base::ListValue;
+
+namespace extensions {
+namespace api {
+namespace experimental {
+
+//
+// Types
+//
+
+Rule::Rule() {}
+Rule::~Rule() {}
+
+// static
+bool Rule::Populate(const Value& value, Rule* out) {
+ if (!value.IsType(Value::TYPE_DICTIONARY))
+ return false;
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
+
+ Value* priority_value = NULL;
+ if (dict->GetWithoutPathExpansion("priority", &priority_value)) {
+ {
+ if (!priority_value->IsType(Value::TYPE_INTEGER))
+ return false;
+ int temp;
+ if (priority_value->GetAsInteger(&temp))
+ out->priority.reset(new int(temp));
+ }
+ }
+
+ Value* conditions_value = NULL;
+ if (!dict->GetWithoutPathExpansion("conditions", &conditions_value))
+ return false;
+ {
+ if (!conditions_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!conditions_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->conditions))
+ return false;
+ }
+
+ Value* id_value = NULL;
+ if (dict->GetWithoutPathExpansion("id", &id_value)) {
+ {
+ if (!id_value->IsType(Value::TYPE_STRING))
+ return false;
+ std::string temp;
+ if (id_value->GetAsString(&temp))
+ out->id.reset(new std::string(temp));
+ }
+ }
+
+ Value* actions_value = NULL;
+ if (!dict->GetWithoutPathExpansion("actions", &actions_value))
+ return false;
+ {
+ if (!actions_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!actions_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->actions))
+ return false;
+ }
+
+ return true;
+}
+
+scoped_ptr<DictionaryValue> Rule::ToValue() const {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+
+ if (priority.get())
+ value->SetWithoutPathExpansion("priority", Value::CreateIntegerValue(*priority));
+ json_schema_compiler::util::PopulateDictionaryFromArray(conditions, "conditions", value.get());
+ if (id.get())
+ value->SetWithoutPathExpansion("id", Value::CreateStringValue(*id));
+ json_schema_compiler::util::PopulateDictionaryFromArray(actions, "actions", value.get());
+
+ return value.Pass();
+}
+
+
+//
+// Functions
+//
+
+GetRules::Params::Params() {}
+GetRules::Params::~Params() {}
+
+// static
+scoped_ptr<GetRules::Params> GetRules::Params::Create(const ListValue& args) {
+ if (args.GetSize() < 1 || args.GetSize() > 2)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* event_value = NULL;
+ if (!args.Get(0, &event_value) || event_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!event_value->IsType(Value::TYPE_STRING))
+ return scoped_ptr<Params>();
+ if (!event_value->GetAsString(&params->event))
+ return scoped_ptr<Params>();
+ }
+
+ Value* rule_identifiers_value = NULL;
+ if (!args.Get(1, &rule_identifiers_value) || rule_identifiers_value->IsType(Value::TYPE_NULL))
+ return params.Pass();
+ {
+ if (!rule_identifiers_value->IsType(Value::TYPE_LIST))
+ return scoped_ptr<Params>();
+ ListValue* list = NULL;
+ if (!rule_identifiers_value->GetAsList(&list))
+ return scoped_ptr<Params>();
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &params->rule_identifiers))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* GetRules::Result::Create(const std::vector<linked_ptr<Rule> >& rules) {
+ ListValue* value = new ListValue();
+ json_schema_compiler::util::PopulateListFromArray(rules, value);
+ return value;
+}
+
+RemoveRules::Params::Params() {}
+RemoveRules::Params::~Params() {}
+
+// static
+scoped_ptr<RemoveRules::Params> RemoveRules::Params::Create(const ListValue& args) {
+ if (args.GetSize() < 1 || args.GetSize() > 2)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* event_value = NULL;
+ if (!args.Get(0, &event_value) || event_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!event_value->IsType(Value::TYPE_STRING))
+ return scoped_ptr<Params>();
+ if (!event_value->GetAsString(&params->event))
+ return scoped_ptr<Params>();
+ }
+
+ Value* rule_identifiers_value = NULL;
+ if (!args.Get(1, &rule_identifiers_value) || rule_identifiers_value->IsType(Value::TYPE_NULL))
+ return params.Pass();
+ {
+ if (!rule_identifiers_value->IsType(Value::TYPE_LIST))
+ return scoped_ptr<Params>();
+ ListValue* list = NULL;
+ if (!rule_identifiers_value->GetAsList(&list))
+ return scoped_ptr<Params>();
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &params->rule_identifiers))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* RemoveRules::Result::Create() {
+ return Value::CreateNullValue();
+}
+
+AddRules::Params::Params() {}
+AddRules::Params::~Params() {}
+
+// static
+scoped_ptr<AddRules::Params> AddRules::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 2)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* event_value = NULL;
+ if (!args.Get(0, &event_value) || event_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!event_value->IsType(Value::TYPE_STRING))
+ return scoped_ptr<Params>();
+ if (!event_value->GetAsString(&params->event))
+ return scoped_ptr<Params>();
+ }
+
+ Value* rules_value = NULL;
+ if (!args.Get(1, &rules_value) || rules_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!rules_value->IsType(Value::TYPE_LIST))
+ return scoped_ptr<Params>();
+ ListValue* list = NULL;
+ if (!rules_value->GetAsList(&list))
+ return scoped_ptr<Params>();
+ if (!json_schema_compiler::util::PopulateArrayFromList(*list, &params->rules))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* AddRules::Result::Create(const std::vector<linked_ptr<Rule> >& rules) {
+ ListValue* value = new ListValue();
+ json_schema_compiler::util::PopulateListFromArray(rules, value);
+ return value;
+}
+
+} // experimental
+} // api
+} // extensions
« no previous file with comments | « generated_files_will_not_submit/experimental.declarative.h ('k') | generated_files_will_not_submit/permissions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698