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

Unified Diff: mojo/public/python/mojo_bindings/descriptor.py

Issue 939083002: Fix version handling for boolean groups. (Closed) Base URL: https://github.com/domokit/mojo.git@fix_apk_update
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | mojo/public/python/mojo_bindings/serialization.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 45e073f5badd5630a89538cb6efef7728a2195fb..4143c51b29d371bd5201bec1e1ca0c8aa1fd35cc 100644
--- a/mojo/public/python/mojo_bindings/descriptor.py
+++ b/mojo/public/python/mojo_bindings/descriptor.py
@@ -608,7 +608,10 @@ class FieldGroup(object):
def GetByteSize(self):
raise NotImplementedError()
- def GetVersion(self):
+ def GetMinVersion(self):
+ raise NotImplementedError()
+
+ def GetMaxVersion(self):
raise NotImplementedError()
def Serialize(self, obj, data_offset, data, handle_offset):
@@ -617,6 +620,9 @@ class FieldGroup(object):
def Deserialize(self, value, context):
raise NotImplementedError()
+ def Filter(self, version):
+ raise NotImplementedError()
+
class SingleFieldGroup(FieldGroup, FieldDescriptor):
"""A FieldGroup that contains a single FieldDescriptor."""
@@ -632,7 +638,10 @@ class SingleFieldGroup(FieldGroup, FieldDescriptor):
def GetByteSize(self):
return self.field_type.GetByteSize()
- def GetVersion(self):
+ def GetMinVersion(self):
+ return self.version
+
+ def GetMaxVersion(self):
return self.version
def Serialize(self, obj, data_offset, data, handle_offset):
@@ -643,12 +652,16 @@ class SingleFieldGroup(FieldGroup, FieldDescriptor):
entity = self.field_type.Deserialize(value, context)
return { self.name: entity }
+ def Filter(self, version):
+ return self
+
class BooleanGroup(FieldGroup):
"""A FieldGroup to pack booleans."""
def __init__(self, descriptors):
FieldGroup.__init__(self, descriptors)
- self.version = min([descriptor.version for descriptor in descriptors])
+ self.min_version = min([descriptor.version for descriptor in descriptors])
+ self.max_version = max([descriptor.version for descriptor in descriptors])
def GetTypeCode(self):
return 'B'
@@ -656,8 +669,11 @@ class BooleanGroup(FieldGroup):
def GetByteSize(self):
return 1
- def GetVersion(self):
- return self.version
+ def GetMinVersion(self):
+ return self.min_version
+
+ def GetMaxVersion(self):
+ return self.max_version
def Serialize(self, obj, data_offset, data, handle_offset):
value = _ConvertBooleansToByte(
@@ -670,6 +686,10 @@ class BooleanGroup(FieldGroup):
fillvalue=False)
return dict(values)
+ def Filter(self, version):
+ return BooleanGroup(
+ filter(lambda d: d.version <= version, self.descriptors))
+
def _SerializeNativeArray(value, data_offset, data, length):
data_size = len(data)
« no previous file with comments | « no previous file | mojo/public/python/mojo_bindings/serialization.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698