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

Side by Side 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 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // GENERATED FROM THE API DEFINITION IN
6 // chrome/common/extensions/api/experimental.declarative.json
7 // DO NOT EDIT.
8
9 #include "tools/json_schema_compiler/util.h"
10 #include "chrome/common/extensions/api/experimental.declarative.h"
11
12 namespace extensions {
13 namespace api {
14 namespace experimental_declarative {
15
16 //
17 // Types
18 //
19
20 Rule::Rule() {}
21 Rule::~Rule() {}
22
23 // static
24 bool Rule::Populate(const Value& value, Rule* out) {
25 if (!value.IsType(Value::TYPE_DICTIONARY))
26 return false;
27 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
28
29 {
30 int priority_temp;
31 if (dict->GetInteger("priority", &priority_temp))
32 out->priority.reset(new int(priority_temp));
33 }
34 if (!json_schema_compiler::util::GetArrayFromDictionary(*dict, "conditions", & out->conditions))
35 return false;
36 {
37 std::string id_temp;
38 if (dict->GetString("id", &id_temp))
39 out->id.reset(new std::string(id_temp));
40 }
41 if (!json_schema_compiler::util::GetArrayFromDictionary(*dict, "actions", &out ->actions))
42 return false;
43 return true;
44 }
45
46 DictionaryValue* Rule::ToValue() const {
47 DictionaryValue* value = new DictionaryValue();
48
49 if (priority.get())
50 value->SetWithoutPathExpansion("priority", Value::CreateIntegerValue(*priori ty));
51 json_schema_compiler::util::SetArrayToDictionary(conditions, "conditions", val ue);
52 if (id.get())
53 value->SetWithoutPathExpansion("id", Value::CreateStringValue(*id));
54 json_schema_compiler::util::SetArrayToDictionary(actions, "actions", value);
55
56 return value;
57 }
58
59
60 //
61 // Functions
62 //
63
64 GetRules::Params::Params() {}
65 GetRules::Params::~Params() {}
66
67 // static
68 scoped_ptr<GetRules::Params> GetRules::Params::Create(const ListValue& args) {
69 scoped_ptr<Params> params(new Params());
70
71 if (!args.GetString(0, &params->event))
72 return scoped_ptr<Params>();
73
74 ListValue* rule_identifiers_param = NULL;
75 if (!args.GetList(1, &rule_identifiers_param))
76 return scoped_ptr<Params>();
77 if (!json_schema_compiler::util::GetArrayFromList(*rule_identifiers_param, &pa rams->rule_identifiers))
78 return scoped_ptr<Params>();
79
80 return params.Pass();
81 }
82
83 // static
84 // Rules that were registered, the optional parameters are filled with values.
85 Value* GetRules::Result::Create(const std::vector<linked_ptr<Rule> > rules) {
86 ListValue* value = new ListValue();
87 json_schema_compiler::util::SetArrayToList(rules, value);
88 return value;
89 }
90
91 RemoveRules::Params::Params() {}
92 RemoveRules::Params::~Params() {}
93
94 // static
95 scoped_ptr<RemoveRules::Params> RemoveRules::Params::Create(const ListValue& arg s) {
96 scoped_ptr<Params> params(new Params());
97
98 if (!args.GetString(0, &params->event))
99 return scoped_ptr<Params>();
100
101 ListValue* rule_identifiers_param = NULL;
102 if (!args.GetList(1, &rule_identifiers_param))
103 return scoped_ptr<Params>();
104 if (!json_schema_compiler::util::GetArrayFromList(*rule_identifiers_param, &pa rams->rule_identifiers))
105 return scoped_ptr<Params>();
106
107 return params.Pass();
108 }
109
110 // static
111 Value* RemoveRules::Result::Create() {
112 return Value::CreateNullValue();
113 }
114
115 AddRules::Params::Params() {}
116 AddRules::Params::~Params() {}
117
118 // static
119 scoped_ptr<AddRules::Params> AddRules::Params::Create(const ListValue& args) {
120 scoped_ptr<Params> params(new Params());
121
122 if (!args.GetString(0, &params->event))
123 return scoped_ptr<Params>();
124
125 ListValue* rules_param = NULL;
126 if (!args.GetList(1, &rules_param))
127 return scoped_ptr<Params>();
128 if (!json_schema_compiler::util::GetArrayFromList(*rules_param, &params->rules ))
129 return scoped_ptr<Params>();
130
131 return params.Pass();
132 }
133
134 // static
135 // Rules that were registered, the optional parameters are filled with values.
136 Value* AddRules::Result::Create(const std::vector<linked_ptr<Rule> > rules) {
137 ListValue* value = new ListValue();
138 json_schema_compiler::util::SetArrayToList(rules, value);
139 return value;
140 }
141
142 } // experimental_declarative
143 } // api
144 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698