Commit 32ce3342 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindigns: Make InstallRuntimeEnabledFeatures as API

Before this CL,
  we used V8Foo::InstallRuntimeEnabledFeatures() if we don't have V8FooPartial, and
  we used V8Foo::install_runtime_enabled_features_function() if we have.
It was confusing and difficult to call the correct one.

This CL does
 - rename InstallRuntimeEnabledFeatures() as InstallRuntimeEnabledFeaturesImpl()
 - create a new API 'InstallRuntimeEnabledFeautres()', which has same name as before
then callsites do not need to care whether the target interface has partial interface or not.



Bug: 806167
Change-Id: I6f277f2bb254df7cbe0fb193dd2f91c7ac1b1778
Reviewed-on: https://chromium-review.googlesource.com/888380Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532080}
parent 8fd16447
...@@ -168,8 +168,8 @@ bool V8ContextSnapshot::InstallConditionalFeatures( ...@@ -168,8 +168,8 @@ bool V8ContextSnapshot::InstallConditionalFeatures(
v8::Local<v8::Object> prototype = interface->Get(context, prototype_str) v8::Local<v8::Object> prototype = interface->Get(context, prototype_str)
.ToLocalChecked() .ToLocalChecked()
.As<v8::Object>(); .As<v8::Object>();
V8Window::install_runtime_enabled_features_function_( V8Window::InstallRuntimeEnabledFeatures(isolate, world, window_wrapper,
isolate, world, window_wrapper, prototype, interface); prototype, interface);
type->InstallConditionalFeatures(context, world, window_wrapper, prototype, type->InstallConditionalFeatures(context, world, window_wrapper, prototype,
interface, interface,
type->domTemplate(isolate, world)); type->domTemplate(isolate, world));
......
...@@ -1139,7 +1139,7 @@ v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V ...@@ -1139,7 +1139,7 @@ v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
{% if needs_runtime_enabled_installer %} {% if needs_runtime_enabled_installer %}
InstallRuntimeEnabledFeaturesFunction InstallRuntimeEnabledFeaturesFunction
{{v8_class}}::install_runtime_enabled_features_function_ = {{v8_class}}::install_runtime_enabled_features_function_ =
&{{v8_class}}::InstallRuntimeEnabledFeatures; &{{v8_class}}::InstallRuntimeEnabledFeaturesImpl;
{% endif %} {% endif %}
{% if not is_array_buffer_or_view %} {% if not is_array_buffer_or_view %}
InstallRuntimeEnabledFeaturesOnTemplateFunction InstallRuntimeEnabledFeaturesOnTemplateFunction
......
...@@ -266,11 +266,6 @@ class {{v8_class}} { ...@@ -266,11 +266,6 @@ class {{v8_class}} {
v8::Local<v8::Object> instance, v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype, v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface); v8::Local<v8::Function> interface);
{% if has_partial_interface %}
static InstallRuntimeEnabledFeaturesFunction
install_runtime_enabled_features_function_;
{% endif %}
{% endif %}{# needs_runtime_enabled_installer #} {% endif %}{# needs_runtime_enabled_installer #}
{% if not is_array_buffer_or_view %} {% if not is_array_buffer_or_view %}
...@@ -284,9 +279,23 @@ class {{v8_class}} { ...@@ -284,9 +279,23 @@ class {{v8_class}} {
{% endif %} {% endif %}
{% endif %}{# not is_array_buffer_or_view #} {% endif %}{# not is_array_buffer_or_view #}
{% if has_partial_interface %} {% if needs_runtime_enabled_installer or has_partial_interface %}
private: private:
{% if needs_runtime_enabled_installer %}
static void InstallRuntimeEnabledFeaturesImpl(
v8::Isolate*,
const DOMWrapperWorld& world,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface);
{% endif %}{# needs_runtime_enabled_installer #}
{% if has_partial_interface %}
static InstallTemplateFunction install{{v8_class}}TemplateFunction; static InstallTemplateFunction install{{v8_class}}TemplateFunction;
{% if needs_runtime_enabled_installer %}
static InstallRuntimeEnabledFeaturesFunction
install_runtime_enabled_features_function_;
{% endif %}
{% endif %}{# has_partial_interface #}
{% endif %} {% endif %}
}; };
......
...@@ -785,11 +785,10 @@ void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate( ...@@ -785,11 +785,10 @@ void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate(
{##############################################################################} {##############################################################################}
{% block install_runtime_enabled %} {% block install_runtime_enabled %}
{% if needs_runtime_enabled_installer %} {% if needs_runtime_enabled_installer %}
{% from 'attributes.cpp.tmpl' import accessor_configuration, {% from 'attributes.cpp.tmpl' import accessor_configuration, attribute_configuration with context %}
attribute_configuration,
with context %}
{% from 'methods.cpp.tmpl' import install_custom_signature with context %} {% from 'methods.cpp.tmpl' import install_custom_signature with context %}
void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures( {% if not is_partial %}
void {{v8_class}}::InstallRuntimeEnabledFeatures(
v8::Isolate* isolate, v8::Isolate* isolate,
const DOMWrapperWorld& world, const DOMWrapperWorld& world,
v8::Local<v8::Object> instance, v8::Local<v8::Object> instance,
...@@ -799,8 +798,23 @@ void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures( ...@@ -799,8 +798,23 @@ void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures(
#error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have InstallRuntimeEnabledFeatures()." #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have InstallRuntimeEnabledFeatures()."
{% endif %} {% endif %}
{% if is_partial %} InstallRuntimeEnabledFeaturesImpl(isolate, world, instance, prototype, interface);
{{v8_class}}::InstallRuntimeEnabledFeatures(isolate, world, instance, prototype, interface); {% if has_partial_interface %}
// Call partial interface's installer.
install_runtime_enabled_features_function_(isolate, world, instance, prototype, interface);
{% endif %}
}
{% endif %}{# not is_partial #}
void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesImpl(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface) {
{% if runtime_enabled_feature_name %}
#error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have InstallRuntimeEnabledFeatures()."
{% endif %} {% endif %}
v8::Local<v8::FunctionTemplate> interface_template = {{v8_class}}::wrapperTypeInfo.domTemplate(isolate, world); v8::Local<v8::FunctionTemplate> interface_template = {{v8_class}}::wrapperTypeInfo.domTemplate(isolate, world);
......
...@@ -7,7 +7,7 @@ void {{v8_class_or_partial}}::initialize() { ...@@ -7,7 +7,7 @@ void {{v8_class_or_partial}}::initialize() {
{{v8_class}}::UpdateWrapperTypeInfo( {{v8_class}}::UpdateWrapperTypeInfo(
&{{v8_class_or_partial}}::install{{v8_class}}Template, &{{v8_class_or_partial}}::install{{v8_class}}Template,
{% if needs_runtime_enabled_installer %} {% if needs_runtime_enabled_installer %}
&{{v8_class_or_partial}}::InstallRuntimeEnabledFeatures, &{{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesImpl,
{% else %} {% else %}
nullptr, nullptr,
{% endif %} {% endif %}
......
...@@ -47,14 +47,6 @@ class {{v8_class_or_partial}} { ...@@ -47,14 +47,6 @@ class {{v8_class_or_partial}} {
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if needs_runtime_enabled_installer %}
static void InstallRuntimeEnabledFeatures(
v8::Isolate*,
const DOMWrapperWorld&,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface);
{% endif %}
static void InstallRuntimeEnabledFeaturesOnTemplate( static void InstallRuntimeEnabledFeaturesOnTemplate(
v8::Isolate*, v8::Isolate*,
const DOMWrapperWorld&, const DOMWrapperWorld&,
...@@ -113,6 +105,15 @@ class {{v8_class_or_partial}} { ...@@ -113,6 +105,15 @@ class {{v8_class_or_partial}} {
{% endif %} {% endif %}
private: private:
{% if needs_runtime_enabled_installer %}
static void InstallRuntimeEnabledFeaturesImpl(
v8::Isolate*,
const DOMWrapperWorld&,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface);
{% endif %}
static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate); static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
}; };
......
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