changeset 50:312dcf38226f

construct children of DEXFile from map items
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 20 Jun 2011 18:39:00 +0800
parents 38fdd422f611
children 00d106f6c427
files paraspace/dexfile.py
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/paraspace/dexfile.py	Mon Jun 20 17:49:09 2011 +0800
+++ b/paraspace/dexfile.py	Mon Jun 20 18:39:00 2011 +0800
@@ -1505,14 +1505,14 @@
     child_names = 'header'.split()
 
     block_defs = {
-        # 0x0000: 'kDexTypeHeaderItem',
+        0x0000: 'header',
         0x0001: 'stringIds',
         0x0002: 'typeIds',
         0x0003: 'protoIds',
         0x0004: 'fieldIds',
         0x0005: 'methodIds',
         0x0006: 'classDefs',
-        # 0x1000: 'kDexTypeMapList',
+        0x1000: 'maps',
         0x1001: 'typeLists',
         # 0x1002: 'kDexTypeAnnotationSetRefList',
         0x1003: 'annotationSetItems',
@@ -1567,6 +1567,8 @@
         data = self.data
         maps = self.maps.items.items
         for map in maps:
+            if map.type in (0x0000, 0x1000): # header and maps
+                continue
             if map.type in self.block_defs:
                 self._parse_block(map)
                 pass
@@ -1579,10 +1581,11 @@
         pass
 
     def children(self):
-        return 'header stringIds typeIds protoIds fieldIds methodIds ' \
-            'classDefs typeLists annotationSetItems classDatas codeItems ' \
-            'stringDataItems debugInfoItems annotationItems ' \
-            'encodedArrayItems annotationsDirectoryItems'.split()
+        map_items = [self.block_defs[map_item.type]
+                     for map_item in self.maps.items.items]
+        children = map_items + ['maps']
+        print children
+        return children
     pass