| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 dependency_order.append(type_) | 134 dependency_order.append(type_) |
| 135 | 135 |
| 136 for type_ in self._namespace.types.values(): | 136 for type_ in self._namespace.types.values(): |
| 137 ExpandType([], type_) | 137 ExpandType([], type_) |
| 138 return dependency_order | 138 return dependency_order |
| 139 | 139 |
| 140 def _GenerateEnumDeclaration(self, enum_name, type_): | 140 def _GenerateEnumDeclaration(self, enum_name, type_): |
| 141 """Generate a code object with the declaration of a C++ enum. | 141 """Generate a code object with the declaration of a C++ enum. |
| 142 """ | 142 """ |
| 143 c = Code() | 143 c = Code() |
| 144 c.Sblock('enum %s {' % enum_name) | 144 c.Sblock('enum %s%s {' % ('class ' if type_.is_enum_class else '', |
| 145 c.Append(self._type_helper.GetEnumNoneValue(type_) + ',') | 145 enum_name)) |
| 146 c.Append(self._type_helper.GetEnumNoneValue( |
| 147 type_, is_in_declaration=True) + ',') |
| 146 for value in type_.enum_values: | 148 for value in type_.enum_values: |
| 147 current_enum_string = self._type_helper.GetEnumValue(type_, value) | 149 current_enum_string = self._type_helper.GetEnumValue( |
| 150 type_, value, is_in_declaration=True) |
| 148 c.Append(current_enum_string + ',') | 151 c.Append(current_enum_string + ',') |
| 149 c.Append('%s = %s,' % ( | 152 c.Append('%s = %s,' % ( |
| 150 self._type_helper.GetEnumLastValue(type_), current_enum_string)) | 153 self._type_helper.GetEnumLastValue(type_, is_in_declaration=True), |
| 154 current_enum_string)) |
| 151 c.Eblock('};') | 155 c.Eblock('};') |
| 152 return c | 156 return c |
| 153 | 157 |
| 154 def _GenerateFields(self, props): | 158 def _GenerateFields(self, props): |
| 155 """Generates the field declarations when declaring a type. | 159 """Generates the field declarations when declaring a type. |
| 156 """ | 160 """ |
| 157 c = Code() | 161 c = Code() |
| 158 needs_blank_line = False | 162 needs_blank_line = False |
| 159 for prop in props: | 163 for prop in props: |
| 160 if needs_blank_line: | 164 if needs_blank_line: |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 """Builds the parameter list for a function, given an array of parameters. | 400 """Builds the parameter list for a function, given an array of parameters. |
| 397 """ | 401 """ |
| 398 # |error| is populated with warnings and/or errors found during parsing. | 402 # |error| is populated with warnings and/or errors found during parsing. |
| 399 # |error| being set does not necessarily imply failure and may be | 403 # |error| being set does not necessarily imply failure and may be |
| 400 # recoverable. | 404 # recoverable. |
| 401 # For example, optional properties may have failed to parse, but the | 405 # For example, optional properties may have failed to parse, but the |
| 402 # parser was able to continue. | 406 # parser was able to continue. |
| 403 if self._generate_error_messages: | 407 if self._generate_error_messages: |
| 404 params += ('base::string16* error',) | 408 params += ('base::string16* error',) |
| 405 return ', '.join(str(p) for p in params) | 409 return ', '.join(str(p) for p in params) |
| OLD | NEW |