Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1604)

Side by Side Diff: tools/json_schema_compiler/cc_generator.py

Issue 851673003: Cleanup: Some simplifications in json_schema_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_dart_tests
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/json_schema_compiler/util.h » ('j') | tools/json_schema_compiler/util.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/util.h » ('j') | tools/json_schema_compiler/util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698