bulk88 - That's exactly what I needed! Thank you! Now I have to figure out how to add args processing to this jit-compiled C function, but that's a different problem. :-)
David On Sat, Jul 21, 2012 at 2:31 AM, bulk 88 <bul...@hotmail.com> wrote: > > > --Forwarded Message Attachment-- > Date: Tue, 20 Mar 2012 11:34:37 -0500 > Subject: Creating an XSUB on the fly > From: dcmertens.p...@gmail.com > To: perl-xs@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. > -- "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." -- Brian Kernighan