예제 #1
0
 def generate_code_internal(self, definitions, definition_name):
     if not definition_name in definitions.dictionaries:
         raise ValueError('%s is not an IDL dictionary')
     interfaces_info = self.info_provider.interfaces_info
     dictionary = definitions.dictionaries[definition_name]
     interface_info = interfaces_info[definition_name]
     header_template = self.jinja_env.get_template('dictionary_impl.h')
     cpp_template = self.jinja_env.get_template('dictionary_impl.cpp')
     template_context = v8_dictionary.dictionary_impl_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     # Add union containers header file to header_includes rather than
     # cpp file so that union containers can be used in dictionary headers.
     union_container_headers = [header for header in include_paths
                                if header.find('UnionTypes') > 0]
     include_paths = [header for header in include_paths
                      if header not in union_container_headers]
     template_context['header_includes'].update(union_container_headers)
     if not is_testing_target(interface_info.get('full_path')):
         template_context['exported'] = self.info_provider.specifier_for_export
         template_context['header_includes'].add(self.info_provider.include_path_for_export)
     header_text, cpp_text = render_template(
         include_paths, header_template, cpp_template, template_context)
     header_path, cpp_path = self.output_paths(
         cpp_name(dictionary), interface_info)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
예제 #2
0
 def generate_code_internal(self, definitions, definition_name):
     if not definition_name in definitions.dictionaries:
         raise ValueError('%s is not an IDL dictionary')
     interfaces_info = self.info_provider.interfaces_info
     dictionary = definitions.dictionaries[definition_name]
     interface_info = interfaces_info[definition_name]
     header_template = self.jinja_env.get_template('dictionary_impl.h')
     cpp_template = self.jinja_env.get_template('dictionary_impl.cpp')
     template_context = v8_dictionary.dictionary_impl_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     if not is_testing_target(interface_info.get('full_path')):
         template_context[
             'exported'] = self.info_provider.specifier_for_export
         template_context['header_includes'].add(
             self.info_provider.include_path_for_export)
     template_context['header_includes'].update(
         interface_info.get('additional_header_includes', []))
     header_text, cpp_text = render_template(include_paths, header_template,
                                             cpp_template, template_context)
     header_path, cpp_path = self.output_paths(cpp_name(dictionary),
                                               interface_info)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
    def generate_code_internal(self, callback_function, path):
        self.typedef_resolver.resolve(callback_function, callback_function.name)
        header_template = self.jinja_env.get_template('callback_function.h.tmpl')
        cpp_template = self.jinja_env.get_template('callback_function.cpp.tmpl')
        template_context = v8_callback_function.callback_function_context(
            callback_function)
        if not is_testing_target(path):
            template_context['exported'] = self.info_provider.specifier_for_export
            template_context['header_includes'].append(
                self.info_provider.include_path_for_export)

        # TODO(bashi): Dependency resolution shouldn't happen here.
        # Move this into includes_for_type() families.
        for argument in callback_function.arguments:
            if argument.idl_type.is_union_type:
                template_context['header_includes'].append(
                    self.info_provider.include_path_for_union_types(argument.idl_type))

        template_context['header_includes'] = normalize_and_sort_includes(
            template_context['header_includes'])
        template_context['cpp_includes'] = normalize_and_sort_includes(
            template_context['cpp_includes'])
        template_context['code_generator'] = MODULE_PYNAME
        header_text = render_template(header_template, template_context)
        cpp_text = render_template(cpp_template, template_context)
        snake_base_name = to_snake_case('V8%s' % callback_function.name)
        header_path = posixpath.join(self.output_dir, '%s.h' % snake_base_name)
        cpp_path = posixpath.join(self.output_dir, '%s.cc' % snake_base_name)
        return (
            (header_path, header_text),
            (cpp_path, cpp_text),
        )
