Mercurial > paraspace
changeset 22:61855daafece
Extract generation of dex types into a function
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 02 Jun 2011 09:09:26 +0800 |
parents | f031b9d02ce8 |
children | fff40aabefab |
files | paraspace/dexfile.py |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/dexfile.py Wed Jun 01 23:50:06 2011 +0800 +++ b/paraspace/dexfile.py Thu Jun 02 09:09:26 2011 +0800 @@ -1353,7 +1353,7 @@ _nest_types = (array, cond, switch) -def _dig_clazz(name_path, clazz, population): +def _dig_clazz(name_path, clazz, dex_types): deps = {} for attr in dir(clazz): @@ -1373,11 +1373,11 @@ value_type = value_type.child_type elif isinstance(value_type, switch): for key, child_type in value_type.map.items(): - if child_type in population.values(): + if child_type in dex_types.values(): continue child_name_path = '.'.join(namelist) + '.' + repr(key) child_deps = \ - _dig_clazz(child_name_path, child_type, population) + _dig_clazz(child_name_path, child_type, dex_types) deps.update(child_deps) pass digged_flag = True @@ -1405,15 +1405,20 @@ return deps -def collect_dependencies(): - population = dict([(name, value) +def all_dex_types(): + dex_types = dict([(name, value) for name, value in globals().items() if name.startswith('_DEX_')]) - population['DEXFile'] = DEXFile + dex_types['DEXFile'] = DEXFile + return dex_types + + +def collect_dependencies(): + dex_types = all_dex_types() all_deps = {} - for name_path, clazz in population.items(): - deps = _dig_clazz(name_path, clazz, population) + for name_path, clazz in dex_types.items(): + deps = _dig_clazz(name_path, clazz, dex_types) all_deps.update(deps) pass