| Index: bindings/scripts/code_generator_v8.py
|
| diff --git a/bindings/scripts/code_generator_v8.py b/bindings/scripts/code_generator_v8.py
|
| index 4169c23a2edca55f96e650d5aa4846aeb8229ea6..381d321641fb3430c077fcaa9cbb4f5ddfd584ea 100644
|
| --- a/bindings/scripts/code_generator_v8.py
|
| +++ b/bindings/scripts/code_generator_v8.py
|
| @@ -79,16 +79,26 @@ from v8_globals import includes, interfaces
|
| import v8_interface
|
| import v8_types
|
| import v8_union
|
| -from v8_utilities import capitalize, cpp_name, conditional_string, v8_class_name
|
| +from v8_utilities import capitalize, cpp_name, v8_class_name
|
| from utilities import KNOWN_COMPONENTS, idl_filename_to_component, is_valid_component_dependency, is_testing_target
|
|
|
|
|
| +def normalize_and_sort_includes(include_paths):
|
| + normalized_include_paths = []
|
| + for include_path in include_paths:
|
| + match = re.search(r'/gen/blink/(.*)$', posixpath.abspath(include_path))
|
| + if match:
|
| + include_path = match.group(1)
|
| + normalized_include_paths.append(include_path)
|
| + return sorted(normalized_include_paths)
|
| +
|
| +
|
| 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'] = normalize_and_sort_includes(
|
| template_context['header_includes'])
|
|
|
| for include_path in include_paths:
|
| @@ -97,7 +107,7 @@ def render_template(include_paths, header_template, cpp_template,
|
| assert is_valid_component_dependency(component, dependency)
|
| includes.add(include_path)
|
|
|
| - template_context['cpp_includes'] = sorted(includes)
|
| + template_context['cpp_includes'] = normalize_and_sort_includes(includes)
|
|
|
| header_text = header_template.render(template_context)
|
| cpp_text = cpp_template.render(template_context)
|
| @@ -245,10 +255,9 @@ class CodeGeneratorV8(CodeGeneratorBase):
|
| header_template_filename = 'interface.h'
|
| cpp_template_filename = 'interface.cpp'
|
| interface_context = v8_interface.interface_context
|
| - header_template = self.jinja_env.get_template(header_template_filename)
|
| - cpp_template = self.jinja_env.get_template(cpp_template_filename)
|
|
|
| template_context = interface_context(interface)
|
| + includes.update(interface_info.get('cpp_includes', {}).get(component, set()))
|
| if not interface.is_partial and not is_testing_target(full_path):
|
| template_context['header_includes'].add(self.info_provider.include_path_for_export)
|
| template_context['exported'] = self.info_provider.specifier_for_export
|
| @@ -257,6 +266,9 @@ class CodeGeneratorV8(CodeGeneratorBase):
|
| template_context['header_includes'].add('core/dom/DOMTypedArray.h')
|
| elif interface_info['include_path']:
|
| template_context['header_includes'].add(interface_info['include_path'])
|
| +
|
| + header_template = self.jinja_env.get_template(header_template_filename)
|
| + cpp_template = self.jinja_env.get_template(cpp_template_filename)
|
| header_text, cpp_text = render_template(
|
| include_paths, header_template, cpp_template, template_context,
|
| component)
|
| @@ -370,7 +382,7 @@ class CodeGeneratorUnionType(object):
|
| additional_header_includes.append(
|
| 'bindings/core/v8/UnionTypesCore.h')
|
|
|
| - template_context['header_includes'] = sorted(
|
| + template_context['header_includes'] = normalize_and_sort_includes(
|
| template_context['header_includes'] + additional_header_includes)
|
|
|
| header_text = header_template.render(template_context)
|
| @@ -396,7 +408,6 @@ def initialize_jinja_env(cache_dir):
|
| trim_blocks=True)
|
| jinja_env.filters.update({
|
| 'blink_capitalize': capitalize,
|
| - 'conditional': conditional_if_endif,
|
| 'exposed': exposed_if,
|
| 'runtime_enabled': runtime_enabled_if,
|
| })
|
| @@ -411,21 +422,11 @@ def generate_indented_conditional(code, conditional):
|
| '%s}\n' % indent)
|
|
|
|
|
| -# [Conditional]
|
| -def conditional_if_endif(code, conditional_string):
|
| - # Jinja2 filter to generate if/endif directive blocks
|
| - if not conditional_string:
|
| - return code
|
| - return ('#if %s\n' % conditional_string +
|
| - code +
|
| - '#endif // %s\n' % conditional_string)
|
| -
|
| -
|
| # [Exposed]
|
| def exposed_if(code, exposed_test):
|
| if not exposed_test:
|
| return code
|
| - return generate_indented_conditional(code, 'context && (%s)' % exposed_test)
|
| + return generate_indented_conditional(code, 'executionContext && (%s)' % exposed_test)
|
|
|
|
|
| # [RuntimeEnabled]
|
|
|