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: mojo/public/tools/bindings/generators/mojom_python_generator.py

Issue 1413033011: Fix bug whereby booleans in unions could not be serialized in python. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojo/public/python/mojo_bindings/descriptor.py ('k') | mojo/python/tests/bindings_unions_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/mojom_python_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_python_generator.py b/mojo/public/tools/bindings/generators/mojom_python_generator.py
index a12f5e1a19a27289ded2ce07c653d984a3419f7d..175fda3818e28abb410da82160bd9c14b4e19632 100644
--- a/mojo/public/tools/bindings/generators/mojom_python_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_python_generator.py
@@ -175,9 +175,9 @@ def GetFieldType(kind, field=None):
return _kind_to_type[kind]
-def GetFieldDescriptor(field, index, min_version):
+def GetFieldDescriptor(field, index, min_version, union_field=False):
class_name = 'SingleFieldGroup'
- if field.kind == mojom.BOOL:
+ if field.kind == mojom.BOOL and not union_field:
class_name = 'FieldDescriptor'
arguments = [ '%r' % GetNameForElement(field) ]
arguments.append(GetFieldType(field.kind, field))
@@ -195,7 +195,7 @@ def GetStructFieldDescriptor(packed_field):
packed_field.field, packed_field.index, packed_field.min_version)
def GetUnionFieldDescriptor(field):
- return GetFieldDescriptor(field, field.ordinal, 0)
+ return GetFieldDescriptor(field, field.ordinal, 0, union_field=True)
def GetFieldGroup(byte):
if byte.packed_fields[0].field.kind == mojom.BOOL:
« no previous file with comments | « mojo/public/python/mojo_bindings/descriptor.py ('k') | mojo/python/tests/bindings_unions_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698