line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Platypus::Declare; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
110202
|
use strict; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
32
|
use 5.008004; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
7
|
1
|
|
|
1
|
|
740
|
use FFI::Platypus 1.33; |
|
1
|
|
|
|
|
10336
|
|
|
1
|
|
|
|
|
788
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: (discouraged) Declarative interface to FFI::Platypus |
10
|
|
|
|
|
|
|
our $VERSION = '1.33'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $ffi = {}; |
14
|
|
|
|
|
|
|
our $types = {}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _ffi_object |
17
|
|
|
|
|
|
|
{ |
18
|
51
|
|
|
51
|
|
369
|
my($package, $filename) = caller(1); |
19
|
51
|
|
66
|
|
|
473
|
$ffi->{$package} ||= FFI::Platypus->new->package($package,$filename); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub lib (@) |
24
|
|
|
|
|
|
|
{ |
25
|
5
|
|
|
5
|
1
|
23905
|
_ffi_object->lib(@_); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub type ($;$) |
30
|
|
|
|
|
|
|
{ |
31
|
6
|
|
|
6
|
1
|
19457
|
_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
|
6421
|
my $wrapper; |
58
|
12
|
100
|
|
|
|
46
|
$wrapper = pop if ref($_[-1]) eq 'CODE'; |
59
|
12
|
|
|
|
|
37
|
my($name, $args, $ret, $proto) = @_; |
60
|
|
|
|
|
|
|
|
61
|
12
|
100
|
|
|
|
49
|
my($symbol_name, $perl_name) = ref $name ? (@$name) : ($name, $name); |
62
|
12
|
|
|
|
|
30
|
my $function = _ffi_object->function($symbol_name, $args, $ret, $wrapper); |
63
|
12
|
|
|
|
|
2588
|
$function->attach($perl_name, $proto); |
64
|
12
|
|
|
|
|
634
|
(); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub closure (&) |
69
|
|
|
|
|
|
|
{ |
70
|
3
|
|
|
3
|
1
|
8497
|
my($coderef) = @_; |
71
|
3
|
|
|
|
|
822
|
require FFI::Platypus::Closure; |
72
|
3
|
|
|
|
|
969
|
FFI::Platypus::Closure->new($coderef); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub sticky ($) |
77
|
|
|
|
|
|
|
{ |
78
|
1
|
|
|
1
|
1
|
19
|
my($closure) = @_; |
79
|
1
|
50
|
33
|
|
|
12
|
Carp::croak("usage: sticky \$closure") |
80
|
|
|
|
|
|
|
unless defined $closure && ref($closure) eq 'FFI::Platypus::Closure'; |
81
|
1
|
|
|
|
|
6
|
$closure->sticky; |
82
|
1
|
|
|
|
|
23
|
$closure; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub cast ($$$) |
87
|
|
|
|
|
|
|
{ |
88
|
3
|
|
|
3
|
1
|
6170
|
_ffi_object->cast(@_); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub attach_cast ($$$) |
93
|
|
|
|
|
|
|
{ |
94
|
3
|
|
|
3
|
1
|
3719
|
my($name, $type1, $type2) = @_; |
95
|
3
|
|
|
|
|
11
|
my $caller = caller; |
96
|
3
|
|
|
|
|
12
|
$name = join '::', $caller, $name; |
97
|
3
|
|
|
|
|
11
|
_ffi_object->attach_cast($name, $type1, $type2); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub sizeof ($) |
102
|
|
|
|
|
|
|
{ |
103
|
4
|
|
|
4
|
1
|
10113
|
_ffi_object->sizeof($_[0]); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub lang ($) |
108
|
|
|
|
|
|
|
{ |
109
|
1
|
|
|
1
|
1
|
4689
|
_ffi_object->lang($_[0]); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub abi ($) |
114
|
|
|
|
|
|
|
{ |
115
|
12
|
|
|
12
|
1
|
43740
|
_ffi_object->abi($_[0]); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub import |
119
|
|
|
|
|
|
|
{ |
120
|
9
|
|
|
9
|
|
8407
|
my $caller = caller; |
121
|
9
|
|
|
|
|
18
|
shift; # class |
122
|
|
|
|
|
|
|
|
123
|
9
|
|
|
|
|
24
|
foreach my $arg (@_) |
124
|
|
|
|
|
|
|
{ |
125
|
5
|
100
|
|
|
|
18
|
if(ref $arg) |
126
|
|
|
|
|
|
|
{ |
127
|
2
|
50
|
|
|
|
11
|
if($arg->[0] =~ /::/) |
128
|
|
|
|
|
|
|
{ |
129
|
0
|
|
|
|
|
0
|
_ffi_object->load_custom_type(@$arg); |
130
|
1
|
|
|
1
|
|
16
|
no strict 'refs'; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
116
|
|
131
|
0
|
|
|
0
|
|
0
|
*{join '::', $caller, $arg->[1]} = sub () { $arg->[1] }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
else |
134
|
|
|
|
|
|
|
{ |
135
|
2
|
|
|
|
|
8
|
_ffi_object->type(@$arg); |
136
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
137
|
2
|
|
|
2
|
|
388
|
*{join '::', $caller, $arg->[1]} = sub () { $arg->[0] }; |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
38
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
else |
141
|
|
|
|
|
|
|
{ |
142
|
3
|
|
|
|
|
19
|
_ffi_object->type($arg); |
143
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
144
|
3
|
|
|
4
|
|
11520
|
*{join '::', $caller, $arg} = sub () { $arg }; |
|
3
|
|
|
|
|
25
|
|
|
4
|
|
|
|
|
44
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
255
|
|
149
|
9
|
|
|
|
|
24
|
*{join '::', $caller, 'lib'} = \&lib; |
|
9
|
|
|
|
|
46
|
|
150
|
9
|
|
|
|
|
23
|
*{join '::', $caller, 'type'} = \&type; |
|
9
|
|
|
|
|
29
|
|
151
|
9
|
|
|
|
|
20
|
*{join '::', $caller, 'type_meta'} = \&type_meta; |
|
9
|
|
|
|
|
40
|
|
152
|
9
|
|
|
|
|
20
|
*{join '::', $caller, 'custom_type'} = \&custom_type; |
|
9
|
|
|
|
|
34
|
|
153
|
9
|
|
|
|
|
18
|
*{join '::', $caller, 'load_custom_type'} = \&load_custom_type; |
|
9
|
|
|
|
|
32
|
|
154
|
9
|
|
|
|
|
21
|
*{join '::', $caller, 'attach'} = \&attach; |
|
9
|
|
|
|
|
30
|
|
155
|
9
|
|
|
|
|
20
|
*{join '::', $caller, 'closure'} = \&closure; |
|
9
|
|
|
|
|
37
|
|
156
|
9
|
|
|
|
|
18
|
*{join '::', $caller, 'sticky'} = \&sticky; |
|
9
|
|
|
|
|
28
|
|
157
|
9
|
|
|
|
|
21
|
*{join '::', $caller, 'cast'} = \&cast; |
|
9
|
|
|
|
|
30
|
|
158
|
9
|
|
|
|
|
17
|
*{join '::', $caller, 'attach_cast'} = \&attach_cast; |
|
9
|
|
|
|
|
33
|
|
159
|
9
|
|
|
|
|
16
|
*{join '::', $caller, 'sizeof'} = \&sizeof; |
|
9
|
|
|
|
|
29
|
|
160
|
9
|
|
|
|
|
21
|
*{join '::', $caller, 'lang'} = \〈 |
|
9
|
|
|
|
|
28
|
|
161
|
9
|
|
|
|
|
18
|
*{join '::', $caller, 'abi'} = \&abi; |
|
9
|
|
|
|
|
3938
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
__END__ |