line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::C::Array; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
118
|
|
4
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
90
|
|
5
|
4
|
|
|
4
|
|
29
|
use FFI::C::FFI (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
196
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
|
|
|
|
|
|
'@{}' => \&tie, |
8
|
165
|
|
|
165
|
|
828
|
bool => sub { 1 }, |
9
|
4
|
|
|
4
|
|
29
|
fallback => 1; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
51
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Array instance for FFI |
12
|
|
|
|
|
|
|
our $VERSION = '0.14'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get |
16
|
|
|
|
|
|
|
{ |
17
|
78
|
|
|
78
|
1
|
6357
|
my($self, $index) = @_; |
18
|
78
|
50
|
|
|
|
171
|
Carp::croak("Negative array index") if $index < 0; |
19
|
78
|
100
|
100
|
|
|
354
|
Carp::croak("OOB array index") if $self->{count} && $index >= $self->{count}; |
20
|
77
|
|
|
|
|
145
|
my $member = $self->{def}->{members}->{member}; |
21
|
77
|
|
|
|
|
201
|
my $ptr = $self->{ptr} + $member->size * $index; |
22
|
77
|
|
66
|
|
|
235
|
$member->create($ptr,$self->{owner} || $self); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
21
|
|
|
21
|
1
|
7002
|
sub count { shift->{count} } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub tie |
28
|
|
|
|
|
|
|
{ |
29
|
9
|
|
|
9
|
1
|
1813
|
my @a; |
30
|
9
|
|
|
|
|
35
|
CORE::tie @a, 'FFI::C::Array', shift; |
31
|
9
|
|
|
|
|
45
|
\@a; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub DESTROY |
35
|
|
|
|
|
|
|
{ |
36
|
10
|
|
|
10
|
|
1070
|
my($self) = @_; |
37
|
10
|
100
|
66
|
|
|
64
|
if($self->{ptr} && !$self->{owner}) |
38
|
|
|
|
|
|
|
{ |
39
|
5
|
|
|
|
|
68
|
FFI::C::FFI::free(delete $self->{ptr}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub TIEARRAY |
44
|
|
|
|
|
|
|
{ |
45
|
9
|
|
|
9
|
|
23
|
my($class, $array) = @_; |
46
|
9
|
|
|
|
|
23
|
$array; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub FETCH |
50
|
|
|
|
|
|
|
{ |
51
|
41
|
|
|
41
|
|
70
|
my($self, $index) = @_; |
52
|
41
|
|
|
|
|
96
|
$self->get($index); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub STORE |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
|
0
|
Carp::croak("Cannot set"); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub FETCHSIZE |
61
|
|
|
|
|
|
|
{ |
62
|
16
|
|
|
16
|
|
124
|
my($self) = @_; |
63
|
16
|
|
|
|
|
48
|
$self->count; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub STORESIZE |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
0
|
|
|
my($self) = @_; |
69
|
0
|
|
|
|
|
|
$self->count; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub CLEAR |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
|
|
Carp::croak("Cannot clear"); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |