Ayuto

custom_types example (datamap_t)

Dec 26th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. from custom_types import utils
  2.  
  3. def dump_datamap(datamap):
  4.     def dump_dmap(proppath, dmap, offset=0):
  5.         # Loop through all properties in this data map
  6.         for x in xrange(dmap.dataNumFields):
  7.             # Get the current description
  8.             desc = dmap.dataDesc[x]
  9.            
  10.             # Does the property have no name or is it a function?
  11.             if not desc.fieldName or desc.inputFunc:
  12.                 continue
  13.  
  14.             temppath = proppath + '.' + desc.fieldName
  15.            
  16.             # Calculate the current offset
  17.             tempoffset = offset + desc.fieldOffset[0]
  18.            
  19.             # Is there no embedded datamap?
  20.             if not desc.td:
  21.                 print temppath, tempoffset
  22.             else:
  23.                 # Dump the embedded data map, too!
  24.                 dump_dmap(temppath, desc.td, tempoffset)
  25.  
  26.     # Dump the data map and its subclasses
  27.     while datamap:
  28.         dump_dmap(datamap.dataClassName, datamap)
  29.         datamap = datamap.baseMap
  30.  
  31.  
  32. entity = utils.EntityByIndex(1)
  33. if not entity:
  34.     raise ValueError('Could not find an entity with index 1.')
  35.    
  36. dump_datamap(entity.GetDataDescMap())
Advertisement
Add Comment
Please, Sign In to add comment