| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 .Cblock(self._GenerateTypes(p.type_ for p in properties)) | 268 .Cblock(self._GenerateTypes(p.type_ for p in properties)) |
| 269 .Cblock(self._GenerateFields(properties))) | 269 .Cblock(self._GenerateFields(properties))) |
| 270 if type_.additional_properties is not None: | 270 if type_.additional_properties is not None: |
| 271 # Most additionalProperties actually have type "any", which is better | 271 # Most additionalProperties actually have type "any", which is better |
| 272 # modelled as a DictionaryValue rather than a map of string -> Value. | 272 # modelled as a DictionaryValue rather than a map of string -> Value. |
| 273 if type_.additional_properties.property_type == PropertyType.ANY: | 273 if type_.additional_properties.property_type == PropertyType.ANY: |
| 274 c.Append('base::DictionaryValue additional_properties;') | 274 c.Append('base::DictionaryValue additional_properties;') |
| 275 else: | 275 else: |
| 276 (c.Cblock(self._GenerateType(type_.additional_properties)) | 276 (c.Cblock(self._GenerateType(type_.additional_properties)) |
| 277 .Append('std::map<std::string, %s> additional_properties;' % | 277 .Append('std::map<std::string, %s> additional_properties;' % |
| 278 cpp_util.PadForGenerics( | |
| 279 self._type_helper.GetCppType(type_.additional_properties, | 278 self._type_helper.GetCppType(type_.additional_properties, |
| 280 is_in_container=True))) | 279 is_in_container=True)) |
| 281 ) | 280 ) |
| 282 (c.Eblock() | 281 (c.Eblock() |
| 283 .Append() | 282 .Append() |
| 284 .Sblock(' private:') | 283 .Sblock(' private:') |
| 285 .Append('DISALLOW_COPY_AND_ASSIGN(%(classname)s);') | 284 .Append('DISALLOW_COPY_AND_ASSIGN(%(classname)s);') |
| 286 .Eblock('};') | 285 .Eblock('};') |
| 287 ) | 286 ) |
| 288 return c.Substitute({'classname': classname}) | 287 return c.Substitute({'classname': classname}) |
| 289 | 288 |
| 290 def _GenerateEvent(self, event): | 289 def _GenerateEvent(self, event): |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 """Builds the parameter list for a function, given an array of parameters. | 395 """Builds the parameter list for a function, given an array of parameters. |
| 397 """ | 396 """ |
| 398 # |error| is populated with warnings and/or errors found during parsing. | 397 # |error| is populated with warnings and/or errors found during parsing. |
| 399 # |error| being set does not necessarily imply failure and may be | 398 # |error| being set does not necessarily imply failure and may be |
| 400 # recoverable. | 399 # recoverable. |
| 401 # For example, optional properties may have failed to parse, but the | 400 # For example, optional properties may have failed to parse, but the |
| 402 # parser was able to continue. | 401 # parser was able to continue. |
| 403 if self._generate_error_messages: | 402 if self._generate_error_messages: |
| 404 params += ('base::string16* error',) | 403 params += ('base::string16* error',) |
| 405 return ', '.join(str(p) for p in params) | 404 return ', '.join(str(p) for p in params) |
| OLD | NEW |