Alt-FFI-Raw-Platypus
view release on metacpan or search on metacpan
lib/FFI/Raw.pm view on Meta::CPAN
package FFI::Raw;
use strict;
use warnings;
use base qw( FFI::Platypus::Legacy::Raw );
use FFI::Raw::Callback;
use FFI::Raw::Ptr;
use FFI::Raw::MemPtr;
# ABSTRACT: Perl bindings to the portable FFI library (libffi)
our $VERSION = '0.32';
foreach my $function (qw( memptr callback void int uint short ushort long ulong int64 uint64 char uchar float double str ptr ))
{
no strict 'refs';
*$function = *{"FFI::Platypus::Legacy::Raw::$function"};
}
sub platypus
{
require Carp;
Carp::croak("platypus not available for FFI::Raw interface");
}
sub attach
{
require Carp;
Carp::croak("attach not available for FFI::Raw interface");
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
FFI::Raw - Perl bindings to the portable FFI library (libffi)
=head1 VERSION
version 0.04
=head1 SYNOPSIS
use FFI::Raw;
my $cos = FFI::Raw->new(
'libm.so', 'cos',
FFI::Raw::double, # return value
FFI::Raw::double # arg #1
);
say $cos->call(2.0);
=head1 DESCRIPTION
B<FFI::Raw> provides a low-level foreign function interface (FFI) for Perl based
on L<libffi|http://sourceware.org/libffi/>. In essence, it can access and call
functions exported by shared libraries without the need to write C/XS code.
Dynamic symbols can be automatically resolved at runtime so that the only
information needed to use B<FFI::Raw> is the name (or path) of the target
library, the name of the function to call and its signature (though it is also
possible to pass a function pointer obtained, for example, using L<DynaLoader>).
Note that this module has nothing to do with L<FFI>.
=head1 CONSTRUCTORS
=head2 new
my $ffi = FFI::Raw->new( $library, $function, $return_type, @arg_types )
Create a new C<FFI::Raw> object. It loads C<$library>, finds the function
C<$function> with return type C<$return_type> and creates a calling interface.
If C<$library> is C<undef> then the function is searched in the main program.
This method also takes a variable number of types, representing the arguments
of the wanted function.
=head2 new_from_ptr
my $ffi = FFI::Raw->new_from_ptr( $function_ptr, $return_type, @arg_types )
Create a new C<FFI::Raw> object from the C<$function_ptr> function pointer.
This method also takes a variable number of types, representing the arguments
of the wanted function.
=head1 METHODS
=head2 call
my $ret = $ffi->call( @args)
Execute the C<FFI::Raw> function. This method also takes a variable number of
( run in 0.731 second using v1.01-cache-2.11-cpan-2398b32b56e )