Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: Source/bindings/templates/methods.cpp

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 94b70730869b707916dfc76315938738c13565d4..6110a24a14c26d29ba3d181b2379cbd7edcf0f33 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -378,6 +378,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
case {{length}}:
{# Then resolve by testing argument #}
{% for test, method in tests_methods %}
+ {% if method.visible %}
{% filter runtime_enabled(not overloads.runtime_enabled_function_all and
method.runtime_enabled_function) %}
if ({{test}}) {
@@ -391,10 +392,18 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
return;
}
{% endfilter %}
+ {% endif %}
{% endfor %}
break;
{% endfor %}
default:
+ {# If methods are overloaded between interface and partial interface #}
+ {# definitions, need to invoke methods defined in the partial #}
+ {# interface. #}
+ {# FIXME: we do not need to always generate this code. #}
+ {% if not is_partial and overloads.has_partial_overloads %}
+ ({{overloads.name}}MethodForPartialInterface)(info);
+ {% else %}
{# Invalid arity, throw error #}
{# Report full list of valid arities if gaps and above minimum #}
{% if overloads.valid_arities %}
@@ -407,11 +416,16 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
{# Otherwise just report "not enough arguments" #}
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{overloads.minarg}}, info.Length()));
exceptionState.throwIfNeeded();
+ {% endif %}
return;
}
+ {% if not is_partial and overloads.has_partial_overloads %}
+ ({{overloads.name}}MethodForPartialInterface)(info);
+ {% else %}
{# No match, throw error #}
exceptionState.throwTypeError("No function was found that matched the signature provided.");
exceptionState.throwIfNeeded();
+ {% endif %}
}
{% endmacro %}
@@ -446,7 +460,7 @@ static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
{% if method.is_custom %}
{{v8_class}}::{{method.name}}MethodCustom(info);
{% else %}
- {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
+ {{actual_cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
{% endif %}
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
@@ -600,9 +614,9 @@ v8SetReturnValue(info, wrapper);
{##############################################################################}
{% macro method_configuration(method) %}
{% set method_callback =
- '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %}
+ '%sV8Internal::%sMethodCallback' % (actual_cpp_class, method.name) %}
{% set method_callback_for_main_world =
- '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name)
+ '%sV8Internal::%sMethodCallbackForMainWorld' % (actual_cpp_class, method.name)
if method.is_per_world_bindings else '0' %}
{% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivateScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::ExposedToAllScripts' %}
{"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}}}
@@ -611,7 +625,7 @@ v8SetReturnValue(info, wrapper);
{######################################}
{% macro install_custom_signature(method) %}
-{% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %}
+{% set method_callback = '%sV8Internal::%sMethodCallback' % (actual_cpp_class, method.name) %}
{% set method_callback_for_main_world = '%sForMainWorld' % method_callback
if method.is_per_world_bindings else '0' %}
{% set property_attribute =
@@ -623,3 +637,27 @@ static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
};
V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signature}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate);
{%- endmacro %}
+
+{######################################}
+{% macro install_conditionally_enabled_methods() %}
+void {{actual_v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> prototypeObject, v8::Isolate* isolate)
+{
+ {% if is_partial %}
+ {{v8_class}}::installConditionallyEnabledMethods(prototypeObject, isolate);
+ {% endif %}
+ {% if conditionally_enabled_methods %}
+ {# Define per-context enabled operations #}
+ v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTemplate(isolate));
+ ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext());
+ ASSERT(context);
+
+ {% for method in conditionally_enabled_methods %}
+ {% filter per_context_enabled(method.per_context_enabled_function) %}
+ {% filter exposed(method.exposed_test) %}
+ prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::FunctionTemplate::New(isolate, {{actual_cpp_class}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFunction());
+ {% endfilter %}
+ {% endfilter %}
+ {% endfor %}
+ {% endif %}
+}
+{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698