I am attempting to write a complete perl interface to an existing library and SDK. The library is centered around processing of a data stream and is written in C; it has a few simple interface functions, and uses a user specified callback function to do all the work.
I've read (okay, somewhere btw. skimmed and read) perlcall, perlapi and perlguts. I've managed to write C code, and a special C wrapper for a user specified perl callback function. This part works. I can currently compile my C code, start it, and it will run the callback function which is written in perl. (every invocation of the C callback does a sv_setpvn, ..., call_pv, POPpx, memcpy, &c)
I've also written XS code to successfully let me access the other functions in the library (other than the register_callback function) successfully.
My question is this: What do I write in my XS code to let me ... run code in the calling interpreter's instance? When I try to call newSVpv in a c file being linked against my XS file I get errors about *my_perl not existing. Is there some XS function or keyword to get a pointer to the calling perl instance? My goal is to have a 'registercb' function in the XS file (which takes SV *name), and have the c-language callback function use call_sv (name ..).
Any help? Has anyone written a perl interface to a callback based library before that can offer advice?
In reply to perl->c->perl by jpollack
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |