```{index} single: FFI::Platypus::API ``` # FFI::Platypus::API Platypus arguments and return value API for custom types ## VERSION version 2.12 ## SYNOPSIS ```perl package FFI::Platypus::Type::MyCustomType; use FFI::Platypus::API; sub ffi_custom_type_api_1 { { native_type => 'uint32', 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, } } ``` ## DESCRIPTION **NOTE**: I added this interface early on to [FFI::Platypus](../Platypus.md), 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. The custom types API for [FFI::Platypus](../Platypus.md) 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. The custom type API is somewhat experimental, and you should expect some changes as needs arise (I won't break compatibility lightly, however). ## FUNCTIONS These functions are only valid within a custom type callback. ### arguments\_count ```perl my $count = argument_count; ``` Returns the total number of native arguments. ### arguments\_get\_sint8 ```perl my $sint8 = arguments_get_sint8 $i; ``` Get the 8 bit signed integer argument from position _$i_. ### arguments\_set\_sint8 ```perl arguments_set_sint8 $i, $sint8; ``` Set the 8 bit signed integer argument at position _$i_ to _$sint8_. ### arguments\_get\_uint8 ```perl my $uint8 = arguments_get_uint8 $i; ``` Get the 8 bit unsigned integer argument from position _$i_. ### arguments\_set\_uint8 ```perl arguments_set_uint8 $i, $uint8; ``` Set the 8 bit unsigned integer argument at position _$i_ to _$uint8_. ### arguments\_get\_sint16 ```perl my $sint16 = arguments_get_sint16 $i; ``` Get the 16 bit signed integer argument from position _$i_. ### arguments\_set\_sint16 ```perl arguments_set_sint16 $i, $sint16; ``` Set the 16 bit signed integer argument at position _$i_ to _$sint16_. ### arguments\_get\_uint16 ```perl my $uint16 = arguments_get_uint16 $i; ``` Get the 16 bit unsigned integer argument from position _$i_. ### arguments\_set\_uint16 ```perl arguments_set_uint16 $i, $uint16; ``` Set the 16 bit unsigned integer argument at position _$i_ to _$uint16_. ### arguments\_get\_sint32 ```perl my $sint32 = arguments_get_sint32 $i; ``` Get the 32 bit signed integer argument from position _$i_. ### arguments\_set\_sint32 ```perl arguments_set_sint32 $i, $sint32; ``` Set the 32 bit signed integer argument at position _$i_ to _$sint32_. ### arguments\_get\_uint32 ```perl my $uint32 = arguments_get_uint32 $i; ``` Get the 32 bit unsigned integer argument from position _$i_. ### arguments\_set\_uint32 ```perl arguments_set_uint32 $i, $uint32; ``` Set the 32 bit unsigned integer argument at position _$i_ to _$uint32_. ### arguments\_get\_sint64 ```perl my $sint64 = arguments_get_sint64 $i; ``` Get the 64 bit signed integer argument from position _$i_. ### arguments\_set\_sint64 ```perl arguments_set_sint64 $i, $sint64; ``` Set the 64 bit signed integer argument at position _$i_ to _$sint64_. ### arguments\_get\_uint64 ```perl my $uint64 = arguments_get_uint64 $i; ``` Get the 64 bit unsigned integer argument from position _$i_. ### arguments\_set\_uint64 ```perl arguments_set_uint64 $i, $uint64; ``` Set the 64 bit unsigned integer argument at position _$i_ to _$uint64_. ### arguments\_get\_float ```perl my $float = arguments_get_float $i; ``` Get the floating point argument from position _$i_. ### arguments\_set\_float ```perl arguments_set_float $i, $float; ``` Set the floating point argument at position _$i_ to _$float_ ### arguments\_get\_double ```perl my $double = arguments_get_double $i; ``` Get the double precision floating point argument from position _$i_. ### arguments\_set\_double ```perl arguments_set_double $i, $double; ``` Set the double precision floating point argument at position _$i_ to _$double_ ### arguments\_get\_pointer ```perl my $pointer = arguments_get_pointer $i; ``` Get the pointer argument from position _$i_. ### arguments\_set\_pointer ```perl arguments_set_pointer $i, $pointer; ``` Set the pointer argument at position _$i_ to _$pointer_. ### arguments\_get\_string ```perl my $string = arguments_get_string $i; ``` Get the string argument from position _$i_. ### arguments\_set\_string ```perl arguments_set_string $i, $string; ``` Set the string argument at position _$i_ to _$string_. ## SEE ALSO - [FFI::Platypus](../Platypus.md) Examples of use: - [FFI::Platypus::Type::PointerSizeBuffer](Type/PointerSizeBuffer.md) ## AUTHOR Author: Graham Ollis Contributors: Bakkiaraj Murugesan (bakkiaraj) Dylan Cali (calid) pipcet Zaki Mughal (zmughal) Fitz Elliott (felliott) Vickenty Fesunov (vyf) Gregor Herrmann (gregoa) Shlomi Fish (shlomif) Damyan Ivanov Ilya Pavlov (Ilya33) Petr Písař (ppisar) Mohammad S Anwar (MANWAR) Håkon Hægland (hakonhagland, HAKONH) Meredith (merrilymeredith, MHOWARD) Diab Jerius (DJERIUS) Eric Brine (IKEGAMI) szTheory José Joaquín Atria (JJATRIA) Pete Houston (openstrike, HOUSTON) Lukas Mai (MAUKE) ## COPYRIGHT AND LICENSE This software is copyright (c) 2015-2022 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.