428
|
1 /* Declarations having to do with Mule char tables.
|
|
2 Copyright (C) 1992 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
1296
|
4 Copyright (C) 2002, 2003 Ben Wing.
|
428
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Mule 2.3. Not synched with FSF.
|
|
24
|
|
25 This file was written independently of the FSF implementation,
|
|
26 and is not compatible. */
|
|
27
|
440
|
28 #ifndef INCLUDED_chartab_h_
|
|
29 #define INCLUDED_chartab_h_
|
428
|
30
|
771
|
31 #include "charset.h"
|
|
32
|
428
|
33 /************************************************************************/
|
|
34 /* Char Tables */
|
|
35 /************************************************************************/
|
|
36
|
|
37 /* Under Mule, we use a complex representation (see below).
|
|
38 When not under Mule, there are only 256 possible characters
|
|
39 so we just represent them directly. */
|
|
40
|
|
41 #ifdef MULE
|
|
42
|
|
43 struct Lisp_Char_Table_Entry
|
|
44 {
|
2720
|
45 #ifdef MC_ALLOC
|
|
46 struct lrecord_header header;
|
|
47 #else /* MC_ALLOC */
|
428
|
48 struct lcrecord_header header;
|
2720
|
49 #endif /* MC_ALLOC */
|
428
|
50
|
|
51 /* In the interests of simplicity, we just use a fixed 96-entry
|
|
52 table. If we felt like being smarter, we could make this
|
|
53 variable-size and add an offset value into this structure. */
|
|
54 Lisp_Object level2[96];
|
|
55 };
|
440
|
56 typedef struct Lisp_Char_Table_Entry Lisp_Char_Table_Entry;
|
|
57
|
|
58 DECLARE_LRECORD (char_table_entry, Lisp_Char_Table_Entry);
|
|
59 #define XCHAR_TABLE_ENTRY(x) \
|
|
60 XRECORD (x, char_table_entry, Lisp_Char_Table_Entry)
|
617
|
61 #define wrap_char_table_entry(p) wrap_record (p, char_table_entry)
|
440
|
62 #define CHAR_TABLE_ENTRYP(x) RECORDP (x, char_table_entry)
|
|
63 /* #define CHECK_CHAR_TABLE_ENTRY(x) CHECK_RECORD (x, char_table_entry)
|
|
64 char table entries should never escape to Lisp */
|
428
|
65
|
|
66 #endif /* MULE */
|
|
67
|
|
68 enum char_table_type
|
|
69 {
|
|
70 CHAR_TABLE_TYPE_GENERIC,
|
|
71 #ifdef MULE
|
|
72 CHAR_TABLE_TYPE_CATEGORY,
|
|
73 #endif
|
|
74 CHAR_TABLE_TYPE_SYNTAX,
|
|
75 CHAR_TABLE_TYPE_DISPLAY,
|
|
76 CHAR_TABLE_TYPE_CHAR
|
|
77 };
|
|
78
|
|
79 #ifdef MULE
|
|
80 #define NUM_ASCII_CHARS 160
|
|
81 #else
|
|
82 #define NUM_ASCII_CHARS 256
|
|
83 #endif
|
|
84
|
|
85 struct Lisp_Char_Table
|
|
86 {
|
2720
|
87 #ifdef MC_ALLOC
|
|
88 struct lrecord_header header;
|
|
89 #else /* MC_ALLOC */
|
428
|
90 struct lcrecord_header header;
|
2720
|
91 #endif /* MC_ALLOC */
|
428
|
92
|
|
93 Lisp_Object ascii[NUM_ASCII_CHARS];
|
826
|
94 Lisp_Object default_;
|
793
|
95 Lisp_Object parent; /* #### not yet implemented */
|
|
96
|
428
|
97 #ifdef MULE
|
|
98 /* We basically duplicate the Mule vectors-of-vectors implementation.
|
|
99 We can do this because we know a great deal about the sorts of
|
|
100 things we are going to be indexing.
|
|
101
|
|
102 The current implementation is as follows:
|
|
103
|
|
104 ascii[0-159] is used for ASCII and Control-1 characters.
|
|
105
|
|
106 level1[0 .. (NUM_LEADING_BYTES-1)] indexes charsets by leading
|
|
107 byte (subtract MIN_LEADING_BYTE from the leading byte). If the
|
|
108 value of this is not an opaque, then it specifies a value for all
|
|
109 characters in the charset. Otherwise, it will be a
|
|
110 96-Lisp-Object opaque that we created, specifying a value for
|
|
111 each row. If the value of this is not an opaque, then it
|
|
112 specifies a value for all characters in the row. Otherwise, it
|
|
113 will be a 96-Lisp-Object opaque that we created, specifying a
|
|
114 value for each character.
|
|
115
|
|
116 NOTE: 1) This will fail if some C routine passes an opaque to
|
|
117 Fput_char_table(). Currently this is not a problem
|
|
118 since all char tables that are created are Lisp-visible
|
|
119 and thus no one should ever be putting an opaque in
|
|
120 a char table. Another possibility is to consider
|
|
121 adding a type to */
|
|
122
|
|
123 Lisp_Object level1[NUM_LEADING_BYTES];
|
|
124
|
|
125 #endif /* MULE */
|
|
126
|
|
127 enum char_table_type type;
|
|
128
|
|
129 /* stuff used for syntax tables */
|
1296
|
130 Lisp_Object mirror_table; /* points to mirror table for this table
|
|
131 (a cache for quicker access), or a back
|
|
132 pointer if MIRROR_TABLE_P. */
|
428
|
133 Lisp_Object next_table; /* DO NOT mark through this. */
|
1296
|
134 char dirty; /* nonzero if mirror dirty and needs updating. */
|
|
135 char mirror_table_p; /* nonzero if this is a mirror table. */
|
428
|
136 };
|
440
|
137 typedef struct Lisp_Char_Table Lisp_Char_Table;
|
|
138
|
|
139 DECLARE_LRECORD (char_table, Lisp_Char_Table);
|
|
140 #define XCHAR_TABLE(x) XRECORD (x, char_table, Lisp_Char_Table)
|
617
|
141 #define wrap_char_table(p) wrap_record (p, char_table)
|
440
|
142 #define CHAR_TABLEP(x) RECORDP (x, char_table)
|
|
143 #define CHECK_CHAR_TABLE(x) CHECK_RECORD (x, char_table)
|
|
144 #define CONCHECK_CHAR_TABLE(x) CONCHECK_RECORD (x, char_table)
|
|
145
|
|
146 #define CHAR_TABLE_TYPE(ct) ((ct)->type)
|
|
147 #define XCHAR_TABLE_TYPE(ct) CHAR_TABLE_TYPE (XCHAR_TABLE (ct))
|
428
|
148
|
440
|
149 Lisp_Object get_non_ascii_char_table_value (Lisp_Char_Table *ct,
|
|
150 int leading_byte,
|
867
|
151 Ichar c);
|
428
|
152
|
826
|
153 DECLARE_INLINE_HEADER (
|
|
154 Lisp_Object
|
1296
|
155 get_char_table_1 (Ichar ch, Lisp_Object table)
|
826
|
156 )
|
428
|
157 {
|
826
|
158 Lisp_Object retval;
|
|
159 Lisp_Char_Table *ct = XCHAR_TABLE (table);
|
|
160 #ifdef MULE
|
|
161 if (ch < NUM_ASCII_CHARS)
|
|
162 retval = ct->ascii[ch];
|
428
|
163 else
|
826
|
164 {
|
867
|
165 unsigned char lb = ichar_leading_byte (ch);
|
826
|
166 if (!CHAR_TABLE_ENTRYP (ct->level1[lb - MIN_LEADING_BYTE]))
|
|
167 retval = ct->level1[lb - MIN_LEADING_BYTE];
|
|
168 else
|
|
169 retval = get_non_ascii_char_table_value (ct, lb, ch);
|
|
170 }
|
|
171 #else /* not MULE */
|
|
172 retval = ct->ascii[(unsigned char) ch];
|
|
173 #endif /* not MULE */
|
|
174 if (!UNBOUNDP (retval))
|
|
175 return retval;
|
|
176 else
|
|
177 return ct->default_;
|
428
|
178 }
|
|
179
|
1296
|
180 #ifdef ERROR_CHECK_TYPES
|
|
181 DECLARE_INLINE_HEADER (
|
|
182 Lisp_Object
|
|
183 get_char_table (Ichar ch, Lisp_Object table)
|
|
184 )
|
|
185 {
|
|
186 assert (!XCHAR_TABLE (table)->mirror_table_p);
|
|
187 return get_char_table_1 (ch, table);
|
|
188 }
|
|
189 #else
|
|
190 #define get_char_table(ch, table) get_char_table_1 (ch, table)
|
|
191 #endif
|
|
192
|
428
|
193 enum chartab_range_type
|
|
194 {
|
|
195 CHARTAB_RANGE_ALL,
|
|
196 #ifdef MULE
|
|
197 CHARTAB_RANGE_CHARSET,
|
|
198 CHARTAB_RANGE_ROW,
|
|
199 #endif
|
|
200 CHARTAB_RANGE_CHAR
|
|
201 };
|
|
202
|
|
203 struct chartab_range
|
|
204 {
|
|
205 enum chartab_range_type type;
|
867
|
206 Ichar ch;
|
428
|
207 Lisp_Object charset;
|
|
208 int row;
|
|
209 };
|
|
210
|
826
|
211 void set_char_table_default (Lisp_Object table, Lisp_Object value);
|
|
212 void put_char_table (Lisp_Object table, struct chartab_range *range,
|
428
|
213 Lisp_Object val);
|
826
|
214 int map_char_table (Lisp_Object table,
|
428
|
215 struct chartab_range *range,
|
|
216 int (*fn) (struct chartab_range *range,
|
826
|
217 Lisp_Object table,
|
428
|
218 Lisp_Object val, void *arg),
|
|
219 void *arg);
|
|
220 void prune_syntax_tables (void);
|
826
|
221 Lisp_Object get_range_char_table (struct chartab_range *range,
|
|
222 Lisp_Object table, Lisp_Object multi);
|
1296
|
223 #ifdef ERROR_CHECK_TYPES
|
|
224 Lisp_Object updating_mirror_get_range_char_table (struct chartab_range *range,
|
|
225 Lisp_Object table,
|
|
226 Lisp_Object multi);
|
|
227 #else
|
|
228 #define updating_mirror_get_range_char_table get_range_char_table
|
|
229 #endif
|
826
|
230 void copy_char_table_range (Lisp_Object from, Lisp_Object to,
|
|
231 struct chartab_range *range);
|
867
|
232 int word_boundary_p (Ichar c1, Ichar c2);
|
428
|
233
|
|
234 EXFUN (Fcopy_char_table, 1);
|
|
235 EXFUN (Fmake_char_table, 1);
|
|
236 EXFUN (Fput_char_table, 3);
|
|
237 EXFUN (Fget_char_table, 2);
|
|
238
|
|
239 extern Lisp_Object Vall_syntax_tables;
|
|
240
|
|
241
|
|
242
|
|
243 #ifdef MULE
|
867
|
244 int check_category_char (Ichar ch, Lisp_Object ctbl, int designator,
|
826
|
245 int not_p);
|
428
|
246
|
|
247 extern Lisp_Object Vstandard_category_table;
|
|
248
|
|
249 #define CATEGORY_DESIGNATORP(x) \
|
|
250 (CHARP (x) && XCHAR (x) >= 32 && XCHAR (x) <= 126)
|
|
251
|
|
252 #define CHECK_CATEGORY_DESIGNATOR(x) do { \
|
|
253 if (!CATEGORY_DESIGNATORP (x)) \
|
|
254 dead_wrong_type_argument (Qcategory_designator_p, x); \
|
|
255 } while (0)
|
|
256
|
|
257 #define CONCHECK_CATEGORY_DESIGNATOR(x) do { \
|
|
258 if (!CATEGORY_DESIGNATORP (x)) \
|
|
259 x = wrong_type_argument (Qcategory_designator_p, x); \
|
|
260 } while (0)
|
|
261
|
|
262 #define CATEGORY_TABLE_VALUEP(x) \
|
|
263 (NILP (x) || (BIT_VECTORP (x) && (bit_vector_length (XBIT_VECTOR (x)) == 95)))
|
|
264
|
|
265 #define CHECK_CATEGORY_TABLE_VALUE(x) do { \
|
|
266 if (!CATEGORY_TABLE_VALUEP (x)) \
|
|
267 dead_wrong_type_argument (Qcategory_table_value_p, x); \
|
|
268 } while (0)
|
|
269
|
|
270 #define CONCHECK_CATEGORY_TABLE_VALUE(x) do { \
|
|
271 if (!CATEGORY_TABLE_VALUEP (x)) \
|
|
272 x = wrong_type_argument (Qcategory_table_value_p, x); \
|
|
273 } while (0)
|
|
274
|
|
275 #endif /* MULE */
|
|
276
|
440
|
277 #endif /* INCLUDED_chartab_h_ */
|