Mercurial > paraspace
changeset 6:917f0a9b9d06
Refactor _DEX_TypeItem from _DEX_TypeList for layout info tracking
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 24 May 2011 10:14:05 +0800 |
parents | 97b7006ced5f |
children | 1d776ec496e5 |
files | paraspace/dexfile.py |
diffstat | 1 files changed, 23 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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