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

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

Issue 337343002: IDL: make optional arguments (without default) explicit sometimes Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-default-arguments-next
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 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 0650c48664fea7f36890f858e7e8521d162a5d84..af976dc5bc24f457a0a26a4bb6ac785811609af9 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -76,19 +76,23 @@ if (listener && !impl->toNode())
{######################################}
{% macro generate_arguments(method, world_suffix) %}
{% for argument in method.arguments %}
-{{generate_argument_var_declaration(argument)}};
-{% endfor %}
+{{generate_argument_var_declaration(argument)}}
+{%- endfor %}
{
{% if method.arguments_need_try_catch %}
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
{% endif %}
{% for argument in method.arguments %}
- {% if argument.default_value %}
+ {% if argument.default_value or argument.is_explicit_optional %}
if (info.Length() > {{argument.index}}) {
{{generate_argument(method, argument, world_suffix) | indent(8)}}
} else {
+ {% if argument.default_value %}
{{argument.name}} = {{argument.default_value}};
+ {% else %}
+ {{argument.name}}Missing = true;
+ {% endif %}
}
{% else %}
{{generate_argument(method, argument, world_suffix) | indent}}
@@ -103,23 +107,26 @@ if (listener && !impl->toNode())
{% if argument.is_callback_interface %}
{# FIXME: remove EventListener special case #}
{% if argument.idl_type == 'EventListener' %}
-RefPtr<{{argument.idl_type}}> {{argument.name}}
-{%- else %}
-OwnPtr<{{argument.idl_type}}> {{argument.name}}
-{%- endif %}{# argument.idl_type == 'EventListener' #}
-{%- elif argument.is_clamp %}{# argument.is_callback_interface #}
+RefPtr<{{argument.idl_type}}> {{argument.name}};
+{% else %}
+OwnPtr<{{argument.idl_type}}> {{argument.name}};
+{% endif %}{# argument.idl_type == 'EventListener' #}
+{% elif argument.is_clamp %}{# argument.is_callback_interface #}
{# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #}
-{{argument.cpp_type}} {{argument.name}} = 0
-{%- else %}
-{{argument.cpp_type}} {{argument.name}}
-{%- endif %}
-{% endmacro %}
+{{argument.cpp_type}} {{argument.name}} = 0;
+{% else %}
+{{argument.cpp_type}} {{argument.name}};
+{% endif %}
+{% if argument.is_explicit_optional %}
+bool {{argument.name}}Missing = false;
+{% endif %}
+{%- endmacro %}
{######################################}
{% macro generate_argument(method, argument, world_suffix) %}
-{% if argument.is_optional and not argument.has_default and
- argument.idl_type != 'Dictionary' and
+{% if argument.is_optional and not argument.is_explicit_optional and
+ not argument.has_default and argument.idl_type != 'Dictionary' and
not argument.is_callback_interface %}
{# Optional arguments without a default value generate an early call with
fewer arguments if they are omitted.

Powered by Google App Engine
This is Rietveld 408576698