Mercurial > paraspace
comparison 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 |
comparison
equal
deleted
inserted
replaced
105:f14c32108164 | 106:7821c6e89622 |
---|---|
1027 'header ' \ | 1027 'header ' \ |
1028 'staticFields instanceFields directMethods virtualMethods'.split() | 1028 'staticFields instanceFields directMethods virtualMethods'.split() |
1029 pass | 1029 pass |
1030 | 1030 |
1031 | 1031 |
1032 class _DEX_TypeList_typeid(composite): | |
1033 typeIdx = depend_idx('DEXFile.typeIds')(uint16) | |
1034 | |
1035 child_names = ('typeIdx',) | |
1036 pass | |
1037 | |
1038 | |
1032 class _DEX_TypeList(composite): | 1039 class _DEX_TypeList(composite): |
1033 num = uint32 | 1040 num = uint32 |
1034 typeItems = array('num', depend_idx('DEXFile.typeIds')(uint16)) | 1041 typeItems = array('num', _DEX_TypeList_typeid) |
1035 | 1042 |
1036 child_names = 'num typeItems'.split() | 1043 child_names = 'num typeItems'.split() |
1037 pass | 1044 pass |
1038 | 1045 |
1039 | 1046 |
1831 typelist1 = proto1.parametersOffRef.value | 1838 typelist1 = proto1.parametersOffRef.value |
1832 typelist2 = proto2.parametersOffRef.value | 1839 typelist2 = proto2.parametersOffRef.value |
1833 if len(typelist1.typeItems.items) != len(typelist2.typeItems.items): | 1840 if len(typelist1.typeItems.items) != len(typelist2.typeItems.items): |
1834 return False | 1841 return False |
1835 | 1842 |
1836 for typeid1, typeid2 in map(None, | 1843 for tl_typeid1, tl_typeid2 in map(None, |
1837 typelist1.typeItems.items, | 1844 typelist1.typeItems.items, |
1838 typelist2.typeItems.items): | 1845 typelist2.typeItems.items): |
1839 if typeid1 != typeid2: | 1846 if tl_typeid1.typeIdx != tl_typeid2.typeIdx: |
1840 return False | 1847 return False |
1841 pass | 1848 pass |
1842 return True | 1849 return True |
1843 | 1850 |
1844 def find_method_name_proto(self, method_name, proto, classdef): | 1851 def find_method_name_proto(self, method_name, proto, classdef): |
1853 continue | 1860 continue |
1854 if DEXFile_linked._proto_is_compatible(wmethod.protoIdx, proto): | 1861 if DEXFile_linked._proto_is_compatible(wmethod.protoIdx, proto): |
1855 return wmethod | 1862 return wmethod |
1856 pass | 1863 pass |
1857 raise ValueError, 'can not find a method for given name and prototype' | 1864 raise ValueError, 'can not find a method for given name and prototype' |
1865 | |
1866 @staticmethod | |
1867 def get_param_typeids_protoid(protoid): | |
1868 if not protoid.parametersOffRef.is_true: | |
1869 return () | |
1870 tl_typeids = protoid.parametersOffRef.value.typeItems.items | |
1871 typeids = [tl_typeid.typeIdx | |
1872 for tl_typeid in tl_typeids] | |
1873 return typeids | |
1874 | |
1875 ## \brief Dump content of a proto ID. | |
1876 @staticmethod | |
1877 def dump_protoid(protoid): | |
1878 rtype_name = DEXFile_linked.get_typeid_name(protoid.returnTypeIdx) | |
1879 param_types = DEXFile_linked.get_param_typeids_protoid(protoid) | |
1880 ptype_names = [DEXFile_linked.get_typeid_name(ptype) | |
1881 for ptype in param_types] | |
1882 return '(%s) --> %s' % (', '.join(ptype_names), rtype_name) | |
1858 pass | 1883 pass |
1859 | 1884 |
1860 | 1885 |
1861 if __name__ == '__main__': | 1886 if __name__ == '__main__': |
1862 import sys | 1887 import sys |