.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "FFI::Platypus::API 3pm" .TH FFI::Platypus::API 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME FFI::Platypus::API \- Platypus arguments and return value API for custom types .SH VERSION .IX Header "VERSION" version 2.08 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& package FFI::Platypus::Type::MyCustomType; \& \& use FFI::Platypus::API; \& \& sub ffi_custom_type_api_1 \& { \& { \& native_type => \*(Aquint32\*(Aq, \& perl_to_native => sub { \& my($value, $i) = @_; \& # Translates ($value) passed in from Perl \& # into ($value+1, $value+2) \& arguments_set_uint32($i, $value+1); \& arguments_set_uint32($i+1, $value+2); \& }, \& argument_count => 2, \& } \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fBNOTE\fR: I added this interface early on to FFI::Platypus, but haven't used it much, generally finding function wrappers to be a more powerful (although possibly not as fast) interface. It has thus not been tested as much as the rest of Platypus. If you feel the need to use this interface please coordinate with the Platypus developers. .PP The custom types API for FFI::Platypus allows you to set multiple C arguments from a single Perl argument as a common type. This is sometimes useful for pointer / size pairs which are a common pattern in C, but are usually represented by a single value (a string scalar) in Perl. .PP The custom type API is somewhat experimental, and you should expect some changes as needs arise (I won't break compatibility lightly, however). .SH FUNCTIONS .IX Header "FUNCTIONS" These functions are only valid within a custom type callback. .SS arguments_count .IX Subsection "arguments_count" .Vb 1 \& my $count = argument_count; .Ve .PP Returns the total number of native arguments. .SS arguments_get_sint8 .IX Subsection "arguments_get_sint8" .Vb 1 \& my $sint8 = arguments_get_sint8 $i; .Ve .PP Get the 8 bit signed integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_sint8 .IX Subsection "arguments_set_sint8" .Vb 1 \& arguments_set_sint8 $i, $sint8; .Ve .PP Set the 8 bit signed integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$sint8\fR\fI\fR. .SS arguments_get_uint8 .IX Subsection "arguments_get_uint8" .Vb 1 \& my $uint8 = arguments_get_uint8 $i; .Ve .PP Get the 8 bit unsigned integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_uint8 .IX Subsection "arguments_set_uint8" .Vb 1 \& arguments_set_uint8 $i, $uint8; .Ve .PP Set the 8 bit unsigned integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$uint8\fR\fI\fR. .SS arguments_get_sint16 .IX Subsection "arguments_get_sint16" .Vb 1 \& my $sint16 = arguments_get_sint16 $i; .Ve .PP Get the 16 bit signed integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_sint16 .IX Subsection "arguments_set_sint16" .Vb 1 \& arguments_set_sint16 $i, $sint16; .Ve .PP Set the 16 bit signed integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$sint16\fR\fI\fR. .SS arguments_get_uint16 .IX Subsection "arguments_get_uint16" .Vb 1 \& my $uint16 = arguments_get_uint16 $i; .Ve .PP Get the 16 bit unsigned integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_uint16 .IX Subsection "arguments_set_uint16" .Vb 1 \& arguments_set_uint16 $i, $uint16; .Ve .PP Set the 16 bit unsigned integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$uint16\fR\fI\fR. .SS arguments_get_sint32 .IX Subsection "arguments_get_sint32" .Vb 1 \& my $sint32 = arguments_get_sint32 $i; .Ve .PP Get the 32 bit signed integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_sint32 .IX Subsection "arguments_set_sint32" .Vb 1 \& arguments_set_sint32 $i, $sint32; .Ve .PP Set the 32 bit signed integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$sint32\fR\fI\fR. .SS arguments_get_uint32 .IX Subsection "arguments_get_uint32" .Vb 1 \& my $uint32 = arguments_get_uint32 $i; .Ve .PP Get the 32 bit unsigned integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_uint32 .IX Subsection "arguments_set_uint32" .Vb 1 \& arguments_set_uint32 $i, $uint32; .Ve .PP Set the 32 bit unsigned integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$uint32\fR\fI\fR. .SS arguments_get_sint64 .IX Subsection "arguments_get_sint64" .Vb 1 \& my $sint64 = arguments_get_sint64 $i; .Ve .PP Get the 64 bit signed integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_sint64 .IX Subsection "arguments_set_sint64" .Vb 1 \& arguments_set_sint64 $i, $sint64; .Ve .PP Set the 64 bit signed integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$sint64\fR\fI\fR. .SS arguments_get_uint64 .IX Subsection "arguments_get_uint64" .Vb 1 \& my $uint64 = arguments_get_uint64 $i; .Ve .PP Get the 64 bit unsigned integer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_uint64 .IX Subsection "arguments_set_uint64" .Vb 1 \& arguments_set_uint64 $i, $uint64; .Ve .PP Set the 64 bit unsigned integer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$uint64\fR\fI\fR. .SS arguments_get_float .IX Subsection "arguments_get_float" .Vb 1 \& my $float = arguments_get_float $i; .Ve .PP Get the floating point argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_float .IX Subsection "arguments_set_float" .Vb 1 \& arguments_set_float $i, $float; .Ve .PP Set the floating point argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$float\fR\fI\fR .SS arguments_get_double .IX Subsection "arguments_get_double" .Vb 1 \& my $double = arguments_get_double $i; .Ve .PP Get the double precision floating point argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_double .IX Subsection "arguments_set_double" .Vb 1 \& arguments_set_double $i, $double; .Ve .PP Set the double precision floating point argument at position \fR\f(CI$i\fR\fI\fR to \&\fI\fR\f(CI$double\fR\fI\fR .SS arguments_get_pointer .IX Subsection "arguments_get_pointer" .Vb 1 \& my $pointer = arguments_get_pointer $i; .Ve .PP Get the pointer argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_pointer .IX Subsection "arguments_set_pointer" .Vb 1 \& arguments_set_pointer $i, $pointer; .Ve .PP Set the pointer argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$pointer\fR\fI\fR. .SS arguments_get_string .IX Subsection "arguments_get_string" .Vb 1 \& my $string = arguments_get_string $i; .Ve .PP Get the string argument from position \fR\f(CI$i\fR\fI\fR. .SS arguments_set_string .IX Subsection "arguments_set_string" .Vb 1 \& arguments_set_string $i, $string; .Ve .PP Set the string argument at position \fR\f(CI$i\fR\fI\fR to \fI\fR\f(CI$string\fR\fI\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP FFI::Platypus 4 .IX Item "FFI::Platypus" .PP Examples of use: .IP FFI::Platypus::Type::PointerSizeBuffer 4 .IX Item "FFI::Platypus::Type::PointerSizeBuffer" .SH AUTHOR .IX Header "AUTHOR" Author: Graham Ollis .PP Contributors: .PP Bakkiaraj Murugesan (bakkiaraj) .PP Dylan Cali (calid) .PP pipcet .PP Zaki Mughal (zmughal) .PP Fitz Elliott (felliott) .PP Vickenty Fesunov (vyf) .PP Gregor Herrmann (gregoa) .PP Shlomi Fish (shlomif) .PP Damyan Ivanov .PP Ilya Pavlov (Ilya33) .PP Petr Písař (ppisar) .PP Mohammad S Anwar (MANWAR) .PP Håkon Hægland (hakonhagland, HAKONH) .PP Meredith (merrilymeredith, MHOWARD) .PP Diab Jerius (DJERIUS) .PP Eric Brine (IKEGAMI) .PP szTheory .PP José Joaquín Atria (JJATRIA) .PP Pete Houston (openstrike, HOUSTON) .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2015\-2022 by Graham Ollis. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.