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

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