<s> """<STR_LIT>""" <EOL> import ctypes <EOL> import _ctypes <EOL> def fixedpropety ( f ) : <EOL> cache_name = "<STR_LIT:_>" + f . __name__ <EOL> def prop ( self ) : <EOL> try : <EOL> return getattr ( self , cache_name ) <EOL> except AttributeError : <EOL> setattr ( self , cache_name , f ( self ) ) <EOL> return getattr ( self , cache_name ) <EOL> return property ( prop , doc = f . __doc__ ) <EOL> def swallow_ctypes_copy ( ctypes_object ) : <EOL> new_copy = type ( ctypes_object ) ( ) <EOL> ctypes . memmove ( ctypes . byref ( new_copy ) , ctypes . byref ( ctypes_object ) , ctypes . sizeof ( new_copy ) ) <EOL> return new_copy <EOL> def transform_ctypes_fields ( struct , replacement ) : <EOL> return [ ( name , replacement . get ( name , type ) ) for name , type in struct . _fields_ ] <EOL> def print_ctypes_struct ( struct , name = "<STR_LIT>" , ident = <NUM_LIT:0> , hexa = False ) : <EOL> if isinstance ( struct , _ctypes . _Pointer ) : <EOL> if ctypes . cast ( struct , ctypes . c_void_p ) . value is None : <EOL> print ( "<STR_LIT>" . format ( name ) ) <EOL> return <EOL> return print_ctypes_struct ( struct [ <NUM_LIT:0> ] , name + "<STR_LIT>" , hexa = hexa ) <EOL> if not hasattr ( struct , "<STR_LIT>" ) : <EOL> value = struct <EOL> if hasattr ( struct , "<STR_LIT:value>" ) : <EOL> value = struct . value <EOL> if isinstance ( value , basestring ) : <EOL> value = repr ( value ) <EOL> if hexa : <EOL> try : <EOL> print ( "<STR_LIT>" . format ( name , hex ( value ) ) ) <EOL> return <EOL> except TypeError : <EOL> pass <EOL> print ( "<STR_LIT>" . format ( name , value ) ) <EOL> return <EOL> for fname , ftype in struct . _fields_ : <EOL> value = getattr ( struct , fname ) <EOL> print_ctypes_struct ( value , "<STR_LIT>" . format ( name , fname ) , hexa = hexa ) </s>
