line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package pragmatic; |
2
|
|
|
|
|
|
|
$VERSION = 1.0; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
bootstrap xsub; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
7
|
use xsub _refcount => q($), q{ |
7
|
|
|
|
|
|
|
SV *sv = argv[0]; |
8
|
|
|
|
|
|
|
if (SvROK(sv)) { |
9
|
|
|
|
|
|
|
SV *rv = SvRV(sv); |
10
|
|
|
|
|
|
|
return newSVuv(SvREFCNT(rv)); |
11
|
|
|
|
|
|
|
} else { |
12
|
|
|
|
|
|
|
return &PL_sv_undef; |
13
|
|
|
|
|
|
|
} |
14
|
1
|
|
|
1
|
|
2165
|
}; |
|
1
|
|
|
|
|
6
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub DESTROY { |
17
|
0
|
|
|
0
|
|
|
my $x = shift; |
18
|
0
|
|
|
|
|
|
my ($p, $b, $last) = splice @$x; |
19
|
0
|
0
|
|
|
|
|
$last or return $p->disable; |
20
|
0
|
0
|
|
|
|
|
_refcount($last) > 1 or return; |
21
|
0
|
0
|
|
|
|
|
$$last[1] ? $p->enable : $p->disable |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub enable($) { |
25
|
0
|
|
|
0
|
|
|
1 |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub disable($) { |
29
|
0
|
|
|
0
|
|
|
'' |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub enabled($) { |
33
|
0
|
|
|
0
|
|
|
my $p = shift; |
34
|
0
|
|
0
|
|
|
|
!!($^H{$p} && ${$^H{$p}}[1]) |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub disabled($) { |
38
|
|
|
|
|
|
|
!shift->enabled |
39
|
0
|
|
|
0
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub import($;) { |
42
|
0
|
|
|
0
|
|
|
my $p = shift; |
43
|
0
|
|
|
|
|
|
$^H |= 0x20000; |
44
|
0
|
|
|
0
|
|
|
local *DESTROY = sub { }; |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$^H{$p} = bless [$p, 1, delete $^H{$p}]; |
46
|
0
|
|
|
|
|
|
$p->enable |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub unimport($;) { |
50
|
0
|
|
|
0
|
|
|
my $p = shift; |
51
|
0
|
|
|
|
|
|
$^H |= 0x20000; |
52
|
0
|
|
|
0
|
|
|
local *DESTROY = sub { }; |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$^H{$p} = bless [$p, 0, delete $^H{$p}]; |
54
|
0
|
|
|
|
|
|
$p->disable |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1 |