2010/12/10 Oliver Seeliger :
>> 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
> > The question is whether there is a
> > function like perl_get_sv(), but for lexical variables?
>
> I don't know. Someone else?
Have a look at:
http://search.cpan.org/~robin/PadWalker/
It's not 'easy', but you should be able to copy/reuse some of the code.
Regards,
jez.
> 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 els
Hi,
>> SV* perl_get_sv("package::varname", FALSE);
>>
>> This returns NULL if the variable does not exist.
>>
>> If you want to know if this variable (or any other SV) is actually
>> defined, you can call:
>>
>> SvOK(SV*)
>
> Note that this works for global (package) variables only.
>
Hi Josef,
> I'd like to access a Perl-variable (a scalar) from within an XS. I do
> accept that the scalar may not (yet) exists, so I'd cater for that:
>
> How do I do that:
> - find out if a scalar exists
> - access the contents of the scalar.
If you know the name of a scalar variable, you can