[Pyrex] decoding returned variables

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jan 26 23:30:47 UTC 2007


Phil.Cummins at ga.gov.au wrote:
> I would like to wruite a Pyrex wrapper for a function which is called in 
> C as follows:
>
>      int dbgetv(Dbptr db, char *table_name, char *field_name, void 
> *value1, [ char *field_name2, void *value2, ... ], 0 )

There's no way you can create a general wrapper that will turn
one Python call into one C call to that function. That would be
impossible even in C without using platform-specific tricks.

Can you do it by making a separate call for each field? If not,
your only hope is if there is a vector version of this function
(like vprintf, etc.)

> how do I tell pyrex what pointers to pass, when their 
> types are only known at run time?

You'll have to find out the types somehow, either by passing
typecodes into the call or introspecting the database. Then
you'll have to switch on the types to different pieces of
code to handle each type.

--
Greg




More information about the Pyrex mailing list