| OLD | NEW |
| 1 {##############################################################################} | 1 {##############################################################################} |
| 2 {% macro generate_method(method, world_suffix) %} | 2 {% macro generate_method(method, world_suffix) %} |
| 3 {% filter conditional(method.conditional_string) %} | 3 {% filter conditional(method.conditional_string) %} |
| 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
| 5 { | 5 { |
| 6 {# Local variables #} | 6 {# Local variables #} |
| 7 {% if method.has_exception_state %} | 7 {% if method.has_exception_state %} |
| 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 9 {% endif %} | 9 {% endif %} |
| 10 {# Overloaded methods have length checked during overload resolution #} | 10 {# Overloaded methods have length checked during overload resolution #} |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 {% macro create_minimum_arity_type_error_without_exception_state(method, number_
of_required_arguments) %} | 325 {% macro create_minimum_arity_type_error_without_exception_state(method, number_
of_required_arguments) %} |
| 326 {% if method.is_constructor %} | 326 {% if method.is_constructor %} |
| 327 createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "{{interface_name}}
", {{number_of_required_arguments}}, info.Length()) | 327 createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "{{interface_name}}
", {{number_of_required_arguments}}, info.Length()) |
| 328 {%- else %} | 328 {%- else %} |
| 329 createMinimumArityTypeErrorForMethod(info.GetIsolate(), "{{method.name}}", "{{in
terface_name}}", {{number_of_required_arguments}}, info.Length()) | 329 createMinimumArityTypeErrorForMethod(info.GetIsolate(), "{{method.name}}", "{{in
terface_name}}", {{number_of_required_arguments}}, info.Length()) |
| 330 {%- endif %} | 330 {%- endif %} |
| 331 {%- endmacro %} | 331 {%- endmacro %} |
| 332 | 332 |
| 333 | 333 |
| 334 {##############################################################################} | 334 {##############################################################################} |
| 335 {% macro runtime_determined_length_method(overloads) %} |
| 336 static int {{overloads.name}}MethodLength() |
| 337 { |
| 338 {% for length, runtime_enabled_functions in overloads.runtime_determined_len
gths %} |
| 339 {% for runtime_enabled_function in runtime_enabled_functions %} |
| 340 {% filter runtime_enabled(runtime_enabled_function) %} |
| 341 return {{length}}; |
| 342 {% endfilter %} |
| 343 {% endfor %} |
| 344 {% endfor %} |
| 345 } |
| 346 {% endmacro %} |
| 347 |
| 348 |
| 349 {##############################################################################} |
| 335 {# FIXME: We should return a rejected Promise if an error occurs in this | 350 {# FIXME: We should return a rejected Promise if an error occurs in this |
| 336 function when ALL methods in this overload return Promise. In order to do so, | 351 function when ALL methods in this overload return Promise. In order to do so, |
| 337 we must ensure either ALL or NO methods in this overload return Promise #} | 352 we must ensure either ALL or NO methods in this overload return Promise #} |
| 338 {% macro overload_resolution_method(overloads, world_suffix) %} | 353 {% macro overload_resolution_method(overloads, world_suffix) %} |
| 339 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) | 354 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 340 { | 355 { |
| 341 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads
.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 356 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads
.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 342 {% if overloads.measure_all_as %} | 357 {% if overloads.measure_all_as %} |
| 343 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte
xt(info.GetIsolate()), UseCounter::{{overloads.measure_all_as}}); | 358 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte
xt(info.GetIsolate()), UseCounter::{{overloads.measure_all_as}}); |
| 344 {% endif %} | 359 {% endif %} |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 {# FIXME: we do not need to always generate this code. #} | 395 {# FIXME: we do not need to always generate this code. #} |
| 381 {# Invalid arity, throw error #} | 396 {# Invalid arity, throw error #} |
| 382 {# Report full list of valid arities if gaps and above minimum #} | 397 {# Report full list of valid arities if gaps and above minimum #} |
| 383 {% if overloads.valid_arities %} | 398 {% if overloads.valid_arities %} |
| 384 if (info.Length() >= {{overloads.minarg}}) { | 399 if (info.Length() >= {{overloads.minarg}}) { |
| 385 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf
o.Length()); | 400 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf
o.Length()); |
| 386 {{throw_from_exception_state(overloads)}}; | 401 {{throw_from_exception_state(overloads)}}; |
| 387 return; | 402 return; |
| 388 } | 403 } |
| 389 {% endif %} | 404 {% endif %} |
| 390 {# Otherwise just report "not enough arguments" #} | 405 break; |
| 391 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{ov
erloads.minarg}}, info.Length())); | |
| 392 {{throw_from_exception_state(overloads)}}; | |
| 393 return; | |
| 394 {% endif %} | 406 {% endif %} |
| 395 } | 407 } |
| 396 {% if not is_partial and overloads.has_partial_overloads %} | 408 {% if not is_partial and overloads.has_partial_overloads %} |
| 397 ASSERT({{overloads.name}}MethodForPartialInterface); | 409 ASSERT({{overloads.name}}MethodForPartialInterface); |
| 398 ({{overloads.name}}MethodForPartialInterface)(info); | 410 ({{overloads.name}}MethodForPartialInterface)(info); |
| 399 {% else %} | 411 {% else %} |
| 412 if (info.Length() < {{overloads.length}}) { |
| 413 {# Otherwise just report "not enough arguments" #} |
| 414 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{ov
erloads.length}}, info.Length())); |
| 415 {{throw_from_exception_state(overloads)}}; |
| 416 return; |
| 417 } |
| 400 {# No match, throw error #} | 418 {# No match, throw error #} |
| 401 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 419 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 402 {{throw_from_exception_state(overloads)}}; | 420 {{throw_from_exception_state(overloads)}}; |
| 403 {% endif %} | 421 {% endif %} |
| 404 } | 422 } |
| 405 {% endmacro %} | 423 {% endmacro %} |
| 406 | 424 |
| 407 | 425 |
| 408 {##############################################################################} | 426 {##############################################################################} |
| 409 {% macro method_callback(method, world_suffix) %} | 427 {% macro method_callback(method, world_suffix) %} |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 606 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
| 589 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.length}}, {{only_exposed_to_private_script}}} | 607 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.length}}, {{only_exposed_to_private_script}}} |
| 590 {%- endmacro %} | 608 {%- endmacro %} |
| 591 | 609 |
| 592 | 610 |
| 593 {######################################} | 611 {######################################} |
| 594 {% macro install_custom_signature(method) %} | 612 {% macro install_custom_signature(method) %} |
| 595 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class_or_partia
l, method.name) %} | 613 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class_or_partia
l, method.name) %} |
| 596 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback | 614 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback |
| 597 if method.is_per_world_bindings else '0' %} | 615 if method.is_per_world_bindings else '0' %} |
| 616 {% set method_length = method.overloads.length if method.overloads else method.l
ength %} |
| 598 {% set property_attribute = | 617 {% set property_attribute = |
| 599 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) | 618 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut
es) |
| 600 if method.property_attributes else 'v8::None' %} | 619 if method.property_attributes else 'v8::None' %} |
| 601 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 620 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
| 602 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig
uration = { | 621 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= { |
| 603 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method.length}}, {{only_exposed_to_private_script}}, | 622 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}},
{{method_length}}, {{only_exposed_to_private_script}}, |
| 604 }; | 623 }; |
| 605 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 624 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu
re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
| 606 {%- endmacro %} | 625 {%- endmacro %} |
| 607 | 626 |
| 608 {######################################} | 627 {######################################} |
| 609 {% macro install_conditionally_enabled_methods() %} | 628 {% macro install_conditionally_enabled_methods() %} |
| 610 void {{v8_class_or_partial}}::installConditionallyEnabledMethods(v8::Handle<v8::
Object> prototypeObject, v8::Isolate* isolate) | 629 void {{v8_class_or_partial}}::installConditionallyEnabledMethods(v8::Handle<v8::
Object> prototypeObject, v8::Isolate* isolate) |
| 611 { | 630 { |
| 612 {% if is_partial %} | 631 {% if is_partial %} |
| 613 {{v8_class}}::installConditionallyEnabledMethods(prototypeObject, isolate); | 632 {{v8_class}}::installConditionallyEnabledMethods(prototypeObject, isolate); |
| 614 {% endif %} | 633 {% endif %} |
| 615 {% if conditionally_enabled_methods %} | 634 {% if conditionally_enabled_methods %} |
| 616 {# Define per-context enabled operations #} | 635 {# Define per-context enabled operations #} |
| 617 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT
emplate(isolate)); | 636 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT
emplate(isolate)); |
| 618 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont
ext()); | 637 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont
ext()); |
| 619 ASSERT(context); | 638 ASSERT(context); |
| 620 | 639 |
| 621 {% for method in conditionally_enabled_methods %} | 640 {% for method in conditionally_enabled_methods %} |
| 622 {% filter per_context_enabled(method.per_context_enabled_function) %} | 641 {% filter per_context_enabled(method.per_context_enabled_function) %} |
| 623 {% filter exposed(method.exposed_test) %} | 642 {% filter exposed(method.exposed_test) %} |
| 624 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); | 643 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); |
| 625 {% endfilter %} | 644 {% endfilter %} |
| 626 {% endfilter %} | 645 {% endfilter %} |
| 627 {% endfor %} | 646 {% endfor %} |
| 628 {% endif %} | 647 {% endif %} |
| 629 } | 648 } |
| 630 {%- endmacro %} | 649 {%- endmacro %} |
| OLD | NEW |