FFI-Platypus-Declare

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    it like this:

     foo(closure { ... });         # BAD

    Perl will not see any references to it and try to free it immediately.
    (this has to do with the way Perl and C handle responsibilities for
    memory allocation differently). One fix for this is to make sure the
    closure remains in scope using either my or our. If you know the
    closure will need to remain in existence for the life of the process
    (or if you do not care about leaking memory), then you can add the
    sticky keyword to tell FFI::Platypus to keep the thing in memory.

     foo(sticky closure { ... });  # OKAY

 cast

     my $converted_value = cast $original_type, $converted_type, $original_value;

    The cast function converts an existing $original_value of type
    $original_type into one of type $converted_type. Not all types are
    supported, so care must be taken. For example, to get the address of a
    string, you can do this:

     my $address = cast 'string' => 'opaque', $string_value;

 attach_cast

     attach_cast "cast_name", $original_type, $converted_type;
     my $converted_value = cast_name($original_value);

    This function creates a subroutine which can be used to convert
    variables just like the cast function above. The above synopsis is
    roughly equivalent to this:

     sub cast_name { cast($original_type, $converted_type, $_[0]) }
     my $converted_value = cast_name($original_value);

    Except that the attach_cast variant will be much faster if called
    multiple times since the cast does not need to be dynamically allocated
    on each instance.

 sizeof

     my $size = sizeof $type;

    Returns the total size of the given type. For example to get the size
    of an integer:

     my $intsize = sizeof 'int'; # usually 4 or 8 depending on platform

    You can also get the size of arrays

     my $intarraysize = sizeof 'int[64]';

    Keep in mind that "pointer" types will always be the pointer / word
    size for the platform that you are using. This includes strings, opaque
    and pointers to other types.

    This function is not very fast, so you might want to save this value as
    a constant, particularly if you need the size in a loop with many
    iterations.

 lang

     lang $language;

    Specifies the foreign language that you will be interfacing with. The
    default is C. The foreign language specified with this attribute
    changes the default native types (for example, if you specify Rust, you
    will get i32 as an alias for sint32 instead of int as you do with C).

    In the future this may attribute may offer hints when doing demangling
    of languages that require it like C++.

 abi

     abi $abi;

    Set the ABI or calling convention for use in subsequent calls to
    "attach". May be either a string name or integer value from
    FFI::Platypus#abis.

SEE ALSO

    FFI::Platypus

      Object oriented interface to Platypus.

    FFI::Platypus::Type

      Type definitions for Platypus.

    FFI::Platypus::API

      Custom types API for Platypus.

    FFI::Platypus::Memory

      memory functions for FFI.

    FFI::CheckLib

      Find dynamic libraries in a portable way.

    FFI::TinyCC

      JIT compiler for FFI.

AUTHOR

    Author: Graham Ollis <plicease@cpan.org>

    Contributors:

    Carlos D. Álvaro (cdalvaro)

COPYRIGHT AND LICENSE

    This software is copyright (c) 2020 by Graham Ollis.

    This is free software; you can redistribute it and/or modify it under



( run in 0.478 second using v1.01-cache-2.11-cpan-71847e10f99 )