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 %} |