diff 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
line wrap: on
line diff
--- a/paraspace/dexfile.py	Sat Jun 25 08:16:16 2011 +0800
+++ b/paraspace/dexfile.py	Sun Jun 26 21:34:52 2011 +0800
@@ -755,6 +755,18 @@
         return v
 
     def sizeof(self, v):
+        from paraspace.dex_deptracker import _resolve_name_path
+        from paraspace.dex_deptracker import _skip_marker_clazz
+        
+        depon_clazz, dummy = _resolve_name_path(self.depend_on)
+        depon_clazz = _skip_marker_clazz(depon_clazz)
+        if type(depon_clazz) == type and \
+                isinstance(v, depon_clazz):
+            v = v.data_offset
+        elif type(depon_clazz) != type and \
+                isinstance(v, depon_clazz.__class__):
+            v = v.data_offset
+            pass
         v = self.back_type.sizeof(v)
         return v
 
@@ -793,6 +805,24 @@
 
 
 class depend_idx(depend):
+    def sizeof(self, v):
+        from paraspace.dex_deptracker import _resolve_name_path
+        from paraspace.dex_deptracker import _skip_marker_clazz
+        
+        depon_clazz, dummy = _resolve_name_path(self.depend_on)
+        depon_clazz = _skip_marker_clazz(depon_clazz)
+        do_child_clazz = depon_clazz.child_type # depon_clazz must be an array
+        
+        if type(do_child_clazz) == type and \
+                isinstance(v, do_child_clazz):
+            v = v.data_idx
+        elif type(do_child_clazz) != type and \
+                isinstance(v, do_child_clazz.__class__):
+            v = v.data_idx
+            pass
+        v = self.back_type.sizeof(v)
+        return v
+        pass
     pass