#NEWLINE# def test_address_of_function( ) : #NEWLINE# #INDENT# ffi = FFI ( ) #NEWLINE# ffi . cdef ( 'long myfunc(long x);' ) #NEWLINE# lib = verify ( ffi , 'test_addressof_function' , '\n        char myfunc(char x) { return (char)(x + 42); }\n    ' ) #NEWLINE# assert ( lib . myfunc ( 5 ) == 47 ) #NEWLINE# assert ( lib . myfunc ( 703493 ) == 47 ) #NEWLINE# assert ( not isinstance ( lib . myfunc , ffi . CData ) ) #NEWLINE# assert ( ffi . typeof ( lib . myfunc ) == ffi . typeof ( 'long(*)(long)' ) ) #NEWLINE# addr = ffi . addressof ( lib , 'myfunc' ) #NEWLINE# assert ( addr ( 5 ) == 47 ) #NEWLINE# assert ( addr ( 703493 ) == 47 ) #NEWLINE# assert isinstance ( addr , ffi . CData ) #NEWLINE# assert ( ffi . typeof ( addr ) == ffi . typeof ( 'long(*)(long)' ) )