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

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

Issue 2594053002: [Schema Compiler] Remove cpp_util.PadForGenerics() (Closed)
Patch Set: Created 3 years, 12 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/cpp_type_generator.py » ('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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 """Returns Code that converts a ListValue of string constants from 933 """Returns Code that converts a ListValue of string constants from
934 |src_var| into an array of enums of |type_| in |dst_var|. On failure, 934 |src_var| into an array of enums of |type_| in |dst_var|. On failure,
935 returns |failure_value|. 935 returns |failure_value|.
936 """ 936 """
937 c = Code() 937 c = Code()
938 accessor = '.' 938 accessor = '.'
939 if is_ptr: 939 if is_ptr:
940 accessor = '->' 940 accessor = '->'
941 cpp_type = self._type_helper.GetCppType(item_type, is_in_container=True) 941 cpp_type = self._type_helper.GetCppType(item_type, is_in_container=True)
942 c.Append('%s.reset(new std::vector<%s>);' % 942 c.Append('%s.reset(new std::vector<%s>);' %
943 (dst_var, cpp_util.PadForGenerics(cpp_type))) 943 (dst_var, cpp_type))
944 (c.Sblock('for (const auto& it : *(%s)) {' % src_var) 944 (c.Sblock('for (const auto& it : *(%s)) {' % src_var)
945 .Append('%s tmp;' % self._type_helper.GetCppType(item_type)) 945 .Append('%s tmp;' % self._type_helper.GetCppType(item_type))
946 .Concat(self._GenerateStringToEnumConversion(item_type, 946 .Concat(self._GenerateStringToEnumConversion(item_type,
947 '(it)', 947 '(it)',
948 'tmp', 948 'tmp',
949 failure_value)) 949 failure_value))
950 .Append('%s%spush_back(tmp);' % (dst_var, accessor)) 950 .Append('%s%spush_back(tmp);' % (dst_var, accessor))
951 .Eblock('}') 951 .Eblock('}')
952 ) 952 )
953 return c 953 return c
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 if self._generate_error_messages: 1150 if self._generate_error_messages:
1151 params = list(params) + ['base::string16* error'] 1151 params = list(params) + ['base::string16* error']
1152 return ', '.join(str(p) for p in params) 1152 return ', '.join(str(p) for p in params)
1153 1153
1154 def _GenerateArgs(self, args): 1154 def _GenerateArgs(self, args):
1155 """Builds the argument list for a function, given an array of arguments. 1155 """Builds the argument list for a function, given an array of arguments.
1156 """ 1156 """
1157 if self._generate_error_messages: 1157 if self._generate_error_messages:
1158 args = list(args) + ['error'] 1158 args = list(args) + ['error']
1159 return ', '.join(str(a) for a in args) 1159 return ', '.join(str(a) for a in args)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698