line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::C::Array; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
95
|
|
4
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
84
|
|
5
|
4
|
|
|
4
|
|
19
|
use FFI::C::FFI (); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
189
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
|
|
|
|
|
|
'@{}' => \&tie, |
8
|
165
|
|
|
165
|
|
619
|
bool => sub { 1 }, |
9
|
4
|
|
|
4
|
|
22
|
fallback => 1; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
38
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Array instance for FFI |
12
|
|
|
|
|
|
|
our $VERSION = '0.12'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get |
16
|
|
|
|
|
|
|
{ |
17
|
78
|
|
|
78
|
1
|
5537
|
my($self, $index) = @_; |
18
|
78
|
50
|
|
|
|
133
|
Carp::croak("Negative array index") if $index < 0; |
19
|
78
|
100
|
100
|
|
|
289
|
Carp::croak("OOB array index") if $self->{count} && $index >= $self->{count}; |
20
|
77
|
|
|
|
|
118
|
my $member = $self->{def}->{members}->{member}; |
21
|
77
|
|
|
|
|
167
|
my $ptr = $self->{ptr} + $member->size * $index; |
22
|
77
|
|
66
|
|
|
198
|
$member->create($ptr,$self->{owner} || $self); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
21
|
|
|
21
|
1
|
5993
|
sub count { shift->{count} } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub tie |
28
|
|
|
|
|
|
|
{ |
29
|
9
|
|
|
9
|
1
|
1524
|
my @a; |
30
|
9
|
|
|
|
|
34
|
CORE::tie @a, 'FFI::C::Array', shift; |
31
|
9
|
|
|
|
|
40
|
\@a; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub DESTROY |
35
|
|
|
|
|
|
|
{ |
36
|
10
|
|
|
10
|
|
956
|
my($self) = @_; |
37
|
10
|
100
|
66
|
|
|
55
|
if($self->{ptr} && !$self->{owner}) |
38
|
|
|
|
|
|
|
{ |
39
|
5
|
|
|
|
|
108
|
FFI::C::FFI::free(delete $self->{ptr}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub TIEARRAY |
44
|
|
|
|
|
|
|
{ |
45
|
9
|
|
|
9
|
|
22
|
my($class, $array) = @_; |
46
|
9
|
|
|
|
|
18
|
$array; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub FETCH |
50
|
|
|
|
|
|
|
{ |
51
|
41
|
|
|
41
|
|
60
|
my($self, $index) = @_; |
52
|
41
|
|
|
|
|
68
|
$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
|
|
107
|
my($self) = @_; |
63
|
16
|
|
|
|
|
33
|
$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__ |