Chromium Code Reviews| Index: Source/bindings/templates/methods.cpp |
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
| index d0410ba52948db887ff030ea4544ce7ac32e54aa..136e1a60f225361dee4d9fea3cdb3276fa3e805b 100644 |
| --- a/Source/bindings/templates/methods.cpp |
| +++ b/Source/bindings/templates/methods.cpp |
| @@ -281,3 +281,39 @@ static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo |
| TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| } |
| {% endmacro %} |
| + |
| + |
| +{##############################################################################} |
| +{% macro constructor_callback(constructor) %} |
| +static void constructor{{constructor.overload_index}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + {% if interface_length and not constructor.overload_index %} |
| + {# FIXME: remove this UNLIKELY: constructors are heavy, so no difference. #} |
| + if (UNLIKELY(info.Length() < {{interface_length}})) { |
| + throwTypeError(ExceptionMessages::failedToExecute("Constructor", "{{interface_name}}", ExceptionMessages::notEnoughArguments({{interface_length}}, info.Length())), info.GetIsolate()); |
|
haraken
2013/12/13 10:23:31
You can use the throw_type_error macro here, or yo
Nils Barth (inactive)
2013/12/16 03:15:57
Fixed; used macro consistently.
|
| + return; |
| + } |
| + {% endif %} |
| + {% if is_constructor_raises_exception %} |
| + ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| + {% endif %} |
| + {% for argument in constructor.arguments %} |
| + {{generate_argument(constructor, argument) | indent}} |
| + {% endfor %} |
| + {% if is_constructor_call_with_execution_context %} |
| + ExecutionContext* context = getExecutionContext(); |
| + {% endif %} |
| + {% if is_constructor_call_with_document %} |
|
haraken
2013/12/13 10:23:31
I hope you replace [CallWith=Document] with [CallW
Nils Barth (inactive)
2013/12/16 03:15:57
Got it; will do after finish other constructors ([
|
| + Document& document = *toDocument(getExecutionContext()); |
| + {% endif %} |
| + RefPtr<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor.argument_list | join(', ')}}); |
| + v8::Handle<v8::Object> wrapper = info.Holder(); |
| + {% if is_constructor_raises_exception %} |
| + if (exceptionState.throwIfNeeded()) |
| + return; |
| + {% endif %} |
| + |
| + V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent); |
|
haraken
2013/12/13 10:23:31
Question: I wonder why we always specify 'Dependen
Nils Barth (inactive)
2013/12/16 03:15:57
Added a FIXME to that effect!
|
| + v8SetReturnValue(info, wrapper); |
| +} |
| +{% endmacro %} |