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
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
5 my ($out) = __FILE__ =~ /(^.*)\.PL/i;
6 $out =~ s/_h$/.h/;
7 open(OUT,">$out") || die "Cannot open $file:$!";
8 print "Extracting $out...\n";
9 print OUT <<"END";
10 /*
11  !!! Don't modify this file - it's autogenerated from $0 !!!
12  */
13 END
14
15 foreach my $const (qw(
16                       AVf_REAL
17                       CVf_ANON
18                       CVf_ASSERTION
19                       CVf_CLONE
20                       CVf_CLONED
21                       CVf_CONST
22                       CVf_LOCKED
23                       CVf_LVALUE
24                       CVf_METHOD
25                       CVf_NODEBUG
26                       CVf_OLDSTYLE
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 foreach my $file (qw(op.h cop.h))
64  {
65   my $path = $^O eq 'MacOS' ? ":::$file" : "../../$file";
66   open(OPH,"$path") || die "Cannot open $path:$!";
67   while (<OPH>)
68    {  
69     doconst($1) if (/#define\s+(\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
70    }  
71   close(OPH);
72  }
73 close(OUT);
74                
75 sub doconst
76 {
77  my $sym = shift;
78  my $l = length($sym);
79  print OUT <<"END";
80  newCONSTSUB(stash,"$sym",newSViv($sym)); 
81  av_push(export_ok,newSVpvn("$sym",$l));
82 END
83 }