comparison src/chartab.h @ 428:3ecd8885ac67 r21-2-22

Import from CVS: tag r21-2-22
author cvs
date Mon, 13 Aug 2007 11:28:15 +0200
parents
children 8de8e3f6228a
comparison
equal deleted inserted replaced
427:0a0253eac470 428:3ecd8885ac67
1 /* Declarations having to do with Mule char tables.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3 Copyright (C) 1995 Sun Microsystems, Inc.
4
5 This file is part of XEmacs.
6
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
10 later version.
11
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
15 for more details.
16
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. */
21
22 /* Synched up with: Mule 2.3. Not synched with FSF.
23
24 This file was written independently of the FSF implementation,
25 and is not compatible. */
26
27 #ifndef _MULE_CHARTAB_H
28 #define _MULE_CHARTAB_H
29
30 /************************************************************************/
31 /* Char Tables */
32 /************************************************************************/
33
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. */
37
38 #ifdef MULE
39
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 */
47
48 struct Lisp_Char_Table_Entry
49 {
50 struct lcrecord_header header;
51
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];
56 };
57
58 #endif /* MULE */
59
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)
67
68 #define CHAR_TABLE_TYPE(ct) ((ct)->type)
69 #define XCHAR_TABLE_TYPE(ct) CHAR_TABLE_TYPE (XCHAR_TABLE (ct))
70
71 enum char_table_type
72 {
73 CHAR_TABLE_TYPE_GENERIC,
74 #ifdef MULE
75 CHAR_TABLE_TYPE_CATEGORY,
76 #endif
77 CHAR_TABLE_TYPE_SYNTAX,
78 CHAR_TABLE_TYPE_DISPLAY,
79 CHAR_TABLE_TYPE_CHAR
80 };
81
82 #ifdef MULE
83 #define NUM_ASCII_CHARS 160
84 #else
85 #define NUM_ASCII_CHARS 256
86 #endif
87
88 struct Lisp_Char_Table
89 {
90 struct lcrecord_header header;
91
92 Lisp_Object ascii[NUM_ASCII_CHARS];
93
94 #ifdef MULE
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.
98
99 The current implementation is as follows:
100
101 ascii[0-159] is used for ASCII and Control-1 characters.
102
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.
112
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
118 adding a type to */
119
120 Lisp_Object level1[NUM_LEADING_BYTES];
121
122 #endif /* MULE */
123
124 enum char_table_type type;
125
126 /* stuff used for syntax tables */
127 Lisp_Object mirror_table;
128 Lisp_Object next_table; /* DO NOT mark through this. */
129 };
130
131 #ifdef MULE
132
133 Lisp_Object get_non_ascii_char_table_value (struct Lisp_Char_Table *ct,
134 int leading_byte,
135 Emchar c);
136
137 INLINE Lisp_Object
138 CHAR_TABLE_NON_ASCII_VALUE_UNSAFE (struct Lisp_Char_Table *ct, Emchar ch);
139 INLINE Lisp_Object
140 CHAR_TABLE_NON_ASCII_VALUE_UNSAFE (struct Lisp_Char_Table *ct, Emchar ch)
141 {
142 unsigned char lb = CHAR_LEADING_BYTE (ch);
143 if (!CHAR_TABLE_ENTRYP ((ct)->level1[lb - MIN_LEADING_BYTE]))
144 return (ct)->level1[lb - MIN_LEADING_BYTE];
145 else
146 return get_non_ascii_char_table_value (ct, lb, ch);
147 }
148
149 #define CHAR_TABLE_VALUE_UNSAFE(ct, ch) \
150 ((ch) < NUM_ASCII_CHARS \
151 ? (ct)->ascii[ch] \
152 : CHAR_TABLE_NON_ASCII_VALUE_UNSAFE (ct, ch))
153
154 #else /* not MULE */
155
156 #define CHAR_TABLE_VALUE_UNSAFE(ct, ch) ((ct)->ascii[(unsigned char) (ch)])
157
158 #endif /* not MULE */
159
160 enum chartab_range_type
161 {
162 CHARTAB_RANGE_ALL,
163 #ifdef MULE
164 CHARTAB_RANGE_CHARSET,
165 CHARTAB_RANGE_ROW,
166 #endif
167 CHARTAB_RANGE_CHAR
168 };
169
170 struct chartab_range
171 {
172 enum chartab_range_type type;
173 Emchar ch;
174 Lisp_Object charset;
175 int row;
176 };
177
178 void fill_char_table (struct Lisp_Char_Table *ct, Lisp_Object value);
179 void put_char_table (struct Lisp_Char_Table *ct, struct chartab_range *range,
180 Lisp_Object val);
181 Lisp_Object get_char_table (Emchar, struct Lisp_Char_Table *);
182 int map_char_table (struct Lisp_Char_Table *ct,
183 struct chartab_range *range,
184 int (*fn) (struct chartab_range *range,
185 Lisp_Object val, void *arg),
186 void *arg);
187 void prune_syntax_tables (void);
188
189 EXFUN (Fcopy_char_table, 1);
190 EXFUN (Fmake_char_table, 1);
191 EXFUN (Fput_char_table, 3);
192 EXFUN (Fget_char_table, 2);
193
194 extern Lisp_Object Vall_syntax_tables;
195
196
197
198 #ifdef MULE
199 int check_category_char(Emchar ch, Lisp_Object ctbl,
200 unsigned int designator, unsigned int not);
201
202 extern Lisp_Object Vstandard_category_table;
203
204 #define CATEGORY_DESIGNATORP(x) \
205 (CHARP (x) && XCHAR (x) >= 32 && XCHAR (x) <= 126)
206
207 #define CHECK_CATEGORY_DESIGNATOR(x) do { \
208 if (!CATEGORY_DESIGNATORP (x)) \
209 dead_wrong_type_argument (Qcategory_designator_p, x); \
210 } while (0)
211
212 #define CONCHECK_CATEGORY_DESIGNATOR(x) do { \
213 if (!CATEGORY_DESIGNATORP (x)) \
214 x = wrong_type_argument (Qcategory_designator_p, x); \
215 } while (0)
216
217 #define CATEGORY_TABLE_VALUEP(x) \
218 (NILP (x) || (BIT_VECTORP (x) && (bit_vector_length (XBIT_VECTOR (x)) == 95)))
219
220 #define CHECK_CATEGORY_TABLE_VALUE(x) do { \
221 if (!CATEGORY_TABLE_VALUEP (x)) \
222 dead_wrong_type_argument (Qcategory_table_value_p, x); \
223 } while (0)
224
225 #define CONCHECK_CATEGORY_TABLE_VALUE(x) do { \
226 if (!CATEGORY_TABLE_VALUEP (x)) \
227 x = wrong_type_argument (Qcategory_table_value_p, x); \
228 } while (0)
229
230 #endif /* MULE */
231
232 #endif /* _MULE_CHARTAB_H */