line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
23
|
|
|
23
|
|
1580252
|
use 5.005; |
|
23
|
|
|
|
|
248
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Types::Bool; |
5
|
|
|
|
|
|
|
$Types::Bool::VERSION = '2.98012'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: An interface to booleans as objects for Perl |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# For historical reasons, alias *Types::Bool::Impl with JSON::PP::Boolean |
12
|
23
|
|
|
23
|
|
234
|
*Types::Bool::Impl:: = *JSON::PP::Boolean::; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# JSON/PP/Boolean.pm is redundant |
15
|
|
|
|
|
|
|
$INC{'JSON/PP/Boolean.pm'} ||= __FILE__ |
16
|
23
|
50
|
50
|
|
|
6824
|
unless $ENV{TYPES_BOOL_NICE}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package # |
20
|
|
|
|
|
|
|
Types::Bool::Impl; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
BEGIN { |
23
|
23
|
|
|
23
|
|
22770
|
require overload; |
24
|
23
|
50
|
|
|
|
18237
|
if ( $ENV{TYPES_BOOL_LOUD} ) { |
25
|
0
|
|
|
|
|
0
|
my @o = grep __PACKAGE__->overload::Method($_), qw(0+ ++ --); |
26
|
0
|
|
|
|
|
0
|
my @s = grep __PACKAGE__->can($_), qw(new); |
27
|
0
|
0
|
|
|
|
0
|
push @s, '$VERSION' if $Types::Bool::VERSION; |
28
|
0
|
0
|
0
|
|
|
0
|
if ( @o || @s ) { |
29
|
0
|
|
|
|
|
0
|
my $p = ref do { bless \( my $dummy ), __PACKAGE__ }; |
|
0
|
|
|
|
|
0
|
|
30
|
0
|
|
|
|
|
0
|
my @f; |
31
|
0
|
0
|
|
|
|
0
|
push @f, join( ', ', @s ) if @s; |
32
|
0
|
0
|
|
|
|
0
|
push @f, 'overloads on ' . join( ', ', @o ) if @o; |
33
|
0
|
|
|
|
|
0
|
warn join( ' and ', @f ), qq{ defined for $p elsewhere}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
overload->import( |
38
|
0
|
|
|
0
|
|
0
|
'0+' => sub { ${ $_[0] } }, |
|
0
|
|
|
|
|
0
|
|
39
|
0
|
|
|
0
|
|
0
|
'++' => sub { $_[0] = ${ $_[0] } + 1 }, |
|
0
|
|
|
|
|
0
|
|
40
|
0
|
|
|
0
|
|
0
|
'--' => sub { $_[0] = ${ $_[0] } - 1 }, |
|
0
|
|
|
|
|
0
|
|
41
|
23
|
100
|
|
|
|
145
|
fallback => 1, |
42
|
|
|
|
|
|
|
) unless __PACKAGE__->overload::Method('0+'); |
43
|
|
|
|
|
|
|
|
44
|
46
|
100
|
|
46
|
|
3286
|
*new = sub { bless \( my $dummy = $_[1] ? 1 : 0 ), $_[0] } |
45
|
23
|
50
|
|
|
|
2232
|
unless __PACKAGE__->can('new'); |
46
|
|
|
|
|
|
|
|
47
|
23
|
50
|
|
|
|
612
|
$Types::Bool::Impl::VERSION = '2.98012' |
48
|
|
|
|
|
|
|
unless $Types::Bool::Impl::VERSION; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Types::Bool; |
52
|
|
|
|
|
|
|
|
53
|
23
|
|
|
23
|
|
130
|
use Scalar::Util (); |
|
23
|
|
|
|
|
41
|
|
|
23
|
|
|
|
|
750
|
|
54
|
|
|
|
|
|
|
|
55
|
23
|
|
|
23
|
|
126
|
use constant true => Types::Bool::Impl->new(1); |
|
23
|
|
|
|
|
35
|
|
|
23
|
|
|
|
|
90
|
|
56
|
23
|
|
|
23
|
|
130
|
use constant false => Types::Bool::Impl->new(0); |
|
23
|
|
|
|
|
43
|
|
|
23
|
|
|
|
|
60
|
|
57
|
|
|
|
|
|
|
|
58
|
23
|
|
|
23
|
|
106
|
use constant BOOL_PACKAGE => ref true; |
|
23
|
|
|
|
|
34
|
|
|
23
|
|
|
|
|
4140
|
|
59
|
|
|
|
|
|
|
|
60
|
175
|
100
|
|
175
|
1
|
86596
|
sub is_bool ($) { Scalar::Util::blessed( $_[0] ) and $_[0]->isa(BOOL_PACKAGE) } |
61
|
|
|
|
|
|
|
|
62
|
50
|
100
|
|
50
|
1
|
41632
|
sub to_bool ($) { $_[0] ? true : false } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
@Types::Bool::EXPORT_OK = qw(true false is_bool to_bool BOOL_PACKAGE); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
BEGIN { |
67
|
23
|
50
|
|
23
|
|
1095
|
if ( "$]" < 5.008003 ) { # Inherit from Exporter (if needed) |
68
|
0
|
|
|
|
|
0
|
require Exporter; |
69
|
0
|
|
|
|
|
0
|
my $EXPORTER_VERSION = Exporter->VERSION; |
70
|
0
|
|
|
|
|
0
|
$EXPORTER_VERSION =~ tr/_//d; |
71
|
0
|
0
|
|
|
|
0
|
push @Types::Bool::ISA, qw(Exporter) if $EXPORTER_VERSION < 5.57; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub import { # Load Exporter only if needed |
76
|
7
|
50
|
|
7
|
|
9359
|
return unless @_ > 1; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
require Exporter; |
79
|
|
|
|
|
|
|
|
80
|
23
|
|
|
23
|
|
139
|
no warnings 'redefine'; |
|
23
|
|
|
|
|
39
|
|
|
23
|
|
|
|
|
2137
|
|
81
|
|
|
|
|
|
|
*import = sub { |
82
|
0
|
0
|
|
0
|
|
|
return unless @_ > 1; |
83
|
0
|
|
|
|
|
|
goto &Exporter::import; |
84
|
0
|
|
|
|
|
|
}; |
85
|
0
|
|
|
|
|
|
goto &Exporter::import; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |