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

Side by Side Diff: generated_files_will_not_submit/array.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 unified diff | Download patch
« no previous file with comments | « generated_files_will_not_submit/array.h ('k') | generated_files_will_not_submit/choices.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // tools/json_schema_compiler/test/array.json
7 // DO NOT EDIT.
8
9 #include "tools/json_schema_compiler/util.h"
10 #include "tools/json_schema_compiler/test/array.h"
11
12 using base::Value;
13 using base::DictionaryValue;
14 using base::ListValue;
15
16 namespace test {
17 namespace api {
18 namespace array {
19
20 //
21 // Types
22 //
23
24 Item::Item() {}
25 Item::~Item() {}
26
27 // static
28 bool Item::Populate(const Value& value, Item* out) {
29 if (!value.IsType(Value::TYPE_DICTIONARY))
30 return false;
31 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
32
33 Value* val_value = NULL;
34 if (!dict->GetWithoutPathExpansion("val", &val_value))
35 return false;
36 {
37 if (!val_value->IsType(Value::TYPE_INTEGER))
38 return false;
39 if (!val_value->GetAsInteger(&out->val))
40 return false;
41 }
42
43 return true;
44 }
45
46 scoped_ptr<DictionaryValue> Item::ToValue() const {
47 scoped_ptr<DictionaryValue> value(new DictionaryValue());
48
49 value->SetWithoutPathExpansion("val", Value::CreateIntegerValue(val));
50
51 return value.Pass();
52 }
53
54
55 BasicArrayType::BasicArrayType() {}
56 BasicArrayType::~BasicArrayType() {}
57
58 // static
59 bool BasicArrayType::Populate(const Value& value, BasicArrayType* out) {
60 if (!value.IsType(Value::TYPE_DICTIONARY))
61 return false;
62 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
63
64 Value* integers_value = NULL;
65 if (!dict->GetWithoutPathExpansion("integers", &integers_value))
66 return false;
67 {
68 if (!integers_value->IsType(Value::TYPE_LIST))
69 return false;
70 ListValue* list = NULL;
71 if (!integers_value->GetAsList(&list))
72 return false;
73 if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->integers ))
74 return false;
75 }
76
77 Value* booleans_value = NULL;
78 if (!dict->GetWithoutPathExpansion("booleans", &booleans_value))
79 return false;
80 {
81 if (!booleans_value->IsType(Value::TYPE_LIST))
82 return false;
83 ListValue* list = NULL;
84 if (!booleans_value->GetAsList(&list))
85 return false;
86 if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->booleans ))
87 return false;
88 }
89
90 Value* numbers_value = NULL;
91 if (!dict->GetWithoutPathExpansion("numbers", &numbers_value))
92 return false;
93 {
94 if (!numbers_value->IsType(Value::TYPE_LIST))
95 return false;
96 ListValue* list = NULL;
97 if (!numbers_value->GetAsList(&list))
98 return false;
99 if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->numbers) )
100 return false;
101 }
102
103 Value* strings_value = NULL;
104 if (!dict->GetWithoutPathExpansion("strings", &strings_value))
105 return false;
106 {
107 if (!strings_value->IsType(Value::TYPE_LIST))
108 return false;
109 ListValue* list = NULL;
110 if (!strings_value->GetAsList(&list))
111 return false;
112 if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->strings) )
113 return false;
114 }
115
116 return true;
117 }
118
119 scoped_ptr<DictionaryValue> BasicArrayType::ToValue() const {
120 scoped_ptr<DictionaryValue> value(new DictionaryValue());
121
122 json_schema_compiler::util::PopulateDictionaryFromArray(integers, "integers", value.get());
123 json_schema_compiler::util::PopulateDictionaryFromArray(booleans, "booleans", value.get());
124 json_schema_compiler::util::PopulateDictionaryFromArray(numbers, "numbers", va lue.get());
125 json_schema_compiler::util::PopulateDictionaryFromArray(strings, "strings", va lue.get());
126
127 return value.Pass();
128 }
129
130
131 RefArrayType::RefArrayType() {}
132 RefArrayType::~RefArrayType() {}
133
134 // static
135 bool RefArrayType::Populate(const Value& value, RefArrayType* out) {
136 if (!value.IsType(Value::TYPE_DICTIONARY))
137 return false;
138 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
139
140 Value* refs_value = NULL;
141 if (!dict->GetWithoutPathExpansion("refs", &refs_value))
142 return false;
143 {
144 if (!refs_value->IsType(Value::TYPE_LIST))
145 return false;
146 ListValue* list = NULL;
147 if (!refs_value->GetAsList(&list))
148 return false;
149 if (!json_schema_compiler::util::PopulateArrayFromList(*list, &out->refs))
150 return false;
151 }
152
153 return true;
154 }
155
156 scoped_ptr<DictionaryValue> RefArrayType::ToValue() const {
157 scoped_ptr<DictionaryValue> value(new DictionaryValue());
158
159 json_schema_compiler::util::PopulateDictionaryFromArray(refs, "refs", value.ge t());
160
161 return value.Pass();
162 }
163
164
165 //
166 // Functions
167 //
168
169 IntegerArray::Params::Params() {}
170 IntegerArray::Params::~Params() {}
171
172 // static
173 scoped_ptr<IntegerArray::Params> IntegerArray::Params::Create(const ListValue& a rgs) {
174 if (args.GetSize() != 1)
175 return scoped_ptr<Params>();
176 scoped_ptr<Params> params(new Params());
177
178 Value* nums_value = NULL;
179 if (!args.Get(0, &nums_value) || nums_value->IsType(Value::TYPE_NULL))
180 return scoped_ptr<Params>();
181 {
182 if (!nums_value->IsType(Value::TYPE_LIST))
183 return scoped_ptr<Params>();
184 ListValue* list = NULL;
185 if (!nums_value->GetAsList(&list))
186 return scoped_ptr<Params>();
187 if (!json_schema_compiler::util::PopulateArrayFromList(*list, &params->nums) )
188 return scoped_ptr<Params>();
189 }
190
191 return params.Pass();
192 }
193
194
195 Value* IntegerArray::Result::Create() {
196 return Value::CreateNullValue();
197 }
198
199 } // array
200 } // api
201 } // test
OLDNEW
« no previous file with comments | « generated_files_will_not_submit/array.h ('k') | generated_files_will_not_submit/choices.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698