def __len__(self):
fmt = ''
more_len = 0
for field in self._field_names_:
fmt_ = self._field_format_[field]
if isinstance(fmt_, StructArray):
fmt += fmt_.get_struct()
elif isinstance(fmt_, type) and issubclass(fmt_, Struct):
more_len = len(fmt)
elif fmt_ != 'variable':
fmt += fmt_
hdr_len = struct.calcsize(fmt) + more_len
if hasattr(self, 'data'):
hdr_len += len(self.data)
return hdr_len
评论列表
文章目录