line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Carp::Growl; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
124915
|
use warnings; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
375
|
|
4
|
11
|
|
|
11
|
|
55
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
304
|
|
5
|
11
|
|
|
11
|
|
51
|
use Carp; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
1146
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
9447
|
use version; our $VERSION = '0.0.10'; |
|
11
|
|
|
|
|
26691
|
|
|
11
|
|
|
|
|
71
|
|
8
|
|
|
|
|
|
|
|
9
|
11
|
|
|
11
|
|
5878
|
use Growl::Any; |
|
11
|
|
|
|
|
92
|
|
|
11
|
|
|
|
|
1811
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $build_warnmess; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $DEFAULT_FUNCS = +{}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
16
|
|
|
|
|
|
|
$build_warnmess = sub { |
17
|
30
|
|
|
|
|
74
|
my ( $func, @args ) = @_; |
18
|
30
|
|
|
|
|
143
|
my ( $pkg, $file, $line ) = caller(1); |
19
|
30
|
|
|
|
|
52
|
my $self; |
20
|
30
|
50
|
|
|
|
79
|
unless (@args) { |
21
|
0
|
0
|
|
|
|
0
|
unshift @args, |
22
|
|
|
|
|
|
|
( $func eq 'warn' ? "Warning: something's wrong" : "Died" ); |
23
|
|
|
|
|
|
|
} |
24
|
30
|
|
|
|
|
67
|
$self = join( $", @args ); |
25
|
30
|
100
|
|
|
|
106
|
unless ( $self =~ s/\n \z//msx ) { |
26
|
28
|
|
|
|
|
135
|
$self .= " at $file line $line."; |
27
|
|
|
|
|
|
|
} |
28
|
30
|
|
|
|
|
148
|
$self; |
29
|
11
|
|
|
11
|
|
3771
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
if ( $] < 5.016000 ) { |
33
|
|
|
|
|
|
|
@{$DEFAULT_FUNCS}{qw/warn die/} = ( |
34
|
|
|
|
|
|
|
sub { CORE::warn( $build_warnmess->( 'warn', @_ ), $/ ); }, |
35
|
|
|
|
|
|
|
sub { CORE::die( $build_warnmess->( 'die', @_ ), $/ ); }, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
|
|
|
|
|
|
$DEFAULT_FUNCS->{warn} = \&CORE::warn; |
40
|
|
|
|
|
|
|
$DEFAULT_FUNCS->{die} = \&CORE::die; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $g = Growl::Any->new( appname => __PACKAGE__, events => [qw/warn die/] ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our @CARP_NOT; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $KEEP = {}; |
48
|
|
|
|
|
|
|
my $imported = 0; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $AVAILABLE_IMPORT_ARGS = [qw/global/]; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $validate_args = sub { |
53
|
|
|
|
|
|
|
my %bads; |
54
|
|
|
|
|
|
|
for my $good (@$AVAILABLE_IMPORT_ARGS) { |
55
|
|
|
|
|
|
|
$bads{$_}++ for grep { $_ ne $good } @_; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
keys %bads; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
for my $f (qw/carp croak/) { |
60
|
11
|
|
|
11
|
|
69
|
no strict 'refs'; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
2206
|
|
61
|
|
|
|
|
|
|
$DEFAULT_FUNCS->{$f} = *{ 'Carp::' . $f }{CODE}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
my $BUILD_FUNC_ARGS = +{ |
64
|
|
|
|
|
|
|
warn => { event => 'warn', title => 'WARNING', }, |
65
|
|
|
|
|
|
|
die => { event => 'die', title => 'FATAL', }, |
66
|
|
|
|
|
|
|
carp => { event => 'warn', title => 'WARNING', }, |
67
|
|
|
|
|
|
|
croak => { event => 'die', title => 'FATAL', }, |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _build_func { |
71
|
56
|
|
|
56
|
|
75
|
my $func = shift; |
72
|
56
|
100
|
100
|
|
|
810
|
if ( ( $func eq 'warn' || $func eq 'die' ) ) { |
73
|
|
|
|
|
|
|
return sub { |
74
|
30
|
50
|
|
30
|
|
37953
|
$g->notify( |
75
|
|
|
|
|
|
|
$BUILD_FUNC_ARGS->{$func}->{event}, # event |
76
|
|
|
|
|
|
|
$BUILD_FUNC_ARGS->{$func}->{title}, # title |
77
|
|
|
|
|
|
|
$build_warnmess->( $func, @_ ), # message |
78
|
|
|
|
|
|
|
undef, # icon |
79
|
|
|
|
|
|
|
) |
80
|
|
|
|
|
|
|
if defined $^S; |
81
|
30
|
|
|
|
|
166
|
goto &{ $DEFAULT_FUNCS->{$func} }; |
|
30
|
|
|
|
|
488
|
|
82
|
28
|
|
|
|
|
154
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
|
|
|
|
|
|
return sub { |
86
|
11
|
|
|
11
|
|
59
|
no strict 'refs'; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
3368
|
|
87
|
|
|
|
|
|
|
# if ( caller eq 'main' ) { |
88
|
|
|
|
|
|
|
# local *{'main::CARP_NOT'}; |
89
|
|
|
|
|
|
|
# push @{ *{'main::CARP_NOT'} }, __PACKAGE__; |
90
|
|
|
|
|
|
|
# } |
91
|
30
|
|
|
30
|
|
37604
|
my $msg = Carp::shortmess(@_); |
92
|
30
|
|
|
|
|
442
|
chomp $msg; |
93
|
30
|
50
|
|
|
|
229
|
$g->notify( |
94
|
|
|
|
|
|
|
$BUILD_FUNC_ARGS->{$func}->{event}, # event |
95
|
|
|
|
|
|
|
$BUILD_FUNC_ARGS->{$func}->{title}, # title |
96
|
|
|
|
|
|
|
$msg, # message |
97
|
|
|
|
|
|
|
undef, # icon |
98
|
|
|
|
|
|
|
) |
99
|
|
|
|
|
|
|
if defined $^S; |
100
|
30
|
|
|
|
|
351
|
goto &{ $DEFAULT_FUNCS->{$func} }; |
|
30
|
|
|
|
|
3661
|
|
101
|
28
|
|
|
|
|
115
|
}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
##~~~~~ IMPORT ~~~~~## |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub import { |
108
|
16
|
|
|
16
|
|
3824
|
my $self = shift; |
109
|
16
|
|
|
|
|
40
|
my @args = @_; |
110
|
16
|
100
|
|
|
|
54
|
if (@args) { |
111
|
7
|
|
|
|
|
18
|
my @bads = $validate_args->(@args); |
112
|
7
|
100
|
|
|
|
44
|
CORE::die 'Illegal args: "' |
113
|
|
|
|
|
|
|
. join( '", "', @bads ) |
114
|
|
|
|
|
|
|
. '" for import()' |
115
|
|
|
|
|
|
|
if @bads; |
116
|
5
|
|
|
|
|
10
|
$imported = 2; |
117
|
5
|
50
|
|
|
|
8
|
goto &_global_import if grep { $_ eq 'global' } @args; |
|
5
|
|
|
|
|
36
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else { |
120
|
9
|
|
|
|
|
21
|
$imported = 1; |
121
|
|
|
|
|
|
|
} |
122
|
9
|
|
|
|
|
43
|
goto &_local_import; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _local_import { |
126
|
14
|
100
|
|
14
|
|
61
|
my $args = @_ ? \@_ : [ keys %$BUILD_FUNC_ARGS ]; |
127
|
14
|
|
|
|
|
36
|
my $pkg = caller(); |
128
|
11
|
|
|
11
|
|
59
|
no strict 'refs'; |
|
11
|
|
|
|
|
34
|
|
|
11
|
|
|
|
|
1243
|
|
129
|
14
|
|
|
|
|
40
|
for my $func ( keys %$BUILD_FUNC_ARGS ) { |
130
|
8
|
|
|
|
|
9
|
$KEEP->{$pkg}->{$func} = \&{ *{ $pkg . '::' . $func } } |
|
8
|
|
|
|
|
38
|
|
|
56
|
|
|
|
|
248
|
|
131
|
56
|
100
|
|
|
|
56
|
if defined *{ $pkg . '::' . $func }{CODE}; |
132
|
|
|
|
|
|
|
} |
133
|
14
|
|
|
|
|
31
|
for my $func (@$args) { |
134
|
11
|
|
|
11
|
|
84
|
no warnings 'redefine'; |
|
11
|
|
|
|
|
117
|
|
|
11
|
|
|
|
|
1399
|
|
135
|
46
|
|
|
|
|
91
|
*{ $pkg . '::' . $func } = _build_func($func); |
|
46
|
|
|
|
|
195
|
|
136
|
|
|
|
|
|
|
} |
137
|
14
|
100
|
|
|
|
5299
|
push @CARP_NOT, $pkg if $pkg ne 'main'; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub _global_import { |
141
|
11
|
|
|
11
|
|
62
|
no strict 'refs'; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
338
|
|
142
|
11
|
|
|
11
|
|
51
|
no warnings 'redefine'; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
3663
|
|
143
|
5
|
|
|
5
|
|
14
|
my $pkg = caller; |
144
|
5
|
|
|
|
|
10
|
for my $func (qw/warn die/) { |
145
|
2
|
|
|
|
|
3
|
$KEEP->{'CORE::GLOBAL'}->{$func} = \&{ *{ 'CORE::GLOBAL::' . $func } } |
|
2
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
602
|
|
146
|
10
|
100
|
|
|
|
13
|
if defined *{ 'CORE::GLOBAL::' . $func }{CODE}; |
147
|
10
|
|
|
|
|
27
|
*{ 'CORE::GLOBAL::' . $func } = _build_func($func); |
|
10
|
|
|
|
|
33
|
|
148
|
2
|
|
|
|
|
3
|
$KEEP->{$pkg}->{$func} = \&{ *{ $pkg . '::' . $func } } |
|
2
|
|
|
|
|
8
|
|
|
10
|
|
|
|
|
51
|
|
149
|
10
|
100
|
|
|
|
17
|
if defined *{ $pkg . '::' . $func }{CODE}; |
150
|
2
|
|
|
|
|
2
|
undef &{ *{ $pkg . '::' . $func } } |
|
2
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
49
|
|
151
|
10
|
100
|
|
|
|
14
|
if defined *{ $pkg . '::' . $func }{CODE}; |
152
|
|
|
|
|
|
|
} |
153
|
5
|
|
|
|
|
27
|
push @Carp::CARP_NOT, __PACKAGE__; |
154
|
5
|
|
|
|
|
15
|
@_ = qw/carp croak/; |
155
|
5
|
|
|
|
|
34
|
goto &_local_import; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
##~~~~~ UNIMPORT ~~~~~## |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub unimport { |
161
|
6
|
|
|
6
|
|
8718
|
my $self = shift; |
162
|
6
|
|
|
|
|
31
|
my @args = @_; |
163
|
6
|
100
|
|
|
|
27
|
CORE::die 'Illegal args: "' . join( '", "', @args ) . '" for unimport()' |
164
|
|
|
|
|
|
|
if @args; |
165
|
5
|
|
|
|
|
8
|
$imported = 0; |
166
|
5
|
|
|
|
|
595
|
goto &_global_unimport; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub _local_unimport { |
170
|
5
|
50
|
|
5
|
|
25
|
my $args = @_ ? \@_ : [ keys %$BUILD_FUNC_ARGS ]; |
171
|
5
|
|
|
|
|
15
|
my ($pkg) = caller(); |
172
|
11
|
|
|
11
|
|
58
|
no strict 'refs'; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
368
|
|
173
|
11
|
|
|
11
|
|
54
|
no warnings 'redefine'; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
1982
|
|
174
|
5
|
|
|
|
|
10
|
for my $func (@$args) { |
175
|
20
|
100
|
|
|
|
44
|
if ( $KEEP->{$pkg}->{$func} ) { |
176
|
8
|
|
|
|
|
10
|
*{ $pkg . '::' . $func } = $KEEP->{$pkg}->{$func}; |
|
8
|
|
|
|
|
35
|
|
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
else { |
179
|
8
|
|
|
|
|
9
|
undef &{ *{ $pkg . '::' . $func } } |
|
8
|
|
|
|
|
52
|
|
|
12
|
|
|
|
|
40
|
|
180
|
12
|
100
|
|
|
|
12
|
if defined *{ $pkg . '::' . $func }{CODE}; |
181
|
|
|
|
|
|
|
} |
182
|
20
|
|
|
|
|
18
|
@{ *{ $pkg . '::CARP_NOT' } } |
|
20
|
|
|
|
|
67
|
|
|
0
|
|
|
|
|
0
|
|
183
|
20
|
|
|
|
|
30
|
= grep { $_ ne __PACKAGE__ } @{ *{ $pkg . '::CARP_NOT' } }; |
|
20
|
|
|
|
|
18
|
|
|
20
|
|
|
|
|
57
|
|
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub _global_unimport { |
188
|
11
|
|
|
11
|
|
50
|
no strict 'refs'; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
300
|
|
189
|
11
|
|
|
11
|
|
63
|
no warnings 'redefine'; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
1648
|
|
190
|
5
|
|
|
5
|
|
13
|
for my $func (qw/warn die/) { |
191
|
10
|
100
|
|
|
|
35
|
if ( $KEEP->{'CORE::GLOBAL'}->{$func} ) { |
|
8
|
100
|
|
|
|
41
|
|
192
|
2
|
|
|
|
|
4
|
*{ 'CORE::GLOBAL::' . $func } = $KEEP->{'CORE::GLOBAL'}->{$func}; |
|
2
|
|
|
|
|
15
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
elsif ( defined *{ 'CORE::GLOBAL::' . $func }{CODE} ) { |
195
|
4
|
|
|
|
|
6
|
undef &{ *{ 'CORE::GLOBAL::' . $func } }; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
34
|
|
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
# @_ = qw/carp croak/; |
199
|
5
|
|
|
|
|
14
|
goto &_local_unimport; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
203
|
|
|
|
|
|
|
__END__ |