FFI-Platypus-Legacy-Raw
view release on metacpan or search on metacpan
lib/FFI/Platypus/Legacy/Raw/Platypus.pm view on Meta::CPAN
package FFI::Platypus::Legacy::Raw::Platypus;
use strict;
use warnings;
use Ref::Util qw( is_ref );
use FFI::Platypus;
use base qw( Exporter );
# ABSTRACT: Private class for FFI::Platypus::Legacy::Raw
our $VERSION = '0.06'; # VERSION
our @EXPORT = qw( _ffi _ffi_libc _ffi_package );
sub _add_p_type
{
my $ffi = shift;
$ffi->custom_type(
'p' => {
native_type => 'opaque',
native_to_perl => sub { $_[0] },
perl_to_native => sub {
if(is_ref $_[0])
{
if(eval { $_[0]->isa('FFI::Platypus::Legacy::Raw::Ptr') })
{ return ${$_[0]} }
elsif(eval { $_[0]->isa('FFI::Platypus::Legacy::Raw::Callback') })
{ return $_[0]->{ptr} }
}
$_[0];
},
},
);
}
my %ffi;
sub _ffi ($)
{
my $lib = shift;
die "lib is not defined" unless defined $lib;
$ffi{$lib} ||= do {
my $ffi = FFI::Platypus->new;
$ffi->lang('Raw');
$ffi->lib($lib);
_add_p_type($ffi);
$ffi;
};
}
my $libc;
sub _ffi_libc ()
{
unless($libc)
{
$libc = FFI::Platypus->new;
$libc->lang('Raw');
$libc->lib(undef);
_add_p_type($libc);
}
$libc;
}
my $package;
sub _ffi_package ()
{
( run in 1.431 second using v1.01-cache-2.11-cpan-d80b1682f3f )