예제 #4
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
        if interface.is_callback:
            header_template_filename = 'callback_interface.h.tmpl'
            cpp_template_filename = 'callback_interface.cc.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.cc.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.cc.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/dom_typed_array.h')
        elif interface.is_callback:
            pass
        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)
        this_include_header_path = self.normalize_this_header_path(header_path)
        template_context['this_include_header_path'] = this_include_header_path
        template_context['header_guard'] = to_header_guard(
            this_include_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_templates(include_paths,
                                                      header_template,
                                                      cpp_template,
                                                      template_context,
                                                      component)
        return (
            (header_path, header_text),
            (cpp_path, cpp_text),
        )
예제 #5
0
 def generate_dictionary_code(self, definitions, dictionary_name,
                              dictionary):
     interfaces_info = self.info_provider.interfaces_info
     header_template = self.jinja_env.get_template('dictionary_v8.h')
     cpp_template = self.jinja_env.get_template('dictionary_v8.cpp')
     interface_info = interfaces_info[dictionary_name]
     template_context = v8_dictionary.dictionary_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     # Add the include for interface itself
     if interface_info['include_path']:
         template_context['header_includes'].add(
             interface_info['include_path'])
     if not is_testing_target(interface_info.get('full_path')):
         template_context['header_includes'].add(
             self.info_provider.include_path_for_export)
         template_context[
             'exported'] = self.info_provider.specifier_for_export
     header_text, cpp_text = render_template(include_paths, header_template,
                                             cpp_template, template_context)
     header_path, cpp_path = self.output_paths(dictionary_name)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
예제 #6
0
 def generate_code_internal(self, definitions, definition_name):
     if not definition_name in definitions.dictionaries:
         raise ValueError('%s is not an IDL dictionary')
     interfaces_info = self.info_provider.interfaces_info
     dictionary = definitions.dictionaries[definition_name]
     interface_info = interfaces_info[definition_name]
     header_template = self.jinja_env.get_template('dictionary_impl.h')
     cpp_template = self.jinja_env.get_template('dictionary_impl.cpp')
     template_context = v8_dictionary.dictionary_impl_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     # Add union containers header file to header_includes rather than
     # cpp file so that union containers can be used in dictionary headers.
     union_container_headers = [
         header for header in include_paths if header.find('UnionTypes') > 0
     ]
     include_paths = [
         header for header in include_paths
         if header not in union_container_headers
     ]
     template_context['header_includes'].update(union_container_headers)
     if not is_testing_target(interface_info.get('full_path')):
         template_context[
             'exported'] = self.info_provider.specifier_for_export
         template_context['header_includes'].add(
             self.info_provider.include_path_for_export)
     header_text, cpp_text = render_template(include_paths, header_template,
                                             cpp_template, template_context)
     header_path, cpp_path = self.output_paths(cpp_name(dictionary),
                                               interface_info)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
예제 #7
0
 def generate_dictionary_code(self, definitions, dictionary_name,
                              dictionary):
     # pylint: disable=unused-argument
     interfaces_info = self.info_provider.interfaces_info
     header_template = self.jinja_env.get_template('dictionary_v8.h.tmpl')
     cpp_template = self.jinja_env.get_template('dictionary_v8.cc.tmpl')
     interface_info = interfaces_info[dictionary_name]
     component_info = self.info_provider.component_info
     template_context = v8_dictionary.dictionary_context(
         dictionary, interfaces_info, component_info)
     include_paths = interface_info.get('dependencies_include_paths')
     # Add the include for interface itself
     template_context['header_includes'].add(interface_info['include_path'])
     if not is_testing_target(interface_info.get('full_path')):
         template_context['header_includes'].add(
             self.info_provider.include_path_for_export)
         template_context['exported'] = \
             self.info_provider.specifier_for_export
     header_path, cpp_path = self.output_paths(dictionary_name)
     this_include_header_path = self.normalize_this_header_path(header_path)
     template_context['this_include_header_path'] = this_include_header_path
     template_context['header_guard'] = to_header_guard(
         this_include_header_path)
     header_text, cpp_text = self.render_templates(include_paths,
                                                   header_template,
                                                   cpp_template,
                                                   template_context)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
예제 #8
0
 def generate_code_internal(self, callback_function, path):
     self.typedef_resolver.resolve(callback_function,
                                   callback_function.name)
     header_template = self.jinja_env.get_template(
         'callback_function.h.tmpl')
     cpp_template = self.jinja_env.get_template(
         'callback_function.cpp.tmpl')
     template_context = v8_callback_function.callback_function_context(
         callback_function)
     if not is_testing_target(path):
         template_context[
             'exported'] = self.info_provider.specifier_for_export
         template_context['header_includes'].append(
             self.info_provider.include_path_for_export)
     template_context['header_includes'] = normalize_and_sort_includes(
         template_context['header_includes'])
     template_context['code_generator'] = MODULE_PYNAME
     header_text = render_template(header_template, template_context)
     cpp_text = render_template(cpp_template, template_context)
     header_path = posixpath.join(self.output_dir,
                                  '%s.h' % callback_function.name)
     cpp_path = posixpath.join(self.output_dir,
                               '%s.cpp' % callback_function.name)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
    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/dom_typed_array.h')
        elif interface.is_callback:
            if len(interface.constants) > 0:  # legacy callback interface
                includes.add(interface_info['include_path'])
        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),
        )
예제 #10
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_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)
        header_path, cpp_path = self.output_paths(interface_name)
        return (
            (header_path, header_text),
            (cpp_path, cpp_text),
        )
예제 #11
0
    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
        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)
        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'])
        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),
        )
예제 #12
0
    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),
        )
