| 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
Condition33%1/3
$^O eq "MSWin32" and do {
require Config;
$Config::Config{"archname"} =~ /MSWin32-x64/
}
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/
}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 42 | 4 | ▶ | unless(readonly(${$_[0]})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||