OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from model import PropertyType | 5 from model import PropertyType |
6 import code | 6 import code |
7 import cpp_util | 7 import cpp_util |
8 import model | 8 import model |
9 import os | 9 import os |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 # additionalProperties. | 153 # additionalProperties. |
154 if type_.properties: | 154 if type_.properties: |
155 raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) + | 155 raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) + |
156 '\nCannot generate both functions and properties on a type') | 156 '\nCannot generate both functions and properties on a type') |
157 c.Sblock('namespace %(classname)s {') | 157 c.Sblock('namespace %(classname)s {') |
158 for function in type_.functions.values(): | 158 for function in type_.functions.values(): |
159 (c.Concat(self._GenerateFunction(function)) | 159 (c.Concat(self._GenerateFunction(function)) |
160 .Append() | 160 .Append() |
161 ) | 161 ) |
162 c.Eblock('}') | 162 c.Eblock('}') |
| 163 elif type_.type_ == PropertyType.ARRAY: |
| 164 if type_.description: |
| 165 c.Comment(type_.description) |
| 166 c.Append('typedef std::vector<%(item_type)s> %(classname)s;') |
| 167 c.Substitute({'classname': classname, 'item_type': |
| 168 self._cpp_type_generator.GetType(type_.item_type, |
| 169 wrap_optional=True)}) |
163 else: | 170 else: |
164 if type_.description: | 171 if type_.description: |
165 c.Comment(type_.description) | 172 c.Comment(type_.description) |
166 (c.Sblock('struct %(classname)s {') | 173 (c.Sblock('struct %(classname)s {') |
167 .Append('~%(classname)s();') | 174 .Append('~%(classname)s();') |
168 .Append('%(classname)s();') | 175 .Append('%(classname)s();') |
169 .Append() | 176 .Append() |
170 .Concat(self._GeneratePropertyStructures(type_.properties.values())) | 177 .Concat(self._GeneratePropertyStructures(type_.properties.values())) |
171 .Concat(self._GenerateFields(type_.properties.values())) | 178 .Concat(self._GenerateFields(type_.properties.values())) |
172 ) | 179 ) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 c.Comment(param.description) | 284 c.Comment(param.description) |
278 if param.type_ == PropertyType.ANY: | 285 if param.type_ == PropertyType.ANY: |
279 c.Comment("Value* Result::Create(Value*) not generated " | 286 c.Comment("Value* Result::Create(Value*) not generated " |
280 "because it's redundant.") | 287 "because it's redundant.") |
281 continue | 288 continue |
282 c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration( | 289 c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration( |
283 param, self._cpp_type_generator.GetType(param))) | 290 param, self._cpp_type_generator.GetType(param))) |
284 c.Eblock('};') | 291 c.Eblock('};') |
285 | 292 |
286 return c | 293 return c |
OLD | NEW |