This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make the constant AVf_REAL conditional on Perl version.
[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(
a8770bf5 17 CVf_ANON
0520e62f 18 CVf_ASSERTION
a8770bf5
JH
19 CVf_CLONE
20 CVf_CLONED
21 CVf_CONST
22 CVf_LOCKED
23 CVf_LVALUE
24 CVf_METHOD
25 CVf_NODEBUG
a8770bf5
JH
26 CVf_UNIQUE
27 CVf_WEAKOUTSIDE
28 GVf_IMPORTED_AV
29 GVf_IMPORTED_CV
30 GVf_IMPORTED_HV
31 GVf_IMPORTED_SV
b874ff32 32 HEf_SVKEY
a8770bf5
JH
33 SVTYPEMASK
34 SVf_FAKE
35 SVf_IOK
36 SVf_IVisUV
37 SVf_NOK
38 SVf_POK
39 SVf_READONLY
40 SVf_ROK
41 SVp_IOK
42 SVp_NOK
43 SVp_POK
44 SVpad_OUR
45 SVs_RMG
46 SVs_SMG
47 SVt_PVGV
48 SVt_PVHV
aa38d90e
NC
49 PAD_FAKELEX_ANON
50 PAD_FAKELEX_MULTI
059a8bb7 51 ))
4c1f658f
NIS
52 {
53 doconst($const);
54 }
93993289
NC
55
56if ($] < 5.009) {
57 # This is only present in 5.10, but it's useful to B::Deparse to be able
58 # to import a dummy value from B
59 doconst(OPpPAD_STATE);
60}
61
71c2fea9
NC
62if ($] >= 5.009) {
63 # Constant not present in 5.8.x
64 doconst(CVf_ISXSUB);
5f8a8dc2
NC
65} else {
66 # Constant not present after 5.8.x
67 doconst(AVf_REAL);
68}
71c2fea9 69
4c1f658f
NIS
70foreach my $file (qw(op.h cop.h))
71 {
db5fd395
CN
72 my $path = $^O eq 'MacOS' ? ":::$file" : "../../$file";
73 open(OPH,"$path") || die "Cannot open $path:$!";
4c1f658f
NIS
74 while (<OPH>)
75 {
76 doconst($1) if (/#define\s+(\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
77 }
78 close(OPH);
79 }
80close(OUT);
81
82sub doconst
83{
84 my $sym = shift;
85 my $l = length($sym);
86 print OUT <<"END";
87 newCONSTSUB(stash,"$sym",newSViv($sym));
79cb57f6 88 av_push(export_ok,newSVpvn("$sym",$l));
4c1f658f
NIS
89END
90}