This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor Perl_get_vtbl() to a small array lookup from a large switch statement.
[perl5.git] / mg_vtable.h
CommitLineData
8b09643d
NC
1/* -*- buffer-read-only: t -*-
2 *
3 * mg_vtable.h
4 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
5 * This file is built by regen/mg_vtable.pl.
6 * Any changes made here will be lost!
7 */
8
ca298f7d
NC
9enum { /* pass one of these to get_vtbl */
10 want_vtbl_sv,
11 want_vtbl_env,
12 want_vtbl_envelem,
13 want_vtbl_sigelem,
14 want_vtbl_pack,
15 want_vtbl_packelem,
16 want_vtbl_dbline,
17 want_vtbl_isa,
18 want_vtbl_isaelem,
19 want_vtbl_arylen,
20 want_vtbl_arylen_p,
21 want_vtbl_mglob,
22 want_vtbl_nkeys,
23 want_vtbl_taint,
24 want_vtbl_substr,
25 want_vtbl_vec,
26 want_vtbl_pos,
27 want_vtbl_bm,
28 want_vtbl_fm,
29 want_vtbl_uvar,
30 want_vtbl_defelem,
31 want_vtbl_regexp,
32 want_vtbl_regdata,
33 want_vtbl_regdatum,
34 want_vtbl_amagic,
35 want_vtbl_amagicelem,
36 want_vtbl_backref,
37 want_vtbl_ovrld,
38 want_vtbl_utf8,
39 want_vtbl_collxfrm,
40 want_vtbl_hintselem,
c7fdacb9
NC
41 want_vtbl_hints,
42 magic_vtable_max
ca298f7d
NC
43};
44
8b09643d
NC
45/* These all need to be 0, not NULL, as NULL can be (void*)0, which is a
46 * pointer to data, whereas we're assigning pointers to functions, which are
47 * not the same beast. ANSI doesn't allow the assignment from one to the other.
48 * (although most, but not all, compilers are prepared to do it)
49 */
50
0ffb5b03 51/* order is:
8b09643d
NC
52 get
53 set
54 len
55 clear
56 free
57 copy
58 dup
59 local
60*/
61
0ffb5b03 62#ifdef DOINIT
c7fdacb9 63EXT_MGVTBL PL_magic_vtables[magic_vtable_max] = {
b7b5e578
NC
64 { Perl_magic_get, Perl_magic_set, Perl_magic_len, 0, 0, 0, 0, 0 },
65 { 0, Perl_magic_set_all_env, 0, Perl_magic_clear_all_env, 0, 0, 0, 0 },
66 { 0, Perl_magic_setenv, 0, Perl_magic_clearenv, 0, 0, 0, 0 },
8b09643d 67#ifndef PERL_MICRO
b7b5e578
NC
68 { Perl_magic_getsig, Perl_magic_setsig, 0, Perl_magic_clearsig, 0, 0, 0, 0 },
69#else
70 { 0, 0, 0, 0, 0, 0, 0, 0 },
71#endif
72 { 0, 0, Perl_magic_sizepack, Perl_magic_wipepack, 0, 0, 0, 0 },
73 { Perl_magic_getpack, Perl_magic_setpack, 0, Perl_magic_clearpack, 0, 0, 0, 0 },
74 { 0, Perl_magic_setdbline, 0, 0, 0, 0, 0, 0 },
75 { 0, Perl_magic_setisa, 0, Perl_magic_clearisa, 0, 0, 0, 0 },
76 { 0, Perl_magic_setisa, 0, 0, 0, 0, 0, 0 },
77 { (int (*)(pTHX_ SV *, MAGIC *))Perl_magic_getarylen, Perl_magic_setarylen, 0, 0, 0, 0, 0, 0 },
78 { 0, 0, 0, 0, Perl_magic_freearylen_p, 0, 0, 0 },
79 { 0, Perl_magic_setmglob, 0, 0, 0, 0, 0, 0 },
80 { Perl_magic_getnkeys, Perl_magic_setnkeys, 0, 0, 0, 0, 0, 0 },
81 { Perl_magic_gettaint, Perl_magic_settaint, 0, 0, 0, 0, 0, 0 },
82 { Perl_magic_getsubstr, Perl_magic_setsubstr, 0, 0, 0, 0, 0, 0 },
83 { Perl_magic_getvec, Perl_magic_setvec, 0, 0, 0, 0, 0, 0 },
84 { Perl_magic_getpos, Perl_magic_setpos, 0, 0, 0, 0, 0, 0 },
85 { 0, Perl_magic_setregexp, 0, 0, 0, 0, 0, 0 },
86 { 0, Perl_magic_setregexp, 0, 0, 0, 0, 0, 0 },
87 { Perl_magic_getuvar, Perl_magic_setuvar, 0, 0, 0, 0, 0, 0 },
88 { Perl_magic_getdefelem, Perl_magic_setdefelem, 0, 0, 0, 0, 0, 0 },
89 { 0, Perl_magic_setregexp, 0, 0, 0, 0, 0, 0 },
90 { 0, 0, Perl_magic_regdata_cnt, 0, 0, 0, 0, 0 },
91 { Perl_magic_regdatum_get, Perl_magic_regdatum_set, 0, 0, 0, 0, 0, 0 },
92 { 0, Perl_magic_setamagic, 0, 0, Perl_magic_setamagic, 0, 0, 0 },
93 { 0, Perl_magic_setamagic, 0, 0, Perl_magic_setamagic, 0, 0, 0 },
94 { 0, 0, 0, 0, Perl_magic_killbackrefs, 0, 0, 0 },
95 { 0, 0, 0, 0, Perl_magic_freeovrld, 0, 0, 0 },
96 { 0, Perl_magic_setutf8, 0, 0, 0, 0, 0, 0 },
8b09643d 97#ifdef USE_LOCALE_COLLATE
b7b5e578 98 { 0, Perl_magic_setcollxfrm, 0, 0, 0, 0, 0, 0 },
0ffb5b03 99#else
b7b5e578 100 { 0, 0, 0, 0, 0, 0, 0, 0 },
0ffb5b03 101#endif
b7b5e578
NC
102 { 0, Perl_magic_sethint, 0, Perl_magic_clearhint, 0, 0, 0, 0 },
103 { 0, 0, 0, Perl_magic_clearhints, 0, 0, 0, 0 }
104};
0ffb5b03 105#else
c7fdacb9 106EXT_MGVTBL PL_magic_vtables[magic_vtable_max];
b7b5e578
NC
107#endif
108
109#define PL_vtbl_amagic PL_magic_vtables[want_vtbl_amagic]
110#define PL_vtbl_amagicelem PL_magic_vtables[want_vtbl_amagicelem]
111#define PL_vtbl_arylen PL_magic_vtables[want_vtbl_arylen]
112#define PL_vtbl_arylen_p PL_magic_vtables[want_vtbl_arylen_p]
113#define PL_vtbl_backref PL_magic_vtables[want_vtbl_backref]
114#define PL_vtbl_bm PL_magic_vtables[want_vtbl_bm]
115#define PL_vtbl_collxfrm PL_magic_vtables[want_vtbl_collxfrm]
116#define PL_vtbl_dbline PL_magic_vtables[want_vtbl_dbline]
117#define PL_vtbl_defelem PL_magic_vtables[want_vtbl_defelem]
118#define PL_vtbl_env PL_magic_vtables[want_vtbl_env]
119#define PL_vtbl_envelem PL_magic_vtables[want_vtbl_envelem]
120#define PL_vtbl_fm PL_magic_vtables[want_vtbl_fm]
121#define PL_vtbl_hints PL_magic_vtables[want_vtbl_hints]
122#define PL_vtbl_hintselem PL_magic_vtables[want_vtbl_hintselem]
123#define PL_vtbl_isa PL_magic_vtables[want_vtbl_isa]
124#define PL_vtbl_isaelem PL_magic_vtables[want_vtbl_isaelem]
125#define PL_vtbl_mglob PL_magic_vtables[want_vtbl_mglob]
126#define PL_vtbl_nkeys PL_magic_vtables[want_vtbl_nkeys]
127#define PL_vtbl_ovrld PL_magic_vtables[want_vtbl_ovrld]
128#define PL_vtbl_pack PL_magic_vtables[want_vtbl_pack]
129#define PL_vtbl_packelem PL_magic_vtables[want_vtbl_packelem]
130#define PL_vtbl_pos PL_magic_vtables[want_vtbl_pos]
131#define PL_vtbl_regdata PL_magic_vtables[want_vtbl_regdata]
132#define PL_vtbl_regdatum PL_magic_vtables[want_vtbl_regdatum]
133#define PL_vtbl_regexp PL_magic_vtables[want_vtbl_regexp]
134#define PL_vtbl_sigelem PL_magic_vtables[want_vtbl_sigelem]
135#define PL_vtbl_substr PL_magic_vtables[want_vtbl_substr]
136#define PL_vtbl_sv PL_magic_vtables[want_vtbl_sv]
137#define PL_vtbl_taint PL_magic_vtables[want_vtbl_taint]
138#define PL_vtbl_utf8 PL_magic_vtables[want_vtbl_utf8]
139#define PL_vtbl_uvar PL_magic_vtables[want_vtbl_uvar]
140#define PL_vtbl_vec PL_magic_vtables[want_vtbl_vec]
8b09643d
NC
141
142/* ex: set ro: */