Mercurial > paraspace
changeset 97:00cd331f8aa8
Get unlinked one from a linked one
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 25 Jul 2011 17:46:20 +0800 |
parents | 1769e52bdd9d |
children | c0c127c7b37e |
files | paraspace/dexfile.py paraspace/tests/injection_test.py |
diffstat | 2 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/dexfile.py Mon Jul 25 16:49:28 2011 +0800 +++ b/paraspace/dexfile.py Mon Jul 25 17:46:20 2011 +0800 @@ -1665,8 +1665,9 @@ # dependence. # class DEXFile_linked(DEXFile): + _dep_decls = None + def _copy_attributes(self, dex): - super(DEXFile_linked, self).__init__() for attr, value in dex.__dict__.items(): setattr(self, attr, value) pass @@ -1683,6 +1684,8 @@ linked = DEXFile_linked() build_dependencies(dex, dep_decls) linked._copy_attributes(dex) + + linked._dep_decls = dep_decls return linked @@ -1698,6 +1701,18 @@ return classdef pass raise ValueError, 'can not find class definition for \'%s\'' % (name) + + def get_unlinked(self): + from paraspace.dex_deptracker import restore_dependencies + unlinked = DEXFile() + + for attr, value in self.__dict__.items(): + setattr(unlinked, attr, value) + pass + + restore_dependencies(unlinked, self._dep_decls) + + return unlinked pass
--- a/paraspace/tests/injection_test.py Mon Jul 25 16:49:28 2011 +0800 +++ b/paraspace/tests/injection_test.py Mon Jul 25 17:46:20 2011 +0800 @@ -48,5 +48,8 @@ clone = dexfile_insert_class(helloworld_dex, fakefile_def) assert clone assert clone != fakefile_def + + helloworld_unlinked = helloworld_linked.get_unlinked() + assert helloworld_unlinked pass