Mercurial > hg > xemacs-beta
comparison src/specifier.c @ 424:11054d720c21 r21-2-20
Import from CVS: tag r21-2-20
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:26:11 +0200 |
parents | 41dbb7a9d5f2 |
children |
comparison
equal
deleted
inserted
replaced
423:28d9c139be4c | 424:11054d720c21 |
---|---|
62 typedef struct | 62 typedef struct |
63 { | 63 { |
64 Dynarr_declare (specifier_type_entry); | 64 Dynarr_declare (specifier_type_entry); |
65 } specifier_type_entry_dynarr; | 65 } specifier_type_entry_dynarr; |
66 | 66 |
67 specifier_type_entry_dynarr *the_specifier_type_entry_dynarr; | 67 static specifier_type_entry_dynarr *the_specifier_type_entry_dynarr; |
68 | |
69 static const struct lrecord_description ste_description_1[] = { | |
70 { XD_LISP_OBJECT, offsetof(specifier_type_entry, symbol), 1 }, | |
71 { XD_STRUCT_PTR, offsetof(specifier_type_entry, meths), 1, &specifier_methods_description }, | |
72 { XD_END } | |
73 }; | |
74 | |
75 static const struct struct_description ste_description = { | |
76 sizeof(specifier_type_entry), | |
77 ste_description_1 | |
78 }; | |
79 | |
80 static const struct lrecord_description sted_description_1[] = { | |
81 XD_DYNARR_DESC(specifier_type_entry_dynarr, &ste_description), | |
82 { XD_END } | |
83 }; | |
84 | |
85 static const struct struct_description sted_description = { | |
86 sizeof(specifier_type_entry_dynarr), | |
87 sted_description_1 | |
88 }; | |
68 | 89 |
69 static Lisp_Object Vspecifier_type_list; | 90 static Lisp_Object Vspecifier_type_list; |
70 | 91 |
71 static Lisp_Object Vcached_specifiers; | 92 static Lisp_Object Vcached_specifiers; |
72 /* Do NOT mark through this, or specifiers will never be GC'd. */ | 93 /* Do NOT mark through this, or specifiers will never be GC'd. */ |
178 Fremove_specifier (rest, buffer, Qnil, Qnil); | 199 Fremove_specifier (rest, buffer, Qnil, Qnil); |
179 } | 200 } |
180 } | 201 } |
181 | 202 |
182 static Lisp_Object | 203 static Lisp_Object |
183 mark_specifier (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 204 mark_specifier (Lisp_Object obj) |
184 { | 205 { |
185 struct Lisp_Specifier *specifier = XSPECIFIER (obj); | 206 struct Lisp_Specifier *specifier = XSPECIFIER (obj); |
186 | 207 |
187 markobj (specifier->global_specs); | 208 mark_object (specifier->global_specs); |
188 markobj (specifier->device_specs); | 209 mark_object (specifier->device_specs); |
189 markobj (specifier->frame_specs); | 210 mark_object (specifier->frame_specs); |
190 markobj (specifier->window_specs); | 211 mark_object (specifier->window_specs); |
191 markobj (specifier->buffer_specs); | 212 mark_object (specifier->buffer_specs); |
192 markobj (specifier->magic_parent); | 213 mark_object (specifier->magic_parent); |
193 markobj (specifier->fallback); | 214 mark_object (specifier->fallback); |
194 if (!GHOST_SPECIFIER_P (XSPECIFIER (obj))) | 215 if (!GHOST_SPECIFIER_P (XSPECIFIER (obj))) |
195 MAYBE_SPECMETH (specifier, mark, (obj, markobj)); | 216 MAYBE_SPECMETH (specifier, mark, (obj)); |
196 return Qnil; | 217 return Qnil; |
197 } | 218 } |
198 | 219 |
199 /* The idea here is that the specifier specs point to locales | 220 /* The idea here is that the specifier specs point to locales |
200 (windows, buffers, frames, and devices), and we want to make sure | 221 (windows, buffers, frames, and devices), and we want to make sure |
214 We now use weak lists for this purpose. | 235 We now use weak lists for this purpose. |
215 | 236 |
216 */ | 237 */ |
217 | 238 |
218 void | 239 void |
219 prune_specifiers (int (*obj_marked_p) (Lisp_Object)) | 240 prune_specifiers (void) |
220 { | 241 { |
221 Lisp_Object rest, prev = Qnil; | 242 Lisp_Object rest, prev = Qnil; |
222 | 243 |
223 for (rest = Vall_specifiers; | 244 for (rest = Vall_specifiers; |
224 !GC_NILP (rest); | 245 !NILP (rest); |
225 rest = XSPECIFIER (rest)->next_specifier) | 246 rest = XSPECIFIER (rest)->next_specifier) |
226 { | 247 { |
227 if (! obj_marked_p (rest)) | 248 if (! marked_p (rest)) |
228 { | 249 { |
229 struct Lisp_Specifier* sp = XSPECIFIER (rest); | 250 struct Lisp_Specifier* sp = XSPECIFIER (rest); |
230 /* A bit of assertion that we're removing both parts of the | 251 /* A bit of assertion that we're removing both parts of the |
231 magic one altogether */ | 252 magic one altogether */ |
232 assert (!GC_MAGIC_SPECIFIER_P(sp) | 253 assert (!MAGIC_SPECIFIER_P(sp) |
233 || (GC_BODILY_SPECIFIER_P(sp) && obj_marked_p (sp->fallback)) | 254 || (BODILY_SPECIFIER_P(sp) && marked_p (sp->fallback)) |
234 || (GC_GHOST_SPECIFIER_P(sp) && obj_marked_p (sp->magic_parent))); | 255 || (GHOST_SPECIFIER_P(sp) && marked_p (sp->magic_parent))); |
235 /* This specifier is garbage. Remove it from the list. */ | 256 /* This specifier is garbage. Remove it from the list. */ |
236 if (GC_NILP (prev)) | 257 if (NILP (prev)) |
237 Vall_specifiers = sp->next_specifier; | 258 Vall_specifiers = sp->next_specifier; |
238 else | 259 else |
239 XSPECIFIER (prev)->next_specifier = sp->next_specifier; | 260 XSPECIFIER (prev)->next_specifier = sp->next_specifier; |
240 } | 261 } |
241 else | 262 else |
278 static void | 299 static void |
279 finalize_specifier (void *header, int for_disksave) | 300 finalize_specifier (void *header, int for_disksave) |
280 { | 301 { |
281 struct Lisp_Specifier *sp = (struct Lisp_Specifier *) header; | 302 struct Lisp_Specifier *sp = (struct Lisp_Specifier *) header; |
282 /* don't be snafued by the disksave finalization. */ | 303 /* don't be snafued by the disksave finalization. */ |
283 if (!for_disksave && !GC_GHOST_SPECIFIER_P(sp) && sp->caching) | 304 if (!for_disksave && !GHOST_SPECIFIER_P(sp) && sp->caching) |
284 { | 305 { |
285 xfree (sp->caching); | 306 xfree (sp->caching); |
286 sp->caching = 0; | 307 sp->caching = 0; |
287 } | 308 } |
288 } | 309 } |
334 | 355 |
335 static size_t | 356 static size_t |
336 sizeof_specifier (CONST void *header) | 357 sizeof_specifier (CONST void *header) |
337 { | 358 { |
338 if (GHOST_SPECIFIER_P ((struct Lisp_Specifier *) header)) | 359 if (GHOST_SPECIFIER_P ((struct Lisp_Specifier *) header)) |
339 return sizeof (struct Lisp_Specifier); | 360 return offsetof (struct Lisp_Specifier, data); |
340 else | 361 else |
341 { | 362 { |
342 CONST struct Lisp_Specifier *p = (CONST struct Lisp_Specifier *) header; | 363 CONST struct Lisp_Specifier *p = (CONST struct Lisp_Specifier *) header; |
343 return sizeof (*p) + p->methods->extra_data_size - 1; | 364 return offsetof (struct Lisp_Specifier, data) + p->methods->extra_data_size; |
344 } | 365 } |
345 } | 366 } |
367 | |
368 static const struct lrecord_description specifier_methods_description_1[] = { | |
369 { XD_LISP_OBJECT, offsetof(struct specifier_methods, predicate_symbol), 1 }, | |
370 { XD_END } | |
371 }; | |
372 | |
373 const struct struct_description specifier_methods_description = { | |
374 sizeof(struct specifier_methods), | |
375 specifier_methods_description_1 | |
376 }; | |
377 | |
378 static const struct lrecord_description specifier_caching_description_1[] = { | |
379 { XD_END } | |
380 }; | |
381 | |
382 static const struct struct_description specifier_caching_description = { | |
383 sizeof(struct specifier_caching), | |
384 specifier_caching_description_1 | |
385 }; | |
386 | |
387 static const struct lrecord_description specifier_description[] = { | |
388 { XD_STRUCT_PTR, offsetof(struct Lisp_Specifier, methods), 1, &specifier_methods_description }, | |
389 { XD_LO_LINK, offsetof(struct Lisp_Specifier, next_specifier) }, | |
390 { XD_LISP_OBJECT, offsetof(struct Lisp_Specifier, global_specs), 5 }, | |
391 { XD_STRUCT_PTR, offsetof(struct Lisp_Specifier, caching), 1, &specifier_caching_description }, | |
392 { XD_LISP_OBJECT, offsetof(struct Lisp_Specifier, magic_parent), 2 }, | |
393 { XD_SPECIFIER_END } | |
394 }; | |
395 | |
396 const struct lrecord_description specifier_empty_extra_description[] = { | |
397 { XD_END } | |
398 }; | |
346 | 399 |
347 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("specifier", specifier, | 400 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("specifier", specifier, |
348 mark_specifier, print_specifier, | 401 mark_specifier, print_specifier, |
349 finalize_specifier, | 402 finalize_specifier, |
350 specifier_equal, specifier_hash, 0, | 403 specifier_equal, specifier_hash, |
404 specifier_description, | |
351 sizeof_specifier, | 405 sizeof_specifier, |
352 struct Lisp_Specifier); | 406 struct Lisp_Specifier); |
353 | 407 |
354 /************************************************************************/ | 408 /************************************************************************/ |
355 /* Creating specifiers */ | 409 /* Creating specifiers */ |
412 make_specifier_internal (struct specifier_methods *spec_meths, | 466 make_specifier_internal (struct specifier_methods *spec_meths, |
413 size_t data_size, int call_create_meth) | 467 size_t data_size, int call_create_meth) |
414 { | 468 { |
415 Lisp_Object specifier; | 469 Lisp_Object specifier; |
416 struct Lisp_Specifier *sp = (struct Lisp_Specifier *) | 470 struct Lisp_Specifier *sp = (struct Lisp_Specifier *) |
417 alloc_lcrecord (sizeof (struct Lisp_Specifier) + | 471 alloc_lcrecord (offsetof (struct Lisp_Specifier, data) + |
418 data_size - 1, &lrecord_specifier); | 472 data_size, &lrecord_specifier); |
419 | 473 |
420 sp->methods = spec_meths; | 474 sp->methods = spec_meths; |
421 sp->global_specs = Qnil; | 475 sp->global_specs = Qnil; |
422 sp->device_specs = Qnil; | 476 sp->device_specs = Qnil; |
423 sp->frame_specs = Qnil; | 477 sp->frame_specs = Qnil; |
3123 | 3177 |
3124 void | 3178 void |
3125 specifier_type_create (void) | 3179 specifier_type_create (void) |
3126 { | 3180 { |
3127 the_specifier_type_entry_dynarr = Dynarr_new (specifier_type_entry); | 3181 the_specifier_type_entry_dynarr = Dynarr_new (specifier_type_entry); |
3182 dumpstruct (&the_specifier_type_entry_dynarr, &sted_description); | |
3128 | 3183 |
3129 Vspecifier_type_list = Qnil; | 3184 Vspecifier_type_list = Qnil; |
3130 staticpro (&Vspecifier_type_list); | 3185 staticpro (&Vspecifier_type_list); |
3131 | 3186 |
3132 INITIALIZE_SPECIFIER_TYPE (generic, "generic", "generic-specifier-p"); | 3187 INITIALIZE_SPECIFIER_TYPE (generic, "generic", "generic-specifier-p"); |
3144 SPECIFIER_HAS_METHOD (boolean, validate); | 3199 SPECIFIER_HAS_METHOD (boolean, validate); |
3145 | 3200 |
3146 INITIALIZE_SPECIFIER_TYPE (display_table, "display-table", "display-table-p"); | 3201 INITIALIZE_SPECIFIER_TYPE (display_table, "display-table", "display-table-p"); |
3147 | 3202 |
3148 SPECIFIER_HAS_METHOD (display_table, validate); | 3203 SPECIFIER_HAS_METHOD (display_table, validate); |
3204 } | |
3205 | |
3206 void | |
3207 reinit_specifier_type_create (void) | |
3208 { | |
3209 REINITIALIZE_SPECIFIER_TYPE (generic); | |
3210 REINITIALIZE_SPECIFIER_TYPE (integer); | |
3211 REINITIALIZE_SPECIFIER_TYPE (natnum); | |
3212 REINITIALIZE_SPECIFIER_TYPE (boolean); | |
3213 REINITIALIZE_SPECIFIER_TYPE (display_table); | |
3149 } | 3214 } |
3150 | 3215 |
3151 void | 3216 void |
3152 vars_of_specifier (void) | 3217 vars_of_specifier (void) |
3153 { | 3218 { |
3155 staticpro (&Vcached_specifiers); | 3220 staticpro (&Vcached_specifiers); |
3156 | 3221 |
3157 /* Do NOT mark through this, or specifiers will never be GC'd. | 3222 /* Do NOT mark through this, or specifiers will never be GC'd. |
3158 This is the same deal as for weak hash tables. */ | 3223 This is the same deal as for weak hash tables. */ |
3159 Vall_specifiers = Qnil; | 3224 Vall_specifiers = Qnil; |
3225 pdump_wire_list (&Vall_specifiers); | |
3160 | 3226 |
3161 Vuser_defined_tags = Qnil; | 3227 Vuser_defined_tags = Qnil; |
3162 staticpro (&Vuser_defined_tags); | 3228 staticpro (&Vuser_defined_tags); |
3163 | 3229 |
3164 Vunlock_ghost_specifiers = Qnil; | 3230 Vunlock_ghost_specifiers = Qnil; |