line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Inline::Pdlpp; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
290950
|
use strict; |
|
2
|
|
|
|
|
27
|
|
|
2
|
|
|
|
|
193
|
|
4
|
2
|
|
|
2
|
|
37
|
use warnings; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
223
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
17
|
use Config; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
253
|
|
7
|
2
|
|
|
2
|
|
1923
|
use Data::Dumper; |
|
2
|
|
|
|
|
16133
|
|
|
2
|
|
|
|
|
289
|
|
8
|
2
|
|
|
2
|
|
23
|
use Carp; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
225
|
|
9
|
2
|
|
|
2
|
|
23
|
use Cwd qw(cwd abs_path); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
124
|
|
10
|
2
|
|
|
2
|
|
1220
|
use PDL::Core::Dev; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
395
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$Inline::Pdlpp::VERSION = '0.4'; |
13
|
2
|
|
|
2
|
|
16
|
use base qw(Inline::C); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1383
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#============================================================================== |
16
|
|
|
|
|
|
|
# Register this module as an Inline language support module |
17
|
|
|
|
|
|
|
#============================================================================== |
18
|
|
|
|
|
|
|
sub register { |
19
|
|
|
|
|
|
|
return { |
20
|
|
|
|
|
|
|
language => 'Pdlpp', |
21
|
|
|
|
|
|
|
aliases => ['pdlpp','PDLPP'], |
22
|
|
|
|
|
|
|
type => 'compiled', |
23
|
|
|
|
|
|
|
suffix => $Config{dlext}, |
24
|
0
|
|
|
0
|
0
|
0
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# handle BLESS, INTERNAL, NOISY - pass everything else up to Inline::C |
28
|
|
|
|
|
|
|
sub validate { |
29
|
2
|
|
|
2
|
0
|
107
|
my $o = shift; |
30
|
2
|
|
50
|
|
|
50
|
$o->{ILSM} ||= {}; |
31
|
2
|
|
50
|
|
|
13
|
$o->{ILSM}{XS} ||= {}; |
32
|
|
|
|
|
|
|
# Shouldn't use internal linking for Inline stuff, normally |
33
|
2
|
50
|
|
|
|
8
|
$o->{ILSM}{INTERNAL} = 0 unless defined $o->{ILSM}{INTERNAL}; |
34
|
2
|
|
50
|
|
|
10
|
$o->{ILSM}{MAKEFILE} ||= {}; |
35
|
2
|
50
|
|
|
|
16
|
if (not $o->UNTAINT) { |
36
|
2
|
|
|
|
|
14
|
my $w = abs_path(PDL::Core::Dev::whereami_any()); |
37
|
2
|
|
|
|
|
13
|
$o->{ILSM}{MAKEFILE}{INC} = qq{"-I$w/Core"}; |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
50
|
|
|
15
|
$o->{ILSM}{AUTO_INCLUDE} ||= ' '; # not '' as Inline::C does ||= |
40
|
2
|
|
|
|
|
3
|
my @pass_along; |
41
|
2
|
|
|
|
|
7
|
while (@_) { |
42
|
0
|
|
|
|
|
0
|
my ($key, $value) = (shift, shift); |
43
|
0
|
0
|
0
|
|
|
0
|
if ($key eq 'INTERNAL' or |
44
|
|
|
|
|
|
|
$key eq 'BLESS' |
45
|
|
|
|
|
|
|
) { |
46
|
0
|
|
|
|
|
0
|
$o->{ILSM}{$key} = $value; |
47
|
0
|
|
|
|
|
0
|
next; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
0
|
|
|
|
0
|
if ($key eq 'NOISY') { |
50
|
0
|
|
|
|
|
0
|
$o->{CONFIG}{BUILD_NOISY} = $value; |
51
|
0
|
|
|
|
|
0
|
next; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
0
|
push @pass_along, $key, $value; |
54
|
|
|
|
|
|
|
} |
55
|
2
|
|
|
|
|
23
|
$o->SUPER::validate(@pass_along); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
0
|
0
|
sub add_list { goto &Inline::C::add_list } |
59
|
0
|
|
|
0
|
0
|
0
|
sub add_string { goto &Inline::C::add_string } |
60
|
0
|
|
|
0
|
0
|
0
|
sub add_text { goto &Inline::C::add_text } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#============================================================================== |
63
|
|
|
|
|
|
|
# Parse and compile C code |
64
|
|
|
|
|
|
|
#============================================================================== |
65
|
|
|
|
|
|
|
sub build { |
66
|
2
|
|
|
2
|
0
|
3304
|
my $o = shift; |
67
|
|
|
|
|
|
|
# $o->parse; # no parsing in pdlpp |
68
|
2
|
|
|
|
|
7
|
$o->get_maps; # get the typemaps |
69
|
2
|
|
|
|
|
8
|
$o->write_PD; |
70
|
|
|
|
|
|
|
# $o->write_Inline_headers; # shouldn't need this one either |
71
|
2
|
|
|
|
|
12
|
$o->write_Makefile_PL; |
72
|
2
|
|
|
|
|
12
|
$o->compile; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#============================================================================== |
76
|
|
|
|
|
|
|
# Return a small report about the C code.. |
77
|
|
|
|
|
|
|
#============================================================================== |
78
|
|
|
|
|
|
|
sub info { |
79
|
0
|
|
|
0
|
1
|
0
|
my $o = shift; |
80
|
0
|
|
|
|
|
0
|
my $txt = <
|
81
|
|
|
|
|
|
|
The following PP code was generated (caution, can be long)... |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
*** start PP file **** |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
END |
86
|
0
|
|
|
|
|
0
|
return $txt . $o->pd_generate . "\n*** end PP file ****\n"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub config { |
90
|
0
|
|
|
0
|
0
|
0
|
my $o = shift; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#============================================================================== |
94
|
|
|
|
|
|
|
# Write the PDL::PP code into a PD file |
95
|
|
|
|
|
|
|
#============================================================================== |
96
|
|
|
|
|
|
|
sub write_PD { |
97
|
2
|
|
|
2
|
0
|
4
|
my $o = shift; |
98
|
2
|
|
|
|
|
10
|
my $modfname = $o->{API}{modfname}; |
99
|
2
|
|
|
|
|
5
|
my $module = $o->{API}{module}; |
100
|
2
|
|
|
|
|
48
|
$o->mkpath($o->{API}{build_dir}); |
101
|
2
|
50
|
|
|
|
1058
|
open my $fh, ">", "$o->{API}{build_dir}/$modfname.pd" or croak $!; |
102
|
2
|
|
|
|
|
12
|
print $fh $o->pd_generate; |
103
|
2
|
|
|
|
|
90
|
close $fh; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#============================================================================== |
107
|
|
|
|
|
|
|
# Generate the PDL::PP code (piece together a few snippets) |
108
|
|
|
|
|
|
|
#============================================================================== |
109
|
|
|
|
|
|
|
sub pd_generate { |
110
|
2
|
|
|
2
|
0
|
4
|
my $o = shift; |
111
|
2
|
|
|
|
|
6
|
return join "\n", ($o->pd_includes, |
112
|
|
|
|
|
|
|
$o->pd_code, |
113
|
|
|
|
|
|
|
$o->pd_boot, |
114
|
|
|
|
|
|
|
$o->pd_bless, |
115
|
|
|
|
|
|
|
$o->pd_done, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub pd_includes { |
120
|
2
|
|
|
2
|
0
|
3
|
my $o = shift; |
121
|
2
|
|
|
|
|
12
|
return << "END"; |
122
|
|
|
|
|
|
|
pp_addhdr << 'EOH'; |
123
|
|
|
|
|
|
|
$o->{ILSM}{AUTO_INCLUDE} |
124
|
|
|
|
|
|
|
EOH |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
END |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub pd_code { |
130
|
2
|
|
|
2
|
0
|
5
|
my $o = shift; |
131
|
2
|
|
|
|
|
22
|
return $o->{API}{code}; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub pd_boot { |
135
|
2
|
|
|
2
|
0
|
6
|
my $o = shift; |
136
|
2
|
0
|
33
|
|
|
9
|
if (defined $o->{ILSM}{XS}{BOOT} and |
137
|
|
|
|
|
|
|
$o->{ILSM}{XS}{BOOT}) { |
138
|
0
|
|
|
|
|
0
|
return <
|
139
|
|
|
|
|
|
|
pp_add_boot << 'EOB'; |
140
|
|
|
|
|
|
|
$o->{ILSM}{XS}{BOOT} |
141
|
|
|
|
|
|
|
EOB |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
END |
144
|
|
|
|
|
|
|
} |
145
|
2
|
|
|
|
|
7
|
return ''; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub pd_bless { |
150
|
2
|
|
|
2
|
0
|
4
|
my $o = shift; |
151
|
2
|
0
|
33
|
|
|
8
|
if (defined $o->{ILSM}{BLESS} and |
152
|
|
|
|
|
|
|
$o->{ILSM}{BLESS}) { |
153
|
0
|
|
|
|
|
0
|
return <
|
154
|
|
|
|
|
|
|
pp_bless $o->{ILSM}{BLESS}; |
155
|
|
|
|
|
|
|
END |
156
|
|
|
|
|
|
|
} |
157
|
2
|
|
|
|
|
6
|
return ''; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub pd_done { |
162
|
2
|
|
|
2
|
0
|
59
|
return <
|
163
|
|
|
|
|
|
|
pp_done(); |
164
|
|
|
|
|
|
|
END |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub get_maps { |
168
|
2
|
|
|
2
|
0
|
4
|
my $o = shift; |
169
|
2
|
|
|
|
|
17
|
$o->SUPER::get_maps; |
170
|
2
|
|
|
|
|
330
|
my $w = abs_path(PDL::Core::Dev::whereami_any()); |
171
|
2
|
|
|
|
|
7
|
push @{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}, "$w/Core/typemap.pdl"; |
|
2
|
|
|
|
|
12
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
#============================================================================== |
175
|
|
|
|
|
|
|
# Generate the Makefile.PL |
176
|
|
|
|
|
|
|
#============================================================================== |
177
|
|
|
|
|
|
|
sub write_Makefile_PL { |
178
|
2
|
|
|
2
|
0
|
5
|
my $o = shift; |
179
|
2
|
|
|
|
|
4
|
my ($modfname,$module,$pkg) = @{$o->{API}}{qw(modfname module pkg)}; |
|
2
|
|
|
|
|
12
|
|
180
|
2
|
50
|
|
|
|
11
|
my $coredev_suffix = $o->{ILSM}{INTERNAL} ? '_int' : ''; |
181
|
2
|
|
|
|
|
9
|
my @pack = [ "$modfname.pd", $modfname, $module ]; |
182
|
|
|
|
|
|
|
my $stdargs_func = $o->{ILSM}{INTERNAL} |
183
|
2
|
50
|
|
|
|
10
|
? \&pdlpp_stdargs_int : \&pdlpp_stdargs; |
184
|
2
|
|
|
|
|
10
|
my %hash = $stdargs_func->(@pack); |
185
|
2
|
|
|
|
|
10
|
delete $hash{VERSION_FROM}; |
186
|
|
|
|
|
|
|
my %options = ( |
187
|
|
|
|
|
|
|
%hash, |
188
|
|
|
|
|
|
|
VERSION => $o->{API}{version} || "0.00", |
189
|
2
|
|
|
|
|
55
|
%{$o->{ILSM}{MAKEFILE}}, |
190
|
|
|
|
|
|
|
NAME => $o->{API}{module}, |
191
|
|
|
|
|
|
|
INSTALLSITEARCH => $o->{API}{install_lib}, |
192
|
|
|
|
|
|
|
INSTALLDIRS => 'site', |
193
|
|
|
|
|
|
|
INSTALLSITELIB => $o->{API}{install_lib}, |
194
|
2
|
|
50
|
|
|
23
|
MAN3PODS => {}, |
195
|
|
|
|
|
|
|
PM => {}, |
196
|
|
|
|
|
|
|
); |
197
|
2
|
50
|
|
|
|
146
|
open my $fh, ">", "$o->{API}{build_dir}/Makefile.PL" or croak; |
198
|
2
|
|
|
|
|
44
|
print $fh <
|
199
|
|
|
|
|
|
|
use strict; |
200
|
|
|
|
|
|
|
use warnings; |
201
|
|
|
|
|
|
|
use ExtUtils::MakeMaker; |
202
|
|
|
|
|
|
|
use PDL::Core::Dev; |
203
|
|
|
|
|
|
|
my \@pack = [ "$modfname.pd", "$modfname", "$module" ]; |
204
|
|
|
|
|
|
|
my %options = %\{ |
205
|
|
|
|
|
|
|
END |
206
|
2
|
|
|
|
|
6
|
local $Data::Dumper::Terse = 1; |
207
|
2
|
|
|
|
|
17
|
local $Data::Dumper::Indent = 1; |
208
|
2
|
|
|
|
|
14
|
print $fh Data::Dumper::Dumper(\ %options); |
209
|
2
|
|
|
|
|
361
|
print $fh <
|
210
|
|
|
|
|
|
|
\}; |
211
|
|
|
|
|
|
|
WriteMakefile(%options); |
212
|
|
|
|
|
|
|
sub MY::postamble { pdlpp_postamble$coredev_suffix(\@pack); } |
213
|
|
|
|
|
|
|
END |
214
|
2
|
|
|
|
|
81
|
close $fh; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
#============================================================================== |
218
|
|
|
|
|
|
|
# Run the build process. |
219
|
|
|
|
|
|
|
#============================================================================== |
220
|
|
|
|
|
|
|
sub compile { |
221
|
2
|
|
|
2
|
0
|
4
|
my $o = shift; |
222
|
|
|
|
|
|
|
# grep is because on Windows, Cwd::abs_path blows up on non-exist dir |
223
|
|
|
|
|
|
|
local $ENV{PERL5LIB} = join $Config{path_sep}, map abs_path($_), grep -e, @INC |
224
|
2
|
50
|
|
|
|
17
|
unless defined $ENV{PERL5LIB}; |
225
|
2
|
|
|
|
|
31
|
$o->SUPER::compile; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
2
|
0
|
|
sub fix_make { } # our Makefile.PL doesn't need this |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
1; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
__END__ |