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 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 import util_cc_helper | 9 import util_cc_helper |
| 10 from cpp_namespace_environment import CppNamespaceEnvironment | 10 from cpp_namespace_environment import CppNamespaceEnvironment |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 .Append('for (const auto& it : %s) {' % varname) | 500 .Append('for (const auto& it : %s) {' % varname) |
| 501 .Append('%s.push_back(%sToString(it));' % (enum_list_var, | 501 .Append('%s.push_back(%sToString(it));' % (enum_list_var, |
| 502 maybe_namespace)) | 502 maybe_namespace)) |
| 503 .Eblock('}')) | 503 .Eblock('}')) |
| 504 | 504 |
| 505 # Because the std::vector above is always created for both required and | 505 # Because the std::vector above is always created for both required and |
| 506 # optional enum arrays, |is_ptr| is set to false and uses the | 506 # optional enum arrays, |is_ptr| is set to false and uses the |
| 507 # std::vector to create the values. | 507 # std::vector to create the values. |
| 508 (c.Append(code % | 508 (c.Append(code % |
| 509 self._GenerateCreateValueFromType(type_, enum_list_var, False)) | 509 self._GenerateCreateValueFromType(type_, enum_list_var, False)) |
| 510 .Eblock('}')) | 510 .Append('}')) |
|
Devlin
2015/03/27 20:50:11
This Eblock (and another in .h generator) didn't h
| |
| 511 return c | 511 return c |
| 512 | 512 |
| 513 c.Append(code % self._GenerateCreateValueFromType(type_, var, is_ptr)) | 513 c.Append(code % self._GenerateCreateValueFromType(type_, var, is_ptr)) |
| 514 return c | 514 return c |
| 515 | 515 |
| 516 def _GenerateCreateValueFromType(self, type_, var, is_ptr): | 516 def _GenerateCreateValueFromType(self, type_, var, is_ptr): |
| 517 """Generates the statement to create a base::Value given a type. | 517 """Generates the statement to create a base::Value given a type. |
| 518 | 518 |
| 519 type_: The type of the values being converted. | 519 type_: The type of the values being converted. |
| 520 var: The name of the variable. | 520 var: The name of the variable. |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 if self._generate_error_messages: | 1052 if self._generate_error_messages: |
| 1053 params = list(params) + ['base::string16* error'] | 1053 params = list(params) + ['base::string16* error'] |
| 1054 return ', '.join(str(p) for p in params) | 1054 return ', '.join(str(p) for p in params) |
| 1055 | 1055 |
| 1056 def _GenerateArgs(self, args): | 1056 def _GenerateArgs(self, args): |
| 1057 """Builds the argument list for a function, given an array of arguments. | 1057 """Builds the argument list for a function, given an array of arguments. |
| 1058 """ | 1058 """ |
| 1059 if self._generate_error_messages: | 1059 if self._generate_error_messages: |
| 1060 args = list(args) + ['error'] | 1060 args = list(args) + ['error'] |
| 1061 return ', '.join(str(a) for a in args) | 1061 return ', '.join(str(a) for a in args) |
| OLD | NEW |