line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Variable::Strongly::Typed::Array; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
63
|
use version; $VERSION = qv('1.0.0'); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
45
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
512
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
184
|
|
6
|
7
|
|
|
7
|
|
35
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
212
|
|
7
|
7
|
|
|
7
|
|
32
|
use Carp; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
502
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
33
|
use base qw(Variable::Strongly::Typed); |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
4807
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
sub TIEARRAY { |
13
|
1
|
|
|
1
|
|
4
|
my($class, $type) = @_; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
4
|
my $self = bless \my($anon_scalar), $class; |
16
|
1
|
|
|
|
|
12
|
$self->_init([], $type); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
### Bummer have to implement all the array functions... |
20
|
|
|
|
|
|
|
sub FETCHSIZE { |
21
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
22
|
0
|
|
|
|
|
|
return scalar @{$arr}; |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub STORESIZE { |
26
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
27
|
0
|
|
|
|
|
|
$#{$arr} = $_[0]-1; |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub STORE { |
31
|
0
|
|
|
0
|
|
|
my ($self, $index, $value) = @_; |
32
|
0
|
|
|
|
|
|
my $arr = $self->_get_object; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->_check_values($value); |
35
|
0
|
|
|
|
|
|
$arr->[$index] = $value; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Note we don't currently check on the way out as |
39
|
|
|
|
|
|
|
# Tie::Constrained does... |
40
|
|
|
|
|
|
|
sub FETCH { |
41
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
42
|
0
|
|
|
|
|
|
$arr->[$_[0]]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub CLEAR { |
46
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
47
|
0
|
|
|
|
|
|
@{$arr} = (); |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub POP { |
51
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
52
|
0
|
|
|
|
|
|
pop(@{$arr}); |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub PUSH { |
56
|
0
|
|
|
0
|
|
|
my ($self, @values) = @_; |
57
|
0
|
|
|
|
|
|
my $arr = $self->_get_object; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->_check_values(@values); |
60
|
0
|
|
|
|
|
|
push(@$arr, @values); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub SHIFT { |
64
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
65
|
0
|
|
|
|
|
|
shift(@{$arr}); |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub UNSHIFT { |
69
|
0
|
|
|
0
|
|
|
my ($self, @values) = @_; |
70
|
0
|
|
|
|
|
|
my $arr = $self->_get_object; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->_check_values(@values); |
73
|
0
|
|
|
|
|
|
unshift(@$arr, @values); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub EXISTS { |
77
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
78
|
0
|
|
|
|
|
|
exists $arr->[$_[0]]; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub DELETE { |
82
|
0
|
|
|
0
|
|
|
my $arr = shift->_get_object; |
83
|
0
|
|
|
|
|
|
delete $arr->[$_[0]]; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub SPLICE { |
87
|
0
|
|
|
0
|
|
|
my ($self) = shift; |
88
|
0
|
|
|
|
|
|
my $arr = $self->_get_object; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $sz = $arr->FETCHSIZE; |
91
|
0
|
0
|
|
|
|
|
my $off = @_ ? shift : 0; |
92
|
0
|
0
|
|
|
|
|
$off += $sz if $off < 0; |
93
|
0
|
0
|
|
|
|
|
my $len = @_ ? shift : $sz - $off; |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
$self->_check_values(@_) if (@_); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return splice(@$arr, $off, $len, @_); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub EXTEND { |
101
|
0
|
|
|
0
|
|
|
my ($self) = shift; |
102
|
0
|
|
|
|
|
|
$self->STORESIZE(shift); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |