Mercurial > paraspace
comparison paraspace/injection.py @ 100:355986e5cfbd
Make surce methods of injected class are also being and bug fixed.
- dex_type_2_array_attr_map() misses marked array attributes.
- It is fixed by skiping marked array and use back type instead.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 26 Jul 2011 10:06:44 +0800 |
parents | 3898711adb2c |
children | 61cef1662035 |
comparison
equal
deleted
inserted
replaced
99:3898711adb2c | 100:355986e5cfbd |
---|---|
1 | 1 |
2 def _relocatable_children(obj): | 2 def _relocatable_children(obj): |
3 from paraspace.dexfile import relocatable | 3 from paraspace.dexfile import relocatable, array |
4 | |
5 if isinstance(obj, array): | |
6 if not obj.items: | |
7 return [] | |
8 rel_children = [(repr(idx), elt) | |
9 for idx, elt in enumerate(obj.items) | |
10 if isinstance(elt, relocatable)] | |
11 return rel_children | |
4 | 12 |
5 attr_value_pairs = [(attr, getattr(obj, attr)) for attr in dir(obj)] | 13 attr_value_pairs = [(attr, getattr(obj, attr)) for attr in dir(obj)] |
6 rel_children = [(attr, value) for attr, value in attr_value_pairs | 14 rel_children = [(attr, value) for attr, value in attr_value_pairs |
7 if isinstance(value, relocatable)] | 15 if isinstance(value, relocatable)] |
8 return rel_children | 16 return rel_children |
43 while isinstance(clazz, _marker): | 51 while isinstance(clazz, _marker): |
44 clazz = clazz.back_type | 52 clazz = clazz.back_type |
45 pass | 53 pass |
46 return clazz | 54 return clazz |
47 | 55 |
48 attr_values = [(attr, getattr(DEXFile, attr)) | 56 attr_values = [(attr, skip_marker_type(getattr(DEXFile, attr))) |
49 for attr in dir(DEXFile)] | 57 for attr in dir(DEXFile)] |
50 type_2_attr = dict([(skip_marker_type(value.child_type), attr) | 58 array_attrs = [(skip_marker_type(value.child_type), attr) |
51 for attr, value in attr_values | 59 for attr, value in attr_values |
52 if isinstance(value, array)]) | 60 if isinstance(value, array)] |
61 type_2_attr = dict(array_attrs) | |
53 | 62 |
54 dex_type_2_array_attr_map = lambda: type_2_attr | 63 dex_type_2_array_attr_map = lambda: type_2_attr |
55 | 64 |
56 return type_2_attr | 65 return type_2_attr |
57 | 66 |