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

Unified Diff: mojo/public/python/mojo_bindings/descriptor.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 | « no previous file | mojo/public/tools/bindings/generators/mojom_python_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/python/mojo_bindings/descriptor.py
diff --git a/mojo/public/python/mojo_bindings/descriptor.py b/mojo/public/python/mojo_bindings/descriptor.py
index 3f66e61b3339186b75f874edf9b691d832804026..f086aec365c4778d9103b4576c9166c8295d12f1 100644
--- a/mojo/public/python/mojo_bindings/descriptor.py
+++ b/mojo/public/python/mojo_bindings/descriptor.py
@@ -102,12 +102,18 @@ class SerializableType(Type):
raise NotImplementedError()
-class BooleanType(Type):
+class BooleanType(SerializableType):
"""Type object for booleans"""
def Convert(self, value):
return bool(value)
+ def Serialize(self, value, data_offset, data, handle_offset):
+ return (_ConvertBooleansToByte([value]), [])
+
+ def Deserialize(self, value, context):
+ return _ConvertByteToBooleans(value)[0]
+
class NumericType(SerializableType):
"""Base Type object for all numeric types"""
@@ -636,7 +642,7 @@ class MapType(SerializableType):
return GenericArrayType(t)
-TYPE_BOOL = BooleanType()
+TYPE_BOOL = BooleanType('B')
TYPE_INT8 = IntegerType('b')
TYPE_INT16 = IntegerType('h')
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/mojom_python_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698