예제 #13
0
 def generate_code_internal(self, callback_function, path):
     self.typedef_resolver.resolve(callback_function, callback_function.name)
     header_template = self.jinja_env.get_template("callback_function.h.tmpl")
     cpp_template = self.jinja_env.get_template("callback_function.cpp.tmpl")
     template_context = v8_callback_function.callback_function_context(callback_function)
     if not is_testing_target(path):
         template_context["exported"] = self.info_provider.specifier_for_export
         template_context["header_includes"].append(self.info_provider.include_path_for_export)
     template_context["header_includes"] = normalize_and_sort_includes(template_context["header_includes"])
     template_context["code_generator"] = MODULE_PYNAME
     header_text = header_template.render(template_context)
     cpp_text = cpp_template.render(template_context)
     header_path = posixpath.join(self.output_dir, "%s.h" % callback_function.name)
     cpp_path = posixpath.join(self.output_dir, "%s.cpp" % callback_function.name)
     return ((header_path, header_text), (cpp_path, cpp_text))
예제 #14
0
 def generate_code_internal(self, definitions, definition_name):
     if not definition_name in definitions.dictionaries:
         raise ValueError("%s is not an IDL dictionary" % definition_name)
     interfaces_info = self.info_provider.interfaces_info
     dictionary = definitions.dictionaries[definition_name]
     interface_info = interfaces_info[definition_name]
     header_template = self.jinja_env.get_template("dictionary_impl.h.tmpl")
     cpp_template = self.jinja_env.get_template("dictionary_impl.cpp.tmpl")
     template_context = v8_dictionary.dictionary_impl_context(dictionary, interfaces_info)
     include_paths = interface_info.get("dependencies_include_paths")
     if not is_testing_target(interface_info.get("full_path")):
         template_context["exported"] = self.info_provider.specifier_for_export
         template_context["header_includes"].add(self.info_provider.include_path_for_export)
     template_context["header_includes"].update(interface_info.get("additional_header_includes", []))
     header_text, cpp_text = self.render_template(include_paths, header_template, cpp_template, template_context)
     header_path, cpp_path = self.output_paths(cpp_name(dictionary), interface_info)
     return ((header_path, header_text), (cpp_path, cpp_text))
예제 #15
0
 def generate_dictionary_code(self, definitions, dictionary_name, dictionary):
     # pylint: disable=unused-argument
     interfaces_info = self.info_provider.interfaces_info
     header_template = self.jinja_env.get_template("dictionary_v8.h.tmpl")
     cpp_template = self.jinja_env.get_template("dictionary_v8.cpp.tmpl")
     interface_info = interfaces_info[dictionary_name]
     template_context = v8_dictionary.dictionary_context(dictionary, interfaces_info)
     include_paths = interface_info.get("dependencies_include_paths")
     # Add the include for interface itself
     if interface_info["include_path"]:
         template_context["header_includes"].add(interface_info["include_path"])
     if not is_testing_target(interface_info.get("full_path")):
         template_context["header_includes"].add(self.info_provider.include_path_for_export)
         template_context["exported"] = self.info_provider.specifier_for_export
     header_text, cpp_text = self.render_template(include_paths, header_template, cpp_template, template_context)
     header_path, cpp_path = self.output_paths(dictionary_name)
     return ((header_path, header_text), (cpp_path, cpp_text))
예제 #16
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
        if 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/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 = self.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))
예제 #17
0
 def generate_dictionary_code(self, definitions, dictionary_name,
                              dictionary):
     interfaces_info = self.info_provider.interfaces_info
     header_template = self.jinja_env.get_template('dictionary_v8.h')
     cpp_template = self.jinja_env.get_template('dictionary_v8.cpp')
     interface_info = interfaces_info[dictionary_name]
     template_context = v8_dictionary.dictionary_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     # Add the include for interface itself
     if interface_info['include_path']:
         template_context['header_includes'].add(interface_info['include_path'])
     if not is_testing_target(interface_info.get('full_path')):
         template_context['header_includes'].add(self.info_provider.include_path_for_export)
         template_context['exported'] = self.info_provider.specifier_for_export
     header_text, cpp_text = render_template(
         include_paths, header_template, cpp_template, template_context)
     header_path, cpp_path = self.output_paths(dictionary_name)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
예제 #18
0
 def generate_code_internal(self, definitions, definition_name):
     if not definition_name in definitions.dictionaries:
         raise ValueError('%s is not an IDL dictionary')
     interfaces_info = self.info_provider.interfaces_info
     dictionary = definitions.dictionaries[definition_name]
     interface_info = interfaces_info[definition_name]
     header_template = self.jinja_env.get_template('dictionary_impl.h')
     cpp_template = self.jinja_env.get_template('dictionary_impl.cpp')
     template_context = v8_dictionary.dictionary_impl_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     if not is_testing_target(interface_info.get('full_path')):
         template_context['exported'] = self.info_provider.specifier_for_export
         template_context['header_includes'].add(self.info_provider.include_path_for_export)
     template_context['header_includes'].update(
         interface_info.get('additional_header_includes', []))
     header_text, cpp_text = render_template(
         include_paths, header_template, cpp_template, template_context)
     header_path, cpp_path = self.output_paths(
         cpp_name(dictionary), interface_info)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )