blib/lib/FFI/Platypus/Type/StringPointer.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 91.6% 11 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 85.7% 66 / 77 CC 8 SCAR 8.3
CC
8
Cov
92%
BEGIN
4.1
perl_to_native_post
3.0
native_to_perl
3.0
CRAP 2.3
« blib/lib/FFI/Platypus/Type/StringArray.pm ↑ Summary blib/lib/FFI/Platypus/Record/Meta.pm »
1 package FFI::Platypus::Type::StringPointer;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use FFI::Platypus;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Scalar::Util qw( readonly );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Convert a pointer to a string and back
10 1 our $VERSION = '2.12'; # VERSION
11  
12  
13 1 ▶use constant _incantation =>
Subroutine BEGIN: called CC=3 SCAR=14.2
14 0 ▶ $^O eq 'MSWin32' && do { require Config; $Config::Config{archname} =~ /MSWin32-x64/ }
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' && do { require Config; $Config::Config{'archname'} =~ /MSWin32-x64/ } ? : 0 1 1
Condition33%1/3
$^O eq "MSWin32" and do { require Config; $Config::Config{"archname"} =~ /MSWin32-x64/ }
!ll&&!rl&&r
100
MC/DC0%0/2
$^O eq "MSWin32" and do { require Config; $Config::Config{"archname"} =~ /MSWin32-x64/ }
$^O eq "MSWin32" do { require Config; $Config::Config{"archname"} =~ /MSWin32-x64/ }
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= do { require Config; $Config::Config{"archname"} =~ /MSWin32-x64/ }
ABresult
0X0
100
111
15 ? 'Q'
16 1 : 'L!';
17 1 ▶use constant _pointer_buffer => "P" . FFI::Platypus->new( api => 2 )->sizeof('opaque');
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 my @stack;
20  
21 sub perl_to_native
22 5 ▶{
Subroutine perl_to_native: called CC=2 SCAR=6.9
Pod undocumented
23 5 ▶ if(defined $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) { } 4 1 5
24 {
25 4 my $packed = pack 'P', ${$_[0]};
26 4 my $pointer_pointer = pack 'P', $packed;
27 4 my $unpacked = unpack _incantation, $pointer_pointer;
28 4 push @stack, [ \$packed, \$pointer_pointer ];
29 4 return $unpacked;
30 }
31 else
32 {
33 1 push @stack, [];
34 1 return undef;
35 }
36 }
37  
38 sub perl_to_native_post
39 5 ▶{
Subroutine perl_to_native_post: called CC=3 SCAR=11.0
Pod undocumented
40 5 my($packed) = @{ pop @stack };
41 5 ▶ return unless defined $packed;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $packed 1 4 5
42 4 ▶ unless(readonly(${$_[0]}))
Branch: 1 branch
BranchTrueFalseTotal
unless (&readonly(${$_[0];})) 2 2 4
43 {
44 2 ${$_[0]} = unpack 'p', $$packed;
45 }
46 }
47  
48 sub native_to_perl
49 3 ▶{
Subroutine native_to_perl: called CC=3 SCAR=11.0
Pod undocumented
50 3 ▶ return unless defined $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 1 2 3
51 2 my $pointer_pointer = unpack(_incantation, unpack(_pointer_buffer, pack(_incantation, $_[0])));
52 2 ▶ $pointer_pointer ? \unpack('p', pack(_incantation, $pointer_pointer)) : \undef;
Branch: 1 branch
BranchTrueFalseTotal
$pointer_pointer ? : 1 1 2
53 }
54  
55 sub ffi_custom_type_api_1
56 1 ▶{
Subroutine ffi_custom_type_api_1: called CC=1 SCAR=0.0
Pod undocumented
57 return {
58 1 native_type => 'opaque',
59 perl_to_native => \&perl_to_native,
60 perl_to_native_post => \&perl_to_native_post,
61 native_to_perl => \&native_to_perl,
62 }
63 }
64  
65 1 1;
66  
67 __END__
« blib/lib/FFI/Platypus/Type/StringArray.pm ↑ Summary blib/lib/FFI/Platypus/Record/Meta.pm »