Mercurial > paraspace
diff paraspace/dexfile.py @ 106:7821c6e89622
dexfile_redirect_types() is almost ready.
fakefile.dex must be updated to provide correctly constructor signature.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 29 Jul 2011 16:17:15 +0800 |
parents | 61cef1662035 |
children | 4b3573d039af |
line wrap: on
line diff
--- a/paraspace/dexfile.py Thu Jul 28 13:25:55 2011 +0800 +++ b/paraspace/dexfile.py Fri Jul 29 16:17:15 2011 +0800 @@ -1029,9 +1029,16 @@ pass +class _DEX_TypeList_typeid(composite): + typeIdx = depend_idx('DEXFile.typeIds')(uint16) + + child_names = ('typeIdx',) + pass + + class _DEX_TypeList(composite): num = uint32 - typeItems = array('num', depend_idx('DEXFile.typeIds')(uint16)) + typeItems = array('num', _DEX_TypeList_typeid) child_names = 'num typeItems'.split() pass @@ -1833,10 +1840,10 @@ if len(typelist1.typeItems.items) != len(typelist2.typeItems.items): return False - for typeid1, typeid2 in map(None, - typelist1.typeItems.items, - typelist2.typeItems.items): - if typeid1 != typeid2: + for tl_typeid1, tl_typeid2 in map(None, + typelist1.typeItems.items, + typelist2.typeItems.items): + if tl_typeid1.typeIdx != tl_typeid2.typeIdx: return False pass return True @@ -1855,6 +1862,24 @@ return wmethod pass raise ValueError, 'can not find a method for given name and prototype' + + @staticmethod + def get_param_typeids_protoid(protoid): + if not protoid.parametersOffRef.is_true: + return () + tl_typeids = protoid.parametersOffRef.value.typeItems.items + typeids = [tl_typeid.typeIdx + for tl_typeid in tl_typeids] + return typeids + + ## \brief Dump content of a proto ID. + @staticmethod + def dump_protoid(protoid): + rtype_name = DEXFile_linked.get_typeid_name(protoid.returnTypeIdx) + param_types = DEXFile_linked.get_param_typeids_protoid(protoid) + ptype_names = [DEXFile_linked.get_typeid_name(ptype) + for ptype in param_types] + return '(%s) --> %s' % (', '.join(ptype_names), rtype_name) pass