record: return offset

This commit is contained in:
Sebastien Bourdeauducq 2012-01-10 17:10:03 +01:00
parent a6e5f3e766
commit c93eb5f482
1 changed files with 5 additions and 2 deletions

View File

@ -67,7 +67,7 @@ class Record:
tpl2 = other.flatten() tpl2 = other.flatten()
return len(tpl1) == len(tpl2) return len(tpl1) == len(tpl2)
def flatten(self, align=False, offset=0): def flatten(self, align=False, offset=0, return_offset=False):
l = [] l = []
for key, alignment in self.field_order: for key, alignment in self.field_order:
if align: if align:
@ -86,7 +86,10 @@ class Record:
for x in added: for x in added:
offset += x.bv.width offset += x.bv.width
l += added l += added
return l if return_offset:
return (l, offset)
else:
return l
def __repr__(self): def __repr__(self):
return repr(self.layout()) return repr(self.layout())