Commit b08e081d authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Make generated interface compilable (5 of N)

Resolves header include issues.

Bug: 839389
Change-Id: I705d5265a0be2efbe917b408ffb3f7f89cfcd839
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032694Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737299}
parent 746461d1
...@@ -184,13 +184,8 @@ def bind_callback_local_vars(code_node, cg_context): ...@@ -184,13 +184,8 @@ def bind_callback_local_vars(code_node, cg_context):
"\"${class_like.identifier}\";")), "\"${class_like.identifier}\";")),
S("current_context", ("v8::Local<v8::Context> ${current_context} = " S("current_context", ("v8::Local<v8::Context> ${current_context} = "
"${isolate}->GetCurrentContext();")), "${isolate}->GetCurrentContext();")),
S("current_execution_context",
("ExecutionContext* ${current_execution_context} = "
"ExecutionContext::From(${current_script_state});")),
S("current_script_state", ("ScriptState* ${current_script_state} = " S("current_script_state", ("ScriptState* ${current_script_state} = "
"ScriptState::From(${current_context});")), "ScriptState::From(${current_context});")),
S("execution_context", ("ExecutionContext* ${execution_context} = "
"ExecutionContext::From(${script_state});")),
S("isolate", "v8::Isolate* ${isolate} = ${info}.GetIsolate();"), S("isolate", "v8::Isolate* ${isolate} = ${info}.GetIsolate();"),
S("per_context_data", ("V8PerContextData* ${per_context_data} = " S("per_context_data", ("V8PerContextData* ${per_context_data} = "
"${script_state}->PerContextData();")), "${script_state}->PerContextData();")),
...@@ -226,6 +221,15 @@ def bind_callback_local_vars(code_node, cg_context): ...@@ -226,6 +221,15 @@ def bind_callback_local_vars(code_node, cg_context):
if is_receiver_context else "${current_script_state}") if is_receiver_context else "${current_script_state}")
local_vars.append(S("script_state", _format(pattern, _1=_1))) local_vars.append(S("script_state", _format(pattern, _1=_1)))
# execution_context
node = S("execution_context", ("ExecutionContext* ${execution_context} = "
"ExecutionContext::From(${script_state});"))
node.accumulate(
CodeGenAccumulator.require_include_headers([
"third_party/blink/renderer/core/execution_context/execution_context.h"
]))
local_vars.append(node)
# exception_state_context_type # exception_state_context_type
pattern = ( pattern = (
"const ExceptionState::ContextType ${exception_state_context_type} = " "const ExceptionState::ContextType ${exception_state_context_type} = "
...@@ -672,8 +676,8 @@ def make_check_security_of_return_value(cg_context): ...@@ -672,8 +676,8 @@ def make_check_security_of_return_value(cg_context):
"WebFeature::{}", "WebFeature::{}",
name_style.constant("CrossOrigin", cg_context.class_like.identifier, name_style.constant("CrossOrigin", cg_context.class_like.identifier,
cg_context.member_like.identifier)) cg_context.member_like.identifier))
use_counter = _format( use_counter = _format("UseCounter::Count(${execution_context}, {});",
"UseCounter::Count(${current_execution_context}, {});", web_feature) web_feature)
cond = T("!BindingSecurity::ShouldAllowAccessTo(" cond = T("!BindingSecurity::ShouldAllowAccessTo("
"ToLocalDOMWindow(${current_context}), ${return_value}, " "ToLocalDOMWindow(${current_context}), ${return_value}, "
"BindingSecurity::ErrorReportOption::kDoNotReport)") "BindingSecurity::ErrorReportOption::kDoNotReport)")
...@@ -1656,8 +1660,6 @@ def bind_installer_local_vars(code_node, cg_context): ...@@ -1656,8 +1660,6 @@ def bind_installer_local_vars(code_node, cg_context):
local_vars = [] local_vars = []
local_vars.extend([ local_vars.extend([
S("execution_context", ("ExecutionContext* ${execution_context} = "
"ExecutionContext::From(${script_state});")),
S("instance_template", S("instance_template",
("v8::Local<v8::ObjectTemplate> ${instance_template} = " ("v8::Local<v8::ObjectTemplate> ${instance_template} = "
"${interface_template}->InstanceTemplate();")), "${interface_template}->InstanceTemplate();")),
...@@ -1681,6 +1683,16 @@ def bind_installer_local_vars(code_node, cg_context): ...@@ -1681,6 +1683,16 @@ def bind_installer_local_vars(code_node, cg_context):
"${class_name}::GetWrapperTypeInfo();")), "${class_name}::GetWrapperTypeInfo();")),
]) ])
# execution_context
node = S("execution_context", ("ExecutionContext* ${execution_context} = "
"ExecutionContext::From(${script_state});"))
node.accumulate(
CodeGenAccumulator.require_include_headers([
"third_party/blink/renderer/core/execution_context/execution_context.h"
]))
local_vars.append(node)
# parent_interface_template
pattern = ( pattern = (
"v8::Local<v8::FunctionTemplate> ${parent_interface_template}{_1};") "v8::Local<v8::FunctionTemplate> ${parent_interface_template}{_1};")
_1 = (" = ${wrapper_type_info}->parent_class->dom_template_function" _1 = (" = ${wrapper_type_info}->parent_class->dom_template_function"
...@@ -2754,6 +2766,8 @@ def _collect_include_headers(interface): ...@@ -2754,6 +2766,8 @@ def _collect_include_headers(interface):
type_def_obj = idl_type.type_definition_object type_def_obj = idl_type.type_definition_object
if type_def_obj is not None: if type_def_obj is not None:
headers.add(PathManager(type_def_obj).api_path(ext="h")) headers.add(PathManager(type_def_obj).api_path(ext="h"))
if isinstance(type_def_obj, web_idl.Interface):
headers.add(PathManager(type_def_obj).blink_path(ext="h"))
return return
union_def_obj = idl_type.union_definition_object union_def_obj = idl_type.union_definition_object
if union_def_obj is not None: if union_def_obj is not None:
......
...@@ -115,13 +115,20 @@ class PathManager(object): ...@@ -115,13 +115,20 @@ class PathManager(object):
self._api_dir = self._component_reldirs[self._api_component] self._api_dir = self._component_reldirs[self._api_component]
self._impl_dir = self._component_reldirs[self._impl_component] self._impl_dir = self._component_reldirs[self._impl_component]
self._v8_bind_basename = name_style.file("v8", self._api_basename = name_style.file("v8", idl_definition.identifier)
idl_definition.identifier) self._impl_basename = name_style.file("v8", idl_definition.identifier)
# TODO(peria, yukishiino): Add "v8" prefix to union's files. Trying to # TODO(peria, yukishiino): Add "v8" prefix to union's files. Trying to
# produce the same filepaths with the old bindings generator for the # produce the same filepaths with the old bindings generator for the
# time being. # time being.
if isinstance(idl_definition, web_idl.Union): if isinstance(idl_definition, web_idl.Union):
self._v8_bind_basename = name_style.file(idl_definition.identifier) self._api_basename = name_style.file(idl_definition.identifier)
self._impl_basename = name_style.file(idl_definition.identifier)
if not isinstance(idl_definition, web_idl.Union):
idl_path = idl_definition.debug_info.location.filepath
self._blink_dir = posixpath.dirname(idl_path)
self._blink_basename = name_style.file(
blink_class_name(idl_definition))
@property @property
def is_cross_components(self): def is_cross_components(self):
...@@ -138,7 +145,7 @@ class PathManager(object): ...@@ -138,7 +145,7 @@ class PathManager(object):
def api_path(self, filename=None, ext=None): def api_path(self, filename=None, ext=None):
return self._join( return self._join(
dirpath=self.api_dir, dirpath=self.api_dir,
filename=(filename or self._v8_bind_basename), filename=(filename or self._api_basename),
ext=ext) ext=ext)
@property @property
...@@ -152,7 +159,17 @@ class PathManager(object): ...@@ -152,7 +159,17 @@ class PathManager(object):
def impl_path(self, filename=None, ext=None): def impl_path(self, filename=None, ext=None):
return self._join( return self._join(
dirpath=self.impl_dir, dirpath=self.impl_dir,
filename=(filename or self._v8_bind_basename), filename=(filename or self._impl_basename),
ext=ext)
@property
def blink_dir(self):
return self._blink_dir
def blink_path(self, filename=None, ext=None):
return self._join(
dirpath=self.blink_dir,
filename=(filename or self._blink_basename),
ext=ext) ext=ext)
@staticmethod @staticmethod
......
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