Commit 792823f3 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Rename binding_header_basename as binding_header_filename

"basename" does not include exntensions, but the function outputs
filename including ".h" extension.
This CL rename the function and clean up around its use cases.

Bug: None
Change-Id: Ie04b198f5c8c34e206c5909089104258c88c92ab
Reviewed-on: https://chromium-review.googlesource.com/1023070Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553469}
parent b85cc453
......@@ -152,8 +152,8 @@ class CodeGeneratorV8Base(CodeGeneratorBase):
# This should be implemented in subclasses.
raise NotImplementedError()
def get_output_basename(self, definition_name, ext, prefix=None):
return build_basename(definition_name, prefix=prefix, ext=ext)
def get_output_filename(self, definition_name, ext, prefix=None):
return build_basename(definition_name, prefix=prefix) + ext
class CodeGeneratorV8(CodeGeneratorV8Base):
......@@ -161,9 +161,9 @@ class CodeGeneratorV8(CodeGeneratorV8Base):
CodeGeneratorV8Base.__init__(self, info_provider, cache_dir, output_dir)
def output_paths(self, definition_name):
header_path = posixpath.join(self.output_dir, self.get_output_basename(
header_path = posixpath.join(self.output_dir, self.get_output_filename(
definition_name, '.h', prefix='v8_'))
cpp_path = posixpath.join(self.output_dir, self.get_output_basename(
cpp_path = posixpath.join(self.output_dir, self.get_output_filename(
definition_name, '.cc', prefix='v8_'))
return header_path, cpp_path
......@@ -225,7 +225,7 @@ class CodeGeneratorV8(CodeGeneratorV8Base):
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)
template_context['this_include_header_path'] = 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(
......@@ -252,7 +252,7 @@ class CodeGeneratorV8(CodeGeneratorV8Base):
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)
template_context['this_include_header_name'] = posixpath.basename(header_path)
template_context['this_include_header_path'] = posixpath.basename(header_path)
header_text, cpp_text = self.render_template(
include_paths, header_template, cpp_template, template_context)
return (
......@@ -269,9 +269,9 @@ class CodeGeneratorDictionaryImpl(CodeGeneratorV8Base):
output_dir = posixpath.join(self.output_dir,
interface_info['relative_dir'])
header_path = posixpath.join(output_dir,
self.get_output_basename(definition_name, '.h'))
self.get_output_filename(definition_name, '.h'))
cpp_path = posixpath.join(output_dir,
self.get_output_basename(definition_name, '.cc'))
self.get_output_filename(definition_name, '.cc'))
return header_path, cpp_path
def generate_code_internal(self, definitions, definition_name):
......@@ -292,7 +292,7 @@ class CodeGeneratorDictionaryImpl(CodeGeneratorV8Base):
interface_info.get('additional_header_includes', []))
header_path, cpp_path = self.output_paths(
cpp_name(dictionary), interface_info)
template_context['this_include_header_name'] = posixpath.basename(header_path)
template_context['this_include_header_path'] = posixpath.basename(header_path)
header_text, cpp_text = self.render_template(
include_paths, header_template, cpp_template, template_context)
return (
......@@ -333,7 +333,7 @@ class CodeGeneratorUnionType(CodeGeneratorBase):
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
template_context['this_include_header_path'] = snake_base_name + '.h'
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)
......
......@@ -93,8 +93,8 @@ def main():
for meta_data in meta_data_list]
interface_names.sort()
includes = ['#include "bindings/modules/v8/%s"' %
build_basename(interface_name, ext='.h')
includes = ['#include "bindings/modules/v8/%s.h"' %
build_basename(interface_name)
for interface_name in interface_names]
initialize_calls = [' %s::initialize();' % interface_name
for interface_name in interface_names]
......
......@@ -19,7 +19,7 @@ from code_generator import (initialize_jinja_env, normalize_and_sort_includes,
from idl_reader import IdlReader
from utilities import (create_component_info_provider, write_file,
idl_filename_to_component)
from v8_utilities import (binding_header_basename, v8_class_name,
from v8_utilities import (binding_header_filename, v8_class_name,
v8_class_name_or_partial, uncapitalize)
# Make sure extension is .py, not .pyc or .pyo, so doesn't depend on caching
......@@ -127,12 +127,12 @@ def origin_trial_features_info(info_provider, reader, idl_filenames, target_comp
parent_interface_info.get('full_path'))
if interface.is_partial and target_component != parent_component:
includes.add('bindings/%s/v8/%s' %
(parent_component, binding_header_basename(interface.name)))
(parent_component, binding_header_filename(interface.name)))
includes.add('bindings/%s/v8/%s' %
(target_component, binding_header_basename(interface.name + 'Partial')))
(target_component, binding_header_filename(interface.name + 'Partial')))
else:
includes.add('bindings/%s/v8/%s' %
(target_component, binding_header_basename(interface.name)))
(target_component, binding_header_filename(interface.name)))
# If this is a partial interface in the same component as
# its parent, then treat it as a non-partial interface.
interface.is_partial = False
......
......@@ -192,13 +192,13 @@ class ExternalReferenceTableGenerator(object):
interfaces = []
for name in sorted(self._interface_contexts):
interfaces.append(self._interface_contexts[name])
header_name = 'v8_context_snapshot_external_references.h'
header_path = 'bindings/modules/v8/v8_context_snapshot_external_references.h'
include_files = list(self._include_files)
return {
'class': 'V8ContextSnapshotExternalReferences',
'interfaces': interfaces,
'include_files': sorted(include_files),
'this_include_header_name': header_name,
'this_include_header_path': header_path,
'code_generator': os.path.basename(__file__),
'jinja_template_filename': TEMPLATE_FILE
}
......
......@@ -45,7 +45,7 @@ def callback_function_context(callback_function):
'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES),
'idl_type': idl_type_str,
'return_cpp_type': idl_type.cpp_type,
'this_include_header_name': to_snake_case('V8%s' % callback_function.name),
'this_include_header_path': to_snake_case('V8%s' % callback_function.name) + '.h',
}
if idl_type_str != 'void':
......
......@@ -45,7 +45,7 @@ from v8_globals import includes
import v8_methods
import v8_types
import v8_utilities
from v8_utilities import (binding_header_basename, context_enabled_feature_name,
from v8_utilities import (binding_header_filename, context_enabled_feature_name,
cpp_name_or_partial, cpp_name,
has_extended_attribute_value,
runtime_enabled_feature_name,
......@@ -209,7 +209,7 @@ def interface_context(interface, interfaces):
parent_interface = None
is_event_target = False
# partial interface needs the definition of its original interface.
includes.add('bindings/core/v8/%s' % binding_header_basename(interface.name))
includes.add('bindings/core/v8/%s' % binding_header_filename(interface.name))
else:
parent_interface = interface.parent
if parent_interface:
......
......@@ -50,7 +50,7 @@ from idl_types import IdlUnionType
from utilities import to_snake_case
import v8_attributes # for IdlType.constructor_type_name
from v8_globals import includes
from v8_utilities import binding_header_basename, extended_attribute_value_contains
from v8_utilities import binding_header_filename, extended_attribute_value_contains
################################################################################
......@@ -445,7 +445,7 @@ def includes_for_type(idl_type, extended_attributes=None):
return INCLUDES_FOR_TYPE[base_idl_type]
if base_idl_type in TYPED_ARRAY_TYPES:
return INCLUDES_FOR_TYPE['ArrayBufferView'].union(
set(['bindings/%s/v8/%s' % (component_dir[base_idl_type], binding_header_basename(base_idl_type))])
set(['bindings/%s/v8/%s' % (component_dir[base_idl_type], binding_header_filename(base_idl_type))])
)
if idl_type.is_basic_type:
return set(['bindings/core/v8/idl_types.h',
......@@ -464,11 +464,11 @@ def includes_for_type(idl_type, extended_attributes=None):
return set()
if idl_type.is_callback_function:
component = IdlType.callback_functions[base_idl_type]['component_dir']
return set(['bindings/%s/v8/%s' % (component, binding_header_basename(base_idl_type))])
return set(['bindings/%s/v8/%s' % (component, binding_header_filename(base_idl_type))])
if base_idl_type not in component_dir:
return set()
return set(['bindings/%s/v8/%s' % (component_dir[base_idl_type],
binding_header_basename(base_idl_type))])
binding_header_filename(base_idl_type))])
IdlType.includes_for_type = includes_for_type
......
......@@ -148,22 +148,19 @@ def v8_class_name_or_partial(interface):
return class_name
def build_basename(name, prefix=None, ext=None):
def build_basename(name, prefix=None):
basename = to_snake_case(name)
if prefix:
basename = prefix + basename
if not ext:
return basename
return basename + ext
def binding_header_basename(name):
"""Returns a binding header basename including an extension for the
specified interface name.
def binding_header_filename(name):
"""Returns a binding header filename for the specified interface name.
E.g. 'NodeList' -> 'v8_node_list.h'
"""
return build_basename(name, prefix='v8_', ext='.h')
return build_basename(name, prefix='v8_') + '.h'
################################################################################
......
......@@ -3,7 +3,7 @@
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}.h"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes %}
#include "{{filename}}"
......
......@@ -2,7 +2,7 @@
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes %}
#include "{{filename}}"
......
......@@ -2,7 +2,7 @@
{% filter format_blink_cpp_source_code %}
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes %}
#include "{{filename}}"
......
......@@ -2,7 +2,7 @@
{% from 'utilities.cpp.tmpl' import declare_enum_validation_variable %}
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes if filename != '%s.h' % v8_class %}
#include "{{filename}}"
......
......@@ -2,7 +2,7 @@
{% include 'copyright_block.txt' %}
#include "bindings/modules/v8/{{this_include_header_name}}"
#include "{{this_include_header_path}}"
#include <cstdint>
......
{% filter format_blink_cpp_source_code %}
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
#include "{{filename}}"
......
{% filter format_blink_cpp_source_code %}
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes %}
#include "{{filename}}"
......
......@@ -21,7 +21,7 @@ if (V8{{member.type_name}}::hasInstance(v8Value, isolate)) {
{#############################################################################}
{% filter format_blink_cpp_source_code %}
{% include 'copyright_block.txt' %}
#include "{{this_include_header_name}}.h"
#include "{{this_include_header_path}}"
{% for filename in cpp_includes %}
#include "{{filename}}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment