2010/12/10 Oliver Seeliger <oli...@seeliger.name>:
>> Not necessarily. Let's assume I have code like this:
>> my $var = 'X';
>> myXSfunc();
>> In myXSfunc(), I want to access variable $var.
>
> Ok, understood what you're thinking of.
>
>> The question is whether there is a
>> function like perl_get_sv(), but for lexical variables?
>
> I don't know. Someone else?

There's no global way to find any lexical, you have to know where to
find them, in which scope, and best at which op it is attached to.
For a PADOP it's just PAD_SVl(o->op_padix)
See illguts: http://cpansearch.perl.org/src/RURBAN/illguts-0.35/index.html#pad
and
the Padwalker module, esp. peek_my()

First you need the scope, i.e, the depth, CvDEPTH.
Then there are two kinds of lexicals stored at CvPADLIST: Named and unnnamed.
Unnamed lexicals  are just index by op->targ.
my vars are usually named.

There are also two ways how to get to them internally, threaded or unthreaded.
-- 
Reini Urban
http://phpwiki.org/           http://murbreak.at/

Reply via email to