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

Unified Diff: Source/bindings/scripts/v8_methods.py

Issue 312683005: IDL: Support optional argument default value syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address nits 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/scripts/v8_methods.py
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py
index 7f7b83b348f2525957d2cc759bf2e2329044ffc3..dfb8460f0c3f6d8bc594efa8f0b424607978d6d5 100644
--- a/Source/bindings/scripts/v8_methods.py
+++ b/Source/bindings/scripts/v8_methods.py
@@ -181,8 +181,11 @@ def generate_argument(interface, method, argument, index):
used_as_argument=True,
used_as_variadic_argument=argument.is_variadic),
'cpp_value': this_cpp_value,
+ # FIXME: check that the default value's type is compatible with the argument's
+ 'default_value': str(argument.default_value) if argument.default_value else None,
'enum_validation_expression': idl_type.enum_validation_expression,
- 'has_default': 'Default' in extended_attributes,
+ # FIXME: remove once [Default] removed and just use argument.default_value
+ 'has_default': 'Default' in extended_attributes or argument.default_value,
'has_event_listener_argument': any(
argument_so_far for argument_so_far in method.arguments[:index]
if argument_so_far.idl_type.name == 'EventListener'),
@@ -298,9 +301,10 @@ def v8_value_to_local_cpp_value(argument, index):
name = argument.name
if argument.is_variadic:
return v8_value_to_local_cpp_variadic_value(argument, index)
- # [Default=NullString]
+ # FIXME: This special way of handling string arguments with null defaults
+ # can go away once we fully support default values.
if (argument.is_optional and idl_type.name in ('String', 'ByteString') and
- extended_attributes.get('Default') == 'NullString'):
+ argument.default_value and argument.default_value.is_null):
v8_value = 'argumentOrNull(info, %s)' % index
else:
v8_value = 'info[%s]' % index
« no previous file with comments | « Source/bindings/scripts/idl_definitions.py ('k') | Source/bindings/tests/idls/TestInterfaceConstructor2.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698