annotate src/lrecord.h @ 996:25e260cb7994

[xemacs-hg @ 2002-09-10 15:27:02 by james] Enable unloading of dynamic modules. Create the first two internal XEmacs modules: LDAP and postgreSQL. Update the sample directory to contain a sample internal XEmacs module and a sample external XEmacs module. Improve support for autoloading modules. Make internal module code compile into the XEmacs binary if XEmacs is configured without module support. Make the internal module directories self-contained so that they can be distributed separately from XEmacs.
author james
date Tue, 10 Sep 2002 15:27:39 +0000
parents c925bacdda60
children e22b0213b713
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.
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3 Copyright (C) 1996, 2001, 2002 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
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
24 #ifndef INCLUDED_lrecord_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
25 #define INCLUDED_lrecord_h_
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* The "lrecord" type of Lisp object is used for all object types
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 other than a few simple ones. This allows many types to be
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 implemented but only a few bits required in a Lisp object for type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30 information. (The tradeoff is that each object has its type marked
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
31 in it, thereby increasing its size.) All lrecords begin with a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
32 `struct lrecord_header', which identifies the lisp object type, by
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
33 providing an index into a table of `struct lrecord_implementation',
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
34 which describes the behavior of the lisp object. It also contains
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
35 some other data bits.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 Lrecords are of two types: straight lrecords, and lcrecords.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 Straight lrecords are used for those types of objects that have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 their own allocation routines (typically allocated out of 2K chunks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 of memory called `frob blocks'). These objects have a `struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 lrecord_header' at the top, containing only the bits needed to find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 the lrecord_implementation for the object. There are special
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 routines in alloc.c to deal with each such object type.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 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
46 their own allocation. Each such object is malloc()ed individually,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 and the objects are chained together through a `next' pointer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 Lcrecords have a `struct lcrecord_header' at the top, which
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 contains a `struct lrecord_header' and a `next' pointer, and are
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 allocated using alloc_lcrecord().
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Creating a new lcrecord type is fairly easy; just follow the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 lead of some existing type (e.g. hash tables). Note that you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 do not need to supply all the methods (see below); reasonable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 defaults are provided for many of them. Alternatively, if you're
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 just looking for a way of encapsulating data (which possibly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 could contain Lisp_Objects in it), you may well be able to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 the opaque type. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 struct lrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 /* index into lrecord_implementations_table[] */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 unsigned int type :8;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 /* 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
66 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
67 - by being referenced from other objects during the GC mark phase
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 - because it is permanently on, for c_readonly objects */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 unsigned int mark :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
71 /* 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
72 reference other non-c_readonly objects.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
73 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
74 unsigned int c_readonly :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 /* 1 if the object is readonly from lisp */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
77 unsigned int lisp_readonly :1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
78
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
79 unsigned int unused :21;
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
80
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 struct lrecord_implementation;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
84 int lrecord_type_index (const struct lrecord_implementation *implementation);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
86 #define set_lheader_implementation(header,imp) do { \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 struct lrecord_header* SLI_header = (header); \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
88 SLI_header->type = (imp)->lrecord_type_index; \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
89 SLI_header->mark = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
90 SLI_header->c_readonly = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
91 SLI_header->lisp_readonly = 0; \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 struct lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 struct lrecord_header lheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
98 /* The `next' field is normally used to chain all lcrecords together
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 so that the GC can find (and free) all of them.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
100 `alloc_lcrecord' threads lcrecords together.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 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
103 other mechanism is provided for letting the GC do its work.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 For example, the event and marker object types allocate members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 out of memory chunks, and are able to find all unmarked members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 by sweeping through the elements of the list of chunks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 struct lcrecord_header *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 /* The `uid' field is just for debugging/printing convenience.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 Having this slot doesn't hurt us much spacewise, since an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 lcrecord already has the above slots plus malloc overhead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 unsigned int uid :31;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 /* The `free' field is a flag that indicates whether this lcrecord
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 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
117 of calls to malloc() when we're repeatedly allocating and freeing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 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
119 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
120 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
121 lcrecords and there are no freed lcrecords elsewhere. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 unsigned int free :1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 /* Used for lcrecords in an lcrecord-list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 struct free_lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 struct lcrecord_header lcheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 Lisp_Object chain;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
132 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134 /* 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
135 #### This should be replaced by a symbol_value_magic_p flag
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 in the Lisp_Symbol lrecord_header. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 lrecord_type_symbol_value_forward,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
138 lrecord_type_symbol_value_varalias,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 lrecord_type_symbol_value_lisp_magic,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 lrecord_type_symbol_value_buffer_local,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 lrecord_type_symbol,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 lrecord_type_subr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 lrecord_type_cons,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 lrecord_type_vector,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 lrecord_type_string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 lrecord_type_lcrecord_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 lrecord_type_compiled_function,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 lrecord_type_weak_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 lrecord_type_bit_vector,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 lrecord_type_float,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 lrecord_type_hash_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 lrecord_type_lstream,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 lrecord_type_process,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 lrecord_type_charset,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 lrecord_type_coding_system,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 lrecord_type_char_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 lrecord_type_char_table_entry,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
160 lrecord_type_range_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
161 lrecord_type_opaque,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 lrecord_type_opaque_ptr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163 lrecord_type_buffer,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 lrecord_type_extent,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 lrecord_type_extent_info,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
166 lrecord_type_extent_auxiliary,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
167 lrecord_type_marker,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168 lrecord_type_event,
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
169 #ifdef USE_KKCC
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
170 lrecord_type_key_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
171 lrecord_type_button_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
172 lrecord_type_motion_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
173 lrecord_type_process_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
174 lrecord_type_timeout_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
175 lrecord_type_eval_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
176 lrecord_type_misc_user_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
177 lrecord_type_magic_eval_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
178 lrecord_type_magic_data,
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
179 #endif /* USE_KKCC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 lrecord_type_keymap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
181 lrecord_type_command_builder,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182 lrecord_type_timeout,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183 lrecord_type_specifier,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
184 lrecord_type_console,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
185 lrecord_type_device,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186 lrecord_type_frame,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
187 lrecord_type_window,
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
188 lrecord_type_window_mirror,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 lrecord_type_window_configuration,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 lrecord_type_gui_item,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
191 lrecord_type_popup_data,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 lrecord_type_toolbar_button,
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
193 lrecord_type_scrollbar_instance,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194 lrecord_type_color_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 lrecord_type_font_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
196 lrecord_type_image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197 lrecord_type_glyph,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
198 lrecord_type_face,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
199 lrecord_type_database,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
200 lrecord_type_tooltalk_message,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
201 lrecord_type_tooltalk_pattern,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
202 lrecord_type_ldap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 lrecord_type_pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204 lrecord_type_pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205 lrecord_type_devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206 lrecord_type_mswindows_dialog_id,
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
207 lrecord_type_case_table,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
208 lrecord_type_emacs_ffi,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
209 lrecord_type_emacs_gtk_object,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
210 lrecord_type_emacs_gtk_boxed,
858
2c12fe2da451 [xemacs-hg @ 2002-05-31 09:38:45 by michaels]
michaels
parents: 826
diff changeset
211 lrecord_type_weak_box,
888
201c016cfc12 [xemacs-hg @ 2002-06-28 14:24:07 by michaels]
michaels
parents: 867
diff changeset
212 lrecord_type_ephemeron,
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
213 lrecord_type_free, /* only used for "free" lrecords */
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
214 lrecord_type_undefined, /* only used for debugging */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
215 lrecord_type_last_built_in_type /* must be last */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
218 extern int lrecord_type_count;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 struct lrecord_implementation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222 const char *name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
224 /* 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
225 be dumped. */
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
226 unsigned int dumpable :1;
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
227
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
228 /* `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
229 pointed to by this object get properly marked. It should call
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 the mark_object function on all Lisp_Objects in the object. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 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
232 marked (don't call the mark_object function explicitly on it,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 because the GC routines will do this). Doing it this way reduces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 recursion, so the object returned should preferably be the one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 with the deepest level of Lisp_Object pointers. This function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 can be NULL, meaning no GC marking is necessary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 Lisp_Object (*marker) (Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
238
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
239 /* `printer' converts the object to a printed representation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
240 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
241 used instead. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
243
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
244 /* `finalizer' is called at GC time when the object is about to
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 be freed, and at dump time (FOR_DISKSAVE will be non-zero in this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 case). It should perform any necessary cleanup (e.g. freeing
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
247 malloc()ed memory). This can be NULL, meaning no special
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 finalization is necessary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
250 WARNING: remember that `finalizer' is called at dump time even
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 though the object is not being freed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 void (*finalizer) (void *header, int for_disksave);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
253
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 /* This can be NULL, meaning compare objects with EQ(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
256
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
257 /* `hash' generates hash values for use with hash tables that have
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 `equal' as their test function. This can be NULL, meaning use
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259 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
260 the constraint that if two objects are `equal', then they *must*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261 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
262 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
263 also NULL. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 unsigned long (*hash) (Lisp_Object, int);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 /* External data layout description */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 const struct lrecord_description *description;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 /* These functions allow any object type to have builtin property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270 lists that can be manipulated from the lisp level with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 `get', `put', `remprop', and `object-plist'. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 Lisp_Object (*plist) (Lisp_Object obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
277 /* Only one of `static_size' and `size_in_bytes_method' is non-0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
278 If both are 0, this type is not instantiable by alloc_lcrecord(). */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
279 Bytecount static_size;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
280 Bytecount (*size_in_bytes_method) (const void *header);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
281
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
282 /* The (constant) index into lrecord_implementations_table */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
283 enum lrecord_type lrecord_type_index;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
284
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 one that does not have an lcrecord_header at the front and which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 is (usually) allocated in frob blocks. We only use this flag for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 some consistency checking, and that only when error-checking is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 enabled. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
290 unsigned int basic_p :1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
293 /* 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
294 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
295 room in `lrecord_implementations_table' for such new lisp object types. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 #define MODULE_DEFINABLE_TYPE_COUNT 32
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
297
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
298 extern const struct lrecord_implementation *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
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
301 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
302 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 extern int gc_in_progress;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
313 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314 struct lrecord_header *SCRRH_lheader = (lheader); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 SCRRH_lheader->c_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 SCRRH_lheader->lisp_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 SCRRH_lheader->mark = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 ((void) ((lheader)->lisp_readonly = 1))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
323 #ifdef USE_KKCC
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
324 #define RECORD_DUMPABLE(lheader) (lrecord_implementations_table[(lheader)->type])->dumpable
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
325 #endif /* USE_KKCC */
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
326
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 /* External description stuff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
329 PLEASE NOTE: Both lrecord_description and struct_description are
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
330 badly misnamed. In reality, an lrecord_description is nothing more
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
331 than a list of the elements in a block of memory that need
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
332 relocating or other special handling, and a struct_description is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
333 no more than an lrecord_description plus the size of the block of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
334 memory. (In fact, a struct_description can now have its size given
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
335 as zero, i.e. unspecified, meaning that the last element in the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
336 structure is noted in the list and the size of the block can
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
337 therefore be computed from it.) The names stem from the fact
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
338 lrecord_descriptions are used to describe lrecords (the size of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
339 lrecord is elsewhere in its description, attached to its methods,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
340 so it does not need to be given here), while struct_descriptions
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
341 are used to describe C structs; but both are used in various
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
342 additional ways. Much better terms would be memory_description and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
343 sized_memory_description.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
345 An lrecord_description is an array of values. (This is actually
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
346 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
347 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
348 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
349 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
350 is type-dependent.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
351
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
352 The description ends with a "XD_END", "XD_SPECIFIER_END" or
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
353 "XD_CODING_SYSTEM_END" record.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
354
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
355 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
356 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
357 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
358 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
359 defaulted by specifying 0 for the size.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
360
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
361 A struct_description is used for describing nested "structures". (Again
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
362 a misnomer, since it can be used for any blocks of memory, not just
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
363 structures.) It just contains a size for the memory block, a pointer to
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
364 an lrecord_description, and (for unions only) a union constant,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
365 described below. The size can be 0, in which case the size will be
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
366 determined from the largest offset logically referenced (i.e. last
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
367 offset mentioned + size of that object). This is useful for stretchy
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
368 arrays.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 Some example descriptions :
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
371
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
372 struct Lisp_String
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
373 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
374 struct lrecord_header lheader;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
375 Bytecount size;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 858
diff changeset
376 Ibyte *data;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
377 Lisp_Object plist;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
378 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
379
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 static const struct lrecord_description cons_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
381 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
382 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
386 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
387
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
388 static const struct lrecord_description string_description[] = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
389 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
390 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT(0, 1) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
391 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
392 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
393 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
394
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
395 "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
396 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
397
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
398 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
399 like this:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
400
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
401 struct Lisp_Foo
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
402 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
403 ...;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
404 int count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
405 Lisp_Object *objects;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
406 ...;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
407 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
408
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
409 You'd use XD_STRUCT_PTR, something like:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
410
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
411 static const struct lrecord_description lo_description_1[] = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
412 { XD_LISP_OBJECT, 0 },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
413 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
414 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
415
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
416 static const struct struct_description lo_description = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
417 sizeof (Lisp_Object),
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
418 lo_description_1
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
419 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
420
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
421 static const struct lrecord_description foo_description[] = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
422 ...
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
423 { XD_INT, offsetof (Lisp_Foo, count) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
424 { XD_STRUCT_PTR, offsetof (Lisp_Foo, objects),
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
425 XD_INDIRECT (0, 0), &lo_description },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
426 ...
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
427 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
428
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
429
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
430 Another example of XD_STRUCT_PTR:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
432 typedef struct hentry
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
433 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
434 Lisp_Object key;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
435 Lisp_Object value;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
436 } hentry;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
437
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
438 struct Lisp_Hash_Table
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
439 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
440 struct lcrecord_header header;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
441 Elemcount size;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
442 Elemcount count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
443 Elemcount rehash_count;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
444 double rehash_size;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
445 double rehash_threshold;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
446 Elemcount golden_ratio;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
447 hash_table_hash_function_t hash_function;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
448 hash_table_test_function_t test_function;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
449 hentry *hentries;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
450 enum hash_table_weakness weakness;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
451 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
452 // hash tables. Don't mark through this.
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
453 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
454
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
455 static const struct lrecord_description hentry_description_1[] = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
456 { XD_LISP_OBJECT, offsetof (hentry, key) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
457 { XD_LISP_OBJECT, offsetof (hentry, value) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
458 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
459 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
460
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
461 static const struct struct_description hentry_description = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
462 sizeof (hentry),
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
463 hentry_description_1
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
464 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
465
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
466 const struct lrecord_description hash_table_description[] = {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
467 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
468 { XD_STRUCT_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT(0, 1),
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
469 &hentry_description },
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
470 { 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
471 { XD_END }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
472 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
473
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
474 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
475 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
476 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
477
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
478
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
479 The existing types :
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
480
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
481
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 XD_LISP_OBJECT
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
483 A Lisp object. This is also the type to use for pointers to other lrecords.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
485 XD_LISP_OBJECT_ARRAY
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
486 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
487 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
488 as Lisp_Object foo[666]. For something declared as Lisp_Object *foo,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
489 use XD_STRUCT_PTR, whose description parameter is a struct_description
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
490 consisting of only XD_LISP_OBJECT and XD_END.
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
491
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 XD_LO_LINK
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
493 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
494 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
495 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
496 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
497 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
498 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
499 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
500 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
501 object.
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
502
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 XD_OPAQUE_PTR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 Pointer to undumpable data. Must be NULL when dumping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 XD_STRUCT_PTR
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
507 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
508 necessarily a pointer to a struct foo.) Parameters are number of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
509 contiguous blocks and struct_description.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
510
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
511 XD_STRUCT_ARRAY
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
512 Array of blocks of described memory. Parameters are number of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
513 structures and struct_description. This differs from XD_STRUCT_PTR
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
514 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
515 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
516 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
517 elsewhere, with a pointer in the containing structure.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 XD_OPAQUE_DATA_PTR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 Pointer to dumpable opaque data. Parameter is the size of the data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 Pointed data must be relocatable without changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
523 XD_UNION
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
524 Union of two or more different types of data. Parameters are a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
525 constant which determines which type the data is (this is usually an
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
526 XD_INDIRECT, referring to one of the fields in the structure), and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
527 an array of struct_descriptions, whose values are used as follows,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
528 which is *DIFFERENT* from their usage in XD_STRUCT_PTR: the first
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
529 field is a constant, which is compared to the first parameter of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
530 XD_UNION descriptor to determine if this description applies to the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
531 data at the given offset, and the second is a pointer to a *SINGLE*
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
532 lrecord_description structure, describing the data being pointed at
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
533 when the associated constant matches. You can go ahead and create
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
534 an array of lrecord_description structures and put an XD_END on it,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
535 but only the first one is used. If the data being pointed at is a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
536 structure, you *MAY NOT* substitute an array of lrecord_description
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
537 structures describing the structure; instead, use a single
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
538 lrecord_description structure with an XD_STRUCT_PTR in it, and point
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
539 it in turn to the description of the structure. See charset.h for a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
540 description of how to use XD_UNION. (In other words, if the constant
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
541 matches, the lrecord_description pointed at will in essence be
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
542 substituted for the XD_UNION declaration.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
543
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 XD_C_STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 Pointer to a C string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 XD_DOC_STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 Pointer to a doc string (C string if positive, opaque value if negative)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 XD_INT_RESET
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 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
552
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
553
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
554 XD_ELEMCOUNT
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
555 Elemcount value. Used for counts.
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
556
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
557 XD_BYTECOUNT
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
558 Bytecount value. Used for counts.
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
559
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
560 XD_HASHCODE
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
561 Hashcode value. Used for the results of hashing functions.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 XD_INT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 int value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 XD_LONG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 long value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
569 XD_BYTECOUNT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
570 bytecount value. Used for counts.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
571
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 XD_END
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 Special type indicating the end of the array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 XD_SPECIFIER_END
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 Special type indicating the end of the array for a specifier. Extra
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
577 description, describing the specifier-type-specific data at the end
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
578 of the specifier object, is going to be fetched from the specifier
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
579 methods. This should occur exactly once, in the description of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
580 specifier object, and the dump code knows how to special-case this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
581 by fetching the specifier_methods pointer from the appropriate place
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
582 in the memory block (which will, of course, be a struct
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
583 Lisp_Specifier), fetching the description of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
584 specifier-type-specific data from this, and continuing processing
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
585 the memory block.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
586
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
587 XD_CODING_SYSTEM_END
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
588 Special type indicating the end of the array for a coding system.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
589 Extra description is going to be fetched from the coding system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
590 methods. Works just like XD_SPECIFIER_END.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 Special macros:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 XD_INDIRECT(line, delta)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 Usable where a "count" or "size" is requested. Gives the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 the element which is at line number 'line' in the description (count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 starts at zero) and adds delta to it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
600 enum lrecord_description_type
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
601 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
602 XD_LISP_OBJECT_ARRAY,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 XD_LISP_OBJECT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 XD_LO_LINK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 XD_OPAQUE_PTR,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 XD_STRUCT_PTR,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
607 XD_STRUCT_ARRAY,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 XD_OPAQUE_DATA_PTR,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
609 XD_UNION,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 XD_C_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 XD_DOC_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 XD_INT_RESET,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
613 XD_BYTECOUNT,
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
614 XD_ELEMCOUNT,
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
615 XD_HASHCODE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 XD_INT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 XD_LONG,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 XD_END,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
619 XD_SPECIFIER_END,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
620 XD_CODING_SYSTEM_END
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
623 struct lrecord_description
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
624 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 enum lrecord_description_type type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 int offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 EMACS_INT data1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 const struct struct_description *data2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
631 struct struct_description
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
632 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
633 Bytecount size;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 const struct lrecord_description *description;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 #define XD_INDIRECT(val, delta) (-1-((val)|(delta<<8)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 #define XD_IS_INDIRECT(code) (code<0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 #define XD_INDIRECT_VAL(code) ((-1-code) & 255)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 #define XD_INDIRECT_DELTA(code) (((-1-code)>>8) & 255)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 #define XD_DYNARR_DESC(base_type, sub_desc) \
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
644 { XD_STRUCT_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
645 { XD_INT, offsetof (base_type, cur) }, \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
646 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
652 #if defined (ERROR_CHECK_TYPES)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
653 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 #else
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
655 # define DECLARE_ERROR_CHECK_TYPES(c_name, structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
658
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
659 #ifdef USE_KKCC
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
660 #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
661 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
662
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
663 #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
664 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
665
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
666 #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
667 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
668
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
669 #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
670 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
671
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
672 #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
673 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
674
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
675 #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
676 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
677
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
678 #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
679 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
680
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
681 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
682 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
683 const struct lrecord_implementation lrecord_##c_name = \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
684 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
685 getprop, putprop, remprop, plist, size, sizer, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
686 lrecord_type_##c_name, basic_p }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
687
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
688 #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
689 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
690
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
691 #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
692 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
693
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
694 #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
695 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
696
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
697 #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
698 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
699
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
700 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
701 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
702 int lrecord_type_##c_name; \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
703 struct lrecord_implementation lrecord_##c_name = \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
704 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
705 getprop, putprop, remprop, plist, size, sizer, \
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
706 lrecord_type_last_built_in_type, basic_p }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
707
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
708 #else /* not USE_KKCC */
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
709
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
713 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
714 MAKE_LRECORD_IMPLEMENTATION(name,c_name,0,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof(structtype),0,1,structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
720 MAKE_LRECORD_IMPLEMENTATION(name,c_name,0,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
725 #define DEFINE_BASIC_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
726 MAKE_LRECORD_IMPLEMENTATION(name,c_name,0,marker,printer,nuker,equal,hash,desc,0,0,0,0,0,sizer,1,structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
729 MAKE_LRECORD_IMPLEMENTATION(name,c_name,0,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
730
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
731 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
732 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
733 const struct lrecord_implementation lrecord_##c_name = \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
734 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
735 getprop, putprop, remprop, plist, size, sizer, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
736 lrecord_type_##c_name, basic_p }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
737
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
738 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
739 DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
740
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
741 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
742 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,0,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
743
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
744 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
745 DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
746
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
747 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
748 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,0,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
749
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
750 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,dumpable,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
751 DECLARE_ERROR_CHECK_TYPES(c_name, structtype) \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
752 int lrecord_type_##c_name; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
753 struct lrecord_implementation lrecord_##c_name = \
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
754 { name, dumpable, marker, printer, nuker, equal, hash, desc, \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
755 getprop, putprop, remprop, plist, size, sizer, \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
756 lrecord_type_last_built_in_type, basic_p }
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 888
diff changeset
757 #endif /* not USE_KKCC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
758
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
759 extern Lisp_Object (*lrecord_markers[]) (Lisp_Object);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
760
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
761 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
762 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
763 lrecord_markers[lrecord_type_##type] = \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
764 lrecord_implementations_table[lrecord_type_##type]->marker; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
765 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
767 #define INIT_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
768 lrecord_type_##type = lrecord_type_count++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
769 lrecord_##type.lrecord_type_index = lrecord_type_##type; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
770 INIT_LRECORD_IMPLEMENTATION(type); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
771 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
772
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
773 #ifdef HAVE_SHLIB
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
774 /* 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
775
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
776 #define UNDEF_LRECORD_IMPLEMENTATION(type) do { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
777 lrecord_implementations_table[lrecord_type_##type] = NULL; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
778 lrecord_markers[lrecord_type_##type] = NULL; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
779 } while (0)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
780
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
781 #define UNDEF_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
782 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
783 /* 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
784 lrecord_type_##type = lrecord_type_count--; \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
785 } /* 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
786 UNDEF_LRECORD_IMPLEMENTATION(type); \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
787 } while (0)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
788
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
789 #endif /* HAVE_SHLIB */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents: 934
diff changeset
790
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 #define RECORD_TYPEP(x, ty) \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
795 (LRECORDP (x) && (XRECORD_LHEADER (x)->type == (unsigned int) (ty)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
796
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
797 /* Steps to create a new object:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
798
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
799 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
800 Remember that it must begin with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
801
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
802 struct lcrecord_header header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
803
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
804 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
805 struct definition -- see below.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
806
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
807 3. Add this header file to inline.c.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
808
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
809 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
810 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
811
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
812 5. Define your object with DEFINE_LRECORD_IMPLEMENTATION() or some
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
813 variant.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
815 6. Include the header file in the .c file where you defined the object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
816
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
817 7. Put a call to INIT_LRECORD_IMPLEMENTATION() for the object in the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
818 .c file's syms_of_foo() function.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
819
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
820 8. Add a type enum for the object to enum lrecord_type, earlier in this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
821 file.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
822
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
823 An example:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
825 ------------------------------ in toolbar.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
826
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
827 struct toolbar_button
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
828 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
829 struct lcrecord_header header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
830
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
831 Lisp_Object next;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
832 Lisp_Object frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
833
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
834 Lisp_Object up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
835 Lisp_Object down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
836 Lisp_Object disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
837
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
838 Lisp_Object cap_up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
839 Lisp_Object cap_down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
840 Lisp_Object cap_disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
841
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
842 Lisp_Object callback;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
843 Lisp_Object enabled_p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
844 Lisp_Object help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
845
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
846 char enabled;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
847 char down;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
848 char pushright;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
849 char blank;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
850
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
851 int x, y;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
852 int width, height;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
853 int dirty;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
854 int vertical;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
855 int border_width;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
856 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
858 [[ the standard junk: ]]
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
859
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
860 DECLARE_LRECORD (toolbar_button, struct toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
861 #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
862 #define wrap_toolbar_button(p) wrap_record (p, toolbar_button)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
863 #define TOOLBAR_BUTTONP(x) RECORDP (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
864 #define CHECK_TOOLBAR_BUTTON(x) CHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
865 #define CONCHECK_TOOLBAR_BUTTON(x) CONCHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
866
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
867 ------------------------------ in toolbar.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
868
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
870
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
871 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
872
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
873 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
874 mark_toolbar_button (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
875 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
876 struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
877 mark_object (data->next);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
878 mark_object (data->frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
879 mark_object (data->up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
880 mark_object (data->down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
881 mark_object (data->disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
882 mark_object (data->cap_up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
883 mark_object (data->cap_down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
884 mark_object (data->cap_disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
885 mark_object (data->callback);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
886 mark_object (data->enabled_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
887 return data->help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
888 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
889
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
890 [[ 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
891 as internal_object_printer instead of 0. ]]
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
892
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
893 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
894 mark_toolbar_button, 0,
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
895 0, 0, 0, 0, struct toolbar_button);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
896
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
897 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
898
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
899 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
900 syms_of_toolbar (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
901 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
902 INIT_LRECORD_IMPLEMENTATION (toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
903
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
904 ...;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
905 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
906
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
907 ------------------------------ in inline.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
908
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
909 #ifdef HAVE_TOOLBARS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
911 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
912
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
913 ------------------------------ in lrecord.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
914
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
915 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
916 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
917 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
918 lrecord_type_toolbar_button,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
919 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
920 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
921
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
923
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
925
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
926 Note: Object types defined in external dynamically-loaded modules (not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
927 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
928 and DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION rather than DECLARE_LRECORD
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
929 and DEFINE_LRECORD_IMPLEMENTATION.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
930
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
931 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
932
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
934 #ifdef ERROR_CHECK_TYPES
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
936 # define DECLARE_LRECORD(c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
937 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
938 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
939 structtype * \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
940 error_check_##c_name (Lisp_Object obj, const char *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
941 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
942 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
943 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
944 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
945 } \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
948 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
949 extern int lrecord_type_##c_name; \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
950 extern struct lrecord_implementation lrecord_##c_name; \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
951 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
952 structtype * \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
953 error_check_##c_name (Lisp_Object obj, const char *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
954 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
955 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
956 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
957 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
958 } \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
959 extern Lisp_Object Q##c_name##p
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
960
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
961 # 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
962 DECLARE_INLINE_HEADER ( \
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
963 structtype * \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
964 error_check_##c_name (Lisp_Object obj, const char *file, int line) \
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
965 ) \
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
966 { \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
967 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
968 return (structtype *) XPNTR (obj); \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
969 } \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
972 # define XRECORD(x, c_name, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
973 error_check_##c_name (x, __FILE__, __LINE__)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
974 # define XNONRECORD(x, c_name, type_enum, structtype) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
975 error_check_##c_name (x, __FILE__, __LINE__)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
977 DECLARE_INLINE_HEADER (
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
978 Lisp_Object
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
979 wrap_record_1 (const void *ptr, enum lrecord_type ty, const char *file,
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
980 int line)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
981 )
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
982 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
983 Lisp_Object obj = wrap_pointer_1 (ptr);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 788
diff changeset
984
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
985 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
986 return obj;
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
987 }
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
988
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
989 #define wrap_record(ptr, ty) \
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
990 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
991
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
992 #else /* not ERROR_CHECK_TYPES */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 # define DECLARE_LRECORD(c_name, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 extern Lisp_Object Q##c_name##p; \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
996 extern const struct lrecord_implementation lrecord_##c_name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
997 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
998 extern Lisp_Object Q##c_name##p; \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
999 extern int lrecord_type_##c_name; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1000 extern struct lrecord_implementation lrecord_##c_name
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 # define XNONRECORD(x, c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 ((structtype *) XPNTR (x))
617
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1006 /* 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
1007 know what you're doing. */
af57a77cbc92 [xemacs-hg @ 2001-06-18 07:09:50 by ben]
ben
parents: 462
diff changeset
1008 #define wrap_record(ptr, ty) wrap_pointer_1 (ptr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
1010 #endif /* not ERROR_CHECK_TYPES */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1012 #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
1013
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 /* Note: we now have two different kinds of type-checking macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 The "old" kind has now been renamed CONCHECK_foo. The reason for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 this is that the CONCHECK_foo macros signal a continuable error,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 allowing the user (through debug-on-error) to substitute a different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 value and return from the signal, which causes the lvalue argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 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
1020 because it did things like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 foo = XCAR (list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 CHECK_STRING (foo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 and later on did XSTRING (XCAR (list)), assuming that the type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 is correct (when it might be wrong, if the user substituted a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 correct value in the debugger).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 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
1030 non-continuable error. Places where a continuable error is OK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 (generally only when called directly on the argument of a Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 primitive) should be changed to use CONCHECK().
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 FSF Emacs does not have this problem because RMS took the cheesy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 way out and disabled returning from a signal entirely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 #define CONCHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1038 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 x = wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 x = wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 #define CHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1046 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 dead_wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 dead_wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1054 /* Various ways of allocating lcrecords. All bytes (except lcrecord
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1055 header) are zeroed in returned structure. */
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
1056
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
1057 void *alloc_lcrecord (Bytecount size,
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 617
diff changeset
1058 const struct lrecord_implementation *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1060 void *alloc_automanaged_lcrecord (Bytecount size,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1061 const struct lrecord_implementation *);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1062
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1063 #define alloc_unmanaged_lcrecord_type(type, lrecord_implementation) \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1064 ((type *) alloc_lcrecord (sizeof (type), lrecord_implementation))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1065
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 #define alloc_lcrecord_type(type, lrecord_implementation) \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1067 ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1068
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1069 void free_lcrecord (Lisp_Object rec);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1070
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 /* Copy the data from one lcrecord structure into another, but don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 overwrite the header information. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1075 #define copy_sized_lcrecord(dst, src, size) \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1076 memcpy ((char *) (dst) + sizeof (struct lcrecord_header), \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1077 (char *) (src) + sizeof (struct lcrecord_header), \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1078 (size) - sizeof (struct lcrecord_header))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1079
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1080 #define copy_lcrecord(dst, src) copy_sized_lcrecord (dst, src, sizeof (*(dst)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1082 #define zero_sized_lcrecord(lcr, size) \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
1083 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1084 (size) - sizeof (struct lcrecord_header))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1085
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1086 #define zero_lcrecord(lcr) zero_sized_lcrecord(lcr, sizeof (*(lcr)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
1088 #endif /* INCLUDED_lrecord_h_ */