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

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: Rebased. 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') | no next file with comments »
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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698