Mercurial > hg > xemacs-beta
comparison src/lrecord.h @ 5125:b5df3737028a ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Feb 2010 01:58:04 -0600 |
parents | 623d57b7fbe8 0d4c9d0f6a8d |
children | 2a462149bd6a |
comparison
equal
deleted
inserted
replaced
5124:623d57b7fbe8 | 5125:b5df3737028a |
---|---|
1 /* The "lrecord" structure (header of a compound lisp object). | 1 /* The "lrecord" structure (header of a compound lisp object). |
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. | 2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
3 Copyright (C) 1996, 2001, 2002, 2004, 2005, 2009 Ben Wing. | 3 Copyright (C) 1996, 2001, 2002, 2004, 2005, 2009, 2010 Ben Wing. |
4 | 4 |
5 This file is part of XEmacs. | 5 This file is part of XEmacs. |
6 | 6 |
7 XEmacs is free software; you can redistribute it and/or modify it | 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 | 8 under the terms of the GNU General Public License as published by the |
57 do not need to supply all the methods (see below); reasonable | 57 do not need to supply all the methods (see below); reasonable |
58 defaults are provided for many of them. Alternatively, if you're | 58 defaults are provided for many of them. Alternatively, if you're |
59 just looking for a way of encapsulating data (which possibly | 59 just looking for a way of encapsulating data (which possibly |
60 could contain Lisp_Objects in it), you may well be able to use | 60 could contain Lisp_Objects in it), you may well be able to use |
61 the opaque type. | 61 the opaque type. |
62 | |
63 The "public API's" meant for use by regular Lisp objects are macros | |
64 in capital letters, involving the word "LISP_OBJECT". Underlyingly, | |
65 the functions and structures use "lrecord" or "lcrecord", but most | |
66 code shouldn't have to worry about this. | |
67 */ | 62 */ |
63 | |
64 #ifdef NEW_GC | |
65 /* | |
66 There are some limitations under New-GC that lead to the creation of a | |
67 large number of new internal object types. I'm not completely sure what | |
68 all of them are, but they are at least partially related to limitations | |
69 on finalizers. Something else must be going on as well, because | |
70 non-dumpable, non-finalizable objects like devices and frames also have | |
71 their window-system-specific substructures converted into Lisp objects. | |
72 It must have something to do with the fact that these substructures | |
73 contain pointers to Lisp objects, but it's not completely clear why -- | |
74 object descriptions exist to indicate the size of these structures and | |
75 the Lisp object pointers within them. | |
76 | |
77 At least one definite issue is that under New-GC dumpable objects cannot | |
78 contain any finalizers (see pdump_register_object()). This means that any | |
79 substructures in dumpable objects that are allocated separately and | |
80 normally freed in a finalizer need instead to be made into actual Lisp | |
81 objects. If those structures are Dynarrs, they need to be made into | |
82 Dynarr Lisp objects (e.g. face-cachel-dynarr or glyph-cachel-dynarr), | |
83 which are created using Dynarr_lisp_new() or Dynarr_new_new2(). | |
84 Furthermore, the objects contained in the Dynarr also need to be Lisp | |
85 objects (e.g. face-cachel or glyph-cachel). | |
86 | |
87 --ben | |
88 */ | |
89 | |
90 #endif | |
91 | |
92 | |
68 | 93 |
69 #ifdef NEW_GC | 94 #ifdef NEW_GC |
70 #define ALLOC_LISP_OBJECT(type) alloc_lrecord (&lrecord_##type) | 95 #define ALLOC_LISP_OBJECT(type) alloc_lrecord (&lrecord_##type) |
71 #define ALLOC_SIZED_LISP_OBJECT(size, type) \ | 96 #define ALLOC_SIZED_LISP_OBJECT(size, type) \ |
72 alloc_sized_lrecord (size, &lrecord_##type) | 97 alloc_sized_lrecord (size, &lrecord_##type) |
292 #ifndef NEW_GC | 317 #ifndef NEW_GC |
293 lrecord_type_free, /* only used for "free" lrecords */ | 318 lrecord_type_free, /* only used for "free" lrecords */ |
294 lrecord_type_undefined, /* only used for debugging */ | 319 lrecord_type_undefined, /* only used for debugging */ |
295 #endif /* not NEW_GC */ | 320 #endif /* not NEW_GC */ |
296 #ifdef NEW_GC | 321 #ifdef NEW_GC |
322 /* See comment up top explaining why these extra object types must exist. */ | |
297 lrecord_type_string_indirect_data, | 323 lrecord_type_string_indirect_data, |
298 lrecord_type_string_direct_data, | 324 lrecord_type_string_direct_data, |
299 lrecord_type_hash_table_entry, | 325 lrecord_type_hash_table_entry, |
300 lrecord_type_syntax_cache, | 326 lrecord_type_syntax_cache, |
301 lrecord_type_buffer_text, | 327 lrecord_type_buffer_text, |
368 libraries, such as window-system windows or file handles. This can be | 394 libraries, such as window-system windows or file handles. This can be |
369 NULL, meaning no special finalization is necessary. */ | 395 NULL, meaning no special finalization is necessary. */ |
370 void (*finalizer) (void *header); | 396 void (*finalizer) (void *header); |
371 | 397 |
372 /* This can be NULL, meaning compare objects with EQ(). */ | 398 /* This can be NULL, meaning compare objects with EQ(). */ |
373 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth); | 399 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth, |
400 int foldcase); | |
374 | 401 |
375 /* `hash' generates hash values for use with hash tables that have | 402 /* `hash' generates hash values for use with hash tables that have |
376 `equal' as their test function. This can be NULL, meaning use | 403 `equal' as their test function. This can be NULL, meaning use |
377 the Lisp_Object itself as the hash. But, you must still satisfy | 404 the Lisp_Object itself as the hash. But, you must still satisfy |
378 the constraint that if two objects are `equal', then they *must* | 405 the constraint that if two objects are `equal', then they *must* |
483 && !LRECORD_FREE_P (MCACF_lheader) ) \ | 510 && !LRECORD_FREE_P (MCACF_lheader) ) \ |
484 { \ | 511 { \ |
485 const struct lrecord_implementation *MCACF_implementation \ | 512 const struct lrecord_implementation *MCACF_implementation \ |
486 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ | 513 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ |
487 if (MCACF_implementation && MCACF_implementation->disksaver) \ | 514 if (MCACF_implementation && MCACF_implementation->disksaver) \ |
488 MCACF_implementation->disksaver (ptr); \ | 515 MCACF_implementation->disksaver (MCACF_obj); \ |
489 } \ | 516 } \ |
490 } while (0) | 517 } while (0) |
491 | 518 |
492 #define LRECORD_FREE_P(ptr) \ | 519 #define LRECORD_FREE_P(ptr) \ |
493 (((struct lrecord_header *) ptr)->free) | 520 (((struct lrecord_header *) ptr)->free) |
708 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects), | 735 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects), |
709 XD_INDIRECT (0, 0), { &lisp_object_description } }, | 736 XD_INDIRECT (0, 0), { &lisp_object_description } }, |
710 ... | 737 ... |
711 }; | 738 }; |
712 | 739 |
713 lisp_object_description is declared in alloc.c, like this: | 740 lisp_object_description is declared in gc.c, like this: |
714 | 741 |
715 static const struct memory_description lisp_object_description_1[] = { | 742 static const struct memory_description lisp_object_description_1[] = { |
716 { XD_LISP_OBJECT, 0 }, | 743 { XD_LISP_OBJECT, 0 }, |
717 { XD_END } | 744 { XD_END } |
718 }; | 745 }; |
1129 | 1156 |
1130 #define XD_IS_INDIRECT(code) ((code) < 0) | 1157 #define XD_IS_INDIRECT(code) ((code) < 0) |
1131 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) | 1158 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) |
1132 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) | 1159 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) |
1133 | 1160 |
1134 #define XD_DYNARR_DESC(base_type, sub_desc) \ | |
1135 { XD_BLOCK_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), {sub_desc} },\ | |
1136 { XD_INT, offsetof (base_type, cur) }, \ | |
1137 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } \ | |
1138 | |
1139 #ifdef NEW_GC | |
1140 #define XD_LISP_DYNARR_DESC(base_type, sub_desc) \ | |
1141 { XD_LISP_OBJECT_BLOCK_PTR, offsetof (base_type, base), \ | |
1142 XD_INDIRECT(1, 0), {sub_desc} }, \ | |
1143 { XD_INT, offsetof (base_type, cur) }, \ | |
1144 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } | |
1145 #endif /* not NEW_GC */ | |
1146 | |
1147 /* DEFINE_*_LISP_OBJECT is for objects with constant size. (Either | 1161 /* DEFINE_*_LISP_OBJECT is for objects with constant size. (Either |
1148 DEFINE_DUMPABLE_LISP_OBJECT for objects that can be saved in a dumped | 1162 DEFINE_DUMPABLE_LISP_OBJECT for objects that can be saved in a dumped |
1149 executable, or DEFINE_NODUMP_LISP_OBJECT for objects that cannot be | 1163 executable, or DEFINE_NODUMP_LISP_OBJECT for objects that cannot be |
1150 saved -- e.g. that contain pointers to non-persistent external objects | 1164 saved -- e.g. that contain pointers to non-persistent external objects |
1151 such as window-system windows.) | 1165 such as window-system windows.) |