This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove want_vtbl_{glob,symtab}, which aren't used and don't do anything useful.
[perl5.git] / regen / mg_vtable.pl
CommitLineData
8b09643d
NC
1#!/usr/bin/perl -w
2#
3# Regenerate (overwriting only if changed):
4#
5# mg_vtable.h
6#
7# from information stored in this file.
8#
9# Accepts the standard regen_lib -q and -v args.
10#
11# This script is normally invoked from regen.pl.
12
13use strict;
14require 5.004;
15
16BEGIN {
17 # Get function prototypes
18 require 'regen/regen_lib.pl';
19}
20
0a1f728a 21# These have a subtly different "namespace" from the magic types.
8b09643d
NC
22my @sig =
23 (
24 'sv' => {get => 'get', set => 'set', len => 'len'},
25 'env' => {set => 'set_all_env', clear => 'clear_all_env'},
26 'envelem' => {set => 'setenv', clear => 'clearenv'},
27 'sigelem' => {get => 'getsig', set => 'setsig', clear => 'clearsig',
28 cond => '#ifndef PERL_MICRO'},
29 'pack' => {len => 'sizepack', clear => 'wipepack'},
30 'packelem' => {get => 'getpack', set => 'setpack', clear => 'clearpack'},
31 'dbline' => {set => 'setdbline'},
32 'isa' => {set => 'setisa', clear => 'clearisa'},
33 'isaelem' => {set => 'setisa'},
34 'arylen' => {get => 'getarylen', set => 'setarylen', const => 1},
35 'arylen_p' => {free => 'freearylen_p'},
36 'mglob' => {set => 'setmglob'},
37 'nkeys' => {get => 'getnkeys', set => 'setnkeys'},
38 'taint' => {get => 'gettaint', set => 'settaint'},
39 'substr' => {get => 'getsubstr', set => 'setsubstr'},
40 'vec' => {get => 'getvec', set => 'setvec'},
41 'pos' => {get => 'getpos', set => 'setpos'},
42 'bm' => {set => 'setregexp'},
43 'fm' => {set => 'setregexp'},
44 'uvar' => {get => 'getuvar', set => 'setuvar'},
45 'defelem' => {get => 'getdefelem', set => 'setdefelem'},
46 'regexp' => {set => 'setregexp'},
47 'regdata' => {len => 'regdata_cnt'},
48 'regdatum' => {get => 'regdatum_get', set => 'regdatum_set'},
49 'amagic' => {set => 'setamagic', free => 'setamagic'},
50 'amagicelem' => {set => 'setamagic', free => 'setamagic'},
51 'backref' => {free => 'killbackrefs'},
52 'ovrld' => {free => 'freeovrld'},
53 'utf8' => {set => 'setutf8'},
54 'collxfrm' => {set => 'setcollxfrm',
55 cond => '#ifdef USE_LOCALE_COLLATE'},
56 'hintselem' => {set => 'sethint', clear => 'clearhint'},
57 'hints' => {clear => 'clearhints'},
58);
59
60my $h = open_new('mg_vtable.h', '>',
61 { by => 'regen/mg_vtable.pl', file => 'mg_vtable.h',
62 style => '*' });
63
64print $h <<'EOH';
65/* These all need to be 0, not NULL, as NULL can be (void*)0, which is a
66 * pointer to data, whereas we're assigning pointers to functions, which are
67 * not the same beast. ANSI doesn't allow the assignment from one to the other.
68 * (although most, but not all, compilers are prepared to do it)
69 */
70
0ffb5b03 71/* order is:
8b09643d
NC
72 get
73 set
74 len
75 clear
76 free
77 copy
78 dup
79 local
80*/
81
82EOH
83
84while (my ($name, $data) = splice @sig, 0, 2) {
0a1f728a 85 my @funcs = map {
8b09643d
NC
86 $data->{$_} ? "Perl_magic_$data->{$_}" : 0;
87 } qw(get set len clear free copy dup local);
88
0a1f728a 89 $funcs[0] = "(int (*)(pTHX_ SV *, MAGIC *))" . $funcs[0] if $data->{const};
0ffb5b03 90 my $funcs = join ", ", @funcs;
8b09643d
NC
91
92 print $h "$data->{cond}\n" if $data->{cond};
93 print $h <<"EOT";
0ffb5b03
NC
94#ifdef DOINIT
95EXT_MGVTBL PL_vtbl_$name
96 = { $funcs };
97#else
98EXT_MGVTBL PL_vtbl_$name;
99#endif
8b09643d
NC
100EOT
101 print $h "#endif\n" if $data->{cond};
102 print $h "\n";
103}
104
105read_only_bottom_close_and_rename($h);