Legacy/Raw/Platypus.pm

filter: Statementstmt 100% 53 / 53 Branchbran 83.3% 10 / 12 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 93.8% 76 / 81 CC 8 SCAR 8.0
CC
8
Cov
96%
__ANON__
4.0
_ffi
3.0
_ffi_libc
2.0
CRAP 2.2
« Legacy/Raw/Callback.pm ↑ Summary Legacy/Raw/MemPtr.pm »
1 package FFI::Platypus::Legacy::Raw::Platypus;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use Ref::Util qw( is_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use FFI::Platypus;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use base qw( Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Private class for FFI::Platypus::Legacy::Raw
10 8 our $VERSION = '0.06'; # VERSION
11  
12 8 our @EXPORT = qw( _ffi _ffi_libc _ffi_package );
13  
14 sub _add_p_type
15 19 ▶{
Subroutine _add_p_type: called CC=1 SCAR=0.0
16 19 my $ffi = shift;
17 $ffi->custom_type(
18 'p' => {
19 native_type => 'opaque',
20 4 ▶ native_to_perl => sub { $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
21 34 ▶ perl_to_native => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
22 34 ▶ if(is_ref $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (is_ref($_[0])) 29 5 34
23 {
24 29 ▶ if(eval { $_[0]->isa('FFI::Platypus::Legacy::Raw::Ptr') })
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { $_[0]->isa('FFI::Platypus::Legacy::Raw::Ptr') } }) { } 18 11 29
elsif (eval { do { $_[0]->isa('FFI::Platypus::Legacy::Raw::Callback') } }) { } 11 0 11
25 18 { return ${$_[0]} }
26 11 elsif(eval { $_[0]->isa('FFI::Platypus::Legacy::Raw::Callback') })
27 11 { return $_[0]->{ptr} }
28 }
29 5 $_[0];
30 },
31 },
32 19 );
33 }
34  
35 8 my %ffi;
36 sub _ffi ($)
37 55 ▶{
Subroutine _ffi: called CC=3 SCAR=11.1
38 55 my $lib = shift;
39 55 ▶ die "lib is not defined" unless defined $lib;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lib 0 55 55
40 55 ▶ $ffi{$lib} ||= do {
Condition66%2/3
$ffi{$lib} ||= do { my $ffi = "FFI::Platypus"->new; $ffi->lang("Raw"); $ffi->lib($lib); _add_p_type($ffi); $ffi }
l!l&&r!l&&!r
4780
MC/DC0%0/2
$ffi{$lib} ||= do { my $ffi = "FFI::Platypus"->new; $ffi->lang("Raw"); $ffi->lib($lib); _add_p_type($ffi); $ffi }
$ffi{$lib} do { my $ffi = "FFI::Platypus"->new; $ffi->lang("Raw"); $ffi->lib($lib); _add_p_type($ffi); $ffi }
Truth table66%2/3
A ||= B
A= $ffi{$lib}B= do { my $ffi = "FFI::Platypus"->new; $ffi->lang("Raw"); $ffi->lib($lib); _add_p_type($ffi); $ffi }
ABresult
1X1
011
000
41 8 my $ffi = FFI::Platypus->new;
42 8 $ffi->lang('Raw');
43 8 $ffi->lib($lib);
44 8 _add_p_type($ffi);
45 8 $ffi;
46 };
47 }
48  
49 my $libc;
50 sub _ffi_libc ()
51 4 ▶{
Subroutine _ffi_libc: called CC=2 SCAR=6.9
52 4 ▶ unless($libc)
Branch: 1 branch
BranchTrueFalseTotal
unless ($libc) 3 1 4
53 {
54 3 $libc = FFI::Platypus->new;
55 3 $libc->lang('Raw');
56 3 $libc->lib(undef);
57 3 _add_p_type($libc);
58 }
59  
60 4 $libc;
61 }
62  
63 8 my $package;
64 sub _ffi_package ()
65 29 ▶{
Subroutine _ffi_package: called CC=2 SCAR=6.9
66 29 ▶ unless($package)
Branch: 1 branch
BranchTrueFalseTotal
unless ($package) 8 21 29
67 {
68 8 $package = FFI::Platypus->new;
69 8 $package->lang('Raw');
70 8 my $file = __FILE__;
71 # assumes of course that both this and ../Raw.pm
72 # are installed together and in the same place.
73 8 $file =~ s{Raw/Platypus\.pm$}{Raw.pm};
74 8 $package->package('FFI::Platypus::Legacy::Raw', $file);
75 8 _add_p_type($package);
76 }
77  
78 29 $package;
79 }
80  
81 8 1;
82  
83 __END__
« Legacy/Raw/Callback.pm ↑ Summary Legacy/Raw/MemPtr.pm »