Commit | Line | Data |
918c0b2d |
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) |
b7254abc |
4 | #!perl -w |
5 | use File::Spec; |
6 | my (undef, $headerpath) = @ARGV; |
32882678 |
7 | my ($out) = __FILE__ =~ /(^.*)\.PL/i; |
93804878 |
8 | $out =~ s/_h$/.h/; |
fd40a117 |
9 | unlink $out if -l $out; |
4c1f658f |
10 | open(OUT,">$out") || die "Cannot open $file:$!"; |
cc50ac46 |
11 | print "Extracting $out...\n"; |
651aa52e |
12 | print OUT <<"END"; |
13 | /* |
14 | !!! Don't modify this file - it's autogenerated from $0 !!! |
15 | */ |
16 | END |
17 | |
059a8bb7 |
18 | foreach my $const (qw( |
7386c4fb |
19 | CVf_ANON |
7386c4fb |
20 | CVf_CLONE |
21 | CVf_CLONED |
22 | CVf_CONST |
23 | CVf_LOCKED |
24 | CVf_LVALUE |
25 | CVf_METHOD |
26 | CVf_NODEBUG |
7386c4fb |
27 | CVf_UNIQUE |
28 | CVf_WEAKOUTSIDE |
29 | GVf_IMPORTED_AV |
30 | GVf_IMPORTED_CV |
31 | GVf_IMPORTED_HV |
32 | GVf_IMPORTED_SV |
b874ff32 |
33 | HEf_SVKEY |
7386c4fb |
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 |
077a3fa2 |
50 | PAD_FAKELEX_ANON |
51 | PAD_FAKELEX_MULTI |
059a8bb7 |
52 | )) |
4c1f658f |
53 | { |
54 | doconst($const); |
55 | } |
e6663653 |
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 | |
e412117e |
63 | if ($] >= 5.009) { |
64 | # Constant not present in 5.8.x |
65 | doconst(CVf_ISXSUB); |
f7192a3f |
66 | } else { |
67 | # Constant not present after 5.8.x |
68 | doconst(AVf_REAL); |
69 | } |
e412117e |
70 | |
c737faaf |
71 | foreach my $tuple (['op.h'],['cop.h'],['regexp.h','RXf_']) |
4c1f658f |
72 | { |
c737faaf |
73 | my $file = $tuple->[0]; |
74 | my $pfx = $tuple->[1] || ''; |
b7254abc |
75 | my $path = File::Spec->catfile($headerpath, $file); |
db5fd395 |
76 | open(OPH,"$path") || die "Cannot open $path:$!"; |
4c1f658f |
77 | while (<OPH>) |
78 | { |
c737faaf |
79 | doconst($1) if (/#define\s+($pfx\w+)\s+([\(\)\|\dx]+)\s*(?:$|\/\*)/); |
4c1f658f |
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)); |
79cb57f6 |
91 | av_push(export_ok,newSVpvn("$sym",$l)); |
4c1f658f |
92 | END |
93 | } |