Commit 66baa955 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

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

- Makes V8SetReturnValue accept const value
- Catches up BLINK_BINDINGS_TRACE_EVENT
  (https://crrev.com/c/2006149)
- Minor fixes

Bug: 839389
Change-Id: Ic6e63f8f72b78e2ac38d01f369d6c3e367f1ec46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2030352
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737275}
parent c7de6178
......@@ -15,56 +15,63 @@ namespace bindings {
// ScriptWrappable (DOMWindow specialization)
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
DOMWindow* value,
const DOMWindow* value,
V8ReturnValue::MainWorld) {
DCHECK(DOMWrapperWorld::Current(info.GetIsolate()).IsMainWorld());
info.GetReturnValue().Set(ToV8(value, info.This(), info.GetIsolate()));
DOMWindow* wrappable = const_cast<DOMWindow*>(value);
info.GetReturnValue().Set(ToV8(wrappable, info.This(), info.GetIsolate()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
DOMWindow& value,
const DOMWindow& value,
V8ReturnValue::MainWorld) {
DCHECK(DOMWrapperWorld::Current(info.GetIsolate()).IsMainWorld());
info.GetReturnValue().Set(ToV8(&value, info.This(), info.GetIsolate()));
DOMWindow* wrappable = const_cast<DOMWindow*>(&value);
info.GetReturnValue().Set(ToV8(wrappable, info.This(), info.GetIsolate()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
DOMWindow* value,
const DOMWindow* value,
const ScriptWrappable* receiver) {
info.GetReturnValue().Set(ToV8(value, info.This(), info.GetIsolate()));
DOMWindow* wrappable = const_cast<DOMWindow*>(value);
info.GetReturnValue().Set(ToV8(wrappable, info.This(), info.GetIsolate()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
DOMWindow& value,
const DOMWindow& value,
const ScriptWrappable* receiver) {
info.GetReturnValue().Set(ToV8(&value, info.This(), info.GetIsolate()));
DOMWindow* wrappable = const_cast<DOMWindow*>(&value);
info.GetReturnValue().Set(ToV8(wrappable, info.This(), info.GetIsolate()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
DOMWindow* value,
const DOMWindow* value,
v8::Local<v8::Context> creation_context) {
info.GetReturnValue().Set(ToV8(value, info.This(), info.GetIsolate()));
DOMWindow* wrappable = const_cast<DOMWindow*>(value);
info.GetReturnValue().Set(ToV8(wrappable, info.This(), info.GetIsolate()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
DOMWindow& value,
const DOMWindow& value,
v8::Local<v8::Context> creation_context) {
info.GetReturnValue().Set(ToV8(&value, info.This(), info.GetIsolate()));
DOMWindow* wrappable = const_cast<DOMWindow*>(&value);
info.GetReturnValue().Set(ToV8(wrappable, info.This(), info.GetIsolate()));
}
// EventListener
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
EventListener* value,
const EventListener* value,
v8::Isolate* isolate,
EventTarget* event_target) {
EventListener* event_listener = const_cast<EventListener*>(value);
info.GetReturnValue().Set(
JSEventHandler::AsV8Value(isolate, event_target, value));
JSEventHandler::AsV8Value(isolate, event_target, event_listener));
}
} // namespace bindings
......
......@@ -553,6 +553,23 @@ def bind_return_value(code_node, cg_context):
SymbolNode("return_value", definition_constructor=create_definition))
def make_bindings_trace_event(cg_context):
assert isinstance(cg_context, CodeGenContext)
assert cg_context.property_.identifier
event_name = "{}.{}".format(cg_context.class_like.identifier,
cg_context.property_.identifier)
if cg_context.attribute_get:
event_name = "{}.{}".format(event_name, "get")
elif cg_context.attribute_set:
event_name = "{}.{}".format(event_name, "set")
elif cg_context.constructor_group:
event_name = "{}.{}".format(cg_context.class_like.identifier,
"constructor")
return TextNode("BLINK_BINDINGS_TRACE_EVENT(\"{}\");".format(event_name))
def make_check_argument_length(cg_context):
assert isinstance(cg_context, CodeGenContext)
......@@ -1304,6 +1321,7 @@ def make_attribute_get_callback_def(cg_context, function_name):
body.extend([
make_runtime_call_timer_scope(cg_context),
make_bindings_trace_event(cg_context),
make_report_deprecate_as(cg_context),
make_report_measure_as(cg_context),
make_log_activity(cg_context),
......@@ -1348,6 +1366,7 @@ def make_attribute_set_callback_def(cg_context, function_name):
body.extend([
make_runtime_call_timer_scope(cg_context),
make_bindings_trace_event(cg_context),
make_report_deprecate_as(cg_context),
make_report_measure_as(cg_context),
make_log_activity(cg_context),
......@@ -1410,6 +1429,7 @@ def make_constant_callback_def(cg_context, function_name):
constant_name(cg_context))
body.extend([
make_runtime_call_timer_scope(cg_context),
make_bindings_trace_event(cg_context),
logging_nodes,
EmptyNode(),
TextNode(v8_set_return_value),
......@@ -1461,6 +1481,7 @@ def make_constructor_function_def(cg_context, function_name):
body.extend([
make_runtime_call_timer_scope(cg_context),
make_bindings_trace_event(cg_context),
make_report_deprecate_as(cg_context),
make_report_measure_as(cg_context),
make_log_activity(cg_context),
......@@ -1530,6 +1551,7 @@ def make_exposed_construct_callback_def(cg_context, function_name):
v8_bridge_class_name(cg_context.exposed_construct))
body.extend([
make_runtime_call_timer_scope(cg_context),
make_bindings_trace_event(cg_context),
make_report_deprecate_as(cg_context),
make_report_measure_as(cg_context),
make_log_activity(cg_context),
......@@ -1549,6 +1571,7 @@ def make_operation_function_def(cg_context, function_name):
body.extend([
make_runtime_call_timer_scope(cg_context),
make_bindings_trace_event(cg_context),
make_report_deprecate_as(cg_context),
make_report_measure_as(cg_context),
make_log_activity(cg_context),
......@@ -2747,9 +2770,6 @@ def _collect_include_headers(interface):
for argument in operation.arguments:
collect_from_idl_type(argument.idl_type)
if interface.inherited:
headers.add(PathManager(interface.inherited).api_path(ext="h"))
path_manager = PathManager(interface)
headers.discard(path_manager.api_path(ext="h"))
headers.discard(path_manager.impl_path(ext="h"))
......@@ -3059,6 +3079,9 @@ def generate_interface(interface):
interface.code_generator_info.blink_headers[0],
"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"))
if is_cross_components:
impl_header_node.accumulator.add_include_headers([
api_header_path,
......@@ -3151,5 +3174,5 @@ def generate_interface(interface):
def generate_interfaces(web_idl_database):
interface = web_idl_database.find("Node")
interface = web_idl_database.find("Element")
generate_interface(interface)
......@@ -119,79 +119,87 @@ void V8SetReturnValue(const CallbackInfo& info,
// ScriptWrappable
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable* value,
const ScriptWrappable* value,
V8ReturnValue::MainWorld) {
DCHECK(DOMWrapperWorld::Current(info.GetIsolate()).IsMainWorld());
if (UNLIKELY(!value))
return info.GetReturnValue().SetNull();
if (DOMDataStore::SetReturnValueForMainWorld(info.GetReturnValue(), value))
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(value);
if (DOMDataStore::SetReturnValueForMainWorld(info.GetReturnValue(),
wrappable))
return;
info.GetReturnValue().Set(value->Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable& value,
const ScriptWrappable& value,
V8ReturnValue::MainWorld) {
DCHECK(DOMWrapperWorld::Current(info.GetIsolate()).IsMainWorld());
if (DOMDataStore::SetReturnValueForMainWorld(info.GetReturnValue(), &value))
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(&value);
if (DOMDataStore::SetReturnValueForMainWorld(info.GetReturnValue(),
wrappable))
return;
info.GetReturnValue().Set(value.Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable* value,
const ScriptWrappable* value,
const ScriptWrappable* receiver) {
if (UNLIKELY(!value))
return info.GetReturnValue().SetNull();
if (DOMDataStore::SetReturnValueFast(info.GetReturnValue(), value,
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(value);
if (DOMDataStore::SetReturnValueFast(info.GetReturnValue(), wrappable,
info.This(), receiver)) {
return;
}
info.GetReturnValue().Set(value->Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable& value,
const ScriptWrappable& value,
const ScriptWrappable* receiver) {
if (DOMDataStore::SetReturnValueFast(info.GetReturnValue(), &value,
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(&value);
if (DOMDataStore::SetReturnValueFast(info.GetReturnValue(), wrappable,
info.This(), receiver)) {
return;
}
info.GetReturnValue().Set(value.Wrap(info.GetIsolate(), info.This()));
info.GetReturnValue().Set(wrappable->Wrap(info.GetIsolate(), info.This()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable* value,
const ScriptWrappable* value,
v8::Local<v8::Context> creation_context) {
if (UNLIKELY(!value))
return info.GetReturnValue().SetNull();
if (DOMDataStore::SetReturnValue(info.GetReturnValue(), value))
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(value);
if (DOMDataStore::SetReturnValue(info.GetReturnValue(), wrappable))
return;
info.GetReturnValue().Set(
value->Wrap(info.GetIsolate(), creation_context->Global()));
wrappable->Wrap(info.GetIsolate(), creation_context->Global()));
}
template <typename CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
ScriptWrappable& value,
v8::Local<v8::Context> creation_context) {
if (DOMDataStore::SetReturnValue(info.GetReturnValue(), &value))
ScriptWrappable* wrappable = const_cast<ScriptWrappable*>(&value);
if (DOMDataStore::SetReturnValue(info.GetReturnValue(), wrappable))
return;
info.GetReturnValue().Set(
value.Wrap(info.GetIsolate(), creation_context->Global()));
wrappable->Wrap(info.GetIsolate(), creation_context->Global()));
}
} // namespace bindings
......
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