diff options
author | David Mitchell <davem@iabyn.com> | 2016-11-10 20:44:16 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-11-12 16:15:09 +0000 |
commit | 9a70c74b0f460b0c96e443ecdfcb551157e02b51 (patch) | |
tree | b7f59e9bc08d86ebb042c3980b31991777380d4e /universal.c | |
parent | 4c57ced57467061af9e672665cba30edd3391432 (diff) | |
download | perl-9a70c74b0f460b0c96e443ecdfcb551157e02b51.tar.gz |
remove DOES's usage of SvSCREAM
Currently the SvSCREAM flag is set on a temporary SV whose string value
is "isa", but where for the purposes of printing
Can't call method "XXX"
its name is treated as "DOES" rather than "isa".
Instead, set the temp SV's PVX buffer to point to a special static
string (PL_isa_DOES) whose value is "isa", but the where the error
reporting code can compare the address with PL_isa_DOES and if so, print
"DOES" instead.
This is to reduce the number of odd special cases for the SvSCREAM flag.
Diffstat (limited to 'universal.c')
-rw-r--r-- | universal.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/universal.c b/universal.c index 345b75e815..b88d3e22d3 100644 --- a/universal.c +++ b/universal.c @@ -184,6 +184,10 @@ The SV can be a Perl object or the name of a Perl class. #include "XSUB.h" +/* a special string address whose value is "isa", but whicb perl knows + * to treat as if it were really "DOES" */ +char PL_isa_DOES[] = "isa"; + bool Perl_sv_does_sv(pTHX_ SV *sv, SV *namesv, U32 flags) { @@ -222,11 +226,14 @@ Perl_sv_does_sv(pTHX_ SV *sv, SV *namesv, U32 flags) PUSHs(namesv); PUTBACK; - methodname = newSVpvs_flags("isa", SVs_TEMP); - /* 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); + /* create a PV with value "isa", but with a special address + * so that perl knows were' realling doing "DOES" instead */ + methodname = newSV_type(SVt_PV); + SvLEN(methodname) = 0; + SvCUR(methodname) = strlen(PL_isa_DOES); + SvPVX(methodname) = PL_isa_DOES; + SvPOK_on(methodname); + sv_2mortal(methodname); call_sv(methodname, G_SCALAR | G_METHOD); SPAGAIN; |