# HG changeset patch # User Thinker K.F. Li # Date 1311433359 -28800 # Node ID cd1ee85853f4fd8c7c7a73048def4f2cd7cfe5dc # Parent 793af8437efe44ef288fda8ad4c7769888dce73c Add injection.py diff -r 793af8437efe -r cd1ee85853f4 paraspace/injection.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paraspace/injection.py Sat Jul 23 23:02:39 2011 +0800 @@ -0,0 +1,47 @@ + +def _deep_travel(obj, cloner, adjuster, visit_log=None): + from paraspace.dexfile import _dex_type + + if not visit_log: + visit_log = {} + pass + + if id(obj) in visit_log: + return visit_log[id(obj)] + + attrs = [attr for attr in dir(obj) + if not attr.startswith('_') and \ + isinstance(getattr(obj, attr), _dex_type)] + + pass + + +def dexfile_insert_class(dex, class_def): + classId_orig = class_def.classIdx + if dex_find_type(dex, class_orig): + raise RuntimeError, 'duplicated type' + classId = dex_dup_insert_type(dex, classId_orig) + + superclassId_orig = class_def.superclassId + superclassId = dex_find_type(dex, superclassId_orig) or \ + dex_dup_insert_type(dex, superclassId_orig) + + if dex.interfacesOffRef.is_true: + interfaces_orig = dex.interfacesOffRef.value + interfaces = dex_dup_insert_typelist(dex, interfaces_org) + pass + + sourceFileIdx_orig = dex.sourceFileIdx + sourceFileIdx = dex_find_type(dex, sourceFileIdx_orig) or \ + dex_dup_insert_type(dex, sourceFileIdx_orig) + + if dex.annotationsOffRef.is_true: + annotations_orig = dex.annotationsOffRef.value + annotations = dex_dup_insert(dex, annotations_orig) + pass + + if dex.classDataOffRef.is_true: + class_data_orig = dex.classDataOffRef.value + class_data = dex_dup_insert(dex, class_data_orig) + pass + pass