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