Debian Codegraph @

lib/FFI/Platypus/API.pm

raw
1 package FFI::Platypus::API;
2
3 use strict;
4 use warnings;
5 use 5.008004;
6 use FFI::Platypus;
7 use Exporter qw( import );
8
9 our @EXPORT = grep /^arguments_/, keys %FFI::Platypus::API::;
10
11 # ABSTRACT: Platypus arguments and return value API for custom types
12 our $VERSION = '2.12'; # VERSION
13
14
15 1;
16
17 __END__
18
19 =pod
20
21 =encoding UTF-8
22
23 =head1 NAME
24
25 FFI::Platypus::API - Platypus arguments and return value API for custom types
26
27 =head1 VERSION
28
29 version 2.12
30
31 =head1 SYNOPSIS
32
33 package FFI::Platypus::Type::MyCustomType;
34
35 use FFI::Platypus::API;
36
37 sub ffi_custom_type_api_1
38 {
39 {
40 native_type => 'uint32',
41 perl_to_native => sub {
42 my($value, $i) = @_;
43 # Translates ($value) passed in from Perl
44 # into ($value+1, $value+2)
45 arguments_set_uint32($i, $value+1);
46 arguments_set_uint32($i+1, $value+2);
47 },
48 argument_count => 2,
49 }
50 }
51
52 =head1 DESCRIPTION
53
54 B<NOTE>: I added this interface early on to L<FFI::Platypus>, but haven't
55 used it much, generally finding function wrappers to be a more powerful
56 (although possibly not as fast) interface. It has thus not been
57 tested as much as the rest of Platypus. If you feel the need to use
58 this interface please coordinate with the Platypus developers.
59
60 The custom types API for L<FFI::Platypus> allows you to set multiple C
61 arguments from a single Perl argument as a common type. This is
62 sometimes useful for pointer / size pairs which are a common pattern in
63 C, but are usually represented by a single value (a string scalar) in
64 Perl.
65
66 The custom type API is somewhat experimental, and you should expect some
67 changes as needs arise (I won't break compatibility lightly, however).
68
69 =head1 FUNCTIONS
70
71 These functions are only valid within a custom type callback.
72
73 =head2 arguments_count
74
75 my $count = argument_count;
76
77 Returns the total number of native arguments.
78
79 =head2 arguments_get_sint8
80
81 my $sint8 = arguments_get_sint8 $i;
82
83 Get the 8 bit signed integer argument from position I<$i>.
84
85 =head2 arguments_set_sint8
86
87 arguments_set_sint8 $i, $sint8;
88
89 Set the 8 bit signed integer argument at position I<$i> to I<$sint8>.
90
91 =head2 arguments_get_uint8
92
93 my $uint8 = arguments_get_uint8 $i;
94
95 Get the 8 bit unsigned integer argument from position I<$i>.
96
97 =head2 arguments_set_uint8
98
99 arguments_set_uint8 $i, $uint8;
100
101 Set the 8 bit unsigned integer argument at position I<$i> to I<$uint8>.
102
103 =head2 arguments_get_sint16
104
105 my $sint16 = arguments_get_sint16 $i;
106
107 Get the 16 bit signed integer argument from position I<$i>.
108
109 =head2 arguments_set_sint16
110
111 arguments_set_sint16 $i, $sint16;
112
113 Set the 16 bit signed integer argument at position I<$i> to I<$sint16>.
114
115 =head2 arguments_get_uint16
116
117 my $uint16 = arguments_get_uint16 $i;
118
119 Get the 16 bit unsigned integer argument from position I<$i>.
120
121 =head2 arguments_set_uint16
122
123 arguments_set_uint16 $i, $uint16;
124
125 Set the 16 bit unsigned integer argument at position I<$i> to I<$uint16>.
126
127 =head2 arguments_get_sint32
128
129 my $sint32 = arguments_get_sint32 $i;
130
131 Get the 32 bit signed integer argument from position I<$i>.
132
133 =head2 arguments_set_sint32
134
135 arguments_set_sint32 $i, $sint32;
136
137 Set the 32 bit signed integer argument at position I<$i> to I<$sint32>.
138
139 =head2 arguments_get_uint32
140
141 my $uint32 = arguments_get_uint32 $i;
142
143 Get the 32 bit unsigned integer argument from position I<$i>.
144
145 =head2 arguments_set_uint32
146
147 arguments_set_uint32 $i, $uint32;
148
149 Set the 32 bit unsigned integer argument at position I<$i> to I<$uint32>.
150
151 =head2 arguments_get_sint64
152
153 my $sint64 = arguments_get_sint64 $i;
154
155 Get the 64 bit signed integer argument from position I<$i>.
156
157 =head2 arguments_set_sint64
158
159 arguments_set_sint64 $i, $sint64;
160
161 Set the 64 bit signed integer argument at position I<$i> to I<$sint64>.
162
163 =head2 arguments_get_uint64
164
165 my $uint64 = arguments_get_uint64 $i;
166
167 Get the 64 bit unsigned integer argument from position I<$i>.
168
169 =head2 arguments_set_uint64
170
171 arguments_set_uint64 $i, $uint64;
172
173 Set the 64 bit unsigned integer argument at position I<$i> to I<$uint64>.
174
175 =head2 arguments_get_float
176
177 my $float = arguments_get_float $i;
178
179 Get the floating point argument from position I<$i>.
180
181 =head2 arguments_set_float
182
183 arguments_set_float $i, $float;
184
185 Set the floating point argument at position I<$i> to I<$float>
186
187 =head2 arguments_get_double
188
189 my $double = arguments_get_double $i;
190
191 Get the double precision floating point argument from position I<$i>.
192
193 =head2 arguments_set_double
194
195 arguments_set_double $i, $double;
196
197 Set the double precision floating point argument at position I<$i> to
198 I<$double>
199
200 =head2 arguments_get_pointer
201
202 my $pointer = arguments_get_pointer $i;
203
204 Get the pointer argument from position I<$i>.
205
206 =head2 arguments_set_pointer
207
208 arguments_set_pointer $i, $pointer;
209
210 Set the pointer argument at position I<$i> to I<$pointer>.
211
212 =head2 arguments_get_string
213
214 my $string = arguments_get_string $i;
215
216 Get the string argument from position I<$i>.
217
218 =head2 arguments_set_string
219
220 arguments_set_string $i, $string;
221
222 Set the string argument at position I<$i> to I<$string>.
223
224 =head1 SEE ALSO
225
226 =over 4
227
228 =item L<FFI::Platypus>
229
230 =back
231
232 Examples of use:
233
234 =over 4
235
236 =item L<FFI::Platypus::Type::PointerSizeBuffer>
237
238 =back
239
240 =head1 AUTHOR
241
242 Author: Graham Ollis E<lt>[email protected]<gt>
243
244 Contributors:
245
246 Bakkiaraj Murugesan (bakkiaraj)
247
248 Dylan Cali (calid)
249
250 pipcet
251
252 Zaki Mughal (zmughal)
253
254 Fitz Elliott (felliott)
255
256 Vickenty Fesunov (vyf)
257
258 Gregor Herrmann (gregoa)
259
260 Shlomi Fish (shlomif)
261
262 Damyan Ivanov
263
264 Ilya Pavlov (Ilya33)
265
266 Petr Písař (ppisar)
267
268 Mohammad S Anwar (MANWAR)
269
270 Håkon Hægland (hakonhagland, HAKONH)
271
272 Meredith (merrilymeredith, MHOWARD)
273
274 Diab Jerius (DJERIUS)
275
276 Eric Brine (IKEGAMI)
277
278 szTheory
279
280 José Joaquín Atria (JJATRIA)
281
282 Pete Houston (openstrike, HOUSTON)
283
284 Lukas Mai (MAUKE)
285
286 =head1 COPYRIGHT AND LICENSE
287
288 This software is copyright (c) 2015-2022 by Graham Ollis.
289
290 This is free software; you can redistribute it and/or modify it under
291 the same terms as the Perl 5 programming language system itself.
292
293 =cut