Mercurial > paraspace
comparison paraspace/dexfile.py @ 58:c2a4921ec83b
Fix issue misbehavior for dependency when update_offset()
- If value of a depenend object is linked to its depend-on, it's size
should be computed with value from depend-on. But, it was not.
- It is fixed by awaring linking of depend objects in
dex_deptracker.update_offset() and depend classes.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 26 Jun 2011 21:34:52 +0800 |
parents | fa8fe7d714b9 |
children | 21d9b6773242 |
comparison
equal
deleted
inserted
replaced
57:fa8fe7d714b9 | 58:c2a4921ec83b |
---|---|
753 def parse(self, parent, data, off): | 753 def parse(self, parent, data, off): |
754 v = self.back_type.parse(parent, data, off) | 754 v = self.back_type.parse(parent, data, off) |
755 return v | 755 return v |
756 | 756 |
757 def sizeof(self, v): | 757 def sizeof(self, v): |
758 from paraspace.dex_deptracker import _resolve_name_path | |
759 from paraspace.dex_deptracker import _skip_marker_clazz | |
760 | |
761 depon_clazz, dummy = _resolve_name_path(self.depend_on) | |
762 depon_clazz = _skip_marker_clazz(depon_clazz) | |
763 if type(depon_clazz) == type and \ | |
764 isinstance(v, depon_clazz): | |
765 v = v.data_offset | |
766 elif type(depon_clazz) != type and \ | |
767 isinstance(v, depon_clazz.__class__): | |
768 v = v.data_offset | |
769 pass | |
758 v = self.back_type.sizeof(v) | 770 v = self.back_type.sizeof(v) |
759 return v | 771 return v |
760 | 772 |
761 def compute_size(self, child): | 773 def compute_size(self, child): |
762 if issubclass(self.back_type, relocatable): | 774 if issubclass(self.back_type, relocatable): |
791 pass | 803 pass |
792 pass | 804 pass |
793 | 805 |
794 | 806 |
795 class depend_idx(depend): | 807 class depend_idx(depend): |
808 def sizeof(self, v): | |
809 from paraspace.dex_deptracker import _resolve_name_path | |
810 from paraspace.dex_deptracker import _skip_marker_clazz | |
811 | |
812 depon_clazz, dummy = _resolve_name_path(self.depend_on) | |
813 depon_clazz = _skip_marker_clazz(depon_clazz) | |
814 do_child_clazz = depon_clazz.child_type # depon_clazz must be an array | |
815 | |
816 if type(do_child_clazz) == type and \ | |
817 isinstance(v, do_child_clazz): | |
818 v = v.data_idx | |
819 elif type(do_child_clazz) != type and \ | |
820 isinstance(v, do_child_clazz.__class__): | |
821 v = v.data_idx | |
822 pass | |
823 v = self.back_type.sizeof(v) | |
824 return v | |
825 pass | |
796 pass | 826 pass |
797 | 827 |
798 | 828 |
799 class _DEX_header(composite): | 829 class _DEX_header(composite): |
800 magic = rawstr(8) | 830 magic = rawstr(8) |