Discussion:
call_pv built-in
(too old to reply)
William Ahern
2005-07-12 06:33:34 UTC
Permalink
Is it not possible to directly call built-in functions like caller? The only
way I could call caller was to wrap it in a subroutine, in this case an
anonymous sub routine: sub { caller shift }.

Everytime I tried to call it directly (with every option under the sun) Perl
would somehow longjmp over my XS code back into the initial call into Perl.
The flow looked like C -> Perl:perl_parse() -> C:XS -> Perl:call_pv("caller").
call_pv would jump back to per_parse, across the XS code. Very strange.

Things seem to be working, but I'm curious what the real issue was.

TIA,

Bill
Nick Ing-Simmons
2005-07-28 20:44:48 UTC
Permalink
Post by William Ahern
Is it not possible to directly call built-in functions like caller?
It is _possible_ to call perl ops from XS but is far from easy
- I have never bothered to finish working out all the hoops you have
to jump through.

You can "of course" do what caller() does in your C code - but that
isn't pretty either.
Post by William Ahern
The only
way I could call caller was to wrap it in a subroutine, in this case an
anonymous sub routine: sub { caller shift }.
That is what I did too.
Post by William Ahern
Everytime I tried to call it directly (with every option under the sun) Perl
would somehow longjmp over my XS code back into the initial call into Perl.
The flow looked like C -> Perl:perl_parse() -> C:XS -> Perl:call_pv("caller").
call_pv would jump back to per_parse, across the XS code. Very strange.
caller isn't a sub it is an opcode.

You are doing equivalent of &{"caller"}().

So perl is essentially die-ing which is why it longjmp()s.
If you had call_pv("caller",G_EVAL) you could have caught the message.
Post by William Ahern
Things seem to be working, but I'm curious what the real issue was.
TIA,
Bill
Loading...