Chromium Code Reviews| 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 and not method.union_result_members %} |
| 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 %} | 254 {%- elif method.union_result_members %} |
| 255 {{union_type_method_call_and_set_return_value(method)}} | 255 {{union_type_method_call_and_set_return_value(method)}} |
| 256 {%- elif v8_set_return_value %} | 256 {%- elif v8_set_return_value %} |
| 257 {% if method.is_explicit_nullable %} | 257 {% if method.is_explicit_nullable %} |
| 258 if (result.isNull()) | 258 if (result.isNull()) |
| 259 v8SetReturnValueNull(info); | 259 v8SetReturnValueNull(info); |
| 260 else | 260 else |
| 261 {{v8_set_return_value}}; | 261 {{v8_set_return_value}}; |
| 262 {% else %} | 262 {% else %} |
| 263 {{v8_set_return_value}}; | 263 {{v8_set_return_value}}; |
| 264 {% endif %} | 264 {% endif %} |
| 265 {%- endif %}{# None for void #} | 265 {%- endif %}{# None for void #} |
| 266 {# Post-set #} | 266 {# Post-set #} |
| 267 {% if interface_name in ('EventTarget', 'MediaQueryList') | 267 {% if interface_name in ('EventTarget', 'MediaQueryList') |
| 268 and method.name in ('addEventListener', 'removeEventListener', 'addListener' , 'removeListener') %} | 268 and method.name in ('addEventListener', 'removeEventListener', 'addListener' , 'removeListener') %} |
| 269 {% set hidden_dependency_action = 'addHiddenValueToArray' | 269 {% set hidden_dependency_action = 'addHiddenValueToArray' |
| 270 if method.name in ('addEventListener', 'addListener') else 'removeHiddenV alueFromArray' %} | 270 if method.name in ('addEventListener', 'addListener') else 'removeHiddenV alueFromArray' %} |
| 271 {% set argument_index = '1' if interface_name == 'EventTarget' else '0' %} | 271 {% set argument_index = '1' if interface_name == 'EventTarget' else '0' %} |
| 272 {# Length check needed to skip action on legacy calls without enough arguments. | 272 {# Length check needed to skip action on legacy calls without enough arguments. |
| 273 http://crbug.com/353484 #} | 273 http://crbug.com/353484 #} |
| 274 if (info.Length() >= {{argument_index}} + 1 && listener && !impl->toNode()) | 274 if (info.Length() >= {{argument_index}} + 1 && listener && !impl->toNode()) |
| 275 {{hidden_dependency_action}}(info.GetIsolate(), info.Holder(), info[{{argume nt_index}}], {{v8_class}}::eventListenerCacheIndex); | 275 {{hidden_dependency_action}}(info.GetIsolate(), info.Holder(), info[{{argume nt_index}}], {{v8_class}}::eventListenerCacheIndex); |
| 276 {% endif %} | 276 {% endif %} |
| 277 {% endmacro %} | 277 {% endmacro %} |
| 278 | 278 |
| 279 | 279 |
| 280 {######################################} | 280 {######################################} |
| 281 {% macro union_type_method_call_and_set_return_value(method) %} | 281 {% macro union_type_method_call_and_set_return_value(method) %} |
|
Jens Widell
2014/10/28 11:31:38
Could the scope of this macro now be reduced to ju
bashi
2014/10/29 01:34:32
Took the later approach, and removed special code
| |
| 282 {% for argument in method.union_arguments %} | 282 {{method.cpp_type}} result; |
| 283 {{argument.cpp_type}} {{argument.cpp_value}}{{argument.cpp_type_initializer}}; | |
| 284 {% endfor %} | |
| 285 {{method.cpp_value}}; | 283 {{method.cpp_value}}; |
| 286 {% if method.is_null_expression %}{# used by getters #} | 284 {% if method.is_null_expression %}{# used by getters #} |
| 287 if ({{method.is_null_expression}}) | 285 if ({{method.is_null_expression}}) |
| 288 return; | 286 return; |
| 289 {% endif %} | 287 {% endif %} |
| 290 {% for argument in method.union_arguments %} | 288 {% for member in method.union_result_members %} |
| 291 if ({{argument.null_check_value}}) { | 289 if ({{member.null_check_value}}) { |
| 292 {{argument.v8_set_return_value}}; | 290 {{member.v8_set_return_value}}; |
| 293 return; | 291 return; |
| 294 } | 292 } |
| 295 {% endfor %} | 293 {% endfor %} |
| 296 {# Fall back to null if none of the union members results are returned #} | 294 {# Fall back to null if none of the union members results are returned #} |
| 297 {% if method.is_null_expression %} | 295 {% if method.is_null_expression %} |
| 298 ASSERT_NOT_REACHED(); | 296 ASSERT_NOT_REACHED(); |
| 299 {% else %} | 297 {% else %} |
| 300 v8SetReturnValueNull(info); | 298 v8SetReturnValueNull(info); |
| 301 {% endif %} | 299 {% endif %} |
| 302 {% endmacro %} | 300 {% endmacro %} |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 {% for method in conditionally_enabled_methods %} | 654 {% for method in conditionally_enabled_methods %} |
| 657 {% filter per_context_enabled(method.per_context_enabled_function) %} | 655 {% filter per_context_enabled(method.per_context_enabled_function) %} |
| 658 {% filter exposed(method.exposed_test) %} | 656 {% 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()); | 657 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 %} | 658 {% endfilter %} |
| 661 {% endfilter %} | 659 {% endfilter %} |
| 662 {% endfor %} | 660 {% endfor %} |
| 663 {% endif %} | 661 {% endif %} |
| 664 } | 662 } |
| 665 {%- endmacro %} | 663 {%- endmacro %} |
| OLD | NEW |