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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/code_generator_v8.py

Issue 2749253002: bindings: Expand typedefs before generating union files. (Closed)
Patch Set: Created 3 years, 9 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 | third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.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) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 class CodeGeneratorUnionType(CodeGeneratorBase): 281 class CodeGeneratorUnionType(CodeGeneratorBase):
282 """Generates union type container classes. 282 """Generates union type container classes.
283 This generator is different from CodeGeneratorV8 and 283 This generator is different from CodeGeneratorV8 and
284 CodeGeneratorDictionaryImpl. It assumes that all union types are already 284 CodeGeneratorDictionaryImpl. It assumes that all union types are already
285 collected. It doesn't process idl files directly. 285 collected. It doesn't process idl files directly.
286 """ 286 """
287 def __init__(self, info_provider, cache_dir, output_dir, target_component): 287 def __init__(self, info_provider, cache_dir, output_dir, target_component):
288 CodeGeneratorBase.__init__(self, MODULE_PYNAME, info_provider, cache_dir , output_dir) 288 CodeGeneratorBase.__init__(self, MODULE_PYNAME, info_provider, cache_dir , output_dir)
289 self.target_component = target_component 289 self.target_component = target_component
290 # The code below duplicates parts of TypedefResolver. We do not use it
291 # directly because IdlUnionType is not a type defined in
292 # idl_definitions.py. What we do instead is to resolve typedefs in
293 # _generate_container_code() whenever a new union file is generated.
294 self.typedefs = {}
bashi 2017/03/15 23:27:11 Could you explain why do you need to set |typedef|
Raphael Kubo da Costa (rakuco) 2017/03/16 08:04:48 Just to avoid having to iterate through self.info_
295 for name, typedef in self.info_provider.typedefs.iteritems():
296 self.typedefs[name] = typedef.idl_type
290 297
291 def _generate_container_code(self, union_type): 298 def _generate_container_code(self, union_type):
299 union_type = union_type.resolve_typedefs(self.typedefs)
292 header_template = self.jinja_env.get_template('union_container.h.tmpl') 300 header_template = self.jinja_env.get_template('union_container.h.tmpl')
293 cpp_template = self.jinja_env.get_template('union_container.cpp.tmpl') 301 cpp_template = self.jinja_env.get_template('union_container.cpp.tmpl')
294 template_context = v8_union.container_context( 302 template_context = v8_union.container_context(
295 union_type, self.info_provider.interfaces_info) 303 union_type, self.info_provider.interfaces_info)
296 template_context['header_includes'].append( 304 template_context['header_includes'].append(
297 self.info_provider.include_path_for_export) 305 self.info_provider.include_path_for_export)
298 template_context['header_includes'] = normalize_and_sort_includes( 306 template_context['header_includes'] = normalize_and_sort_includes(
299 template_context['header_includes']) 307 template_context['header_includes'])
300 template_context['code_generator'] = self.generator_name 308 template_context['code_generator'] = self.generator_name
301 template_context['exported'] = self.info_provider.specifier_for_export 309 template_context['exported'] = self.info_provider.specifier_for_export
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 outputs = set() 381 outputs = set()
374 for callback_function_dict in callback_functions.itervalues(): 382 for callback_function_dict in callback_functions.itervalues():
375 if callback_function_dict['component_dir'] != self.target_component: 383 if callback_function_dict['component_dir'] != self.target_component:
376 continue 384 continue
377 callback_function = callback_function_dict['callback_function'] 385 callback_function = callback_function_dict['callback_function']
378 if 'Custom' in callback_function.extended_attributes: 386 if 'Custom' in callback_function.extended_attributes:
379 continue 387 continue
380 path = callback_function_dict['full_path'] 388 path = callback_function_dict['full_path']
381 outputs.update(self.generate_code_internal(callback_function, path)) 389 outputs.update(self.generate_code_internal(callback_function, path))
382 return outputs 390 return outputs
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698