Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 466323002: IDL: Use Nullable for union type return value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/scripts/v8_types.py ('k') | Source/bindings/tests/idls/TestTypedefs.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 {# Length check needed to skip action on legacy calls without enough arguments. 289 {# Length check needed to skip action on legacy calls without enough arguments.
290 http://crbug.com/353484 #} 290 http://crbug.com/353484 #}
291 if (info.Length() >= 2 && listener && !impl->toNode()) 291 if (info.Length() >= 2 && listener && !impl->toNode())
292 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventList enerCacheIndex, info.GetIsolate()); 292 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventList enerCacheIndex, info.GetIsolate());
293 {% endif %} 293 {% endif %}
294 {% endmacro %} 294 {% endmacro %}
295 295
296 296
297 {######################################} 297 {######################################}
298 {% macro union_type_method_call_and_set_return_value(method) %} 298 {% macro union_type_method_call_and_set_return_value(method) %}
299 {% for cpp_type in method.cpp_type %} 299 {% for argument in method.union_arguments %}
300 bool result{{loop.index0}}Enabled = false; 300 {{argument.cpp_type}} {{argument.cpp_value}};
301 {{cpp_type}} result{{loop.index0}};
302 {% endfor %} 301 {% endfor %}
303 {{method.cpp_value}}; 302 {{method.cpp_value}};
304 {% if method.is_null_expression %}{# used by getters #} 303 {% if method.is_null_expression %}{# used by getters #}
305 if ({{method.is_null_expression}}) 304 if ({{method.is_null_expression}})
306 return; 305 return;
307 {% endif %} 306 {% endif %}
308 {% for v8_set_return_value in method.v8_set_return_value %} 307 {% for argument in method.union_arguments %}
309 if (result{{loop.index0}}Enabled) { 308 if ({{argument.null_check_value}}) {
310 {{v8_set_return_value}}; 309 {{argument.v8_set_return_value}};
311 return; 310 return;
312 } 311 }
313 {% endfor %} 312 {% endfor %}
314 {# Fall back to null if none of the union members results are returned #} 313 {# Fall back to null if none of the union members results are returned #}
314 {% if method.is_null_expression %}
315 ASSERT_NOT_REACHED();
316 {% else %}
315 v8SetReturnValueNull(info); 317 v8SetReturnValueNull(info);
318 {% endif %}
316 {% endmacro %} 319 {% endmacro %}
317 320
318 321
319 {######################################} 322 {######################################}
320 {% macro throw_type_error(method, error_message) %} 323 {% macro throw_type_error(method, error_message) %}
321 {% if method.has_exception_state %} 324 {% if method.has_exception_state %}
322 exceptionState.throwTypeError({{error_message}}); 325 exceptionState.throwTypeError({{error_message}});
323 {{throw_from_exception_state(method)}}; 326 {{throw_from_exception_state(method)}};
324 {% elif method.idl_type == 'Promise' %} 327 {% elif method.idl_type == 'Promise' %}
325 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), V8ThrowExcept ion::createTypeError({{type_error_message(method, error_message)}}, info.GetIsol ate()))); 328 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), V8ThrowExcept ion::createTypeError({{type_error_message(method, error_message)}}, info.GetIsol ate())));
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate ()); 619 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate ());
617 {% else %} 620 {% else %}
618 {% set constructor_class = v8_class + ('Constructor' 621 {% set constructor_class = v8_class + ('Constructor'
619 if constructor.is_named_constructor else 622 if constructor.is_named_constructor else
620 '') %} 623 '') %}
621 v8::Handle<v8::Object> wrapper = info.Holder(); 624 v8::Handle<v8::Object> wrapper = info.Holder();
622 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configurat ion}}); 625 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configurat ion}});
623 {% endif %} 626 {% endif %}
624 v8SetReturnValue(info, wrapper); 627 v8SetReturnValue(info, wrapper);
625 {% endmacro %} 628 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_types.py ('k') | Source/bindings/tests/idls/TestTypedefs.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698