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
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)
4 #!perl -w
5 use File::Spec;
6 my (undef, $headerpath) = @ARGV;
7 my ($out) = __FILE__ =~ /(^.*)\.PL/i;
8 $out =~ s/_h$/.h/;
9 unlink $out if -l $out;
10 open(OUT,">$out") || die "Cannot open $file:$!";
11 print "Extracting $out...\n";
12 print OUT <<"END";
13 /*
14  !!! Don't modify this file - it's autogenerated from $0 !!!
15  */
16 END
17
18 foreach my $const (qw(
19                       CVf_ANON
20                       CVf_CLONE
21                       CVf_CLONED
22                       CVf_CONST
23                       CVf_LOCKED
24                       CVf_LVALUE
25                       CVf_METHOD
26                       CVf_NODEBUG
27                       CVf_UNIQUE
28                       CVf_WEAKOUTSIDE
29                       GVf_IMPORTED_AV
30                       GVf_IMPORTED_CV
31                       GVf_IMPORTED_HV
32                       GVf_IMPORTED_SV
33                       HEf_SVKEY
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
50                       PAD_FAKELEX_ANON
51                       PAD_FAKELEX_MULTI
52                       ))
53  {
54   doconst($const);
55  }
56
57 if ($] < 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
63 if ($] >= 5.009) {
64     # Constant not present in 5.8.x
65     doconst(CVf_ISXSUB);
66 } else {
67     # Constant not present after 5.8.x
68     doconst(AVf_REAL);
69 }  
70
71 foreach my $tuple (['op.h'],['cop.h'],['regexp.h','RXf_'])
72  {
73   my $file = $tuple->[0];
74   my $pfx = $tuple->[1] || '';
75   my $path = File::Spec->catfile($headerpath, $file);
76   open(OPH,"$path") || die "Cannot open $path:$!";
77   while (<OPH>)
78    {  
79     doconst($1) if (/#define\s+($pfx\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
80    }  
81   close(OPH);
82  }
83 close(OUT);
84                
85 sub doconst
86 {
87  my $sym = shift;
88  my $l = length($sym);
89  print OUT <<"END";
90  newCONSTSUB(stash,"$sym",newSViv($sym)); 
91  av_push(export_ok,newSVpvn("$sym",$l));
92 END
93 }