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 code import Code | 5 from code import Code |
6 from model import PropertyType | 6 from model import PropertyType |
7 import cpp_util | 7 import cpp_util |
8 import model | 8 import model |
9 import os | 9 import os |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 .Append() | 172 .Append() |
173 ) | 173 ) |
174 c.Eblock('}') | 174 c.Eblock('}') |
175 elif type_.type_ == PropertyType.ARRAY: | 175 elif type_.type_ == PropertyType.ARRAY: |
176 if type_.description: | 176 if type_.description: |
177 c.Comment(type_.description) | 177 c.Comment(type_.description) |
178 c.Append('typedef std::vector<%(item_type)s> %(classname)s;') | 178 c.Append('typedef std::vector<%(item_type)s> %(classname)s;') |
179 c.Substitute({'classname': classname, 'item_type': | 179 c.Substitute({'classname': classname, 'item_type': |
180 self._cpp_type_generator.GetType(type_.item_type, | 180 self._cpp_type_generator.GetType(type_.item_type, |
181 wrap_optional=True)}) | 181 wrap_optional=True)}) |
| 182 elif type_.type_ == PropertyType.STRING: |
| 183 if type_.description: |
| 184 c.Comment(type_.description) |
| 185 c.Append('typedef std::string %(classname)s;') |
| 186 c.Substitute({'classname': classname}) |
182 else: | 187 else: |
183 if type_.description: | 188 if type_.description: |
184 c.Comment(type_.description) | 189 c.Comment(type_.description) |
185 (c.Sblock('struct %(classname)s {') | 190 (c.Sblock('struct %(classname)s {') |
186 .Append('~%(classname)s();') | 191 .Append('~%(classname)s();') |
187 .Append('%(classname)s();') | 192 .Append('%(classname)s();') |
188 .Append() | 193 .Append() |
189 .Concat(self._GeneratePropertyStructures(type_.properties.values())) | 194 .Concat(self._GeneratePropertyStructures(type_.properties.values())) |
190 .Concat(self._GenerateFields(type_.properties.values())) | 195 .Concat(self._GenerateFields(type_.properties.values())) |
191 ) | 196 ) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 c.Comment(param.description) | 301 c.Comment(param.description) |
297 if param.type_ == PropertyType.ANY: | 302 if param.type_ == PropertyType.ANY: |
298 c.Comment("Value* Result::Create(Value*) not generated " | 303 c.Comment("Value* Result::Create(Value*) not generated " |
299 "because it's redundant.") | 304 "because it's redundant.") |
300 continue | 305 continue |
301 c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration( | 306 c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration( |
302 param, self._cpp_type_generator.GetType(param))) | 307 param, self._cpp_type_generator.GetType(param))) |
303 c.Eblock('};') | 308 c.Eblock('};') |
304 | 309 |
305 return c | 310 return c |
OLD | NEW |