Rwilding <[EMAIL PROTECTED]> writes:
>Hi all,
>
>Can anyone point me in the direction of how to retrieve the name of the perl
>variable an XSub is going to return to (if its possible of course).
>
>For example, if in perl the statement $retName=XSUB_CALL(.....), where
>XSUB_CALL is some xsub call.
>
>I want to be able trace the value "$retName" from within the xsub. I've had a
>look around on the perl stack on entry to the xsub SvPV_nolen(ST(0)) appears
>to report the perl alias of the xsub function.
>
>I'm finding it hard to track down where in the source code perl branches off
>to do the xsub call and sets up/post processes the stack - i'd hoped this
>might have given me a clue, either that or confirm my suspicion that its not
>possible.

It isn't possible. The value is returned on the stack, and then another 
op some time later assigns value to its home. There are many cases 
where there is no named variable anyway e.g.

       sub_call(1,2,XSUB_CALL(...),4);

If you pass refrerence in and return via that :

       XSUB_CALL($retVal,...)

there is _still_ little chance of getting a name as you will be passed 
the SV that variable is bound to at the point of call. With closures:

     my $retVal;
     ...
     my $foo = sub { XSUB_CALL($retVal,...}
     ...
     my $bar = sub { XSUB_CALL($retVal,...}

Those are both '$retVal' but possibly _different_ ones...
also in general the names of lexicals are only "about" at compile time.

or local and glob tricks 

     local *retVal = \$realRet;
     XSUB_CALL($retVal);

it is hard to "name" that SV in a meaningful way. 





>
>Any pointers would be greatly appreciated!
>
>Rich
--
Nick Ing-Simmons http://www.ni-s.u-net.com/


Reply via email to