Loader.pm

filter: Statementstmt 36.4% 27 / 74 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 25 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 66.6% 8 / 12 Podpod 66.6% 2 / 3 totaltotal 23.1% 37 / 160 CC 27 SCAR 56.3
CC
27
Cov
21%
load
452.1
mod2fname_unique
30.0
__ANON__
2.0
CRAP 277.9
« Install/ParseXS.pm ↑ Summary Install/FrozenShit/ParseXS/Node.pm »
1 package XS::Loader;
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Config();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use DynaLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use XS::Install::Payload;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use XS::Install::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 11 our $UNIQUE_LIBNAME = ($^O eq 'MSWin32');
10  
11 0 ▶sub load {
Subroutine load: not called CC=23 SCAR=61.1
Pod documented
12 0 ▶ shift if $_[0] && $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] and $_[0] eq __PACKAGE__ 0 0 0
Condition0%0/3
$_[0] and $_[0] eq __PACKAGE__
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq __PACKAGE__
$_[0] $_[0] eq __PACKAGE__
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq __PACKAGE__
ABresult
0X0
100
111
13 0 my ($module, $version, $flags, $noboot) = @_;
14  
15 0 ▶ $module ||= caller(0);
Condition0%0/3
$module ||= caller 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$module ||= caller 0
$module caller 0
Truth table0%0/3
A ||= B
A= $moduleB= caller 0
ABresult
1X1
011
000
16 0 ▶ $version ||= XS::Install::Payload::loaded_module_version($module);
Condition0%0/3
$version ||= XS::Install::Payload::loaded_module_version($module)
l!l&&r!l&&!r
000
MC/DC0%0/2
$version ||= XS::Install::Payload::loaded_module_version($module)
$version XS::Install::Payload::loaded_module_version($module)
Truth table0%0/3
A ||= B
A= $versionB= XS::Install::Payload::loaded_module_version($module)
ABresult
1X1
011
000
17 0 ▶ $flags //= 0x01;
Condition0%0/2
$flags //= 1
l!l
00
MC/DC0%0/1
$flags //= 1
$flags
Truth table0%0/2
A
A= $flags
Aresult
11
00
18 0 ▶ $noboot = 1 if $module eq 'MyTest';
Branch: 1 branch
BranchTrueFalseTotal
if $module eq "MyTest" 0 0 0
19  
20 0 ▶ if ($flags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags) 0 0 0
21 11 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 0 ▶ *{"${module}::dl_load_flags"} = sub { $flags };
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 }
24  
25 0 ▶ if (my $info = XS::Install::Payload::binary_module_info($module)) {{
Branch: 1 branch
BranchTrueFalseTotal
if (my $info = XS::Install::Payload::binary_module_info($module)) 0 0 0
26 0 ▶ my $bin_deps = $info->{BIN_DEPS} or last;
Branch: 1 branch
BranchTrueFalseTotal
my $bin_deps = $info->{"BIN_DEPS"} or last 0 0 0
27 0 foreach my $dep_module (keys %$bin_deps) {
28 0 ▶ next if $dep_module eq 'XS::Install';
Branch: 1 branch
BranchTrueFalseTotal
if $dep_module eq "XS::Install" 0 0 0
29 0 my $path = $dep_module;
30 0 $path =~ s!::!/!g;
31 0 ▶ require $path.".pm" or next; # in what cases it returns false without croaking?
Branch: 1 branch
BranchTrueFalseTotal
require $path . '.pm' or next 0 0 0
32 0 my $dep_version = XS::Install::Payload::loaded_module_version($dep_module);
33 0 ▶ next if $dep_version eq $bin_deps->{$dep_module};
Branch: 1 branch
BranchTrueFalseTotal
if $dep_version eq $bin_deps->{$dep_module} 0 0 0
34 0 ▶ my $dep_info = XS::Install::Payload::binary_module_info($dep_module) || {};
Condition0%0/2
XS::Install::Payload::binary_module_info($dep_module) || {}
l!l
00
MC/DC0%0/1
XS::Install::Payload::binary_module_info($dep_module) || {}
XS::Install::Payload::binary_module_info($dep_module)
Truth table0%0/2
A
A= XS::Install::Payload::binary_module_info($dep_module)
Aresult
11
00
35 0 my $bin_dependent = $dep_info->{BIN_DEPENDENT};
36 0 ▶ $bin_dependent = [$module] if !$bin_dependent or !@$bin_dependent;
Branch: 1 branch
BranchTrueFalseTotal
unless $bin_dependent and @$bin_dependent 0 0 0
Condition0%0/3
$bin_dependent and @$bin_dependent
!ll&&!rl&&r
000
MC/DC0%0/2
$bin_dependent and @$bin_dependent
$bin_dependent @$bin_dependent
Truth table0%0/3
A and B
A= $bin_dependentB= @$bin_dependent
ABresult
0X0
100
111
37 0 $bin_dependent = XS::Install::Util::linearize_dependent($bin_dependent);
38 0 die << "EOF";
39 ******************************************************************************
40 XS::Loader: XS module $module binary depends on XS module $dep_module.
41 $module was compiled with $dep_module version $bin_deps->{$dep_module}, but current version is $dep_version.
42 Please reinstall all modules that binary depend on $dep_module:
43 cpanm --reinstall @$bin_dependent
44 ******************************************************************************
45 EOF
46 }
47 }}
48  
49 0 ▶ local *DynaLoader::mod2fname = \&mod2fname_unique if $UNIQUE_LIBNAME;
Branch: 1 branch
BranchTrueFalseTotal
if $XS::Loader::UNIQUE_LIBNAME 0 0 0
50  
51 0 my $ok = eval {
52 0 DynaLoader::bootstrap_inherit($module, $version);
53 0 1;
54 };
55 0 ▶ die($@) if !$ok and !($noboot and $@ and $@ =~ /Can't find 'boot_/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok or $noboot and $@ and $@ =~ /Can't find 'boot_/i 0 0 0
Condition0%0/9
$ok or $noboot and $@ and $@ =~ /Can't find 'boot_/i
l!l&&r!l&&!r
000
$noboot and $@ and $@ =~ /Can't find 'boot_/i
!ll&&!rl&&r
000
$noboot and $@
!ll&&!rl&&r
000
MC/DC0%0/4
$ok or $noboot and $@ and $@ =~ /Can't find 'boot_/i
$ok $noboot $@ $@ =~ /Can't find 'boot_/i
Truth table0%0/5
A or B and C and D
A= $okB= $nobootC= $@D= $@ =~ /Can't find 'boot_/i
ABCDresult
1XXX1
01111
00XX0
010X0
01100
56  
57 0 ▶ if ($flags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags) 0 0 0
58 11 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
59 0 my $stash = \%{"${module}::"};
60 0 delete $stash->{dl_load_flags};
61 }
62 }
63  
64 0 ▶sub load_noboot {
Subroutine load_noboot: not called CC=1 SCAR=6.9
Pod documented
65 0 @_ = ($_[0], $_[1], $_[2], 1);
66 0 goto &load;
67 }
68  
69 11 *bootstrap = *load;
70  
71 ############## taken from DynaLoader_pm.PL, needed on Windows #####################
72 0 ▶sub mod2fname_unique {
Subroutine mod2fname_unique: not called CC=5 SCAR=34.0
Pod undocumented
73 0 my $parts = shift;
74 0 my $so_len = length($Config::Config{dlext}) + 1;
75 0 my $name_max = 255; # No easy way to get this here
76  
77 0 my $libname = "PL_".join("__", @$parts);
78  
79 0 ▶ return $libname if (length($libname)+$so_len) <= $name_max;
Branch: 1 branch
BranchTrueFalseTotal
if length($libname) + $so_len <= $name_max 0 0 0
80  
81 # It's too darned big, so we need to go strip. We use the same
82 # algorithm as xsubpp does. First, strip out doubled __
83 0 $libname =~ s/__/_/g;
84 0 ▶ return $libname if (length($libname)+$so_len) <= $name_max;
Branch: 1 branch
BranchTrueFalseTotal
if length($libname) + $so_len <= $name_max 0 0 0
85  
86 # Strip duplicate letters
87 0 ▶ 1 while $libname =~ s/(.)\1/\U$1/i;
Branch: 1 branch
BranchTrueFalseTotal
$libname =~ s/(.)\1/\U$1\E/i and do { '???' } 0 0 0
88 0 ▶ return $libname if (length($libname)+$so_len) <= $name_max;
Branch: 1 branch
BranchTrueFalseTotal
if length($libname) + $so_len <= $name_max 0 0 0
89  
90 # Still too long. Truncate.
91 0 $libname = substr($libname, 0, $name_max - $so_len);
92 0 return $libname;
93 }
94  
95 11 1;
« Install/ParseXS.pm ↑ Summary Install/FrozenShit/ParseXS/Node.pm »