RE: Creating an XSUB on the fly

[email protected] (bulk 88)
Newsgroups perl.xs
Message-ID <[email protected]>

--Forwarded Message Attachment--
Date: Tue, 20 Mar 2012 11:34:37 -0500
Subject: Creating an XSUB on the fly
From: [email protected]
To: [email protected]

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.