Re: Accessing variables from inside a C-XS

2010-12-10 Thread Reini Urban
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

RE: Accessing variables from inside a C-XS

2010-12-10 Thread Jeremy White
> > 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.

Re: Accessing variables from inside a C-XS

2010-12-10 Thread 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 variables? I don't know. Someone els

Re: Accessing variables from inside a C-XS

2010-12-09 Thread Oliver Seeliger
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. >

Re: Accessing variables from inside a C-XS

2010-12-09 Thread Oliver Seeliger
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