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

Unified Diff: Source/bindings/templates/methods.cpp

Issue 312683005: IDL: Support optional argument default value syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index f1f0fdb5593b5155d4e13acf141d648f200f3ca3..113fdd78f0c66158090606c287829ddc876822fa 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -84,7 +84,15 @@ if (listener && !impl->toNode())
V8RethrowTryCatchScope rethrow(block);
{% endif %}
{% for argument in method.arguments %}
+ {% 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
+ if (info.Length() > {{argument.index}}) {
+ {{generate_argument(method, argument, world_suffix) | indent(8)}}
+ } else {
+ {{argument.name}} = {{argument.default_value}};
+ }
+ {% else %}
{{generate_argument(method, argument, world_suffix) | indent}}
+ {% endif %}
{% endfor %}
}
{% endmacro %}
@@ -110,7 +118,8 @@ OwnPtr<{{argument.idl_type}}> {{argument.name}}
{######################################}
{% macro generate_argument(method, argument, world_suffix) %}
-{% if argument.is_optional and not argument.has_default and
+{% if argument.is_optional and
+ 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
argument.idl_type != 'Dictionary' and
not argument.is_callback_interface %}
{# Optional arguments without a default value generate an early call with

Powered by Google App Engine
This is Rietveld 408576698