summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-10-01 22:14:19 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-10-06 13:01:00 -0700
commit0eeb01b957d2d66eec1a0e1e347c6d8772e5284e (patch)
tree110f9778173d6a76d65b152c2344eb48f09bc692
parent0fe84f7c4203febe7385a57fe43af2ee032318cf (diff)
downloadperl-0eeb01b957d2d66eec1a0e1e347c6d8772e5284e.tar.gz
Remove method param from gv_autoload_*
method is a boolean flag (typed I32, but used as a boolean) added by commit 54310121b442. These new gv_autoload_* functions have a flags parameter, so there’s no reason for this extra effective bool. We can just use a flag bit.
-rw-r--r--embed.fnc6
-rw-r--r--embed.h6
-rw-r--r--ext/XS-APItest/APItest.xs10
-rw-r--r--ext/XS-APItest/t/gv_autoload4.t16
-rw-r--r--gv.c14
-rw-r--r--gv.h9
-rw-r--r--proto.h6
7 files changed, 37 insertions, 30 deletions
diff --git a/embed.fnc b/embed.fnc
index 0fe0d3dc77..23d071d393 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -431,11 +431,11 @@ Apmb |GV* |gv_HVadd |NULLOK GV *gv
Apmb |GV* |gv_IOadd |NULLOK GV* gv
AmR |GV* |gv_autoload4 |NULLOK HV* stash|NN const char* name \
|STRLEN len|I32 method
-ApR |GV* |gv_autoload_sv |NULLOK HV* stash|NN SV* namesv|I32 method|U32 flags
+ApR |GV* |gv_autoload_sv |NULLOK HV* stash|NN SV* namesv|U32 flags
ApR |GV* |gv_autoload_pv |NULLOK HV* stash|NN const char* namepv \
- |I32 method|U32 flags
+ |U32 flags
ApR |GV* |gv_autoload_pvn |NULLOK HV* stash|NN const char* name \
- |STRLEN len|I32 method|U32 flags
+ |STRLEN len|U32 flags
Ap |void |gv_check |NN const HV* stash
Ap |void |gv_efullname |NN SV* sv|NN const GV* gv
Apmb |void |gv_efullname3 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix
diff --git a/embed.h b/embed.h
index 3e06942e11..8430619ec0 100644
--- a/embed.h
+++ b/embed.h
@@ -161,9 +161,9 @@
#define grok_numeric_radix(a,b) Perl_grok_numeric_radix(aTHX_ a,b)
#define grok_oct(a,b,c,d) Perl_grok_oct(aTHX_ a,b,c,d)
#define gv_add_by_type(a,b) Perl_gv_add_by_type(aTHX_ a,b)
-#define gv_autoload_pv(a,b,c,d) Perl_gv_autoload_pv(aTHX_ a,b,c,d)
-#define gv_autoload_pvn(a,b,c,d,e) Perl_gv_autoload_pvn(aTHX_ a,b,c,d,e)
-#define gv_autoload_sv(a,b,c,d) Perl_gv_autoload_sv(aTHX_ a,b,c,d)
+#define gv_autoload_pv(a,b,c) Perl_gv_autoload_pv(aTHX_ a,b,c)
+#define gv_autoload_pvn(a,b,c,d) Perl_gv_autoload_pvn(aTHX_ a,b,c,d)
+#define gv_autoload_sv(a,b,c) Perl_gv_autoload_sv(aTHX_ a,b,c)
#define gv_check(a) Perl_gv_check(aTHX_ a)
#define gv_const_sv(a) Perl_gv_const_sv(aTHX_ a)
#define gv_dump(a) Perl_gv_dump(aTHX_ a)
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 618bd32dc8..6ef52d1b8f 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -1953,29 +1953,29 @@ gv_fetchmethod_flags_type(stash, methname, type, flags)
XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
void
-gv_autoload_type(stash, methname, type, method, flags)
+gv_autoload_type(stash, methname, type, method)
HV* stash
SV* methname
int type
I32 method
- I32 flags
PREINIT:
STRLEN len;
const char * const name = SvPV_const(methname, len);
GV* gv;
+ I32 flags = method ? GV_AUTOLOAD_ISMETHOD : 0;
PPCODE:
switch (type) {
case 0:
gv = gv_autoload4(stash, name, len, method);
break;
case 1:
- gv = gv_autoload_sv(stash, methname, method, flags);
+ gv = gv_autoload_sv(stash, methname, flags);
break;
case 2:
- gv = gv_autoload_pv(stash, name, method, flags | SvUTF8(methname));
+ gv = gv_autoload_pv(stash, name, flags | SvUTF8(methname));
break;
case 3:
- gv = gv_autoload_pvn(stash, name, len, method, flags | SvUTF8(methname));
+ gv = gv_autoload_pvn(stash, name, len, flags | SvUTF8(methname));
break;
}
XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
diff --git a/ext/XS-APItest/t/gv_autoload4.t b/ext/XS-APItest/t/gv_autoload4.t
index dc4e2270a8..1f57437168 100644
--- a/ext/XS-APItest/t/gv_autoload4.t
+++ b/ext/XS-APItest/t/gv_autoload4.t
@@ -18,27 +18,27 @@ sub AUTOLOAD {
my $sub = "nothing";
-ok my $glob = XS::APItest::gv_autoload_type(\%::, $sub, 1, $method, 0);
+ok my $glob = XS::APItest::gv_autoload_type(\%::, $sub, 1, $method);
*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, '$AUTOLOAD set correctly' );
$sub = "some_sub";
for my $type ( 0..3 ) {
- is $glob = XS::APItest::gv_autoload_type(\%::, $sub, $type, $method, 0), "*main::AUTOLOAD", "*main::AUTOLOAD if autoload is true in $types[$type].";
+ is $glob = XS::APItest::gv_autoload_type(\%::, $sub, $type, $method), "*main::AUTOLOAD", "*main::AUTOLOAD if autoload is true in $types[$type].";
*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, '$AUTOLOAD set correctly' );
}
$sub = "method\0not quite!";
-ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 0, $method, 0);
+ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 0, $method);
*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, "gv_autoload4() is nul-clean");
-ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 1, $method, 0);
+ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 1, $method);
*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, "gv_autoload_sv() is nul-clean");
-ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 2, $method, 0);
+ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 2, $method);
*{$glob}{CODE}->( __PACKAGE__ . "::" . ($sub =~ s/\0.*//r), "gv_autoload_pv() is not nul-clean");
-ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 3, $method, 0);
+ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 3, $method);
*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, "gv_autoload_pvn() is nul-clean");
=begin
@@ -55,9 +55,9 @@ ok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 3, $method, 0);
}
for my $type ( 1..3 ) {
- ::ok $glob = XS::APItest::gv_autoload_type(\%main::, $sub = "method", $type, $method, 0);
+ ::ok $glob = XS::APItest::gv_autoload_type(\%main::, $sub = "method", $type, $method);
*{$glob}{CODE}->( "main::" . $sub, "$types[$type]() is UTF8-clean when both the stash and the sub are in UTF-8");
- ::ok $glob = XS::APItest::gv_autoload_type(\%main::, $sub = "method", $type, $method, 0);
+ ::ok $glob = XS::APItest::gv_autoload_type(\%main::, $sub = "method", $type, $method);
*{$glob}{CODE}->( "main::" . $sub, "$types[$type]() is UTF8-clean when only the stash is in UTF-8");
}
}
diff --git a/gv.c b/gv.c
index 81326d5e6d..e363a4c449 100644
--- a/gv.c
+++ b/gv.c
@@ -1079,7 +1079,7 @@ Perl_gv_fetchmethod_pvn_flags(pTHX_ HV *stash, const char *name, const STRLEN le
}
GV*
-Perl_gv_autoload_sv(pTHX_ HV *stash, SV* namesv, I32 method, U32 flags)
+Perl_gv_autoload_sv(pTHX_ HV *stash, SV* namesv, U32 flags)
{
char *namepv;
STRLEN namelen;
@@ -1087,18 +1087,18 @@ Perl_gv_autoload_sv(pTHX_ HV *stash, SV* namesv, I32 method, U32 flags)
namepv = SvPV(namesv, namelen);
if (SvUTF8(namesv))
flags |= SVf_UTF8;
- return gv_autoload_pvn(stash, namepv, namelen, method, flags);
+ return gv_autoload_pvn(stash, namepv, namelen, flags);
}
GV*
-Perl_gv_autoload_pv(pTHX_ HV *stash, const char *namepv, I32 method, U32 flags)
+Perl_gv_autoload_pv(pTHX_ HV *stash, const char *namepv, U32 flags)
{
PERL_ARGS_ASSERT_GV_AUTOLOAD_PV;
- return gv_autoload_pvn(stash, namepv, strlen(namepv), method, flags);
+ return gv_autoload_pvn(stash, namepv, strlen(namepv), flags);
}
GV*
-Perl_gv_autoload_pvn(pTHX_ HV *stash, const char *name, STRLEN len, I32 method, U32 flags)
+Perl_gv_autoload_pvn(pTHX_ HV *stash, const char *name, STRLEN len, U32 flags)
{
dVAR;
GV* gv;
@@ -1133,7 +1133,9 @@ Perl_gv_autoload_pvn(pTHX_ HV *stash, const char *name, STRLEN len, I32 method,
/*
* Inheriting AUTOLOAD for non-methods works ... for now.
*/
- if (!method && (GvCVGEN(gv) || GvSTASH(gv) != stash)
+ if (
+ !(flags & GV_AUTOLOAD_ISMETHOD)
+ && (GvCVGEN(gv) || GvSTASH(gv) != stash)
)
Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
"Use of inherited AUTOLOAD for non-method %s::%.*s() is deprecated",
diff --git a/gv.h b/gv.h
index 4ca5be1fc4..2b6941a329 100644
--- a/gv.h
+++ b/gv.h
@@ -222,8 +222,12 @@ Return the SV from the GV.
#define GV_NO_SVGMAGIC 0x800 /* Skip get-magic on an SV argument;
used only by gv_fetchsv(_nomg) */
+/* Flags for gv_autoload_*/
+#define GV_AUTOLOAD_ISMETHOD 1 /* autoloading a method? */
+
/* SVf_UTF8 (more accurately the return value from SvUTF8) is also valid
- as a flag to gv_fetch_pvn_flags, so ensure it lies outside this range.
+ as a flag to gv_fetchpvn_flags and gv_autoload_*, so ensure it lies
+ outside this range.
*/
#define GV_NOADD_MASK \
@@ -240,7 +244,8 @@ Return the SV from the GV.
#define gv_fetchmeth(stash,name,len,level) gv_fetchmeth_pvn(stash, name, len, level, 0)
#define gv_fetchmeth_autoload(stash,name,len,level) gv_fetchmeth_pvn_autoload(stash, name, len, level, 0)
#define gv_fetchmethod_flags(stash,name,flags) gv_fetchmethod_pv_flags(stash, name, flags)
-#define gv_autoload4(stash, name, len, method) gv_autoload_pvn(stash, name, len, method, 0)
+#define gv_autoload4(stash, name, len, method) \
+ gv_autoload_pvn(stash, name, len, !!(method))
#define gv_AVadd(gv) gv_add_by_type((gv), SVt_PVAV)
#define gv_HVadd(gv) gv_add_by_type((gv), SVt_PVHV)
diff --git a/proto.h b/proto.h
index 451400f7fa..2262cb380f 100644
--- a/proto.h
+++ b/proto.h
@@ -1146,19 +1146,19 @@ PERL_CALLCONV GV* Perl_gv_add_by_type(pTHX_ GV *gv, svtype type);
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_2); */
-PERL_CALLCONV GV* Perl_gv_autoload_pv(pTHX_ HV* stash, const char* namepv, I32 method, U32 flags)
+PERL_CALLCONV GV* Perl_gv_autoload_pv(pTHX_ HV* stash, const char* namepv, U32 flags)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_2);
#define PERL_ARGS_ASSERT_GV_AUTOLOAD_PV \
assert(namepv)
-PERL_CALLCONV GV* Perl_gv_autoload_pvn(pTHX_ HV* stash, const char* name, STRLEN len, I32 method, U32 flags)
+PERL_CALLCONV GV* Perl_gv_autoload_pvn(pTHX_ HV* stash, const char* name, STRLEN len, U32 flags)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_2);
#define PERL_ARGS_ASSERT_GV_AUTOLOAD_PVN \
assert(name)
-PERL_CALLCONV GV* Perl_gv_autoload_sv(pTHX_ HV* stash, SV* namesv, I32 method, U32 flags)
+PERL_CALLCONV GV* Perl_gv_autoload_sv(pTHX_ HV* stash, SV* namesv, U32 flags)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_2);
#define PERL_ARGS_ASSERT_GV_AUTOLOAD_SV \