|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Hello and perl question-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hi, I've been looking at using swig for getting a perl wrapper of a C library and have come across a stumbling block - a check through the archives didn't turn up the answer. The C library requires registering callbacks, which would be in Perl. I've already written and tested the perl callbacks using an embedded perl library, so the "hard" part of wrapping the library seems to be done already. The only thing that remains is converting this code from the perl embedding API to something that works with SWIG. The question is: How do I get the reference to the PerlInterpreter that many of the embedding API macros use? In your typical embedded perl application, you have the moral equivalent of this code: #include <EXTERN.h> /* from the Perl distribution */ #include <perl.h> /* from the Perl distribution */ static PerlInterpreter *my_perl; /*** The Perl interpreter ***/ int main(int argc, char **argv, char **env) { my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, NULL, argc, argv, (char **)NULL); /* do some stuff until we want to call the perl handler */ dSP; ENTER; SAVETMPS; PUSHMARK(sp); /* push the params into the call stack */ XPUSHs( sv_2mortal( sv1)); ... XPUSHs( sv_2mortal( svN)); PUTBACK; /* call the perl handler */ n = perl_call_sv( handler, G_SCALAR); SPAGAIN; PUTBACK; FREETMPS; LEAVE; /* done calling the perl handler */ perl_destruct(my_perl); perl_free(my_perl); } Many of the macros from the dSP through to LEAVE make reference to the static my_perl defined globally. My question is, will the same code basically work within SWIG? And if so, then how do I get hold of the handle to the static perl_interpreter that is running the wrapped code? I figure the answer is either really easy, or really hard. I'm hoping it is the former. Thanks in advance, Steve -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.12 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrTrYAACgkQcVd2YI1BWAhT+gCeJwT8GqsL1cWNqcqtY7iJaEgq c3oAn2aroyBydsMCQaQy/HjAthBwJwnJ =E9DI -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
|
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |