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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/parse/ast.py

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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: mojo/public/tools/bindings/pylib/mojom/parse/ast.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/ast.py b/mojo/public/tools/bindings/pylib/mojom/parse/ast.py
index a98a6cece67beaa61144f937226a4f4efe618c8e..e1fa4f8f4ad6ec864474b8858d3e5222d06c492c 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/ast.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/ast.py
@@ -352,3 +352,37 @@ class StructBody(NodeListBase):
"""Represents the body of (i.e., list of definitions inside) a struct."""
_list_item_type = (Const, Enum, StructField)
+
+
+class Union(Definition):
+ """Represents a union definition."""
+
+ def __init__(self, name, body, **kwargs):
+ assert isinstance(body, UnionBody)
+ super(Union, self).__init__(name, **kwargs)
+ self.body = body
+
+ def __eq__(self, other):
+ return super(Union, self).__eq__(other) and \
+ self.body == other.body
+
+
+class UnionField(Definition):
+
+ def __init__(self, name, ordinal, typename, **kwargs):
+ assert isinstance(name, str)
+ assert ordinal is None or isinstance(ordinal, Ordinal)
+ assert isinstance(typename, str)
+ super(UnionField, self).__init__(name, **kwargs)
+ self.ordinal = ordinal
+ self.typename = typename
+
+ def __eq__(self, other):
+ return super(UnionField, self).__eq__(other) and \
+ self.ordinal == other.ordinal and \
+ self.typename == other.typename
+
+
+class UnionBody(NodeListBase):
+
+ _list_item_type = UnionField

Powered by Google App Engine
This is Rietveld 408576698