beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / tex / primitive.h
blobb6b13c74f73a99bafdaa4e2e998769fc60e9f3da
1 /* primitive.h
3 Copyright 2008-2009 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
7 LuaTeX is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License along
18 with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
21 #ifndef LUATEX_PRIMITIVE_H
22 # define LUATEX_PRIMITIVE_H 1
24 /* This enum is a list of origins for primitive commands */
26 typedef enum {
27 /* Can be modified as suggested ?*/
28 tex_command = 1, /* 1 */
29 etex_command = 2, /* 2 */
30 pdftex_command = 16, /* 4 */ /* obsolete */
31 luatex_command = 32, /* 8 */
32 core_command = 64, /* 16 */
33 no_command = 128, /* 32 */
34 umath_command = 256, /* 64 */ /* obsolete */
35 } command_origin;
37 # define hash_size 65536 /* maximum number of control sequences; it should be at most about |(fix_mem_max-fix_mem_min)/10| */
38 # define hash_prime 55711 /* a prime number equal to about 85\pct! of |hash_size| */
40 extern two_halves *hash; /* the hash table */
41 extern halfword hash_used; /* allocation pointer for |hash| */
42 extern int hash_extra; /* |hash_extra=hash| above |eqtb_size| */
43 extern halfword hash_top; /* maximum of the hash array */
44 extern halfword hash_high; /* pointer to next high hash location */
45 extern boolean no_new_control_sequence; /* are new identifiers legal? */
46 extern int cs_count; /* total number of known identifiers */
48 # define cs_next(a) hash[(a)].lhfield /* link for coalesced lists */
49 # define cs_text(a) hash[(a)].rh
50 /* string number for control sequence name */
52 # define undefined_primitive 0
53 # define prim_size 2100 /* maximum number of primitives */
54 # define prim_prime 1777 /* about 85\pct! of |primitive_size| */
56 extern void init_primitives(void);
57 extern void ini_init_primitives(void);
59 extern halfword compute_pool_hash(pool_pointer j, pool_pointer l,
60 halfword prime_number);
61 extern pointer prim_lookup(str_number s);
63 extern boolean is_primitive(str_number csname);
65 extern quarterword get_prim_eq_type(int p);
66 extern halfword get_prim_equiv(int p);
67 extern str_number get_prim_text(int p);
68 extern quarterword get_prim_origin(int p);
70 extern void dump_primitives(void);
71 extern void undump_primitives(void);
73 # define primitive_tex(a,b,c,d) primitive((a),(b),(c),(d),tex_command)
74 # define primitive_etex(a,b,c,d) primitive((a),(b),(c),(d),etex_command)
75 # define primitive_pdftex(a,b,c,d) primitive((a),(b),(c),(d),pdftex_command)
76 # define primitive_luatex(a,b,c,d) primitive((a),(b),(c),(d),luatex_command)
77 # define primitive_umath(a,b,c,d) primitive((a),(b),(c),(d),umath_command)
78 # define primitive_core(a,b,c,d) primitive((a),(b),(c),(d),core_command)
79 # define primitive_no(a,b,c,d) primitive((a),(b),(c),(d),no_command)
81 extern void primitive(const char *ss, quarterword c, halfword o, halfword off,
82 int cmd_origin);
83 extern void primitive_def(const char *s, size_t l, quarterword c, halfword o);
84 extern void print_cmd_chr(quarterword cmd, halfword chr_code);
86 extern pointer string_lookup(const char *s, size_t l);
87 extern pointer id_lookup(int j, int l);
89 #endif /* LUATEX_PRIMITIVE_H */