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),
        )
 def _generate_container_code(self, union_type):
     union_type = union_type.resolve_typedefs(self.typedefs)
     header_template = self.jinja_env.get_template('union_container.h.tmpl')
     cpp_template = self.jinja_env.get_template('union_container.cpp.tmpl')
     template_context = v8_union.container_context(union_type,
                                                   self.info_provider)
     template_context['header_includes'].append(
         self.info_provider.include_path_for_export)
     template_context['header_includes'] = normalize_and_sort_includes(
         template_context['header_includes'],
         self.snake_case_generated_files)
     template_context['cpp_includes'] = normalize_and_sort_includes(
         template_context['cpp_includes'], self.snake_case_generated_files)
     template_context['code_generator'] = self.generator_name
     template_context['exported'] = self.info_provider.specifier_for_export
     snake_base_name = to_snake_case(shorten_union_name(union_type))
     template_context['this_include_header_name'] = snake_base_name
     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' % snake_base_name)
     cpp_path = posixpath.join(self.output_dir, '%s.cc' % snake_base_name)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
Example #3
0
 def build(self):
     if 'cpp_includes' in self.result:
         self.result['cpp_includes'] = set(
             normalize_and_sort_includes(self.result['cpp_includes']))
     if 'header_includes' in self.result:
         self.result['header_includes'] = set(
             normalize_and_sort_includes(self.result['header_includes']))
     return self.result
Example #4
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),
     )
Example #5
0
def origin_trial_features_context(generator_name, feature_info):
    context = {'code_generator': generator_name}

    # Unpack the feature info tuple.
    features_for_type, types_for_feature, include_files = feature_info

    # Add includes needed for cpp code and normalize.
    include_files.update([
        'core/context_features/context_feature_settings.h',
        'core/execution_context/execution_context.h',
        'core/frame/frame.h',
        'core/origin_trials/origin_trials.h',
        'platform/bindings/origin_trial_features.h',
        'platform/bindings/script_state.h',
        'platform/bindings/v8_per_context_data.h',
        'platform/runtime_enabled_features.h',
        # TODO(iclelland): Remove the need to explicitly include this; it is
        # here because the ContextFeatureSettings code needs it.
        'bindings/core/v8/v8_window.h',
    ])
    context['includes'] = normalize_and_sort_includes(include_files)

    # For each interface, collect a list of bindings installation functions to
    # call, organized by conditional feature.
    context['installers_by_interface'] = [{
        'name':
        interface_info.name,
        'is_global':
        interface_info.is_global,
        'v8_class':
        interface_info.v8_class,
        'installers':
        get_install_functions([interface_info], feature_names)
    } for interface_info, feature_names in features_for_type.items()]
    context['installers_by_interface'].sort(key=lambda x: x['name'])

    # For each conditional feature, collect a list of bindings installation
    # functions to call, organized by interface.
    context['installers_by_feature'] = [{
        'name':
        feature_name,
        'name_constant':
        'OriginTrialFeature::k%s' % feature_name,
        'installers':
        get_install_functions(interfaces, [feature_name])
    } for feature_name, interfaces in types_for_feature.items()]
    context['installers_by_feature'].sort(key=lambda x: x['name'])

    return context
Example #6
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))
Example #7
0
 def _generate_container_code(self, union_type):
     header_template = self.jinja_env.get_template("union_container.h.tmpl")
     cpp_template = self.jinja_env.get_template("union_container.cpp.tmpl")
     template_context = v8_union.container_context(union_type, self.info_provider.interfaces_info)
     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"] = self.generator_name
     template_context["exported"] = self.info_provider.specifier_for_export
     name = shorten_union_name(union_type)
     template_context["this_include_header_name"] = name
     header_text = header_template.render(template_context)
     cpp_text = cpp_template.render(template_context)
     header_path = posixpath.join(self.output_dir, "%s.h" % name)
     cpp_path = posixpath.join(self.output_dir, "%s.cpp" % name)
     return ((header_path, header_text), (cpp_path, cpp_text))
