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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 c.Concat(self._GenerateListValueToEnumArrayConversion( | 769 c.Concat(self._GenerateListValueToEnumArrayConversion( |
770 item_type, | 770 item_type, |
771 'list', | 771 'list', |
772 dst_var, | 772 dst_var, |
773 failure_value, | 773 failure_value, |
774 is_ptr=is_ptr)) | 774 is_ptr=is_ptr)) |
775 else: | 775 else: |
776 (c.Sblock('if (!%s) {' % self._util_cc_helper.PopulateArrayFromList( | 776 (c.Sblock('if (!%s) {' % self._util_cc_helper.PopulateArrayFromList( |
777 'list', | 777 'list', |
778 dst_var, | 778 dst_var, |
779 is_ptr))) | 779 is_ptr, |
| 780 item_type.property_type == PropertyType.BINARY))) |
780 c.Concat(self._GenerateError( | 781 c.Concat(self._GenerateError( |
781 '"unable to populate array \'%%(parent_key)s\'"')) | 782 '"unable to populate array \'%%(parent_key)s\'"')) |
782 if is_ptr and self._generate_error_messages: | 783 if is_ptr and self._generate_error_messages: |
783 c.Append('%(dst_var)s.reset();') | 784 c.Append('%(dst_var)s.reset();') |
784 else: | 785 else: |
785 c.Append('return %(failure_value)s;') | 786 c.Append('return %(failure_value)s;') |
786 c.Eblock('}') | 787 c.Eblock('}') |
787 c.Eblock('}') | 788 c.Eblock('}') |
788 elif underlying_type.property_type == PropertyType.CHOICES: | 789 elif underlying_type.property_type == PropertyType.CHOICES: |
789 if is_ptr: | 790 if is_ptr: |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 if self._generate_error_messages: | 1062 if self._generate_error_messages: |
1062 params = list(params) + ['base::string16* error'] | 1063 params = list(params) + ['base::string16* error'] |
1063 return ', '.join(str(p) for p in params) | 1064 return ', '.join(str(p) for p in params) |
1064 | 1065 |
1065 def _GenerateArgs(self, args): | 1066 def _GenerateArgs(self, args): |
1066 """Builds the argument list for a function, given an array of arguments. | 1067 """Builds the argument list for a function, given an array of arguments. |
1067 """ | 1068 """ |
1068 if self._generate_error_messages: | 1069 if self._generate_error_messages: |
1069 args = list(args) + ['error'] | 1070 args = list(args) + ['error'] |
1070 return ', '.join(str(a) for a in args) | 1071 return ', '.join(str(a) for a in args) |
OLD | NEW |