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 {% if method.number_of_required_arguments %} | 10 {% if method.number_of_required_arguments %} |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 {% if method.is_call_with_new_script_state %} | 191 {% if method.is_call_with_new_script_state %} |
192 NewScriptState* state = NewScriptState::current(info.GetIsolate()); | 192 NewScriptState* state = NewScriptState::current(info.GetIsolate()); |
193 {% endif %} | 193 {% endif %} |
194 {% if method.is_call_with_execution_context %} | 194 {% if method.is_call_with_execution_context %} |
195 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate()); | 195 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate()); |
196 {% endif %} | 196 {% endif %} |
197 {% if method.is_call_with_script_arguments %} | 197 {% if method.is_call_with_script_arguments %} |
198 RefPtr<ScriptArguments> scriptArguments(createScriptArguments(info, {{method.num ber_of_arguments}})); | 198 RefPtr<ScriptArguments> scriptArguments(createScriptArguments(info, {{method.num ber_of_arguments}})); |
199 {% endif %} | 199 {% endif %} |
200 {# Call #} | 200 {# Call #} |
201 {% if method.idl_type == 'void' %} | 201 {% if method.is_constructor %} |
202 {{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
| |
203 {% elif method.idl_type == 'void' %} | |
202 {{cpp_value}}; | 204 {{cpp_value}}; |
203 {% elif method.is_call_with_script_state or method.is_call_with_new_script_state or method.is_raises_exception %} | 205 {% elif method.is_call_with_script_state or method.is_call_with_new_script_state or method.is_raises_exception %} |
204 {# FIXME: consider always using a local variable #} | 206 {# FIXME: consider always using a local variable #} |
205 {{method.cpp_type}} result = {{cpp_value}}; | 207 {{method.cpp_type}} result = {{cpp_value}}; |
206 {% endif %} | 208 {% endif %} |
207 {# Post-call #} | 209 {# Post-call #} |
208 {% if method.is_raises_exception %} | 210 {% if method.is_raises_exception %} |
209 if (exceptionState.throwIfNeeded()) | 211 if (exceptionState.throwIfNeeded()) |
210 return; | 212 return; |
211 {% endif %} | 213 {% endif %} |
212 {# Set return value #} | 214 {# Set return value #} |
213 {% if method.union_arguments %} | 215 {% if method.is_constructor %} |
216 {{generate_constructor_wrapper(method)}}{% elif method.union_arguments %} | |
214 {{union_type_method_call_and_set_return_value(method)}} | 217 {{union_type_method_call_and_set_return_value(method)}} |
215 {% elif v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for voi d #} | 218 {% elif v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for voi d #} |
216 {% endmacro %} | 219 {% endmacro %} |
217 | 220 |
218 | 221 |
219 {######################################} | 222 {######################################} |
220 {% macro union_type_method_call_and_set_return_value(method) %} | 223 {% macro union_type_method_call_and_set_return_value(method) %} |
221 {% for cpp_type in method.cpp_type %} | 224 {% for cpp_type in method.cpp_type %} |
222 bool result{{loop.index0}}Enabled = false; | 225 bool result{{loop.index0}}Enabled = false; |
223 {{cpp_type}} result{{loop.index0}}; | 226 {{cpp_type}} result{{loop.index0}}; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 {% endif %} | 389 {% endif %} |
387 {% if is_constructor_call_with_document %} | 390 {% if is_constructor_call_with_document %} |
388 Document& document = *toDocument(currentExecutionContext(isolate)); | 391 Document& document = *toDocument(currentExecutionContext(isolate)); |
389 {% endif %} | 392 {% endif %} |
390 {{ref_ptr}}<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor.argume nt_list | join(', ')}}); | 393 {{ref_ptr}}<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor.argume nt_list | join(', ')}}); |
391 {% if is_constructor_raises_exception %} | 394 {% if is_constructor_raises_exception %} |
392 if (exceptionState.throwIfNeeded()) | 395 if (exceptionState.throwIfNeeded()) |
393 return; | 396 return; |
394 {% endif %} | 397 {% endif %} |
395 | 398 |
396 {% if has_custom_wrap %} | 399 {{generate_constructor_wrapper(constructor)| indent}} |
397 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); | |
398 {% else %} | |
399 v8::Handle<v8::Object> wrapper = info.Holder(); | |
400 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); | |
401 {% endif %} | |
402 v8SetReturnValue(info, wrapper); | |
403 } | 400 } |
404 {% endmacro %} | 401 {% endmacro %} |
405 | 402 |
406 | 403 |
407 {##############################################################################} | 404 {##############################################################################} |
405 {% macro generate_constructor_wrapper(constructor) %} | |
406 {# 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 -
| |
407 {% if has_custom_wrap %} | |
408 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); | |
409 {% else %} | |
410 v8::Handle<v8::Object> wrapper = info.Holder(); | |
411 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_cla ss}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); | |
412 {% endif %} | |
413 v8SetReturnValue(info, wrapper); | |
414 {% endmacro %} | |
415 | |
416 | |
417 {##############################################################################} | |
408 {% macro named_constructor_callback(constructor) %} | 418 {% macro named_constructor_callback(constructor) %} |
409 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info) | 419 static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V alue>& info) |
410 { | 420 { |
411 if (!info.IsConstructCall()) { | 421 if (!info.IsConstructCall()) { |
412 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), info.GetIsolate()); | 422 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co nstructor.name}}"), info.GetIsolate()); |
413 return; | 423 return; |
414 } | 424 } |
415 | 425 |
416 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis tingObject) { | 426 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis tingObject) { |
417 v8SetReturnValue(info, info.Holder()); | 427 v8SetReturnValue(info, info.Holder()); |
(...skipping 27 matching lines...) Expand all Loading... | |
445 | 455 |
446 {% if has_custom_wrap %} | 456 {% if has_custom_wrap %} |
447 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late()); | 457 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIso late()); |
448 {% else %} | 458 {% else %} |
449 v8::Handle<v8::Object> wrapper = info.Holder(); | 459 v8::Handle<v8::Object> wrapper = info.Holder(); |
450 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_conf iguration}}); | 460 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_conf iguration}}); |
451 {% endif %} | 461 {% endif %} |
452 v8SetReturnValue(info, wrapper); | 462 v8SetReturnValue(info, wrapper); |
453 } | 463 } |
454 {% endmacro %} | 464 {% endmacro %} |
OLD | NEW |