#NEWLINE# def generate_ctypes( self ) : #NEWLINE# #INDENT# lines = [ ] #NEWLINE# for ( i , name ) in self . fields : #NEWLINE# #INDENT# lines . append ( '{0} = EnumValue("{2}", "{0}", {1})' . format ( name , hex ( i ) , self . name ) ) #NEWLINE# #UNINDENT# lines += [ 'class {0}(EnumType):' . format ( self . name ) ] #NEWLINE# lines += [ '    values = [{0}]' . format ( ', ' . join ( [ name for ( i , name ) in self . fields ] ) ) ] #NEWLINE# lines += [ '    mapper = {{x:x for x in values}}' . format ( lines . name ) ] #NEWLINE# for ( typedef_name , value ) in self . typedef . items ( ) : #NEWLINE# #INDENT# str_value = self . name #NEWLINE# if ( type ( value ) == Ptr ) : #NEWLINE# #INDENT# str_value = 'POINTER({0})' . format ( self . name ) #NEWLINE# #UNINDENT# lines += [ '{0} = {1}' . format ( typedef_name , str_value ) ] #NEWLINE# #UNINDENT# lines += [ '' ] #NEWLINE# ctypes_class = '\n' . join ( lines ) #NEWLINE# return ( ctypes_class + '\n' )