annotate src/lrecord.h @ 5043:d0c14ea98592

various frame-geometry fixes -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-02-15 Ben Wing <ben@xemacs.org> * EmacsFrame.c: * EmacsFrame.c (EmacsFrameResize): * console-msw-impl.h: * console-msw-impl.h (struct mswindows_frame): * console-msw-impl.h (FRAME_MSWINDOWS_TARGET_RECT): * device-tty.c: * device-tty.c (tty_asynch_device_change): * event-msw.c: * event-msw.c (mswindows_wnd_proc): * faces.c (Fface_list): * faces.h: * frame-gtk.c: * frame-gtk.c (gtk_set_initial_frame_size): * frame-gtk.c (gtk_set_frame_size): * frame-msw.c: * frame-msw.c (mswindows_init_frame_1): * frame-msw.c (mswindows_set_frame_size): * frame-msw.c (mswindows_size_frame_internal): * frame-msw.c (msprinter_init_frame_3): * frame.c: * frame.c (enum): * frame.c (Fmake_frame): * frame.c (adjust_frame_size): * frame.c (store_minibuf_frame_prop): * frame.c (Fframe_property): * frame.c (Fframe_properties): * frame.c (Fframe_displayable_pixel_height): * frame.c (Fframe_displayable_pixel_width): * frame.c (internal_set_frame_size): * frame.c (Fset_frame_height): * frame.c (Fset_frame_pixel_height): * frame.c (Fset_frame_displayable_pixel_height): * frame.c (Fset_frame_width): * frame.c (Fset_frame_pixel_width): * frame.c (Fset_frame_displayable_pixel_width): * frame.c (Fset_frame_size): * frame.c (Fset_frame_pixel_size): * frame.c (Fset_frame_displayable_pixel_size): * frame.c (frame_conversion_internal_1): * frame.c (get_frame_displayable_pixel_size): * frame.c (change_frame_size_1): * frame.c (change_frame_size): * frame.c (generate_title_string): * frame.h: * gtk-xemacs.c: * gtk-xemacs.c (gtk_xemacs_size_request): * gtk-xemacs.c (gtk_xemacs_size_allocate): * gtk-xemacs.c (gtk_xemacs_paint): * gutter.c: * gutter.c (update_gutter_geometry): * redisplay.c (end_hold_frame_size_changes): * redisplay.c (redisplay_frame): * toolbar.c: * toolbar.c (update_frame_toolbars_geometry): * window.c: * window.c (frame_pixsize_valid_p): * window.c (check_frame_size): Various fixes to frame geometry to make it a bit easier to understand and fix some bugs. 1. IMPORTANT: Some renamings. Will need to be applied carefully to the carbon repository, in the following order: -- pixel_to_char_size -> pixel_to_frame_unit_size -- char_to_pixel_size -> frame_unit_to_pixel_size -- pixel_to_real_char_size -> pixel_to_char_size -- char_to_real_pixel_size -> char_to_pixel_size -- Reverse second and third arguments of change_frame_size() and change_frame_size_1() to try to make functions consistent in putting width before height. -- Eliminate old round_size_to_char, because it didn't really do anything differently from round_size_to_real_char() -- round_size_to_real_char -> round_size_to_char; any places that called the old round_size_to_char should just call the new one. 2. IMPORTANT FOR CARBON: The set_frame_size() method is now passed sizes in "frame units", like all other frame-sizing functions, rather than some hacked-up combination of char-cell units and total pixel size. This only affects window systems that use "pixelated geometry", and I'm not sure if Carbon is one of them. MS Windows is pixelated, X and GTK are not. For pixelated-geometry systems, the size in set_frame_size() is in displayable pixels rather than total pixels and needs to be converted appropriately; take a look at the changes made to mswindows_set_frame_size() method if necessary. 3. Add a big long comment in frame.c describing how frame geometry works. 4. Remove MS Windows-specific character height and width fields, duplicative and unused. 5. frame-displayable-pixel-* and set-frame-displayable-pixel-* didn't use to work on MS Windows, but they do now. 6. In general, clean up the handling of "pixelated geometry" so that fewer functions have to worry about this. This is really an abomination that should be removed entirely but that will have to happen later. Fix some buggy code in frame_conversion_internal() that happened to "work" because it was countered by oppositely buggy code in change_frame_size(). 7. Clean up some frame-size code in toolbar.c and use functions already provided in frame.c instead of rolling its own. 8. Fix check_frame_size() in window.c, which formerly didn't take pixelated geometry into account.
author Ben Wing <ben@xemacs.org>
date Mon, 15 Feb 2010 22:14:11 -0600
parents 0d4c9d0f6a8d
children c8f90d61dcf3 b5df3737028a 8b2f75cecb89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* The "lrecord" structure (header of a compound lisp object).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
3 Copyright (C) 1996, 2001, 2002, 2004, 2005, 2010 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
24 /* This file has been Mule-ized, Ben Wing, 10-13-04. */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
25
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
26 #ifndef INCLUDED_lrecord_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
27 #define INCLUDED_lrecord_h_
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
29 /* The "lrecord" type of Lisp object is used for all object types other
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
30 than a few simple ones (like char and int). This allows many types to be
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
31 implemented but only a few bits required in a Lisp object for type
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
32 information. (The tradeoff is that each object has its type marked in
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
33 it, thereby increasing its size.) All lrecords begin with a `struct
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
34 lrecord_header', which identifies the lisp object type, by providing an
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
35 index into a table of `struct lrecord_implementation', which describes
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
36 the behavior of the lisp object. It also contains some other data bits.
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
37
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
38 #ifndef NEW_GC
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 Lrecords are of two types: straight lrecords, and lcrecords.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 Straight lrecords are used for those types of objects that have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 their own allocation routines (typically allocated out of 2K chunks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 of memory called `frob blocks'). These objects have a `struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 lrecord_header' at the top, containing only the bits needed to find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 the lrecord_implementation for the object. There are special
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
45 routines in alloc.c to create an object of each such type.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 Lcrecords are used for less common sorts of objects that don't do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 their own allocation. Each such object is malloc()ed individually,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 and the objects are chained together through a `next' pointer.
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
50 Lcrecords have a `struct old_lcrecord_header' at the top, which
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51 contains a `struct lrecord_header' and a `next' pointer, and are
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
52 allocated using old_alloc_lcrecord_type() or its variants.
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
53 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
55 Creating a new Lisp object type is fairly easy; just follow the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 lead of some existing type (e.g. hash tables). Note that you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 do not need to supply all the methods (see below); reasonable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 defaults are provided for many of them. Alternatively, if you're
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 just looking for a way of encapsulating data (which possibly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 could contain Lisp_Objects in it), you may well be able to use
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
61 the opaque type.
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
62 */
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
63
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
64 #ifdef NEW_GC
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
65 /*
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
66 There are some limitations under New-GC that lead to the creation of a
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
67 large number of new internal object types. I'm not completely sure what
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
68 all of them are, but they are at least partially related to limitations
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
69 on finalizers. Something else must be going on as well, because
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
70 non-dumpable, non-finalizable objects like devices and frames also have
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
71 their window-system-specific substructures converted into Lisp objects.
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
72 It must have something to do with the fact that these substructures
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
73 contain pointers to Lisp objects, but it's not completely clear why --
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
74 object descriptions exist to indicate the size of these structures and
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
75 the Lisp object pointers within them.
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
76
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
77 At least one definite issue is that under New-GC dumpable objects cannot
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
78 contain any finalizers (see pdump_register_object()). This means that any
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
79 substructures in dumpable objects that are allocated separately and
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
80 normally freed in a finalizer need instead to be made into actual Lisp
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
81 objects. If those structures are Dynarrs, they need to be made into
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
82 Dynarr Lisp objects (e.g. face-cachel-dynarr or glyph-cachel-dynarr),
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
83 which are created using Dynarr_lisp_new() or Dynarr_new_new2().
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
84 Furthermore, the objects contained in the Dynarr also need to be Lisp
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
85 objects (e.g. face-cachel or glyph-cachel).
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
86
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
87 --ben
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
88 */
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
89
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
90 #endif
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
91
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
92
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
94 #ifdef NEW_GC
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
95 #define ALLOC_LCRECORD_TYPE alloc_lrecord_type
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
96 #define COPY_SIZED_LCRECORD copy_sized_lrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
97 #define COPY_LCRECORD copy_lrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
98 #define LISPOBJ_STORAGE_SIZE(ptr, size, stats) \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
99 mc_alloced_storage_size (size, stats)
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
100 #define ZERO_LCRECORD zero_lrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
101 #define LCRECORD_HEADER lrecord_header
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
102 #define BASIC_ALLOC_LCRECORD alloc_lrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
103 #define FREE_LCRECORD free_lrecord
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
104 #else /* not NEW_GC */
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
105 #define ALLOC_LCRECORD_TYPE old_alloc_lcrecord_type
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
106 #define COPY_SIZED_LCRECORD old_copy_sized_lcrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
107 #define COPY_LCRECORD old_copy_lcrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
108 #define LISPOBJ_STORAGE_SIZE malloced_storage_size
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
109 #define ZERO_LCRECORD old_zero_lcrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
110 #define LCRECORD_HEADER old_lcrecord_header
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
111 #define BASIC_ALLOC_LCRECORD old_basic_alloc_lcrecord
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
112 #define FREE_LCRECORD old_free_lcrecord
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
113 #endif /* not NEW_GC */
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
114
1743
543769b89fed [xemacs-hg @ 2003-10-14 05:02:57 by james]
james
parents: 1688
diff changeset
115 BEGIN_C_DECLS
1650
34abfb24e891 [xemacs-hg @ 2003-08-28 15:44:04 by james]
james
parents: 1638
diff changeset
116
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 struct lrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
119 /* Index into lrecord_implementations_table[]. Objects that have been
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
120 explicitly freed using e.g. free_cons() have lrecord_type_free in this
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
121 field. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
122 unsigned int type :8;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
124 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
125 /* 1 if the object is readonly from lisp */
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
126 unsigned int lisp_readonly :1;
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
127
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
128 /* The `free' field is a flag that indicates whether this lrecord
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
129 is currently free or not. This is used for error checking and
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
130 debugging. */
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
131 unsigned int free :1;
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
132
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
133 /* The `uid' field is just for debugging/printing convenience. Having
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
134 this slot doesn't hurt us spacewise, since the bits are unused
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
135 anyway. (The bits are used for strings, though.) */
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
136 unsigned int uid :22;
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
137
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
138 #else /* not NEW_GC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 /* If `mark' is 0 after the GC mark phase, the object will be freed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 during the GC sweep phase. There are 2 ways that `mark' can be 1:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 - by being referenced from other objects during the GC mark phase
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 - because it is permanently on, for c_readonly objects */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 unsigned int mark :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 /* 1 if the object resides in logically read-only space, and does not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 reference other non-c_readonly objects.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 unsigned int c_readonly :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 /* 1 if the object is readonly from lisp */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 unsigned int lisp_readonly :1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
152
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
153 /* The `uid' field is just for debugging/printing convenience. Having
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
154 this slot doesn't hurt us spacewise, since the bits are unused
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
155 anyway. (The bits are used for strings, though.) */
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
156 unsigned int uid :21;
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
157
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
158 #endif /* not NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 struct lrecord_implementation;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 int lrecord_type_index (const struct lrecord_implementation *implementation);
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
163 extern int lrecord_uid_counter;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
165 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
166 #define set_lheader_implementation(header,imp) do { \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
167 struct lrecord_header* SLI_header = (header); \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
168 SLI_header->type = (imp)->lrecord_type_index; \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
169 SLI_header->lisp_readonly = 0; \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
170 SLI_header->free = 0; \
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
171 SLI_header->uid = lrecord_uid_counter++; \
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
172 } while (0)
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
173 #else /* not NEW_GC */
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
174 #define set_lheader_implementation(header,imp) do { \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 struct lrecord_header* SLI_header = (header); \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176 SLI_header->type = (imp)->lrecord_type_index; \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
177 SLI_header->mark = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
178 SLI_header->c_readonly = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
179 SLI_header->lisp_readonly = 0; \
3063
d30cd499e445 [xemacs-hg @ 2005-11-13 10:48:01 by ben]
ben
parents: 3029
diff changeset
180 SLI_header->uid = lrecord_uid_counter++; \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 } while (0)
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
182 #endif /* not NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
184 #ifndef NEW_GC
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
185 struct old_lcrecord_header
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 struct lrecord_header lheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 /* The `next' field is normally used to chain all lcrecords together
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 so that the GC can find (and free) all of them.
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
191 `old_basic_alloc_lcrecord' threads lcrecords together.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 The `next' field may be used for other purposes as long as some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 other mechanism is provided for letting the GC do its work.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 For example, the event and marker object types allocate members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 out of memory chunks, and are able to find all unmarked members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 by sweeping through the elements of the list of chunks. */
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
199 struct old_lcrecord_header *next;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 /* The `uid' field is just for debugging/printing convenience.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 Having this slot doesn't hurt us much spacewise, since an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 lcrecord already has the above slots plus malloc overhead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 unsigned int uid :31;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 /* The `free' field is a flag that indicates whether this lcrecord
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 is on a "free list". Free lists are used to minimize the number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 of calls to malloc() when we're repeatedly allocating and freeing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 a number of the same sort of lcrecord. Lcrecords on a free list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 always get marked in a different fashion, so we can use this flag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 as a sanity check to make sure that free lists only have freed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 lcrecords and there are no freed lcrecords elsewhere. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 unsigned int free :1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 /* Used for lcrecords in an lcrecord-list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 struct free_lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 {
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
219 struct old_lcrecord_header lcheader;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 Lisp_Object chain;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 };
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
222 #endif /* not NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3263
diff changeset
224 /* DON'T FORGET to update .gdbinit.in if you change this list. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
226 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
227 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
228 #### This should be replaced by a symbol_value_magic_p flag
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
229 in the Lisp_Symbol lrecord_header. */
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
230 lrecord_type_symbol_value_forward, /* 0 */
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
231 lrecord_type_symbol_value_varalias,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
232 lrecord_type_symbol_value_lisp_magic,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
233 lrecord_type_symbol_value_buffer_local,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
234 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local,
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
235 lrecord_type_symbol,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
236 lrecord_type_subr,
4677
8f1ee2d15784 Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3931
diff changeset
237 lrecord_type_multiple_value,
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
238 lrecord_type_cons,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
239 lrecord_type_vector,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
240 lrecord_type_string,
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
241 #ifndef NEW_GC
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
242 lrecord_type_lcrecord_list,
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
243 #endif /* not NEW_GC */
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
244 lrecord_type_compiled_function,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
245 lrecord_type_weak_list,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
246 lrecord_type_bit_vector,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
247 lrecord_type_float,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
248 lrecord_type_hash_table,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
249 lrecord_type_lstream,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
250 lrecord_type_process,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
251 lrecord_type_charset,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
252 lrecord_type_coding_system,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
253 lrecord_type_char_table,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
254 lrecord_type_char_table_entry,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
255 lrecord_type_range_table,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
256 lrecord_type_opaque,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
257 lrecord_type_opaque_ptr,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
258 lrecord_type_buffer,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
259 lrecord_type_extent,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
260 lrecord_type_extent_info,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
261 lrecord_type_extent_auxiliary,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
262 lrecord_type_marker,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
263 lrecord_type_event,
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
264 #ifdef EVENT_DATA_AS_OBJECTS /* not defined */
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
265 lrecord_type_key_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
266 lrecord_type_button_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
267 lrecord_type_motion_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
268 lrecord_type_process_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
269 lrecord_type_timeout_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
270 lrecord_type_eval_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
271 lrecord_type_misc_user_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
272 lrecord_type_magic_eval_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
273 lrecord_type_magic_data,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
274 #endif /* EVENT_DATA_AS_OBJECTS */
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
275 lrecord_type_keymap,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
276 lrecord_type_command_builder,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
277 lrecord_type_timeout,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
278 lrecord_type_specifier,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
279 lrecord_type_console,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
280 lrecord_type_device,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
281 lrecord_type_frame,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
282 lrecord_type_window,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
283 lrecord_type_window_mirror,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
284 lrecord_type_window_configuration,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
285 lrecord_type_gui_item,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
286 lrecord_type_popup_data,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
287 lrecord_type_toolbar_button,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
288 lrecord_type_scrollbar_instance,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
289 lrecord_type_color_instance,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
290 lrecord_type_font_instance,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
291 lrecord_type_image_instance,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
292 lrecord_type_glyph,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
293 lrecord_type_face,
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3263
diff changeset
294 lrecord_type_fc_config,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 3092
diff changeset
295 lrecord_type_fc_pattern,
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
296 lrecord_type_database,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
297 lrecord_type_tooltalk_message,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
298 lrecord_type_tooltalk_pattern,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
299 lrecord_type_ldap,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
300 lrecord_type_pgconn,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
301 lrecord_type_pgresult,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
302 lrecord_type_devmode,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
303 lrecord_type_mswindows_dialog_id,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
304 lrecord_type_case_table,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
305 lrecord_type_emacs_ffi,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
306 lrecord_type_emacs_gtk_object,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
307 lrecord_type_emacs_gtk_boxed,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
308 lrecord_type_weak_box,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
309 lrecord_type_ephemeron,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
310 lrecord_type_bignum,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
311 lrecord_type_ratio,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
312 lrecord_type_bigfloat,
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
313 #ifndef NEW_GC
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
314 lrecord_type_free, /* only used for "free" lrecords */
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
315 lrecord_type_undefined, /* only used for debugging */
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
316 #endif /* not NEW_GC */
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
317 #ifdef NEW_GC
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
318 /* See comment up top explaining why these extra object types must exist. */
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
319 lrecord_type_string_indirect_data,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
320 lrecord_type_string_direct_data,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
321 lrecord_type_hash_table_entry,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
322 lrecord_type_syntax_cache,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
323 lrecord_type_buffer_text,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
324 lrecord_type_compiled_function_args,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
325 lrecord_type_tty_console,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
326 lrecord_type_stream_console,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
327 lrecord_type_dynarr,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
328 lrecord_type_face_cachel,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
329 lrecord_type_face_cachel_dynarr,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
330 lrecord_type_glyph_cachel,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
331 lrecord_type_glyph_cachel_dynarr,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
332 lrecord_type_x_device,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
333 lrecord_type_gtk_device,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
334 lrecord_type_tty_device,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
335 lrecord_type_mswindows_device,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
336 lrecord_type_msprinter_device,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
337 lrecord_type_x_frame,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
338 lrecord_type_gtk_frame,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
339 lrecord_type_mswindows_frame,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
340 lrecord_type_gap_array_marker,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
341 lrecord_type_gap_array,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
342 lrecord_type_extent_list_marker,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
343 lrecord_type_extent_list,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
344 lrecord_type_stack_of_extents,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
345 lrecord_type_tty_color_instance_data,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
346 lrecord_type_tty_font_instance_data,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
347 lrecord_type_specifier_caching,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
348 lrecord_type_expose_ignore,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
349 #endif /* NEW_GC */
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
350 lrecord_type_last_built_in_type /* must be last */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
351 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
352
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
353 extern MODULE_API int lrecord_type_count;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 struct lrecord_implementation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
357 const Ascbyte *name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
358
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
359 /* information for the dumper: is the object dumpable and should it
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
360 be dumped. */
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
361 unsigned int dumpable :1;
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
362
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 /* `marker' is called at GC time, to make sure that all Lisp_Objects
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 pointed to by this object get properly marked. It should call
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 the mark_object function on all Lisp_Objects in the object. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 the return value is non-nil, it should be a Lisp_Object to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 marked (don't call the mark_object function explicitly on it,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 because the GC routines will do this). Doing it this way reduces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 recursion, so the object returned should preferably be the one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 with the deepest level of Lisp_Object pointers. This function
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
371 can be NULL, meaning no GC marking is necessary.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
372
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
373 NOTE NOTE NOTE: This is not used by KKCC (which uses the data
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
374 description below instead), unless the data description is missing.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
375 Yes, this currently means there is logic duplication. Eventually the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
376 mark methods will be removed. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 Lisp_Object (*marker) (Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
378
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 /* `printer' converts the object to a printed representation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
380 This can be NULL; in this case default_object_printer() will be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381 used instead. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
383
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
384 /* `finalizer' is called at GC time when the object is about to be freed,
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
385 and at dump time (FOR_DISKSAVE will be non-zero in this case). It
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
386 should perform any necessary cleanup (e.g. freeing malloc()ed memory
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
387 or releasing objects created in external libraries, such as
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
388 window-system windows or file handles). This can be NULL, meaning no
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
389 special finalization is necessary.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
4930
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
391 WARNING: remember that `finalizer' is called at dump time even though
9f04877ce07e fix up comments about finalizers and NEWGC internal objects
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
392 the object is not being freed -- check the FOR_DISKSAVE argument. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 void (*finalizer) (void *header, int for_disksave);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
394
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 /* This can be NULL, meaning compare objects with EQ(). */
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
396 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth,
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4844
diff changeset
397 int foldcase);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
398
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
399 /* `hash' generates hash values for use with hash tables that have
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
400 `equal' as their test function. This can be NULL, meaning use
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401 the Lisp_Object itself as the hash. But, you must still satisfy
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402 the constraint that if two objects are `equal', then they *must*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
403 hash to the same value in order for hash tables to work properly.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
404 This means that `hash' can be NULL only if the `equal' method is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
405 also NULL. */
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2367
diff changeset
406 Hashcode (*hash) (Lisp_Object, int);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
408 /* Data layout description for your object. See long comment below. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
409 const struct memory_description *description;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
411 /* These functions allow any object type to have builtin property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
412 lists that can be manipulated from the lisp level with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
413 `get', `put', `remprop', and `object-plist'. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 Lisp_Object (*plist) (Lisp_Object obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
419 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
420 /* Only one of `static_size' and `size_in_bytes_method' is non-0. */
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
421 #else /* not NEW_GC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
422 /* Only one of `static_size' and `size_in_bytes_method' is non-0.
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
423 If both are 0, this type is not instantiable by
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
424 old_basic_alloc_lcrecord(). */
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
425 #endif /* not NEW_GC */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
426 Bytecount static_size;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
427 Bytecount (*size_in_bytes_method) (const void *header);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
428
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
429 /* The (constant) index into lrecord_implementations_table */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
430 enum lrecord_type lrecord_type_index;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
431
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
432 #ifndef NEW_GC
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
434 one that does not have an old_lcrecord_header at the front and which
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
435 is (usually) allocated in frob blocks. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 unsigned int basic_p :1;
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
437 #endif /* not NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
440 /* All the built-in lisp object types are enumerated in `enum lrecord_type'.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
441 Additional ones may be defined by a module (none yet). We leave some
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
442 room in `lrecord_implementations_table' for such new lisp object types. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443 #define MODULE_DEFINABLE_TYPE_COUNT 32
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
444
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
445 extern MODULE_API const struct lrecord_implementation *
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
446 lrecord_implementations_table[lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
452 #include "gc.h"
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
453
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
454 #ifdef NEW_GC
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
455 #include "vdb.h"
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
456 #endif /* NEW_GC */
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
457
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 extern int gc_in_progress;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
460 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
461 #include "mc-alloc.h"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
462
2994
ec5f23ea6d2e [xemacs-hg @ 2005-10-14 01:21:57 by ben]
ben
parents: 2775
diff changeset
463 #ifdef ALLOC_TYPE_STATS
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
464 void init_lrecord_stats (void);
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
465 void inc_lrecord_stats (Bytecount size, const struct lrecord_header *h);
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
466 void dec_lrecord_stats (Bytecount size_including_overhead,
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
467 const struct lrecord_header *h);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
468 int lrecord_stats_heap_size (void);
2994
ec5f23ea6d2e [xemacs-hg @ 2005-10-14 01:21:57 by ben]
ben
parents: 2775
diff changeset
469 #endif /* ALLOC_TYPE_STATS */
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
470
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
471 /* Tell mc-alloc how to call a finalizer. */
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
472 #define MC_ALLOC_CALL_FINALIZER(ptr) \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
473 { \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
474 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
475 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
476 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
477 && !LRECORD_FREE_P (MCACF_lheader) ) \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
478 { \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
479 const struct lrecord_implementation *MCACF_implementation \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
480 = LHEADER_IMPLEMENTATION (MCACF_lheader); \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
481 if (MCACF_implementation && MCACF_implementation->finalizer) \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
482 { \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
483 GC_STAT_FINALIZED; \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
484 MCACF_implementation->finalizer (ptr, 0); \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
485 } \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
486 } \
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
487 } while (0)
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
488
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
489 /* Tell mc-alloc how to call a finalizer for disksave. */
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
490 #define MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
491 { \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
492 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
493 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
494 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
495 && !LRECORD_FREE_P (MCACF_lheader) ) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
496 { \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
497 const struct lrecord_implementation *MCACF_implementation \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
498 = LHEADER_IMPLEMENTATION (MCACF_lheader); \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
499 if (MCACF_implementation && MCACF_implementation->finalizer) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
500 MCACF_implementation->finalizer (ptr, 1); \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
501 } \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
502 } while (0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
503
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
504 #define LRECORD_FREE_P(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
505 (((struct lrecord_header *) ptr)->free)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
506
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
507 #define MARK_LRECORD_AS_FREE(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
508 ((void) (((struct lrecord_header *) ptr)->free = 1))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
509
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
510 #define MARK_LRECORD_AS_NOT_FREE(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
511 ((void) (((struct lrecord_header *) ptr)->free = 0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
512
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
513 #define MARKED_RECORD_P(obj) MARKED_P (obj)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
514 #define MARKED_RECORD_HEADER_P(lheader) MARKED_P (lheader)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
515 #define MARK_RECORD_HEADER(lheader) MARK (lheader)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
516 #define UNMARK_RECORD_HEADER(lheader) UNMARK (lheader)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
517
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
518 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
519 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
520 ((void) ((lheader)->lisp_readonly = 1))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
521 #define MARK_LRECORD_AS_LISP_READONLY(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
522 ((void) (((struct lrecord_header *) ptr)->lisp_readonly = 1))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
523
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
524 #else /* not NEW_GC */
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
525
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
526 #define LRECORD_FREE_P(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
527 (((struct lrecord_header *) ptr)->type == lrecord_type_free)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
528
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
529 #define MARK_LRECORD_AS_FREE(ptr) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
530 ((void) (((struct lrecord_header *) ptr)->type = lrecord_type_free))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
531
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
540 struct lrecord_header *SCRRH_lheader = (lheader); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 SCRRH_lheader->c_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542 SCRRH_lheader->lisp_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
543 SCRRH_lheader->mark = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 ((void) ((lheader)->lisp_readonly = 1))
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
547 #endif /* not NEW_GC */
1676
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
548
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
549 #ifdef USE_KKCC
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
550 #define RECORD_DESCRIPTION(lheader) lrecord_memory_descriptions[(lheader)->type]
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
551 #else /* not USE_KKCC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type]
1676
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
553 #endif /* not USE_KKCC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
555 #define RECORD_DUMPABLE(lheader) (lrecord_implementations_table[(lheader)->type])->dumpable
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
556
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
557 /* Data description stuff
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
558
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
559 Data layout descriptions describe blocks of memory (in particular, Lisp
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
560 objects and other objects on the heap, and global objects with pointers
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
561 to such heap objects), including their size and a list of the elements
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
562 that need relocating, marking or other special handling. They are
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
563 currently used in two places: by pdump [the new, portable dumper] and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
564 KKCC [the new garbage collector]. The two subsystems use the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
565 descriptions in different ways, and as a result some of the descriptions
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
566 are appropriate only for one or the other, when it is known that only
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
567 that subsystem will use the description. (This is particularly the case
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
568 with objects that can't be dumped, because pdump needs more info than
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
569 KKCC.) However, properly written descriptions are appropriate for both,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
570 and you should strive to write your descriptions that way, since the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
571 dumpable status of an object may change and new uses for the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
572 descriptions may be created. (An example that comes to mind is a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
573 facility for determining the memory usage of XEmacs data structures --
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
574 like `buffer-memory-usage', `window-memory-usage', etc. but more
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
575 general.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
576
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
577 More specifically:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
579 Pdump (the portable dumper) needs to write out all objects in heap
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
580 space, and later on (in another invocation of XEmacs) load them back
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
581 into the heap, relocating all pointers to the heap objects in the global
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
582 data space. ("Heap" means anything malloc()ed, including all Lisp
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
583 objects, and "global data" means anything declared globally or
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
584 `static'.) Pdump, then, needs to be told about the location of all
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
585 global pointers to heap objects, all the description of all such
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
586 objects, including their size and any pointers to other heap (aka
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
587 "relocatable") objects. (Pdump assumes that the heap may occur in
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
588 different places in different invocations -- therefore, it is not enough
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
589 simply to write out the entire heap and later reload it at the same
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
590 location -- but that global data is always in the same place, and hence
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
591 pointers to it do not need to be relocated. This assumption holds true
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
592 in general for modern operating systems, but would be broken, for
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
593 example, in a system without virtual memory, or when dealing with shared
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
594 libraries. Also, unlike unexec, pdump does not usually write out or
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
595 restore objects in the global data space, and thus they need to be
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
596 initialized every time XEmacs is loaded. This is the purpose of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
597 reinit_*() functions throughout XEmacs. [It's possible, however, to make
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
598 pdump restore global data. This must be done, of course, for heap
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
599 pointers, but is also done for other values that are not easy to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
600 recompute -- in particular, values established by the Lisp code loaded
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
601 at dump time.]) Note that the data type `Lisp_Object' is basically just
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
602 a relocatable pointer disguised as a long, and in general pdump treats
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
603 the Lisp_Object values and pointers to Lisp objects (e.g. Lisp_Object
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
604 vs. `struct frame *') identically. (NOTE: This equivalence depends
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
605 crucially on the current "minimal tagbits" implementation of Lisp_Object
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
606 pointers.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
608 Descriptions are used by pdump in three places: (a) descriptions of Lisp
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
609 objects, referenced in the DEFINE_*LRECORD_*IMPLEMENTATION*() call; (b)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
610 descriptions of global objects to be dumped, registered by
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
611 dump_add_root_block(); (c) descriptions of global pointers to
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
612 non-Lisp_Object heap objects, registered by dump_add_root_block_ptr().
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
613 The descriptions need to tell pdump which elements of your structure are
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
614 Lisp_Objects or structure pointers, plus the descriptions in turn of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
615 non-Lisp_Object structures pointed to. If these structures are you own
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
616 private ones, you will have to write these recursive descriptions
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
617 yourself; otherwise, you are reusing a structure already in existence
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
618 elsewhere and there is probably already a description for it.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
619
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
620 Pdump does not care about Lisp objects that cannot be dumped (the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
621 dumpable flag to DEFINE_*LRECORD_*IMPLEMENTATION*() is 0).
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
622
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
623 KKCC also uses data layout descriptions, but differently. It cares
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
624 about all objects, dumpable or not, but specifically only wants to know
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
625 about Lisp_Objects in your object and in structures pointed to. Thus,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
626 it doesn't care about things like pointers to structures ot other blocks
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
627 of memory with no Lisp Objects in them, which pdump would care a lot
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
628 about.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
629
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
630 Technically, then, you could write your description differently
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
631 depending on whether your object is dumpable -- the full pdump
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
632 description if so, the abbreviated KKCC description if not. In fact,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
633 some descriptions are written this way. This is dangerous, though,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
634 because another use might come along for the data descriptions, that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
635 doesn't care about the dumper flag and makes use of some of the stuff
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
636 normally omitted from the "abbreviated" description -- see above.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
637
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
638 A memory_description is an array of values. (This is actually
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
639 misnamed, in that it does not just describe lrecords, but any
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
640 blocks of memory.) The first value of each line is a type, the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
641 second the offset in the lrecord structure. The third and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
642 following elements are parameters; their presence, type and number
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
643 is type-dependent.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
644
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
645 The description ends with an "XD_END" record.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
646
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
647 The top-level description of an lrecord or lcrecord does not need
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
648 to describe every element, just the ones that need to be relocated,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
649 since the size of the lrecord is known. (The same goes for nested
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
650 structures, whenever the structure size is given, rather than being
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
651 defaulted by specifying 0 for the size.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
652
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
653 A sized_memory_description is a memory_description plus the size of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
654 block of memory. The size field in a sized_memory_description can be
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
655 given as zero, i.e. unspecified, meaning that the last element in the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
656 structure is described in the description and the size of the block can
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
657 therefore be computed from it. (This is useful for stretchy arrays.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
658
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
659 memory_descriptions are used to describe lrecords (the size of the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
660 lrecord is elsewhere in its description, attached to its methods, so it
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
661 does not need to be given here) and global objects, where the size is an
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
662 argument to the call to dump_add_root_block().
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
663 sized_memory_descriptions are used for pointers and arrays in
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
664 memory_descriptions and for calls to dump_add_root_block_ptr(). (####
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
665 It is not obvious why this is so in the latter case. Probably, calls to
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
666 dump_add_root_block_ptr() should use plain memory_descriptions and have
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
667 the size be an argument to the call.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
668
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
669 NOTE: Anywhere that a sized_memory_description occurs inside of a plain
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
670 memory_description, a "description map" can be substituted. Rather than
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
671 being an actual description, this describes how to find the description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
672 by looking inside of the object being described. This is a convenient
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
673 way to describe Lisp objects with subtypes and corresponding
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
674 type-specific data.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 Some example descriptions :
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
677
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
678 struct Lisp_String
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
679 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
680 struct lrecord_header lheader;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
681 Bytecount size;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 858
diff changeset
682 Ibyte *data;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
683 Lisp_Object plist;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
684 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
685
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
686 static const struct memory_description cons_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
687 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
688 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
692 Which means "two lisp objects starting at the 'car' and 'cdr' elements"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
694 static const struct memory_description string_description[] = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
695 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
696 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT (0, 1) },
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
697 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
698 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
699 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
700
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
701 "A pointer to string data at 'data', the size of the pointed array being
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
702 the value of the size variable plus 1, and one lisp object at 'plist'"
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
703
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
704 If your object has a pointer to an array of Lisp_Objects in it, something
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
705 like this:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
706
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
707 struct Lisp_Foo
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
708 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
709 ...;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
710 int count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
711 Lisp_Object *objects;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
712 ...;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
713 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
714
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
715 You'd use XD_BLOCK_PTR, something like:
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
716
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
717 static const struct memory_description foo_description[] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
718 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
719 { XD_INT, offsetof (Lisp_Foo, count) },
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
720 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects),
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
721 XD_INDIRECT (0, 0), { &lisp_object_description } },
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
722 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
723 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
724
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4937
diff changeset
725 lisp_object_description is declared in gc.c, like this:
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
726
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
727 static const struct memory_description lisp_object_description_1[] = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
728 { XD_LISP_OBJECT, 0 },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
729 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
730 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
731
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
732 const struct sized_memory_description lisp_object_description = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
733 sizeof (Lisp_Object),
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
734 lisp_object_description_1
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
735 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
736
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
737 Another example of XD_BLOCK_PTR:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
739 typedef struct htentry
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
740 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
741 Lisp_Object key;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
742 Lisp_Object value;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
743 } htentry;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
744
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
745 struct Lisp_Hash_Table
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
746 {
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2994
diff changeset
747 struct LCRECORD_HEADER header;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
748 Elemcount size;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
749 Elemcount count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
750 Elemcount rehash_count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
751 double rehash_size;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
752 double rehash_threshold;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
753 Elemcount golden_ratio;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
754 hash_table_hash_function_t hash_function;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
755 hash_table_test_function_t test_function;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
756 htentry *hentries;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
757 enum hash_table_weakness weakness;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
758 Lisp_Object next_weak; // Used to chain together all of the weak
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
759 // hash tables. Don't mark through this.
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
760 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
761
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
762 static const struct memory_description htentry_description_1[] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
763 { XD_LISP_OBJECT, offsetof (htentry, key) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
764 { XD_LISP_OBJECT, offsetof (htentry, value) },
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
765 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
766 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
767
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
768 static const struct sized_memory_description htentry_description = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
769 sizeof (htentry),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
770 htentry_description_1
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
771 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
772
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
773 const struct memory_description hash_table_description[] = {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
774 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) },
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
775 { XD_BLOCK_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT (0, 1),
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
776 { &htentry_description } },
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
777 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
778 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
779 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
780
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
781 Note that we don't need to declare all the elements in the structure, just
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
782 the ones that need to be relocated (Lisp_Objects and structures) or that
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
783 need to be referenced as counts for relocated objects.
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
784
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
785 A description map looks like this:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
786
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
787 static const struct sized_memory_description specifier_extra_description_map [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
788 { offsetof (Lisp_Specifier, methods) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
789 { offsetof (struct specifier_methods, extra_description) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
790 { -1 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
791 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
792
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
793 const struct memory_description specifier_description[] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
794 ...
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
795 { XD_BLOCK_ARRAY, offset (Lisp_Specifier, data), 1,
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
796 { specifier_extra_description_map } },
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
797 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
798 { XD_END }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
799 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
800
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
801 This would be appropriate for an object that looks like this:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
802
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
803 struct specifier_methods
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
804 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
805 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
806 const struct sized_memory_description *extra_description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
807 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
808 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
809
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
810 struct Lisp_Specifier
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
811 {
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2994
diff changeset
812 struct LCRECORD_HEADER header;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
813 struct specifier_methods *methods;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
814
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
815 ...
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
816 // type-specific extra data attached to a specifier
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
817 max_align_t data[1];
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
818 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
819
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
820 The description map means "retrieve a pointer into the object at offset
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
821 `offsetof (Lisp_Specifier, methods)' , then in turn retrieve a pointer
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
822 into that object at offset `offsetof (struct specifier_methods,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
823 extra_description)', and that is the sized_memory_description to use."
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
824 There can be any number of indirections, which can be either into
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
825 straight pointers or Lisp_Objects. The way that description maps are
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
826 distinguished from normal sized_memory_descriptions is that in the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
827 former, the memory_description pointer is NULL.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
828
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
829 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
830
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
831
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
832 The existing types :
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
833
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
834
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 XD_LISP_OBJECT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
836
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
837 A Lisp object. This is also the type to use for pointers to other lrecords
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
838 (e.g. struct frame *).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
840 XD_LISP_OBJECT_ARRAY
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
841
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
842 An array of Lisp objects or (equivalently) pointers to lrecords.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
843 The parameter (i.e. third element) is the count. This would be declared
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
844 as Lisp_Object foo[666]. For something declared as Lisp_Object *foo,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
845 use XD_BLOCK_PTR, whose description parameter is a sized_memory_description
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
846 consisting of only XD_LISP_OBJECT and XD_END.
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
847
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 XD_LO_LINK
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
849
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
850 Weak link in a linked list of objects of the same type. This is a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
851 link that does NOT generate a GC reference. Thus the pdumper will
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
852 not automatically add the referenced object to the table of all
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
853 objects to be dumped, and when storing and loading the dumped data
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
854 will automatically prune unreferenced objects in the chain and link
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
855 each referenced object to the next referenced object, even if it's
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
856 many links away. We also need to special handling of a similar
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
857 nature for the root of the chain, which will be a staticpro()ed
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
858 object.
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
859
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 XD_OPAQUE_PTR
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
861
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 Pointer to undumpable data. Must be NULL when dumping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
864 XD_OPAQUE_PTR_CONVERTIBLE
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
865
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
866 Pointer to data which is not directly dumpable but can be converted
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
867 to a dumpable, opaque external representation. The parameter is
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
868 a pointer to an opaque_convert_functions struct.
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
869
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
870 XD_OPAQUE_DATA_CONVERTIBLE
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
871
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
872 Data which is not directly dumpable but can be converted to a
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
873 dumpable, opaque external representation. The parameter is a
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
874 pointer to an opaque_convert_functions struct.
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
875
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
876 XD_BLOCK_PTR
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
877
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
878 Pointer to block of described memory. (This is misnamed: It is NOT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
879 necessarily a pointer to a struct foo.) Parameters are number of
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
880 contiguous blocks and sized_memory_description.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
881
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
882 XD_BLOCK_ARRAY
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
883
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
884 Array of blocks of described memory. Parameters are number of
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
885 structures and sized_memory_description. This differs from XD_BLOCK_PTR
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
886 in that the parameter is declared as struct foo[666] instead of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
887 struct *foo. In other words, the block of memory holding the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
888 structures is within the containing structure, rather than being
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
889 elsewhere, with a pointer in the containing structure.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
891 NOTE NOTE NOTE: Be sure that you understand the difference between
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
892 XD_BLOCK_PTR and XD_BLOCK_ARRAY:
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
893 - struct foo bar[666], i.e. 666 inline struct foos
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
894 --> XD_BLOCK_ARRAY, argument 666, pointing to a description of
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
895 struct foo
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
896 - struct foo *bar, i.e. pointer to a block of 666 struct foos
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
897 --> XD_BLOCK_PTR, argument 666, pointing to a description of
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
898 struct foo
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
899 - struct foo *bar[666], i.e. 666 pointers to separate blocks of struct foos
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
900 --> XD_BLOCK_ARRAY, argument 666, pointing to a description of
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
901 a single pointer to struct foo; the description is a single
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
902 XD_BLOCK_PTR, argument 1, which in turn points to a description
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
903 of struct foo.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
904
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
905 NOTE also that an XD_BLOCK_PTR of 666 foos is equivalent to an
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
906 XD_BLOCK_PTR of 1 bar, where the description of `bar' is an
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
907 XD_BLOCK_ARRAY of 666 foos.
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
908
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 XD_OPAQUE_DATA_PTR
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
910
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 Pointer to dumpable opaque data. Parameter is the size of the data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 Pointed data must be relocatable without changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
914 XD_UNION
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
915
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
916 Union of two or more different types of data. Parameters are a constant
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
917 which determines which type the data is (this is usually an XD_INDIRECT,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
918 referring to one of the fields in the structure), and a "sizing lobby" (a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
919 sized_memory_description, which points to a memory_description and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
920 indicates its size). The size field in the sizing lobby describes the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
921 size of the union field in the object, and the memory_description in it
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
922 is referred to as a "union map" and has a special interpretation: The
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
923 offset field is replaced by a constant, which is compared to the first
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
924 parameter of the XD_UNION descriptor to determine if this description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
925 applies to the union data, and XD_INDIRECT references refer to the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
926 containing object and description. Note that the description applies
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
927 "inline" to the union data, like XD_BLOCK_ARRAY and not XD_BLOCK_PTR.
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
928 If the union data is a pointer to different types of structures, each
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
929 element in the memory_description should be an XD_BLOCK_PTR. See
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
930 unicode.c, redisplay.c and objects.c for examples of XD_UNION.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
931
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
932 XD_UNION_DYNAMIC_SIZE
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
933
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
934 Same as XD_UNION except that this is used for objects where the size of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
935 the object containing the union varies depending on the particular value
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
936 of the union constant. That is, an object with plain XD_UNION typically
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
937 has the union declared as `union foo' or as `void *', where an object
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
938 with XD_UNION_DYNAMIC_SIZE typically has the union as the last element,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
939 and declared as something like Rawbyte foo[1]. With plain XD_UNION, the
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
940 object is (usually) of fixed size and always contains enough space for
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
941 the data associated with all possible union constants, and thus the union
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
942 constant can potentially change during the lifetime of the object. With
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
943 XD_UNION_DYNAMIC_SIZE, however, the union constant is fixed at the time
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
944 of creation of the object, and the size of the object is computed
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
945 dynamically at creation time based on the size of the data associated
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
946 with the union constant. Currently, the only difference between XD_UNION
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
947 and XD_UNION_DYNAMIC_SIZE is how the size of the union data is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
948 calculated, when (a) the structure containing the union has no size
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
949 given; (b) the union occurs as the last element in the structure; and (c)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
950 the union has no size given (in the first-level sized_memory_description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
951 pointed to). In this circumstance, the size of XD_UNION comes from the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
952 max size of the data associated with all possible union constants,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
953 whereas the size of XD_UNION_DYNAMIC_SIZE comes from the size of the data
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
954 associated with the currently specified (and unchangeable) union
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
955 constant.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
956
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
957 XD_ASCII_STRING
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
958
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
959 Pointer to a C string, purely ASCII.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 XD_DOC_STRING
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
962
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
963 Pointer to a doc string (C string in pure ASCII if positive,
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
964 opaque value if negative)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 XD_INT_RESET
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
967
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 An integer which will be reset to a given value in the dump file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
970 XD_ELEMCOUNT
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
971
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
972 Elemcount value. Used for counts.
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
973
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
974 XD_BYTECOUNT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
975
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
976 Bytecount value. Used for counts.
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
977
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
978 XD_HASHCODE
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
979
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
980 Hashcode value. Used for the results of hashing functions.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 XD_INT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
983
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 int value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 XD_LONG
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
987
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 long value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
990 XD_BYTECOUNT
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
991
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
992 bytecount value. Used for counts.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
993
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 XD_END
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
995
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 Special type indicating the end of the array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 Special macros:
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1000
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1001 XD_INDIRECT (line, delta)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1002 Usable where a count, size, offset or union constant is requested. Gives
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1003 the value of the element which is at line number 'line' in the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1004 description (count starts at zero) and adds delta to it, which must
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1005 (currently) be positive.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1008 enum memory_description_type
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
1009 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
1010 XD_LISP_OBJECT_ARRAY,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 XD_LISP_OBJECT,
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
1012 #ifdef NEW_GC
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
1013 XD_LISP_OBJECT_BLOCK_PTR,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
1014 #endif /* NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 XD_LO_LINK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 XD_OPAQUE_PTR,
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1017 XD_OPAQUE_PTR_CONVERTIBLE,
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1018 XD_OPAQUE_DATA_CONVERTIBLE,
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1019 XD_OPAQUE_DATA_PTR,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1020 XD_BLOCK_PTR,
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1021 XD_BLOCK_ARRAY,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1022 XD_UNION,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1023 XD_UNION_DYNAMIC_SIZE,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1024 XD_ASCII_STRING,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 XD_DOC_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 XD_INT_RESET,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1027 XD_BYTECOUNT,
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1028 XD_ELEMCOUNT,
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1029 XD_HASHCODE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 XD_INT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 XD_LONG,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1032 XD_END
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1035 enum data_description_entry_flags
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
1036 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1037 /* If set, KKCC does not process this entry.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1038
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1039 (1) One obvious use is with things that pdump saves but which do not get
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1040 marked normally -- for example the next and prev fields in a marker. The
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1041 marker chain is weak, with its entries removed when they are finalized.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1042
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1043 (2) This can be set on structures not containing any Lisp objects, or (more
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1044 usefully) on structures that contain Lisp objects but where the objects
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1045 always occur in another structure as well. For example, the extent lists
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1046 kept by a buffer keep the extents in two lists, one sorted by the start
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1047 of the extent and the other by the end. There's no point in marking
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1048 both, since each contains the same objects as the other; but when dumping
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1049 (if we were to dump such a structure), when computing memory size, etc.,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1050 it's crucial to tag both sides.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1051 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1052 XD_FLAG_NO_KKCC = 1,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1053 /* If set, pdump does not process this entry. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1054 XD_FLAG_NO_PDUMP = 2,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1055 /* Indicates that this is a "default" entry in a union map. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1056 XD_FLAG_UNION_DEFAULT_ENTRY = 4,
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1057 #ifndef NEW_GC
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1058 /* Indicates that this is a free Lisp object we're marking.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1059 Only relevant for ERROR_CHECK_GC. This occurs when we're marking
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1060 lcrecord-lists, where the objects have had their type changed to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1061 lrecord_type_free and also have had their free bit set, but we mark
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1062 them as normal. */
1429
969b7290edca [xemacs-hg @ 2003-04-24 05:33:43 by youngs]
youngs
parents: 1330
diff changeset
1063 XD_FLAG_FREE_LISP_OBJECT = 8
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1064 #endif /* not NEW_GC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1065 #if 0
1429
969b7290edca [xemacs-hg @ 2003-04-24 05:33:43 by youngs]
youngs
parents: 1330
diff changeset
1066 ,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1067 /* Suggestions for other possible flags: */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1068
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1069 /* Eliminate XD_UNION_DYNAMIC_SIZE and replace it with a flag, like this. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1070 XD_FLAG_UNION_DYNAMIC_SIZE = 16,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1071 /* Require that everyone who uses a description map has to flag it, so
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1072 that it's easy to tell, when looking through the code, where the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1073 description maps are and who's using them. This might also become
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1074 necessary if for some reason the format of the description map is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1075 expanded and we need to stick a pointer in the second slot (although
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1076 we could still ensure that the second slot in the first entry was NULL
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1077 or <0). */
1429
969b7290edca [xemacs-hg @ 2003-04-24 05:33:43 by youngs]
youngs
parents: 1330
diff changeset
1078 XD_FLAG_DESCRIPTION_MAP = 32
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1079 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1082 union memory_contents_description
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1083 {
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1084 /* The first element is used by static initializers only. We always read
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1085 from one of the other two pointers. */
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1086 const void *write_only;
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1087 const struct sized_memory_description *descr;
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1088 const struct opaque_convert_functions *funcs;
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1089 };
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1090
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1091 struct memory_description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1092 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1093 enum memory_description_type type;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1094 Bytecount offset;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1095 EMACS_INT data1;
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1096 union memory_contents_description data2;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1097 /* Indicates which subsystems process this entry, plus (potentially) other
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1098 flags that apply to this entry. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1099 int flags;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1100 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1102 struct sized_memory_description
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1103 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1104 Bytecount size;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1105 const struct memory_description *description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1106 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1107
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1108
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1109 struct opaque_convert_functions
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1110 {
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1111 /* Used by XD_OPAQUE_PTR_CONVERTIBLE and
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1112 XD_OPAQUE_DATA_CONVERTIBLE */
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1113
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1114 /* Converter to external representation, for those objects from
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1115 external libraries that can't be directly dumped as opaque data
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1116 because they contain pointers. This is called at dump time to
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1117 convert to an opaque, pointer-less representation.
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1118
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1119 This function must put a pointer to the opaque result in *data
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1120 and its size in *size. */
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1121 void (*convert)(const void *object, void **data, Bytecount *size);
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1122
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1123 /* Post-conversion cleanup. Optional (null if not provided).
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1124
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1125 When provided it will be called post-dumping to free any storage
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1126 allocated for the conversion results. */
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1127 void (*convert_free)(const void *object, void *data, Bytecount size);
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1128
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1129 /* De-conversion.
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1130
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1131 At reload time, rebuilds the object from the converted form.
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1132 "object" is 0 for the PTR case, return is ignored in the DATA
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1133 case. */
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1134 void *(*deconvert)(void *object, void *data, Bytecount size);
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1135
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1136 };
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1137
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1138 extern const struct sized_memory_description lisp_object_description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1139
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1140 #define XD_INDIRECT(val, delta) (-1 - (Bytecount) ((val) | ((delta) << 8)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1142 #define XD_IS_INDIRECT(code) ((code) < 0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1143 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1144 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1145
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1150 #if defined (ERROR_CHECK_TYPES)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1151 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 #else
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1153 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1156
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1157 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1158 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1159
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1160 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1161 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof(structtype),0,1,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1162
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1163 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1164 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1165
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1166 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1167 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1168
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1169 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1170 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1171
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1172 #define DEFINE_BASIC_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1173 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,0,sizer,1,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1174
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1175 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1176 MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1177
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1178 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1179 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1180 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1181 const struct lrecord_implementation lrecord_##c_name = \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1182 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1183 getprop, putprop, remprop, plist, size, sizer, \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1184 lrecord_type_##c_name }
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1185 #else /* not NEW_GC */
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1186 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1187 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1188 const struct lrecord_implementation lrecord_##c_name = \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1189 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1190 getprop, putprop, remprop, plist, size, sizer, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1191 lrecord_type_##c_name, basic_p }
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1192 #endif /* not NEW_GC */
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1193
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1194 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1195 DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1196
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1197 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1198 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1199
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1200 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1201 DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1202
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1203 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1204 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1205
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1206 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1207 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1208 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1209 int lrecord_type_##c_name; \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1210 struct lrecord_implementation lrecord_##c_name = \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1211 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1212 getprop, putprop, remprop, plist, size, sizer, \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1213 lrecord_type_last_built_in_type }
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1214 #else /* not NEW_GC */
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1215 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1216 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1217 int lrecord_type_##c_name; \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1218 struct lrecord_implementation lrecord_##c_name = \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1219 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1220 getprop, putprop, remprop, plist, size, sizer, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1221 lrecord_type_last_built_in_type, basic_p }
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1222 #endif /* not NEW_GC */
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
1223
1676
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1224 #ifdef USE_KKCC
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1225 extern MODULE_API const struct memory_description *lrecord_memory_descriptions[];
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1226
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1227 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1228 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1229 lrecord_memory_descriptions[lrecord_type_##type] = \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1230 lrecord_implementations_table[lrecord_type_##type]->description; \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1231 } while (0)
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1232 #else /* not USE_KKCC */
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1233 extern MODULE_API Lisp_Object (*lrecord_markers[]) (Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1234
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1235 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1236 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1237 lrecord_markers[lrecord_type_##type] = \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1238 lrecord_implementations_table[lrecord_type_##type]->marker; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1239 } while (0)
1676
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1240 #endif /* not USE_KKCC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1242 #define INIT_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1243 lrecord_type_##type = lrecord_type_count++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1244 lrecord_##type.lrecord_type_index = lrecord_type_##type; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1245 INIT_LRECORD_IMPLEMENTATION(type); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1246 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1247
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1248 #ifdef HAVE_SHLIB
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1249 /* Allow undefining types in order to support module unloading. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1250
1676
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1251 #ifdef USE_KKCC
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1252 #define UNDEF_LRECORD_IMPLEMENTATION(type) do { \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1253 lrecord_implementations_table[lrecord_type_##type] = NULL; \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1254 lrecord_memory_descriptions[lrecord_type_##type] = NULL; \
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1255 } while (0)
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1256 #else /* not USE_KKCC */
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1257 #define UNDEF_LRECORD_IMPLEMENTATION(type) do { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1258 lrecord_implementations_table[lrecord_type_##type] = NULL; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1259 lrecord_markers[lrecord_type_##type] = NULL; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1260 } while (0)
1676
a72f7bf813c9 [xemacs-hg @ 2003-09-11 09:11:07 by crestani]
crestani
parents: 1650
diff changeset
1261 #endif /* not USE_KKCC */
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1262
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1263 #define UNDEF_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1264 if (lrecord_##type.lrecord_type_index == lrecord_type_count - 1) { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1265 /* This is the most recently defined type. Clean up nicely. */ \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1266 lrecord_type_##type = lrecord_type_count--; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1267 } /* Else we can't help leaving a hole with this implementation. */ \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1268 UNDEF_LRECORD_IMPLEMENTATION(type); \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1269 } while (0)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1270
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1271 #endif /* HAVE_SHLIB */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
1272
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 #define RECORD_TYPEP(x, ty) \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
1277 (LRECORDP (x) && (XRECORD_LHEADER (x)->type == (unsigned int) (ty)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1278
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1279 /* Steps to create a new object:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1280
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1281 1. Declare the struct for your object in a header file somewhere.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1282 Remember that it must begin with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1283
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2994
diff changeset
1284 struct LCRECORD_HEADER header;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1285
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
1286 2. Put the "standard junk" (DECLARE_RECORD()/XFOO/etc.) below the
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1287 struct definition -- see below.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1288
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1289 3. Add this header file to inline.c.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1290
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1291 4. Create the methods for your object. Note that technically you don't
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1292 need any, but you will almost always want at least a mark method.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1293
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1294 4. Create the data layout description for your object. See
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1295 toolbar_button_description below; the comment above in `struct lrecord',
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1296 describing the purpose of the descriptions; and comments elsewhere in
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1297 this file describing the exact syntax of the description structures.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1298
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1299 6. Define your object with DEFINE_LRECORD_IMPLEMENTATION() or some
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1300 variant.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1301
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1302 7. Include the header file in the .c file where you defined the object.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1303
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1304 8. Put a call to INIT_LRECORD_IMPLEMENTATION() for the object in the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1305 .c file's syms_of_foo() function.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1306
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1307 9. Add a type enum for the object to enum lrecord_type, earlier in this
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1308 file.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1309
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1310 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1311
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1312 An example:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1314 ------------------------------ in toolbar.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1315
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1316 struct toolbar_button
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1317 {
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2994
diff changeset
1318 struct LCRECORD_HEADER header;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1319
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1320 Lisp_Object next;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1321 Lisp_Object frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1322
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1323 Lisp_Object up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1324 Lisp_Object down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1325 Lisp_Object disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1326
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1327 Lisp_Object cap_up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1328 Lisp_Object cap_down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1329 Lisp_Object cap_disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1330
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1331 Lisp_Object callback;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1332 Lisp_Object enabled_p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1333 Lisp_Object help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1334
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1335 char enabled;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1336 char down;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1337 char pushright;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1338 char blank;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1339
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1340 int x, y;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1341 int width, height;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1342 int dirty;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1343 int vertical;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1344 int border_width;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1345 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1347 [[ the standard junk: ]]
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1348
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1349 DECLARE_LRECORD (toolbar_button, struct toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1350 #define XTOOLBAR_BUTTON(x) XRECORD (x, toolbar_button, struct toolbar_button)
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1351 #define wrap_toolbar_button(p) wrap_record (p, toolbar_button)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1352 #define TOOLBAR_BUTTONP(x) RECORDP (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1353 #define CHECK_TOOLBAR_BUTTON(x) CHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1354 #define CONCHECK_TOOLBAR_BUTTON(x) CONCHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1355
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1356 ------------------------------ in toolbar.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1357
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1358 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1359
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1360 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1361
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1362 static const struct memory_description toolbar_button_description [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1363 { XD_LISP_OBJECT, offsetof (struct toolbar_button, next) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1364 { XD_LISP_OBJECT, offsetof (struct toolbar_button, frame) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1365 { XD_LISP_OBJECT, offsetof (struct toolbar_button, up_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1366 { XD_LISP_OBJECT, offsetof (struct toolbar_button, down_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1367 { XD_LISP_OBJECT, offsetof (struct toolbar_button, disabled_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1368 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_up_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1369 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_down_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1370 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_disabled_glyph) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1371 { XD_LISP_OBJECT, offsetof (struct toolbar_button, callback) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1372 { XD_LISP_OBJECT, offsetof (struct toolbar_button, enabled_p) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1373 { XD_LISP_OBJECT, offsetof (struct toolbar_button, help_string) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1374 { XD_END }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1375 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1376
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1377 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1378 mark_toolbar_button (Lisp_Object obj)
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1379 \{
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1380 struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1381 mark_object (data->next);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1382 mark_object (data->frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1383 mark_object (data->up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1384 mark_object (data->down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1385 mark_object (data->disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1386 mark_object (data->cap_up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1387 mark_object (data->cap_down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1388 mark_object (data->cap_disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1389 mark_object (data->callback);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1390 mark_object (data->enabled_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1391 return data->help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1392 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1393
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1394 [[ If your object should never escape to Lisp, declare its print method
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1395 as internal_object_printer instead of 0. ]]
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1396
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1397 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1398 0, mark_toolbar_button, 0, 0, 0, 0,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1399 toolbar_button_description,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1400 struct toolbar_button);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1401
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1402 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1403
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1404 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1405 syms_of_toolbar (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1406 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1407 INIT_LRECORD_IMPLEMENTATION (toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1408
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1409 ...;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1410 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1411
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1412 ------------------------------ in inline.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1413
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1414 #ifdef HAVE_TOOLBARS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1415 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1416 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1417
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1418 ------------------------------ in lrecord.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1419
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1420 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1421 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1422 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1423 lrecord_type_toolbar_button,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1424 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1425 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1426
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1427
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1428 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1429
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1430 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1431
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1432 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1433
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1434 Note: Object types defined in external dynamically-loaded modules (not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1435 part of the XEmacs main source code) should use DECLARE_EXTERNAL_LRECORD
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1436 and DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION rather than DECLARE_LRECORD
3029
986cd22006a9 [xemacs-hg @ 2005-10-26 13:01:37 by stephent]
stephent
parents: 3024
diff changeset
1437 and DEFINE_LRECORD_IMPLEMENTATION. The EXTERNAL versions declare and
986cd22006a9 [xemacs-hg @ 2005-10-26 13:01:37 by stephent]
stephent
parents: 3024
diff changeset
1438 allocate an enumerator for the type being defined.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1439
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1440 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1441
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1443 #ifdef ERROR_CHECK_TYPES
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1445 # define DECLARE_LRECORD(c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1446 extern const struct lrecord_implementation lrecord_##c_name; \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1447 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1448 structtype * \
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1449 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1450 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1451 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1452 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1453 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1454 } \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1457 # define DECLARE_MODULE_API_LRECORD(c_name, structtype) \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1458 extern MODULE_API const struct lrecord_implementation lrecord_##c_name; \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1459 DECLARE_INLINE_HEADER ( \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1460 structtype * \
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1461 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1462 ) \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1463 { \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1464 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1465 return (structtype *) XPNTR (obj); \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1466 } \
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1467 extern MODULE_API Lisp_Object Q##c_name##p
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1468
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1469 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1470 extern int lrecord_type_##c_name; \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1471 extern struct lrecord_implementation lrecord_##c_name; \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1472 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1473 structtype * \
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1474 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1475 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1476 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1477 assert_at_line (RECORD_TYPEP (obj, lrecord_type_##c_name), file, line); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1478 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1479 } \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1480 extern Lisp_Object Q##c_name##p
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1481
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1482 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1483 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1484 structtype * \
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1485 error_check_##c_name (Lisp_Object obj, const Ascbyte *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1486 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1487 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1488 assert_at_line (XTYPE (obj) == type_enum, file, line); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1489 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1490 } \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1493 # define XRECORD(x, c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1494 error_check_##c_name (x, __FILE__, __LINE__)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1495 # define XNONRECORD(x, c_name, type_enum, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1496 error_check_##c_name (x, __FILE__, __LINE__)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1498 DECLARE_INLINE_HEADER (
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1499 Lisp_Object
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1500 wrap_record_1 (const void *ptr, enum lrecord_type ty, const Ascbyte *file,
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1501 int line)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1502 )
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1503 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
1504 Lisp_Object obj = wrap_pointer_1 (ptr);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
1505
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1506 assert_at_line (RECORD_TYPEP (obj, ty), file, line);
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1507 return obj;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1508 }
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1509
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1510 #define wrap_record(ptr, ty) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
1511 wrap_record_1 (ptr, lrecord_type_##ty, __FILE__, __LINE__)
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1512
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1513 #else /* not ERROR_CHECK_TYPES */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 # define DECLARE_LRECORD(c_name, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 extern Lisp_Object Q##c_name##p; \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1517 extern const struct lrecord_implementation lrecord_##c_name
1638
1ecc2785dce3 [xemacs-hg @ 2003-08-21 14:08:32 by james]
james
parents: 1632
diff changeset
1518 # define DECLARE_MODULE_API_LRECORD(c_name, structtype) \
1ecc2785dce3 [xemacs-hg @ 2003-08-21 14:08:32 by james]
james
parents: 1632
diff changeset
1519 extern MODULE_API Lisp_Object Q##c_name##p; \
1ecc2785dce3 [xemacs-hg @ 2003-08-21 14:08:32 by james]
james
parents: 1632
diff changeset
1520 extern MODULE_API const struct lrecord_implementation lrecord_##c_name
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1521 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1522 extern Lisp_Object Q##c_name##p; \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
1523 extern int lrecord_type_##c_name; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1524 extern struct lrecord_implementation lrecord_##c_name
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 # define XNONRECORD(x, c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 ((structtype *) XPNTR (x))
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1530 /* wrap_pointer_1 is so named as a suggestion not to use it unless you
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1531 know what you're doing. */
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1532 #define wrap_record(ptr, ty) wrap_pointer_1 (ptr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1534 #endif /* not ERROR_CHECK_TYPES */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1536 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 /* Note: we now have two different kinds of type-checking macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 The "old" kind has now been renamed CONCHECK_foo. The reason for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 this is that the CONCHECK_foo macros signal a continuable error,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 allowing the user (through debug-on-error) to substitute a different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 value and return from the signal, which causes the lvalue argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 to get changed. Quite a lot of code would crash if that happened,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 because it did things like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 foo = XCAR (list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 CHECK_STRING (foo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 and later on did XSTRING (XCAR (list)), assuming that the type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 is correct (when it might be wrong, if the user substituted a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 correct value in the debugger).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 To get around this, I made all the CHECK_foo macros signal a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 non-continuable error. Places where a continuable error is OK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 (generally only when called directly on the argument of a Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 primitive) should be changed to use CONCHECK().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 FSF Emacs does not have this problem because RMS took the cheesy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 way out and disabled returning from a signal entirely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 #define CONCHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1562 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 x = wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 x = wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 #define CHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1570 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 dead_wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 dead_wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1578 #ifndef NEW_GC
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1579 /*-------------------------- lcrecord-list -----------------------------*/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1580
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1581 struct lcrecord_list
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1582 {
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1583 struct LCRECORD_HEADER header;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1584 Lisp_Object free;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1585 Elemcount size;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1586 const struct lrecord_implementation *implementation;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1587 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1588
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1589 DECLARE_LRECORD (lcrecord_list, struct lcrecord_list);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1590 #define XLCRECORD_LIST(x) XRECORD (x, lcrecord_list, struct lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1591 #define wrap_lcrecord_list(p) wrap_record (p, lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1592 #define LCRECORD_LISTP(x) RECORDP (x, lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1593 /* #define CHECK_LCRECORD_LIST(x) CHECK_RECORD (x, lcrecord_list)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1594 Lcrecord lists should never escape to the Lisp level, so
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1595 functions should not be doing this. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1596
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1597 /* Various ways of allocating lcrecords. All bytes (except lcrecord
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1598 header) are zeroed in returned structure.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1599
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1600 See above for a discussion of the difference between plain lrecords and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1601 lrecords. lcrecords themselves are divided into three types: (1)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1602 auto-managed, (2) hand-managed, and (3) unmanaged. "Managed" refers to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1603 using a special object called an lcrecord-list to keep track of freed
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1604 lcrecords, which can freed with FREE_LCRECORD() or the like and later be
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1605 recycled when a new lcrecord is required, rather than requiring new
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1606 malloc(). Thus, allocation of lcrecords can be very
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1607 cheap. (Technically, the lcrecord-list manager could divide up large
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1608 chunks of memory and allocate out of that, mimicking what happens with
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1609 lrecords. At that point, however, we'd want to rethink the whole
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1610 division between lrecords and lcrecords.)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1611
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1612 NOTE: There is a fundamental limitation of lcrecord-lists, which is that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1613 they only handle blocks of a particular, fixed size. Thus, objects that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1614 can be of varying sizes need to do various tricks. These considerations
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1615 in particular dictate the various types of management:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1616
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1617 -- "Auto-managed" means that you just go ahead and allocate the lcrecord
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1618 whenever you want, using old_alloc_lcrecord_type(), and the appropriate
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1619 lcrecord-list manager is automatically created. To free, you just call
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1620 "FREE_LCRECORD()" and the appropriate lcrecord-list manager is
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1621 automatically located and called. The limitation here of course is that
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1622 all your objects are of the same size. (#### Eventually we should have a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1623 more sophisticated system that tracks the sizes seen and creates one
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1624 lcrecord list per size, indexed in a hash table. Usually there are only
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1625 a limited number of sizes, so this works well.)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1626
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1627 -- "Hand-managed" exists because we haven't yet written the more
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1628 sophisticated scheme for auto-handling different-sized lcrecords, as
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1629 described in the end of the last paragraph. In this model, you go ahead
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1630 and create the lcrecord-list objects yourself for the sizes you will
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1631 need, using make_lcrecord_list(). Then, create lcrecords using
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1632 alloc_managed_lcrecord(), passing in the lcrecord-list you created, and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1633 free them with free_managed_lcrecord().
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1634
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1635 -- "Unmanaged" means you simply allocate lcrecords, period. No
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1636 lcrecord-lists, no way to free them. This may be suitable when the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1637 lcrecords are variable-sized and (a) you're too lazy to write the code
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1638 to hand-manage them, or (b) the objects you create are always or almost
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1639 always Lisp-visible, and thus there's no point in freeing them (and it
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1640 wouldn't be safe to do so). You just create them with
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1641 BASIC_ALLOC_LCRECORD(), and that's it.
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1642
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1643 --ben
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1644
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1645 Here is an in-depth look at the steps required to create a allocate an
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1646 lcrecord using the hand-managed style. Since this is the most
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1647 complicated, you will learn a lot about the other styles as well. In
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1648 addition, there is useful general information about what freeing an
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1649 lcrecord really entails, and what are the precautions:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1650
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1651 1) Create an lcrecord-list object using make_lcrecord_list(). This is
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1652 often done at initialization. Remember to staticpro_nodump() this
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1653 object! The arguments to make_lcrecord_list() are the same as would be
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1654 passed to BASIC_ALLOC_LCRECORD().
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1656 2) Instead of calling BASIC_ALLOC_LCRECORD(), call alloc_managed_lcrecord()
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1657 and pass the lcrecord-list earlier created.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1658
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1659 3) When done with the lcrecord, call free_managed_lcrecord(). The
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1660 standard freeing caveats apply: ** make sure there are no pointers to
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1661 the object anywhere! **
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1662
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1663 4) Calling free_managed_lcrecord() is just like kissing the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1664 lcrecord goodbye as if it were garbage-collected. This means:
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1665 -- the contents of the freed lcrecord are undefined, and the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1666 contents of something produced by alloc_managed_lcrecord()
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1667 are undefined, just like for BASIC_ALLOC_LCRECORD().
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1668 -- the mark method for the lcrecord's type will *NEVER* be called
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1669 on freed lcrecords.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1670 -- the finalize method for the lcrecord's type will be called
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1671 at the time that free_managed_lcrecord() is called.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1672 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1673
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1674 /* UNMANAGED MODEL: */
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1675 void *old_basic_alloc_lcrecord (Bytecount size,
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1676 const struct lrecord_implementation *);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1677
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1678 /* HAND-MANAGED MODEL: */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1679 Lisp_Object make_lcrecord_list (Elemcount size,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1680 const struct lrecord_implementation
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1681 *implementation);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1682 Lisp_Object alloc_managed_lcrecord (Lisp_Object lcrecord_list);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1683 void free_managed_lcrecord (Lisp_Object lcrecord_list, Lisp_Object lcrecord);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1684
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1685 /* AUTO-MANAGED MODEL: */
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1686 MODULE_API void *
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1687 alloc_automanaged_lcrecord (Bytecount size,
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1688 const struct lrecord_implementation *);
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2994
diff changeset
1689
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1690 #define old_alloc_lcrecord_type(type, lrecord_implementation) \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1691 ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1692
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1693 void old_free_lcrecord (Lisp_Object rec);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1694
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 /* Copy the data from one lcrecord structure into another, but don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 overwrite the header information. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1699 #define old_copy_sized_lcrecord(dst, src, size) \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1700 memcpy ((Rawbyte *) (dst) + sizeof (struct old_lcrecord_header), \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1701 (Rawbyte *) (src) + sizeof (struct old_lcrecord_header), \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1702 (size) - sizeof (struct old_lcrecord_header))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1703
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1704 #define old_copy_lcrecord(dst, src) \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1705 old_copy_sized_lcrecord (dst, src, sizeof (*(dst)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1707 #define old_zero_sized_lcrecord(lcr, size) \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1708 memset ((Rawbyte *) (lcr) + sizeof (struct old_lcrecord_header), 0, \
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1709 (size) - sizeof (struct old_lcrecord_header))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1710
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 3017
diff changeset
1711 #define old_zero_lcrecord(lcr) old_zero_sized_lcrecord (lcr, sizeof (*(lcr)))
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1712
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1713 #else /* NEW_GC */
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1714
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1715 /* How to allocate a lrecord:
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1716
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1717 - If the size of the lrecord is fix, say it equals its size of its
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1718 struct, then use alloc_lrecord_type.
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1719
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1720 - If the size varies, i.e. it is not equal to the size of its
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1721 struct, use alloc_lrecord and specify the amount of storage you
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1722 need for the object.
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1723
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1724 - Some lrecords, which are used totally internally, use the
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1725 noseeum-* functions for the reason of debugging.
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1726
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1727 - To free a Lisp_Object manually, use free_lrecord. */
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1728
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1729 void *alloc_lrecord (Bytecount size,
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1730 const struct lrecord_implementation *);
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1731
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
1732 void *alloc_lrecord_array (Bytecount size, int elemcount,
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
1733 const struct lrecord_implementation *);
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3063
diff changeset
1734
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1735 #define alloc_lrecord_type(type, lrecord_implementation) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1736 ((type *) alloc_lrecord (sizeof (type), lrecord_implementation))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1737
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1738 void *noseeum_alloc_lrecord (Bytecount size,
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1739 const struct lrecord_implementation *);
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1740
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1741 #define noseeum_alloc_lrecord_type(type, lrecord_implementation) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1742 ((type *) noseeum_alloc_lrecord (sizeof (type), lrecord_implementation))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1743
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1744 void free_lrecord (Lisp_Object rec);
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1745
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1746
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1747 /* Copy the data from one lrecord structure into another, but don't
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1748 overwrite the header information. */
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1749
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1750 #define copy_sized_lrecord(dst, src, size) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1751 memcpy ((char *) (dst) + sizeof (struct lrecord_header), \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1752 (char *) (src) + sizeof (struct lrecord_header), \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1753 (size) - sizeof (struct lrecord_header))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1754
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1755 #define copy_lrecord(dst, src) copy_sized_lrecord (dst, src, sizeof (*(dst)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1756
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1757 #endif /* NEW_GC */
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 2994
diff changeset
1758
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1759 #define zero_sized_lrecord(lcr, size) \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1760 memset ((char *) (lcr) + sizeof (struct lrecord_header), 0, \
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1761 (size) - sizeof (struct lrecord_header))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1762
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1763 #define zero_lrecord(lcr) zero_sized_lrecord (lcr, sizeof (*(lcr)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1764
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1765 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1766 Bytecount
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1767 detagged_lisp_object_size (const struct lrecord_header *h)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1768 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1769 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1770 const struct lrecord_implementation *imp = LHEADER_IMPLEMENTATION (h);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1771
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1772 return (imp->size_in_bytes_method ?
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1773 imp->size_in_bytes_method (h) :
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1774 imp->static_size);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1775 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1776
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1777 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1778 Bytecount
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1779 lisp_object_size (Lisp_Object o)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1780 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1781 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1782 return detagged_lisp_object_size (XRECORD_LHEADER (o));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1783 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1784
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1785
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1786 /************************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1787 /* Dumping */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1788 /************************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1789
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1790 /* dump_add_root_block_ptr (&var, &desc) dumps the structure pointed to by
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1791 `var'. This is for a single relocatable pointer located in the data
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1792 segment (i.e. the block pointed to is in the heap).
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1793
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1794 If the structure pointed to is not a `struct' but an array, you should
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1795 set the size field of the sized_memory_description to 0, and use
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1796 XD_BLOCK_ARRAY in the inner memory_description.
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1797
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1798 NOTE that a "root struct pointer" could also be described using
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1799 dump_add_root_block(), with SIZE == sizeof (void *), and a description
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1800 containing a single XD_BLOCK_PTR entry, offset 0, size 1, with a
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1801 structure description the same as the value passed to
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1802 dump_add_root_block_ptr(). That would require an extra level of
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1803 description, though, as compared to using dump_add_root_block_ptr(),
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1804 and thus this function is generally more convenient.
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1805 */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1806 #ifdef PDUMP
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1807 void dump_add_root_block_ptr (void *, const struct sized_memory_description *);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1808 #else
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1809 #define dump_add_root_block_ptr(varaddr, descaddr) DO_NOTHING
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1810 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1811
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1812 /* dump_add_opaque (&var, size) dumps the opaque static structure `var'.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1813 This is for a static block of memory (in the data segment, not the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1814 heap), with no relocatable pointers in it. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1815 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1816 #define dump_add_opaque(varaddr,size) dump_add_root_block (varaddr, size, NULL)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1817 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1818 #define dump_add_opaque(varaddr,size) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1819 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1820
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1821 /* dump_add_root_block (ptr, size, desc) dumps the static structure
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1822 located at `var' of size SIZE and described by DESC. This is for a
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1823 static block of memory (in the data segment, not the heap), with
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1824 relocatable pointers in it. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1825 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1826 void dump_add_root_block (const void *ptraddress, Bytecount size,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1827 const struct memory_description *desc);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1828 #else
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1829 #define dump_add_root_block(ptraddress, size, desc) DO_NOTHING
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1830 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1831
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1832 /* Call dump_add_opaque_int (&int_var) to dump `int_var', of type `int'. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1833 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1834 #define dump_add_opaque_int(int_varaddr) do { \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1835 int *dao_ = (int_varaddr); /* type check */ \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1836 dump_add_opaque (dao_, sizeof (*dao_)); \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1837 } while (0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1838 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1839 #define dump_add_opaque_int(int_varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1840 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1841
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1842 /* Call dump_add_opaque_fixnum (&fixnum_var) to dump `fixnum_var', of type
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1843 `Fixnum'. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1844 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1845 #define dump_add_opaque_fixnum(fixnum_varaddr) do { \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1846 Fixnum *dao_ = (fixnum_varaddr); /* type check */ \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1847 dump_add_opaque (dao_, sizeof (*dao_)); \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1848 } while (0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1849 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1850 #define dump_add_opaque_fixnum(fixnum_varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1851 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1852
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1853 /* Call dump_add_root_lisp_object (&var) to ensure that var is properly
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1854 updated after pdump. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1855 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1856 void dump_add_root_lisp_object (Lisp_Object *);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1857 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1858 #define dump_add_root_lisp_object(varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1859 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1860
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1861 /* Call dump_add_weak_lisp_object (&var) to ensure that var is properly
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1862 updated after pdump. var must point to a linked list of objects out of
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1863 which some may not be dumped */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1864 #ifdef PDUMP
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1865 void dump_add_weak_object_chain (Lisp_Object *);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1866 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1867 #define dump_add_weak_object_chain(varaddr) DO_NOTHING
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1868 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1869
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1870 /* Nonzero means Emacs has already been initialized.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1871 Used during startup to detect startup of dumped Emacs. */
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1429
diff changeset
1872 extern MODULE_API int initialized;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1873
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1874 #ifdef PDUMP
1688
034a2ddf5b6b [xemacs-hg @ 2003-09-16 03:57:54 by james]
james
parents: 1676
diff changeset
1875 #include "dumper.h"
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1876 #ifdef NEW_GC
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2551
diff changeset
1877 #define DUMPEDP(adr) 0
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1878 #else /* not NEW_GC */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1879 #define DUMPEDP(adr) ((((Rawbyte *) (adr)) < pdump_end) && \
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1880 (((Rawbyte *) (adr)) >= pdump_start))
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3100
diff changeset
1881 #endif /* not NEW_GC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1882 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1883 #define DUMPEDP(adr) 0
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1884 #endif
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1885
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1204
diff changeset
1886 #define OBJECT_DUMPED_P(obj) DUMPEDP (XPNTR (obj))
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 1204
diff changeset
1887
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1888 /***********************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1889 /* data descriptions */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1890 /***********************************************************************/
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1891
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1892
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1893 #if defined (USE_KKCC) || defined (PDUMP)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1894
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1895 extern int in_pdump;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1896
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1897 EMACS_INT lispdesc_indirect_count_1 (EMACS_INT code,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1898 const struct memory_description *idesc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1899 const void *idata);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1900 const struct sized_memory_description *lispdesc_indirect_description_1
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1901 (const void *obj, const struct sized_memory_description *sdesc);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1902 Bytecount lispdesc_block_size_1 (const void *obj, Bytecount size,
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1903 const struct memory_description *desc);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1904
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1905 DECLARE_INLINE_HEADER (
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1906 Bytecount lispdesc_block_size (const void *obj,
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1907 const struct sized_memory_description *sdesc))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1908 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1909 return lispdesc_block_size_1 (obj, sdesc->size, sdesc->description);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1983
diff changeset
1910 }
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1911
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1912 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1913 EMACS_INT
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1914 lispdesc_indirect_count (EMACS_INT code,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1915 const struct memory_description *idesc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1916 const void *idata)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1917 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1918 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1919 if (XD_IS_INDIRECT (code))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1920 code = lispdesc_indirect_count_1 (code, idesc, idata);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1921 return code;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1922 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1923
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1924 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1925 const struct sized_memory_description *
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1926 lispdesc_indirect_description (const void *obj,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1927 const struct sized_memory_description *sdesc)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1928 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1929 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1930 if (sdesc->description)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1931 return sdesc;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1932 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1933 return lispdesc_indirect_description_1 (obj, sdesc);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1934 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1935
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1936
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1937 /* Do standard XD_UNION processing. DESC1 is an entry in DESC, which
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1938 describes the entire data structure. Returns NULL (do nothing, nothing
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1939 matched), or a new value for DESC1. In the latter case, assign to DESC1
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1940 in your function and goto union_switcheroo. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1941
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1942 DECLARE_INLINE_HEADER (
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1943 const struct memory_description *
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1944 lispdesc_process_xd_union (const struct memory_description *desc1,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1945 const struct memory_description *desc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1946 const void *data)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1947 )
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1948 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1949 int count = 0;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1950 EMACS_INT variant = lispdesc_indirect_count (desc1->data1, desc,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1951 data);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1952 desc1 =
2551
9f70af3ac939 [xemacs-hg @ 2005-02-03 16:14:02 by james]
james
parents: 2515
diff changeset
1953 lispdesc_indirect_description (data, desc1->data2.descr)->description;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1954
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1955 for (count = 0; desc1[count].type != XD_END; count++)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1956 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1957 if ((desc1[count].flags & XD_FLAG_UNION_DEFAULT_ENTRY) ||
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1958 desc1[count].offset == variant)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1959 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1960 return &desc1[count];
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1961 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1962 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1963
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1964 return NULL;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1965 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1966
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 996
diff changeset
1967 #endif /* defined (USE_KKCC) || defined (PDUMP) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968
1743
543769b89fed [xemacs-hg @ 2003-10-14 05:02:57 by james]
james
parents: 1688
diff changeset
1969 END_C_DECLS
1650
34abfb24e891 [xemacs-hg @ 2003-08-28 15:44:04 by james]
james
parents: 1638
diff changeset
1970
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
1971 #endif /* INCLUDED_lrecord_h_ */