comparison paraspace/dexfile.py @ 48:3936d223989a

Introduce null_relocatable for any relocatable without real instance - Some dex type does not own a real instance, it actually a generator of child type. - null_relocatable is used to classify types without real instance.
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 20 Jun 2011 13:34:47 +0800
parents 71218ba3bc8a
children 38fdd422f611
comparison
equal deleted inserted replaced
47:cd4e3584ed7f 48:3936d223989a
391 pass 391 pass
392 pass 392 pass
393 pass 393 pass
394 394
395 395
396 class relocatable(_dex_type):
397 data_size = None
398
399 @staticmethod
400 def parse(parent, data, off):
401 pass
402
403 @staticmethod
404 def sizeof(v):
405 return v.data_size
406
407 def to_str(self):
408 pass
409
410 def compute_size(self):
411 pass
412
413 def children(self):
414 raise NotImplementedError, \
415 '%s: does not implement children' % (self.__class__.__name__)
416 pass
417
418
419 class null_relocatable(relocatable):
420 pass
421
422
396 ## \brief Implicit reference to a target. 423 ## \brief Implicit reference to a target.
397 # 424 #
398 # It is a placeholder for storing relationship defined by an association. 425 # It is a placeholder for storing relationship defined by an association.
399 # 426 #
400 class ref(_dex_type): 427 class ref(null_relocatable):
401 target_path = None 428 target_path = None
402 target = None 429 target = None
403 430
404 def __init__(self, target_path=None): 431 def __init__(self, target_path=None):
405 self.target_path = target_path 432 self.target_path = target_path
451 value = _dex_tree_get_child(parent, attr_path) 478 value = _dex_tree_get_child(parent, attr_path)
452 return value 479 return value
453 pass 480 pass
454 481
455 482
456 class relocatable(_dex_type):
457 data_size = None
458
459 @staticmethod
460 def parse(parent, data, off):
461 pass
462
463 @staticmethod
464 def sizeof(v):
465 return v.data_size
466
467 def to_str(self):
468 pass
469
470 def compute_size(self):
471 pass
472
473 def children(self):
474 raise NotImplementedError, \
475 '%s: does not implement children' % (self.__class__.__name__)
476 pass
477
478
479 class array(relocatable): 483 class array(relocatable):
480 count_name = None 484 count_name = None
481 child_type = None 485 child_type = None
482 items = None 486 items = None
483 487
714 def children(self): 718 def children(self):
715 return ('value',) 719 return ('value',)
716 pass 720 pass
717 721
718 722
719 class depend(relocatable): 723 class depend(null_relocatable):
720 depend_on = None 724 depend_on = None
721 child_type = None 725 child_type = None
722 726
723 def __init__(self, depend_on): 727 def __init__(self, depend_on):
724 self.depend_on = depend_on 728 self.depend_on = depend_on