Skip to content

Commit

Permalink
Rename is{bool,weak} to is_{bool,weak}
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed Mar 7, 2022
1 parent 7ea8b04 commit 5caabca
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 101 deletions.
12 changes: 6 additions & 6 deletions builtin.c
Expand Up @@ -97,12 +97,12 @@ XS(XS_builtin_func1_scalar)
croak_xs_usage(cv, "arg");

switch(ix) {
case OP_ISBOOL:
Perl_pp_isbool(aTHX);
case OP_IS_BOOL:
Perl_pp_is_bool(aTHX);
break;

case OP_ISWEAK:
Perl_pp_isweak(aTHX);
case OP_IS_WEAK:
Perl_pp_is_weak(aTHX);
break;

case OP_BLESSED:
Expand Down Expand Up @@ -205,10 +205,10 @@ static const struct BuiltinFuncDescriptor builtins[] = {
{ "builtin::false", &XS_builtin_false, &ck_builtin_const, BUILTIN_CONST_FALSE },

/* unary functions */
{ "builtin::isbool", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_ISBOOL },
{ "builtin::is_bool", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_BOOL },
{ "builtin::weaken", &XS_builtin_func1_void, &ck_builtin_func1, OP_WEAKEN },
{ "builtin::unweaken", &XS_builtin_func1_void, &ck_builtin_func1, OP_UNWEAKEN },
{ "builtin::isweak", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_ISWEAK },
{ "builtin::is_weak", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_WEAK },
{ "builtin::blessed", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_BLESSED },
{ "builtin::refaddr", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_REFADDR },
{ "builtin::reftype", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_REFTYPE },
Expand Down
6 changes: 3 additions & 3 deletions ext/Opcode/Opcode.pm
Expand Up @@ -6,7 +6,7 @@ use strict;

our($VERSION, @ISA, @EXPORT_OK);

$VERSION = "1.56";
$VERSION = "1.57";

use Carp;
use Exporter 'import';
Expand Down Expand Up @@ -353,8 +353,8 @@ invert_opset function.
cmpchain_and cmpchain_dup
isbool
isweak weaken unweaken
is_bool
is_weak weaken unweaken
leaveeval -- needed for Safe to operate, is safe
without entereval
Expand Down
6 changes: 3 additions & 3 deletions lib/B/Deparse.pm
Expand Up @@ -53,7 +53,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
MDEREF_SHIFT
);

our $VERSION = '1.62';
our $VERSION = '1.63';
our $AUTOLOAD;
use warnings ();
require feature;
Expand Down Expand Up @@ -6631,8 +6631,8 @@ sub builtin1 {
return "builtin::$name($arg)";
}

sub pp_isbool { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "isbool"); }
sub pp_isweak { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "isweak"); }
sub pp_is_bool { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "is_bool"); }
sub pp_is_weak { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "is_weak"); }
sub pp_weaken { builtin1(@_, "weaken"); }
sub pp_unweaken { builtin1(@_, "unweaken"); }
sub pp_blessed { builtin1(@_, "blessed"); }
Expand Down
4 changes: 2 additions & 2 deletions lib/B/Deparse.t
Expand Up @@ -3212,8 +3212,8 @@ defer {
# builtin:: functions
# CONTEXT no warnings 'experimental::builtin';
my $x;
$x = builtin::isbool(undef);
$x = builtin::isweak(undef);
$x = builtin::is_bool(undef);
$x = builtin::is_weak(undef);
builtin::weaken($x);
builtin::unweaken($x);
$x = builtin::blessed(undef);
Expand Down
8 changes: 4 additions & 4 deletions lib/B/Op_private.pm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions lib/builtin.pm
Expand Up @@ -17,8 +17,8 @@ builtin - Perl pragma to import built-in utility functions
=head1 SYNOPSIS
use builtin qw(
true false isbool
weaken unweaken isweak
true false is_bool
weaken unweaken is_weak
blessed refaddr reftype
ceil floor
);
Expand Down Expand Up @@ -48,12 +48,12 @@ pragmas such as L<strict> and L<feature>.
{
my $val = shift;
use builtin 'isbool';
return isbool($val) ? "boolean" : "not a boolean";
use builtin 'is_bool';
return is_bool($val) ? "boolean" : "not a boolean";
}
# the isbool() function is no longer visible here
# but may still be called by builtin::isbool()
# the is_bool() function is no longer visible here
# but may still be called by builtin::is_bool()
Because these functions are imported lexically, rather than by package
symbols, the user does not need to take any special measures to ensure they
Expand All @@ -78,7 +78,7 @@ don't accidentally appear as object methods from a class.
Returns the boolean truth value. While any scalar value can be tested for
truth and most defined, non-empty and non-zero values are considered "true"
by perl, this one is special in that L</isbool> considers it to be a
by perl, this one is special in that L</is_bool> considers it to be a
distinguished boolean value.
This gives an equivalent value to expressions like C<!!1> or C<!0>.
Expand All @@ -88,21 +88,24 @@ This gives an equivalent value to expressions like C<!!1> or C<!0>.
$val = false;
Returns the boolean fiction value. While any non-true scalar value is
considered "false" by perl, this one is special in that L</isbool> considers
considered "false" by perl, this one is special in that L</is_bool> considers
it to be a distinguished boolean value.
This gives an equivalent value to expressions like C<!!0> or C<!1>.
=head2 isbool
=head2 is_bool
$bool = isbool($val);
$bool = is_bool($val);
Returns true when given a distinguished boolean value, or false if not. A
distinguished boolean value is the result of any boolean-returning builtin
function (such as C<true> or C<isbool> itself), boolean-returning operator
function (such as C<true> or C<is_bool> itself), boolean-returning operator
(such as the C<eq> or C<==> comparison tests or the C<!> negation operator),
or any variable containing one of these results.
This function used to be named C<isbool>. A compatibility alias is provided
currently but will be removed in a later version.
=head2 weaken
weaken($ref);
Expand All @@ -118,13 +121,16 @@ value set to C<undef>.
Strengthens a reference, undoing the effects of a previous call to L</weaken>.
=head2 isweak
=head2 is_weak
$bool = isweak($ref);
$bool = is_weak($ref);
Returns true when given a weakened reference, or false if not a reference or
not weak.
This function used to be named C<isweak>. A compatibility alias is provided
currently but will be removed in a later version.
=head2 blessed
$str = blessed($ref);
Expand Down
36 changes: 18 additions & 18 deletions lib/builtin.t
Expand Up @@ -19,51 +19,51 @@ package FetchStoreCounter {

# booleans
{
use builtin qw( true false isbool );
use builtin qw( true false is_bool );

ok(true, 'true is true');
ok(!false, 'false is false');

ok(isbool(true), 'true is bool');
ok(isbool(false), 'false is bool');
ok(!isbool(undef), 'undef is not bool');
ok(!isbool(1), '1 is not bool');
ok(!isbool(""), 'empty is not bool');
ok(is_bool(true), 'true is bool');
ok(is_bool(false), 'false is bool');
ok(!is_bool(undef), 'undef is not bool');
ok(!is_bool(1), '1 is not bool');
ok(!is_bool(""), 'empty is not bool');

my $truevar = (5 == 5);
my $falsevar = (5 == 6);

ok(isbool($truevar), '$truevar is bool');
ok(isbool($falsevar), '$falsevar is bool');
ok(is_bool($truevar), '$truevar is bool');
ok(is_bool($falsevar), '$falsevar is bool');

ok(isbool(isbool(true)), 'isbool true is bool');
ok(isbool(isbool(123)), 'isbool false is bool');
ok(is_bool(is_bool(true)), 'is_bool true is bool');
ok(is_bool(is_bool(123)), 'is_bool false is bool');

# Invokes magic

tie my $tied, FetchStoreCounter => (\my $fetchcount, \my $storecount);

my $_dummy = isbool($tied);
is($fetchcount, 1, 'isbool() invokes FETCH magic');
my $_dummy = is_bool($tied);
is($fetchcount, 1, 'is_bool() invokes FETCH magic');

$tied = isbool(false);
is($storecount, 1, 'isbool() TARG invokes STORE magic');
$tied = is_bool(false);
is($storecount, 1, 'is_bool() TARG invokes STORE magic');
}

# weakrefs
{
use builtin qw( isweak weaken unweaken );
use builtin qw( is_weak weaken unweaken );

my $arr = [];
my $ref = $arr;

ok(!isweak($ref), 'ref is not weak initially');
ok(!is_weak($ref), 'ref is not weak initially');

weaken($ref);
ok(isweak($ref), 'ref is weak after weaken()');
ok(is_weak($ref), 'ref is weak after weaken()');

unweaken($ref);
ok(!isweak($ref), 'ref is not weak after unweaken()');
ok(!is_weak($ref), 'ref is not weak after unweaken()');

weaken($ref);
undef $arr;
Expand Down
26 changes: 13 additions & 13 deletions opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions opnames.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pp.c
Expand Up @@ -7212,7 +7212,7 @@ PP(pp_cmpchain_dup)
RETURN;
}

PP(pp_isbool)
PP(pp_is_bool)
{
dSP;
dTARGET;
Expand All @@ -7225,7 +7225,7 @@ PP(pp_isbool)
RETURN;
}

PP(pp_isweak)
PP(pp_is_weak)
{
dSP;
dTARGET;
Expand Down
4 changes: 2 additions & 2 deletions pp_proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions regen/opcodes
Expand Up @@ -584,8 +584,8 @@ poptry pop try ck_null @
catch catch {} block ck_null |
pushdefer push defer {} block ck_null |

isbool boolean type test ck_null fsT1
isweak weakref type test ck_null fsT1
is_bool boolean type test ck_null fsT1
is_weak weakref type test ck_null fsT1
weaken reference weaken ck_null 1
unweaken reference unweaken ck_null 1
blessed blessed ck_null fs1
Expand Down

0 comments on commit 5caabca

Please sign in to comment.