line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Record::Meta; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
534
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
326
|
|
4
|
10
|
|
|
10
|
|
63
|
use warnings; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
255
|
|
5
|
10
|
|
|
10
|
|
198
|
use 5.008004; |
|
10
|
|
|
|
|
38
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: FFI support for structured records data |
8
|
|
|
|
|
|
|
our $VERSION = '2.06_01'; # TRIAL VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
require FFI::Platypus; |
13
|
|
|
|
|
|
|
my $ffi = FFI::Platypus->new( |
14
|
|
|
|
|
|
|
api => 2, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
$ffi->bundle; |
17
|
|
|
|
|
|
|
$ffi->mangler(sub { |
18
|
|
|
|
|
|
|
my($name) = @_; |
19
|
|
|
|
|
|
|
$name =~ s/^/ffi_platypus_record_meta__/; |
20
|
|
|
|
|
|
|
$name; |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$ffi->type('opaque' => 'ffi_type'); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ffi->custom_type('meta_t' => { |
26
|
|
|
|
|
|
|
native_type => 'opaque', |
27
|
|
|
|
|
|
|
perl_to_native => sub { |
28
|
|
|
|
|
|
|
${ $_[0] }; |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
}); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$ffi->attach( _find_symbol => ['string'] => 'ffi_type'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$ffi->attach( new => ['ffi_type[]','int'] => 'meta_t', sub { |
35
|
|
|
|
|
|
|
my($xsub, $class, $elements, $closure_safe) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if(ref($elements) ne 'ARRAY') |
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
require Carp; |
40
|
|
|
|
|
|
|
Carp::croak("passed something other than a array ref to @{[ __PACKAGE__ ]}"); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my @element_type_pointers; |
44
|
|
|
|
|
|
|
foreach my $element_type (@$elements) |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
my $ptr = _find_symbol($element_type); |
47
|
|
|
|
|
|
|
if($ptr) |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
push @element_type_pointers, $ptr; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
require Carp; |
54
|
|
|
|
|
|
|
Carp::croak("unknown type: $element_type"); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
push @element_type_pointers, undef; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $ptr = $xsub->(\@element_type_pointers, $closure_safe); |
61
|
|
|
|
|
|
|
bless \$ptr, $class; |
62
|
|
|
|
|
|
|
}); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$ffi->attach( ffi_type => ['meta_t'] => 'ffi_type' ); |
65
|
|
|
|
|
|
|
$ffi->attach( size => ['meta_t'] => 'size_t' ); |
66
|
|
|
|
|
|
|
$ffi->attach( alignment => ['meta_t'] => 'ushort' ); |
67
|
|
|
|
|
|
|
$ffi->attach( element_pointers => ['meta_t'] => 'ffi_type[]' ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$ffi->attach( DESTROY => ['meta_t'] => 'void' ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
6
|
0
|
11
|
sub ptr { ${ shift() } } |
|
6
|
|
|
|
|
69
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |