Chromium Code Reviews| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 (maybe_static, classname, classname)) | 221 (maybe_static, classname, classname)) |
| 222 ) | 222 ) |
| 223 elif type_.property_type in (PropertyType.CHOICES, | 223 elif type_.property_type in (PropertyType.CHOICES, |
| 224 PropertyType.OBJECT): | 224 PropertyType.OBJECT): |
| 225 if type_.description: | 225 if type_.description: |
| 226 c.Comment(type_.description) | 226 c.Comment(type_.description) |
| 227 (c.Sblock('struct %(classname)s {') | 227 (c.Sblock('struct %(classname)s {') |
| 228 .Append('%(classname)s();') | 228 .Append('%(classname)s();') |
| 229 .Append('~%(classname)s();') | 229 .Append('~%(classname)s();') |
| 230 ) | 230 ) |
| 231 if 'use_movable_types' in type_.namespace.compiler_options: | |
|
Devlin
2016/03/18 20:17:40
Note: we could actually generate move ctors/operat
| |
| 232 (c.Append('%(classname)s(%(classname)s&& other);') | |
| 233 .Append('%(classname)s& operator=(%(classname)s&& other);') | |
| 234 ) | |
| 231 if type_.origin.from_json: | 235 if type_.origin.from_json: |
| 232 (c.Append() | 236 (c.Append() |
| 233 .Comment('Populates a %s object from a base::Value. Returns' | 237 .Comment('Populates a %s object from a base::Value. Returns' |
| 234 ' whether |out| was successfully populated.' % classname) | 238 ' whether |out| was successfully populated.' % classname) |
| 235 .Append('static bool Populate(%s);' % self._GenerateParams( | 239 .Append('static bool Populate(%s);' % self._GenerateParams( |
| 236 ('const base::Value& value', '%s* out' % classname))) | 240 ('const base::Value& value', '%s* out' % classname))) |
| 237 ) | 241 ) |
| 238 if is_toplevel: | 242 if is_toplevel: |
| 239 (c.Append() | 243 (c.Append() |
| 240 .Comment('Creates a %s object from a base::Value, or NULL on ' | 244 .Comment('Creates a %s object from a base::Value, or NULL on ' |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 """Builds the parameter list for a function, given an array of parameters. | 398 """Builds the parameter list for a function, given an array of parameters. |
| 395 """ | 399 """ |
| 396 # |error| is populated with warnings and/or errors found during parsing. | 400 # |error| is populated with warnings and/or errors found during parsing. |
| 397 # |error| being set does not necessarily imply failure and may be | 401 # |error| being set does not necessarily imply failure and may be |
| 398 # recoverable. | 402 # recoverable. |
| 399 # For example, optional properties may have failed to parse, but the | 403 # For example, optional properties may have failed to parse, but the |
| 400 # parser was able to continue. | 404 # parser was able to continue. |
| 401 if self._generate_error_messages: | 405 if self._generate_error_messages: |
| 402 params += ('base::string16* error',) | 406 params += ('base::string16* error',) |
| 403 return ', '.join(str(p) for p in params) | 407 return ', '.join(str(p) for p in params) |
| OLD | NEW |