line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Spy; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
31888
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
31
|
use 5.010; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
355
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(spy_hash); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require XSLoader; |
15
|
|
|
|
|
|
|
XSLoader::load('Hash::Spy', $VERSION); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %cb_slot = ( delete => 0, |
18
|
|
|
|
|
|
|
store => 1, |
19
|
|
|
|
|
|
|
clear => 2, |
20
|
|
|
|
|
|
|
empty => 3 ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub spy_hash (\%@) { |
23
|
6
|
|
|
6
|
1
|
445789
|
my $hash = shift; |
24
|
6
|
|
|
|
|
58
|
my $spy = _hash_get_spy($hash); |
25
|
6
|
|
|
|
|
22
|
while (@_) { |
26
|
7
|
|
|
|
|
9
|
my $name = shift; |
27
|
7
|
|
33
|
|
|
25
|
my $slot = $cb_slot{$name} // |
28
|
|
|
|
|
|
|
croak "bad spy callback '$name'"; |
29
|
7
|
|
|
|
|
7
|
my $cb = shift; |
30
|
7
|
100
|
|
|
|
18
|
if (defined $cb) { |
31
|
6
|
50
|
|
|
|
21
|
UNIVERSAL::isa($cb, 'CODE') |
32
|
|
|
|
|
|
|
or croak "spy callback '$name' is not a CODE ref"; |
33
|
|
|
|
|
|
|
} |
34
|
7
|
|
|
|
|
30
|
$spy->_set_cb($slot, $cb); |
35
|
|
|
|
|
|
|
} |
36
|
6
|
|
|
|
|
14
|
1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
__END__ |