This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Updaate ppport.h to get a conditional PERL_UNUSED_DECL
[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                       CVf_ANON
17                       CVf_ASSERTION
18                       CVf_CLONE
19                       CVf_CLONED
20                       CVf_CONST
21                       CVf_LOCKED
22                       CVf_LVALUE
23                       CVf_METHOD
24                       CVf_NODEBUG
25                       CVf_OLDSTYLE
26                       CVf_UNIQUE
27                       CVf_WEAKOUTSIDE
28                       GVf_IMPORTED_AV
29                       GVf_IMPORTED_CV
30                       GVf_IMPORTED_HV
31                       GVf_IMPORTED_SV
32                       HEf_SVKEY
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
49                       ))
50  {
51   doconst($const);
52  }
53 foreach my $file (qw(op.h cop.h))
54  {
55   my $path = $^O eq 'MacOS' ? ":::$file" : "../../$file";
56   open(OPH,"$path") || die "Cannot open $path:$!";
57   while (<OPH>)
58    {  
59     doconst($1) if (/#define\s+(\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
60    }  
61   close(OPH);
62  }
63 close(OUT);
64                
65 sub doconst
66 {
67  my $sym = shift;
68  my $l = length($sym);
69  print OUT <<"END";
70  newCONSTSUB(stash,"$sym",newSViv($sym)); 
71  av_push(export_ok,newSVpvn("$sym",$l));
72 END
73 }