# HG changeset patch # User Thinker K.F. Li # Date 1306203245 -28800 # Node ID 917f0a9b9d06d2a83e20478da304882d373404fa # Parent 97b7006ced5fa1fd6d36913d48cfb8d42bb10aab Refactor _DEX_TypeItem from _DEX_TypeList for layout info tracking diff -r 97b7006ced5f -r 917f0a9b9d06 paraspace/dexfile.py --- a/paraspace/dexfile.py Tue May 24 10:04:59 2011 +0800 +++ b/paraspace/dexfile.py Tue May 24 10:14:05 2011 +0800 @@ -352,21 +352,38 @@ pass +class _DEX_TypeItem(object): + typeIdx = None # 2 bytes + + data_size = 2 + + def parse(self, data, off): + self.typeIdx = _to_uint(data[off:off + 2]) + pass + pass + + class _DEX_TypeList(object): typeItems = None data_size = None def parse(self, data, off): - size = _to_uint(data[off:off + 4]) + moff = man_off(off) - item_off = off + 4 - typeItems = [_to_uint(data[cur_off:cur_off + 2]) - for cur_off in range(item_off, item_off + size * 2, 2)] - data_size = 4 + size * 2 + size = _to_uint(data[moff(4):moff()]) + + def parse_type_item(): + item = _DEX_TypeItem() + item.parse(data, moff()) + moff(item.data_size) + return item + + typeItems = [parse_type_item() + for i in range(size)] self.typeItems = typeItems - self.data_size = data_size + self.data_size = moff() - off pass pass