Mercurial > hg > xemacs-beta
comparison src/specifier.h @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 3d6bfa290dbd |
children | 6330739388db |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
42 unsigned long (*hash_method) (Lisp_Object specifier, int depth); | 42 unsigned long (*hash_method) (Lisp_Object specifier, int depth); |
43 | 43 |
44 /* Validate method: Given an instantiator, verify that it's | 44 /* Validate method: Given an instantiator, verify that it's |
45 valid for this specifier type. If not, signal an error. | 45 valid for this specifier type. If not, signal an error. |
46 | 46 |
47 If this functions is not present, all instantiators are | 47 If this function is not present, all instantiators are |
48 considered valid. */ | 48 considered valid. */ |
49 void (*validate_method) (Lisp_Object instantiator); | 49 void (*validate_method) (Lisp_Object instantiator); |
50 | 50 |
51 /* Validate-matchspec method: Given a matchspec, verify that it's | 51 /* Validate-matchspec method: Given a matchspec, verify that it's |
52 valid for this specifier type. If not, signal an error. | 52 valid for this specifier type. If not, signal an error. |
53 | 53 |
54 If this functions is not present, *no* matchspecs are considered | 54 If this function is not present, *no* matchspecs are considered |
55 valid. Note that this differs from validate_method(). */ | 55 valid. Note that this differs from validate_method(). */ |
56 void (*validate_matchspec_method) (Lisp_Object matchspec); | 56 void (*validate_matchspec_method) (Lisp_Object matchspec); |
57 | 57 |
58 /* Instantiate method */ | 58 /* Instantiate method */ |
59 Lisp_Object (*instantiate_method) (Lisp_Object specifier, | 59 Lisp_Object (*instantiate_method) (Lisp_Object specifier, |
96 Lisp_Object next_specifier; | 96 Lisp_Object next_specifier; |
97 | 97 |
98 /* This is a straight list of instantiators. */ | 98 /* This is a straight list of instantiators. */ |
99 Lisp_Object global_specs; | 99 Lisp_Object global_specs; |
100 | 100 |
101 /* These are all assoc lists where the key is type of object the | 101 /* These are all assoc lists where the key is the type of object the |
102 list represents (buffer, window, etc.) and the associated list is | 102 list represents (buffer, window, etc.) and the associated list is |
103 the actual list of instantiators. */ | 103 the actual list of instantiators. */ |
104 Lisp_Object device_specs; | 104 Lisp_Object device_specs; |
105 Lisp_Object frame_specs; | 105 Lisp_Object frame_specs; |
106 /* window_specs is actually a key-assoc weak list. See specifier.c | 106 /* window_specs is actually a key-assoc weak list. See specifier.c |
128 | 128 |
129 #define RAW_SPECMETH(sp, m) ((sp)->methods->m##_method) | 129 #define RAW_SPECMETH(sp, m) ((sp)->methods->m##_method) |
130 #define HAS_SPECMETH_P(sp, m) (!!RAW_SPECMETH (sp, m)) | 130 #define HAS_SPECMETH_P(sp, m) (!!RAW_SPECMETH (sp, m)) |
131 #define SPECMETH(sp, m, args) (((sp)->methods->m##_method) args) | 131 #define SPECMETH(sp, m, args) (((sp)->methods->m##_method) args) |
132 | 132 |
133 /* Call a void-returning specifier method, if it exists */ | 133 /* Call a void-returning specifier method, if it exists. */ |
134 #define MAYBE_SPECMETH(sp, m, args) \ | 134 #define MAYBE_SPECMETH(sp, m, args) do { \ |
135 do { \ | 135 struct Lisp_Specifier *_maybe_specmeth_sp = (sp); \ |
136 struct Lisp_Specifier *_maybe_specmeth_sp = (sp); \ | 136 if (HAS_SPECMETH_P (_maybe_specmeth_sp, m)) \ |
137 if (HAS_SPECMETH_P (_maybe_specmeth_sp, m)) \ | 137 SPECMETH (_maybe_specmeth_sp, m, args); \ |
138 SPECMETH (_maybe_specmeth_sp, m, args); \ | 138 } while (0) |
139 } while (0) | |
140 | |
141 MAC_DECLARE_EXTERN (struct Lisp_Specifier *, MTspecmeth_or_given) | |
142 | |
143 /* Call a specifier method, if it exists; otherwise return | |
144 the specified value */ | |
145 | |
146 #define SPECMETH_OR_GIVEN(sp, m, args, given) \ | |
147 MAC_BEGIN \ | |
148 MAC_DECLARE (struct Lisp_Specifier *, MTspecmeth_or_given, sp) \ | |
149 HAS_SPECMETH_P (MTspecmeth_or_given, m) ? \ | |
150 SPECMETH (MTspecmeth_or_given, m, args) : (given) \ | |
151 MAC_END | |
152 | 139 |
153 /***** Defining new specifier types *****/ | 140 /***** Defining new specifier types *****/ |
154 | 141 |
155 #define DECLARE_SPECIFIER_TYPE(type) \ | 142 #ifdef ERROR_CHECK_TYPECHECK |
143 #define DECLARE_SPECIFIER_TYPE(type) \ | |
144 extern struct specifier_methods * type##_specifier_methods; \ | |
145 INLINE struct type##_specifier * \ | |
146 error_check_##type##_specifier_data (struct Lisp_Specifier *sp); \ | |
147 INLINE struct type##_specifier * \ | |
148 error_check_##type##_specifier_data (struct Lisp_Specifier *sp) \ | |
149 { \ | |
150 assert (SPECIFIER_TYPE_P (sp, type)); \ | |
151 return (struct type##_specifier *) sp->data; \ | |
152 } \ | |
153 DECLARE_NOTHING | |
154 #else | |
155 #define DECLARE_SPECIFIER_TYPE(type) \ | |
156 extern struct specifier_methods * type##_specifier_methods | 156 extern struct specifier_methods * type##_specifier_methods |
157 | 157 #endif /* ERROR_CHECK_TYPECHECK */ |
158 #define DEFINE_SPECIFIER_TYPE(type) \ | 158 |
159 #define DEFINE_SPECIFIER_TYPE(type) \ | |
159 struct specifier_methods * type##_specifier_methods | 160 struct specifier_methods * type##_specifier_methods |
160 | 161 |
161 #define INITIALIZE_SPECIFIER_TYPE(type, obj_name, pred_sym) do { \ | 162 #define INITIALIZE_SPECIFIER_TYPE(type, obj_name, pred_sym) do { \ |
162 type##_specifier_methods = xnew_and_zero (struct specifier_methods); \ | 163 type##_specifier_methods = xnew_and_zero (struct specifier_methods); \ |
163 type##_specifier_methods->name = obj_name; \ | 164 type##_specifier_methods->name = obj_name; \ |
164 defsymbol (&type##_specifier_methods->predicate_symbol, pred_sym); \ | 165 defsymbol (&type##_specifier_methods->predicate_symbol, pred_sym); \ |
165 add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \ | 166 add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \ |
166 } while (0) \ | 167 } while (0) |
167 | 168 |
168 #define INITIALIZE_SPECIFIER_TYPE_WITH_DATA(type, obj_name, pred_sym) \ | 169 #define INITIALIZE_SPECIFIER_TYPE_WITH_DATA(type, obj_name, pred_sym) \ |
169 do { \ | 170 do { \ |
170 INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym); \ | 171 INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym); \ |
171 type##_specifier_methods->extra_data_size = \ | 172 type##_specifier_methods->extra_data_size = \ |
172 sizeof (struct type##_specifier); \ | 173 sizeof (struct type##_specifier); \ |
173 } while (0) | 174 } while (0) |
174 | 175 |
175 /* Declare that specifier-type TYPE has method M; used in | 176 /* Declare that specifier-type TYPE has method METH; used in |
176 initialization routines */ | 177 initialization routines */ |
177 #define SPECIFIER_HAS_METHOD(type, m) \ | 178 #define SPECIFIER_HAS_METHOD(type, meth) \ |
178 (type##_specifier_methods->m##_method = type##_##m) | 179 (type##_specifier_methods->meth##_method = type##_##meth) |
179 | 180 |
180 /***** Macros for accessing specifier types *****/ | 181 /***** Macros for accessing specifier types *****/ |
181 | 182 |
182 #define SPECIFIER_TYPE_P(sp, type) \ | 183 #define SPECIFIER_TYPE_P(sp, type) \ |
183 ((sp)->methods == type##_specifier_methods) | 184 ((sp)->methods == type##_specifier_methods) |
184 | 185 |
185 #ifdef ERROR_CHECK_TYPECHECK | 186 #ifdef ERROR_CHECK_TYPECHECK |
186 MAC_DECLARE_EXTERN (struct Lisp_Specifier *, MTspecifier_data) | 187 # define SPECIFIER_TYPE_DATA(sp, type) \ |
187 # define SPECIFIER_TYPE_DATA(sp, type) \ | 188 error_check_##type##_specifier_data (sp) |
188 MAC_BEGIN \ | |
189 MAC_DECLARE (struct Lisp_Specifier *, MTspecifier_data, sp) \ | |
190 assert (SPECIFIER_TYPE_P (MTspecifier_data, type)) \ | |
191 MAC_SEP \ | |
192 (struct type##_specifier *) MTspecifier_data->data \ | |
193 MAC_END | |
194 #else | 189 #else |
195 # define SPECIFIER_TYPE_DATA(sp, type) \ | 190 # define SPECIFIER_TYPE_DATA(sp, type) \ |
196 ((struct type##_specifier *) (sp)->data) | 191 ((struct type##_specifier *) (sp)->data) |
197 #endif | 192 #endif |
198 | 193 |
199 /* #### Need to create ERROR_CHECKING versions of these. */ | 194 /* #### Need to create ERROR_CHECKING versions of these. */ |
200 | 195 |
201 #define XSPECIFIER_TYPE(x, type) XSPECIFIER (x) | 196 #define XSPECIFIER_TYPE(x, type) XSPECIFIER (x) |
202 #define XSETSPECIFIER_TYPE(x, p, type) XSETSPECIFIER (x, p) | 197 #define XSETSPECIFIER_TYPE(x, p, type) XSETSPECIFIER (x, p) |
203 #define SPECIFIER_TYPEP(x, type) \ | 198 #define SPECIFIER_TYPEP(x, type) \ |
204 (SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), type)) | 199 (SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), type)) |
205 #define CHECK_SPECIFIER_TYPE(x, type) \ | 200 #define CHECK_SPECIFIER_TYPE(x, type) do { \ |
206 do { \ | 201 CHECK_SPECIFIER (x); \ |
207 CHECK_SPECIFIER (x); \ | 202 if (!SPECIFIER_TYPE_P (XSPECIFIER (x), type)) \ |
208 if (!(SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), \ | 203 dead_wrong_type_argument \ |
209 type))) \ | 204 (type##_specifier_methods->predicate_symbol, x); \ |
210 dead_wrong_type_argument \ | 205 } while (0) |
211 (type##_specifier_methods->predicate_symbol, x); \ | 206 #define CONCHECK_SPECIFIER_TYPE(x, type) do { \ |
212 } while (0) | 207 CONCHECK_SPECIFIER (x); \ |
213 #define CONCHECK_SPECIFIER_TYPE(x, type) \ | 208 if (!(SPECIFIER_TYPEP (x, type))) \ |
214 do { \ | 209 x = wrong_type_argument \ |
215 CONCHECK_SPECIFIER (x); \ | 210 (type##_specifier_methods->predicate_symbol, x); \ |
216 if (!(SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), \ | 211 } while (0) |
217 type))) \ | |
218 x = wrong_type_argument \ | |
219 (type##_specifier_methods->predicate_symbol, x); \ | |
220 } while (0) | |
221 | 212 |
222 /***** Miscellaneous structures *****/ | 213 /***** Miscellaneous structures *****/ |
223 | 214 |
224 enum spec_locale_type | 215 enum spec_locale_type |
225 { | 216 { |
249 int offset_into_struct_frame; | 240 int offset_into_struct_frame; |
250 void (*value_changed_in_frame) (Lisp_Object specifier, struct frame *f, | 241 void (*value_changed_in_frame) (Lisp_Object specifier, struct frame *f, |
251 Lisp_Object oldval); | 242 Lisp_Object oldval); |
252 }; | 243 }; |
253 | 244 |
254 extern Lisp_Object decode_locale (Lisp_Object locale); | 245 EXFUN (Fcopy_specifier, 6); |
255 extern Lisp_Object decode_locale_list (Lisp_Object locale); | 246 EXFUN (Fmake_specifier, 1); |
256 extern Lisp_Object decode_domain (Lisp_Object domain); | 247 EXFUN (Fset_specifier_dirty_flag, 1); |
248 EXFUN (Fspecifier_instance, 4); | |
249 EXFUN (Fvalid_specifier_locale_p, 1); | |
250 | |
251 extern Lisp_Object Qfallback, Qnatnum; | |
252 | |
253 Lisp_Object decode_locale_list (Lisp_Object locale); | |
257 extern enum spec_add_meth | 254 extern enum spec_add_meth |
258 decode_how_to_add_specification (Lisp_Object how_to_add); | 255 decode_how_to_add_specification (Lisp_Object how_to_add); |
259 extern Lisp_Object decode_specifier_tag_set (Lisp_Object tag_set); | 256 Lisp_Object decode_specifier_tag_set (Lisp_Object tag_set); |
260 | 257 |
261 extern void add_entry_to_specifier_type_list (Lisp_Object symbol, | 258 void add_entry_to_specifier_type_list (Lisp_Object symbol, |
262 struct specifier_methods *meths); | 259 struct specifier_methods *meths); |
263 extern void set_specifier_caching (Lisp_Object specifier, | 260 void set_specifier_caching (Lisp_Object specifier, |
264 int struct_window_offset, | 261 int struct_window_offset, |
265 void (*value_changed_in_window) | 262 void (*value_changed_in_window) |
266 (Lisp_Object specifier, struct window *w, | 263 (Lisp_Object specifier, struct window *w, |
267 Lisp_Object oldval), | 264 Lisp_Object oldval), |
268 int struct_frame_offset, | 265 int struct_frame_offset, |
269 void (*value_changed_in_frame) | 266 void (*value_changed_in_frame) |
270 (Lisp_Object specifier, struct frame *f, | 267 (Lisp_Object specifier, struct frame *f, |
271 Lisp_Object oldval)); | 268 Lisp_Object oldval)); |
272 extern void set_specifier_fallback (Lisp_Object specifier, | 269 void set_specifier_fallback (Lisp_Object specifier, |
273 Lisp_Object fallback); | 270 Lisp_Object fallback); |
274 extern void recompute_all_cached_specifiers_in_window (struct window *w); | 271 void recompute_all_cached_specifiers_in_window (struct window *w); |
275 extern void recompute_all_cached_specifiers_in_frame (struct frame *f); | 272 void recompute_all_cached_specifiers_in_frame (struct frame *f); |
276 | 273 |
277 extern void cleanup_specifiers (void); | 274 void cleanup_specifiers (void); |
278 extern void prune_specifiers (int (*obj_marked_p) (Lisp_Object)); | 275 void prune_specifiers (int (*obj_marked_p) (Lisp_Object)); |
279 extern void setup_device_initial_specifier_tags (struct device *d); | 276 void setup_device_initial_specifier_tags (struct device *d); |
280 void kill_specifier_buffer_locals (Lisp_Object buffer); | 277 void kill_specifier_buffer_locals (Lisp_Object buffer); |
281 | 278 |
282 DECLARE_SPECIFIER_TYPE (generic); | 279 DECLARE_SPECIFIER_TYPE (generic); |
283 #define XGENERIC_SPECIFIER(x) XSPECIFIER_TYPE (x, generic) | 280 #define XGENERIC_SPECIFIER(x) XSPECIFIER_TYPE (x, generic) |
284 #define XSETGENERIC_SPECIFIER(x, p) XSETSPECIFIER_TYPE (x, p, generic) | 281 #define XSETGENERIC_SPECIFIER(x, p) XSETSPECIFIER_TYPE (x, p, generic) |