This is a little hack, but it might work for you. Hope someone else includes a cleaner way.
from ctypes import * class c_int_hack(c_int): def from_param(self, *args): return self funcspec = CFUNCTYPE(c_int, c_int_hack, POINTER(c_int)) @funcspec def callback(the_int, the_int_p): print(vars()) print(the_int.value) return 3 print(callback(c_int(1), byref(c_int(2))))
.. and conclusion:
{'the_int': <c_int_hack object at 0xb7478b6c>, 'the_int_p': <__main__.LP_c_long object at 0xb747892c>} 1 3
source share