This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: INC handlers and shutdown-time warnings
[perl5.git] / ext / B / defsubs_h.PL
CommitLineData
918c0b2d
CB
1# Do not remove the following line; MakeMaker relies on it to identify
2# this file as a template for defsubs.h
3# Extracting defsubs.h (with variable substitutions)
b7254abc
NC
4#!perl -w
5use File::Spec;
6my (undef, $headerpath) = @ARGV;
32882678 7my ($out) = __FILE__ =~ /(^.*)\.PL/i;
93804878 8$out =~ s/_h$/.h/;
fd40a117 9unlink $out if -l $out;
4c1f658f 10open(OUT,">$out") || die "Cannot open $file:$!";
cc50ac46 11print "Extracting $out...\n";
651aa52e
AE
12print OUT <<"END";
13/*
14 !!! Don't modify this file - it's autogenerated from $0 !!!
15 */
16END
17
059a8bb7 18foreach my $const (qw(
7386c4fb 19 CVf_ANON
7386c4fb
JH
20 CVf_CLONE
21 CVf_CLONED
22 CVf_CONST
23 CVf_LOCKED
24 CVf_LVALUE
25 CVf_METHOD
26 CVf_NODEBUG
7386c4fb
JH
27 CVf_UNIQUE
28 CVf_WEAKOUTSIDE
29 GVf_IMPORTED_AV
30 GVf_IMPORTED_CV
31 GVf_IMPORTED_HV
32 GVf_IMPORTED_SV
b874ff32 33 HEf_SVKEY
7386c4fb
JH
34 SVTYPEMASK
35 SVf_FAKE
36 SVf_IOK
37 SVf_IVisUV
38 SVf_NOK
39 SVf_POK
40 SVf_READONLY
41 SVf_ROK
42 SVp_IOK
43 SVp_NOK
44 SVp_POK
45 SVpad_OUR
46 SVs_RMG
47 SVs_SMG
48 SVt_PVGV
49 SVt_PVHV
077a3fa2
NC
50 PAD_FAKELEX_ANON
51 PAD_FAKELEX_MULTI
059a8bb7 52 ))
4c1f658f
NIS
53 {
54 doconst($const);
55 }
e6663653
NC
56
57if ($] < 5.009) {
58 # This is only present in 5.10, but it's useful to B::Deparse to be able
59 # to import a dummy value from B
60 doconst(OPpPAD_STATE);
61}
62
e412117e
NC
63if ($] >= 5.009) {
64 # Constant not present in 5.8.x
65 doconst(CVf_ISXSUB);
f7192a3f
NC
66} else {
67 # Constant not present after 5.8.x
68 doconst(AVf_REAL);
69}
e412117e 70
c737faaf 71foreach my $tuple (['op.h'],['cop.h'],['regexp.h','RXf_'])
4c1f658f 72 {
c737faaf
YO
73 my $file = $tuple->[0];
74 my $pfx = $tuple->[1] || '';
b7254abc 75 my $path = File::Spec->catfile($headerpath, $file);
db5fd395 76 open(OPH,"$path") || die "Cannot open $path:$!";
4c1f658f
NIS
77 while (<OPH>)
78 {
c737faaf 79 doconst($1) if (/#define\s+($pfx\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
4c1f658f
NIS
80 }
81 close(OPH);
82 }
83close(OUT);
84
85sub doconst
86{
87 my $sym = shift;
88 my $l = length($sym);
89 print OUT <<"END";
90 newCONSTSUB(stash,"$sym",newSViv($sym));
79cb57f6 91 av_push(export_ok,newSVpvn("$sym",$l));
4c1f658f
NIS
92END
93}