bulk 88
2012-07-21 07:31:52 UTC
--Forwarded Message Attachment--
Date: Tue, 20 Mar 2012 11:34:37 -0500
Subject: Creating an XSUB on the fly
From: ***@gmail.com
To: perl-***@perl.org
Hello everybody -
I'm looking into hooking the Tiny C Compiler into Perl. Among other things, it can JIT-compile a string of C code and let you get a function pointer (or a pointer to any other structure of the compiled code that is globally scoped) that you can subsequently call from your original C program. I would like to try to use this to build Perl CVs/XSUBs, but I see no interface for creating an XSUB that is not installed into a package.
The easy work around is to have a designated package into which all such xsubs are installed and simply use newxs (see http://perldoc.perl.org/perlembed.html). The name given to the Perl-side function would be composed from a hashing algorithm of some sort to avoid collisions. Still, I would really like to create simple function references without having to create the entry in the package.
Thoughts? Wisdom?
David
.......................................................
_______________________________________________________
Per, http://perl5.git.perl.org/perl.git/blob/d845901fab02ff3b498515ad6e2d06c711724d24:/op.c#l7375 , I think if the package name is NULL, you get an anonymous CV that has no package with a refcount of 1.
Date: Tue, 20 Mar 2012 11:34:37 -0500
Subject: Creating an XSUB on the fly
From: ***@gmail.com
To: perl-***@perl.org
Hello everybody -
I'm looking into hooking the Tiny C Compiler into Perl. Among other things, it can JIT-compile a string of C code and let you get a function pointer (or a pointer to any other structure of the compiled code that is globally scoped) that you can subsequently call from your original C program. I would like to try to use this to build Perl CVs/XSUBs, but I see no interface for creating an XSUB that is not installed into a package.
The easy work around is to have a designated package into which all such xsubs are installed and simply use newxs (see http://perldoc.perl.org/perlembed.html). The name given to the Perl-side function would be composed from a hashing algorithm of some sort to avoid collisions. Still, I would really like to create simple function references without having to create the entry in the package.
Thoughts? Wisdom?
David
.......................................................
_______________________________________________________
Per, http://perl5.git.perl.org/perl.git/blob/d845901fab02ff3b498515ad6e2d06c711724d24:/op.c#l7375 , I think if the package name is NULL, you get an anonymous CV that has no package with a refcount of 1.