Hello, Reinhard,
Thanks for the reply... sorry I did not see it for a few days or I
would have responded sooner.
On Aug 29, 2005, at 4:29 AM, Reinhard Pagitsch wrote:
Book:
Extending and Embedding Perl
TIM JENNESS
SIMON COZENS
That looks like the key book all right. The new 2nd edition of
Advanced Perl Programming, also by Cozens, apparently has a section
on extending Perl, but it looks like the emphasis is mostly on CPAN
and thus your recommendation would be better.
The XS functions are (simplified) PUSHs (put something to the
stack), POPs (get something from the stack).
I think that you can call them from _all_ functions in your XS
file, or from an other .c/cpp file if you include the Perl header
files.
The trick is that if you want to use functions such as ST(0), the
variables ax and items have to be declared first, so while POPs might
have worked in the helper sub, ST did not. As this is a pack() style
function, popping variables of the top of the stack would have been
inappropriate -- the first thing needed is the TEMPLATE, which you
could only get to by popping every other item off the stack first.
I have since solved the problem another way, but while I was doing so
I found dXSARGS in perlapi, which looks like it does what I needed to
do. It was not listed under "Stack manipulation macros", where I
expected to find it, but under "Variables created by xsubpp and
xsubpp internal functions".
http://perldoc.perl.org/perlapi.html#Variables-created-by-'xsubpp'-
and-'xsubpp'-internal-functions
So, happy ending. Thanks again,
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/