diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-08-07 14:48:32 +0100 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2021-09-10 20:08:40 +0100 |
commit | 1d0d673f78c5c03a0f3c97ceeb7686e9388e0611 (patch) | |
tree | 388abd531263b971a0bfa2762402a33a3c0148ca /ext | |
parent | 914bb57489325d34ddbb7c0557c53df7baa84d86 (diff) | |
download | perl-1d0d673f78c5c03a0f3c97ceeb7686e9388e0611.tar.gz |
Add SvIsBOOL() macro to test for SVs being boolean-intent
These are identified as being static shared COW strings whose string
buffer points directly at PL_Yes / PL_No
Define sv_setbool() and sv_setbool_mg() macros
Use sv_setbool() where appropriate
Have sv_dump() annotate when an SV's PV buffer is one of the PL_(Yes|No) special booleans
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B.pm | 2 | ||||
-rw-r--r-- | ext/B/B.xs | 2 | ||||
-rw-r--r-- | ext/Devel-Peek/t/Peek.t | 24 | ||||
-rw-r--r-- | ext/attributes/attributes.pm | 2 | ||||
-rw-r--r-- | ext/attributes/attributes.xs | 2 |
5 files changed, 28 insertions, 4 deletions
diff --git a/ext/B/B.pm b/ext/B/B.pm index ef23af6baa..9e6f2897c8 100644 --- a/ext/B/B.pm +++ b/ext/B/B.pm @@ -20,7 +20,7 @@ sub import { # walkoptree comes from B.xs BEGIN { - $B::VERSION = '1.82'; + $B::VERSION = '1.83'; @B::EXPORT_OK = (); # Our BOOT code needs $VERSION set, and will append to @EXPORT_OK. diff --git a/ext/B/B.xs b/ext/B/B.xs index e6e3fb8309..7cdd0f9c6a 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -638,7 +638,7 @@ BOOT: cv = newXS("B::diehook", intrpvar_sv_common, file); ASSIGN_COMMON_ALIAS(I, diehook); sv = get_sv("B::OP::does_parent", GV_ADDMULTI); - sv_setsv(sv, &PL_sv_yes); + sv_setbool(sv, TRUE); } void diff --git a/ext/Devel-Peek/t/Peek.t b/ext/Devel-Peek/t/Peek.t index 63a002879a..63face8cd1 100644 --- a/ext/Devel-Peek/t/Peek.t +++ b/ext/Devel-Peek/t/Peek.t @@ -240,6 +240,30 @@ do_test('reference to scalar', COW_REFCNT = 1 '); +do_test('immediate boolean', + !!0, +'SV = PVNV\\($ADDR\\) at $ADDR + REFCNT = \d+ + FLAGS = \\(.*\\) + IV = 0 + NV = 0 + PV = $ADDR "" \[BOOL PL_No\] + CUR = 0 + LEN = 0 +') if $] >= 5.035004; + +do_test('assignment of boolean', + do { my $tmp = !!1 }, +'SV = PVNV\\($ADDR\\) at $ADDR + REFCNT = \d+ + FLAGS = \\(.*\\) + IV = 1 + NV = 1 + PV = $ADDR "1" \[BOOL PL_Yes\] + CUR = 1 + LEN = 0 +') if $] >= 5.035004; + my $c_pattern; if ($type eq 'N') { $c_pattern = ' diff --git a/ext/attributes/attributes.pm b/ext/attributes/attributes.pm index c60f9406b9..4f613f4084 100644 --- a/ext/attributes/attributes.pm +++ b/ext/attributes/attributes.pm @@ -1,6 +1,6 @@ package attributes; -our $VERSION = 0.33; +our $VERSION = 0.34; @EXPORT_OK = qw(get reftype); @EXPORT = (); diff --git a/ext/attributes/attributes.xs b/ext/attributes/attributes.xs index 07b7b8dfe8..f2f28df938 100644 --- a/ext/attributes/attributes.xs +++ b/ext/attributes/attributes.xs @@ -204,7 +204,7 @@ usage: Perl_sv_sethek(aTHX_ TARG, HvNAME_HEK(SvSTASH(sv))); #if 0 /* this was probably a bad idea */ else if (SvPADMY(sv)) - sv_setsv(TARG, &PL_sv_no); /* unblessed lexical */ + sv_setbool(TARG, FALSE); /* unblessed lexical */ #endif else { const HV *stash = NULL; |