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

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

Issue 1837293004: [Extensions] Support choices in autogenerated movable types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar tests Created 4 years, 8 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/test/objects_movable.idl » ('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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 elif t.property_type == PropertyType.FUNCTION: 226 elif t.property_type == PropertyType.FUNCTION:
227 dicts.append(prop.unix_name) 227 dicts.append(prop.unix_name)
228 elif (real_t.property_type == PropertyType.ENUM or 228 elif (real_t.property_type == PropertyType.ENUM or
229 t.property_type == PropertyType.INTEGER or 229 t.property_type == PropertyType.INTEGER or
230 t.property_type == PropertyType.DOUBLE or 230 t.property_type == PropertyType.DOUBLE or
231 t.property_type == PropertyType.BOOLEAN): 231 t.property_type == PropertyType.BOOLEAN):
232 props.append(copy_str % (prop.unix_name, prop.unix_name)) 232 props.append(copy_str % (prop.unix_name, prop.unix_name))
233 else: 233 else:
234 raise TypeError(t) 234 raise TypeError(t)
235 235
236 if type_.property_type == PropertyType.CHOICES:
237 for choice in type_.choices:
238 prop_name = 'as_%s' % choice.unix_name
239 props.append(move_str % (prop_name, prop_name))
240
236 if (type_.property_type == PropertyType.OBJECT and 241 if (type_.property_type == PropertyType.OBJECT and
237 type_.additional_properties is not None): 242 type_.additional_properties is not None):
238 if type_.additional_properties.property_type == PropertyType.ANY: 243 if type_.additional_properties.property_type == PropertyType.ANY:
239 dicts.append('additional_properties') 244 dicts.append('additional_properties')
240 else: 245 else:
241 props.append(move_str % ('additional_properties', 246 props.append(move_str % ('additional_properties',
242 'additional_properties')) 247 'additional_properties'))
243 248
244 return (props, dicts) 249 return (props, dicts)
245 250
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 if self._generate_error_messages: 1161 if self._generate_error_messages:
1157 params = list(params) + ['base::string16* error'] 1162 params = list(params) + ['base::string16* error']
1158 return ', '.join(str(p) for p in params) 1163 return ', '.join(str(p) for p in params)
1159 1164
1160 def _GenerateArgs(self, args): 1165 def _GenerateArgs(self, args):
1161 """Builds the argument list for a function, given an array of arguments. 1166 """Builds the argument list for a function, given an array of arguments.
1162 """ 1167 """
1163 if self._generate_error_messages: 1168 if self._generate_error_messages:
1164 args = list(args) + ['error'] 1169 args = list(args) + ['error']
1165 return ', '.join(str(a) for a in args) 1170 return ', '.join(str(a) for a in args)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/test/objects_movable.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698