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

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

Issue 1063253005: bindings: Use Visitor to collect union types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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/idl_types.py
diff --git a/Source/bindings/scripts/idl_types.py b/Source/bindings/scripts/idl_types.py
index 0db2514f58d815cc91bd884c38f4394855e71607..5d776a7172c563d978594851d86f0b59588d4288 100644
--- a/Source/bindings/scripts/idl_types.py
+++ b/Source/bindings/scripts/idl_types.py
@@ -124,6 +124,11 @@ class IdlTypeBase(object):
raise NotImplementedError(
'resolve_typedefs should be defined in subclasses')
+ def idl_types(self):
+ """A generator which yields IdlTypes which are referenced from |self|,
+ including itself."""
+ yield self
+
################################################################################
# IdlType
@@ -321,6 +326,12 @@ class IdlUnionType(IdlTypeBase):
for member_type in self.member_types]
return self
+ def idl_types(self):
+ yield self
+ for member_type in self.member_types:
+ for idl_type in member_type.idl_types():
+ yield idl_type
+
################################################################################
# IdlArrayOrSequenceType, IdlArrayType, IdlSequenceType
@@ -357,6 +368,11 @@ class IdlArrayOrSequenceType(IdlTypeBase):
def enum_type(self):
return self.element_type.enum_type
+ def idl_types(self):
+ yield self
+ for idl_type in self.element_type.idl_types():
+ yield idl_type
+
class IdlArrayType(IdlArrayOrSequenceType):
def __init__(self, element_type):
@@ -421,3 +437,8 @@ class IdlNullableType(IdlTypeBase):
def resolve_typedefs(self, typedefs):
self.inner_type = self.inner_type.resolve_typedefs(typedefs)
return self
+
+ def idl_types(self):
+ yield self
+ for idl_type in self.inner_type.idl_types():
+ yield idl_type

Powered by Google App Engine
This is Rietveld 408576698