[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Callbacks using a 3rd party library in C
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 30 Jul 2004 11:22:42 -0300
> Assume a third party C library to wich I can register any number of
> callbacks that this library will sometimes call, like:
This is a problem that frequently arises in GUI toolkits. The solution depends
heavily on the signature of callback functions. It certainly helps when
they have a fixed signature that has room for user-supplied data. When this
happens, you can register a *fixed* dispatcher C function for all callbacks
adding enough information in the user-supplied data to be able to disptach to
Lua when the callback is called.
When the signatures of callback functions vary, you're stuck with registering
a dispatcher for each type. When the signatures do not have room for
user-supplied data, you're stuck with global Lua states and possibly more.