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

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

Issue 335113002: IDL: Support argument default values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 %}
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' %}
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 {% endif %} 564 {% endif %}
557 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); 565 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}});
558 {% if is_constructor_raises_exception %} 566 {% if is_constructor_raises_exception %}
559 if (exceptionState.throwIfNeeded()) 567 if (exceptionState.throwIfNeeded())
560 return; 568 return;
561 {% endif %} 569 {% endif %}
562 570
563 {{generate_constructor_wrapper(constructor) | indent}} 571 {{generate_constructor_wrapper(constructor) | indent}}
564 } 572 }
565 {% endmacro %} 573 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698