Alan Burlison <[EMAIL PROTECTED]> writes:
>
> av = newAV();
> ...
> rv = newRV_noinc((SV *)av);
> sv_bless(rv, gv_stashpv("MyPackage", TRUE));
> sv_magic((SV *)av, Nullsv, 'P', Nullch, 0);
> RETVAL = rv;
Should that not be:
sv_magic((SV *)av, rv, 'P', Nullch, 0);
(Maybe not.)
>"Randy J. Ray" wrote:
>
>> I can't say for certain why the pure-perl implementation doesn't exhibit
>> the problem, but I had the same problem at an XS level when I started work
>> on the Perl-RPM bindings. In that case, I'm using a self-tied hash, but the
>> basis is identical.
>
>I think it perhaps twiddles the mg_flags to stop it recursively calling
>FETCH, but I'm dammned if I can figure out how I make it do the same.
>I've reread pp_tie and sv_magic over and over and I can't spot the
>trick.
That is 'cos it is in mg.c
mg_get() calls save_magic which does
SvMAGICAL_off(sv);
>
>> In my self-tied classes, I disable the tie magic before a fetch or store, then
>> reinstate it afterwards. I use simple cpp macros to do this. I don't think it
>> threatens empty-subclassing, since I don't affect the @ISA hierarchy or
>> anything else. Since the tie magic is very specific, I took the liberty/risk
>> of this approach. A sameple of the code I use:
>>
>> #define hv_fetch_nomg(SVP, h, k, kl, f) \
>> SvMAGICAL_off((SV *)(h)); \
>> (SVP) = hv_fetch((h), (k), (kl), (f)); \
>> SvMAGICAL_on((SV *)(h))
>>
>> Turning the magic off doesn't clear that part of the underlying structure, so
>> "switching" it back on has worked thus far.
>
>Unfortunately I can't do this as I can't predict when a store/fetch is
>going to happen.
You know when you are in one though - so FETCH could turn off magic
before it messed with "self".
>I need perl to figure out that it has a self tie and
>suppress the recursive calls to FETCH. I know it can be done, but I
>can't figure out how!
>
>Thanks anyway,
--
Nick Ing-Simmons <[EMAIL PROTECTED]>
Via, but not speaking for: Texas Instruments Ltd.