On Sat, Sep 27, 2003 at 06:45:33PM -0400, Rudy Lippan wrote:
> On Sat, 27 Sep 2003, Tim Bunce wrote:
>
> > I think this would be okay:
> >
> > if (SvROK(sv) && !SvAMAGIC(sv) {
> > ...error...
> > }
> > string = SvPV(sv, len);
> >
>
> Adding the !SvMAGIC(sv) worked nicely, thank you.
Not SvMAGIC but SvAMAGIC. Note the extra "A" in the name.
> One question: What is the difference between SvMAGIC and SvMAGICAL? And
> do you know of a good online refrence on Magic?
#define SvMAGIC(sv) ((XPVMG*) SvANY(sv))->xmg_magic
#define SvMAGICAL(sv) (SvFLAGS(sv) & (SVs_GMG|SVs_SMG|SVs_RMG))
So SvMAGIC returns a pointer to the head of the list of magic
(only valid if SvMAGICAL(sv) is true, else could be garbage).
And SvMAGICAL(sv) is true if one of the get, set, or random
magic flags is set.
But what you're interested in is slightly different:
#define SVf_AMAGIC 0x10000000 /* has magical overloaded methods */
#define SvAMAGIC(sv) (SvFLAGS(sv) & SVf_AMAGIC)
Tim.
p.s. When in doubt "use the source, Luke" :)