line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Declare; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
84358
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
20
|
use 5.008004; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
3
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
7
|
1
|
|
|
1
|
|
544
|
use FFI::Platypus 1.33; |
|
1
|
|
|
|
|
7985
|
|
|
1
|
|
|
|
|
667
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: (discouraged) Declarative interface to FFI::Platypus |
10
|
|
|
|
|
|
|
our $VERSION = '1.34'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $ffi = {}; |
14
|
|
|
|
|
|
|
our $types = {}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _ffi_object |
17
|
|
|
|
|
|
|
{ |
18
|
51
|
|
|
51
|
|
250
|
my($package, $filename) = caller(1); |
19
|
51
|
|
66
|
|
|
251
|
$ffi->{$package} ||= FFI::Platypus->new->package($package,$filename); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub lib (@) |
24
|
|
|
|
|
|
|
{ |
25
|
5
|
|
|
5
|
1
|
17498
|
_ffi_object->lib(@_); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub type ($;$) |
30
|
|
|
|
|
|
|
{ |
31
|
6
|
|
|
6
|
1
|
13307
|
_ffi_object->type(@_); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub custom_type ($$) |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
1
|
0
|
_ffi_object->custom_type(@_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub load_custom_type ($$;@) |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
1
|
0
|
_ffi_object->load_custom_type(@_); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub type_meta($) |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
1
|
0
|
_ffi_object->type_meta(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $inner_counter = 0; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub attach ($$$;$$) |
56
|
|
|
|
|
|
|
{ |
57
|
12
|
|
|
12
|
1
|
4452
|
my $wrapper; |
58
|
12
|
100
|
|
|
|
44
|
$wrapper = pop if ref($_[-1]) eq 'CODE'; |
59
|
12
|
|
|
|
|
26
|
my($name, $args, $ret, $proto) = @_; |
60
|
|
|
|
|
|
|
|
61
|
12
|
100
|
|
|
|
29
|
my($symbol_name, $perl_name) = ref $name ? (@$name) : ($name, $name); |
62
|
12
|
|
|
|
|
19
|
my $function = _ffi_object->function($symbol_name, $args, $ret, $wrapper); |
63
|
12
|
|
|
|
|
1764
|
$function->attach($perl_name, $proto); |
64
|
12
|
|
|
|
|
584
|
(); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub closure (&) |
69
|
|
|
|
|
|
|
{ |
70
|
3
|
|
|
3
|
1
|
5917
|
my($coderef) = @_; |
71
|
3
|
|
|
|
|
443
|
require FFI::Platypus::Closure; |
72
|
3
|
|
|
|
|
638
|
FFI::Platypus::Closure->new($coderef); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub sticky ($) |
77
|
|
|
|
|
|
|
{ |
78
|
1
|
|
|
1
|
1
|
15
|
my($closure) = @_; |
79
|
1
|
50
|
33
|
|
|
8
|
Carp::croak("usage: sticky \$closure") |
80
|
|
|
|
|
|
|
unless defined $closure && ref($closure) eq 'FFI::Platypus::Closure'; |
81
|
1
|
|
|
|
|
4
|
$closure->sticky; |
82
|
1
|
|
|
|
|
15
|
$closure; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub cast ($$$) |
87
|
|
|
|
|
|
|
{ |
88
|
3
|
|
|
3
|
1
|
4197
|
_ffi_object->cast(@_); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub attach_cast ($$$) |
93
|
|
|
|
|
|
|
{ |
94
|
3
|
|
|
3
|
1
|
2233
|
my($name, $type1, $type2) = @_; |
95
|
3
|
|
|
|
|
7
|
my $caller = caller; |
96
|
3
|
|
|
|
|
8
|
$name = join '::', $caller, $name; |
97
|
3
|
|
|
|
|
8
|
_ffi_object->attach_cast($name, $type1, $type2); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub sizeof ($) |
102
|
|
|
|
|
|
|
{ |
103
|
4
|
|
|
4
|
1
|
7197
|
_ffi_object->sizeof($_[0]); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub lang ($) |
108
|
|
|
|
|
|
|
{ |
109
|
1
|
|
|
1
|
1
|
3225
|
_ffi_object->lang($_[0]); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub abi ($) |
114
|
|
|
|
|
|
|
{ |
115
|
12
|
|
|
12
|
1
|
30053
|
_ffi_object->abi($_[0]); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub import |
119
|
|
|
|
|
|
|
{ |
120
|
9
|
|
|
9
|
|
5967
|
my $caller = caller; |
121
|
9
|
|
|
|
|
12
|
shift; # class |
122
|
|
|
|
|
|
|
|
123
|
9
|
|
|
|
|
18
|
foreach my $arg (@_) |
124
|
|
|
|
|
|
|
{ |
125
|
5
|
100
|
|
|
|
12
|
if(ref $arg) |
126
|
|
|
|
|
|
|
{ |
127
|
2
|
50
|
|
|
|
6
|
if($arg->[0] =~ /::/) |
128
|
|
|
|
|
|
|
{ |
129
|
0
|
|
|
|
|
0
|
_ffi_object->load_custom_type(@$arg); |
130
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
76
|
|
131
|
0
|
|
|
0
|
|
0
|
*{join '::', $caller, $arg->[1]} = sub () { $arg->[1] }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
else |
134
|
|
|
|
|
|
|
{ |
135
|
2
|
|
|
|
|
4
|
_ffi_object->type(@$arg); |
136
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
62
|
|
137
|
2
|
|
|
2
|
|
237
|
*{join '::', $caller, $arg->[1]} = sub () { $arg->[0] }; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
40
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
else |
141
|
|
|
|
|
|
|
{ |
142
|
3
|
|
|
|
|
13
|
_ffi_object->type($arg); |
143
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
144
|
3
|
|
|
4
|
|
8197
|
*{join '::', $caller, $arg} = sub () { $arg }; |
|
3
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
30
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
191
|
|
149
|
9
|
|
|
|
|
16
|
*{join '::', $caller, 'lib'} = \&lib; |
|
9
|
|
|
|
|
32
|
|
150
|
9
|
|
|
|
|
16
|
*{join '::', $caller, 'type'} = \&type; |
|
9
|
|
|
|
|
22
|
|
151
|
9
|
|
|
|
|
14
|
*{join '::', $caller, 'type_meta'} = \&type_meta; |
|
9
|
|
|
|
|
30
|
|
152
|
9
|
|
|
|
|
12
|
*{join '::', $caller, 'custom_type'} = \&custom_type; |
|
9
|
|
|
|
|
24
|
|
153
|
9
|
|
|
|
|
12
|
*{join '::', $caller, 'load_custom_type'} = \&load_custom_type; |
|
9
|
|
|
|
|
26
|
|
154
|
9
|
|
|
|
|
14
|
*{join '::', $caller, 'attach'} = \&attach; |
|
9
|
|
|
|
|
63
|
|
155
|
9
|
|
|
|
|
17
|
*{join '::', $caller, 'closure'} = \&closure; |
|
9
|
|
|
|
|
26
|
|
156
|
9
|
|
|
|
|
15
|
*{join '::', $caller, 'sticky'} = \&sticky; |
|
9
|
|
|
|
|
19
|
|
157
|
9
|
|
|
|
|
13
|
*{join '::', $caller, 'cast'} = \&cast; |
|
9
|
|
|
|
|
22
|
|
158
|
9
|
|
|
|
|
12
|
*{join '::', $caller, 'attach_cast'} = \&attach_cast; |
|
9
|
|
|
|
|
20
|
|
159
|
9
|
|
|
|
|
15
|
*{join '::', $caller, 'sizeof'} = \&sizeof; |
|
9
|
|
|
|
|
19
|
|
160
|
9
|
|
|
|
|
13
|
*{join '::', $caller, 'lang'} = \〈 |
|
9
|
|
|
|
|
19
|
|
161
|
9
|
|
|
|
|
14
|
*{join '::', $caller, 'abi'} = \&abi; |
|
9
|
|
|
|
|
2922
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
__END__ |