Mercurial > paraspace
diff paraspace/dex_deptracker.py @ 27:15cb829ac442
travel_dex_type() recoganizes _dex_type correctly
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 07 Jun 2011 22:30:29 +0800 |
parents | b30a0d29a62f |
children | 5ce7ca1187b3 |
line wrap: on
line diff
--- a/paraspace/dex_deptracker.py Tue Jun 07 15:02:42 2011 +0800 +++ b/paraspace/dex_deptracker.py Tue Jun 07 22:30:29 2011 +0800 @@ -36,15 +36,26 @@ def _travel_dex_type(clazz, name_path): - if isinstance(clazz, _marker): - clazz = clazz.back_type - pass + def travelable(attr, attr_name): + if attr_name.startswith('_'): + return False + if callable(attr) and ((not isinstance(attr, dexfile._dex_type)) and + (not (type(attr) == type and + issubclass(attr, dexfile._dex_type)))): + return False + return True travel_queue = [(getattr(clazz, attr_name), name_path + '.' + attr_name) for attr_name in dir(clazz) - if not attr_name.startswith('_')] + if travelable(getattr(clazz, attr_name), attr_name)] + print travel_queue while travel_queue: attr, name_path = travel_queue.pop(0) + if isinstance(attr, _marker): + child = attr.back_type + travel_queue.append((child, name_path)) + continue + yield attr, name_path if isinstance(attr, _marker): @@ -427,7 +438,8 @@ if type(attr) == type and issubclass(attr, dexfile.composite) and attr in marked_types] - print marked_type_refs + import pprint + pprint.pprint(marked_type_refs) def patch_ref(name_path, depon_path): depon, depon_parent = _resolve_name_path(depon_path)