Registering LOTS of C level functions

Markus von Ehr vonehr at ira.uka.de
Thu Feb 1 10:17:42 EST 2001


Grant Munsey wrote:
> 
> I am covering several libraries ... each of which has a couple of thousand
> calls (don't ask!).
> I would really like some way to be able to register all of them to Python
> with one actual
> C function and an ID so that inside the C function I can generate the actual
> call by using
> a data structure that tells the actual functions address and what parameters
> it requires.
> 
> As it stands I don't see any way to do this without an excessive amount of
> trickery. Looks
> to me like there is no way to specify an extra parameter to the low level
> registration process
> for each function ... There is the "self" parameter but that would require
> me to allocate a Python
> object for each procedure I wanted to cover.
> 
> The only thing I can think of at the moment is to generate a bunch of
> re-direction procedures ....
> Tiny procedures that just get called from Python, add the ID code ... and
> then pass on to the
> "real" command handler.
> 
> Anyone have any suggestions?

You can use the calldll module by Sam Rushing which can call 
both __stdcall and __cdecl functions.

ftp://squirl.nightmare.com/pub/python/python-ext/

build a dictionary with your function IDs and the function addresses to
call 
them for each lib.

Markus



More information about the Python-list mailing list