[unix branch on mipsel arch]
I need to involve some method from a .so file, say libevent.so, but there's no guide to handle " typedef struct" as a parameter, here's my code snippet:
-----------------------------------------------------------------------------
import ffi
eventLib = ffi.open('libevent.so')
getHandler = eventLib.func('p', 'get_event_handler', 'Op')
def c(a, b):
print('*'*10)
open('/tmp/t.txt','w').write('test')
event_handler_c = ffi.callback('v', c, 'pp')
getHandler(event_handler_c, 'hoho')
-----------------------------------------------------------------------------
the callback func is definded like this:
typedef void (*EventCallback) (mEvent event, void *param);
get_event_handler is defided :
extern event_handler *get_event_handler(EventCallback callback, void *param);
But event_handler_c is node involved, I don't know why and how to deal with "C struct" as a parameter of a callback.
Your response will be greatly appreciated.
Tim.
how to handle callback and struct in ffi mod ?
Re: how to handle callback and struct in ffi mod ?
By looking for existing examples which do that, and it won't take long: https://github.com/micropython/micropyt ... example.pyhow to handle callback
By using uctypes module: http://docs.micropython.org/en/latest/u ... le-uctypesand struct in ffi mod ?
https://github.com/micropython/micropython-lib has further examples on ffi and uctypes usage.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/