On 2004-05-20, at 12:40:10 +0100, Dirk Koopman wrote: > I am confused. > > I have a simple scalar tie which uses an XS routine to do the fetching > and this all works just fine in perl code. > > However, I want to do a "tied" (or magical?) fetch on the same thing in > XS. When the thing is passed on the stack, it is a reference which > actually points to an opaque pointer to my internal data dictionary > system. It seems to me that it is the *reference* that has the magic on > it, not the dereferenced opaque pointer. > > Do I just do an SvNV(refsv) or do I have to dereference the refsv, then > do something else to invoke the magic. > > Effectively this is the perl equivaleny of what I want to do XS: > > my $n = $SAL::BAL; > > where $SAL::BAL is a tied variable that causes a numeric value contained > within the system (called SAL::BAL) to be put into $n (this all works). > > In my naive way, it would seem that this would be an XS equivalent: > > SV *refsv = get_sv("SAL::BAL", 0);
You may want to insert SvGETMAGIC(refsv); here. This will call C<mg_get> (which in turn will fetch a value) if C<refsv> is magical. > NV d = SvNV(refsv); > > But somehow, I doubt it :-) Have you tried to do it? ;-) Marcus -- Law of Continuity: Experiments should be reproducible. They should all fail the same way.