def generate_code(self, union_types): if not union_types: return () 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), 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) header_path = posixpath.join(self.output_dir, 'UnionTypes%s.h' % capitalized_component) cpp_path = posixpath.join(self.output_dir, 'UnionTypes%s.cpp' % capitalized_component) return ( (header_path, header_text), (cpp_path, cpp_text), )
def generate_code(self): union_types = self.info_provider.union_types if not union_types: return () header_template = self.jinja_env.get_template('union.h') cpp_template = self.jinja_env.get_template('union.cpp') template_context = v8_union.union_context( union_types, self.info_provider.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 # Add UnionTypesCore.h as a dependency when we generate modules union types # because we only generate union type containers which are used by both # core and modules in UnionTypesCore.h. # FIXME: This is an ad hoc workaround and we need a general way to # handle core <-> modules dependency. if self.target_component == 'modules': template_context['header_includes'] = sorted( template_context['header_includes'] + ['bindings/core/v8/UnionTypesCore.h']) header_text = header_template.render(template_context) cpp_text = cpp_template.render(template_context) header_path = posixpath.join(self.output_dir, 'UnionTypes%s.h' % capitalized_component) cpp_path = posixpath.join(self.output_dir, 'UnionTypes%s.cpp' % capitalized_component) return ( (header_path, header_text), (cpp_path, cpp_text), )
def generate_code(self): union_types = self.info_provider.union_types if not union_types: return () header_template = self.jinja_env.get_template('union.h') cpp_template = self.jinja_env.get_template('union.cpp') template_context = v8_union.union_context( union_types, self.info_provider.interfaces_info) template_context['code_generator'] = module_pyname capitalized_component = self.target_component.capitalize() template_context['exported'] = self.info_provider.specifier_for_export template_context[ 'header_filename'] = 'bindings/%s/v8/UnionTypes%s.h' % ( self.target_component, capitalized_component) template_context[ 'macro_guard'] = 'UnionType%s_h' % capitalized_component additional_header_includes = [ self.info_provider.include_path_for_export ] # Add UnionTypesCore.h as a dependency when we generate modules union types # because we only generate union type containers which are used by both # core and modules in UnionTypesCore.h. # FIXME: This is an ad hoc workaround and we need a general way to # handle core <-> modules dependency. if self.target_component == 'modules': additional_header_includes.append( 'bindings/core/v8/UnionTypesCore.h') template_context['header_includes'] = sorted( template_context['header_includes'] + additional_header_includes) header_text = header_template.render(template_context) cpp_text = cpp_template.render(template_context) header_path = posixpath.join(self.output_dir, 'UnionTypes%s.h' % capitalized_component) cpp_path = posixpath.join(self.output_dir, 'UnionTypes%s.cpp' % capitalized_component) return ( (header_path, header_text), (cpp_path, cpp_text), )
def generate_code(self, union_types): if not union_types: return () 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), 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) header_path = posixpath.join(self.output_dir, 'UnionTypes%s.h' % capitalized_component) cpp_path = posixpath.join(self.output_dir, 'UnionTypes%s.cpp' % capitalized_component) return ( (header_path, header_text), (cpp_path, cpp_text), )