On Thu, Jul 12, 2012 at 10:00:08PM -0700, Father Chrysostomos wrote:
>
> On Jul 10, 2012, at 5:50 PM, Jesse Luehrs wrote:
> > So the pure perl version worked fine, but I'm trying to adjust the XS
> > version to do the same thing, and I'm really not sure what the right way
> > to go about it is. gv_init isn't sufficient, because it doesn't attach
> > the appropriate magic. The only function that knows about the kinds of
> > magic that need to be attached to globs is gv_fetchpvn_flags, and that
> > requires a stash name, rather than a stash pointer. Is there any actual
> > API for stash aliasing in C (to work around this for now), or am I going
> > to need to poke around at the internals to emulate the behavior?
>
> In 5.10 you have to emulate it:
>
> sv_magic((SV *)GvAVn(gv), (SV *)gv, PERL_MAGIC_isa, NULL, 0);
>
> In 5.12 (d851b122) you can do this:
>
> SV *rv = newRV_noinc(newAV());
> sv_setsv(gv, rv);
> SvREFCNT_dec(rv);
>
> In 5.17.2 (986d39eeb4) you can do this:
>
> GvAVn(gv);
Sure, but @ISA is only a single case of magical variables. What if gv
is intended for $main::{'^W'}, or something like that? I really don't
want to have to hardcode all of the different variables that might have
magic, especially since it changes between perl versions. The more I
look into it though, the more I can't really see it being reasonably
possible without modifications to the core (in particular, a variant of
gv_fetchpvn_flags that looks things up in a provided stash pointer,
rather than by name). I may have to just stick to name lookups in my
code until something like this makes its way into core.
-doy
Thread Previous
|
Thread Next