This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[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)
4c1f658f 4#!perl
32882678 5my ($out) = __FILE__ =~ /(^.*)\.PL/i;
93804878 6$out =~ s/_h$/.h/;
71c2fea9 7unlink $out if -l $out;
4c1f658f 8open(OUT,">$out") || die "Cannot open $file:$!";
cc50ac46 9print "Extracting $out...\n";
406c4b1e
JH
10print OUT <<"END";
11/*
12 !!! Don't modify this file - it's autogenerated from $0 !!!
13 */
14END
15
059a8bb7 16foreach my $const (qw(
42272d83 17 AVf_REAL
a8770bf5 18 CVf_ANON
0520e62f 19 CVf_ASSERTION
a8770bf5
JH
20 CVf_CLONE
21 CVf_CLONED
22 CVf_CONST
23 CVf_LOCKED
24 CVf_LVALUE
25 CVf_METHOD
26 CVf_NODEBUG
a8770bf5
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
a8770bf5
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
aa38d90e
NC
50 PAD_FAKELEX_ANON
51 PAD_FAKELEX_MULTI
059a8bb7 52 ))
4c1f658f
NIS
53 {
54 doconst($const);
55 }
93993289
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
71c2fea9
NC
63if ($] >= 5.009) {
64 # Constant not present in 5.8.x
65 doconst(CVf_ISXSUB);
66}
67
4c1f658f
NIS
68foreach my $file (qw(op.h cop.h))
69 {
db5fd395
CN
70 my $path = $^O eq 'MacOS' ? ":::$file" : "../../$file";
71 open(OPH,"$path") || die "Cannot open $path:$!";
4c1f658f
NIS
72 while (<OPH>)
73 {
74 doconst($1) if (/#define\s+(\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
75 }
76 close(OPH);
77 }
78close(OUT);
79
80sub doconst
81{
82 my $sym = shift;
83 my $l = length($sym);
84 print OUT <<"END";
85 newCONSTSUB(stash,"$sym",newSViv($sym));
79cb57f6 86 av_push(export_ok,newSVpvn("$sym",$l));
4c1f658f
NIS
87END
88}