FFI-Platypus icon indicating copy to clipboard operation
FFI-Platypus copied to clipboard

Allow specification of direction of conversion for function parameters

Open djerius opened this issue 5 years ago • 1 comments

Sometimes a function uses a parameter only for input or for output. In those cases, the type conversion code can be optimized to convert data in a single direction, rather than assuming that data will need to be converted both to- and from- Perl.

This could be accomplished by creating new types which are optimized for conversion directions. A simple means of indicating this would be to decorate the type names with < and > characters, indicating which direction conversion is required.

For example, >string would convert from Perl to the foreign function, <string would convert from the foreign function to Perl, and <>string would perform bi-directional conversion.

djerius avatar Feb 24 '20 20:02 djerius

This is something that Glib's introspection API has support for (via annotations): https://gi.readthedocs.io/en/latest/annotations/giannotations.html

(in) | parameters | In parameter. | v0.5.0 unknown

(out) | parameters | Out parameter (automatically determine allocation). | v0.5.0 unknown

zmughal avatar Dec 09 '22 23:12 zmughal