jpollack has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl->c->perl
by creamygoodness (Curate) on Dec 12, 2005 at 17:55 UTC | |
|
Re: perl->c->perl
by philcrow (Priest) on Dec 12, 2005 at 17:43 UTC | |
by jpollack (Novice) on Dec 12, 2005 at 18:02 UTC | |
by tye (Sage) on Dec 12, 2005 at 18:48 UTC | |
by jpollack (Novice) on Dec 27, 2005 at 03:02 UTC | |
by tye (Sage) on Dec 27, 2005 at 04:08 UTC | |
| |
by Intrepid (Curate) on Dec 12, 2005 at 17:57 UTC | |
|
Re: perl->c->perl
by salva (Canon) on Dec 13, 2005 at 09:35 UTC |