Commit 2ecdea19 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Remove cross-component exports for testing

Generated code for testing is not going to be part of
'core' nor 'modules' linkage, so such code must not use
CORE_EXPORT nor MODULES_EXPORT.

Bug: 839389
Change-Id: I748d3da2cf7b10805153f80dc8a48d5c8abb05be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2234040
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775958}
parent 12d362f3
......@@ -25,11 +25,8 @@ class CodeGenAccumulator(object):
def include_headers(self):
return self._include_headers
def add_include_header(self, header):
self._include_headers.add(header)
def add_include_headers(self, headers):
self._include_headers.update(headers)
self._include_headers.update(filter(None, headers))
@staticmethod
def require_include_headers(headers):
......@@ -39,11 +36,8 @@ class CodeGenAccumulator(object):
def class_decls(self):
return self._class_decls
def add_class_decl(self, class_name):
self._class_decls.add(class_name)
def add_class_decls(self, class_names):
self._class_decls.update(class_names)
self._class_decls.update(filter(None, class_names))
@staticmethod
def require_class_decls(class_names):
......@@ -53,11 +47,8 @@ class CodeGenAccumulator(object):
def struct_decls(self):
return self._struct_decls
def add_struct_decl(self, struct_name):
self._struct_decls.add(struct_name)
def add_struct_decls(self, struct_names):
self._struct_decls.update(struct_names)
self._struct_decls.update(filter(None, struct_names))
@staticmethod
def require_struct_decls(struct_names):
......
......@@ -59,15 +59,21 @@ def make_header_include_directives(accumulator):
return LiteralNode(HeaderIncludeDirectives(accumulator))
def component_export(component):
def component_export(component, for_testing):
assert isinstance(component, web_idl.Component)
assert isinstance(for_testing, bool)
if for_testing:
return ""
return name_style.macro(component, "EXPORT")
def component_export_header(component):
def component_export_header(component, for_testing):
assert isinstance(component, web_idl.Component)
assert isinstance(for_testing, bool)
if for_testing:
return None
if component == "core":
return "third_party/blink/renderer/core/core_export.h"
elif component == "modules":
......
......@@ -120,6 +120,7 @@ def _make_include_headers(cg_context):
assert isinstance(cg_context, CodeGenContext)
dictionary = cg_context.dictionary
for_testing = dictionary.code_generator_info.for_testing
header_includes = set()
source_includes = set()
......@@ -132,7 +133,7 @@ def _make_include_headers(cg_context):
"third_party/blink/renderer/platform/bindings/dictionary_base.h")
header_includes.update([
component_export_header(dictionary.components[0]),
component_export_header(dictionary.components[0], for_testing),
"third_party/blink/renderer/bindings/core/v8/generated_code_helper.h",
"third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h",
"v8/include/v8.h",
......@@ -856,9 +857,12 @@ def make_dict_trace_func(cg_context):
def generate_dictionary(dictionary):
assert isinstance(dictionary, web_idl.Dictionary)
assert len(dictionary.components) == 1, (
"We don't support partial dictionaries across components yet.")
component = dictionary.components[0]
for_testing = dictionary.code_generator_info.for_testing
path_manager = PathManager(dictionary)
class_name = name_style.class_(blink_class_name(dictionary))
......@@ -889,10 +893,10 @@ def generate_dictionary(dictionary):
source_blink_ns = CxxNamespaceNode(name_style.namespace("blink"))
# Class definitions
class_def = CxxClassDefNode(
cg_context.class_name,
base_class_names=[cg_context.base_class_name],
export=component_export(component))
class_def = CxxClassDefNode(cg_context.class_name,
base_class_names=[cg_context.base_class_name],
export=component_export(
component, for_testing))
class_def.set_base_template_vars(cg_context.template_bindings())
class_def.top_section.append(
TextNode("using BaseClass = ${base_class_name};"))
......
......@@ -237,9 +237,12 @@ def make_enum_string_table(cg_context):
def generate_enumeration(enumeration):
assert isinstance(enumeration, web_idl.Enumeration)
path_manager = PathManager(enumeration)
assert path_manager.api_component == path_manager.impl_component
api_component = path_manager.api_component
for_testing = enumeration.code_generator_info.for_testing
# Class names
class_name = blink_class_name(enumeration)
......@@ -266,11 +269,11 @@ def generate_enumeration(enumeration):
source_blink_ns = CxxNamespaceNode(name_style.namespace("blink"))
# Class definition
class_def = CxxClassDefNode(
cg_context.class_name,
base_class_names=["bindings::EnumerationBase"],
final=True,
export=component_export(api_component))
class_def = CxxClassDefNode(cg_context.class_name,
base_class_names=["bindings::EnumerationBase"],
final=True,
export=component_export(
api_component, for_testing))
class_def.set_base_template_vars(cg_context.template_bindings())
# Implementation parts
......@@ -311,7 +314,7 @@ def generate_enumeration(enumeration):
EmptyNode(),
])
header_node.accumulator.add_include_headers([
component_export_header(api_component),
component_export_header(api_component, for_testing),
"third_party/blink/renderer/bindings/core/v8/generated_code_helper.h",
"third_party/blink/renderer/platform/bindings/enumeration_base.h",
])
......
......@@ -6016,6 +6016,7 @@ def generate_interface(interface):
api_component = path_manager.api_component
impl_component = path_manager.impl_component
is_cross_components = path_manager.is_cross_components
for_testing = interface.code_generator_info.for_testing
# Class names
api_class_name = v8_bridge_class_name(interface)
......@@ -6069,15 +6070,15 @@ def generate_interface(interface):
blink_class_name(interface)),
],
final=True,
export=component_export(api_component))
export=component_export(api_component, for_testing))
api_class_def.set_base_template_vars(cg_context.template_bindings())
api_class_def.bottom_section.append(
TextNode("friend class {};".format(blink_class_name(interface))))
if is_cross_components:
impl_class_def = CxxClassDefNode(
impl_class_name,
final=True,
export=component_export(impl_component))
impl_class_def = CxxClassDefNode(impl_class_name,
final=True,
export=component_export(
impl_component, for_testing))
impl_class_def.set_base_template_vars(cg_context.template_bindings())
api_class_def.public_section.extend([
TextNode("// Cross-component implementation class"),
......@@ -6394,19 +6395,19 @@ def generate_interface(interface):
])
api_header_node.accumulator.add_include_headers([
interface.code_generator_info.blink_headers[0],
component_export_header(api_component),
component_export_header(api_component, for_testing),
"third_party/blink/renderer/platform/bindings/v8_interface_bridge.h",
])
api_source_node.accumulator.add_include_headers([
"third_party/blink/renderer/bindings/core/v8/v8_dom_configuration.h",
])
if interface.inherited:
api_source_node.accumulator.add_include_header(
PathManager(interface.inherited).api_path(ext="h"))
api_source_node.accumulator.add_include_headers(
[PathManager(interface.inherited).api_path(ext="h")])
if is_cross_components:
impl_header_node.accumulator.add_include_headers([
api_header_path,
component_export_header(impl_component),
component_export_header(impl_component, for_testing),
])
impl_source_node.accumulator.add_include_headers([
"third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h",
......@@ -6570,7 +6571,7 @@ def generate_install_properties_per_feature(web_idl_database,
return_type="void")
# Assemble the parts.
header_node.accumulator.add_class_decl("ScriptState")
header_node.accumulator.add_class_decls(["ScriptState"])
header_node.accumulator.add_include_headers([
"third_party/blink/renderer/platform/runtime_enabled_features.h",
])
......@@ -6685,8 +6686,8 @@ using InstallFuncType =
for interface in set_of_interfaces:
path_manager = PathManager(interface)
source_node.accumulator.add_include_header(
path_manager.api_path(ext="h"))
source_node.accumulator.add_include_headers(
[path_manager.api_path(ext="h")])
# The helper function
globals = filter(lambda x: "Global" in x.extended_attributes,
......@@ -6826,8 +6827,8 @@ def generate_init_idl_interfaces(web_idl_database,
path_manager = PathManager(interface)
if path_manager.is_cross_components:
source_node.accumulator.add_include_header(
path_manager.impl_path(ext="h"))
source_node.accumulator.add_include_headers(
[path_manager.impl_path(ext="h")])
class_name = v8_bridge_class_name(interface)
init_calls.append(_format("{}::Impl::Init();", class_name))
......
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