in bindings/scripts/code_generator_v8.py [0:0]
def generate_interface_code(self, definitions, interface_name, interface):
interface_info = self.info_provider.interfaces_info[interface_name]
full_path = interface_info.get('full_path')
component = idl_filename_to_component(full_path)
include_paths = interface_info.get('dependencies_include_paths')
# Select appropriate Jinja template and contents function
#
# A callback interface with constants needs a special handling.
# https://heycam.github.io/webidl/#legacy-callback-interface-object
if interface.is_callback and len(interface.constants) > 0:
header_template_filename = 'legacy_callback_interface.h.tmpl'
cpp_template_filename = 'legacy_callback_interface.cpp.tmpl'
interface_context = v8_callback_interface.legacy_callback_interface_context
elif interface.is_callback:
header_template_filename = 'callback_interface.h.tmpl'
cpp_template_filename = 'callback_interface.cpp.tmpl'
interface_context = v8_callback_interface.callback_interface_context
elif interface.is_partial:
interface_context = v8_interface.interface_context
header_template_filename = 'partial_interface.h.tmpl'
cpp_template_filename = 'partial_interface.cpp.tmpl'
interface_name += 'Partial'
assert component == 'core'
component = 'modules'
include_paths = interface_info.get('dependencies_other_component_include_paths')
else:
header_template_filename = 'interface.h.tmpl'
cpp_template_filename = 'interface.cpp.tmpl'
interface_context = v8_interface.interface_context
template_context = interface_context(interface, definitions.interfaces)
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
# Add the include for interface itself
if IdlType(interface_name).is_typed_array:
template_context['header_includes'].add('core/typed_arrays/DOMTypedArray.h')
else:
template_context['header_includes'].add(interface_info['include_path'])
template_context['header_includes'].update(
interface_info.get('additional_header_includes', []))
header_path, cpp_path = self.output_paths(interface_name)
template_context['this_include_header_name'] = posixpath.basename(header_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 = self.render_template(
include_paths, header_template, cpp_template, template_context,
component)
return (
(header_path, header_text),
(cpp_path, cpp_text),
)