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),
        )
Beispiel #2
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),
     )
Beispiel #3
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))