annotate src/lrecord.h @ 22:8fc7fe29b841 r19-15b94

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