Index: third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py |
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py b/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py |
index 9c2763ddd10d3d12884261b08590cb78b01f817f..666ef439fa52eb8a1365121008270d16092f2a88 100644 |
--- a/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py |
+++ b/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py |
@@ -56,6 +56,9 @@ class Generator(object): |
def GetStructs(self): |
return map(partial(self._AddStructComputedData, True), self.module.structs) |
+ def GetUnions(self): |
+ return map(self._AddUnionComputedData, self.module.unions) |
+ |
def GetInterfaces(self): |
return map(self._AddInterfaceComputedData, self.module.interfaces) |
@@ -91,6 +94,17 @@ class Generator(object): |
struct.exported = exported |
return struct |
+ def _AddUnionComputedData(self, union): |
+ """Adds computed data to the given union. The data is computed once and |
+ used repeatedly in the generation process.""" |
+ ordinal = 0 |
+ for field in union.fields: |
+ if field.ordinal is not None: |
+ ordinal = field.ordinal |
+ field.ordinal = ordinal |
+ ordinal += 1 |
+ return union |
+ |
def _AddInterfaceComputedData(self, interface): |
"""Adds computed data to the given interface. The data is computed once and |
used repeatedly in the generation process.""" |