def conditional_features_context(generator_name, feature_info):
    context = {'code_generator': generator_name}

    # Unpack the feature info tuple.
    features_for_type, types_for_feature, includes = feature_info

    # Add includes needed for cpp code and normalize.
    includes.update([
        "core/context_features/ContextFeatureSettings.h",
        "core/dom/ExecutionContext.h",
        "core/frame/Frame.h",
        "core/origin_trials/OriginTrials.h",
        "platform/bindings/ConditionalFeatures.h",
        "platform/bindings/ScriptState.h",
        # TODO(iclelland): Remove the need to explicitly include this; it is
        # here because the ContextFeatureSettings code needs it.
        "bindings/core/v8/V8Window.h",
    ])
    context['includes'] = normalize_and_sort_includes(includes)

    # For each interface, collect a list of bindings installation functions to
    # call, organized by conditional feature.
    context['installers_by_interface'] = [{
        "name":
        interface_info.name,
        "is_global":
        interface_info.is_global,
        "v8_class":
        interface_info.v8_class,
        "installers":
        get_install_functions([interface_info], feature_names)
    } for interface_info, feature_names in features_for_type.items()]
    context['installers_by_interface'].sort(key=lambda x: x['name'])

    # For each conditional feature, collect a list of bindings installation
    # functions to call, organized by interface.
    context['installers_by_feature'] = [{
        "name":
        feature_name,
        "name_constant":
        "OriginTrials::k%sTrialName" % feature_name,
        "installers":
        get_install_functions(interfaces, [feature_name])
    } for feature_name, interfaces in types_for_feature.items()]
    context['installers_by_feature'].sort(key=lambda x: x['name'])

    return context
 def _generate_container_code(self, union_type):
     header_template = self.jinja_env.get_template('union_container.h.tmpl')
     cpp_template = self.jinja_env.get_template('union_container.cpp.tmpl')
     template_context = v8_union.container_context(
         union_type, self.info_provider.interfaces_info)
     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'] = self.generator_name
     template_context['exported'] = self.info_provider.specifier_for_export
     name = shorten_union_name(union_type)
     template_context['this_include_header_name'] = name
     header_text = header_template.render(template_context)
     cpp_text = cpp_template.render(template_context)
     header_path = posixpath.join(self.output_dir, '%s.h' % name)
     cpp_path = posixpath.join(self.output_dir, '%s.cpp' % name)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
def conditional_features_context(generator_name, feature_info):
    context = {'code_generator': generator_name}

    # Unpack the feature info tuple.
    features_for_type, types_for_feature, includes = feature_info

    # Add includes needed for cpp code and normalize.
    includes.update([
        "core/context_features/ContextFeatureSettings.h",
        "core/dom/ExecutionContext.h",
        "core/frame/Frame.h",
        "core/origin_trials/OriginTrials.h",
        "platform/bindings/ConditionalFeatures.h",
        "platform/bindings/ScriptState.h",
        # TODO(iclelland): Remove the need to explicitly include this; it is
        # here because the ContextFeatureSettings code needs it.
        "bindings/core/v8/V8Window.h",
    ])
    context['includes'] = normalize_and_sort_includes(includes)

    # For each interface, collect a list of bindings installation functions to
    # call, organized by conditional feature.
    context['installers_by_interface'] = [
        {"name": interface_info.name,
         "is_global": interface_info.is_global,
         "v8_class": interface_info.v8_class,
         "installers": get_install_functions([interface_info], feature_names)}
        for interface_info, feature_names in features_for_type.items()]
    context['installers_by_interface'].sort(key=lambda x: x['name'])

    # For each conditional feature, collect a list of bindings installation
    # functions to call, organized by interface.
    context['installers_by_feature'] = [
        {"name": feature_name,
         "name_constant": "OriginTrials::k%sTrialName" % feature_name,
         "installers": get_install_functions(interfaces, [feature_name])}
        for feature_name, interfaces in types_for_feature.items()]
    context['installers_by_feature'].sort(key=lambda x: x['name'])

    return context
Example #11
0
 def _generate_container_code(self, union_type):
     union_type = union_type.resolve_typedefs(self.typedefs)
     header_template = self.jinja_env.get_template('union_container.h.tmpl')
     cpp_template = self.jinja_env.get_template('union_container.cpp.tmpl')
     template_context = v8_union.container_context(
         union_type, self.info_provider)
     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'] = self.generator_name
     template_context['exported'] = self.info_provider.specifier_for_export
     name = shorten_union_name(union_type)
     template_context['this_include_header_name'] = name
     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' % name)
     cpp_path = posixpath.join(self.output_dir, '%s.cpp' % name)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )