#NEWLINE# def generate_selfref_ctypes_class( self ) : #NEWLINE# #INDENT# res = '# Self referencing struct tricks\n' #NEWLINE# res += 'class {0}(Structure): pass\n' . format ( self . name ) #NEWLINE# res += '{0}._fields_ = [\n' . format ( self . name ) #NEWLINE# for ( ftype , name , nb_rep ) in self . fields : #NEWLINE# #INDENT# if ( nb_rep == 1 ) : #NEWLINE# #INDENT# res += '    ("{0}", {1}),\n' . format ( name , ftype . generate_ctypes ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# res += '    ("{0}", {1} * {2}),\n' . format ( name , ftype . generate_ctypes ( ) , nb_rep ) #NEWLINE# #UNINDENT# #UNINDENT# res += ']\n' #NEWLINE# return res