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

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

Issue 841973002: IDL: Support iterable<>, maplike<> and setlike<> syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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_interface.py » ('j') | Source/bindings/scripts/v8_interface.py » ('J')
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 ce978647117f4457440bf6c865c52a0f66d8a8de..d026f0f21ff4ad6d8c555c626b15daa44941a0e4 100644
--- a/Source/bindings/scripts/idl_definitions.py
+++ b/Source/bindings/scripts/idl_definitions.py
@@ -270,6 +270,9 @@ class IdlInterface(object):
self.operations = []
self.parent = None
self.stringifier = None
+ self.iterable = None
+ self.maplike = None
+ self.setlike = None
self.original_interface = None
self.partial_interfaces = []
if not node: # Early exit for IdlException.__init__
@@ -303,9 +306,18 @@ class IdlInterface(object):
elif child_class == 'Stringifier':
self.stringifier = IdlStringifier(idl_name, child)
self.process_stringifier()
+ elif child_class == 'Iterable':
+ self.iterable = IdlIterable(idl_name, child)
+ elif child_class == 'Maplike':
+ self.maplike = IdlMaplike(idl_name, child)
+ elif child_class == 'Setlike':
+ self.setlike = IdlSetlike(idl_name, child)
else:
raise ValueError('Unrecognized node class: %s' % child_class)
+ if len(filter(None, [self.iterable, self.maplike, self.setlike])) > 1:
+ raise ValueError('Interface can only have one of iterable<>, maplike<> and setlike<>.')
+
def resolve_typedefs(self, typedefs):
for attribute in self.attributes:
attribute.resolve_typedefs(typedefs)
@@ -637,6 +649,49 @@ class IdlStringifier(object):
################################################################################
+# Iterable, Maplike, Setlike
+################################################################################
+
+class IdlIterable(object):
+ def __init__(self, idl_name, node):
+ children = node.GetChildren()
+
+ if len(children) == 1:
+ self.key_type = None
+ self.value_type = type_node_to_type(children[0])
+ elif len(children) == 2:
+ self.key_type = type_node_to_type(children[0])
+ self.value_type = type_node_to_type(children[1])
+ else:
+ raise ValueError('Unexpected number of children: %d' % len(children))
+
+
+class IdlMaplike(object):
+ def __init__(self, idl_name, node):
+ self.is_read_only = node.GetProperty('READONLY') or False
yhirano 2015/01/09 02:30:01 bool(node.GetProperty('READONLY'))
Jens Widell 2015/01/09 07:15:04 Done. I had simply copied this from IdlAttribute,
+
+ children = node.GetChildren()
+
+ if len(children) == 2:
+ self.key_type = type_node_to_type(children[0])
+ self.value_type = type_node_to_type(children[1])
+ else:
+ raise ValueError('Unexpected number of children: %d' % len(children))
+
+
+class IdlSetlike(object):
+ def __init__(self, idl_name, node):
+ self.is_read_only = node.GetProperty('READONLY') or False
yhirano 2015/01/09 02:30:01 ditto
Jens Widell 2015/01/09 07:15:04 Done.
+
+ children = node.GetChildren()
+
+ if len(children) == 1:
+ self.value_type = type_node_to_type(children[0])
+ else:
+ raise ValueError('Unexpected number of children: %d' % len(children))
+
+
+################################################################################
# Implement statements
################################################################################
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_interface.py » ('j') | Source/bindings/scripts/v8_interface.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698