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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 {% macro generate_arguments(method, world_suffix) %} | 77 {% macro generate_arguments(method, world_suffix) %} |
78 {% for argument in method.arguments %} | 78 {% for argument in method.arguments %} |
79 {{generate_argument_var_declaration(argument)}}; | 79 {{generate_argument_var_declaration(argument)}}; |
80 {% endfor %} | 80 {% endfor %} |
81 { | 81 { |
82 {% if method.arguments_need_try_catch %} | 82 {% if method.arguments_need_try_catch %} |
83 v8::TryCatch block; | 83 v8::TryCatch block; |
84 V8RethrowTryCatchScope rethrow(block); | 84 V8RethrowTryCatchScope rethrow(block); |
85 {% endif %} | 85 {% endif %} |
86 {% for argument in method.arguments %} | 86 {% for argument in method.arguments %} |
87 {% if argument.default_value %} | |
Nils Barth (inactive)
2014/06/04 05:22:24
This is a behavior change, right?
Could you put t
Jens Widell
2014/06/04 06:12:18
Along with the IDL file changes, yes. Although I b
Nils Barth (inactive)
2014/06/04 06:33:36
The generated code is different (the object code m
| |
88 if (info.Length() > {{argument.index}}) { | |
89 {{generate_argument(method, argument, world_suffix) | indent(8)}} | |
90 } else { | |
91 {{argument.name}} = {{argument.default_value}}; | |
92 } | |
93 {% else %} | |
87 {{generate_argument(method, argument, world_suffix) | indent}} | 94 {{generate_argument(method, argument, world_suffix) | indent}} |
95 {% endif %} | |
88 {% endfor %} | 96 {% endfor %} |
89 } | 97 } |
90 {% endmacro %} | 98 {% endmacro %} |
91 | 99 |
92 | 100 |
93 {######################################} | 101 {######################################} |
94 {% macro generate_argument_var_declaration(argument) %} | 102 {% macro generate_argument_var_declaration(argument) %} |
95 {% if argument.is_callback_interface %} | 103 {% if argument.is_callback_interface %} |
96 {# FIXME: remove EventListener special case #} | 104 {# FIXME: remove EventListener special case #} |
97 {% if argument.idl_type == 'EventListener' %} | 105 {% if argument.idl_type == 'EventListener' %} |
98 RefPtr<{{argument.idl_type}}> {{argument.name}} | 106 RefPtr<{{argument.idl_type}}> {{argument.name}} |
99 {%- else %} | 107 {%- else %} |
100 OwnPtr<{{argument.idl_type}}> {{argument.name}} | 108 OwnPtr<{{argument.idl_type}}> {{argument.name}} |
101 {%- endif %}{# argument.idl_type == 'EventListener' #} | 109 {%- endif %}{# argument.idl_type == 'EventListener' #} |
102 {%- elif argument.is_clamp %}{# argument.is_callback_interface #} | 110 {%- elif argument.is_clamp %}{# argument.is_callback_interface #} |
103 {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 111 {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
104 {{argument.cpp_type}} {{argument.name}} = 0 | 112 {{argument.cpp_type}} {{argument.name}} = 0 |
105 {%- else %} | 113 {%- else %} |
106 {{argument.cpp_type}} {{argument.name}} | 114 {{argument.cpp_type}} {{argument.name}} |
107 {%- endif %} | 115 {%- endif %} |
108 {% endmacro %} | 116 {% endmacro %} |
109 | 117 |
110 | 118 |
111 {######################################} | 119 {######################################} |
112 {% macro generate_argument(method, argument, world_suffix) %} | 120 {% macro generate_argument(method, argument, world_suffix) %} |
113 {% if argument.is_optional and not argument.has_default and | 121 {% if argument.is_optional and |
122 not (argument.has_default or argument.default_value) and | |
Nils Barth (inactive)
2014/06/04 05:22:24
Can you avoid this by changing the definition in v
Jens Widell
2014/06/04 06:12:18
Will do. In general, 'has_default' and its meaning
Nils Barth (inactive)
2014/06/04 06:33:36
Yeah, at this point it becomes vestigial, and "goi
| |
114 argument.idl_type != 'Dictionary' and | 123 argument.idl_type != 'Dictionary' and |
115 not argument.is_callback_interface %} | 124 not argument.is_callback_interface %} |
116 {# Optional arguments without a default value generate an early call with | 125 {# Optional arguments without a default value generate an early call with |
117 fewer arguments if they are omitted. | 126 fewer arguments if they are omitted. |
118 Optional Dictionary arguments default to empty dictionary. #} | 127 Optional Dictionary arguments default to empty dictionary. #} |
119 if (UNLIKELY(info.Length() <= {{argument.index}})) { | 128 if (UNLIKELY(info.Length() <= {{argument.index}})) { |
120 {% if world_suffix %} | 129 {% if world_suffix %} |
121 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} | 130 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argum ent.cpp_value) | indent}} |
122 {% else %} | 131 {% else %} |
123 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} | 132 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 {% endif %} | 562 {% endif %} |
554 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); | 563 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); |
555 {% if is_constructor_raises_exception %} | 564 {% if is_constructor_raises_exception %} |
556 if (exceptionState.throwIfNeeded()) | 565 if (exceptionState.throwIfNeeded()) |
557 return; | 566 return; |
558 {% endif %} | 567 {% endif %} |
559 | 568 |
560 {{generate_constructor_wrapper(constructor) | indent}} | 569 {{generate_constructor_wrapper(constructor) | indent}} |
561 } | 570 } |
562 {% endmacro %} | 571 {% endmacro %} |
OLD | NEW |