comparison src/specifier.h @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 697ef44129c6
children
comparison
equal deleted inserted replaced
423:28d9c139be4c 424:11054d720c21
81 4. All specifiers are added to Vall_specifiers list, both bodily and 81 4. All specifiers are added to Vall_specifiers list, both bodily and
82 ghost. The pair of objects is always removed from the list at the 82 ghost. The pair of objects is always removed from the list at the
83 same time. 83 same time.
84 */ 84 */
85 85
86 extern const struct struct_description specifier_methods_description;
87
86 struct specifier_methods 88 struct specifier_methods
87 { 89 {
88 CONST char *name; 90 CONST char *name;
89 Lisp_Object predicate_symbol; 91 Lisp_Object predicate_symbol;
90 92
93 /* Create method: Initialize specifier data. Optional. */ 95 /* Create method: Initialize specifier data. Optional. */
94 void (*create_method) (Lisp_Object specifier); 96 void (*create_method) (Lisp_Object specifier);
95 97
96 /* Mark method: Mark any lisp object within specifier data 98 /* Mark method: Mark any lisp object within specifier data
97 structure. Not required if no specifier data are Lisp_Objects. */ 99 structure. Not required if no specifier data are Lisp_Objects. */
98 void (*mark_method) (Lisp_Object specifier, void (*markobj) (Lisp_Object)); 100 void (*mark_method) (Lisp_Object specifier);
99 101
100 /* Equal method: Compare two specifiers. This is called after 102 /* Equal method: Compare two specifiers. This is called after
101 ensuring that the two specifiers are of the same type, and have 103 ensuring that the two specifiers are of the same type, and have
102 the same specs. Quit is inhibited during the call so it is safe 104 the same specs. Quit is inhibited during the call so it is safe
103 to call internal_equal(). 105 to call internal_equal().
183 185
184 #### Do not still know if this can safely eval. */ 186 #### Do not still know if this can safely eval. */
185 void (*after_change_method) (Lisp_Object specifier, 187 void (*after_change_method) (Lisp_Object specifier,
186 Lisp_Object locale); 188 Lisp_Object locale);
187 189
190 const struct lrecord_description *extra_description;
188 int extra_data_size; 191 int extra_data_size;
189 }; 192 };
190 193
191 struct Lisp_Specifier 194 struct Lisp_Specifier
192 { 195 {
230 233
231 DECLARE_LRECORD (specifier, struct Lisp_Specifier); 234 DECLARE_LRECORD (specifier, struct Lisp_Specifier);
232 #define XSPECIFIER(x) XRECORD (x, specifier, struct Lisp_Specifier) 235 #define XSPECIFIER(x) XRECORD (x, specifier, struct Lisp_Specifier)
233 #define XSETSPECIFIER(x, p) XSETRECORD (x, p, specifier) 236 #define XSETSPECIFIER(x, p) XSETRECORD (x, p, specifier)
234 #define SPECIFIERP(x) RECORDP (x, specifier) 237 #define SPECIFIERP(x) RECORDP (x, specifier)
235 #define GC_SPECIFIERP(x) GC_RECORDP (x, specifier)
236 #define CHECK_SPECIFIER(x) CHECK_RECORD (x, specifier) 238 #define CHECK_SPECIFIER(x) CHECK_RECORD (x, specifier)
237 #define CONCHECK_SPECIFIER(x) CONCHECK_RECORD (x, specifier) 239 #define CONCHECK_SPECIFIER(x) CONCHECK_RECORD (x, specifier)
238 240
239 /***** Calling a specifier method *****/ 241 /***** Calling a specifier method *****/
240 242
248 if (HAS_SPECMETH_P (maybe_specmeth_sp, m)) \ 250 if (HAS_SPECMETH_P (maybe_specmeth_sp, m)) \
249 SPECMETH (maybe_specmeth_sp, m, args); \ 251 SPECMETH (maybe_specmeth_sp, m, args); \
250 } while (0) 252 } while (0)
251 253
252 /***** Defining new specifier types *****/ 254 /***** Defining new specifier types *****/
255
256 #define specifier_data_offset (offsetof(struct Lisp_Specifier, data))
257 extern const struct lrecord_description specifier_empty_extra_description[];
253 258
254 #ifdef ERROR_CHECK_TYPECHECK 259 #ifdef ERROR_CHECK_TYPECHECK
255 #define DECLARE_SPECIFIER_TYPE(type) \ 260 #define DECLARE_SPECIFIER_TYPE(type) \
256 extern struct specifier_methods * type##_specifier_methods; \ 261 extern struct specifier_methods * type##_specifier_methods; \
257 INLINE struct type##_specifier * \ 262 INLINE struct type##_specifier * \
277 282
278 #define DEFINE_SPECIFIER_TYPE(type) \ 283 #define DEFINE_SPECIFIER_TYPE(type) \
279 struct specifier_methods * type##_specifier_methods 284 struct specifier_methods * type##_specifier_methods
280 285
281 #define INITIALIZE_SPECIFIER_TYPE(type, obj_name, pred_sym) do { \ 286 #define INITIALIZE_SPECIFIER_TYPE(type, obj_name, pred_sym) do { \
282 type##_specifier_methods = xnew_and_zero (struct specifier_methods); \ 287 type##_specifier_methods = xnew_and_zero (struct specifier_methods); \
283 type##_specifier_methods->name = obj_name; \ 288 type##_specifier_methods->name = obj_name; \
284 defsymbol (&type##_specifier_methods->predicate_symbol, pred_sym); \ 289 type##_specifier_methods->extra_description = \
285 add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \ 290 specifier_empty_extra_description; \
291 defsymbol_nodump (&type##_specifier_methods->predicate_symbol, pred_sym); \
292 add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \
293 dumpstruct (&type##_specifier_methods, &specifier_methods_description); \
294 } while (0)
295
296 #define REINITIALIZE_SPECIFIER_TYPE(type) do { \
297 staticpro_nodump (&type##_specifier_methods->predicate_symbol); \
286 } while (0) 298 } while (0)
287 299
288 #define INITIALIZE_SPECIFIER_TYPE_WITH_DATA(type, obj_name, pred_sym) \ 300 #define INITIALIZE_SPECIFIER_TYPE_WITH_DATA(type, obj_name, pred_sym) \
289 do { \ 301 do { \
290 INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym); \ 302 INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym); \
291 type##_specifier_methods->extra_data_size = \ 303 type##_specifier_methods->extra_data_size = \
292 sizeof (struct type##_specifier); \ 304 sizeof (struct type##_specifier); \
305 type##_specifier_methods->extra_description = \
306 type##_specifier_description; \
293 } while (0) 307 } while (0)
294 308
295 /* Declare that specifier-type TYPE has method METH; used in 309 /* Declare that specifier-type TYPE has method METH; used in
296 initialization routines */ 310 initialization routines */
297 #define SPECIFIER_HAS_METHOD(type, meth) \ 311 #define SPECIFIER_HAS_METHOD(type, meth) \
301 315
302 #define SPECIFIER_TYPE_P(sp, type) \ 316 #define SPECIFIER_TYPE_P(sp, type) \
303 ((sp)->methods == type##_specifier_methods) 317 ((sp)->methods == type##_specifier_methods)
304 318
305 /* Any of the two of the magic spec */ 319 /* Any of the two of the magic spec */
306 #define MAGIC_SPECIFIER_P(sp) \ 320 #define MAGIC_SPECIFIER_P(sp) (!NILP((sp)->magic_parent))
307 (!NILP((sp)->magic_parent))
308 /* Normal part of the magic specifier */ 321 /* Normal part of the magic specifier */
309 #define BODILY_SPECIFIER_P(sp) \ 322 #define BODILY_SPECIFIER_P(sp) EQ ((sp)->magic_parent, Qt)
310 (EQ ((sp)->magic_parent, Qt))
311 /* Ghost part of the magic specifier */ 323 /* Ghost part of the magic specifier */
312 #define GHOST_SPECIFIER_P(sp) \ 324 #define GHOST_SPECIFIER_P(sp) SPECIFIERP((sp)->magic_parent)
313 (SPECIFIERP((sp)->magic_parent)) 325
314 /* The same three, when used in GC */ 326 #define GHOST_SPECIFIER(sp) XSPECIFIER ((sp)->fallback)
315 #define GC_MAGIC_SPECIFIER_P(sp) \
316 (!GC_NILP((sp)->magic_parent))
317 #define GC_BODILY_SPECIFIER_P(sp) \
318 (GC_EQ ((sp)->magic_parent, Qt))
319 #define GC_GHOST_SPECIFIER_P(sp) \
320 (GC_SPECIFIERP((sp)->magic_parent))
321
322 #define GHOST_SPECIFIER(sp) \
323 (XSPECIFIER ((sp)->fallback))
324 327
325 #ifdef ERROR_CHECK_TYPECHECK 328 #ifdef ERROR_CHECK_TYPECHECK
326 # define SPECIFIER_TYPE_DATA(sp, type) \ 329 # define SPECIFIER_TYPE_DATA(sp, type) \
327 error_check_##type##_specifier_data (sp) 330 error_check_##type##_specifier_data (sp)
328 #else 331 #else
423 Lisp_Object tag_set, Lisp_Object exact_p); 426 Lisp_Object tag_set, Lisp_Object exact_p);
424 427
425 int unlock_ghost_specifiers_protected (void); 428 int unlock_ghost_specifiers_protected (void);
426 429
427 void cleanup_specifiers (void); 430 void cleanup_specifiers (void);
428 void prune_specifiers (int (*obj_marked_p) (Lisp_Object)); 431 void prune_specifiers (void);
429 void setup_device_initial_specifier_tags (struct device *d); 432 void setup_device_initial_specifier_tags (struct device *d);
430 void kill_specifier_buffer_locals (Lisp_Object buffer); 433 void kill_specifier_buffer_locals (Lisp_Object buffer);
431 434
432 DECLARE_SPECIFIER_TYPE (generic); 435 DECLARE_SPECIFIER_TYPE (generic);
433 #define XGENERIC_SPECIFIER(x) XSPECIFIER_TYPE (x, generic) 436 #define XGENERIC_SPECIFIER(x) XSPECIFIER_TYPE (x, generic)