| 1 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | PDL::Core::Dev - PDL development module | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | This module encapsulates most of the stuff useful for | ||||||||||||||||||||||||||||||||
| 8 | PDL development and is often used from within Makefile.PL's. | ||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | use PDL::Core::Dev; | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | # Stuff used in development/install environment of PDL Makefile.PL's | ||||||||||||||||||||||||||||||||
| 19 | # - not part of PDL itself. | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | package PDL::Core::Dev; | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 10 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 10 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 10 | ▶ | use ExtUtils::Manifest; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 10 | ▶ | use English; require Exporter; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 10 | @ISA = qw( Exporter ); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 10 | @EXPORT = qw( isbigendian genpp %PDL_DATATYPES | |||||||||||||||||||||||||||||||
| 31 | PDL_INCLUDE PDL_TYPEMAP | ||||||||||||||||||||||||||||||||
| 32 | PDL_AUTO_INCLUDE PDL_BOOT | ||||||||||||||||||||||||||||||||
| 33 | PDL_INST_INCLUDE PDL_INST_TYPEMAP | ||||||||||||||||||||||||||||||||
| 34 | pdlpp_postamble_int pdlpp_stdargs_int | ||||||||||||||||||||||||||||||||
| 35 | pdlpp_postamble pdlpp_stdargs write_dummy_make | ||||||||||||||||||||||||||||||||
| 36 | unsupported getcyglib trylink | ||||||||||||||||||||||||||||||||
| 37 | pdlpp_mkgen | ||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 10 | ▶ | my $quotation_mark = $^O =~ /MSWin32/i ? '"' : "'"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | # Installation locations | ||||||||||||||||||||||||||||||||
| 43 | # beware: whereami_any now appends the /Basic or /PDL directory as appropriate | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | # The INST are here still just in case we want to change something later. | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | # print STDERR "executing PDL::Core::Dev from",join(',',caller),"\n"; | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | # Return library locations | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | sub PDL_INCLUDE { '"-I'.whereami_any().'/Core"' }; | ||||||||||||||||||||||||||||||
|
Subroutine
PDL_INCLUDE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 52 | 4 | ▶ | sub PDL_TYPEMAP { whereami_any().'/Core/typemap.pdl' }; | ||||||||||||||||||||||||||||||
|
Subroutine
PDL_TYPEMAP: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 53 | # sub PDL_INST_INCLUDE { '-I'.whereami_any().'/Core' }; | ||||||||||||||||||||||||||||||||
| 54 | # sub PDL_INST_TYPEMAP { whereami_any().'/Core/typemap.pdl' }; | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | sub PDL_INST_INCLUDE {&PDL_INCLUDE} | ||||||||||||||||||||||||||||||
|
Subroutine
PDL_INST_INCLUDE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | sub PDL_INST_TYPEMAP {&PDL_TYPEMAP} | ||||||||||||||||||||||||||||||
|
Subroutine
PDL_INST_TYPEMAP: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | sub PDL_AUTO_INCLUDE { | ||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my ($symname) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
PDL_AUTO_INCLUDE: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | $symname ||= 'PDL'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$symname ||= "PDL"
MC/DC0%0/1
$symname ||= "PDL"
$symname
Truth table50%1/2
A
A= $symname
| |||||||||||||||||||||||||||||||||
| 62 | 1 | return << "EOR"; | |||||||||||||||||||||||||||||||
| 63 | #include <pdlcore.h> | ||||||||||||||||||||||||||||||||
| 64 | static Core* $symname; /* Structure holds core C functions */ | ||||||||||||||||||||||||||||||||
| 65 | static SV* CoreSV; /* Gets pointer to perl var holding core structure */ | ||||||||||||||||||||||||||||||||
| 66 | EOR | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | sub PDL_BOOT { | ||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | my ($symname, $module) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
PDL_BOOT: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | $symname ||= 'PDL'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$symname ||= "PDL"
MC/DC0%0/1
$symname ||= "PDL"
$symname
Truth table50%1/2
A
A= $symname
| |||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | $module ||= 'The code'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$module ||= "The code"
MC/DC0%0/1
$module ||= "The code"
$module
Truth table50%1/2
A
A= $module
| |||||||||||||||||||||||||||||||||
| 73 | 2 | return << "EOR"; | |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */ | ||||||||||||||||||||||||||||||||
| 76 | #ifndef aTHX_ | ||||||||||||||||||||||||||||||||
| 77 | #define aTHX_ | ||||||||||||||||||||||||||||||||
| 78 | #endif | ||||||||||||||||||||||||||||||||
| 79 | if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV)); | ||||||||||||||||||||||||||||||||
| 80 | CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* SV* value */ | ||||||||||||||||||||||||||||||||
| 81 | if (CoreSV==NULL) | ||||||||||||||||||||||||||||||||
| 82 | Perl_croak(aTHX_ "We require the PDL::Core module, which was not found"); | ||||||||||||||||||||||||||||||||
| 83 | $symname = INT2PTR(Core*,SvIV( CoreSV )); /* Core* value */ | ||||||||||||||||||||||||||||||||
| 84 | if ($symname->Version != PDL_CORE_VERSION) | ||||||||||||||||||||||||||||||||
| 85 | Perl_croak(aTHX_ "[$symname->Version: \%d PDL_CORE_VERSION: \%d XS_VERSION: \%s] $module needs to be recompiled against the newly installed PDL", $symname->Version, PDL_CORE_VERSION, XS_VERSION); | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | EOR | ||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | # whereami_any returns appended 'Basic' or 'PDL' dir as appropriate | ||||||||||||||||||||||||||||||||
| 91 | 10 | ▶ | use Cwd qw/abs_path/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 92 | sub whereami_any { | ||||||||||||||||||||||||||||||||
| 93 | 17 | ▶ | my $dir = (&whereami(1) or &whereami_inst(1) or | ||||||||||||||||||||||||||||||
|
Subroutine
whereami_any: called CC=3 SCAR=13.1
Pod
undocumented
Condition40%2/5
&whereami(1) || &whereami_inst(1) || die("Unable to determine ANY directory path to PDL::Core::Dev module\n")
&whereami(1) or &whereami_inst(1)
MC/DC0%0/2
&whereami(1) || &whereami_inst(1) || die("Unable to determine ANY directory path to PDL::Core::Dev module\n")
&whereami(1)
&whereami_inst(1)
Truth table33%1/3
A or B
A= &whereami(1)B= &whereami_inst(1)
| |||||||||||||||||||||||||||||||||
| 94 | die "Unable to determine ANY directory path to PDL::Core::Dev module\n"); | ||||||||||||||||||||||||||||||||
| 95 | 17 | return abs_path($dir); | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | sub whereami { | ||||||||||||||||||||||||||||||||
| 99 | 24 | ▶ | for $dir (@INC,qw|. .. ../.. ../../.. ../../../..|) { | ||||||||||||||||||||||||||||||
|
Subroutine
whereami: called CC=5 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 100 | 210 | ▶ | return ($_[0] ? $dir . '/Basic' : $dir) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 101 | if -e "$dir/Basic/Core/Dev.pm"; | ||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | die "Unable to determine UNINSTALLED directory path to PDL::Core::Dev module\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | if !$_[0]; | ||||||||||||||||||||||||||||||||
| 105 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | sub whereami_inst { | ||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | for $dir (@INC,map {$_."/blib"} qw|. .. ../.. ../../.. ../../../..|) { | ||||||||||||||||||||||||||||||
|
Subroutine
whereami_inst: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return ($_[0] ? $dir . '/PDL' : $dir) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 111 | if -e "$dir/PDL/Core/Dev.pm"; | ||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | die "Unable to determine INSTALLED directory path to PDL::Core::Dev module\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | if !$_[0]; | ||||||||||||||||||||||||||||||||
| 115 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | # | ||||||||||||||||||||||||||||||||
| 119 | # To access PDL's configuration use %PDL::Config. Makefile.PL has been set up | ||||||||||||||||||||||||||||||||
| 120 | # to create this variable so it is available during 'perl Makefile.PL' and | ||||||||||||||||||||||||||||||||
| 121 | # it can be eval-ed during 'make' | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 10 | ▶ | unless ( %PDL::Config ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | # look for the distribution and then the installed version | ||||||||||||||||||||||||||||||||
| 126 | # (a manual version of whereami_any) | ||||||||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||||||||
| 128 | 7 | my $dir; | |||||||||||||||||||||||||||||||
| 129 | 7 | $dir = whereami(1); | |||||||||||||||||||||||||||||||
| 130 | 7 | ▶ | if ( defined $dir ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 131 | 7 | $dir = abs_path($dir . "/Core"); | |||||||||||||||||||||||||||||||
| 132 | } else { | ||||||||||||||||||||||||||||||||
| 133 | # as no argument given whereami_inst will die if it fails | ||||||||||||||||||||||||||||||||
| 134 | # (and it also returns a slightly different path than whereami(1) | ||||||||||||||||||||||||||||||||
| 135 | # does, since it does not include "/PDL") | ||||||||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||||||||
| 137 | 0 | $dir = whereami_inst; | |||||||||||||||||||||||||||||||
| 138 | 0 | $dir = abs_path($dir . "/PDL"); | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 7 | my $dir2 = $dir; | |||||||||||||||||||||||||||||||
| 142 | 7 | $dir2 =~ s/\}/\\\}/g; | |||||||||||||||||||||||||||||||
| 143 | 7 | eval sprintf('require q{%s/Config.pm};', $dir2); | |||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 7 | ▶ | die "Unable to find PDL's configuration info\n [$@]" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | if $@; | ||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | # Data types to C types mapping | ||||||||||||||||||||||||||||||||
| 150 | # get the map from Types.pm | ||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||
| 152 | # load PDL::Types only if it has not been previously loaded | ||||||||||||||||||||||||||||||||
| 153 | 10 | my $loaded_types = grep (m%(PDL|Core)/Types[.]pm$%, keys %INC); | |||||||||||||||||||||||||||||||
| 154 | 10 | $@ = ''; # reset | |||||||||||||||||||||||||||||||
| 155 | 10 | ▶ | eval('require "'.whereami_any().'/Core/Types.pm"') # lets dist Types.pm win | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | unless $loaded_types; # only when PDL::Types not yet loaded | ||||||||||||||||||||||||||||||||
| 157 | 10 | ▶ | if($@) { # if PDL::Types doesn't work try with full path (during build) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 158 | 0 | my $foo = $@; | |||||||||||||||||||||||||||||||
| 159 | 0 | $@=""; | |||||||||||||||||||||||||||||||
| 160 | 0 | eval('require PDL::Types'); | |||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | die "can't find PDL::Types: $foo and $@" unless $@ eq ""; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | 10 | PDL::Types->import(); | |||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | my $inc = defined $PDL::Config{MALLOCDBG}->{include} ? | ||||||||||||||||||||||||||||||||
| 169 | 10 | ▶ | "$PDL::Config{MALLOCDBG}->{include}" : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 170 | my $libs = defined $PDL::Config{MALLOCDBG}->{libs} ? | ||||||||||||||||||||||||||||||||
| 171 | 10 | ▶ | "$PDL::Config{MALLOCDBG}->{libs}" : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 10 | %PDL_DATATYPES = (); | |||||||||||||||||||||||||||||||
| 174 | 10 | foreach $key (keys %PDL::Types::typehash) { | |||||||||||||||||||||||||||||||
| 175 | $PDL_DATATYPES{$PDL::Types::typehash{$key}->{'sym'}} = | ||||||||||||||||||||||||||||||||
| 176 | 80 | $PDL::Types::typehash{$key}->{'ctype'}; | |||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | # non-blocking IO configuration | ||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | 10 | ▶ | $O_NONBLOCK = defined $Config{'o_nonblock'} ? $Config{'o_nonblock'} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 182 | : 'O_NONBLOCK'; | ||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | =head2 isbigendian | ||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | =for ref | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | Is the machine big or little endian? | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | =for example | ||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||
| 192 | print "Your machins is big endian.\n" if isbigendian(); | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | returns 1 if the machine is big endian, 0 if little endian, | ||||||||||||||||||||||||||||||||
| 195 | or dies if neither. It uses the C<byteorder> element of | ||||||||||||||||||||||||||||||||
| 196 | perl's C<%Config> array. | ||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | =for usage | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | my $retval = isbigendian(); | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | =cut | ||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | # ' emacs parsing dummy | ||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | # big/little endian? | ||||||||||||||||||||||||||||||||
| 207 | sub isbigendian { | ||||||||||||||||||||||||||||||||
| 208 | 10 | ▶ | use Config; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 209 | my $byteorder = $Config{byteorder} || | ||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | die "ERROR: Unable to find 'byteorder' in perl's Config\n"; | ||||||||||||||||||||||||||||||
|
Subroutine
isbigendian: not called CC=6 SCAR=37.4
Pod
documented
Condition0%0/2
$Config{'byteorder'} || die("ERROR: Unable to find 'byteorder' in perl's Config\n")
MC/DC0%0/1
$Config{'byteorder'} || die("ERROR: Unable to find 'byteorder' in perl's Config\n")
$Config{'byteorder'}
Truth table0%0/2
A
A= $Config{'byteorder'}
| |||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | return 1 if $byteorder eq "4321"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return 1 if $byteorder eq "87654321"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return 0 if $byteorder eq "1234"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return 0 if $byteorder eq "12345678"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 215 | 0 | die "ERROR: PDL does not understand your machine's byteorder ($byteorder)\n"; | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | #################### PDL Generic PreProcessor #################### | ||||||||||||||||||||||||||||||||
| 219 | # | ||||||||||||||||||||||||||||||||
| 220 | # Preprocesses *.g files to *.c files allowing 'generic' | ||||||||||||||||||||||||||||||||
| 221 | # type code which is converted to code for each type. | ||||||||||||||||||||||||||||||||
| 222 | # | ||||||||||||||||||||||||||||||||
| 223 | # e.g. the code: | ||||||||||||||||||||||||||||||||
| 224 | # | ||||||||||||||||||||||||||||||||
| 225 | # pdl x; | ||||||||||||||||||||||||||||||||
| 226 | # GENERICLOOP(x.datatype) | ||||||||||||||||||||||||||||||||
| 227 | # generic *xx = x.data; | ||||||||||||||||||||||||||||||||
| 228 | # for(i=0; i<nvals; i++) | ||||||||||||||||||||||||||||||||
| 229 | # xx[i] = i/nvals; | ||||||||||||||||||||||||||||||||
| 230 | # ENDGENERICLOOP | ||||||||||||||||||||||||||||||||
| 231 | # | ||||||||||||||||||||||||||||||||
| 232 | # is converted into a giant switch statement: | ||||||||||||||||||||||||||||||||
| 233 | # | ||||||||||||||||||||||||||||||||
| 234 | # pdl x; | ||||||||||||||||||||||||||||||||
| 235 | # switch (x.datatype) { | ||||||||||||||||||||||||||||||||
| 236 | # | ||||||||||||||||||||||||||||||||
| 237 | # case PDL_L: | ||||||||||||||||||||||||||||||||
| 238 | # { | ||||||||||||||||||||||||||||||||
| 239 | # PDL_Long *xx = x.data; | ||||||||||||||||||||||||||||||||
| 240 | # for(i=0; i<nvals; i++) | ||||||||||||||||||||||||||||||||
| 241 | # xx[i] = i/nvals; | ||||||||||||||||||||||||||||||||
| 242 | # }break; | ||||||||||||||||||||||||||||||||
| 243 | # | ||||||||||||||||||||||||||||||||
| 244 | # case PDL_F: | ||||||||||||||||||||||||||||||||
| 245 | # { | ||||||||||||||||||||||||||||||||
| 246 | # PDL_Float *xx = x.data; | ||||||||||||||||||||||||||||||||
| 247 | # | ||||||||||||||||||||||||||||||||
| 248 | # .... etc. ..... | ||||||||||||||||||||||||||||||||
| 249 | # | ||||||||||||||||||||||||||||||||
| 250 | # 'generic' is globally substituted for each relevant data type. | ||||||||||||||||||||||||||||||||
| 251 | # | ||||||||||||||||||||||||||||||||
| 252 | # This is used in PDL to write generic functions (taking pdl or void | ||||||||||||||||||||||||||||||||
| 253 | # objects) which is still efficient with perl writing the actual C | ||||||||||||||||||||||||||||||||
| 254 | # code for each type. | ||||||||||||||||||||||||||||||||
| 255 | # | ||||||||||||||||||||||||||||||||
| 256 | # 1st version - Karl Glazebrook 4/Aug/1996. | ||||||||||||||||||||||||||||||||
| 257 | # | ||||||||||||||||||||||||||||||||
| 258 | # Also makes the followings substitutions: | ||||||||||||||||||||||||||||||||
| 259 | # | ||||||||||||||||||||||||||||||||
| 260 | # (i) O_NONBLOCK - open flag for non-blocking I/O (5/Aug/96) | ||||||||||||||||||||||||||||||||
| 261 | # | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | sub genpp { | ||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $gotstart = 0; @gencode = (); | ||||||||||||||||||||||||||||||
|
Subroutine
genpp: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | while (<>) { # Process files in @ARGV list - result to STDOUT | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | # Do the miscellaneous substitutions first | ||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||
| 272 | 0 | s/O_NONBLOCK/$O_NONBLOCK/go; # I/O | |||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ( m/ (\s*)? \b GENERICLOOP \s* \( ( [^\)]* ) \) ( \s*; )? /x ){ # Start of generic code | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 275 | #print $MATCH, "=$1=\n"; | ||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | die "Found GENERICLOOP while searching for ENDGENERICLOOP\n" if $gotstart; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 278 | 0 | $loopvar = $2; | |||||||||||||||||||||||||||||||
| 279 | 0 | $indent = $1; | |||||||||||||||||||||||||||||||
| 280 | 0 | print $PREMATCH; | |||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | 0 | @gencode = (); # Start saving code | |||||||||||||||||||||||||||||||
| 283 | 0 | push @gencode, $POSTMATCH; | |||||||||||||||||||||||||||||||
| 284 | 0 | $gotstart = 1; | |||||||||||||||||||||||||||||||
| 285 | 0 | next; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ( m/ \b ENDGENERICLOOP ( \s*; )? /x ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | die "Found ENDGENERICLOOP while searching for GENERICLOOP\n" unless $gotstart; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | 0 | push @gencode, $PREMATCH; | |||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||
| 294 | 0 | flushgeneric(); # Output the generic code | |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | 0 | print $POSTMATCH; # End of genric code | |||||||||||||||||||||||||||||||
| 297 | 0 | $gotstart = 0; | |||||||||||||||||||||||||||||||
| 298 | 0 | next; | |||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($gotstart) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 302 | 0 | push @gencode, $_; | |||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||
| 304 | else { | ||||||||||||||||||||||||||||||||
| 305 | 0 | print; | |||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||
| 308 | } # End while | ||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | sub flushgeneric { # Construct the generic code switch | ||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | print $indent,"switch ($loopvar) {\n\n"; | ||||||||||||||||||||||||||||||
|
Subroutine
flushgeneric: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 0 | for $case (PDL::Types::typesrtkeys()){ | |||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||
| 317 | 0 | $type = $PDL_DATATYPES{$case}; | |||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | 0 | my $ppsym = $PDL::Types::typehash{$case}->{ppsym}; | |||||||||||||||||||||||||||||||
| 320 | 0 | print $indent,"case $case:\n"; # Start of this case | |||||||||||||||||||||||||||||||
| 321 | 0 | print $indent," {"; | |||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | # Now output actual code with substutions | ||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||
| 325 | 0 | for (@gencode) { | |||||||||||||||||||||||||||||||
| 326 | 0 | $line = $_; | |||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 0 | $line =~ s/\bgeneric\b/$type/g; | |||||||||||||||||||||||||||||||
| 329 | 0 | $line =~ s/\bgeneric_ppsym\b/$ppsym/g; | |||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||
| 331 | 0 | print " ",$line; | |||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 0 | print "}break;\n\n"; # End of this case | |||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | 0 | print $indent,"default:\n"; | |||||||||||||||||||||||||||||||
| 337 | 0 | print $indent,' croak ("Not a known data type code=%d",'.$loopvar.");\n"; | |||||||||||||||||||||||||||||||
| 338 | 0 | print $indent,"}"; | |||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||
| 343 | sub genpp_cmdline { | ||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | my ($in, $out) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
genpp_cmdline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 345 | 0 | require ExtUtils::MM; | |||||||||||||||||||||||||||||||
| 346 | 0 | my $MM = bless { NAME => 'Fake' }, 'MM'; | |||||||||||||||||||||||||||||||
| 347 | 0 | my $devpm = whereami_any()."/Core/Dev.pm"; | |||||||||||||||||||||||||||||||
| 348 | 0 | sprintf($MM->oneliner(<<'EOF'), $devpm) . qq{ "$in" > "$out"}; | |||||||||||||||||||||||||||||||
| 349 | require "%s"; PDL::Core::Dev->import(); genpp(); | ||||||||||||||||||||||||||||||||
| 350 | EOF | ||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||
| 354 | # Standard PDL postamble | ||||||||||||||||||||||||||||||||
| 355 | # | ||||||||||||||||||||||||||||||||
| 356 | # This is called via .../Gen/Inline/Pdlpp.pm, in the case that the INTERNAL | ||||||||||||||||||||||||||||||||
| 357 | # flag for the compilation is off (grep "ILSM" in that file to find the reference). | ||||||||||||||||||||||||||||||||
| 358 | # If it's ON, then postamble_int gets called instead. | ||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | sub postamble { | ||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
postamble: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 363 | 0 | sprintf <<'EOF', genpp_cmdline(qw($< $@)); | |||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||
| 365 | # Rules for the generic preprocessor | ||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | .SUFFIXES: .g | ||||||||||||||||||||||||||||||||
| 368 | .g.c : | ||||||||||||||||||||||||||||||||
| 369 | %s | ||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||
| 371 | EOF | ||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | # Expects list in format: | ||||||||||||||||||||||||||||||||
| 375 | # [gtest.pd, GTest, PDL::GTest, ['../GIS/Proj', ...] ], [...] | ||||||||||||||||||||||||||||||||
| 376 | # source, prefix,module/package, optional deps | ||||||||||||||||||||||||||||||||
| 377 | # The idea is to support in future several packages in same dir - EUMM | ||||||||||||||||||||||||||||||||
| 378 | # 7.06 supports | ||||||||||||||||||||||||||||||||
| 379 | # each optional dep is a relative dir that a "make" will chdir to and | ||||||||||||||||||||||||||||||||
| 380 | # "make" first - so the *.pd file can then "use" what it makes | ||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||
| 382 | # This is the function internal for PDL. | ||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||
| 384 | sub pdlpp_postamble_int { | ||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | join '',map { my($src,$pref,$mod, $deps) = @$_; | ||||||||||||||||||||||||||||||
|
Subroutine
pdlpp_postamble_int: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | die "If give dependencies, must be array-ref" if $deps and !ref $deps; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$deps and not ref $deps
MC/DC0%0/2
$deps and not ref $deps
$deps
not ref $deps
Truth table0%0/3
A and not(B)
A= $depsB= not ref $deps
| |||||||||||||||||||||||||||||||||
| 387 | 0 | my $w = whereami_any(); | |||||||||||||||||||||||||||||||
| 388 | 0 | $w =~ s%/((PDL)|(Basic))$%%; # remove the trailing subdir | |||||||||||||||||||||||||||||||
| 389 | 0 | my $top = File::Spec->abs2rel($w); | |||||||||||||||||||||||||||||||
| 390 | 0 | my $basic = File::Spec->catdir($top, 'Basic'); | |||||||||||||||||||||||||||||||
| 391 | 0 | my $core = File::Spec->catdir($basic, 'Core'); | |||||||||||||||||||||||||||||||
| 392 | 0 | my $gen = File::Spec->catdir($basic, 'Gen'); | |||||||||||||||||||||||||||||||
| 393 | 0 | my $depbuild = ''; | |||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | for my $dep (@{$deps || []}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 395 | 0 | my $target = ''; | |||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | if ($dep eq 'core') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 397 | 0 | $dep = $top; | |||||||||||||||||||||||||||||||
| 398 | 0 | $target = ' core'; | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | 0 | require ExtUtils::MM; | |||||||||||||||||||||||||||||||
| 401 | 0 | $dep =~ s#([\(\)])#\\$1#g; # in case of unbalanced ( | |||||||||||||||||||||||||||||||
| 402 | 0 | $depbuild .= MM->oneliner("exit(!(chdir q($dep) && !system(q(\$(MAKE)$target))))"); | |||||||||||||||||||||||||||||||
| 403 | 0 | $depbuild .= "\n\t"; | |||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||
| 405 | qq| | ||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||
| 407 | $pref.pm: $src $core/Types.pm | ||||||||||||||||||||||||||||||||
| 408 | $depbuild\$(PERLRUNINST) \"-MPDL::PP qw[$mod $mod $pref]\" $src | ||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||
| 410 | $pref.xs: $pref.pm | ||||||||||||||||||||||||||||||||
| 411 | \$(TOUCH) \$@ | ||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||
| 413 | $pref.c: $pref.xs | ||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||
| 415 | $pref\$(OBJ_EXT): $pref.c | ||||||||||||||||||||||||||||||||
| 416 | | | ||||||||||||||||||||||||||||||||
| 417 | 0 | } (@_) | |||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | # This is the function to be used outside the PDL tree. | ||||||||||||||||||||||||||||||||
| 422 | sub pdlpp_postamble { | ||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | join '',map { my($src,$pref,$mod) = @$_; | ||||||||||||||||||||||||||||||
|
Subroutine
pdlpp_postamble: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 424 | 0 | my $w = whereami_any(); | |||||||||||||||||||||||||||||||
| 425 | 0 | $w =~ s%/((PDL)|(Basic))$%%; # remove the trailing subdir | |||||||||||||||||||||||||||||||
| 426 | 0 | qq| | |||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||
| 428 | $pref.pm: $src | ||||||||||||||||||||||||||||||||
| 429 | \$(PERL) "-I$w" \"-MPDL::PP qw[$mod $mod $pref]\" $src | ||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||
| 431 | $pref.xs: $pref.pm | ||||||||||||||||||||||||||||||||
| 432 | \$(TOUCH) \$@ | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | $pref.c: $pref.xs | ||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||
| 436 | $pref\$(OBJ_EXT): $pref.c | ||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | install :: | ||||||||||||||||||||||||||||||||
| 439 | \@echo "Updating PDL documentation database..."; | ||||||||||||||||||||||||||||||||
| 440 | \$(ABSPERLRUN) -e ${quotation_mark}exit if \$\$ENV{DESTDIR}; use PDL::Doc; eval { PDL::Doc::add_module(q{$mod}); }; ${quotation_mark}; | ||||||||||||||||||||||||||||||||
| 441 | | | ||||||||||||||||||||||||||||||||
| 442 | } (@_) | ||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | sub pdlpp_stdargs_int { | ||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | my($rec) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
pdlpp_stdargs_int: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 447 | 0 | my($src,$pref,$mod) = @$rec; | |||||||||||||||||||||||||||||||
| 448 | 0 | my $w = whereami(); | |||||||||||||||||||||||||||||||
| 449 | my $malloclib = exists $PDL::Config{MALLOCDBG}->{libs} ? | ||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | $PDL::Config{MALLOCDBG}->{libs} : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 451 | my $mallocinc = exists $PDL::Config{MALLOCDBG}->{include} ? | ||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | $PDL::Config{MALLOCDBG}->{include} : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | my $libsarg = $libs || $malloclib ? "$libs $malloclib " : ''; # for Win32 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$libs or $malloclib
MC/DC0%0/2
$libs or $malloclib
$libs
$malloclib
Truth table0%0/3
A or B
A= $libsB= $malloclib
| |||||||||||||||||||||||||||||||||
| 454 | return ( | ||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | %::PDL_OPTIONS, | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 456 | 'NAME' => $mod, | ||||||||||||||||||||||||||||||||
| 457 | 'VERSION_FROM' => "$w/Basic/Core/Version.pm", | ||||||||||||||||||||||||||||||||
| 458 | 'TYPEMAPS' => [&PDL_TYPEMAP()], | ||||||||||||||||||||||||||||||||
| 459 | 'OBJECT' => "$pref\$(OBJ_EXT)", | ||||||||||||||||||||||||||||||||
| 460 | PM => {"$pref.pm" => "\$(INST_LIBDIR)/$pref.pm"}, | ||||||||||||||||||||||||||||||||
| 461 | MAN3PODS => {"$pref.pm" => "\$(INST_MAN3DIR)/$mod.\$(MAN3EXT)"}, | ||||||||||||||||||||||||||||||||
| 462 | 'INC' => &PDL_INCLUDE()." $inc $mallocinc", | ||||||||||||||||||||||||||||||||
| 463 | 'LIBS' => $libsarg ? [$libsarg] : [], | ||||||||||||||||||||||||||||||||
| 464 | 'clean' => {'FILES' => "$pref.xs $pref.pm $pref\$(OBJ_EXT) $pref.c"}, | ||||||||||||||||||||||||||||||||
| 465 | (eval ($ExtUtils::MakeMaker::VERSION) >= 6.57_02 ? ('NO_MYMETA' => 1) : ()), | ||||||||||||||||||||||||||||||||
| 466 | ); | ||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | sub pdlpp_stdargs { | ||||||||||||||||||||||||||||||||
| 470 | 2 | ▶ | my($rec) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
pdlpp_stdargs: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 471 | 2 | my($src,$pref,$mod) = @$rec; | |||||||||||||||||||||||||||||||
| 472 | return ( | ||||||||||||||||||||||||||||||||
| 473 | 2 | ▶ | %::PDL_OPTIONS, | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 474 | 'NAME' => $mod, | ||||||||||||||||||||||||||||||||
| 475 | 'TYPEMAPS' => [&PDL_INST_TYPEMAP()], | ||||||||||||||||||||||||||||||||
| 476 | 'OBJECT' => "$pref\$(OBJ_EXT)", | ||||||||||||||||||||||||||||||||
| 477 | PM => {"$pref.pm" => "\$(INST_LIBDIR)/$pref.pm"}, | ||||||||||||||||||||||||||||||||
| 478 | MAN3PODS => {"$pref.pm" => "\$(INST_MAN3DIR)/$mod.\$(MAN3EXT)"}, | ||||||||||||||||||||||||||||||||
| 479 | 'INC' => &PDL_INST_INCLUDE()." $inc", | ||||||||||||||||||||||||||||||||
| 480 | 'LIBS' => $libs ? ["$libs "] : [], | ||||||||||||||||||||||||||||||||
| 481 | 'clean' => {'FILES' => "$pref.xs $pref.pm $pref\$(OBJ_EXT) $pref.c"}, | ||||||||||||||||||||||||||||||||
| 482 | 'dist' => {'PREOP' => '$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" -MPDL::Core::Dev -e pdlpp_mkgen $(DISTVNAME)' }, | ||||||||||||||||||||||||||||||||
| 483 | (eval ($ExtUtils::MakeMaker::VERSION) >= 6.57_02 ? ('NO_MYMETA' => 1) : ()), | ||||||||||||||||||||||||||||||||
| 484 | ); | ||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||
| 487 | # pdlpp_mkgen($dir) | ||||||||||||||||||||||||||||||||
| 488 | # - scans $dir/MANIFEST for all *.pd files and creates corresponding *.pm files | ||||||||||||||||||||||||||||||||
| 489 | # in $dir/GENERATED/ subdir; needed for proper doc rendering at metacpan.org | ||||||||||||||||||||||||||||||||
| 490 | # - it is used in Makefile.PL like: | ||||||||||||||||||||||||||||||||
| 491 | # dist => { PREOP=>'$(PERL) -MPDL::Core::Dev -e pdlpp_mkgen $(DISTVNAME)' } | ||||||||||||||||||||||||||||||||
| 492 | # so all the magic *.pm generation happens during "make dist" | ||||||||||||||||||||||||||||||||
| 493 | # - it is intended to be called as a one-liner: | ||||||||||||||||||||||||||||||||
| 494 | # perl -MPDL::Core::Dev -e pdlpp_mkgen DirName | ||||||||||||||||||||||||||||||||
| 495 | # | ||||||||||||||||||||||||||||||||
| 496 | sub pdlpp_mkgen { | ||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | my $dir = @_ > 0 ? $_[0] : $ARGV[0]; | ||||||||||||||||||||||||||||||
|
Subroutine
pdlpp_mkgen: not called CC=14 SCAR=53.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | die "pdlpp_mkgen: unspecified directory" unless defined $dir && -d $dir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $dir and -d $dir
MC/DC0%0/2
defined $dir and -d $dir
defined $dir
-d $dir
Truth table0%0/3
A and B
A= defined $dirB= -d $dir
| |||||||||||||||||||||||||||||||||
| 499 | 0 | my $file = "$dir/MANIFEST"; | |||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | die "pdlpp_mkgen: non-existing '$dir/MANIFEST'" unless -f $file; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||
| 502 | 0 | my @pairs = (); | |||||||||||||||||||||||||||||||
| 503 | 0 | my $manifest = ExtUtils::Manifest::maniread($file); | |||||||||||||||||||||||||||||||
| 504 | 0 | for (keys %$manifest) { | |||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | next if $_ !~ m/\.pd$/; # skip non-pd files | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | next if $_ =~ m/^(t|xt)\//; # skip *.pd files in test subdirs | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | next unless -f $_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 508 | 0 | my $content = do { local $/; open my $in, '<', $_; <$in> }; | |||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($content =~ /=head1\s+NAME\s+(\S+)\s+/sg) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 510 | 0 | push @pairs, [$_, $1]; | |||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||
| 512 | else { | ||||||||||||||||||||||||||||||||
| 513 | 0 | warn "pdlpp_mkgen: unknown module name for '$_' (use proper '=head1 NAME' section)\n"; | |||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | 0 | my %added = (); | |||||||||||||||||||||||||||||||
| 518 | 0 | for (@pairs) { | |||||||||||||||||||||||||||||||
| 519 | 0 | my ($pd, $mod) = @$_; | |||||||||||||||||||||||||||||||
| 520 | 0 | (my $prefix = $mod) =~ s|::|/|g; | |||||||||||||||||||||||||||||||
| 521 | 0 | my $manifestpm = "GENERATED/$prefix.pm"; | |||||||||||||||||||||||||||||||
| 522 | 0 | $prefix = "$dir/GENERATED/$prefix"; | |||||||||||||||||||||||||||||||
| 523 | 0 | File::Path::mkpath(dirname($prefix)); | |||||||||||||||||||||||||||||||
| 524 | #there is no way to use PDL::PP from perl code, thus calling via system() | ||||||||||||||||||||||||||||||||
| 525 | 0 | my @in = map { "-I$_" } @INC, 'inc'; | |||||||||||||||||||||||||||||||
| 526 | 0 | my $rv = system($^X, @in, "-MPDL::PP qw[$mod $mod $prefix]", $pd); | |||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if ($rv == 0 && -f "$prefix.pm") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rv == 0 and -f "$prefix.pm"
MC/DC0%0/2
$rv == 0 and -f "$prefix.pm"
$rv == 0
-f "$prefix.pm"
Truth table0%0/3
A and B
A= $rv == 0B= -f "$prefix.pm"
| |||||||||||||||||||||||||||||||||
| 528 | 0 | $added{$manifestpm} = "mod=$mod pd=$pd (added by pdlpp_mkgen)"; | |||||||||||||||||||||||||||||||
| 529 | 0 | unlink "$prefix.xs"; #we need only .pm | |||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||
| 531 | else { | ||||||||||||||||||||||||||||||||
| 532 | 0 | warn "pdlpp_mkgen: cannot convert '$pd'\n"; | |||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if (scalar(keys %added) > 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 537 | #maniadd works only with this global variable | ||||||||||||||||||||||||||||||||
| 538 | 0 | local $ExtUtils::Manifest::MANIFEST = $file; | |||||||||||||||||||||||||||||||
| 539 | 0 | ExtUtils::Manifest::maniadd(\%added); | |||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||
| 543 | sub unsupported { | ||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | my ($package,$os) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
unsupported: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 545 | 0 | "No support for $package on $os platform yet. Will skip build process"; | |||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | sub write_dummy_make { | ||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | my ($msg) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
write_dummy_make: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 550 | 0 | $msg =~ s#\n*\z#\n#; | |||||||||||||||||||||||||||||||
| 551 | 0 | $msg =~ s#^\s*#\n#gm; | |||||||||||||||||||||||||||||||
| 552 | 0 | print $msg; | |||||||||||||||||||||||||||||||
| 553 | 0 | require ExtUtils::MakeMaker; | |||||||||||||||||||||||||||||||
| 554 | 0 | ExtUtils::MakeMaker::WriteEmptyMakefile(NAME => 'Dummy', DIR => []); | |||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||
| 557 | sub getcyglib { | ||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | my ($lib) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
getcyglib: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 559 | 0 | my $lp = `gcc -print-file-name=lib$lib.a`; | |||||||||||||||||||||||||||||||
| 560 | 0 | $lp =~ s|/[^/]+$||; | |||||||||||||||||||||||||||||||
| 561 | 0 | $lp =~ s|^([a-z,A-Z]):|//$1|g; | |||||||||||||||||||||||||||||||
| 562 | 0 | return "-L$lp -l$lib"; | |||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||
| 565 | =head2 trylink | ||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||
| 567 | =for ref | ||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||
| 569 | a perl configure clone | ||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||
| 571 | =for example | ||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||
| 573 | if (trylink 'libGL', '', 'char glBegin(); glBegin();', '-lGL') { | ||||||||||||||||||||||||||||||||
| 574 | $libs = '-lGLU -lGL'; | ||||||||||||||||||||||||||||||||
| 575 | $have_GL = 1; | ||||||||||||||||||||||||||||||||
| 576 | } else { | ||||||||||||||||||||||||||||||||
| 577 | $have_GL = 0; | ||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||
| 579 | $maybe = | ||||||||||||||||||||||||||||||||
| 580 | trylink 'libwhatever', $inc, $body, $libs, $cflags, | ||||||||||||||||||||||||||||||||
| 581 | {MakeMaker=>1, Hide=>0, Clean=>1}; | ||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||
| 583 | Try to link some C-code making up the body of a function | ||||||||||||||||||||||||||||||||
| 584 | with a given set of library specifiers | ||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||
| 586 | return 1 if successful, 0 otherwise | ||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||
| 588 | =for usage | ||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||
| 590 | trylink $infomsg, $include, $progbody, $libs [,$cflags,{OPTIONS}]; | ||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||
| 592 | Takes 4 + 2 optional arguments. | ||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||
| 594 | =over 5 | ||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | =item * | ||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||
| 598 | an informational message to print (can be empty) | ||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||
| 600 | =item * | ||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||
| 602 | any commands to be included at the top of the generated C program | ||||||||||||||||||||||||||||||||
| 603 | (typically something like C<#include "mylib.h">) | ||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||
| 605 | =item * | ||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||
| 607 | the body of the program (in function main) | ||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||
| 609 | =item * | ||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||
| 611 | library flags to use for linking. Preprocessing | ||||||||||||||||||||||||||||||||
| 612 | by MakeMaker should be performed as needed (see options and example). | ||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||
| 614 | =item * | ||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||
| 616 | compilation flags. For example, something like C<-I/usr/local/lib>. | ||||||||||||||||||||||||||||||||
| 617 | Optional argument. Empty if omitted. | ||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||
| 619 | =item * | ||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||
| 621 | OPTIONS | ||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||
| 623 | =over | ||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||
| 625 | =item MakeMaker | ||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||
| 627 | Preprocess library strings in the way MakeMaker does things. This is | ||||||||||||||||||||||||||||||||
| 628 | advisable to ensure that your code will actually work after the link | ||||||||||||||||||||||||||||||||
| 629 | specs have been processed by MakeMaker. | ||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||
| 631 | =item Hide | ||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||
| 633 | Controls if linking output etc is hidden from the user or not. | ||||||||||||||||||||||||||||||||
| 634 | On by default except within the build of the PDL distribution | ||||||||||||||||||||||||||||||||
| 635 | where the config value set in F<perldl.conf> prevails. | ||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||
| 637 | =item Clean | ||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||
| 639 | Remove temporary files. Enabled by default. You might want to switch | ||||||||||||||||||||||||||||||||
| 640 | it off during debugging. | ||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||
| 642 | =back | ||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||
| 644 | =back | ||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||
| 646 | =cut | ||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||
| 649 | sub trylink { | ||||||||||||||||||||||||||||||||
| 650 | 1 | ▶ | my $opt = ref $_[$#_] eq 'HASH' ? pop : {}; | ||||||||||||||||||||||||||||||
|
Subroutine
trylink: called CC=25 SCAR=41.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 651 | 1 | my ($txt,$inc,$body,$libs,$cflags) = @_; | |||||||||||||||||||||||||||||||
| 652 | 1 | ▶ | $cflags ||= ''; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$cflags ||= ""
MC/DC0%0/1
$cflags ||= ""
$cflags
Truth table50%1/2
A
A= $cflags
| |||||||||||||||||||||||||||||||||
| 653 | 1 | require File::Spec; | |||||||||||||||||||||||||||||||
| 654 | 1 | require File::Temp; | |||||||||||||||||||||||||||||||
| 655 | 1 | ▶ | my $cdir = sub { return File::Spec->catdir(@_)}; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 656 | 1 | ▶ | my $cfile = sub { return File::Spec->catfile(@_)}; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 657 | 10 | ▶ | use Config; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||
| 659 | # check if MakeMaker should be used to preprocess the libs | ||||||||||||||||||||||||||||||||
| 660 | 1 | for my $key(keys %$opt) {$opt->{lc $key} = $opt->{$key}} | |||||||||||||||||||||||||||||||
| 661 | 1 | ▶ | my $mmprocess = exists $opt->{makemaker} && $opt->{makemaker}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $opt->{'makemaker'} && $opt->{'makemaker'}
MC/DC0%0/2
exists $opt->{'makemaker'} && $opt->{'makemaker'}
exists $opt->{'makemaker'}
$opt->{'makemaker'}
Truth table33%1/3
A && B
A= exists $opt->{'makemaker'}B= $opt->{'makemaker'}
| |||||||||||||||||||||||||||||||||
| 662 | my $hide = exists $opt->{hide} ? $opt->{hide} : | ||||||||||||||||||||||||||||||||
| 663 | 1 | ▶ | exists $PDL::Config{HIDE_TRYLINK} ? $PDL::Config{HIDE_TRYLINK} : 1; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 664 | 1 | ▶ | my $clean = exists $opt->{clean} ? $opt->{clean} : 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 665 | 1 | ▶ | if ($mmprocess) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 666 | 0 | require ExtUtils::MakeMaker; | |||||||||||||||||||||||||||||||
| 667 | 0 | require ExtUtils::Liblist; | |||||||||||||||||||||||||||||||
| 668 | 0 | my $self = new ExtUtils::MakeMaker {DIR => [],'NAME' => 'NONE'}; | |||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||
| 670 | 0 | my @libs = $self->ext($libs, 0); | |||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | print "processed LIBS: $libs[0]\n" unless $hide; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 673 | 0 | $libs = $libs[0]; # replace by preprocessed libs | |||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||
| 676 | 1 | ▶ | print " Trying $txt...\n " unless $txt =~ /^\s*$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||
| 678 | 1 | ▶ | my $HIDE = !$hide ? '' : '>/dev/null 2>&1'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 679 | 1 | ▶ | if($^O =~ /mswin32/i) {$HIDE = '>NUL 2>&1'} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||
| 681 | 1 | my $tempd; | |||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||
| 683 | 1 | ▶ | $tempd = File::Temp::tempdir(CLEANUP=>1) || die "trylink: could not make TEMPDIR"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
File::Temp::tempdir('CLEANUP', 1) || die('trylink: could not make TEMPDIR')
MC/DC0%0/1
File::Temp::tempdir('CLEANUP', 1) || die('trylink: could not make TEMPDIR')
File::Temp::tempdir('CLEANUP', 1)
Truth table50%1/2
A
A= File::Temp::tempdir('CLEANUP', 1)
| |||||||||||||||||||||||||||||||||
| 684 | ### if($^O =~ /MSWin32/i) {$tempd = File::Spec->tmpdir()} | ||||||||||||||||||||||||||||||||
| 685 | ### else { | ||||||||||||||||||||||||||||||||
| 686 | ### $tempd = $PDL::Config{TEMPDIR} || | ||||||||||||||||||||||||||||||||
| 687 | ### } | ||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||
| 689 | 1 | my ($tc,$te) = map {&$cfile($tempd,"testfile$_")} ('.c',''); | |||||||||||||||||||||||||||||||
| 690 | 1 | ▶ | open FILE,">$tc" or die "trylink: couldn't open testfile `$tc' for writing, $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 691 | 1 | my $prog = <<"EOF"; | |||||||||||||||||||||||||||||||
| 692 | $inc | ||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||
| 694 | int main(void) { | ||||||||||||||||||||||||||||||||
| 695 | $body | ||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||
| 697 | return 0; | ||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||
| 701 | EOF | ||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||
| 703 | 1 | print FILE $prog; | |||||||||||||||||||||||||||||||
| 704 | 1 | close FILE; | |||||||||||||||||||||||||||||||
| 705 | # print "test prog:\n$prog\n"; | ||||||||||||||||||||||||||||||||
| 706 | # make sure we can overwrite the executable. shouldn't need this, | ||||||||||||||||||||||||||||||||
| 707 | # but if it fails and HIDE is on, the user will never see the error. | ||||||||||||||||||||||||||||||||
| 708 | 1 | ▶ | open(T, ">$te") or die( "unable to write to test executable `$te'"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 709 | 1 | close T; | |||||||||||||||||||||||||||||||
| 710 | 1 | ▶ | print "$Config{cc} $cflags -o $te $tc $libs $HIDE ...\n" unless $hide; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 711 | 1 | ▶ | my $success = (system("$Config{cc} $cflags -o $te $tc $libs $HIDE") == 0) && | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
system(qq[$Config{"cc"} $cflags -o $te $tc $libs $HIDE]) == 0 and -e $te
MC/DC0%0/2
system(qq[$Config{"cc"} $cflags -o $te $tc $libs $HIDE]) == 0 and -e $te
system(qq[$Config{"cc"} $cflags -o $te $tc $libs $HIDE]) == 0
-e $te
Truth table33%1/3
A and B
A= system(qq[$Config{"cc"} $cflags -o $te $tc $libs $HIDE]) == 0B= -e $te
| |||||||||||||||||||||||||||||||||
| 712 | -e $te ? 1 : 0; | ||||||||||||||||||||||||||||||||
| 713 | 1 | ▶ | unlink "$te","$tc" if $clean; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 714 | 1 | ▶ | print $success ? "\t\tYES\n" : "\t\tNO\n" unless $txt =~ /^\s*$/; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 715 | 1 | ▶ | print $success ? "\t\tSUCCESS\n" : "\t\tFAILED\n" | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$txt =~ /^\s*$/ and not $hide
MC/DC0%0/2
$txt =~ /^\s*$/ and not $hide
$txt =~ /^\s*$/
not $hide
Truth table33%1/3
A and not(B)
A= $txt =~ /^\s*$/B= not $hide
| |||||||||||||||||||||||||||||||||
| 716 | if $txt =~ /^\s*$/ && !$hide; | ||||||||||||||||||||||||||||||||
| 717 | 1 | return $success; | |||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||
| 720 | =head2 datatypes_switch | ||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||
| 722 | =for ref | ||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||
| 724 | prints on C<STDOUT> XS text for F<Core.xs>. | ||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||
| 726 | =cut | ||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||
| 728 | sub datatypes_switch { | ||||||||||||||||||||||||||||||||
| 729 | 1 | ▶ | my $ntypes = $#PDL::Types::names; | ||||||||||||||||||||||||||||||
|
Subroutine
datatypes_switch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 730 | 1 | my @m; | |||||||||||||||||||||||||||||||
| 731 | 1 | foreach my $i ( 0 .. $ntypes ) { | |||||||||||||||||||||||||||||||
| 732 | 8 | my $type = PDL::Type->new( $i ); | |||||||||||||||||||||||||||||||
| 733 | 8 | my $typesym = $type->symbol; | |||||||||||||||||||||||||||||||
| 734 | 8 | my $typeppsym = $type->ppsym; | |||||||||||||||||||||||||||||||
| 735 | 8 | my $cname = $type->ctype; | |||||||||||||||||||||||||||||||
| 736 | 8 | $cname =~ s/^PDL_//; | |||||||||||||||||||||||||||||||
| 737 | 8 | push @m, "\tcase $typesym: retval.type = $typesym; retval.value.$typeppsym = PDL.bvals.$cname; break;"; | |||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||
| 739 | 1 | print map "$_\n", @m; | |||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||
| 742 | =head2 generate_core_flags | ||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||
| 744 | =for ref | ||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||
| 746 | prints on C<STDOUT> XS text with core flags, for F<Core.xs>. | ||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||
| 748 | =cut | ||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||
| 750 | 10 | my %flags = ( | |||||||||||||||||||||||||||||||
| 751 | hdrcpy => { set => 1 }, | ||||||||||||||||||||||||||||||||
| 752 | fflows => { FLAG => "DATAFLOW_F" }, | ||||||||||||||||||||||||||||||||
| 753 | bflows => { FLAG => "DATAFLOW_B" }, | ||||||||||||||||||||||||||||||||
| 754 | is_inplace => { FLAG => "INPLACE", postset => 1 }, | ||||||||||||||||||||||||||||||||
| 755 | donttouch => { FLAG => "DONTTOUCHDATA" }, | ||||||||||||||||||||||||||||||||
| 756 | allocated => { }, | ||||||||||||||||||||||||||||||||
| 757 | vaffine => { FLAG => "OPT_VAFFTRANSOK" }, | ||||||||||||||||||||||||||||||||
| 758 | anychgd => { FLAG => "ANYCHANGED" }, | ||||||||||||||||||||||||||||||||
| 759 | dimschgd => { FLAG => "PARENTDIMSCHANGED" }, | ||||||||||||||||||||||||||||||||
| 760 | tracedebug => { FLAG => "TRACEDEBUG", set => 1}, | ||||||||||||||||||||||||||||||||
| 761 | ); | ||||||||||||||||||||||||||||||||
| 762 | #if ( $bvalflag ) { $flags{baddata} = { set => 1, FLAG => "BADVAL" }; } | ||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||
| 764 | sub generate_core_flags { | ||||||||||||||||||||||||||||||||
| 765 | # access (read, if set is true then write as well; if postset true then | ||||||||||||||||||||||||||||||||
| 766 | # read first and write new value after that) | ||||||||||||||||||||||||||||||||
| 767 | # to piddle's state | ||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | foreach my $name ( sort keys %flags ) { | ||||||||||||||||||||||||||||||
|
Subroutine
generate_core_flags: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | my $flag = "PDL_" . ($flags{$name}{FLAG} || uc($name)); | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$flags{$name}{'FLAG'} || uc $name
MC/DC0%0/2
$flags{$name}{'FLAG'} || uc $name
$flags{$name}{'FLAG'}
uc $name
Truth table0%0/3
A || B
A= $flags{$name}{'FLAG'}B= uc $name
| |||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | if ( $flags{$name}{set} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 771 | 0 | print <<"!WITH!SUBS!"; | |||||||||||||||||||||||||||||||
| 772 | int | ||||||||||||||||||||||||||||||||
| 773 | $name(x,mode=0) | ||||||||||||||||||||||||||||||||
| 774 | pdl *x | ||||||||||||||||||||||||||||||||
| 775 | int mode | ||||||||||||||||||||||||||||||||
| 776 | CODE: | ||||||||||||||||||||||||||||||||
| 777 | if (items>1) | ||||||||||||||||||||||||||||||||
| 778 | { setflag(x->state,$flag,mode); } | ||||||||||||||||||||||||||||||||
| 779 | RETVAL = ((x->state & $flag) > 0); | ||||||||||||||||||||||||||||||||
| 780 | OUTPUT: | ||||||||||||||||||||||||||||||||
| 781 | RETVAL | ||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||
| 783 | !WITH!SUBS! | ||||||||||||||||||||||||||||||||
| 784 | } elsif ($flags{$name}{postset}) { | ||||||||||||||||||||||||||||||||
| 785 | 0 | print <<"!WITH!SUBS!"; | |||||||||||||||||||||||||||||||
| 786 | int | ||||||||||||||||||||||||||||||||
| 787 | $name(x,mode=0) | ||||||||||||||||||||||||||||||||
| 788 | pdl *x | ||||||||||||||||||||||||||||||||
| 789 | int mode | ||||||||||||||||||||||||||||||||
| 790 | CODE: | ||||||||||||||||||||||||||||||||
| 791 | RETVAL = ((x->state & $flag) > 0); | ||||||||||||||||||||||||||||||||
| 792 | if (items>1) | ||||||||||||||||||||||||||||||||
| 793 | { setflag(x->state,$flag,mode); } | ||||||||||||||||||||||||||||||||
| 794 | OUTPUT: | ||||||||||||||||||||||||||||||||
| 795 | RETVAL | ||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||
| 797 | !WITH!SUBS! | ||||||||||||||||||||||||||||||||
| 798 | } else { | ||||||||||||||||||||||||||||||||
| 799 | 0 | print <<"!WITH!SUBS!"; | |||||||||||||||||||||||||||||||
| 800 | int | ||||||||||||||||||||||||||||||||
| 801 | $name(self) | ||||||||||||||||||||||||||||||||
| 802 | pdl *self | ||||||||||||||||||||||||||||||||
| 803 | CODE: | ||||||||||||||||||||||||||||||||
| 804 | RETVAL = ((self->state & $flag) > 0); | ||||||||||||||||||||||||||||||||
| 805 | OUTPUT: | ||||||||||||||||||||||||||||||||
| 806 | RETVAL | ||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||
| 808 | !WITH!SUBS! | ||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||
| 810 | } # foreach: keys %flags | ||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||
| 813 | =head2 generate_badval_init | ||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||
| 815 | =for ref | ||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||
| 817 | prints on C<STDOUT> XS text with badval initialisation, for F<Core.xs>. | ||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||
| 819 | =cut | ||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||
| 821 | sub generate_badval_init { | ||||||||||||||||||||||||||||||||
| 822 | 1 | ▶ | for my $type (PDL::Types::types()) { | ||||||||||||||||||||||||||||||
|
Subroutine
generate_badval_init: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 823 | 8 | my $typename = $type->ctype; | |||||||||||||||||||||||||||||||
| 824 | 8 | $typename =~ s/^PDL_//; | |||||||||||||||||||||||||||||||
| 825 | 8 | my $bval = $type->defbval; | |||||||||||||||||||||||||||||||
| 826 | 8 | ▶ | if ($PDL::Config{BADVAL_USENAN} && $type->usenan) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$PDL::Config{"BADVAL_USENAN"} and $type->usenan
MC/DC0%0/2
$PDL::Config{"BADVAL_USENAN"} and $type->usenan
$PDL::Config{"BADVAL_USENAN"}
$type->usenan
Truth table33%1/3
A and B
A= $PDL::Config{"BADVAL_USENAN"}B= $type->usenan
| |||||||||||||||||||||||||||||||||
| 827 | # note: no defaults if usenan | ||||||||||||||||||||||||||||||||
| 828 | 0 | print "\tPDL.bvals.$typename = PDL.NaN_$type;\n"; #Core NaN value | |||||||||||||||||||||||||||||||
| 829 | } else { | ||||||||||||||||||||||||||||||||
| 830 | 8 | print "\tPDL.bvals.$typename = PDL.bvals.default_$typename = $bval;\n"; | |||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||
| 833 | # PDL.bvals.Byte = PDL.bvals.default_Byte = UCHAR_MAX; | ||||||||||||||||||||||||||||||||
| 834 | # PDL.bvals.Short = PDL.bvals.default_Short = SHRT_MIN; | ||||||||||||||||||||||||||||||||
| 835 | # PDL.bvals.Ushort = PDL.bvals.default_Ushort = USHRT_MAX; | ||||||||||||||||||||||||||||||||
| 836 | # PDL.bvals.Long = PDL.bvals.default_Long = INT_MIN; | ||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||
| 840 | 10 | 1; | |||||||||||||||||||||||||||||||