1 /* Declarations having to do with Mule char tables.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3 Copyright (C) 1995 Sun Microsystems, Inc.
5 This file is part of XEmacs.
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 XEmacs 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 General Public License
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Synched up with: Mule 2.3. Not synched with FSF.
24 This file was written independently of the FSF implementation,
25 and is not compatible. */
27 #ifndef _MULE_CHARTAB_H
28 #define _MULE_CHARTAB_H
30 /************************************************************************/
32 /************************************************************************/
34 /* Under Mule, we use a complex representation (see below).
35 When not under Mule, there are only 256 possible characters
36 so we just represent them directly. */
40 DECLARE_LRECORD (char_table_entry, struct Lisp_Char_Table_Entry);
41 #define XCHAR_TABLE_ENTRY(x) \
42 XRECORD (x, char_table_entry, struct Lisp_Char_Table_Entry)
43 #define XSETCHAR_TABLE_ENTRY(x, p) XSETRECORD (x, p, char_table_entry)
44 #define CHAR_TABLE_ENTRYP(x) RECORDP (x, char_table_entry)
45 /* #define CHECK_CHAR_TABLE_ENTRY(x) CHECK_RECORD (x, char_table_entry)
46 char table entries should never escape to Lisp */
48 struct Lisp_Char_Table_Entry
50 struct lcrecord_header header;
52 /* In the interests of simplicity, we just use a fixed 96-entry
53 table. If we felt like being smarter, we could make this
54 variable-size and add an offset value into this structure. */
55 Lisp_Object level2[96];
60 DECLARE_LRECORD (char_table, struct Lisp_Char_Table);
61 #define XCHAR_TABLE(x) \
62 XRECORD (x, char_table, struct Lisp_Char_Table)
63 #define XSETCHAR_TABLE(x, p) XSETRECORD (x, p, char_table)
64 #define CHAR_TABLEP(x) RECORDP (x, char_table)
65 #define CHECK_CHAR_TABLE(x) CHECK_RECORD (x, char_table)
66 #define CONCHECK_CHAR_TABLE(x) CONCHECK_RECORD (x, char_table)
68 #define CHAR_TABLE_TYPE(ct) ((ct)->type)
69 #define XCHAR_TABLE_TYPE(ct) CHAR_TABLE_TYPE (XCHAR_TABLE (ct))
73 CHAR_TABLE_TYPE_GENERIC,
75 CHAR_TABLE_TYPE_CATEGORY,
77 CHAR_TABLE_TYPE_SYNTAX,
78 CHAR_TABLE_TYPE_DISPLAY,
83 #define NUM_ASCII_CHARS 160
85 #define NUM_ASCII_CHARS 256
88 struct Lisp_Char_Table
90 struct lcrecord_header header;
92 Lisp_Object ascii[NUM_ASCII_CHARS];
95 /* We basically duplicate the Mule vectors-of-vectors implementation.
96 We can do this because we know a great deal about the sorts of
97 things we are going to be indexing.
99 The current implementation is as follows:
101 ascii[0-159] is used for ASCII and Control-1 characters.
103 level1[0 .. (NUM_LEADING_BYTES-1)] indexes charsets by leading
104 byte (subtract MIN_LEADING_BYTE from the leading byte). If the
105 value of this is not an opaque, then it specifies a value for all
106 characters in the charset. Otherwise, it will be a
107 96-Lisp-Object opaque that we created, specifying a value for
108 each row. If the value of this is not an opaque, then it
109 specifies a value for all characters in the row. Otherwise, it
110 will be a 96-Lisp-Object opaque that we created, specifying a
111 value for each character.
113 NOTE: 1) This will fail if some C routine passes an opaque to
114 Fput_char_table(). Currently this is not a problem
115 since all char tables that are created are Lisp-visible
116 and thus no one should ever be putting an opaque in
117 a char table. Another possibility is to consider
120 Lisp_Object level1[NUM_LEADING_BYTES];
124 enum char_table_type type;
126 /* stuff used for syntax tables */
127 Lisp_Object mirror_table;
128 Lisp_Object next_table; /* DO NOT mark through this. */
133 Lisp_Object get_non_ascii_char_table_value (struct Lisp_Char_Table *ct,
138 CHAR_TABLE_NON_ASCII_VALUE_UNSAFE (struct Lisp_Char_Table *ct, Emchar ch);
140 CHAR_TABLE_NON_ASCII_VALUE_UNSAFE (struct Lisp_Char_Table *ct, Emchar ch)
143 Charset_ID lb = CHAR_CHARSET_ID (ch);
145 Charset_ID lb = CHAR_LEADING_BYTE (ch);
147 if (!CHAR_TABLE_ENTRYP ((ct)->level1[lb - MIN_LEADING_BYTE]))
148 return (ct)->level1[lb - MIN_LEADING_BYTE];
150 return get_non_ascii_char_table_value (ct, lb, ch);
153 #define CHAR_TABLE_VALUE_UNSAFE(ct, ch) \
154 ((ch) < NUM_ASCII_CHARS \
156 : CHAR_TABLE_NON_ASCII_VALUE_UNSAFE (ct, ch))
160 #define CHAR_TABLE_VALUE_UNSAFE(ct, ch) ((ct)->ascii[(unsigned char) (ch)])
162 #endif /* not MULE */
164 enum chartab_range_type
168 CHARTAB_RANGE_CHARSET,
176 enum chartab_range_type type;
182 void fill_char_table (struct Lisp_Char_Table *ct, Lisp_Object value);
183 void put_char_table (struct Lisp_Char_Table *ct, struct chartab_range *range,
185 Lisp_Object get_char_table (Emchar, struct Lisp_Char_Table *);
186 int map_char_table (struct Lisp_Char_Table *ct,
187 struct chartab_range *range,
188 int (*fn) (struct chartab_range *range,
189 Lisp_Object val, void *arg),
191 void prune_syntax_tables (void);
193 EXFUN (Fcopy_char_table, 1);
194 EXFUN (Fmake_char_table, 1);
195 EXFUN (Fput_char_table, 3);
196 EXFUN (Fget_char_table, 2);
198 extern Lisp_Object Vall_syntax_tables;
203 int check_category_char(Emchar ch, Lisp_Object ctbl,
204 unsigned int designator, unsigned int not);
206 extern Lisp_Object Vstandard_category_table;
208 #define CATEGORY_DESIGNATORP(x) \
209 (CHARP (x) && XCHAR (x) >= 32 && XCHAR (x) <= 126)
211 #define CHECK_CATEGORY_DESIGNATOR(x) do { \
212 if (!CATEGORY_DESIGNATORP (x)) \
213 dead_wrong_type_argument (Qcategory_designator_p, x); \
216 #define CONCHECK_CATEGORY_DESIGNATOR(x) do { \
217 if (!CATEGORY_DESIGNATORP (x)) \
218 x = wrong_type_argument (Qcategory_designator_p, x); \
221 #define CATEGORY_TABLE_VALUEP(x) \
222 (NILP (x) || (BIT_VECTORP (x) && (bit_vector_length (XBIT_VECTOR (x)) == 95)))
224 #define CHECK_CATEGORY_TABLE_VALUE(x) do { \
225 if (!CATEGORY_TABLE_VALUEP (x)) \
226 dead_wrong_type_argument (Qcategory_table_value_p, x); \
229 #define CONCHECK_CATEGORY_TABLE_VALUE(x) do { \
230 if (!CATEGORY_TABLE_VALUEP (x)) \
231 x = wrong_type_argument (Qcategory_table_value_p, x); \
236 #endif /* _MULE_CHARTAB_H */