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

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: a few comments, fixes 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 int priority_temp;
30 if(dict->GetInteger("priority", &priority_temp))
31 out->priority.reset(new int(priority_temp));
32 if(!json_schema_compiler::util::GetArrayFromDictionary(*dict, "conditions", &o ut->conditions))
33 return false;
34 std::string id_temp;
35 if(dict->GetString("id", &id_temp))
36 out->id.reset(new std::string(id_temp));
37 if(!json_schema_compiler::util::GetArrayFromDictionary(*dict, "actions", &out- >actions))
38 return false;
39 return true;
40 }
41
42 DictionaryValue* Rule::ToValue() const {
43 DictionaryValue* value = new DictionaryValue();
44
45 if(priority.get())
46 value->SetWithoutPathExpansion("priority", Value::CreateIntegerValue(*priori ty));
47 json_schema_compiler::util::SetArrayToDictionary(conditions, "conditions", val ue);
48 if(id.get())
49 value->SetWithoutPathExpansion("id", Value::CreateStringValue(*id));
50 json_schema_compiler::util::SetArrayToDictionary(actions, "actions", value);
51
52 return value;
53 }
54
55
56 //
57 // Functions
58 //
59
60 GetRules::Params::Params() {}
61 GetRules::Params::~Params() {}
62
63 // static
64 scoped_ptr<GetRules::Params> GetRules::Params::Create(const ListValue& args) {
65
66 scoped_ptr<Params> params(new Params());
67
68 if(!args.GetString(0, &params->event))
69 return scoped_ptr<Params>();
70
71 ListValue* rule_identifiers_param = NULL;
72 if (!args.GetList(1, &rule_identifiers_param))
73 return scoped_ptr<Params>();
74 if (!json_schema_compiler::util::GetArrayFromList(*rule_identifiers_param, &pa rams->rule_identifiers))
75 return scoped_ptr<Params>();
76
77 return params.Pass();
78 }
79
80 // static
81 // Rules that were registered, the optional parameters are filled with values.
82 Value* GetRules::Result::Create(const std::vector<linked_ptr<Rule> > rules) {
83 ListValue* value = new ListValue();
84 json_schema_compiler::util::SetArrayToList(rules, value);
85 return value;
86 }
87
88 RemoveRules::Params::Params() {}
89 RemoveRules::Params::~Params() {}
90
91 // static
92 scoped_ptr<RemoveRules::Params> RemoveRules::Params::Create(const ListValue& arg s) {
93
94 scoped_ptr<Params> params(new Params());
95
96 if(!args.GetString(0, &params->event))
97 return scoped_ptr<Params>();
98
99 ListValue* rule_identifiers_param = NULL;
100 if (!args.GetList(1, &rule_identifiers_param))
101 return scoped_ptr<Params>();
102 if (!json_schema_compiler::util::GetArrayFromList(*rule_identifiers_param, &pa rams->rule_identifiers))
103 return scoped_ptr<Params>();
104
105 return params.Pass();
106 }
107
108 // static
109 Value* RemoveRules::Result::Create() {
110 return Value::CreateNullValue();
111 }
112
113 AddRules::Params::Params() {}
114 AddRules::Params::~Params() {}
115
116 // static
117 scoped_ptr<AddRules::Params> AddRules::Params::Create(const ListValue& args) {
118
119 scoped_ptr<Params> params(new Params());
120
121 if(!args.GetString(0, &params->event))
122 return scoped_ptr<Params>();
123
124 ListValue* rules_param = NULL;
125 if (!args.GetList(1, &rules_param))
126 return scoped_ptr<Params>();
127 if (!json_schema_compiler::util::GetArrayFromList(*rules_param, &params->rules ))
128 return scoped_ptr<Params>();
129
130 return params.Pass();
131 }
132
133 // static
134 // Rules that were registered, the optional parameters are filled with values.
135 Value* AddRules::Result::Create(const std::vector<linked_ptr<Rule> > rules) {
136 ListValue* value = new ListValue();
137 json_schema_compiler::util::SetArrayToList(rules, value);
138 return value;
139 }
140
141 } // experimental_declarative
142 } // api
143 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698