line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Type; |
2
|
|
|
|
|
|
|
|
3
|
56
|
|
|
56
|
|
909
|
use strict; |
|
56
|
|
|
|
|
93
|
|
|
56
|
|
|
|
|
1319
|
|
4
|
56
|
|
|
56
|
|
256
|
use warnings; |
|
56
|
|
|
|
|
94
|
|
|
56
|
|
|
|
|
1029
|
|
5
|
56
|
|
|
56
|
|
740
|
use 5.008004; |
|
56
|
|
|
|
|
169
|
|
6
|
56
|
|
|
56
|
|
249
|
use Carp qw( croak ); |
|
56
|
|
|
|
|
137
|
|
|
56
|
|
|
|
|
10545
|
|
7
|
|
|
|
|
|
|
require FFI::Platypus; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Defining types for FFI::Platypus |
10
|
|
|
|
|
|
|
our $VERSION = '2.07'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# The TypeParser and Type classes are used internally ONLY and |
13
|
|
|
|
|
|
|
# are not to be exposed to the user. External users should |
14
|
|
|
|
|
|
|
# not under any circumstances rely on the implementation of |
15
|
|
|
|
|
|
|
# these classes. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub alignof |
18
|
|
|
|
|
|
|
{ |
19
|
153
|
|
|
153
|
0
|
283
|
my($self) = @_; |
20
|
153
|
|
|
|
|
912
|
my $meta = $self->meta; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# TODO: it is possible, though complicated |
23
|
|
|
|
|
|
|
# to compute the alignment of a struct |
24
|
|
|
|
|
|
|
# type record. |
25
|
|
|
|
|
|
|
croak "cannot determine alignment of record" |
26
|
|
|
|
|
|
|
if $meta->{type} eq 'record' |
27
|
153
|
50
|
66
|
|
|
487
|
&& $meta->{ref} == 1; |
28
|
|
|
|
|
|
|
|
29
|
153
|
|
|
|
|
174
|
my $ffi_type; |
30
|
153
|
100
|
|
|
|
352
|
if($meta->{type} eq 'pointer') |
|
|
100
|
|
|
|
|
|
31
|
|
|
|
|
|
|
{ |
32
|
11
|
|
|
|
|
18
|
$ffi_type = 'pointer'; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif($meta->{type} eq 'record') |
35
|
|
|
|
|
|
|
{ |
36
|
10
|
|
|
|
|
19
|
$ffi_type = 'uint8'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else |
39
|
|
|
|
|
|
|
{ |
40
|
132
|
|
|
|
|
220
|
$ffi_type = $meta->{ffi_type}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
153
|
|
|
|
|
683
|
require FFI::Platypus::ShareConfig; |
44
|
153
|
|
|
|
|
402
|
FFI::Platypus::ShareConfig->get('align')->{$ffi_type}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |