Index: Source/bindings/templates/methods.cpp |
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
index 4118aff639f575fc258dd2b13e78bbed9e10cf7f..95cf53936250b578787a697a5de88a4d1192810a 100644 |
--- a/Source/bindings/templates/methods.cpp |
+++ b/Source/bindings/templates/methods.cpp |
@@ -198,7 +198,9 @@ ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate()); |
RefPtr<ScriptArguments> scriptArguments(createScriptArguments(info, {{method.number_of_arguments}})); |
{% endif %} |
{# Call #} |
-{% if method.idl_type == 'void' %} |
+{% if method.is_constructor %} |
+{{ref_ptr}}<{{cpp_class}}> impl = {{cpp_value}}; |
Nils Barth (inactive)
2014/04/09 02:00:27
Can you reuse the |result| branch here, instead of
sof
2014/04/09 07:31:59
I've moved it down a bit. There is a mismatch betw
|
+{% elif method.idl_type == 'void' %} |
{{cpp_value}}; |
{% elif method.is_call_with_script_state or method.is_call_with_new_script_state or method.is_raises_exception %} |
{# FIXME: consider always using a local variable #} |
@@ -210,7 +212,8 @@ if (exceptionState.throwIfNeeded()) |
return; |
{% endif %} |
{# Set return value #} |
-{% if method.union_arguments %} |
+{% if method.is_constructor %} |
+{{generate_constructor_wrapper(method)}}{% elif method.union_arguments %} |
{{union_type_method_call_and_set_return_value(method)}} |
{% elif v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for void #} |
{% endmacro %} |
@@ -393,18 +396,25 @@ static void constructor{{constructor.overload_index}}(const v8::FunctionCallback |
return; |
{% endif %} |
- {% if has_custom_wrap %} |
- v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); |
- {% else %} |
- v8::Handle<v8::Object> wrapper = info.Holder(); |
- V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); |
- {% endif %} |
- v8SetReturnValue(info, wrapper); |
+ {{generate_constructor_wrapper(constructor)| indent}} |
} |
{% endmacro %} |
{##############################################################################} |
+{% macro generate_constructor_wrapper(constructor) %} |
+{# Emit code to associate wrapper with constructed object. #} |
Nils Barth (inactive)
2014/04/09 02:00:27
Could you remove the "Emit code to", since that's
sof
2014/04/09 07:31:59
Removed comment.
Extended the use of this macro -
|
+{% if has_custom_wrap %} |
+v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); |
+{% else %} |
+v8::Handle<v8::Object> wrapper = info.Holder(); |
+V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); |
+{% endif %} |
+v8SetReturnValue(info, wrapper); |
+{% endmacro %} |
+ |
+ |
+{##############################################################################} |
{% macro named_constructor_callback(constructor) %} |
static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |