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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 { | 475 { |
476 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 476 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
477 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info); | 477 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info); |
478 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 478 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
479 } | 479 } |
480 {% endmacro %} | 480 {% endmacro %} |
481 | 481 |
482 | 482 |
483 {##############################################################################} | 483 {##############################################################################} |
484 {% macro generate_constructor(constructor) %} | 484 {% macro generate_constructor(constructor) %} |
485 static void constructor{{constructor.overload_index}}(const v8::FunctionCallback Info<v8::Value>& info) | 485 {% set name = '%sConstructorCallback' % v8_class |
486 if constructor.is_named_constructor else | |
487 'constructor%s' % (constructor.overload_index or '') %} | |
488 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) | |
486 { | 489 { |
487 v8::Isolate* isolate = info.GetIsolate(); | 490 v8::Isolate* isolate = info.GetIsolate(); |
491 {% if constructor.is_named_constructor %} | |
492 if (!info.IsConstructCall()) { | |
493 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), isolate); | |
494 return; | |
495 } | |
496 | |
497 if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject ) { | |
498 v8SetReturnValue(info, info.Holder()); | |
499 return; | |
500 } | |
501 {% endif %} | |
haraken
2014/06/25 09:43:11
This block is fine in this CL, but we might want t
Jens Widell
2014/06/25 10:55:37
Ah, I was wondering why these things applied only
| |
488 {% if constructor.has_exception_state %} | 502 {% if constructor.has_exception_state %} |
489 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), isolate); | 503 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), isolate); |
490 {% endif %} | 504 {% endif %} |
491 {# Overloaded constructors have length checked during overload resolution #} | 505 {# Overloaded constructors have length checked during overload resolution #} |
492 {% if interface_length and not constructor.overload_index %} | 506 {% if constructor.number_of_required_arguments and not constructor.overload_ index %} |
Jens Widell
2014/06/25 07:50:42
Using 'constructor.number_of_required_arguments' i
haraken
2014/06/25 09:43:11
What is the spec saying?
interface.cpp is still u
Jens Widell
2014/06/25 10:55:37
The key here is that regular constructors (or cust
| |
493 {# FIXME: remove UNLIKELY: constructors are expensive, so no difference. #} | 507 {# FIXME: remove UNLIKELY: constructors are expensive, so no difference. #} |
494 if (UNLIKELY(info.Length() < {{interface_length}})) { | 508 if (UNLIKELY(info.Length() < {{constructor.number_of_required_arguments}})) { |
495 {{throw_minimum_arity_type_error(constructor, interface_length)}}; | 509 {{throw_minimum_arity_type_error(constructor, constructor.number_of_requ ired_arguments)}}; |
496 return; | 510 return; |
497 } | 511 } |
498 {% endif %} | 512 {% endif %} |
499 {% if constructor.arguments %} | 513 {% if constructor.arguments %} |
500 {{generate_arguments(constructor) | indent}} | 514 {{generate_arguments(constructor) | indent}} |
501 {% endif %} | 515 {% endif %} |
502 {% if is_constructor_call_with_execution_context %} | 516 {% if is_constructor_call_with_execution_context %} |
503 ExecutionContext* executionContext = currentExecutionContext(isolate); | 517 ExecutionContext* executionContext = currentExecutionContext(isolate); |
504 {% endif %} | 518 {% endif %} |
505 {% if is_constructor_call_with_document %} | 519 {% if is_constructor_call_with_document %} |
(...skipping 16 matching lines...) Expand all Loading... | |
522 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); | 536 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); |
523 {% else %} | 537 {% else %} |
524 {% set constructor_class = v8_class + ('Constructor' | 538 {% set constructor_class = v8_class + ('Constructor' |
525 if constructor.is_named_constructor else | 539 if constructor.is_named_constructor else |
526 '') %} | 540 '') %} |
527 v8::Handle<v8::Object> wrapper = info.Holder(); | 541 v8::Handle<v8::Object> wrapper = info.Holder(); |
528 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); | 542 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); |
529 {% endif %} | 543 {% endif %} |
530 v8SetReturnValue(info, wrapper); | 544 v8SetReturnValue(info, wrapper); |
531 {% endmacro %} | 545 {% endmacro %} |
532 | |
533 | |
534 {##############################################################################} | |
535 {% macro named_constructor_callback(constructor) %} | |
536 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info) | |
537 { | |
538 v8::Isolate* isolate = info.GetIsolate(); | |
539 if (!info.IsConstructCall()) { | |
540 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), isolate); | |
541 return; | |
542 } | |
543 | |
544 if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject ) { | |
545 v8SetReturnValue(info, info.Holder()); | |
546 return; | |
547 } | |
548 | |
549 Document& document = *toDocument(currentExecutionContext(isolate)); | |
550 | |
551 {% if constructor.has_exception_state %} | |
552 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), isolate); | |
553 {% endif %} | |
554 {% if constructor.number_of_required_arguments %} | |
555 if (UNLIKELY(info.Length() < {{constructor.number_of_required_arguments}})) { | |
556 {{throw_minimum_arity_type_error(constructor, constructor.number_of_requ ired_arguments)}}; | |
557 return; | |
558 } | |
559 {% endif %} | |
560 {% if constructor.arguments %} | |
561 {{generate_arguments(constructor) | indent}} | |
562 {% endif %} | |
563 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; | |
564 {% if is_constructor_raises_exception %} | |
565 if (exceptionState.throwIfNeeded()) | |
566 return; | |
567 {% endif %} | |
568 | |
569 {{generate_constructor_wrapper(constructor) | indent}} | |
570 } | |
571 {% endmacro %} | |
OLD | NEW |