Index: Source/bindings/scripts/code_generator_v8.py |
diff --git a/Source/bindings/scripts/code_generator_v8.py b/Source/bindings/scripts/code_generator_v8.py |
index 10ceed630ad1ece6e5079ca4b306b7e7b986abee..15d9977f5a350cdf85b7bd8279a6698b123c823d 100644 |
--- a/Source/bindings/scripts/code_generator_v8.py |
+++ b/Source/bindings/scripts/code_generator_v8.py |
@@ -103,6 +103,16 @@ def render_template(include_paths, header_template, cpp_template, |
return header_text, cpp_text |
+def set_global_type_info(interfaces_info): |
+ idl_types.set_ancestors(interfaces_info['ancestors']) |
+ IdlType.set_callback_interfaces(interfaces_info['callback_interfaces']) |
+ IdlType.set_dictionaries(interfaces_info['dictionaries']) |
+ IdlType.set_implemented_as_interfaces(interfaces_info['implemented_as_interfaces']) |
+ IdlType.set_garbage_collected_types(interfaces_info['garbage_collected_interfaces']) |
+ IdlType.set_will_be_garbage_collected_types(interfaces_info['will_be_garbage_collected_interfaces']) |
+ v8_types.set_component_dirs(interfaces_info['component_dirs']) |
+ |
+ |
class CodeGeneratorBase(object): |
"""Base class for v8 bindings generator and IDL dictionary impl generator""" |
@@ -111,15 +121,7 @@ class CodeGeneratorBase(object): |
self.interfaces_info = interfaces_info |
self.jinja_env = initialize_jinja_env(cache_dir) |
self.output_dir = output_dir |
- |
- # Set global type info |
- idl_types.set_ancestors(interfaces_info['ancestors']) |
- IdlType.set_callback_interfaces(interfaces_info['callback_interfaces']) |
- IdlType.set_dictionaries(interfaces_info['dictionaries']) |
- IdlType.set_implemented_as_interfaces(interfaces_info['implemented_as_interfaces']) |
- IdlType.set_garbage_collected_types(interfaces_info['garbage_collected_interfaces']) |
- IdlType.set_will_be_garbage_collected_types(interfaces_info['will_be_garbage_collected_interfaces']) |
- v8_types.set_component_dirs(interfaces_info['component_dirs']) |
+ set_global_type_info(interfaces_info) |
def generate_code(self, definitions, definition_name): |
"""Returns .h/.cpp code as ((path, content)...).""" |
@@ -248,7 +250,7 @@ class CodeGeneratorDictionaryImpl(CodeGeneratorBase): |
) |
-class CodeGeneratorUnionTypeContainers(object): |
+class CodeGeneratorUnionType(object): |
"""Generates union type container classes. |
This generator is different from CodeGeneratorV8 and |
CodeGeneratorDictionaryImpl. It assumes that all union types are already |
@@ -259,6 +261,7 @@ class CodeGeneratorUnionTypeContainers(object): |
self.jinja_env = initialize_jinja_env(cache_dir) |
self.output_dir = output_dir |
self.target_component = target_component |
+ set_global_type_info(interfaces_info) |
def generate_code(self, union_types): |
if not union_types: |
@@ -266,9 +269,12 @@ class CodeGeneratorUnionTypeContainers(object): |
header_template = self.jinja_env.get_template('union.h') |
cpp_template = self.jinja_env.get_template('union.cpp') |
template_context = v8_union.union_context( |
- sorted(union_types, key=lambda union_type: union_type.name)) |
+ sorted(union_types, key=lambda union_type: union_type.name), |
+ self.interfaces_info) |
template_context['code_generator'] = module_pyname |
capitalized_component = self.target_component.capitalize() |
+ template_context['header_filename'] = 'bindings/%s/v8/UnionTypes%s.h' % ( |
+ self.target_component, capitalized_component) |
template_context['macro_guard'] = 'UnionType%s_h' % capitalized_component |
header_text = header_template.render(template_context) |
cpp_text = cpp_template.render(template_context) |