X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=universal.c;h=b082da67ffe0234b5534819843f612e26482cb11;hb=83437becac3a89db6e4fbc7e9b794e0d2e203eca;hp=3cd7166230b0fc9d4f836b3dd48da0b3933c40c0;hpb=1ab5d0547ab7398ea9e3e00b1c1b0f1f8ea0dd94;p=p5sagit%2Fp5-mst-13.2.git diff --git a/universal.c b/universal.c index 3cd7166..b082da6 100644 --- a/universal.c +++ b/universal.c @@ -120,8 +120,7 @@ XS(XS_UNIVERSAL_isa) sv = ST(0); name = (char *)SvPV(ST(1),na); - ST(0) = (sv_derived_from(sv, name) ? &sv_yes : &sv_no) ; - + ST(0) = boolSV(sv_derived_from(sv, name)); XSRETURN(1); } @@ -132,8 +131,6 @@ XS(XS_UNIVERSAL_can) SV *sv; char *name; SV *rv; - GV *gv; - CV *cvp; HV *pkg = NULL; if (items != 2) @@ -153,16 +150,9 @@ XS(XS_UNIVERSAL_can) } if (pkg) { - gv = gv_fetchmethod(pkg, name); - - if(gv && GvCV(gv)) { - /* If the sub is only a stub then we may have a gv to AUTOLOAD */ - GV **gvp = (GV**)hv_fetch(GvSTASH(gv), name, strlen(name), TRUE); - if(gvp && (cvp = GvCV(*gvp))) { - rv = sv_newmortal(); - sv_setsv(rv, newRV((SV*)cvp)); - } - } + GV *gv = gv_fetchmethod_autoload(pkg, name, FALSE); + if (gv && isGV(gv)) + rv = sv_2mortal(newRV((SV*)GvCV(gv))); } ST(0) = rv; @@ -170,26 +160,6 @@ XS(XS_UNIVERSAL_can) } static -XS(XS_UNIVERSAL_is_instance) -{ - dXSARGS; - ST(0) = SvROK(ST(0)) ? &sv_yes : &sv_no; - XSRETURN(1); -} - -static -XS(XS_UNIVERSAL_class) -{ - dXSARGS; - if(SvROK(ST(0)) && SvOBJECT(SvRV(ST(0)))) { - SV *sv = sv_newmortal(); - sv_setpv(sv, HvNAME(SvSTASH(SvRV(ST(0))))); - ST(0) = sv; - } - XSRETURN(1); -} - -static XS(XS_UNIVERSAL_VERSION) { dXSARGS; @@ -198,9 +168,7 @@ XS(XS_UNIVERSAL_VERSION) GV *gv; SV *sv; char *undef; -#ifdef _SYS_ISC - double req = SvNV(ST(1)); -#endif + double req; if(SvROK(ST(0))) { sv = (SV*)SvRV(ST(0)); @@ -225,14 +193,9 @@ XS(XS_UNIVERSAL_VERSION) undef = "(undef)"; } -#ifdef _SYS_ISC - /* needed for C compiler of Interactive Unix */ - if(items > 1 && (undef || (req = SvNV(ST(1)) && req > SvNV(sv)))) -#else - if(items > 1 && (undef || SvNV(ST(1)) > SvNV(sv))) -#endif + if (items > 1 && (undef || (req = SvNV(ST(1)), req > SvNV(sv)))) croak("%s version %s required--this is only version %s", - HvNAME(pkg),SvPV(ST(1),na),undef ? undef : SvPV(sv,na)); + HvNAME(pkg), SvPV(ST(1),na), undef ? undef : SvPV(sv,na)); ST(0) = sv; @@ -246,7 +209,5 @@ boot_core_UNIVERSAL() newXS("UNIVERSAL::isa", XS_UNIVERSAL_isa, file); newXS("UNIVERSAL::can", XS_UNIVERSAL_can, file); - newXS("UNIVERSAL::class", XS_UNIVERSAL_class, file); - newXS("UNIVERSAL::is_instance", XS_UNIVERSAL_is_instance, file); newXS("UNIVERSAL::VERSION", XS_UNIVERSAL_VERSION, file); }