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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 c.Sblock('else {') | 756 c.Sblock('else {') |
757 item_type = self._type_helper.FollowRef(underlying_type.item_type) | 757 item_type = self._type_helper.FollowRef(underlying_type.item_type) |
758 if item_type.property_type == PropertyType.ENUM: | 758 if item_type.property_type == PropertyType.ENUM: |
759 c.Concat(self._GenerateListValueToEnumArrayConversion( | 759 c.Concat(self._GenerateListValueToEnumArrayConversion( |
760 item_type, | 760 item_type, |
761 'list', | 761 'list', |
762 dst_var, | 762 dst_var, |
763 failure_value, | 763 failure_value, |
764 is_ptr=is_ptr)) | 764 is_ptr=is_ptr)) |
765 else: | 765 else: |
766 (c.Sblock('if (!%s) {' % self._util_cc_helper.PopulateArrayFromList( | 766 c.Sblock('if (!%s) {' % self._util_cc_helper.PopulateArrayFromList( |
767 'list', | 767 'list', |
768 dst_var, | 768 dst_var, |
769 is_ptr))) | 769 is_ptr)) |
770 c.Concat(self._GenerateError( | 770 c.Concat(self._GenerateError( |
771 '"unable to populate array \'%%(parent_key)s\'"')) | 771 '"unable to populate array \'%%(parent_key)s\'"')) |
772 if is_ptr and self._generate_error_messages: | 772 if is_ptr and self._generate_error_messages: |
773 c.Append('%(dst_var)s.reset();') | 773 c.Append('%(dst_var)s.reset();') |
774 else: | 774 else: |
775 c.Append('return %(failure_value)s;') | 775 c.Append('return %(failure_value)s;') |
776 c.Eblock('}') | 776 c.Eblock('}') |
777 c.Eblock('}') | 777 c.Eblock('}') |
778 elif underlying_type.property_type == PropertyType.CHOICES: | 778 elif underlying_type.property_type == PropertyType.CHOICES: |
779 if is_ptr: | 779 if is_ptr: |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 if self._generate_error_messages: | 1048 if self._generate_error_messages: |
1049 params = list(params) + ['base::string16* error'] | 1049 params = list(params) + ['base::string16* error'] |
1050 return ', '.join(str(p) for p in params) | 1050 return ', '.join(str(p) for p in params) |
1051 | 1051 |
1052 def _GenerateArgs(self, args): | 1052 def _GenerateArgs(self, args): |
1053 """Builds the argument list for a function, given an array of arguments. | 1053 """Builds the argument list for a function, given an array of arguments. |
1054 """ | 1054 """ |
1055 if self._generate_error_messages: | 1055 if self._generate_error_messages: |
1056 args = list(args) + ['error'] | 1056 args = list(args) + ['error'] |
1057 return ', '.join(str(a) for a in args) | 1057 return ', '.join(str(a) for a in args) |
OLD | NEW |