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 065873d90fd04bc2e58ffdbd3c2af4639b780cd0..f57bdc12de2ae4c2b30da326228c08cb0e1f8163 100644 |
--- a/Source/bindings/scripts/code_generator_v8.py |
+++ b/Source/bindings/scripts/code_generator_v8.py |
@@ -78,17 +78,24 @@ from v8_globals import includes, interfaces |
import v8_interface |
import v8_types |
from v8_utilities import capitalize, cpp_name, conditional_string, v8_class_name |
-from utilities import KNOWN_COMPONENTS |
+from utilities import KNOWN_COMPONENTS, idl_filename_to_component, is_valid_component_dependency |
-def render_template(interface_info, header_template, cpp_template, |
- template_context): |
+def render_template(include_paths, header_template, cpp_template, |
+ template_context, component=None): |
template_context['code_generator'] = module_pyname |
# Add includes for any dependencies |
template_context['header_includes'] = sorted( |
template_context['header_includes']) |
- includes.update(interface_info.get('dependencies_include_paths', [])) |
+ |
+ for include_path in include_paths: |
+ if component: |
+ dependency = idl_filename_to_component(include_path) |
+ if not is_valid_component_dependency(component, dependency): |
+ continue |
+ includes.add(include_path) |
+ |
template_context['cpp_includes'] = sorted(includes) |
header_text = header_template.render(template_context) |
@@ -146,17 +153,34 @@ class CodeGeneratorV8(CodeGeneratorBase): |
return self.generate_dictionary_code( |
definitions, definition_name, |
definitions.dictionaries[definition_name]) |
- raise ValueError('%s is not in IDL definitions' % definition_name) |
+ |
+ for method in definitions.interfaces.values(): |
+ if not method.is_partial: |
+ raise ValueError('%s is not in IDL definitions' % definition_name) |
def generate_interface_code(self, definitions, interface_name, interface): |
# Store other interfaces for introspection |
interfaces.update(definitions.interfaces) |
+ interface_info = self.interfaces_info[interface_name] |
+ component = idl_filename_to_component( |
+ interface_info.get('full_path')) |
+ include_paths = interface_info.get('dependencies_include_paths') |
+ |
# Select appropriate Jinja template and contents function |
+ definition_name = interface_name |
if interface.is_callback: |
header_template_filename = 'callback_interface.h' |
cpp_template_filename = 'callback_interface.cpp' |
interface_context = v8_callback_interface.callback_interface_context |
+ elif interface.is_partial: |
+ interface_context = v8_interface.interface_context |
+ header_template_filename = 'partial_interface.h' |
+ cpp_template_filename = 'partial_interface.cpp' |
+ definition_name = ''.join([interface_name, 'Partial']) |
+ assert component == 'core' |
+ component = 'modules' |
+ include_paths = interface_info.get('partial_interface_dependencies_include_paths') |
else: |
header_template_filename = 'interface.h' |
cpp_template_filename = 'interface.cpp' |
@@ -164,14 +188,13 @@ class CodeGeneratorV8(CodeGeneratorBase): |
header_template = self.jinja_env.get_template(header_template_filename) |
cpp_template = self.jinja_env.get_template(cpp_template_filename) |
- interface_info = self.interfaces_info[interface_name] |
- |
template_context = interface_context(interface) |
# Add the include for interface itself |
template_context['header_includes'].add(interface_info['include_path']) |
header_text, cpp_text = render_template( |
- interface_info, header_template, cpp_template, template_context) |
- header_path, cpp_path = self.output_paths(interface_name) |
+ include_paths, header_template, cpp_template, template_context, |
+ component) |
+ header_path, cpp_path = self.output_paths(definition_name) |
return ( |
(header_path, header_text), |
(cpp_path, cpp_text), |
@@ -183,10 +206,11 @@ class CodeGeneratorV8(CodeGeneratorBase): |
cpp_template = self.jinja_env.get_template('dictionary_v8.cpp') |
template_context = v8_dictionary.dictionary_context(dictionary) |
interface_info = self.interfaces_info[dictionary_name] |
+ include_paths = interface_info.get('dependencies_include_paths') |
# Add the include for interface itself |
template_context['header_includes'].add(interface_info['include_path']) |
header_text, cpp_text = render_template( |
- interface_info, header_template, cpp_template, template_context) |
+ include_paths, header_template, cpp_template, template_context) |
header_path, cpp_path = self.output_paths(dictionary_name) |
return ( |
(header_path, header_text), |
@@ -214,8 +238,9 @@ class CodeGeneratorDictionaryImpl(CodeGeneratorBase): |
cpp_template = self.jinja_env.get_template('dictionary_impl.cpp') |
template_context = v8_dictionary.dictionary_impl_context( |
dictionary, self.interfaces_info) |
+ include_paths = interface_info.get('dependencies_include_paths') |
header_text, cpp_text = render_template( |
- interface_info, header_template, cpp_template, template_context) |
+ include_paths, header_template, cpp_template, template_context) |
header_path, cpp_path = self.output_paths( |
definition_name, interface_info) |
return ( |