in reply to Verifying function references in XSUBs
if (SvROK(sv) && SvTYPE(sv) == SVt_PVCV) warn("sv is a code reference (CV) alright.");
As for your second question, you can check that an sv is a reference to an object of (or derived from) a given class using sv_derived_from() (untested all the way):
if (SvROK(sv) && sv_derived_from(sv, "Foo")) warn("sv isa Foo");
And to check that a method is valid for a given class you can do something like (really untested):
if (gv_fetchmethod(gv_stashpv("Foo", 0), "Foo::bar")) warn("succeeded in finding Foo::bar");
Now, I doubt I answered your all your questions, but you weren't exactly clear about what you're trying to do. Maybe you can explain in more detail?
-sam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Verifying function references in XSUBs
by rsteinke (Scribe) on May 21, 2002 at 21:23 UTC | |
by samtregar (Abbot) on May 21, 2002 at 22:10 UTC |