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

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: Fixed patch conflict 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
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/templates/partial_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 78a1b0f1bedc2b7a7277e833dfea65d98b837add..ecc03a8e355b05b4a72b11825de46932a6b2b306 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -381,6 +381,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}}) {
@@ -394,10 +395,16 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
return;
}
{% endfilter %}
+ {% endif %}
{% endfor %}
break;
{% endfor %}
+ {% if is_partial or not overloads.has_partial_overloads %}
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. #}
{# Invalid arity, throw error #}
{# Report full list of valid arities if gaps and above minimum #}
{% if overloads.valid_arities %}
@@ -411,10 +418,16 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{overloads.minarg}}, info.Length()));
exceptionState.throwIfNeeded();
return;
+ {% endif %}
}
+ {% if not is_partial and overloads.has_partial_overloads %}
+ ASSERT({{overloads.name}}MethodForPartialInterface);
+ ({{overloads.name}}MethodForPartialInterface)(info);
+ {% else %}
{# No match, throw error #}
exceptionState.throwTypeError("No function was found that matched the signature provided.");
exceptionState.throwIfNeeded();
+ {% endif %}
}
{% endmacro %}
@@ -449,7 +462,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);
+ {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
{% endif %}
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
@@ -603,9 +616,9 @@ v8SetReturnValue(info, wrapper);
{##############################################################################}
{% macro method_configuration(method) %}
{% set method_callback =
- '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %}
+ '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %}
{% set method_callback_for_main_world =
- '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name)
+ '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, 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}}}
@@ -614,7 +627,7 @@ v8SetReturnValue(info, wrapper);
{######################################}
{% macro install_custom_signature(method) %}
-{% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %}
+{% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %}
{% set method_callback_for_main_world = '%sForMainWorld' % method_callback
if method.is_per_world_bindings else '0' %}
{% set property_attribute =
@@ -626,3 +639,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 {{v8_class_or_partial}}::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, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFunction());
+ {% endfilter %}
+ {% endfilter %}
+ {% endfor %}
+ {% endif %}
+}
+{%- endmacro %}
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/templates/partial_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698