comparison src/symeval.h @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 78478c60bfcd
children 8626e4521993
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
79 && (XRECORD_LHEADER_IMPLEMENTATION (x)->printer \ 79 && (XRECORD_LHEADER_IMPLEMENTATION (x)->printer \
80 == print_symbol_value_magic)) 80 == print_symbol_value_magic))
81 #define XSYMBOL_VALUE_MAGIC_TYPE(v) \ 81 #define XSYMBOL_VALUE_MAGIC_TYPE(v) \
82 (((struct symbol_value_magic *) XPNTR (v))->type) 82 (((struct symbol_value_magic *) XPNTR (v))->type)
83 #define XSETSYMBOL_VALUE_MAGIC(s, p) XSETOBJ (s, Lisp_Type_Record, p) 83 #define XSETSYMBOL_VALUE_MAGIC(s, p) XSETOBJ (s, Lisp_Type_Record, p)
84 extern void print_symbol_value_magic (Lisp_Object, Lisp_Object, int); 84 void print_symbol_value_magic (Lisp_Object, Lisp_Object, int);
85 85
86 /********** The various different symbol-value-magic types ***********/ 86 /********** The various different symbol-value-magic types ***********/
87 87
88 /* 1. symbol-value-forward */ 88 /* 1. symbol-value-forward */
89 89
94 Note that some of these types of variables can be made buffer-local. 94 Note that some of these types of variables can be made buffer-local.
95 Then, the symbol's value field contains a symbol-value-buffer-local, 95 Then, the symbol's value field contains a symbol-value-buffer-local,
96 whose CURRENT-VALUE field then contains a symbol-value-forward. 96 whose CURRENT-VALUE field then contains a symbol-value-forward.
97 */ 97 */
98 98
99 extern CONST_IF_NOT_DEBUG struct lrecord_implementation
100 lrecord_symbol_value_forward[];
101 struct symbol_value_forward 99 struct symbol_value_forward
102 { 100 {
103 struct symbol_value_magic magic; 101 struct symbol_value_magic magic;
104 /* void *forward; -- use magic.lcheader.next instead */ 102 /* void *forward; -- use magic.lcheader.next instead */
105 /* Function controlling magic behavior of this forward variable. 103 /* Function controlling magic behavior of this forward variable.
139 */ 137 */
140 138
141 int (*magicfun) (Lisp_Object sym, Lisp_Object *val, Lisp_Object in_object, 139 int (*magicfun) (Lisp_Object sym, Lisp_Object *val, Lisp_Object in_object,
142 int flags); 140 int flags);
143 }; 141 };
144 #define XSYMBOL_VALUE_FORWARD(v) \ 142 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward);
145 ((CONST struct symbol_value_forward *) XPNTR(v)) 143 #define XSYMBOL_VALUE_FORWARD(x) \
144 XRECORD (x, symbol_value_forward, struct symbol_value_forward)
146 #define symbol_value_forward_forward(m) ((void *)((m)->magic.lcheader.next)) 145 #define symbol_value_forward_forward(m) ((void *)((m)->magic.lcheader.next))
147 #define symbol_value_forward_magicfun(m) ((m)->magicfun) 146 #define symbol_value_forward_magicfun(m) ((m)->magicfun)
148 147
149 /* 2. symbol-value-buffer-local */ 148 /* 2. symbol-value-buffer-local */
150 149
151 extern CONST_IF_NOT_DEBUG struct lrecord_implementation
152 lrecord_symbol_value_buffer_local[];
153 struct symbol_value_buffer_local 150 struct symbol_value_buffer_local
154 { 151 {
155 struct symbol_value_magic magic; 152 struct symbol_value_magic magic;
156 /* Used in a symbol value cell when the symbol's value is per-buffer. 153 /* Used in a symbol value cell when the symbol's value is per-buffer.
157 154
182 otherwise, set the default. (Remember that SYMVAL_BUFFER_LOCAL 179 otherwise, set the default. (Remember that SYMVAL_BUFFER_LOCAL
183 variables implicitly call `make-local-variable' first, so when 180 variables implicitly call `make-local-variable' first, so when
184 setting a value, there will always be an entry in the buffer's 181 setting a value, there will always be an entry in the buffer's
185 local_var_alist to set.) 182 local_var_alist to set.)
186 183
187 However, these operation is potentially slow. To speed it up, 184 However, this operation is potentially slow. To speed it up,
188 we cache the value in one buffer in this structure. 185 we cache the value in one buffer in this structure.
189 186
190 NOTE: This is *not* a write-through cache. I.e. when setting 187 NOTE: This is *not* a write-through cache. I.e. when setting
191 the value in the buffer that is cached, we *only* change the 188 the value in the buffer that is cached, we *only* change the
192 cache and don't write the value through to either the buffer's 189 cache and don't write the value through to either the buffer's
227 Lisp_Object default_value; 224 Lisp_Object default_value;
228 Lisp_Object current_value; 225 Lisp_Object current_value;
229 Lisp_Object current_buffer; 226 Lisp_Object current_buffer;
230 Lisp_Object current_alist_element; 227 Lisp_Object current_alist_element;
231 }; 228 };
232 #define XSYMBOL_VALUE_BUFFER_LOCAL(v) \ 229 DECLARE_LRECORD (symbol_value_buffer_local, struct symbol_value_buffer_local);
233 ((struct symbol_value_buffer_local *) XPNTR(v)) 230 #define XSYMBOL_VALUE_BUFFER_LOCAL(x) \
234 #define SYMBOL_VALUE_BUFFER_LOCAL_P(v) \ 231 XRECORD (x, symbol_value_buffer_local, struct symbol_value_buffer_local)
235 (SYMBOL_VALUE_MAGIC_P (v) && \ 232 #define SYMBOL_VALUE_BUFFER_LOCAL_P(x) RECORDP (x, symbol_value_buffer_local)
236 (XSYMBOL_VALUE_MAGIC_TYPE (v) == SYMVAL_BUFFER_LOCAL \
237 || XSYMBOL_VALUE_MAGIC_TYPE (v) == SYMVAL_SOME_BUFFER_LOCAL))
238 233
239 /* 3. symbol-value-lisp-magic */ 234 /* 3. symbol-value-lisp-magic */
240 235
241 extern CONST_IF_NOT_DEBUG struct lrecord_implementation
242 lrecord_symbol_value_lisp_magic[];
243 enum lisp_magic_handler 236 enum lisp_magic_handler
244 { 237 {
245 MAGIC_HANDLER_GET_VALUE, 238 MAGIC_HANDLER_GET_VALUE,
246 MAGIC_HANDLER_SET_VALUE, 239 MAGIC_HANDLER_SET_VALUE,
247 MAGIC_HANDLER_BOUND_PREDICATE, 240 MAGIC_HANDLER_BOUND_PREDICATE,
256 struct symbol_value_magic magic; 249 struct symbol_value_magic magic;
257 Lisp_Object handler[MAGIC_HANDLER_MAX]; 250 Lisp_Object handler[MAGIC_HANDLER_MAX];
258 Lisp_Object harg[MAGIC_HANDLER_MAX]; 251 Lisp_Object harg[MAGIC_HANDLER_MAX];
259 Lisp_Object shadowed; 252 Lisp_Object shadowed;
260 }; 253 };
261 #define XSYMBOL_VALUE_LISP_MAGIC(v) \ 254 DECLARE_LRECORD (symbol_value_lisp_magic, struct symbol_value_lisp_magic);
262 ((struct symbol_value_lisp_magic *) XPNTR (v)) 255 #define XSYMBOL_VALUE_LISP_MAGIC(x) \
263 #define SYMBOL_VALUE_LISP_MAGIC_P(v) \ 256 XRECORD (x, symbol_value_lisp_magic, struct symbol_value_lisp_magic)
264 (SYMBOL_VALUE_MAGIC_P (v) && \ 257 #define SYMBOL_VALUE_LISP_MAGIC_P(x) RECORDP (x, symbol_value_lisp_magic)
265 XSYMBOL_VALUE_MAGIC_TYPE (v) == SYMVAL_LISP_MAGIC)
266 258
267 /* 4. symbol-value-varalias */ 259 /* 4. symbol-value-varalias */
268 260
269 extern CONST_IF_NOT_DEBUG struct lrecord_implementation
270 lrecord_symbol_value_varalias[];
271 struct symbol_value_varalias 261 struct symbol_value_varalias
272 { 262 {
273 struct symbol_value_magic magic; 263 struct symbol_value_magic magic;
274 Lisp_Object aliasee; 264 Lisp_Object aliasee;
275 Lisp_Object shadowed; 265 Lisp_Object shadowed;
276 }; 266 };
277 #define XSYMBOL_VALUE_VARALIAS(v) \ 267 DECLARE_LRECORD (symbol_value_varalias, struct symbol_value_varalias);
278 ((struct symbol_value_varalias *) XPNTR (v)) 268 #define XSYMBOL_VALUE_VARALIAS(x) \
279 #define SYMBOL_VALUE_VARALIAS_P(v) \ 269 XRECORD (x, symbol_value_varalias, struct symbol_value_varalias)
280 (SYMBOL_VALUE_MAGIC_P (v) && \ 270 #define SYMBOL_VALUE_VARALIAS_P(x) RECORDP (x, symbol_value_varalias)
281 XSYMBOL_VALUE_MAGIC_TYPE (v) == SYMVAL_VARALIAS)
282 #define symbol_value_varalias_aliasee(m) ((m)->aliasee) 271 #define symbol_value_varalias_aliasee(m) ((m)->aliasee)
283 #define symbol_value_varalias_shadowed(m) ((m)->shadowed) 272 #define symbol_value_varalias_shadowed(m) ((m)->shadowed)
284 273
285 /* DEFSUBR (Fname); 274 /* DEFSUBR (Fname);
286 is how we define the symbol for function `Fname' at start-up time. */ 275 is how we define the symbol for function `Fname' at start-up time. */
287 #define DEFSUBR(Fname) defsubr (&S##Fname) 276 #define DEFSUBR(Fname) defsubr (&S##Fname)
288 extern void defsubr (struct Lisp_Subr *); 277 void defsubr (struct Lisp_Subr *);
289 278
290 extern void defsymbol (Lisp_Object *location, CONST char *name); 279 void defsymbol (Lisp_Object *location, CONST char *name);
291 280
292 extern void defkeyword (Lisp_Object *location, CONST char *name); 281 void defkeyword (Lisp_Object *location, CONST char *name);
293 282
294 extern void deferror (Lisp_Object *symbol, CONST char *name, 283 void deferror (Lisp_Object *symbol, CONST char *name,
295 CONST char *message, Lisp_Object inherits_from); 284 CONST char *message, Lisp_Object inherits_from);
296 285
297 /* Macros we use to define forwarded Lisp variables. 286 /* Macros we use to define forwarded Lisp variables.
298 These are used in the syms_of_FILENAME functions. */ 287 These are used in the syms_of_FILENAME functions. */
299 288
300 extern void defvar_mumble (CONST char *names, 289 void defvar_mumble (CONST char *names, CONST void *magic, size_t sizeof_magic);
301 CONST void *magic, int sizeof_magic);
302 290
303 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION 291 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
304 # define symbol_value_forward_lheader_initializer { 1, 0, 0 } 292 # define symbol_value_forward_lheader_initializer { 1, 0, 0 }
305 #else 293 #else
306 # define symbol_value_forward_lheader_initializer \ 294 # define symbol_value_forward_lheader_initializer \
307 { lrecord_symbol_value_forward } 295 { lrecord_symbol_value_forward }
308 #endif 296 #endif
309 297
310 #define DEFVAR_HEADER(lname, c_location, forward_type) do { \ 298 #define DEFVAR_HEADER(lname, c_location, forward_type) \
311 static CONST struct symbol_value_forward I_hate_C \ 299 DEFVAR_MAGIC_HEADER (lname, c_location, forward_type, 0)
312 = { { { symbol_value_forward_lheader_initializer, \
313 (struct lcrecord_header *) (c_location), 69 }, \
314 forward_type }, 0 }; \
315 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)); \
316 } while (0)
317 300
318 #define DEFVAR_MAGIC_HEADER(lname, c_location, forward_type, magicfun) do { \ 301 #define DEFVAR_MAGIC_HEADER(lname, c_location, forward_type, magicfun) do { \
319 static CONST struct symbol_value_forward I_hate_C \ 302 static CONST struct symbol_value_forward I_hate_C \
320 = { { { symbol_value_forward_lheader_initializer, \ 303 = { { { symbol_value_forward_lheader_initializer, \
321 (struct lcrecord_header *) (c_location), 69 }, \ 304 (struct lcrecord_header *) (c_location), 69 }, \
322 forward_type }, magicfun }; \ 305 forward_type }, magicfun }; \
323 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)); \ 306 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)); \
324 } while (0) 307 } while (0)
325
326 /* These discard their DOC arg because it is snarfed by make-docfile
327 * and stored in an external file. */
328 308
329 #define DEFVAR_HEADER_GCPRO(lname, c_location, symbol_value_type) do { \ 309 #define DEFVAR_HEADER_GCPRO(lname, c_location, symbol_value_type) do { \
330 DEFVAR_HEADER (lname, c_location, symbol_value_type); \ 310 DEFVAR_HEADER (lname, c_location, symbol_value_type); \
331 staticpro (c_location); \ 311 staticpro (c_location); \
332 } while (0) 312 } while (0)