annotate src/lrecord.h @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children b8cc9ab3f761
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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
24 #ifndef INCLUDED_lrecord_h_
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
25 #define INCLUDED_lrecord_h_
0
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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
29 implemented but only a few bits required in a Lisp object for type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
30 information. (The tradeoff is that each object has its type marked
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
31 in it, thereby increasing its size.) All lrecords begin with a
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
32 `struct lrecord_header', which identifies the lisp object type, by
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
33 providing an index into a table of `struct lrecord_implementation',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
34 which describes the behavior of the lisp object. It also contains
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
35 some other data bits.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
37 Lrecords are of two types: straight lrecords, and lcrecords.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
38 Straight lrecords are used for those types of objects that have
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
39 their own allocation routines (typically allocated out of 2K chunks
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
40 of memory called `frob blocks'). These objects have a `struct
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
41 lrecord_header' at the top, containing only the bits needed to find
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
42 the lrecord_implementation for the object. There are special
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
43 routines in alloc.c to deal with each such object type.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
45 Lcrecords are used for less common sorts of objects that don't do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
46 their own allocation. Each such object is malloc()ed individually,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
47 and the objects are chained together through a `next' pointer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
48 Lcrecords have a `struct lcrecord_header' at the top, which
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
49 contains a `struct lrecord_header' and a `next' pointer, and are
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
50 allocated using alloc_lcrecord().
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Creating a new lcrecord type is fairly easy; just follow the
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
53 lead of some existing type (e.g. hash tables). Note that you
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 do not need to supply all the methods (see below); reasonable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 defaults are provided for many of them. Alternatively, if you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 just looking for a way of encapsulating data (which possibly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 could contain Lisp_Objects in it), you may well be able to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 the opaque type. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 struct lrecord_header
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61 {
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
62 /* index into lrecord_implementations_table[] */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
63 unsigned int type :8;
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
64
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
65 /* If `mark' is 0 after the GC mark phase, the object will be freed
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
66 during the GC sweep phase. There are 2 ways that `mark' can be 1:
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
67 - by being referenced from other objects during the GC mark phase
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
68 - because it is permanently on, for c_readonly objects */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
69 unsigned int mark :1;
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
70
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
71 /* 1 if the object resides in logically read-only space, and does not
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
72 reference other non-c_readonly objects.
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
73 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
74 unsigned int c_readonly :1;
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
75
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
76 /* 1 if the object is readonly from lisp */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
77 unsigned int lisp_readonly :1;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
78 };
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
79
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 213
diff changeset
80 struct lrecord_implementation;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
81 int lrecord_type_index (const struct lrecord_implementation *implementation);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
82
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
83 #define set_lheader_implementation(header,imp) do { \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
84 struct lrecord_header* SLI_header = (header); \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
85 SLI_header->type = (imp)->lrecord_type_index; \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
86 SLI_header->mark = 0; \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
87 SLI_header->c_readonly = 0; \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
88 SLI_header->lisp_readonly = 0; \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
89 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 struct lcrecord_header
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 struct lrecord_header lheader;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
94
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
95 /* The `next' field is normally used to chain all lcrecords together
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 so that the GC can find (and free) all of them.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
97 `alloc_lcrecord' threads lcrecords together.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
98
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
99 The `next' field may be used for other purposes as long as some
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
100 other mechanism is provided for letting the GC do its work.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
101
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
102 For example, the event and marker object types allocate members
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
103 out of memory chunks, and are able to find all unmarked members
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
104 by sweeping through the elements of the list of chunks. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
105 struct lcrecord_header *next;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
106
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
107 /* The `uid' field is just for debugging/printing convenience.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
108 Having this slot doesn't hurt us much spacewise, since an
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
109 lcrecord already has the above slots plus malloc overhead. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 unsigned int uid :31;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
111
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
112 /* The `free' field is a flag that indicates whether this lcrecord
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
113 is on a "free list". Free lists are used to minimize the number
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
114 of calls to malloc() when we're repeatedly allocating and freeing
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
115 a number of the same sort of lcrecord. Lcrecords on a free list
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
116 always get marked in a different fashion, so we can use this flag
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
117 as a sanity check to make sure that free lists only have freed
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
118 lcrecords and there are no freed lcrecords elsewhere. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 unsigned int free :1;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 /* Used for lcrecords in an lcrecord-list. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 struct free_lcrecord_header
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 struct lcrecord_header lcheader;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 Lisp_Object chain;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
129 enum lrecord_type
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
130 {
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
131 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast.
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
132 #### This should be replaced by a symbol_value_magic_p flag
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
133 in the Lisp_Symbol lrecord_header. */
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
134 lrecord_type_symbol_value_forward,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
135 lrecord_type_symbol_value_varalias,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
136 lrecord_type_symbol_value_lisp_magic,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
137 lrecord_type_symbol_value_buffer_local,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
138 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
139
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
140 lrecord_type_symbol,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
141 lrecord_type_subr,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
142 lrecord_type_cons,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
143 lrecord_type_vector,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
144 lrecord_type_string,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
145 lrecord_type_lcrecord_list,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
146 lrecord_type_compiled_function,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
147 lrecord_type_weak_list,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
148 lrecord_type_bit_vector,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
149 lrecord_type_float,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
150 lrecord_type_hash_table,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
151 lrecord_type_lstream,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
152 lrecord_type_process,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
153 lrecord_type_charset,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
154 lrecord_type_coding_system,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
155 lrecord_type_char_table,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
156 lrecord_type_char_table_entry,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
157 lrecord_type_range_table,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
158 lrecord_type_opaque,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
159 lrecord_type_opaque_ptr,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
160 lrecord_type_buffer,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
161 lrecord_type_extent,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
162 lrecord_type_extent_info,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
163 lrecord_type_extent_auxiliary,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
164 lrecord_type_marker,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
165 lrecord_type_event,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
166 lrecord_type_keymap,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
167 lrecord_type_command_builder,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
168 lrecord_type_timeout,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
169 lrecord_type_specifier,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
170 lrecord_type_console,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
171 lrecord_type_device,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
172 lrecord_type_frame,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
173 lrecord_type_window,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
174 lrecord_type_window_configuration,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
175 lrecord_type_gui_item,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
176 lrecord_type_popup_data,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
177 lrecord_type_toolbar_button,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
178 lrecord_type_color_instance,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
179 lrecord_type_font_instance,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
180 lrecord_type_image_instance,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
181 lrecord_type_glyph,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
182 lrecord_type_face,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
183 lrecord_type_database,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
184 lrecord_type_tooltalk_message,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
185 lrecord_type_tooltalk_pattern,
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
186 lrecord_type_ldap,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
187 lrecord_type_pgconn,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
188 lrecord_type_pgresult,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
189 lrecord_type_pgsetenv,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
190 lrecord_type_count /* must be last */
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
191 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 struct lrecord_implementation
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
194 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
195 const char *name;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
196
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
197 /* `marker' is called at GC time, to make sure that all Lisp_Objects
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 pointed to by this object get properly marked. It should call
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199 the mark_object function on all Lisp_Objects in the object. If
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 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
201 marked (don't call the mark_object function explicitly on it,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 because the GC routines will do this). Doing it this way reduces
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 recursion, so the object returned should preferably be the one
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 with the deepest level of Lisp_Object pointers. This function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 can be NULL, meaning no GC marking is necessary. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
206 Lisp_Object (*marker) (Lisp_Object);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
207
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
208 /* `printer' converts the object to a printed representation.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
209 This can be NULL; in this case default_object_printer() will be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
210 used instead. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
212
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
213 /* `finalizer' is called at GC time when the object is about to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 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
215 case). It should perform any necessary cleanup (e.g. freeing
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
216 malloc()ed memory). This can be NULL, meaning no special
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
217 finalization is necessary.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
218
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
219 WARNING: remember that `finalizer' is called at dump time even
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
220 though the object is not being freed. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
221 void (*finalizer) (void *header, int for_disksave);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
222
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
223 /* This can be NULL, meaning compare objects with EQ(). */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
224 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
225
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
226 /* `hash' generates hash values for use with hash tables that have
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
227 `equal' as their test function. This can be NULL, meaning use
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
228 the Lisp_Object itself as the hash. But, you must still satisfy
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
229 the constraint that if two objects are `equal', then they *must*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
230 hash to the same value in order for hash tables to work properly.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
231 This means that `hash' can be NULL only if the `equal' method is
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
232 also NULL. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
233 unsigned long (*hash) (Lisp_Object, int);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
234
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
235 /* External data layout description */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
236 const struct lrecord_description *description;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
237
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
238 /* These functions allow any object type to have builtin property
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
239 lists that can be manipulated from the lisp level with
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
240 `get', `put', `remprop', and `object-plist'. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
241 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
242 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
243 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
244 Lisp_Object (*plist) (Lisp_Object obj);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
246 /* Only one of `static_size' and `size_in_bytes_method' is non-0.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
247 If both are 0, this type is not instantiable by alloc_lcrecord(). */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
248 size_t static_size;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
249 size_t (*size_in_bytes_method) (const void *header);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
250
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
251 /* The (constant) index into lrecord_implementations_table */
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
252 enum lrecord_type lrecord_type_index;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
253
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
254 /* 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
255 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
256 is (usually) allocated in frob blocks. We only use this flag for
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
257 some consistency checking, and that only when error-checking is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
258 enabled. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
259 unsigned int basic_p :1;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
260 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
262 extern const struct lrecord_implementation *lrecord_implementations_table[];
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
263
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
264 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
265 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
266 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type]
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
267
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 extern int gc_in_progress;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
270 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
271 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
272 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
273 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0))
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
274
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
275 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
276 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
277 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
278 struct lrecord_header *SCRRH_lheader = (lheader); \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
279 SCRRH_lheader->c_readonly = 1; \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
280 SCRRH_lheader->lisp_readonly = 1; \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
281 SCRRH_lheader->mark = 1; \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
282 } while (0)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
283 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
284 ((void) ((lheader)->lisp_readonly = 1))
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
285 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type]
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
286
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
287 /* External description stuff
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
288
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
289 A lrecord external description is an array of values. The first
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
290 value of each line is a type, the second the offset in the lrecord
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
291 structure. Following values are parameters, their presence, type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
292 and number is type-dependant.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
293
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
294 The description ends with a "XD_END" or "XD_SPECIFIER_END" record.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
295
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
296 Some example descriptions :
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
297
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
298 static const struct lrecord_description cons_description[] = {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
299 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
300 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
301 { XD_END }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
302 };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
303
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
304 Which means "two lisp objects starting at the 'car' and 'cdr' elements"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
305
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
306 static const struct lrecord_description string_description[] = {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
307 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
308 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT(0, 1) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
309 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
310 { XD_END }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
311 };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
312 "A pointer to string data at 'data', the size of the pointed array being the value
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
313 of the size variable plus 1, and one lisp object at 'plist'"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
314
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
315 The existing types :
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
316 XD_LISP_OBJECT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
317 A Lisp object. This is also the type to use for pointers to other lrecords.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
318
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
319 XD_LISP_OBJECT_ARRAY
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
320 An array of Lisp objects or pointers to lrecords.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
321 The third element is the count.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
322
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
323 XD_LO_RESET_NIL
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
324 Lisp objects which will be reset to Qnil when dumping. Useful for cleaning
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
325 up caches.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
326
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
327 XD_LO_LINK
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
328 Link in a linked list of objects of the same type.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
329
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
330 XD_OPAQUE_PTR
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
331 Pointer to undumpable data. Must be NULL when dumping.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
332
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
333 XD_STRUCT_PTR
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
334 Pointer to described struct. Parameters are number of structures and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
335 struct_description.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
336
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
337 XD_OPAQUE_DATA_PTR
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
338 Pointer to dumpable opaque data. Parameter is the size of the data.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
339 Pointed data must be relocatable without changes.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
340
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
341 XD_C_STRING
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
342 Pointer to a C string.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
343
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
344 XD_DOC_STRING
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
345 Pointer to a doc string (C string if positive, opaque value if negative)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
346
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
347 XD_INT_RESET
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
348 An integer which will be reset to a given value in the dump file.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
349
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
350
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
351 XD_SIZE_T
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
352 size_t value. Used for counts.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
353
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
354 XD_INT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
355 int value. Used for counts.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
356
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
357 XD_LONG
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
358 long value. Used for counts.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
359
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
360 XD_BYTECOUNT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
361 bytecount value. Used for counts.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
362
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
363 XD_END
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
364 Special type indicating the end of the array.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
365
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
366 XD_SPECIFIER_END
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
367 Special type indicating the end of the array for a specifier. Extra
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
368 description is going to be fetched from the specifier methods.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
369
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
370
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
371 Special macros:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
372 XD_INDIRECT(line, delta)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
373 Usable where a "count" or "size" is requested. Gives the value of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
374 the element which is at line number 'line' in the description (count
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
375 starts at zero) and adds delta to it.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
376 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
377
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
378 enum lrecord_description_type {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
379 XD_LISP_OBJECT_ARRAY,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
380 XD_LISP_OBJECT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
381 XD_LO_RESET_NIL,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
382 XD_LO_LINK,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
383 XD_OPAQUE_PTR,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
384 XD_STRUCT_PTR,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
385 XD_OPAQUE_DATA_PTR,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
386 XD_C_STRING,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
387 XD_DOC_STRING,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
388 XD_INT_RESET,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
389 XD_SIZE_T,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
390 XD_INT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
391 XD_LONG,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
392 XD_BYTECOUNT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
393 XD_END,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
394 XD_SPECIFIER_END
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
395 };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
396
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
397 struct lrecord_description {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
398 enum lrecord_description_type type;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
399 int offset;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
400 EMACS_INT data1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
401 const struct struct_description *data2;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
402 };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
403
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
404 struct struct_description {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
405 size_t size;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
406 const struct lrecord_description *description;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
407 };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
408
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
409 #define XD_INDIRECT(val, delta) (-1-((val)|(delta<<8)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
410
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
411 #define XD_IS_INDIRECT(code) (code<0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
412 #define XD_INDIRECT_VAL(code) ((-1-code) & 255)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
413 #define XD_INDIRECT_DELTA(code) (((-1-code)>>8) & 255)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
414
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
415 #define XD_DYNARR_DESC(base_type, sub_desc) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
416 { XD_STRUCT_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
417 { XD_INT, offsetof (base_type, cur) }, \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
418 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
419
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 #if defined (ERROR_CHECK_TYPECHECK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
430 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
431 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
433 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
434 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof(structtype),0,1,structtype)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
436 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
437 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
439 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
440 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
441
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
442 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
443 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
445 #define DEFINE_BASIC_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
446 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,0,sizer,1,structtype)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
447
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
448 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
449 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype) \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
450
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
451 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
453 const struct lrecord_implementation lrecord_##c_name = \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
454 { name, marker, printer, nuker, equal, hash, desc, \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
455 getprop, putprop, remprop, plist, size, sizer, \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
456 lrecord_type_##c_name, basic_p }
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
457
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
458 extern Lisp_Object (*lrecord_markers[]) (Lisp_Object);
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
459
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
460 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
461 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
462 lrecord_markers[lrecord_type_##type] = \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
463 lrecord_implementations_table[lrecord_type_##type]->marker; \
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
464 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
466 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
468
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
469 #define RECORD_TYPEP(x, ty) \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
470 (LRECORDP (x) && XRECORD_LHEADER (x)->type == (ty))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 /* NOTE: the DECLARE_LRECORD() must come before the associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 DEFINE_LRECORD_*() or you will get compile errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 Furthermore, you always need to put the DECLARE_LRECORD() in a header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 file, and make sure the header file is included in inline.c, even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 if the type is private to a particular file. Otherwise, you will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 get undefined references for the error_check_foo() inline function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 under GCC. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 #ifdef ERROR_CHECK_TYPECHECK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
483 # define DECLARE_LRECORD(c_name, structtype) \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
484 extern const struct lrecord_implementation lrecord_##c_name; \
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
485 INLINE_HEADER structtype * \
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
486 error_check_##c_name (Lisp_Object obj); \
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
487 INLINE_HEADER structtype * \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
488 error_check_##c_name (Lisp_Object obj) \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
489 { \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
490 assert (RECORD_TYPEP (obj, lrecord_type_##c_name)); \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
491 return (structtype *) XPNTR (obj); \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
492 } \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
495 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
496 INLINE_HEADER structtype * \
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
497 error_check_##c_name (Lisp_Object obj); \
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
498 INLINE_HEADER structtype * \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
499 error_check_##c_name (Lisp_Object obj) \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
500 { \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
501 assert (XTYPE (obj) == type_enum); \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
502 return (structtype *) XPNTR (obj); \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
503 } \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 # define XRECORD(x, c_name, structtype) error_check_##c_name (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 # define XNONRECORD(x, c_name, type_enum, structtype) error_check_##c_name (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
509 # define XSETRECORD(var, p, c_name) do \
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
510 { \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
511 XSETOBJ (var, Lisp_Type_Record, p); \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
512 assert (RECORD_TYPEP (var, lrecord_type_##c_name)); \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 #else /* not ERROR_CHECK_TYPECHECK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
517 # define DECLARE_LRECORD(c_name, structtype) \
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
518 extern Lisp_Object Q##c_name##p; \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
519 extern const struct lrecord_implementation lrecord_##c_name
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
520 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
523 # define XNONRECORD(x, c_name, type_enum, structtype) \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ((structtype *) XPNTR (x))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
525 # define XSETRECORD(var, p, c_name) XSETOBJ (var, Lisp_Type_Record, p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 #endif /* not ERROR_CHECK_TYPECHECK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
529 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 /* Note: we now have two different kinds of type-checking macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 The "old" kind has now been renamed CONCHECK_foo. The reason for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 this is that the CONCHECK_foo macros signal a continuable error,
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
534 allowing the user (through debug-on-error) to substitute a different
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 value and return from the signal, which causes the lvalue argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 to get changed. Quite a lot of code would crash if that happened,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 because it did things like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 foo = XCAR (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 CHECK_STRING (foo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 and later on did XSTRING (XCAR (list)), assuming that the type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 is correct (when it might be wrong, if the user substituted a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 correct value in the debugger).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 To get around this, I made all the CHECK_foo macros signal a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 non-continuable error. Places where a continuable error is OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (generally only when called directly on the argument of a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 primitive) should be changed to use CONCHECK().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 FSF Emacs does not have this problem because RMS took the cheesy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 way out and disabled returning from a signal entirely. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
554 #define CONCHECK_RECORD(x, c_name) do { \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
555 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
556 x = wrong_type_argument (Q##c_name##p, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
557 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
558 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
559 if (XTYPE (x) != lisp_enum) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
560 x = wrong_type_argument (predicate, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
561 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
562 #define CHECK_RECORD(x, c_name) do { \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
563 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
564 dead_wrong_type_argument (Q##c_name##p, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
565 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
566 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
567 if (XTYPE (x) != lisp_enum) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
568 dead_wrong_type_argument (predicate, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
569 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
571 void *alloc_lcrecord (size_t size, const struct lrecord_implementation *);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
573 #define alloc_lcrecord_type(type, lrecord_implementation) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
574 ((type *) alloc_lcrecord (sizeof (type), lrecord_implementation))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
575
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 /* Copy the data from one lcrecord structure into another, but don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 overwrite the header information. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
579 #define copy_lcrecord(dst, src) \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
580 memcpy ((char *) (dst) + sizeof (struct lcrecord_header), \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
581 (char *) (src) + sizeof (struct lcrecord_header), \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
582 sizeof (*(dst)) - sizeof (struct lcrecord_header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
584 #define zero_lcrecord(lcr) \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
585 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
586 sizeof (*(lcr)) - sizeof (struct lcrecord_header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
588 #endif /* INCLUDED_lrecord_h_ */