| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 {{cpp_value}}; | 231 {{cpp_value}}; |
| 232 {% elif method.is_implemented_in_private_script %} | 232 {% elif method.is_implemented_in_private_script %} |
| 233 {{method.cpp_type}} result{{method.cpp_type_initializer}}; | 233 {{method.cpp_type}} result{{method.cpp_type_initializer}}; |
| 234 if (!{{method.cpp_value}}) | 234 if (!{{method.cpp_value}}) |
| 235 return; | 235 return; |
| 236 {% elif method.use_output_parameter_for_result %} | 236 {% elif method.use_output_parameter_for_result %} |
| 237 {{method.cpp_type}} result; | 237 {{method.cpp_type}} result; |
| 238 {{cpp_value}}; | 238 {{cpp_value}}; |
| 239 {% elif method.is_constructor %} | 239 {% elif method.is_constructor %} |
| 240 {{method.cpp_type}} impl = {{cpp_value}}; | 240 {{method.cpp_type}} impl = {{cpp_value}}; |
| 241 {% elif method.use_local_result and not method.union_arguments %} | 241 {% elif method.use_local_result %} |
| 242 {{method.cpp_type}} result = {{cpp_value}}; | 242 {{method.cpp_type}} result = {{cpp_value}}; |
| 243 {% endif %} | 243 {% endif %} |
| 244 {# Post-call #} | 244 {# Post-call #} |
| 245 {% if method.is_raises_exception %} | 245 {% if method.is_raises_exception %} |
| 246 if (exceptionState.hadException()) { | 246 if (exceptionState.hadException()) { |
| 247 {{throw_from_exception_state(method)}}; | 247 {{throw_from_exception_state(method)}}; |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 {% endif %} | 250 {% endif %} |
| 251 {# Set return value #} | 251 {# Set return value #} |
| 252 {% if method.is_constructor %} | 252 {% if method.is_constructor %} |
| 253 {{generate_constructor_wrapper(method)}} | 253 {{generate_constructor_wrapper(method)}} |
| 254 {%- elif method.union_arguments %} | |
| 255 {{union_type_method_call_and_set_return_value(method)}} | |
| 256 {%- elif v8_set_return_value %} | 254 {%- elif v8_set_return_value %} |
| 257 {% if method.is_explicit_nullable %} | 255 {% if method.is_explicit_nullable %} |
| 258 if (result.isNull()) | 256 if (result.isNull()) |
| 259 v8SetReturnValueNull(info); | 257 v8SetReturnValueNull(info); |
| 260 else | 258 else |
| 261 {{v8_set_return_value}}; | 259 {{v8_set_return_value}}; |
| 262 {% else %} | 260 {% else %} |
| 263 {{v8_set_return_value}}; | 261 {{v8_set_return_value}}; |
| 264 {% endif %} | 262 {% endif %} |
| 265 {%- endif %}{# None for void #} | 263 {%- endif %}{# None for void #} |
| 266 {# Post-set #} | 264 {# Post-set #} |
| 267 {% if interface_name in ('EventTarget', 'MediaQueryList') | 265 {% if interface_name in ('EventTarget', 'MediaQueryList') |
| 268 and method.name in ('addEventListener', 'removeEventListener', 'addListener'
, 'removeListener') %} | 266 and method.name in ('addEventListener', 'removeEventListener', 'addListener'
, 'removeListener') %} |
| 269 {% set hidden_dependency_action = 'addHiddenValueToArray' | 267 {% set hidden_dependency_action = 'addHiddenValueToArray' |
| 270 if method.name in ('addEventListener', 'addListener') else 'removeHiddenV
alueFromArray' %} | 268 if method.name in ('addEventListener', 'addListener') else 'removeHiddenV
alueFromArray' %} |
| 271 {% set argument_index = '1' if interface_name == 'EventTarget' else '0' %} | 269 {% set argument_index = '1' if interface_name == 'EventTarget' else '0' %} |
| 272 {# Length check needed to skip action on legacy calls without enough arguments. | 270 {# Length check needed to skip action on legacy calls without enough arguments. |
| 273 http://crbug.com/353484 #} | 271 http://crbug.com/353484 #} |
| 274 if (info.Length() >= {{argument_index}} + 1 && listener && !impl->toNode()) | 272 if (info.Length() >= {{argument_index}} + 1 && listener && !impl->toNode()) |
| 275 {{hidden_dependency_action}}(info.GetIsolate(), info.Holder(), info[{{argume
nt_index}}], {{v8_class}}::eventListenerCacheIndex); | 273 {{hidden_dependency_action}}(info.GetIsolate(), info.Holder(), info[{{argume
nt_index}}], {{v8_class}}::eventListenerCacheIndex); |
| 276 {% endif %} | 274 {% endif %} |
| 277 {% endmacro %} | 275 {% endmacro %} |
| 278 | 276 |
| 279 | 277 |
| 280 {######################################} | 278 {######################################} |
| 281 {% macro union_type_method_call_and_set_return_value(method) %} | |
| 282 {% for argument in method.union_arguments %} | |
| 283 {{argument.cpp_type}} {{argument.cpp_value}}{{argument.cpp_type_initializer}}; | |
| 284 {% endfor %} | |
| 285 {{method.cpp_value}}; | |
| 286 {% if method.is_null_expression %}{# used by getters #} | |
| 287 if ({{method.is_null_expression}}) | |
| 288 return; | |
| 289 {% endif %} | |
| 290 {% for argument in method.union_arguments %} | |
| 291 if ({{argument.null_check_value}}) { | |
| 292 {{argument.v8_set_return_value}}; | |
| 293 return; | |
| 294 } | |
| 295 {% endfor %} | |
| 296 {# Fall back to null if none of the union members results are returned #} | |
| 297 {% if method.is_null_expression %} | |
| 298 ASSERT_NOT_REACHED(); | |
| 299 {% else %} | |
| 300 v8SetReturnValueNull(info); | |
| 301 {% endif %} | |
| 302 {% endmacro %} | |
| 303 | |
| 304 | |
| 305 {######################################} | |
| 306 {% macro throw_type_error(method, error_message) %} | 279 {% macro throw_type_error(method, error_message) %} |
| 307 {% if method.has_exception_state %} | 280 {% if method.has_exception_state %} |
| 308 exceptionState.throwTypeError({{error_message}}); | 281 exceptionState.throwTypeError({{error_message}}); |
| 309 {{throw_from_exception_state(method)}}; | 282 {{throw_from_exception_state(method)}}; |
| 310 {% elif method.idl_type == 'Promise' %} | 283 {% elif method.idl_type == 'Promise' %} |
| 311 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), V8ThrowExcept
ion::createTypeError(info.GetIsolate(), {{type_error_message(method, error_messa
ge)}}))); | 284 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), V8ThrowExcept
ion::createTypeError(info.GetIsolate(), {{type_error_message(method, error_messa
ge)}}))); |
| 312 {% else %} | 285 {% else %} |
| 313 V8ThrowException::throwTypeError({{type_error_message(method, error_message)}},
info.GetIsolate()); | 286 V8ThrowException::throwTypeError({{type_error_message(method, error_message)}},
info.GetIsolate()); |
| 314 {% endif %}{# method.has_exception_state #} | 287 {% endif %}{# method.has_exception_state #} |
| 315 {% endmacro %} | 288 {% endmacro %} |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 {% for method in conditionally_enabled_methods %} | 629 {% for method in conditionally_enabled_methods %} |
| 657 {% filter per_context_enabled(method.per_context_enabled_function) %} | 630 {% filter per_context_enabled(method.per_context_enabled_function) %} |
| 658 {% filter exposed(method.exposed_test) %} | 631 {% filter exposed(method.exposed_test) %} |
| 659 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); | 632 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); |
| 660 {% endfilter %} | 633 {% endfilter %} |
| 661 {% endfilter %} | 634 {% endfilter %} |
| 662 {% endfor %} | 635 {% endfor %} |
| 663 {% endif %} | 636 {% endif %} |
| 664 } | 637 } |
| 665 {%- endmacro %} | 638 {%- endmacro %} |
| OLD | NEW |