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

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

Issue 272213005: Support WebIDL optional 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
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/idl_definitions.py
diff --git a/Source/bindings/scripts/idl_definitions.py b/Source/bindings/scripts/idl_definitions.py
index 2230c8f6e207153d8145a7d7dca1560077f1bf7b..94b006c49eb6d813bb8c010a11afdf952e5094f6 100644
--- a/Source/bindings/scripts/idl_definitions.py
+++ b/Source/bindings/scripts/idl_definitions.py
@@ -470,6 +470,7 @@ class IdlOperation(TypedObject):
class IdlArgument(TypedObject):
def __init__(self, node):
+ self.default_value = None
self.extended_attributes = {}
self.idl_type = None
self.is_optional = node.GetProperty('OPTIONAL') # syntax: (optional T)
@@ -488,6 +489,8 @@ class IdlArgument(TypedObject):
if child_name != '...':
raise ValueError('Unrecognized Argument node; expected "...", got "%s"' % child_name)
self.is_variadic = child.GetProperty('ELLIPSIS') or False
+ elif child_class == 'Default':
+ self.default_value = default_node_to_default_value(child)
else:
raise ValueError('Unrecognized node class: %s' % child_class)
@@ -504,6 +507,19 @@ def arguments_node_to_arguments(node):
################################################################################
+# Default value
+################################################################################
+
+def default_node_to_default_value(node):
+ # FIXME: IDL parser currently outputs literal values inconsistently(crbug.com/374178).
Nils Barth (inactive) 2014/06/02 02:48:34 Please use complete URLs (so syntax matching detec
+ # This function should return node.GetProperty('VALUE') once this issue is fixed.
+ if (node.GetProperty('TYPE') == "boolean" or
Nils Barth (inactive) 2014/06/02 02:48:34 Single quotes.
+ node.GetProperty('TYPE') == "float"):
Nils Barth (inactive) 2014/06/02 02:48:34 You can use |in| for checking against a list: node
Nils Barth (inactive) 2014/06/02 02:54:15 BTW, since it's probably unfamiliar: You can also
+ return node.GetProperty('VALUE')
+ return node.GetName()
+
+
+################################################################################
# Extended attributes
################################################################################
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698