*/
STATIC bool
-S_isa_lookup(pTHX_ HV *stash, const char *name, const HV* const name_stash,
- int len, int level)
+S_isa_lookup(pTHX_ HV *stash, const char * const name, const HV* const name_stash)
{
dVAR;
- AV* av;
- GV* gv;
- GV** gvp;
- HV* hv = NULL;
- SV* subgen = NULL;
+ AV* stash_linear_isa;
+ SV** svp;
const char *hvname;
+ I32 items;
/* A stash/class can go by many names (ie. User == main::User), so
we compare the stash itself just in case */
if (strEQ(name, "UNIVERSAL"))
return TRUE;
- if (level > 100)
- Perl_croak(aTHX_ "Recursive inheritance detected in package '%s'",
- hvname);
-
- gvp = (GV**)hv_fetchs(stash, "::ISA::CACHE::", FALSE);
-
- if (gvp && (gv = *gvp) && isGV_with_GP(gv) && (subgen = GvSV(gv))
- && (hv = GvHV(gv)))
- {
- if (SvIV(subgen) == (IV)PL_sub_generation) {
- SV** const svp = (SV**)hv_fetch(hv, name, len, FALSE);
- if (svp) {
- SV * const sv = *svp;
-#ifdef DEBUGGING
- if (sv != &PL_sv_undef)
- DEBUG_o( Perl_deb(aTHX_ "Using cached ISA %s for package %s\n",
- name, hvname) );
-#endif
- return (sv == &PL_sv_yes);
- }
- }
- else {
- DEBUG_o( Perl_deb(aTHX_ "ISA Cache in package %s is stale\n",
- hvname) );
- hv_clear(hv);
- sv_setiv(subgen, PL_sub_generation);
+ stash_linear_isa = mro_get_linear_isa(stash);
+ svp = AvARRAY(stash_linear_isa) + 1;
+ items = AvFILLp(stash_linear_isa);
+ while (items--) {
+ SV* const basename_sv = *svp++;
+ HV* const basestash = gv_stashsv(basename_sv, 0);
+ if (!basestash) {
+ if (ckWARN(WARN_SYNTAX))
+ Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
+ "Can't locate package %"SVf" for the parents of %s",
+ SVfARG(basename_sv), hvname);
+ continue;
}
+ if(name_stash == basestash || strEQ(name, SvPVX(basename_sv)))
+ return TRUE;
}
- gvp = (GV**)hv_fetchs(stash, "ISA", FALSE);
-
- if (gvp && (gv = *gvp) && isGV_with_GP(gv) && (av = GvAV(gv))) {
- if (!hv || !subgen) {
- gvp = (GV**)hv_fetchs(stash, "::ISA::CACHE::", TRUE);
-
- gv = *gvp;
-
- if (SvTYPE(gv) != SVt_PVGV)
- gv_init(gv, stash, "::ISA::CACHE::", 14, TRUE);
-
- if (!hv)
- hv = GvHVn(gv);
- if (!subgen) {
- subgen = newSViv(PL_sub_generation);
- GvSV(gv) = subgen;
- }
- }
- if (hv) {
- SV** svp = AvARRAY(av);
- /* NOTE: No support for tied ISA */
- I32 items = AvFILLp(av) + 1;
- while (items--) {
- SV* const sv = *svp++;
- HV* const basestash = gv_stashsv(sv, 0);
- if (!basestash) {
- if (ckWARN(WARN_MISC))
- Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
- "Can't locate package %"SVf" for @%s::ISA",
- SVfARG(sv), hvname);
- continue;
- }
- if (isa_lookup(basestash, name, name_stash, len, level + 1)) {
- (void)hv_store(hv,name,len,&PL_sv_yes,0);
- return TRUE;
- }
- }
- (void)hv_store(hv,name,len,&PL_sv_no,0);
- }
- }
return FALSE;
}
if (stash) {
HV * const name_stash = gv_stashpv(name, 0);
- return isa_lookup(stash, name, name_stash, strlen(name), 0);
+ return isa_lookup(stash, name, name_stash);
}
else
return FALSE;
{
const char *classname;
bool does_it;
+ SV *methodname;
dSP;
ENTER;
if (sv_isobject(sv)) {
classname = sv_reftype(SvRV(sv),TRUE);
} else {
- classname = SvPV(sv,PL_na);
+ classname = SvPV_nolen(sv);
}
if (strEQ(name,classname))
XPUSHs(sv_2mortal(newSVpv(name, 0)));
PUTBACK;
- call_method("isa", G_SCALAR);
+ methodname = sv_2mortal(newSVpv("isa", 0));
+ /* ugly hack: use the SvSCREAM flag so S_method_common
+ * can figure out we're calling DOES() and not isa(),
+ * and report eventual errors correctly. --rgs */
+ SvSCREAM_on(methodname);
+ call_sv(methodname, G_SCALAR | G_METHOD);
SPAGAIN;
does_it = SvTRUE( TOPs );
newXSproto("Internals::hash_seed",XS_Internals_hash_seed, file, "");
newXSproto("Internals::rehash_seed",XS_Internals_rehash_seed, file, "");
newXSproto("Internals::HvREHASH", XS_Internals_HvREHASH, file, "\\%");
- newXSproto("Internals::inc_sub_generation",XS_Internals_inc_sub_generation,
- file, "");
newXSproto("re::is_regexp", XS_re_is_regexp, file, "$");
newXSproto("re::regname", XS_re_regname, file, ";$$");
newXSproto("re::regnames", XS_re_regnames, file, ";$");
PERL_UNUSED_ARG(cv);
if (items != 2)
- Perl_croak(aTHX_ "Usage: invocant->does(kind)");
+ Perl_croak(aTHX_ "Usage: invocant->DOES(kind)");
else {
SV * const sv = ST(0);
const char *name;
} else {
Perl_croak(aTHX_ "%s version %"SVf" required--"
"this is only version %"SVf"", HvNAME_get(pkg),
- SVfARG(vnumify(req)),
- SVfARG(vnumify(sv)));
+ SVfARG(vstringify(req)),
+ SVfARG(vstringify(sv)));
}
}
}
if ( SvOK(sv) && sv_derived_from(sv, "version") ) {
- ST(0) = vnumify(sv);
+ ST(0) = vstringify(sv);
} else {
ST(0) = sv;
}
Perl_croak(aTHX_ "Internals::HvREHASH $hashref");
}
-XS(XS_Internals_inc_sub_generation)
-{
- dVAR;
- /* Using dXSARGS would also have dITEM and dSP,
- * which define 2 unused local variables. */
- dAXMARK;
- PERL_UNUSED_ARG(cv);
- PERL_UNUSED_VAR(mark);
- ++PL_sub_generation;
- XSRETURN_EMPTY;
-}
-
XS(XS_re_is_regexp)
{
dVAR;
}
{
if (SvPOK(sv) && re && re->paren_names) {
- bufs = CALLREG_NAMEDBUF(re,sv,all && SvTRUE(all));
+ bufs = CALLREG_NAMEDBUF_FETCH(re,sv,all && SvTRUE(all));
if (bufs) {
if (all && SvTRUE(all))
XPUSHs(newRV(bufs));
I32 *nums = (I32*)SvPVX(sv_dat);
for ( i = 0; i < SvIVX(sv_dat); i++ ) {
if ((I32)(re->lastcloseparen) >= nums[i] &&
- re->startp[nums[i]] != -1 &&
- re->endp[nums[i]] != -1)
+ re->offs[nums[i]].start != -1 &&
+ re->offs[nums[i]].end != -1)
{
parno = nums[i];
break;
{
dVAR;
dXSARGS;
- if (items != 0 )
- Perl_croak(aTHX_ "Usage: %s(%s)", "re::regnames_iterinit");
+ if (items != 0)
+ Perl_croak(aTHX_ "Usage: re::regnames_iterinit()");
PERL_UNUSED_VAR(cv); /* -W */
PERL_UNUSED_VAR(ax); /* -Wall */
SP -= items;
I32 *nums = (I32*)SvPVX(sv_dat);
for ( i = 0; i < SvIVX(sv_dat); i++ ) {
if ((I32)(re->lastcloseparen) >= nums[i] &&
- re->startp[nums[i]] != -1 &&
- re->endp[nums[i]] != -1)
+ re->offs[nums[i]].start != -1 &&
+ re->offs[nums[i]].end != -1)
{
parno = nums[i];
break;