<s> from ctypes import * <EOL> import py <EOL> from support import BaseCTypesTestChecker <EOL> def setup_module ( mod ) : <EOL> import conftest <EOL> mod . _ctypes_test = str ( conftest . sofile ) <EOL> mod . TestCFunctions . _dll = CDLL ( _ctypes_test ) <EOL> class TestCFunctions ( BaseCTypesTestChecker ) : <EOL> def S ( self ) : <EOL> return c_longlong . in_dll ( self . _dll , "<STR_LIT>" ) . value <EOL> def U ( self ) : <EOL> return c_ulonglong . in_dll ( self . _dll , "<STR_LIT>" ) . value <EOL> def test_byte ( self ) : <EOL> self . _dll . tf_b . restype = c_byte <EOL> self . _dll . tf_b . argtypes = ( c_byte , ) <EOL> assert self . _dll . tf_b ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_byte_plus ( self ) : <EOL> self . _dll . tf_bb . restype = c_byte <EOL> self . _dll . tf_bb . argtypes = ( c_byte , c_byte ) <EOL> assert self . _dll . tf_bb ( <NUM_LIT:0> , - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_ubyte ( self ) : <EOL> self . _dll . tf_B . restype = c_ubyte <EOL> self . _dll . tf_B . argtypes = ( c_ubyte , ) <EOL> assert self . _dll . tf_B ( <NUM_LIT:255> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT:255> <EOL> def test_ubyte_plus ( self ) : <EOL> self . _dll . tf_bB . restype = c_ubyte <EOL> self . _dll . tf_bB . argtypes = ( c_byte , c_ubyte ) <EOL> assert self . _dll . tf_bB ( <NUM_LIT:0> , <NUM_LIT:255> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT:255> <EOL> def test_short ( self ) : <EOL> self . _dll . tf_h . restype = c_short <EOL> self . _dll . tf_h . argtypes = ( c_short , ) <EOL> assert self . _dll . tf_h ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_short_plus ( self ) : <EOL> self . _dll . tf_bh . restype = c_short <EOL> self . _dll . tf_bh . argtypes = ( c_byte , c_short ) <EOL> assert self . _dll . tf_bh ( <NUM_LIT:0> , - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_ushort ( self ) : <EOL> self . _dll . tf_H . restype = c_ushort <EOL> self . _dll . tf_H . argtypes = ( c_ushort , ) <EOL> assert self . _dll . tf_H ( <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_ushort_plus ( self ) : <EOL> self . _dll . tf_bH . restype = c_ushort <EOL> self . _dll . tf_bH . argtypes = ( c_byte , c_ushort ) <EOL> assert self . _dll . tf_bH ( <NUM_LIT:0> , <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_int ( self ) : <EOL> self . _dll . tf_i . restype = c_int <EOL> self . _dll . tf_i . argtypes = ( c_int , ) <EOL> assert self . _dll . tf_i ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_int_plus ( self ) : <EOL> self . _dll . tf_bi . restype = c_int <EOL> self . _dll . tf_bi . argtypes = ( c_byte , c_int ) <EOL> assert self . _dll . tf_bi ( <NUM_LIT:0> , - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_uint ( self ) : <EOL> self . _dll . tf_I . restype = c_uint <EOL> self . _dll . tf_I . argtypes = ( c_uint , ) <EOL> assert self . _dll . tf_I ( <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_uint_plus ( self ) : <EOL> self . _dll . tf_bI . restype = c_uint <EOL> self . _dll . tf_bI . argtypes = ( c_byte , c_uint ) <EOL> assert self . _dll . tf_bI ( <NUM_LIT:0> , <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_long ( self ) : <EOL> self . _dll . tf_l . restype = c_long <EOL> self . _dll . tf_l . argtypes = ( c_long , ) <EOL> assert self . _dll . tf_l ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_long_plus ( self ) : <EOL> self . _dll . tf_bl . restype = c_long <EOL> self . _dll . tf_bl . argtypes = ( c_byte , c_long ) <EOL> assert self . _dll . tf_bl ( <NUM_LIT:0> , - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_ulong ( self ) : <EOL> self . _dll . tf_L . restype = c_ulong <EOL> self . _dll . tf_L . argtypes = ( c_ulong , ) <EOL> assert self . _dll . tf_L ( <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_ulong_plus ( self ) : <EOL> self . _dll . tf_bL . restype = c_ulong <EOL> self . _dll . tf_bL . argtypes = ( c_char , c_ulong ) <EOL> assert self . _dll . tf_bL ( '<STR_LIT:U+0020>' , <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_longlong ( self ) : <EOL> self . _dll . tf_q . restype = c_longlong <EOL> self . _dll . tf_q . argtypes = ( c_longlong , ) <EOL> assert self . _dll . tf_q ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_longlong_plus ( self ) : <EOL> self . _dll . tf_bq . restype = c_longlong <EOL> self . _dll . tf_bq . argtypes = ( c_byte , c_longlong ) <EOL> assert self . _dll . tf_bq ( <NUM_LIT:0> , - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_ulonglong ( self ) : <EOL> self . _dll . tf_Q . restype = c_ulonglong <EOL> self . _dll . tf_Q . argtypes = ( c_ulonglong , ) <EOL> assert self . _dll . tf_Q ( <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_ulonglong_plus ( self ) : <EOL> self . _dll . tf_bQ . restype = c_ulonglong <EOL> self . _dll . tf_bQ . argtypes = ( c_byte , c_ulonglong ) <EOL> assert self . _dll . tf_bQ ( <NUM_LIT:0> , <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . U ( ) == <NUM_LIT> <EOL> def test_float ( self ) : <EOL> self . _dll . tf_f . restype = c_float <EOL> self . _dll . tf_f . argtypes = ( c_float , ) <EOL> assert self . _dll . tf_f ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_float_plus ( self ) : <EOL> self . _dll . tf_bf . restype = c_float <EOL> self . _dll . tf_bf . argtypes = ( c_byte , c_float ) <EOL> assert self . _dll . tf_bf ( <NUM_LIT:0> , - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_double ( self ) : <EOL> self . _dll . tf_d . restype = c_double <EOL> self . _dll . tf_d . argtypes = ( c_double , ) <EOL> assert self . _dll . tf_d ( <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . S ( ) == <NUM_LIT> <EOL> def test_double_plus ( self ) : <EOL> self . _dll . tf_bd . restype = c_double <EOL> self . _dll . tf_bd . argtypes = ( c_byte , c_double ) <EOL> assert self . _dll . tf_bd ( <NUM_LIT:0> , <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . S ( ) == <NUM_LIT> <EOL> def test_callwithresult ( self ) : <EOL> def process_result ( result ) : <EOL> return result * <NUM_LIT:2> <EOL> self . _dll . tf_i . restype = process_result <EOL> self . _dll . tf_i . argtypes = ( c_int , ) <EOL> assert self . _dll . tf_i ( <NUM_LIT> ) == <NUM_LIT> <EOL> assert self . S ( ) == <NUM_LIT> <EOL> assert self . _dll . tf_i ( - <NUM_LIT> ) == - <NUM_LIT> <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> def test_void ( self ) : <EOL> self . _dll . tv_i . restype = None <EOL> self . _dll . tv_i . argtypes = ( c_int , ) <EOL> assert self . _dll . tv_i ( <NUM_LIT> ) == None <EOL> assert self . S ( ) == <NUM_LIT> <EOL> assert self . _dll . tv_i ( - <NUM_LIT> ) == None <EOL> assert self . S ( ) == - <NUM_LIT> <EOL> try : <EOL> WinDLL <EOL> except NameError : <EOL> pass <EOL> else : <EOL> class stdcall_dll ( WinDLL ) : <EOL> def __getattr__ ( self , name ) : <EOL> if name [ : <NUM_LIT:2> ] == '<STR_LIT>' and name [ - <NUM_LIT:2> : ] == '<STR_LIT>' : <EOL> raise AttributeError , name <EOL> func = self . _FuncPtr ( ( "<STR_LIT>" + name , self ) ) <EOL> setattr ( self , name , func ) <EOL> return func <EOL> class TestStdcallCFunctions ( TestCFunctions ) : <EOL> def setup_class ( cls ) : <EOL> TestCFunctions . setup_class . im_func ( cls ) <EOL> cls . _dll = stdcall_dll ( _ctypes_test ) </s>
