This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Artistic fine-tuning.
[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/;
6 if ($^O eq 'VMS') { ($out) = __FILE__ =~ /^(.+)_PL$/i; }
7 $out =~ s/_h$/.h/;
8 open(OUT,">$out") || die "Cannot open $file:$!";
9 print "Extracting $out...\n";
10 foreach my $const (qw(AVf_REAL 
11                       HEf_SVKEY
12                       SVf_IOK SVf_IVisUV SVf_NOK SVf_POK 
13                       SVf_ROK SVp_IOK SVp_POK ))
14  {
15   doconst($const);
16  }
17 foreach my $file (qw(op.h cop.h))
18  {
19   open(OPH,"../../$file") || die "Cannot open ../../$file:$!";
20   while (<OPH>)
21    {  
22     doconst($1) if (/#define\s+(\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
23    }  
24   close(OPH);
25  }
26 close(OUT);
27                
28 sub doconst
29 {
30  my $sym = shift;
31  my $l = length($sym);
32  print OUT <<"END";
33  newCONSTSUB(stash,"$sym",newSViv($sym)); 
34  av_push(export_ok,newSVpvn("$sym",$l));
35 END
36 }