annotate src/lrecord.h @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* The "lrecord" structure (header of a compound lisp object).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #ifndef _XEMACS_LRECORD_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #define _XEMACS_LRECORD_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 /* The "lrecord" type of Lisp object is used for all object types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 other than a few simple ones. This allows many types to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 implemented but only a few bits required in a Lisp object for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 type information. (The tradeoff is that each object has its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 type marked in it, thereby increasing its size.) The first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 four bytes of all lrecords is a pointer to a struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 lrecord_implementation, which contains methods describing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 how to process this object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 lrecords are of two types: straight lrecords, and lcrecords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 Straight lrecords are used for those types of objects that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 have their own allocation routines (typically allocated out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 of 2K chunks of memory). These objects have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 `struct lrecord_header' at the top, containing only the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 implementation pointer. There are special routines in alloc.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 to deal with each such object type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 Lcrecords are used for less common sorts of objects that don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 do their own allocation. Each such object is malloc()ed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 individually, and the objects are chained together through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 a `next' pointer. Lcrecords have a `struct lcrecord_header'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 at the top, which contains an implementation pointer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 a `next' pointer, and are allocated using alloc_lcrecord().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Creating a new lcrecord type is fairly easy; just follow the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 lead of some existing type (e.g. hashtables). Note that you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 do not need to supply all the methods (see below); reasonable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 defaults are provided for many of them. Alternatively, if you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 just looking for a way of encapsulating data (which possibly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 could contain Lisp_Objects in it), you may well be able to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 the opaque type. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 struct lrecord_header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /* It would be better to put the mark-bit together with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 * following datatype identification field in an 8- or 16-bit integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 * rather than playing funny games with changing header->implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 * and "wasting" 32 bits on the below pointer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 * The type-id would then be a 7 or 15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 * bit index into a table of lrecord-implementations rather than a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 * direct pointer. There would be 24 (or 16) bits left over for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 * datatype-specific per-instance flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 * The below is the simplest thing to do for the present,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 * and doesn't incur that much overhead as most Emacs records
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 * are of such a size that the overhead isn't too bad.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 * (The marker datatype is the worst case.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 * It also has the very very very slight advantage that type-checking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 * involves one memory read (of the "implementation" slot) and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 * comparison against a link-time constant address rather than a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 * read and a comparison against a variable value. (Variable since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 * it is a very good idea to assign the indices into the hypothetical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 * type-code table dynamically rather that pre-defining them.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 * I think I remember that Elk Lisp does something like this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 * Gee, I wonder if some cretin has patented it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 CONST struct lrecord_implementation *implementation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 #define set_lheader_implementation(header,imp) (header)->implementation=(imp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 struct lcrecord_header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 struct lrecord_header lheader;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 /* The "next" field is normally used to chain all lrecords together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 * so that the GC can find (and free) all of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 * "alloc_lcrecord" threads records together.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 * The "next" field may be used for other purposes as long as some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 * other mechanism is provided for letting the GC do its work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 * (For example, the event and marker datatypes allocates members out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 * of memory chunks, and it are able to find all unmarked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 * events by sweeping through the elements of the list of chunks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 struct lcrecord_header *next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 /* This is just for debugging/printing convenience.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 Having this slot doesn't hurt us much spacewise, since an lcrecord
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 already has the above slots together with malloc overhead. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 int uid :31;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 /* A flag that indicates whether this lcrecord is on a "free list".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Free lists are used to minimize the number of calls to malloc()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 when we're repeatedly allocating and freeing a number of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 same sort of lcrecord. Lcrecords on a free list always get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 marked in a different fashion, so we can use this flag as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 sanity check to make sure that free lists only have freed lcrecords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 and no freed lcrecords are elsewhere. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 int free :1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 /* Used for lcrecords in an lcrecord-list. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 struct free_lcrecord_header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 struct lcrecord_header lcheader;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Lisp_Object chain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 /* This as the value of lheader->implementation->finalizer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 * means that this record is already marked */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 extern void this_marks_a_marked_record (void *, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 /* see alloc.c for an explanation */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 extern Lisp_Object this_one_is_unmarkable (Lisp_Object obj,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 void (*markobj) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 struct lrecord_implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 CONST char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 /* This function is called at GC time, to make sure that all Lisp_Objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 pointed to by this object get properly marked. It should call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 the mark_object function on all Lisp_Objects in the object. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 the return value is non-nil, it should be a Lisp_Object to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 marked (don't call the mark_object function explicitly on it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 because the GC routines will do this). Doing it this way reduces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 recursion, so the object returned should preferably be the one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 with the deepest level of Lisp_Object pointers. This function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 can be NULL, meaning no GC marking is necessary. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 Lisp_Object (*marker) (Lisp_Object, void (*mark_object) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 /* This can be NULL if the object is an lcrecord; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 default_object_printer() in print.c will be used. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 /* This function is called at GC time when the object is about to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 be freed, and at dump time (FOR_DISKSAVE will be non-zero in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 case). It should perform any necessary cleanup (e.g. freeing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 malloc()ed memory. This can be NULL, meaning no special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 finalization is necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 WARNING: remember that the finalizer is called at dump time even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 though the object is not being freed. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 void (*finalizer) (void *header, int for_disksave);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 /* This can be NULL, meaning compare objects with EQ(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 /* This can be NULL, meaning use the Lisp_Object itself as the hash;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 but *only* if the `equal' function is EQ (if two objects are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 `equal', they *must* hash to the same value or the hashing won't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 work). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 unsigned long (*hash) (Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 Lisp_Object (*plist) (Lisp_Object obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 /* Only one of these is non-0. If both are 0, it means that this type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 is not instantiable by alloc_lcrecord(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 unsigned int static_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 unsigned int (*size_in_bytes_method) (CONST void *header);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 /* A unique subtag-code (dynamically) assigned to this datatype. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 /* (This is a pointer so the rest of this structure can be read-only.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 int *lrecord_type_index;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 one that does not have an lcrecord_header at the front and which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 is (usually) allocated in frob blocks. We only use this flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 for some consistency checking, and that only when error-checking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 is enabled. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 int basic_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 extern int gc_in_progress;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 #define MARKED_RECORD_P(obj) (gc_in_progress && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 XRECORD_LHEADER (obj)->implementation->finalizer == \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 this_marks_a_marked_record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 /* Declaring the following structures as const puts them in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 text (read-only) segment, which makes debugging inconvenient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 because this segment is not mapped when processing a core-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 dump file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 #ifdef DEBUG_XEMACS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 #define CONST_IF_NOT_DEBUG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 #define CONST_IF_NOT_DEBUG CONST
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 #if defined (ERROR_CHECK_TYPECHECK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 static int lrecord_##c_name##_lrecord_type_index; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name[2] = \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 { { name, marker, printer, nuker, equal, hash, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 0, 0, 0, 0, sizeof (structtype), 0, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 &(lrecord_##c_name##_lrecord_type_index), 1 }, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 { 0, 0, 0, this_marks_a_marked_record, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 static int lrecord_##c_name##_lrecord_type_index; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name[2] = \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 { { name, marker, printer, nuker, equal, hash, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 getprop, putprop, remprop, props, sizeof (structtype), 0, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 &(lrecord_##c_name##_lrecord_type_index), 1 }, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 { 0, 0, 0, this_marks_a_marked_record, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 static int lrecord_##c_name##_lrecord_type_index; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name[2] = \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 { { name, marker, printer, nuker, equal, hash, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 0, 0, 0, 0, sizeof (structtype), 0, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 &(lrecord_##c_name##_lrecord_type_index), 0 }, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 { 0, 0, 0, this_marks_a_marked_record, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 static int lrecord_##c_name##_lrecord_type_index; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name[2] = \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 { { name, marker, printer, nuker, equal, hash, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 getprop, putprop, remprop, props, sizeof (structtype), 0, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 &(lrecord_##c_name##_lrecord_type_index), 0 }, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 { 0, 0, 0, this_marks_a_marked_record, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,sizer,structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 static int lrecord_##c_name##_lrecord_type_index; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name[2] = \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 { { name, marker, printer, nuker, equal, hash, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 0, 0, 0, 0, 0, sizer, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 &(lrecord_##c_name##_lrecord_type_index), 0 }, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 { 0, 0, 0, this_marks_a_marked_record, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,sizer,structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 static int lrecord_##c_name##_lrecord_type_index; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name[2] = \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 { { name, marker, printer, nuker, equal, hash, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 getprop, putprop, remprop, props, 0, sizer, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 &(lrecord_##c_name##_lrecord_type_index), 0 }, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 { 0, 0, 0, this_marks_a_marked_record, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 #define LRECORDP(a) (XTYPE ((a)) == Lisp_Record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 #define RECORD_TYPEP(x, ty) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (LRECORDP (x) && XRECORD_LHEADER (x)->implementation == (ty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 /* NOTE: the DECLARE_LRECORD() must come before the associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 DEFINE_LRECORD_*() or you will get compile errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Furthermore, you always need to put the DECLARE_LRECORD() in a header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 file, and make sure the header file is included in inline.c, even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 if the type is private to a particular file. Otherwise, you will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 get undefined references for the error_check_foo() inline function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 under GCC. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 #ifdef ERROR_CHECK_TYPECHECK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 # define DECLARE_LRECORD(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 extern CONST_IF_NOT_DEBUG struct lrecord_implementation \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 lrecord_##c_name[]; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 INLINE structtype *error_check_##c_name (Lisp_Object _obj); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 INLINE structtype * \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 error_check_##c_name (Lisp_Object _obj) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 XUNMARK (_obj); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 assert (RECORD_TYPEP (_obj, lrecord_##c_name) || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 MARKED_RECORD_P (_obj)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 return (structtype *) XPNTR (_obj); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 INLINE structtype *error_check_##c_name (Lisp_Object _obj); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 INLINE structtype * \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 error_check_##c_name (Lisp_Object _obj) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 XUNMARK (_obj); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 assert (XGCTYPE (_obj) == type_enum); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 return (structtype *) XPNTR (_obj); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 # define XRECORD(x, c_name, structtype) error_check_##c_name (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 # define XNONRECORD(x, c_name, type_enum, structtype) error_check_##c_name (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 # define XSETRECORD(var, p, c_name) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 XSETOBJ (var, Lisp_Record, p); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 assert (RECORD_TYPEP (var, lrecord_##c_name) || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 MARKED_RECORD_P (var)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 #else /* not ERROR_CHECK_TYPECHECK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 # define DECLARE_LRECORD(c_name, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 extern Lisp_Object Q##c_name##p; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 extern CONST_IF_NOT_DEBUG struct lrecord_implementation \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 lrecord_##c_name[]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 # define XNONRECORD(x, c_name, type_enum, structtype) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ((structtype *) XPNTR (x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 # define XSETRECORD(var, p, c_name) XSETOBJ (var, Lisp_Record, p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 #endif /* not ERROR_CHECK_TYPECHECK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_##c_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 #define GC_RECORDP(x, c_name) gc_record_type_p (x, lrecord_##c_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 /* Note: we now have two different kinds of type-checking macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 The "old" kind has now been renamed CONCHECK_foo. The reason for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 this is that the CONCHECK_foo macros signal a continuable error,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 allowing the user (through debug-on-error) to subsitute a different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 value and return from the signal, which causes the lvalue argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 to get changed. Quite a lot of code would crash if that happened,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 because it did things like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 foo = XCAR (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 CHECK_STRING (foo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 and later on did XSTRING (XCAR (list)), assuming that the type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 is correct (when it might be wrong, if the user substituted a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 correct value in the debugger).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 To get around this, I made all the CHECK_foo macros signal a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 non-continuable error. Places where a continuable error is OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (generally only when called directly on the argument of a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 primitive) should be changed to use CONCHECK().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 FSF Emacs does not have this problem because RMS took the cheesy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 way out and disabled returning from a signal entirely. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 #define CONCHECK_RECORD(x, c_name) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 { if (!RECORD_TYPEP (x, lrecord_##c_name)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 x = wrong_type_argument (Q##c_name##p, x); } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 { if (XTYPE (x) != lisp_enum) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 x = wrong_type_argument (predicate, x); } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 #define CHECK_RECORD(x, c_name) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 { if (!RECORD_TYPEP (x, lrecord_##c_name)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 dead_wrong_type_argument (Q##c_name##p, x); } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 #define CHECK_NONRECORD(x, lisp_enum, predicate) do \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 { if (XTYPE (x) != lisp_enum) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 dead_wrong_type_argument (predicate, x); } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 void *alloc_lcrecord (int size, CONST struct lrecord_implementation *);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 int gc_record_type_p (Lisp_Object frob,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 CONST struct lrecord_implementation *type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 /* Copy the data from one lcrecord structure into another, but don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 overwrite the header information. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 #define copy_lcrecord(dst, src) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 memcpy ((char *) dst + sizeof (struct lcrecord_header), \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (char *) src + sizeof (struct lcrecord_header), \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 sizeof (*dst) - sizeof (struct lcrecord_header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 #define zero_lcrecord(lcr) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 memset ((char *) lcr + sizeof (struct lcrecord_header), 0, \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 sizeof (*lcr) - sizeof (struct lcrecord_header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 #endif /* _XEMACS_LRECORD_H_ */