annotate src/lrecord.h @ 571:4326eeed6933

[xemacs-hg @ 2001-05-25 02:57:32 by martinb] fix compile error
author martinb
date Fri, 25 May 2001 02:57:34 +0000
parents 0784d089fdc9
children af57a77cbc92
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* The "lrecord" structure (header of a compound lisp object).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
24 #ifndef INCLUDED_lrecord_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
25 #define INCLUDED_lrecord_h_
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* The "lrecord" type of Lisp object is used for all object types
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 other than a few simple ones. This allows many types to be
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 implemented but only a few bits required in a Lisp object for type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30 information. (The tradeoff is that each object has its type marked
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
31 in it, thereby increasing its size.) All lrecords begin with a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
32 `struct lrecord_header', which identifies the lisp object type, by
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
33 providing an index into a table of `struct lrecord_implementation',
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
34 which describes the behavior of the lisp object. It also contains
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
35 some other data bits.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 Lrecords are of two types: straight lrecords, and lcrecords.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 Straight lrecords are used for those types of objects that have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 their own allocation routines (typically allocated out of 2K chunks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 of memory called `frob blocks'). These objects have a `struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 lrecord_header' at the top, containing only the bits needed to find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 the lrecord_implementation for the object. There are special
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 routines in alloc.c to deal with each such object type.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 Lcrecords are used for less common sorts of objects that don't do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 their own allocation. Each such object is malloc()ed individually,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 and the objects are chained together through a `next' pointer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 Lcrecords have a `struct lcrecord_header' at the top, which
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 contains a `struct lrecord_header' and a `next' pointer, and are
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 allocated using alloc_lcrecord().
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Creating a new lcrecord type is fairly easy; just follow the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 lead of some existing type (e.g. hash tables). Note that you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 do not need to supply all the methods (see below); reasonable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 defaults are provided for many of them. Alternatively, if you're
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 just looking for a way of encapsulating data (which possibly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 could contain Lisp_Objects in it), you may well be able to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 the opaque type. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 struct lrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 /* index into lrecord_implementations_table[] */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 unsigned int type :8;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 /* If `mark' is 0 after the GC mark phase, the object will be freed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 during the GC sweep phase. There are 2 ways that `mark' can be 1:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67 - by being referenced from other objects during the GC mark phase
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 - because it is permanently on, for c_readonly objects */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 unsigned int mark :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
71 /* 1 if the object resides in logically read-only space, and does not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
72 reference other non-c_readonly objects.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
73 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
74 unsigned int c_readonly :1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 /* 1 if the object is readonly from lisp */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
77 unsigned int lisp_readonly :1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 struct lrecord_implementation;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
81 int lrecord_type_index (const struct lrecord_implementation *implementation);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
83 #define set_lheader_implementation(header,imp) do { \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 struct lrecord_header* SLI_header = (header); \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
85 SLI_header->type = (imp)->lrecord_type_index; \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
86 SLI_header->mark = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
87 SLI_header->c_readonly = 0; \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
88 SLI_header->lisp_readonly = 0; \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 struct lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 struct lrecord_header lheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
95 /* The `next' field is normally used to chain all lcrecords together
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 so that the GC can find (and free) all of them.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
97 `alloc_lcrecord' threads lcrecords together.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 The `next' field may be used for other purposes as long as some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 other mechanism is provided for letting the GC do its work.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 For example, the event and marker object types allocate members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 out of memory chunks, and are able to find all unmarked members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 by sweeping through the elements of the list of chunks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 struct lcrecord_header *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 /* The `uid' field is just for debugging/printing convenience.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 Having this slot doesn't hurt us much spacewise, since an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 lcrecord already has the above slots plus malloc overhead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 unsigned int uid :31;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 /* The `free' field is a flag that indicates whether this lcrecord
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 is on a "free list". Free lists are used to minimize the number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 of calls to malloc() when we're repeatedly allocating and freeing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 a number of the same sort of lcrecord. Lcrecords on a free list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 always get marked in a different fashion, so we can use this flag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 as a sanity check to make sure that free lists only have freed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 lcrecords and there are no freed lcrecords elsewhere. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 unsigned int free :1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 /* Used for lcrecords in an lcrecord-list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 struct free_lcrecord_header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 struct lcrecord_header lcheader;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 Lisp_Object chain;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
129 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
130 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
131 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
132 #### This should be replaced by a symbol_value_magic_p flag
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133 in the Lisp_Symbol lrecord_header. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134 lrecord_type_symbol_value_forward,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135 lrecord_type_symbol_value_varalias,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 lrecord_type_symbol_value_lisp_magic,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 lrecord_type_symbol_value_buffer_local,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
138 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 lrecord_type_symbol,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 lrecord_type_subr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 lrecord_type_cons,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 lrecord_type_vector,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 lrecord_type_string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 lrecord_type_lcrecord_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 lrecord_type_compiled_function,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 lrecord_type_weak_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 lrecord_type_bit_vector,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 lrecord_type_float,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 lrecord_type_hash_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 lrecord_type_lstream,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 lrecord_type_process,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 lrecord_type_charset,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 lrecord_type_coding_system,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 lrecord_type_char_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 lrecord_type_char_table_entry,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 lrecord_type_range_table,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 lrecord_type_opaque,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 lrecord_type_opaque_ptr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
160 lrecord_type_buffer,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
161 lrecord_type_extent,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 lrecord_type_extent_info,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163 lrecord_type_extent_auxiliary,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 lrecord_type_marker,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 lrecord_type_event,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
166 lrecord_type_keymap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
167 lrecord_type_command_builder,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168 lrecord_type_timeout,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 lrecord_type_specifier,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170 lrecord_type_console,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 lrecord_type_device,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
172 lrecord_type_frame,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 lrecord_type_window,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 lrecord_type_window_configuration,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 lrecord_type_gui_item,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176 lrecord_type_popup_data,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177 lrecord_type_toolbar_button,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
178 lrecord_type_color_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
179 lrecord_type_font_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 lrecord_type_image_instance,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
181 lrecord_type_glyph,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182 lrecord_type_face,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183 lrecord_type_database,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
184 lrecord_type_tooltalk_message,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
185 lrecord_type_tooltalk_pattern,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186 lrecord_type_ldap,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
187 lrecord_type_pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
188 lrecord_type_pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 lrecord_type_devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 lrecord_type_mswindows_dialog_id,
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
191 lrecord_type_case_table,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
192 lrecord_type_emacs_ffi,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
193 lrecord_type_emacs_gtk_object,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 454
diff changeset
194 lrecord_type_emacs_gtk_boxed,
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
195 lrecord_type_free, /* only used for "free" lrecords */
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 446
diff changeset
196 lrecord_type_undefined, /* only used for debugging */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197 lrecord_type_last_built_in_type /* must be last */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
198 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
199
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
200 extern unsigned int lrecord_type_count;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 struct lrecord_implementation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204 const char *name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206 /* `marker' is called at GC time, to make sure that all Lisp_Objects
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 pointed to by this object get properly marked. It should call
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 the mark_object function on all Lisp_Objects in the object. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 the return value is non-nil, it should be a Lisp_Object to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 marked (don't call the mark_object function explicitly on it,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 because the GC routines will do this). Doing it this way reduces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 recursion, so the object returned should preferably be the one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 with the deepest level of Lisp_Object pointers. This function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 can be NULL, meaning no GC marking is necessary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 Lisp_Object (*marker) (Lisp_Object);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217 /* `printer' converts the object to a printed representation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 This can be NULL; in this case default_object_printer() will be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
219 used instead. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
221
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222 /* `finalizer' is called at GC time when the object is about to
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 be freed, and at dump time (FOR_DISKSAVE will be non-zero in this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 case). It should perform any necessary cleanup (e.g. freeing
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 malloc()ed memory). This can be NULL, meaning no special
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 finalization is necessary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
228 WARNING: remember that `finalizer' is called at dump time even
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 though the object is not being freed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 void (*finalizer) (void *header, int for_disksave);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
231
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 /* This can be NULL, meaning compare objects with EQ(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
234
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
235 /* `hash' generates hash values for use with hash tables that have
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
236 `equal' as their test function. This can be NULL, meaning use
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
237 the Lisp_Object itself as the hash. But, you must still satisfy
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
238 the constraint that if two objects are `equal', then they *must*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
239 hash to the same value in order for hash tables to work properly.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
240 This means that `hash' can be NULL only if the `equal' method is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
241 also NULL. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 unsigned long (*hash) (Lisp_Object, int);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 /* External data layout description */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 const struct lrecord_description *description;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
247 /* These functions allow any object type to have builtin property
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
248 lists that can be manipulated from the lisp level with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
249 `get', `put', `remprop', and `object-plist'. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 Lisp_Object (*plist) (Lisp_Object obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
255 /* Only one of `static_size' and `size_in_bytes_method' is non-0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
256 If both are 0, this type is not instantiable by alloc_lcrecord(). */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 size_t static_size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 size_t (*size_in_bytes_method) (const void *header);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
260 /* The (constant) index into lrecord_implementations_table */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261 enum lrecord_type lrecord_type_index;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
262
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 one that does not have an lcrecord_header at the front and which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 is (usually) allocated in frob blocks. We only use this flag for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 some consistency checking, and that only when error-checking is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 enabled. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 unsigned int basic_p :1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 /* All the built-in lisp object types are enumerated in `enum record_type'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
272 Additional ones may be defined by a module (none yet). We leave some
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
273 room in `lrecord_implementations_table' for such new lisp object types. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
274 #define MODULE_DEFINABLE_TYPE_COUNT 32
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
275
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
276 extern const struct lrecord_implementation *lrecord_implementations_table[(unsigned int)lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
279 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
280 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 extern int gc_in_progress;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
284 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
291 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
292 struct lrecord_header *SCRRH_lheader = (lheader); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293 SCRRH_lheader->c_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
294 SCRRH_lheader->lisp_readonly = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
295 SCRRH_lheader->mark = 1; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 ((void) ((lheader)->lisp_readonly = 1))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
299 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type]
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 /* External description stuff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 A lrecord external description is an array of values. The first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 value of each line is a type, the second the offset in the lrecord
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 structure. Following values are parameters, their presence, type
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 and number is type-dependent.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 The description ends with a "XD_END" or "XD_SPECIFIER_END" record.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 Some example descriptions :
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
311
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 static const struct lrecord_description cons_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
313 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
314 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
318 Which means "two lisp objects starting at the 'car' and 'cdr' elements"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 static const struct lrecord_description string_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
321 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
322 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT(0, 1) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
323 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 "A pointer to string data at 'data', the size of the pointed array being the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 of the size variable plus 1, and one lisp object at 'plist'"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 The existing types :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 XD_LISP_OBJECT
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
331 A Lisp object. This is also the type to use for pointers to other lrecords.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
333 XD_LISP_OBJECT_ARRAY
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
334 An array of Lisp objects or pointers to lrecords.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
335 The third element is the count.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
336
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 XD_LO_LINK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 Link in a linked list of objects of the same type.
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 430
diff changeset
339
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 XD_OPAQUE_PTR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 Pointer to undumpable data. Must be NULL when dumping.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 XD_STRUCT_PTR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 Pointer to described struct. Parameters are number of structures and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 struct_description.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 XD_OPAQUE_DATA_PTR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 Pointer to dumpable opaque data. Parameter is the size of the data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 Pointed data must be relocatable without changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 XD_C_STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 Pointer to a C string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 XD_DOC_STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 Pointer to a doc string (C string if positive, opaque value if negative)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 XD_INT_RESET
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 An integer which will be reset to a given value in the dump file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 XD_SIZE_T
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 size_t value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 XD_INT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 int value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 XD_LONG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 long value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 XD_BYTECOUNT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 bytecount value. Used for counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 XD_END
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 Special type indicating the end of the array.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 XD_SPECIFIER_END
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 Special type indicating the end of the array for a specifier. Extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 description is going to be fetched from the specifier methods.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 Special macros:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 XD_INDIRECT(line, delta)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 Usable where a "count" or "size" is requested. Gives the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 the element which is at line number 'line' in the description (count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 starts at zero) and adds delta to it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 enum lrecord_description_type {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
389 XD_LISP_OBJECT_ARRAY,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 XD_LISP_OBJECT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 XD_LO_LINK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 XD_OPAQUE_PTR,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 XD_STRUCT_PTR,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 XD_OPAQUE_DATA_PTR,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 XD_C_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 XD_DOC_STRING,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 XD_INT_RESET,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 XD_SIZE_T,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 XD_INT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 XD_LONG,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 XD_BYTECOUNT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 XD_END,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 XD_SPECIFIER_END
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 struct lrecord_description {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 enum lrecord_description_type type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 int offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 EMACS_INT data1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 const struct struct_description *data2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 struct struct_description {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 size_t size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 const struct lrecord_description *description;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 #define XD_INDIRECT(val, delta) (-1-((val)|(delta<<8)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 #define XD_IS_INDIRECT(code) (code<0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 #define XD_INDIRECT_VAL(code) ((-1-code) & 255)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 #define XD_INDIRECT_DELTA(code) (((-1-code)>>8) & 255)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 #define XD_DYNARR_DESC(base_type, sub_desc) \
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
425 { XD_STRUCT_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
426 { XD_INT, offsetof (base_type, cur) }, \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
427 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 #if defined (ERROR_CHECK_TYPECHECK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
442 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof(structtype),0,1,structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454 #define DEFINE_BASIC_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,0,sizer,1,structtype)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462 const struct lrecord_implementation lrecord_##c_name = \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 { name, marker, printer, nuker, equal, hash, desc, \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 getprop, putprop, remprop, plist, size, sizer, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
465 lrecord_type_##c_name, basic_p }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468 DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
481 unsigned int lrecord_type_##c_name; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
482 struct lrecord_implementation lrecord_##c_name = \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 { name, marker, printer, nuker, equal, hash, desc, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 getprop, putprop, remprop, plist, size, sizer, \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
485 lrecord_type_last_built_in_type, basic_p }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
488 extern Lisp_Object (*lrecord_markers[]) (Lisp_Object);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
489
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
490 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
491 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
492 lrecord_markers[lrecord_type_##type] = \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
493 lrecord_implementations_table[lrecord_type_##type]->marker; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
494 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
496 #define INIT_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
497 lrecord_type_##type = lrecord_type_count++; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
498 lrecord_##type.lrecord_type_index = lrecord_type_##type; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
499 INIT_LRECORD_IMPLEMENTATION(type); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
500 } while (0)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
501
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 #define RECORD_TYPEP(x, ty) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506 (LRECORDP (x) && (((unsigned int)(XRECORD_LHEADER (x)->type)) == ((unsigned int)(ty))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
508 /* Steps to create a new object:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510 1. Declare the struct for your object in a header file somewhere.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
511 Remember that it must begin with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
512
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
513 struct lcrecord_header header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
515 2. Put a DECLARE_LRECORD() for the object below the struct definition,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 along with the standard XFOO/XSETFOO junk.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
517
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
518 3. Add this header file to inline.c.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
519
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
520 4. Create the methods for your object. Note that technically you don't
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
521 need any, but you will almost always want at least a mark method.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
523 5. Define your object with DEFINE_LRECORD_IMPLEMENTATION() or some
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
524 variant.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
525
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
526 6. Include the header file in the .c file where you defined the object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
528 7. Put a call to INIT_LRECORD_IMPLEMENTATION() for the object in the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
529 .c file's syms_of_foo() function.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
530
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
531 8. Add a type enum for the object to enum lrecord_type, earlier in this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 file.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534 An example:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536 ------------------------------ in toolbar.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538 struct toolbar_button
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
540 struct lcrecord_header header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542 Lisp_Object next;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
543 Lisp_Object frame;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 Lisp_Object up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
546 Lisp_Object down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
547 Lisp_Object disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
548
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
549 Lisp_Object cap_up_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
550 Lisp_Object cap_down_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
551 Lisp_Object cap_disabled_glyph;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 Lisp_Object callback;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
554 Lisp_Object enabled_p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
555 Lisp_Object help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
556
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 char enabled;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
558 char down;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
559 char pushright;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
560 char blank;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
561
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
562 int x, y;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 int width, height;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 int dirty;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565 int vertical;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566 int border_width;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
567 };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
569 DECLARE_LRECORD (toolbar_button, struct toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 #define XTOOLBAR_BUTTON(x) XRECORD (x, toolbar_button, struct toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 #define XSETTOOLBAR_BUTTON(x, p) XSETRECORD (x, p, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 #define TOOLBAR_BUTTONP(x) RECORDP (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 #define CHECK_TOOLBAR_BUTTON(x) CHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 #define CONCHECK_TOOLBAR_BUTTON(x) CONCHECK_RECORD (x, toolbar_button)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
575
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
576 ------------------------------ in toolbar.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
581
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
582 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
583 mark_toolbar_button (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
586 mark_object (data->next);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
587 mark_object (data->frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
588 mark_object (data->up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 mark_object (data->down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
590 mark_object (data->disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
591 mark_object (data->cap_up_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
592 mark_object (data->cap_down_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
593 mark_object (data->cap_disabled_glyph);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
594 mark_object (data->callback);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
595 mark_object (data->enabled_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
596 return data->help_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
597 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
598
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
599 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
600 mark_toolbar_button, 0, 0, 0, 0, 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
601 struct toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
602
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
603 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
604
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
605 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
606 syms_of_toolbar (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
607 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
608 INIT_LRECORD_IMPLEMENTATION (toolbar_button);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
609
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
610 ...;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
611 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
612
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
613 ------------------------------ in inline.c -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
614
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
615 #ifdef HAVE_TOOLBARS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
616 #include "toolbar.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
618
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
619 ------------------------------ in lrecord.h -----------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
620
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 enum lrecord_type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
623 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 lrecord_type_toolbar_button,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 ...
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
626 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
627
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 Note: Object types defined in external dynamically-loaded modules (not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 part of the XEmacs main source code) should use DECLARE_EXTERNAL_LRECORD
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
634 and DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION rather than DECLARE_LRECORD
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 and DEFINE_LRECORD_IMPLEMENTATION.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
636
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 #ifdef ERROR_CHECK_TYPECHECK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 # define DECLARE_LRECORD(c_name, structtype) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
643 extern const struct lrecord_implementation lrecord_##c_name; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
644 INLINE_HEADER structtype * \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
645 error_check_##c_name (Lisp_Object obj); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
646 INLINE_HEADER structtype * \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 error_check_##c_name (Lisp_Object obj) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
649 assert (RECORD_TYPEP (obj, lrecord_type_##c_name)); \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 return (structtype *) XPNTR (obj); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
654 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
655 extern unsigned int lrecord_type_##c_name; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
656 extern struct lrecord_implementation lrecord_##c_name; \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
657 INLINE_HEADER structtype * \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
658 error_check_##c_name (Lisp_Object obj); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
659 INLINE_HEADER structtype * \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
660 error_check_##c_name (Lisp_Object obj) \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
661 { \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
662 assert (RECORD_TYPEP (obj, lrecord_type_##c_name)); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
663 return (structtype *) XPNTR (obj); \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
664 } \
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
665 extern Lisp_Object Q##c_name##p
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 INLINE_HEADER structtype * \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 error_check_##c_name (Lisp_Object obj); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670 INLINE_HEADER structtype * \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 error_check_##c_name (Lisp_Object obj) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 assert (XTYPE (obj) == type_enum); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 return (structtype *) XPNTR (obj); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 # define XRECORD(x, c_name, structtype) error_check_##c_name (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 # define XNONRECORD(x, c_name, type_enum, structtype) error_check_##c_name (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 # define XSETRECORD(var, p, c_name) do \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683 XSETOBJ (var, p); \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 assert (RECORD_TYPEP (var, lrecord_type_##c_name)); \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 #else /* not ERROR_CHECK_TYPECHECK */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 # define DECLARE_LRECORD(c_name, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 extern Lisp_Object Q##c_name##p; \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691 extern const struct lrecord_implementation lrecord_##c_name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 extern Lisp_Object Q##c_name##p; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694 extern unsigned int lrecord_type_##c_name; \
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
695 extern struct lrecord_implementation lrecord_##c_name
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 extern Lisp_Object Q##c_name##p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 # define XNONRECORD(x, c_name, type_enum, structtype) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 ((structtype *) XPNTR (x))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
701 # define XSETRECORD(var, p, c_name) XSETOBJ (var, p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 #endif /* not ERROR_CHECK_TYPECHECK */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 /* Note: we now have two different kinds of type-checking macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 The "old" kind has now been renamed CONCHECK_foo. The reason for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 this is that the CONCHECK_foo macros signal a continuable error,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 allowing the user (through debug-on-error) to substitute a different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 value and return from the signal, which causes the lvalue argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 to get changed. Quite a lot of code would crash if that happened,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 because it did things like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 foo = XCAR (list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 CHECK_STRING (foo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 and later on did XSTRING (XCAR (list)), assuming that the type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 is correct (when it might be wrong, if the user substituted a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 correct value in the debugger).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 To get around this, I made all the CHECK_foo macros signal a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 non-continuable error. Places where a continuable error is OK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (generally only when called directly on the argument of a Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 primitive) should be changed to use CONCHECK().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 FSF Emacs does not have this problem because RMS took the cheesy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 way out and disabled returning from a signal entirely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 #define CONCHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 x = wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 x = wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 #define CHECK_RECORD(x, c_name) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
739 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 dead_wrong_type_argument (Q##c_name##p, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 if (XTYPE (x) != lisp_enum) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 dead_wrong_type_argument (predicate, x); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
747 void *alloc_lcrecord (size_t size, const struct lrecord_implementation *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 #define alloc_lcrecord_type(type, lrecord_implementation) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 ((type *) alloc_lcrecord (sizeof (type), lrecord_implementation))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 /* Copy the data from one lcrecord structure into another, but don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 overwrite the header information. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 #define copy_lcrecord(dst, src) \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
756 memcpy ((char *) (dst) + sizeof (struct lcrecord_header), \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
757 (char *) (src) + sizeof (struct lcrecord_header), \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
758 sizeof (*(dst)) - sizeof (struct lcrecord_header))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 #define zero_lcrecord(lcr) \
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
761 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
762 sizeof (*(lcr)) - sizeof (struct lcrecord_header))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
764 #endif /* INCLUDED_lrecord_h_ */