| 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 import os | 5 import os |
| 6 | 6 |
| 7 from code import Code | 7 from code import Code |
| 8 from model import PropertyType | 8 from model import PropertyType |
| 9 import cpp_util | 9 import cpp_util |
| 10 import schema_util | 10 import schema_util |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 # Wrap functions within types in the type's namespace. | 188 # Wrap functions within types in the type's namespace. |
| 189 (c.Append('namespace %s {' % classname) | 189 (c.Append('namespace %s {' % classname) |
| 190 .Append() | 190 .Append() |
| 191 ) | 191 ) |
| 192 for function in type_.functions.values(): | 192 for function in type_.functions.values(): |
| 193 c.Cblock(self._GenerateFunction(function)) | 193 c.Cblock(self._GenerateFunction(function)) |
| 194 c.Append('} // namespace %s' % classname) | 194 c.Append('} // namespace %s' % classname) |
| 195 elif type_.property_type == PropertyType.ARRAY: | 195 elif type_.property_type == PropertyType.ARRAY: |
| 196 if generate_typedefs and type_.description: | 196 if generate_typedefs and type_.description: |
| 197 c.Comment(type_.description) | 197 c.Comment(type_.description) |
| 198 c.Cblock(self._GenerateType(type_.item_type)) | 198 c.Cblock(self._GenerateType(type_.item_type, is_toplevel=is_toplevel)) |
| 199 if generate_typedefs: | 199 if generate_typedefs: |
| 200 (c.Append('typedef std::vector<%s > %s;' % ( | 200 (c.Append('typedef std::vector<%s > %s;' % ( |
| 201 self._type_helper.GetCppType(type_.item_type), | 201 self._type_helper.GetCppType(type_.item_type), |
| 202 classname)) | 202 classname)) |
| 203 ) | 203 ) |
| 204 elif type_.property_type == PropertyType.STRING: | 204 elif type_.property_type == PropertyType.STRING: |
| 205 if generate_typedefs: | 205 if generate_typedefs: |
| 206 if type_.description: | 206 if type_.description: |
| 207 c.Comment(type_.description) | 207 c.Comment(type_.description) |
| 208 c.Append('typedef std::string %(classname)s;') | 208 c.Append('typedef std::string %(classname)s;') |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 """Builds the parameter list for a function, given an array of parameters. | 393 """Builds the parameter list for a function, given an array of parameters. |
| 394 """ | 394 """ |
| 395 # |error| is populated with warnings and/or errors found during parsing. | 395 # |error| is populated with warnings and/or errors found during parsing. |
| 396 # |error| being set does not necessarily imply failure and may be | 396 # |error| being set does not necessarily imply failure and may be |
| 397 # recoverable. | 397 # recoverable. |
| 398 # For example, optional properties may have failed to parse, but the | 398 # For example, optional properties may have failed to parse, but the |
| 399 # parser was able to continue. | 399 # parser was able to continue. |
| 400 if self._generate_error_messages: | 400 if self._generate_error_messages: |
| 401 params += ('base::string16* error',) | 401 params += ('base::string16* error',) |
| 402 return ', '.join(str(p) for p in params) | 402 return ', '.join(str(p) for p in params) |
| OLD | NEW |