| 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 schema_util | 8 import schema_util |
| 9 | 9 |
| 10 class HGenerator(object): | 10 class HGenerator(object): |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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;') |
| 209 elif type_.property_type == PropertyType.ENUM: | 209 elif type_.property_type == PropertyType.ENUM: |
| 210 if type_.description: | 210 if type_.description: |
| 211 c.Comment(type_.description) | 211 c.Comment(type_.description) |
| 212 c.Cblock(self._GenerateEnumDeclaration(classname, type_)); | 212 c.Cblock(self._GenerateEnumDeclaration(classname, type_)); |
| 213 # Top level enums are in a namespace scope so the methods shouldn't be | 213 # Top level enums are in a namespace scope so the methods shouldn't be |
| 214 # static. On the other hand, those declared inline (e.g. in an object) do. | 214 # static. On the other hand, those declared inline (e.g. in an object) do. |
| 215 maybe_static = '' if is_toplevel else 'static ' | 215 maybe_static = '' if is_toplevel else 'static ' |
| 216 (c.Append() | 216 (c.Append() |
| 217 .Append('%sstd::string %sToString(%s as_enum);' % | |
| 218 (maybe_static, classname, classname)) | |
| 219 .Append('%sstd::string ToString(%s as_enum);' % | 217 .Append('%sstd::string ToString(%s as_enum);' % |
| 220 (maybe_static, classname)) | 218 (maybe_static, classname)) |
| 221 .Append('%s%s Parse%s(const std::string& as_string);' % | 219 .Append('%s%s Parse%s(const std::string& as_string);' % |
| 222 (maybe_static, classname, classname)) | 220 (maybe_static, classname, classname)) |
| 223 ) | 221 ) |
| 224 elif type_.property_type in (PropertyType.CHOICES, | 222 elif type_.property_type in (PropertyType.CHOICES, |
| 225 PropertyType.OBJECT): | 223 PropertyType.OBJECT): |
| 226 if type_.description: | 224 if type_.description: |
| 227 c.Comment(type_.description) | 225 c.Comment(type_.description) |
| 228 (c.Sblock('struct %(classname)s {') | 226 (c.Sblock('struct %(classname)s {') |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 """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. |
| 396 """ | 394 """ |
| 397 # |error| is populated with warnings and/or errors found during parsing. | 395 # |error| is populated with warnings and/or errors found during parsing. |
| 398 # |error| being set does not necessarily imply failure and may be | 396 # |error| being set does not necessarily imply failure and may be |
| 399 # recoverable. | 397 # recoverable. |
| 400 # For example, optional properties may have failed to parse, but the | 398 # For example, optional properties may have failed to parse, but the |
| 401 # parser was able to continue. | 399 # parser was able to continue. |
| 402 if self._generate_error_messages: | 400 if self._generate_error_messages: |
| 403 params += ('base::string16* error',) | 401 params += ('base::string16* error',) |
| 404 return ', '.join(str(p) for p in params) | 402 return ', '.join(str(p) for p in params) |
| OLD | NEW |