blib/script/namespaces_regenerate.pl untested

filter: Statementstmt 0.0% 0 / 89 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 117 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use perltypesnamespaces;
5 our $VERSION = 0.018_000;
6  
7 ## no critic qw(ProhibitExplicitStdin) # USER DEFAULT 4: allow <STDIN>
8  
9 print 'ARE YOU A PERL::TYPES SYSTEM DEVELOPER? ';
10 my $stdin_confirm = <STDIN>;
11 if ( $stdin_confirm =~ /^[Yy]/ ) {
12 print 'Regenerating Perl::Types Namespaces...' . "\n";
13 }
14 else {
15 exit;
16 }
17  
18 my $namespaces_filename = 'lib/perltypesnamespaces_generated.pm';
19  
20 use English qw(-no_match_vars);
21 use Data::Dumper;
22 $Data::Dumper::Sortkeys = 1;
23  
24 package main;
25  
26 #print 'in namespaces_regenerate.pl main::, about to call perltypesnamespaces::hash()...', "\n";
27 my $namespaces_core = perltypesnamespaces::hash();
28 #print 'in namespaces_regenerate.pl main::, ret from perltypesnamespaces::hash(), have $namespaces_core = ', Dumper($namespaces_core), "\n";
29  
30 # do not call Module::ScanDeps in Perl.pm on files in the following namespaces
31 # DEV NOTE, CORRELATION #rp050: hard-coded list of Perl::Types files/packages/namespaces
32 my $namespaces_noncompiled = {
33 'Acme::' => 1,
34 'Algorithm::' => 1,
35 'Archive::' => 1,
36 'Array::' => 1,
37 'Attribute::' => 1,
38 'Authen::' => 1,
39 'Benchmark::' => 1,
40 'CGI::' => 1,
41 'Compress::' => 1,
42 'Cookie::' => 1,
43 'Cpanel::' => 1,
44 'Crypt::' => 1,
45 'DBD::' => 1,
46 'DBI::' => 1,
47 'Date::' => 1,
48 'Excel::' => 1,
49 'FFI::' => 1,
50 'Geo::' => 1,
51 'HTTP::' => 1,
52 'Hash::' => 1,
53 'Hook::' => 1,
54 'Import::' => 1,
55 'IS::' => 1,
56 'LWP::' => 1,
57 'Mail::' => 1,
58 'MooX::' => 1,
59 'MooseX::' => 1,
60 'Net::' => 1,
61 'Number::' => 1,
62 'Opcode::' => 1,
63 'Plack::' => 1,
64 'RPC::' => 1,
65 'Sereal::' => 1,
66 'StackTrace::' => 1,
67 'Statistics::' => 1,
68 'Stream::' => 1,
69 'TAP::' => 1,
70 'Throwable::' => 1,
71 'Tree::' => 1,
72 'URI::' => 1,
73 'Unicode::' => 1,
74 'WWW::' => 1,
75 'XML::' => 1,
76 'ZMQ::' => 1,
77 'autouse::' => 1,
78 'metaclass::' => 1,
79 'subs::' => 1,
80 };
81  
82 # DEV NOTE, CORRELATION #rp050: hard-coded list of Perl::Types files/packages/namespaces
83 # DEV NOTE, CORRELATION #rp003: some Perl::Types packages are missed due to BEGIN{} or INIT{} blocks, etc.
84 my $namespaces_perltypes_missed = {
85 'perltypesnamespaces::' => 1,
86 'perltypesnamespaces_generated::' => 1,
87 'perltypes::' => 1,
88 'perltypesconv::' => 1,
89 'perltypessizes::' => 1,
90 'perlsse::' => 1,
91 'perlgmp::' => 1,
92 'perlgsl::' => 1,
93 'perlapinames_generated::' => 1,
94 };
95  
96 # DEV NOTE, CORRELATION #rp050: hard-coded list of Perl::Types files/packages/namespaces
97 my $filenames_perltypes = {
98 # forward slash
99 'Perl/Config.pm' => 1,
100 'Perl/Types.pm' => 1,
101 'Perl/Class.pm' => 1,
102 'Perl/HelperFunctions_cpp.pm' => 1,
103 'Perl/Inline.pm' => 1,
104  
105 # backslash
106 'Perl\Config.pm' => 1,
107 'Perl\Types.pm' => 1,
108 'Perl\Class.pm' => 1,
109 'Perl\HelperFunctions_cpp.pm' => 1,
110 'Perl\Inline.pm' => 1,
111  
112 # no slash
113 'Perl.pm' => 1,
114 'perltypesnames.pm' => 1,
115 'perltypesnamespaces.pm' => 1,
116 'perltypesnamespaces_generated.pm' => 1,
117 'perltypes.pm' => 1,
118 'perltypesconv.pm' => 1,
119 'perltypessizes.pm' => 1,
120 'perlsse.pm' => 1,
121 'perlgmp.pm' => 1,
122 'perlgsl.pm' => 1,
123 'perlapinames_generated.pm' => 1,
124 };
125  
126 # DEV NOTE, CORRELATION #rp050: hard-coded list of Perl::Types files/packages/namespaces
127 # NEED UPDATE: some of these should be in core
128 my $namespaces_perltypes_deps = {
129 # BEGIN DEPENDENCY BLOCK, all subdependencies of MongoDB?
130 'Authen::' => 1,
131 'Cross::' => 1,
132 'Does::' => 1,
133 'Error::' => 1,
134 'FFI::' => 1,
135 'FakeLocale::' => 1,
136 'MM::' => 1,
137 'MY::' => 1,
138 'Mango::' => 1,
139 'Mouse::' => 1,
140 'Mozilla::' => 1,
141 'Net::' => 1,
142 'Object::' => 1,
143 'Ref::' => 1,
144 'Unicode::' => 1,
145 'Validation::' => 1,
146 'f845a9c1ac41be33::' => 1,
147 'flock::' => 1,
148 'isn::' => 1,
149 'maybe::' => 1,
150 'next::' => 1,
151 'strictures::' => 1,
152 'swig_runtime_data::' => 1,
153 # END DEPENDENCY BLOCK
154  
155 'Alien::' => 1,
156 'AutoSplit::' => 1,
157 'AutoLoader::' => 1,
158 'BSON::' => 1, # subdependency of MongoDB?
159 'Capture::' => 1,
160 'Class::' => 1,
161 'Clone::' => 1,
162 'Config::' => 1,
163 'Config_git::' => 1,
164 'Config_heavy::' => 1,
165 'CPAN::' => 1,
166 'Cwd::' => 1,
167 'DateTime::' => 1,
168 'Devel::' => 1,
169 'Digest::' => 1,
170 'DirHandle::' => 1,
171 'Dos::' => 1,
172 'EPOC::' => 1,
173 'Email::' => 1,
174 'Encode::' => 1,
175 'Env::' => 1,
176 'Eval::' => 1,
177 'Exception::' => 1,
178 'ExtUtils::' => 1,
179 'Fcntl::' => 1,
180 'File::' => 1,
181 'FileHandle::' => 1,
182 'Filter::' => 1,
183 'FindBin::' => 1,
184 'Getopt::' => 1,
185 'HTML::' => 1,
186 'I18N::' => 1,
187 'Inline::' => 1,
188 'IPC::' => 1,
189 'JSON::' => 1,
190 'List::' => 1,
191 'Lingua::' => 1,
192 'Locale::' => 1,
193 'Log::' => 1,
194 'MIME::' => 1,
195 'Math::' => 1,
196 'Method::' => 1, # subdependency of Moo(se)
197 'Module::' => 1,
198 'MongoDB::' => 1,
199 'Moo::' => 1,
200 'Moose::' => 1,
201 'MRO::' => 1,
202 'POSIX::' => 1,
203 'PadWalker::' => 1,
204 'Package::' => 1,
205 'Params::' => 1,
206 'Parse::' => 1,
207 'Path::' => 1,
208 'Perl::' => 1,
209 'Pod::' => 1,
210 'PPI::' => 1,
211 'PPIx::' => 1,
212 'Readonly::' => 1,
213 'Role::' => 1,
214 'Safe::' => 1,
215 'SDL_perl::' => 1,
216 'SDL::' => 1,
217 'SDLx::' => 1,
218 'SelectSaver::' => 1,
219 'SelfLoader::' => 1,
220 'Socket::' => 1,
221 'Specio::' => 1, # subdependency of MongoDB
222 'Storable::' => 1,
223 'String::' => 1,
224 'Symbol::' => 1,
225 'Syntax::' => 1,
226 'Sys::' => 1,
227 'Sub::' => 1,
228 'Term::' => 1,
229 'Test::' => 1,
230 'Test2::' => 1,
231 'Text::' => 1,
232 'Tie::' => 1,
233 'Time::' => 1,
234 'Try::' => 1,
235 'Type::' => 1, # subdependency of MongoDB
236 'Types::' => 1, # subdependency of MongoDB
237 'Variable::' => 1,
238 'VMS::' => 1,
239 'Win32::' => 1,
240 'auto::' => 1,
241 'base::' => 1,
242 'charnames::' => 1,
243 '_charnames::' => 1,
244 'attributes::' => 1,
245 'boolean::' => 1, # NEED FIX: this is also an Perl::Types data type, duplicate entry below
246 'bytes_heavy::' => 1,
247 'deprecate::' => 1,
248 'feature::' => 1,
249 'fields::' => 1,
250 'if::' => 1,
251 'integer::' => 1, # NEED FIX: this is also an Perl::Types data type, duplicate entry below
252 'locale::' => 1,
253 'namespace::' => 1,
254 'parent::' => 1,
255 'psSnake::' => 1,
256 're::' => 1,
257 'ref::' => 1,
258 'strict::' => 1,
259 'unicore::' => 1,
260 'utf8_heavy::' => 1,
261 'vars::' => 1,
262 'warnings::' => 1,
263 };
264  
265 # DEV NOTE: can not use eval{}, must use stringy eval
266 eval 'use Perl::Types';
267 eval 'use perlsse';
268 eval 'use perlgmp';
269 eval 'use perlgsl';
270 eval 'use perlapinames_generated';
271  
272 #print 'in namespaces_regenerate.pl main::, after evals, about to call perltypesnamespaces::hash()...', "\n";
273 my $namespaces_perltypes = perltypesnamespaces::hash();
274 #print 'in namespaces_regenerate.pl main::, after evals, ret from perltypesnamespaces::hash(), have $namespaces_perltypes = ', Dumper($namespaces_perltypes), "\n";
275  
276 $namespaces_perltypes = { %{$namespaces_perltypes}, %{$namespaces_perltypes_missed} };
277  
278 # separate Perl::Types namespaces and Perl core namespaces; discard Inline build eval_XX_YYYY namespaces
279 foreach my $namespace ( keys %{$namespaces_perltypes} ) {
280 if ( exists $namespaces_core->{$namespace} ) {
281 if ( $namespace =~ /perltypes/ ) {
282 delete $namespaces_core->{$namespace};
283 }
284 else {
285 delete $namespaces_perltypes->{$namespace};
286 }
287 }
288 elsif ((substr $namespace, 0, 5) eq 'eval_') {
289 delete $namespaces_perltypes->{$namespace};
290 }
291 }
292  
293 # remove Perl::Types dependency namespaces from Perl::Types namespaces
294 foreach my $namespace_perltypes_dep ( keys %{$namespaces_perltypes_deps} ) {
295 # NEED FIX: allow 'boolean::' & 'integer::' duplicate entries
296 if (($namespace_perltypes_dep ne 'boolean::') and
297 ($namespace_perltypes_dep ne 'integer::') and
298 ( exists $namespaces_perltypes->{$namespace_perltypes_dep})) {
299 delete $namespaces_perltypes->{$namespace_perltypes_dep};
300 }
301 }
302  
303 my $namespaces_noncompiled_string = Dumper($namespaces_noncompiled);
304 $namespaces_noncompiled_string =~ s/\$VAR1/\$perltypesnamespaces_generated::NONCOMPILED/gxms;
305 my $namespaces_core_string = Dumper($namespaces_core);
306 $namespaces_core_string =~ s/\$VAR1/\$perltypesnamespaces_generated::CORE/gxms;
307 my $namespaces_perltypes_deps_string = Dumper($namespaces_perltypes_deps);
308 $namespaces_perltypes_deps_string =~ s/\$VAR1/\$perltypesnamespaces_generated::PERLTYPES_DEPS/gxms;
309 my $namespaces_perltypes_string = Dumper($namespaces_perltypes);
310 $namespaces_perltypes_string =~ s/\$VAR1/\$perltypesnamespaces_generated::PERLTYPES/gxms;
311 my $filenames_perltypes_string = Dumper($filenames_perltypes);
312 $filenames_perltypes_string =~ s/\$VAR1/\$perltypesnamespaces_generated::PERLTYPES_FILES/gxms;
313  
314 #print 'have $namespaces_perltypes_string = ' . "\n" . $namespaces_perltypes_string . "\n\n";
315  
316 my $namespaces_generated = <<'EOF';
317 # THIS FILE IS AUTOMATICALLY GENERATED BY bin/dev/namespaces_regenerate.pl
318 # DO NOT EDIT THIS FILE DIRECTLY!!! please put all changes in namespaces_regenerate.pl
319 ## no critic qw(Capitalization ProhibitMultiplePackages ProhibitReusedNames) # SYSTEM DEFAULT 3: allow multiple & lower case package names
320 package # hide from PAUSE indexing
321 perltypesnamespaces_generated;
322 use strict;
323 use warnings;
324 our $VERSION = 0.001_000;
325  
326 ## no critic qw(ProhibitParensWithBuiltins ProhibitNoisyQuotes) # SYSTEM SPECIAL 3: allow auto-generated code
327  
328 EOF
329  
330 $namespaces_generated .= q{$perltypesnamespaces_generated::NONCOMPILED = undef;} . "\n";
331 $namespaces_generated .= $namespaces_noncompiled_string . "\n";
332 $namespaces_generated .= q{$perltypesnamespaces_generated::CORE = undef;} . "\n";
333 $namespaces_generated .= $namespaces_core_string . "\n";
334 $namespaces_generated .= q{$perltypesnamespaces_generated::PERLTYPES_DEPS = undef;} . "\n";
335 $namespaces_generated .= $namespaces_perltypes_deps_string . "\n";
336 $namespaces_generated .= q{# DEV NOTE, CORRELATION #rp051: hard-coded list of Perl::Types data types and data structures [AUTOMATICALLY GENERATED BY bin/dev/namespaces_regenerate.pl]} . "\n";
337 $namespaces_generated .= q{# DEV NOTE, CORRELATION #rp054: auto-generation of OO property accessors/mutators checks the auto-generated Perl::Types type list for base data types to determine if the entire data structure can be returned by setting ($return_whole = 1)} . "\n";
338 $namespaces_generated .= q{$perltypesnamespaces_generated::PERLTYPES = undef;} . "\n";
339 $namespaces_generated .= $namespaces_perltypes_string . "\n";
340 $namespaces_generated .= q{$perltypesnamespaces_generated::PERLTYPES_FILES = undef;} . "\n";
341 $namespaces_generated .= $filenames_perltypes_string . "\n";
342 $namespaces_generated .= q{1;} . "\n";
343  
344 #print 'have $namespaces_generated = ' . "\n" . $namespaces_generated . "\n\n";
345  
346 my $open_close_retval = open my $NAMESPACES_FILEHANDLE_OUT, '>', $namespaces_filename;
347 if ( not $open_close_retval ) {
348 croak( 'ERROR ERPNS00: Problem opening output file ' . q{'} . $namespaces_filename . q{': } . $OS_ERROR, 'croaking' );
349 }
350  
351 print {$NAMESPACES_FILEHANDLE_OUT} $namespaces_generated;
352  
353 $open_close_retval = close $NAMESPACES_FILEHANDLE_OUT;
354 if ( not $open_close_retval ) {
355 croak( 'ERROR ERPNS01: Problem closing output file ' . q{'} . $namespaces_filename . q{': } . $OS_ERROR, 'croaking' );
356 }
357  
358 system 'perltidy', '-pbp', '--ignore-side-comment-lengths', '--converge', '-b', '-nst', q{-bext='/'}, '-q', $namespaces_filename;
359  
360 print 'Regenerating Perl::Types Namespaces... DONE!' . "\n";