def generate_interface_code(self, definitions, interface_name, interface): # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface.h' cpp_template_filename = 'callback_interface.cpp' interface_context = v8_callback_interface.callback_interface_context else: 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) 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) return ( (header_path, header_text), (cpp_path, cpp_text), )
def generate_interface_code(self, definitions, interface_name, interface): # Store other interfaces for introspection interfaces.update(definitions.interfaces) 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 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' interface_name += 'Partial' assert component == 'core' component = 'modules' include_paths = interface_info.get( 'dependencies_other_component_include_paths') else: header_template_filename = 'interface.h' cpp_template_filename = 'interface.cpp' interface_context = v8_interface.interface_context 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 # Add the include for interface itself if IdlType(interface_name).is_typed_array: template_context['header_includes'].add('core/dom/DOMTypedArray.h') elif interface_info['include_path']: template_context['header_includes'].add( interface_info['include_path']) template_context['header_includes'].update( interface_info.get('additional_header_includes', [])) 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) header_path, cpp_path = self.output_paths(interface_name) return ( (header_path, header_text), (cpp_path, cpp_text), )
def generate_interface_code(self, definitions, interface_name, interface): # Store other interfaces for introspection interfaces.update(definitions.interfaces) 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 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' interface_name += 'Partial' assert component == 'core' component = 'modules' include_paths = interface_info.get('dependencies_other_component_include_paths') else: header_template_filename = 'interface.h' cpp_template_filename = 'interface.cpp' interface_context = v8_interface.interface_context 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 # Add the include for interface itself if IdlType(interface_name).is_typed_array: template_context['header_includes'].add('core/dom/DOMTypedArray.h') elif interface_info['include_path']: template_context['header_includes'].add(interface_info['include_path']) template_context['header_includes'].update( interface_info.get('additional_header_includes', [])) 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) header_path, cpp_path = self.output_paths(interface_name) return ( (header_path, header_text), (cpp_path, cpp_text), )
def generate_code(self, definitions, interface_name): """Returns .h/.cpp code as (header_text, cpp_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function 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 'PrivateScriptInterface' in interface.extended_attributes: # Currently private scripts don't have dependencies. Once private scripts have dependencies, # we should add them to interface_info. header_template_filename = 'private_script_interface.h' cpp_template_filename = 'private_script_interface.cpp' interface_context = v8_private_script_interface.private_script_interface_context else: 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) # Compute context (input values for Jinja) template_context = interface_context(interface) template_context['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] if 'PrivateScriptInterface' not in interface.extended_attributes: template_context['header_includes'].add(interface_info['include_path']) template_context['header_includes'] = sorted(template_context['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_context['cpp_includes'] = sorted(includes) # Render Jinja templates header_text = header_template.render(template_context) cpp_text = cpp_template.render(template_context) return header_text, cpp_text
def generate_code(self, definitions, interface_name): """Returns .h/.cpp code as (header_text, cpp_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface.h' cpp_template_filename = 'callback_interface.cpp' generate_contents = v8_callback_interface.generate_callback_interface else: header_template_filename = 'interface.h' cpp_template_filename = 'interface.cpp' generate_contents = v8_interface.generate_interface header_template = self.jinja_env.get_template(header_template_filename) cpp_template = self.jinja_env.get_template(cpp_template_filename) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] template_contents['header_includes'].add( interface_info['include_path']) template_contents['header_includes'] = sorted( template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_contents['cpp_includes'] = sorted(includes) # Render Jinja templates header_text = header_template.render(template_contents) cpp_text = cpp_template.render(template_contents) return header_text, cpp_text
def generate_code(self, definitions, interface_name): """Returns .h/.cpp code as (header_text, cpp_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface.h' cpp_template_filename = 'callback_interface.cpp' generate_contents = v8_callback_interface.generate_callback_interface else: header_template_filename = 'interface.h' cpp_template_filename = 'interface.cpp' generate_contents = v8_interface.generate_interface header_template = self.jinja_env.get_template(header_template_filename) cpp_template = self.jinja_env.get_template(cpp_template_filename) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] template_contents['header_includes'].add(interface_info['include_path']) template_contents['header_includes'] = sorted(template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_contents['cpp_includes'] = sorted(includes) # Render Jinja templates header_text = header_template.render(template_contents) cpp_text = cpp_template.render(template_contents) return header_text, cpp_text
def write_header_and_cpp(definitions, interface_name, interfaces_info, output_directory): try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set up Jinja if interface.is_callback: header_template_filename = 'callback_interface.h' cpp_template_filename = 'callback_interface.cpp' generate_contents = v8_callback_interface.generate_callback_interface else: header_template_filename = 'interface.h' cpp_template_filename = 'interface.cpp' generate_contents = v8_interface.generate_interface jinja_env = jinja2.Environment( loader=jinja2.FileSystemLoader(templates_dir), keep_trailing_newline=True, # newline-terminate generated files lstrip_blocks=True, # so can indent control flow tags trim_blocks=True) jinja_env.filters.update({ 'blink_capitalize': capitalize, 'conditional': conditional_if_endif, 'runtime_enabled': runtime_enabled_if, }) header_template = jinja_env.get_template(header_template_filename) cpp_template = jinja_env.get_template(cpp_template_filename) # Set type info, both local and global interface_info = interfaces_info[interface_name] v8_types.set_callback_functions(definitions.callback_functions.keys()) v8_types.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) v8_types.set_ancestors(dict( (interface_name, interface_info['ancestors']) for interface_name, interface_info in interfaces_info.iteritems() if 'ancestors' in interface_info)) v8_types.set_callback_interfaces(set( interface_name for interface_name, interface_info in interfaces_info.iteritems() if interface_info['is_callback_interface'])) v8_types.set_implemented_as_interfaces(dict( (interface_name, interface_info['implemented_as']) for interface_name, interface_info in interfaces_info.iteritems() if 'implemented_as' in interface_info)) v8_types.set_will_be_garbage_collected_types(set( interface_name for interface_name, interface_info in interfaces_info.iteritems() if 'inherited_extended_attributes' in interface_info and 'WillBeGarbageCollected' in interface_info['inherited_extended_attributes'])) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['header_includes'].add(interface_info['include_path']) template_contents['header_includes'] = sorted(template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_contents['cpp_includes'] = sorted(includes) # Render Jinja templates and write files def write_file(basename, file_text): filename = os.path.join(output_directory, basename) with open(filename, 'w') as output_file: output_file.write(file_text) header_basename = v8_class_name(interface) + '.h' header_file_text = header_template.render(template_contents) write_file(header_basename, header_file_text) cpp_basename = v8_class_name(interface) + '.cpp' cpp_file_text = cpp_template.render(template_contents) write_file(cpp_basename, cpp_file_text)
def generate_code(self, definitions, interface_name, idl_pickle_filename, only_if_changed): """Returns .h/.cpp code as (header_text, cpp_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface_h.template' cpp_template_filename = 'callback_interface_cpp.template' generate_contents = dart_callback_interface.generate_callback_interface else: header_template_filename = 'interface_h.template' cpp_template_filename = 'interface_cpp.template' generate_contents = dart_interface.generate_interface header_template = self.jinja_env.get_template(header_template_filename) cpp_template = self.jinja_env.get_template(cpp_template_filename) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] template_contents['header_includes'].add( interface_info['include_path']) template_contents['header_includes'] = sorted( template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) # Remove includes that are not needed for Dart and trigger fatal # compile warnings if included. These IDL files need to be # imported by Dart to generate the list of events but the # associated header files do not contain any code used by Dart. includes.discard('core/dom/GlobalEventHandlers.h') includes.discard('core/frame/DOMWindowEventHandlers.h') template_contents['cpp_includes'] = sorted(includes) idl_world = {'interface': None, 'callback': None} # Load the pickle file for this IDL. if os.path.isfile(idl_pickle_filename): with open(idl_pickle_filename) as idl_pickle_file: idl_global_data = pickle.load(idl_pickle_file) idl_pickle_file.close() idl_world['interface'] = idl_global_data['interface'] idl_world['callback'] = idl_global_data['callback'] if 'interface_name' in template_contents: interface_global = { 'name': template_contents['interface_name'], 'parent_interface': template_contents['parent_interface'], 'is_active_dom_object': template_contents['is_active_dom_object'], 'is_event_target': template_contents['is_event_target'], 'has_resolver': template_contents['interface_name'] not in INTERFACES_WITHOUT_RESOLVERS, 'is_node': template_contents['is_node'], 'conditional_string': template_contents['conditional_string'], } idl_world['interface'] = interface_global else: callback_global = {'name': template_contents['cpp_class']} idl_world['callback'] = callback_global write_pickle_file(idl_pickle_filename, idl_world, only_if_changed) # Render Jinja templates header_text = header_template.render(template_contents) cpp_text = cpp_template.render(template_contents) return header_text, cpp_text
def generate_code(self, definitions, interface_name, idl_filename, idl_pickle_filename, only_if_changed): """Returns .h/.cpp/.dart code as (header_text, cpp_text, dart_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface_h.template' cpp_template_filename = 'callback_interface_cpp.template' dart_template_filename = 'callback_interface_dart.template' generate_contents = dart_callback_interface.generate_callback_interface else: header_template_filename = 'interface_h.template' cpp_template_filename = 'interface_cpp.template' dart_template_filename = 'interface_dart.template' generate_contents = dart_interface.interface_context header_template = self.jinja_env.get_template(header_template_filename) cpp_template = self.jinja_env.get_template(cpp_template_filename) dart_template = self.jinja_env.get_template(dart_template_filename) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] template_contents['header_includes'].add( interface_info['include_path']) template_contents['header_includes'] = sorted( template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_contents['cpp_includes'] = sorted(includes) # If PrivateDart is set, read the custom dart file and add it to our # template parameters. if 'PrivateDart' in interface.extended_attributes: template_contents['private_dart'] = True idl_world = {'interface': None, 'callback': None} # Load the pickle file for this IDL. if os.path.isfile(idl_pickle_filename): with open(idl_pickle_filename) as idl_pickle_file: idl_global_data = pickle.load(idl_pickle_file) idl_pickle_file.close() idl_world['interface'] = idl_global_data['interface'] idl_world['callback'] = idl_global_data['callback'] if 'interface_name' in template_contents: interface_global = { 'component_dir': interface_info['component_dir'], 'name': template_contents['interface_name'], 'parent_interface': template_contents['parent_interface'], 'has_resolver': template_contents['interface_name'], 'native_entries': sorted(template_contents['native_entries'], key=lambda (x): x['blink_entry']), } idl_world['interface'] = interface_global else: callback_global = {'name': template_contents['cpp_class']} idl_world['callback'] = callback_global write_pickle_file(idl_pickle_filename, idl_world, only_if_changed) # Render Jinja templates header_text = header_template.render(template_contents) cpp_text = cpp_template.render(template_contents) dart_text = dart_template.render(template_contents) return header_text, cpp_text, dart_text
def generate_code(self, definitions, interface_name, idl_filename, idl_pickle_filename, only_if_changed): """Returns .h/.cpp/.dart code as (header_text, cpp_text, dart_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface_h.template' cpp_template_filename = 'callback_interface_cpp.template' dart_template_filename = 'callback_interface_dart.template' generate_contents = dart_callback_interface.generate_callback_interface else: header_template_filename = 'interface_h.template' cpp_template_filename = 'interface_cpp.template' dart_template_filename = 'interface_dart.template' generate_contents = dart_interface.interface_context header_template = self.jinja_env.get_template(header_template_filename) cpp_template = self.jinja_env.get_template(cpp_template_filename) dart_template = self.jinja_env.get_template(dart_template_filename) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] template_contents['header_includes'].add(interface_info['include_path']) template_contents['header_includes'] = sorted(template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_contents['cpp_includes'] = sorted(includes) # If PrivateDart is set, read the custom dart file and add it to our # template parameters. if 'PrivateDart' in interface.extended_attributes: template_contents['private_dart'] = True idl_world = {'interface': None, 'callback': None} # Load the pickle file for this IDL. if os.path.isfile(idl_pickle_filename): with open(idl_pickle_filename) as idl_pickle_file: idl_global_data = pickle.load(idl_pickle_file) idl_pickle_file.close() idl_world['interface'] = idl_global_data['interface'] idl_world['callback'] = idl_global_data['callback'] if 'interface_name' in template_contents: interface_global = {'component_dir': interface_info['component_dir'], 'name': template_contents['interface_name'], 'parent_interface': template_contents['parent_interface'], 'is_active_dom_object': template_contents['is_active_dom_object'], 'has_resolver': template_contents['interface_name'], 'native_entries': sorted(template_contents['native_entries'], key=lambda(x): x['blink_entry']), } idl_world['interface'] = interface_global else: callback_global = {'name': template_contents['cpp_class']} idl_world['callback'] = callback_global write_pickle_file(idl_pickle_filename, idl_world, only_if_changed) # Render Jinja templates header_text = header_template.render(template_contents) cpp_text = cpp_template.render(template_contents) dart_text = dart_template.render(template_contents) return header_text, cpp_text, dart_text
def generate_code(self, definitions, interface_name, idl_pickle_filename, only_if_changed): """Returns .h/.cpp code as (header_text, cpp_text).""" try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set local type info IdlType.set_callback_functions(definitions.callback_functions.keys()) IdlType.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) # Select appropriate Jinja template and contents function if interface.is_callback: header_template_filename = 'callback_interface_h.template' cpp_template_filename = 'callback_interface_cpp.template' generate_contents = dart_callback_interface.generate_callback_interface else: header_template_filename = 'interface_h.template' cpp_template_filename = 'interface_cpp.template' generate_contents = dart_interface.generate_interface header_template = self.jinja_env.get_template(header_template_filename) cpp_template = self.jinja_env.get_template(cpp_template_filename) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['code_generator'] = module_pyname # Add includes for interface itself and any dependencies interface_info = self.interfaces_info[interface_name] template_contents['header_includes'].add(interface_info['include_path']) template_contents['header_includes'] = sorted(template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) # Remove includes that are not needed for Dart and trigger fatal # compile warnings if included. These IDL files need to be # imported by Dart to generate the list of events but the # associated header files do not contain any code used by Dart. includes.discard('core/dom/GlobalEventHandlers.h') includes.discard('core/frame/DOMWindowEventHandlers.h') template_contents['cpp_includes'] = sorted(includes) idl_world = {'interface': None, 'callback': None} # Load the pickle file for this IDL. if os.path.isfile(idl_pickle_filename): with open(idl_pickle_filename) as idl_pickle_file: idl_global_data = pickle.load(idl_pickle_file) idl_pickle_file.close() idl_world['interface'] = idl_global_data['interface'] idl_world['callback'] = idl_global_data['callback'] if 'interface_name' in template_contents: interface_global = {'name': template_contents['interface_name'], 'parent_interface': template_contents['parent_interface'], 'is_active_dom_object': template_contents['is_active_dom_object'], 'is_event_target': template_contents['is_event_target'], 'has_resolver': template_contents['interface_name'] not in INTERFACES_WITHOUT_RESOLVERS, 'is_node': template_contents['is_node'], 'conditional_string': template_contents['conditional_string'], } idl_world['interface'] = interface_global else: callback_global = {'name': template_contents['cpp_class']} idl_world['callback'] = callback_global write_pickle_file(idl_pickle_filename, idl_world, only_if_changed) # Render Jinja templates header_text = header_template.render(template_contents) cpp_text = cpp_template.render(template_contents) return header_text, cpp_text
def write_header_and_cpp(definitions, interface_name, interfaces_info, output_dir): try: interface = definitions.interfaces[interface_name] except KeyError: raise Exception('%s not in IDL definitions' % interface_name) # Store other interfaces for introspection interfaces.update(definitions.interfaces) # Set up Jinja jinja_env = initialize_jinja_env(output_dir) if interface.is_callback: header_template_filename = 'callback_interface.h' cpp_template_filename = 'callback_interface.cpp' generate_contents = v8_callback_interface.generate_callback_interface else: header_template_filename = 'interface.h' cpp_template_filename = 'interface.cpp' generate_contents = v8_interface.generate_interface header_template = jinja_env.get_template(header_template_filename) cpp_template = jinja_env.get_template(cpp_template_filename) # Set type info, both local and global interface_info = interfaces_info[interface_name] v8_types.set_callback_functions(definitions.callback_functions.keys()) v8_types.set_enums((enum.name, enum.values) for enum in definitions.enumerations.values()) v8_types.set_ancestors(dict( (interface_name, interface_info['ancestors']) for interface_name, interface_info in interfaces_info.iteritems() if 'ancestors' in interface_info)) v8_types.set_callback_interfaces(set( interface_name for interface_name, interface_info in interfaces_info.iteritems() if interface_info['is_callback_interface'])) v8_types.set_implemented_as_interfaces(dict( (interface_name, interface_info['implemented_as']) for interface_name, interface_info in interfaces_info.iteritems() if 'implemented_as' in interface_info)) v8_types.set_will_be_garbage_collected_types(set( interface_name for interface_name, interface_info in interfaces_info.iteritems() if 'inherited_extended_attributes' in interface_info and 'WillBeGarbageCollected' in interface_info['inherited_extended_attributes'])) # Generate contents (input parameters for Jinja) template_contents = generate_contents(interface) template_contents['header_includes'].add(interface_info['include_path']) template_contents['header_includes'] = sorted(template_contents['header_includes']) includes.update(interface_info.get('dependencies_include_paths', [])) template_contents['cpp_includes'] = sorted(includes) # Render Jinja templates and write files def write_file(basename, file_text): filename = os.path.join(output_dir, basename) with open(filename, 'w') as output_file: output_file.write(file_text) header_basename = v8_class_name(interface) + '.h' header_file_text = header_template.render(template_contents) write_file(header_basename, header_file_text) cpp_basename = v8_class_name(interface) + '.cpp' cpp_file_text = cpp_template.render(template_contents) write_file(cpp_basename, cpp_file_text)