B enhancements
[p5sagit/p5-mst-13.2.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                       HEf_SVKEY
18                       SVf_READONLY SVTYPEMASK
19                       GVf_IMPORTED_AV GVf_IMPORTED_HV
20                       GVf_IMPORTED_SV GVf_IMPORTED_CV
21                       CVf_CLONE CVf_CLONED CVf_ANON CVf_OLDSTYLE
22                       CVf_UNIQUE CVf_NODEBUG CVf_METHOD CVf_LOCKED
23                       CVf_LVALUE CVf_CONST CVf_WEAKOUTSIDE CVf_ASSERTION
24                       SVpad_OUR SVf_FAKE SVf_IVisUV
25                       SVf_IOK SVf_NOK SVf_POK SVf_ROK
26                       SVp_IOK SVp_NOK         SVp_POK 
27                       SVt_PVGV SVt_PVHV
28                       SVs_RMG SVs_SMG
29                       ))
30  {
31   doconst($const);
32  }
33 foreach my $file (qw(op.h cop.h))
34  {
35   my $path = $^O eq 'MacOS' ? ":::$file" : "../../$file";
36   open(OPH,"$path") || die "Cannot open $path:$!";
37   while (<OPH>)
38    {  
39     doconst($1) if (/#define\s+(\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/);
40    }  
41   close(OPH);
42  }
43 close(OUT);
44                
45 sub doconst
46 {
47  my $sym = shift;
48  my $l = length($sym);
49  print OUT <<"END";
50  newCONSTSUB(stash,"$sym",newSViv($sym)); 
51  av_push(export_ok,newSVpvn("$sym",$l));
52 END
53 }