line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PerlX::SafeNav; |
2
|
5
|
|
|
5
|
|
965507
|
use strict; |
|
5
|
|
|
|
|
36
|
|
|
5
|
|
|
|
|
199
|
|
3
|
5
|
|
|
5
|
|
39
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
194
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
25
|
use Exporter 'import'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1346
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = ('$safenav', '$unsafenav'); |
9
|
|
|
|
|
|
|
our @EXPORT_OK = ('&safenav'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $safenav = sub { |
12
|
41
|
|
|
41
|
|
14628
|
my $o = shift; |
13
|
41
|
|
|
|
|
233
|
bless \$o, 'PerlX::SafeNav::Object'; |
14
|
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $unsafenav = sub { |
17
|
11
|
|
|
11
|
|
13
|
${ $_[0] } |
|
11
|
|
|
|
|
59
|
|
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub safenav (&@) { |
21
|
5
|
|
|
5
|
1
|
13588
|
my ($block, $o) = @_; |
22
|
5
|
|
|
|
|
11
|
local $_ = $o->$safenav; |
23
|
5
|
|
|
|
|
21
|
$block->()->$unsafenav; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package PerlX::SafeNav::Object; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use overload |
29
|
|
|
|
|
|
|
'@{}' => sub { |
30
|
16
|
|
|
16
|
|
28
|
my $self = shift; |
31
|
16
|
|
|
|
|
61
|
tie my @a, 'PerlX::SafeNav::ArrayRef', $$self; |
32
|
16
|
|
|
|
|
74
|
return \@a; |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
'%{}' => sub { |
35
|
18
|
|
|
18
|
|
40
|
my $self = shift; |
36
|
18
|
|
|
|
|
61
|
tie my %h, 'PerlX::SafeNav::HashRef', $$self; |
37
|
18
|
|
|
|
|
99
|
return \%h; |
38
|
5
|
|
|
5
|
|
36
|
}; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
120
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub AUTOLOAD { |
41
|
44
|
|
|
44
|
|
110
|
our $AUTOLOAD; |
42
|
44
|
|
|
|
|
133
|
my $method = substr $AUTOLOAD, 2 + rindex($AUTOLOAD, '::'); |
43
|
|
|
|
|
|
|
|
44
|
44
|
|
|
|
|
80
|
my ($self, @args) = @_; |
45
|
|
|
|
|
|
|
|
46
|
44
|
100
|
|
|
|
335
|
(defined $$self) ? |
47
|
|
|
|
|
|
|
$$self -> $method(@args) -> $safenav : |
48
|
|
|
|
|
|
|
$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
0
|
|
|
sub DESTROY {} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
package PerlX::SafeNav::ArrayRef; |
54
|
5
|
|
|
5
|
|
3518
|
use Tie::Array; |
|
5
|
|
|
|
|
6465
|
|
|
5
|
|
|
|
|
762
|
|
55
|
|
|
|
|
|
|
our @ISA = ('Tie::Array'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub TIEARRAY { |
58
|
16
|
|
|
16
|
|
77
|
my ($class, $o) = @_; |
59
|
16
|
|
|
|
|
43
|
return bless \$o, $class; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub FETCH { |
63
|
16
|
|
|
16
|
|
52
|
my ($self, $i) = @_; |
64
|
16
|
|
|
|
|
67
|
@$$self[$i] -> $safenav; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub FETCHSIZE { |
68
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
69
|
0
|
0
|
|
|
|
0
|
(defined $$self) ? @$$self : 0 |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package PerlX::SafeNav::HashRef; |
73
|
5
|
|
|
5
|
|
37
|
use Tie::Hash; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
642
|
|
74
|
|
|
|
|
|
|
our @ISA = ('Tie::Hash'); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub TIEHASH { |
77
|
18
|
|
|
18
|
|
38
|
my ($class, $o) = @_; |
78
|
18
|
|
|
|
|
41
|
bless \$o, $class; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub FETCH { |
82
|
18
|
|
|
18
|
|
38
|
my ($self, $k) = @_; |
83
|
18
|
|
|
|
|
72
|
$$self->{$k} -> $safenav; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |