blib/lib/Inline/Pdlpp.pm

filter: Statementstmt 93.0% 93 / 100 Branchbran 58.3% 14 / 24 Conditioncond 40.9% 9 / 22 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 91.3% 21 / 23 Podpod 6.6% 1 / 15 totaltotal 70.4% 138 / 196 CC 22 SCAR 17.3
CC
22
Cov
79%
validate
14.8
write_Makefile_PL
6.1
pd_boot
3.8
CRAP 5.7
« lib/PDL/FFT.pd ↑ Summary blib/lib/PDL/Basic.pm »
1 package Inline::Pdlpp;
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  
6 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Cwd qw(cwd abs_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use PDL::Core::Dev;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 $Inline::Pdlpp::VERSION = '0.4';
13 1 ▶use base qw(Inline::C);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #==============================================================================
16 # Register this module as an Inline language support module
17 #==============================================================================
18 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
19 return {
20 language => 'Pdlpp',
21 aliases => ['pdlpp','PDLPP'],
22 type => 'compiled',
23 suffix => $Config{dlext},
24 0 };
25 }
26  
27 # handle BLESS, INTERNAL - pass everything else up to Inline::C
28 2 ▶sub validate {
Subroutine validate: called CC=11 SCAR=27.0
Pod undocumented
29 2 my $o = shift;
30 2 ▶ $o->{ILSM} ||= {};
Condition50%1/2
$o->{"ILSM"} ||= {}
l!l
02
MC/DC0%0/1
$o->{"ILSM"} ||= {}
$o->{"ILSM"}
Truth table50%1/2
A
A= $o->{"ILSM"}
Aresult
11
00
31 2 ▶ $o->{ILSM}{XS} ||= {};
Condition50%1/2
$o->{"ILSM"}{"XS"} ||= {}
l!l
02
MC/DC0%0/1
$o->{"ILSM"}{"XS"} ||= {}
$o->{"ILSM"}{"XS"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"XS"}
Aresult
11
00
32 # Shouldn't use internal linking for Inline stuff, normally
33 2 ▶ $o->{ILSM}{INTERNAL} = 0 unless defined $o->{ILSM}{INTERNAL};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o->{"ILSM"}{"INTERNAL"} 2 0 2
34 2 ▶ $o->{ILSM}{MAKEFILE} ||= {};
Condition50%1/2
$o->{"ILSM"}{"MAKEFILE"} ||= {}
l!l
02
MC/DC0%0/1
$o->{"ILSM"}{"MAKEFILE"} ||= {}
$o->{"ILSM"}{"MAKEFILE"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"MAKEFILE"}
Aresult
11
00
35 2 ▶ if (not $o->UNTAINT) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($o->UNTAINT) 2 0 2
36 2 $o->{ILSM}{MAKEFILE}{INC} = PDL::Core::Dev::PDL_INCLUDE();
37 }
38 2 ▶ $o->{ILSM}{AUTO_INCLUDE} ||= ' '; # not '' as Inline::C does ||=
Condition50%1/2
$o->{"ILSM"}{"AUTO_INCLUDE"} ||= " "
l!l
02
MC/DC0%0/1
$o->{"ILSM"}{"AUTO_INCLUDE"} ||= " "
$o->{"ILSM"}{"AUTO_INCLUDE"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"AUTO_INCLUDE"}
Aresult
11
00
39 2 my @pass_along;
40 2 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 2 3
41 1 my ($key, $value) = (shift, shift);
42 1 ▶ if ($key eq 'INTERNAL' or
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "INTERNAL" or $key eq "PACKAGE" or $key eq "BLESS") 1 0 1
Condition33%2/6
$key eq "INTERNAL" or $key eq "PACKAGE" or $key eq "BLESS"
l!l&&r!l&&!r
100
$key eq "INTERNAL" or $key eq "PACKAGE"
l!l&&r!l&&!r
010
MC/DC0%0/3
$key eq "INTERNAL" or $key eq "PACKAGE" or $key eq "BLESS"
$key eq "INTERNAL" $key eq "PACKAGE" $key eq "BLESS"
Truth table25%1/4
A or B or C
A= $key eq "INTERNAL"B= $key eq "PACKAGE"C= $key eq "BLESS"
ABCresult
1XX1
01X1
0011
0000
43 $key eq 'PACKAGE' or
44 $key eq 'BLESS'
45 ) {
46 1 $o->{ILSM}{$key} = $value;
47 1 next;
48 }
49 0 push @pass_along, $key, $value;
50 }
51 2 $o->SUPER::validate(@pass_along);
52 }
53  
54 #==============================================================================
55 # Parse and compile C code
56 #==============================================================================
57 2 ▶sub build {
Subroutine build: called CC=1 SCAR=0.0
Pod undocumented
58 2 my $o = shift;
59 # $o->parse; # no parsing in pdlpp
60 2 $o->get_maps; # get the typemaps
61 2 $o->write_PD;
62 # $o->write_Inline_headers; # shouldn't need this one either
63 2 $o->write_Makefile_PL;
64 2 $o->compile;
65 }
66  
67 #==============================================================================
68 # Return a small report about the C code..
69 #==============================================================================
70 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod documented
71 0 my $o = shift;
72 0 my $txt = <<END;
73 The following PP code was generated (caution, can be long)...
74  
75 *** start PP file ****
76  
77 END
78 0 return $txt . $o->pd_generate . "\n*** end PP file ****\n";
79 }
80  
81 #==============================================================================
82 # Write the PDL::PP code into a PD file
83 #==============================================================================
84 2 ▶sub write_PD {
Subroutine write_PD: called CC=2 SCAR=7.0
Pod undocumented
85 2 my $o = shift;
86 2 my $modfname = $o->{API}{modfname};
87 2 my $module = $o->{API}{module};
88 2 $o->mkpath($o->{API}{build_dir});
89 2 ▶ open my $fh, ">", "$o->{API}{build_dir}/$modfname.pd" or croak $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", qq[$o->{"API"}{"build_dir"}/$modfname.pd] or croak($!) 2 0 2
90 2 print $fh $o->pd_generate;
91 2 close $fh;
92 }
93  
94 #==============================================================================
95 # Generate the PDL::PP code (piece together a few snippets)
96 #==============================================================================
97 2 ▶sub pd_generate {
Subroutine pd_generate: called CC=1 SCAR=0.0
Pod undocumented
98 2 my $o = shift;
99 2 return join "\n", ($o->pd_includes,
100 $o->pd_code,
101 $o->pd_boot,
102 $o->pd_bless,
103 $o->pd_done,
104 );
105 }
106  
107 2 ▶sub pd_includes {
Subroutine pd_includes: called CC=1 SCAR=0.0
Pod undocumented
108 2 my $o = shift;
109 2 return << "END";
110 pp_addhdr << 'EOH';
111 $o->{ILSM}{AUTO_INCLUDE}
112 EOH
113  
114 END
115 }
116  
117 2 ▶sub pd_code {
Subroutine pd_code: called CC=1 SCAR=0.0
Pod undocumented
118 2 my $o = shift;
119 2 return $o->{API}{code};
120 }
121  
122 2 ▶sub pd_boot {
Subroutine pd_boot: called CC=3 SCAR=13.3
Pod undocumented
123 2 my $o = shift;
124 2 ▶ if (defined $o->{ILSM}{XS}{BOOT} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o->{"ILSM"}{"XS"}{"BOOT"} and $o->{"ILSM"}{"XS"}{"BOOT"}) 0 2 2
Condition33%1/3
defined $o->{"ILSM"}{"XS"}{"BOOT"} and $o->{"ILSM"}{"XS"}{"BOOT"}
!ll&&!rl&&r
200
MC/DC0%0/2
defined $o->{"ILSM"}{"XS"}{"BOOT"} and $o->{"ILSM"}{"XS"}{"BOOT"}
defined $o->{"ILSM"}{"XS"}{"BOOT"} $o->{"ILSM"}{"XS"}{"BOOT"}
Truth table33%1/3
A and B
A= defined $o->{"ILSM"}{"XS"}{"BOOT"}B= $o->{"ILSM"}{"XS"}{"BOOT"}
ABresult
0X0
100
111
125 $o->{ILSM}{XS}{BOOT}) {
126 0 return <<END;
127 pp_add_boot << 'EOB';
128 $o->{ILSM}{XS}{BOOT}
129 EOB
130  
131 END
132 }
133 2 return '';
134 }
135  
136  
137 2 ▶sub pd_bless {
Subroutine pd_bless: called CC=3 SCAR=13.3
Pod undocumented
138 2 my $o = shift;
139 2 ▶ if (defined $o->{ILSM}{BLESS} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o->{"ILSM"}{"BLESS"} and $o->{"ILSM"}{"BLESS"}) 0 2 2
Condition33%1/3
defined $o->{"ILSM"}{"BLESS"} and $o->{"ILSM"}{"BLESS"}
!ll&&!rl&&r
200
MC/DC0%0/2
defined $o->{"ILSM"}{"BLESS"} and $o->{"ILSM"}{"BLESS"}
defined $o->{"ILSM"}{"BLESS"} $o->{"ILSM"}{"BLESS"}
Truth table33%1/3
A and B
A= defined $o->{"ILSM"}{"BLESS"}B= $o->{"ILSM"}{"BLESS"}
ABresult
0X0
100
111
140 $o->{ILSM}{BLESS}) {
141 0 return <<END;
142 pp_bless $o->{ILSM}{BLESS};
143 END
144 }
145 2 return '';
146 }
147  
148  
149 2 ▶sub pd_done {
Subroutine pd_done: called CC=1 SCAR=0.0
Pod undocumented
150 2 return <<END;
151 pp_done();
152 END
153 }
154  
155 2 ▶sub get_maps {
Subroutine get_maps: called CC=1 SCAR=0.0
Pod undocumented
156 2 my $o = shift;
157 2 $o->SUPER::get_maps;
158 2 push @{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}, PDL::Core::Dev::PDL_TYPEMAP();
159 }
160  
161 #==============================================================================
162 # Generate the Makefile.PL
163 #==============================================================================
164 2 ▶sub write_Makefile_PL {
Subroutine write_Makefile_PL: called CC=6 SCAR=18.1
Pod undocumented
165 2 my $o = shift;
166 2 my ($modfname,$module,$pkg) = @{$o->{API}}{qw(modfname module pkg)};
167 2 ▶ my $coredev_suffix = $o->{ILSM}{INTERNAL} ? '_int' : '';
Branch: 1 branch
BranchTrueFalseTotal
$o->{'ILSM'}{'INTERNAL'} ? : 0 2 2
168 2 my @pack = [ "$modfname.pd", $modfname, $module ];
169 my $stdargs_func = $o->{ILSM}{INTERNAL}
170 2 ▶ ? \&pdlpp_stdargs_int : \&pdlpp_stdargs;
Branch: 1 branch
BranchTrueFalseTotal
$o->{'ILSM'}{'INTERNAL'} ? : 0 2 2
171 2 my %hash = $stdargs_func->(@pack);
172 2 delete $hash{VERSION_FROM};
173 my %options = (
174 %hash,
175 VERSION => $o->{API}{version} || "0.00",
176 2 %{$o->{ILSM}{MAKEFILE}},
177 NAME => $o->{API}{module},
178 INSTALLSITEARCH => $o->{API}{install_lib},
179 INSTALLDIRS => 'site',
180 INSTALLSITELIB => $o->{API}{install_lib},
181 2 ▶ MAN3PODS => {},
Condition50%1/2
$o->{'API'}{'version'} || '0.00'
l!l
02
MC/DC0%0/1
$o->{'API'}{'version'} || '0.00'
$o->{'API'}{'version'}
Truth table50%1/2
A
A= $o->{'API'}{'version'}
Aresult
11
00
182 PM => {},
183 );
184 2 my @postamblepack = ("$modfname.pd", $modfname, $module);
185 2 ▶ push @postamblepack, $o->{ILSM}{PACKAGE} if $o->{ILSM}{PACKAGE};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"ILSM"}{"PACKAGE"} 1 1 2
186 2 local $Data::Dumper::Terse = 1;
187 2 local $Data::Dumper::Indent = 1;
188 2 ▶ open my $fh, ">", "$o->{API}{build_dir}/Makefile.PL" or croak;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", qq[$o->{"API"}{"build_dir"}/Makefile.PL] or croak() 2 0 2
189 2 print $fh <<END;
190 use strict;
191 use warnings;
192 use ExtUtils::MakeMaker;
193 use PDL::Core::Dev;
194 2 my \$pack = @{[ Data::Dumper::Dumper(\@postamblepack) ]};
195 my %options = %\{
196 END
197 2 print $fh Data::Dumper::Dumper(\%options);
198 2 print $fh <<END;
199 \};
200 WriteMakefile(%options);
201 sub MY::postamble { pdlpp_postamble$coredev_suffix(\$pack); }
202 END
203 2 close $fh;
204 }
205  
206 #==============================================================================
207 # Run the build process.
208 #==============================================================================
209 2 ▶sub compile {
Subroutine compile: called CC=2 SCAR=7.1
Pod undocumented
210 2 my $o = shift;
211 # grep is because on Windows, Cwd::abs_path blows up on non-exist dir
212 local $ENV{PERL5LIB} = join $Config{path_sep}, map abs_path($_), grep -e, @INC
213 2 ▶ unless defined $ENV{PERL5LIB};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ENV{"PERL5LIB"} 0 2 2
214 2 $o->SUPER::compile;
215 }
216 2 ▶sub fix_make { } # our Makefile.PL doesn't need this
Subroutine fix_make: called CC=1 SCAR=0.0
Pod undocumented
217  
218 1 1;
219  
220 __END__
« lib/PDL/FFT.pd ↑ Summary blib/lib/PDL/Basic.pm »