Chromium Code Reviews| 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 {{throw_minimum_arity_type_error(constructor, interface_length)}}; | 489 {{throw_minimum_arity_type_error(constructor, interface_length)}}; |
| 490 return; | 490 return; |
| 491 } | 491 } |
| 492 {% endif %} | 492 {% endif %} |
| 493 {% if constructor.arguments %} | 493 {% if constructor.arguments %} |
| 494 {{generate_arguments(constructor) | indent}} | 494 {{generate_arguments(constructor) | indent}} |
| 495 {% endif %} | 495 {% endif %} |
| 496 {% if is_constructor_call_with_execution_context %} | 496 {% if is_constructor_call_with_execution_context %} |
| 497 ExecutionContext* executionContext = currentExecutionContext(isolate); | 497 ExecutionContext* executionContext = currentExecutionContext(isolate); |
| 498 {% endif %} | 498 {% endif %} |
| 499 {% if is_constructor_call_with_document %} | |
| 500 Document& document = *toDocument(currentExecutionContext(isolate)); | |
| 501 {% endif %} | |
| 502 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; | 499 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; |
| 503 {% if is_constructor_raises_exception %} | 500 {% if is_constructor_raises_exception %} |
| 504 if (exceptionState.throwIfNeeded()) | 501 if (exceptionState.throwIfNeeded()) |
| 505 return; | 502 return; |
| 506 {% endif %} | 503 {% endif %} |
| 507 | 504 |
| 508 {{generate_constructor_wrapper(constructor) | indent}} | 505 {{generate_constructor_wrapper(constructor) | indent}} |
| 509 } | 506 } |
| 510 {% endmacro %} | 507 {% endmacro %} |
| 511 | 508 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 533 if (!info.IsConstructCall()) { | 530 if (!info.IsConstructCall()) { |
| 534 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), isolate); | 531 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), isolate); |
| 535 return; | 532 return; |
| 536 } | 533 } |
| 537 | 534 |
| 538 if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject ) { | 535 if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject ) { |
| 539 v8SetReturnValue(info, info.Holder()); | 536 v8SetReturnValue(info, info.Holder()); |
| 540 return; | 537 return; |
| 541 } | 538 } |
| 542 | 539 |
| 543 Document* documentPtr = currentDOMWindow(isolate)->document(); | 540 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); |
| 541 | |
| 542 Document* documentPtr = toDocument(executionContext); | |
| 544 ASSERT(documentPtr); | 543 ASSERT(documentPtr); |
| 545 Document& document = *documentPtr; | |
| 546 | 544 |
| 547 // Make sure the document is added to the DOM Node map. Otherwise, the {{cpp _class}} instance | 545 // Make sure the document is added to the DOM Node map. Otherwise, the {{cpp _class}} instance |
| 548 // may end up being the only node in the map and get garbage-collected prema turely. | 546 // may end up being the only node in the map and get garbage-collected prema turely. |
| 549 toV8(documentPtr, info.Holder(), isolate); | 547 toV8(documentPtr, info.Holder(), isolate); |
|
Jens Widell
2014/06/18 10:39:08
I don't really understand what this code is about,
haraken
2014/06/18 10:49:21
This is complicated to explain, but basically this
Jens Widell
2014/06/18 11:14:38
Why would this only be needed for "named" construc
haraken
2014/06/18 11:24:52
That is because Nodes can have named constructors
Jens Widell
2014/06/18 11:29:02
I don't understand. In what sense is Comment (and
| |
| 550 | 548 |
| 551 {% if constructor.has_exception_state %} | 549 {% if constructor.has_exception_state %} |
| 552 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), isolate); | 550 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), isolate); |
| 553 {% endif %} | 551 {% endif %} |
| 554 {% if constructor.number_of_required_arguments %} | 552 {% if constructor.number_of_required_arguments %} |
| 555 if (UNLIKELY(info.Length() < {{constructor.number_of_required_arguments}})) { | 553 if (UNLIKELY(info.Length() < {{constructor.number_of_required_arguments}})) { |
| 556 {{throw_minimum_arity_type_error(constructor, constructor.number_of_requ ired_arguments)}}; | 554 {{throw_minimum_arity_type_error(constructor, constructor.number_of_requ ired_arguments)}}; |
| 557 return; | 555 return; |
| 558 } | 556 } |
| 559 {% endif %} | 557 {% endif %} |
| 560 {% if constructor.arguments %} | 558 {% if constructor.arguments %} |
| 561 {{generate_arguments(constructor) | indent}} | 559 {{generate_arguments(constructor) | indent}} |
| 562 {% endif %} | 560 {% endif %} |
| 563 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; | 561 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; |
| 564 {% if is_constructor_raises_exception %} | 562 {% if is_constructor_raises_exception %} |
| 565 if (exceptionState.throwIfNeeded()) | 563 if (exceptionState.throwIfNeeded()) |
| 566 return; | 564 return; |
| 567 {% endif %} | 565 {% endif %} |
| 568 | 566 |
| 569 {{generate_constructor_wrapper(constructor) | indent}} | 567 {{generate_constructor_wrapper(constructor) | indent}} |
| 570 } | 568 } |
| 571 {% endmacro %} | 569 {% endmacro %} |
| OLD | NEW |