comparison src/symeval.h @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 0293115a14e9
children 78478c60bfcd
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
24 * and does weird magic stuff if so */ 24 * and does weird magic stuff if so */
25 25
26 #ifndef _XEMACS_SYMEVAL_H_ 26 #ifndef _XEMACS_SYMEVAL_H_
27 #define _XEMACS_SYMEVAL_H_ 27 #define _XEMACS_SYMEVAL_H_
28 28
29 enum symbol_value_type
30 {
31 /* The following tags use the 'symbol_value_forward' structure
32 and are strictly for variables DEFVARed on the C level. */
33 SYMVAL_FIXNUM_FORWARD, /* Forward C "int" */
34 SYMVAL_CONST_FIXNUM_FORWARD, /* Same, but can't be set */
35 SYMVAL_BOOLEAN_FORWARD, /* Forward C boolean ("int") */
36 SYMVAL_CONST_BOOLEAN_FORWARD, /* Same, but can't be set */
37 SYMVAL_OBJECT_FORWARD, /* Forward C Lisp_Object */
38 SYMVAL_CONST_OBJECT_FORWARD, /* Same, but can't be set */
39 SYMVAL_CONST_SPECIFIER_FORWARD, /* Same, can't be set, but gives a
40 different message when attempting to
41 set that says "use set-specifier" */
42 SYMVAL_DEFAULT_BUFFER_FORWARD, /* Forward Lisp_Object into Vbuffer_defaults */
43 SYMVAL_CURRENT_BUFFER_FORWARD, /* Forward Lisp_Object into current_buffer */
44 SYMVAL_CONST_CURRENT_BUFFER_FORWARD, /* Forward Lisp_Object into
45 current_buffer, can't be set */
46 SYMVAL_DEFAULT_CONSOLE_FORWARD, /* Forward Lisp_Object into
47 Vconsole_defaults */
48 SYMVAL_SELECTED_CONSOLE_FORWARD, /* Forward Lisp_Object into
49 Vselected_console */
50 SYMVAL_CONST_SELECTED_CONSOLE_FORWARD, /* Forward Lisp_Object into
51 Vselected_console,
52 can't be set */
53 SYMVAL_UNBOUND_MARKER, /* Only Qunbound actually has this tag */
54
55 /* The following tags use the 'symbol_value_buffer_local' structure */
56 SYMVAL_BUFFER_LOCAL, /* make-variable-buffer-local */
57 SYMVAL_SOME_BUFFER_LOCAL, /* make-local-variable */
58
59 /* The following tag uses the 'symbol_value_lisp_magic' structure */
60 SYMVAL_LISP_MAGIC, /* Forward to lisp callbacks */
61
62 /* The following tag uses the 'symbol_value_varalias' structure */
63 SYMVAL_VARALIAS /* defvaralias */
64
65 #if 0
66 /* NYI */
67 SYMVAL_CONSTANT_SYMBOL, /* Self-evaluating symbol */
68 /* NYI */
69 #endif
70 };
71
29 struct symbol_value_magic 72 struct symbol_value_magic
30 { 73 {
31 struct lcrecord_header lcheader; 74 struct lcrecord_header lcheader;
32 enum 75 enum symbol_value_type type;
33 {
34 /* The following tags use the 'symbol_value_forward' structure
35 and are strictly for variables DEFVARed on the C level. */
36 SYMVAL_FIXNUM_FORWARD, /* Forward C "int" */
37 SYMVAL_CONST_FIXNUM_FORWARD, /* Same, but can't be set */
38 SYMVAL_BOOLEAN_FORWARD, /* Forward C boolean ("int") */
39 SYMVAL_CONST_BOOLEAN_FORWARD, /* Same, but can't be set */
40 SYMVAL_OBJECT_FORWARD, /* Forward C Lisp_Object */
41 SYMVAL_CONST_OBJECT_FORWARD, /* Same, but can't be set */
42 SYMVAL_CONST_SPECIFIER_FORWARD, /* Same, can't be set, but gives
43 a different message when attempting
44 to set that says "use set-specifier"
45 */
46 SYMVAL_DEFAULT_BUFFER_FORWARD, /* Forward Lisp_Object into
47 Vbuffer_defaults */
48 SYMVAL_CURRENT_BUFFER_FORWARD, /* Forward Lisp_Object into
49 current_buffer */
50 SYMVAL_CONST_CURRENT_BUFFER_FORWARD, /* Forward Lisp_Object into
51 current_buffer, can't
52 be set */
53 SYMVAL_DEFAULT_CONSOLE_FORWARD, /* Forward Lisp_Object into
54 Vconsole_defaults */
55 SYMVAL_SELECTED_CONSOLE_FORWARD, /* Forward Lisp_Object into
56 Vselected_console */
57 SYMVAL_CONST_SELECTED_CONSOLE_FORWARD, /* Forward Lisp_Object into
58 Vselected_console, can't
59 be set */
60 SYMVAL_UNBOUND_MARKER, /* Only Qunbound actually has this
61 tag */
62
63 /* The following tags use the 'symbol_value_buffer_local' structure */
64 SYMVAL_BUFFER_LOCAL, /* make-variable-buffer-local */
65 SYMVAL_SOME_BUFFER_LOCAL, /* make-local-variable */
66
67 /* The following tag uses the 'symbol_value_lisp_magic' structure */
68 SYMVAL_LISP_MAGIC, /* Forward to lisp callbacks */
69
70 /* The following tag uses the 'symbol_value_varalias' structure */
71 SYMVAL_VARALIAS /* defvaralias */
72
73 #if 0
74 /* NYI */
75 SYMVAL_CONSTANT_SYMBOL, /* Self-evaluating symbol */
76 /* NYI */
77 #endif
78 } type;
79 }; 76 };
80 #define SYMBOL_VALUE_MAGIC_P(x) \ 77 #define SYMBOL_VALUE_MAGIC_P(x) \
81 (LRECORDP (x) \ 78 (LRECORDP (x) \
82 && (XRECORD_LHEADER (x)->implementation->printer \ 79 && (XRECORD_LHEADER (x)->implementation->printer \
83 == print_symbol_value_magic)) 80 == print_symbol_value_magic))
84 #define XSYMBOL_VALUE_MAGIC_TYPE(v) \ 81 #define XSYMBOL_VALUE_MAGIC_TYPE(v) \
85 (((struct symbol_value_magic *) XPNTR (v))->type) 82 (((struct symbol_value_magic *) XPNTR (v))->type)
86 #define XSETSYMBOL_VALUE_MAGIC(s, p) XSETOBJ (s, Lisp_Record, p) 83 #define XSETSYMBOL_VALUE_MAGIC(s, p) XSETOBJ (s, Lisp_Type_Record, p)
87 extern void print_symbol_value_magic (Lisp_Object, Lisp_Object, int); 84 extern void print_symbol_value_magic (Lisp_Object, Lisp_Object, int);
88 85
89 /********** The various different symbol-value-magic types ***********/ 86 /********** The various different symbol-value-magic types ***********/
90 87
91 /* 1. symbol-value-forward */ 88 /* 1. symbol-value-forward */
96 93
97 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.
98 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,
99 whose CURRENT-VALUE field then contains a symbol-value-forward. 96 whose CURRENT-VALUE field then contains a symbol-value-forward.
100 */ 97 */
101 98
102 extern CONST_IF_NOT_DEBUG struct lrecord_implementation 99 extern CONST_IF_NOT_DEBUG struct lrecord_implementation
103 lrecord_symbol_value_forward[]; 100 lrecord_symbol_value_forward[];
104 struct symbol_value_forward 101 struct symbol_value_forward
105 { 102 {
106 struct symbol_value_magic magic; 103 struct symbol_value_magic magic;
138 is about to be changed. Note that this can occur explicitly 135 is about to be changed. Note that this can occur explicitly
139 through a call to `set', `setq', `set-default', or `setq-default', 136 through a call to `set', `setq', `set-default', or `setq-default',
140 or implicitly by the current buffer being changed. 137 or implicitly by the current buffer being changed.
141 138
142 */ 139 */
143 140
144 int (*magicfun) (Lisp_Object sym, Lisp_Object *val, Lisp_Object in_object, 141 int (*magicfun) (Lisp_Object sym, Lisp_Object *val, Lisp_Object in_object,
145 int flags); 142 int flags);
146 }; 143 };
147 #define XSYMBOL_VALUE_FORWARD(v) \ 144 #define XSYMBOL_VALUE_FORWARD(v) \
148 ((CONST struct symbol_value_forward *) XPNTR(v)) 145 ((CONST struct symbol_value_forward *) XPNTR(v))
204 -- the element (a cons) from the buffer's local_var_alist, or 201 -- the element (a cons) from the buffer's local_var_alist, or
205 nil if there is no local value in the buffer 202 nil if there is no local value in the buffer
206 203
207 These slots are called CURRENT-BUFFER, CURRENT-VALUE, and 204 These slots are called CURRENT-BUFFER, CURRENT-VALUE, and
208 CURRENT-ALIST-ELEMENT, respectively. 205 CURRENT-ALIST-ELEMENT, respectively.
209 206
210 If we want to examine or set the value in BUFFER and CURRENT-BUFFER 207 If we want to examine or set the value in BUFFER and CURRENT-BUFFER
211 equals BUFFER, we just examine or set CURRENT-VALUE. Otherwise, 208 equals BUFFER, we just examine or set CURRENT-VALUE. Otherwise,
212 we store CURRENT-VALUE value into CURRENT-ALIST-ELEMENT (or maybe 209 we store CURRENT-VALUE value into CURRENT-ALIST-ELEMENT (or maybe
213 into DEFAULT-VALUE), then find the appropriate alist element for 210 into DEFAULT-VALUE), then find the appropriate alist element for
214 BUFFER and set up CURRENT-ALIST-ELEMENT. Then we set CURRENT-VALUE 211 BUFFER and set up CURRENT-ALIST-ELEMENT. Then we set CURRENT-VALUE
215 out of that element (or maybe out of DEFAULT-VALUE), and store 212 out of that element (or maybe out of DEFAULT-VALUE), and store
216 BUFFER into CURRENT-BUFFER. 213 BUFFER into CURRENT-BUFFER.
217 214
218 If we are setting the variable and the current buffer does not have 215 If we are setting the variable and the current buffer does not have
219 an alist entry for this variable, an alist entry is created. 216 an alist entry for this variable, an alist entry is created.
220 217
221 Note that CURRENT-BUFFER's local_var_alist value for this variable 218 Note that CURRENT-BUFFER's local_var_alist value for this variable
222 might be out-of-date (the correct value is stored in CURRENT-VALUE). 219 might be out-of-date (the correct value is stored in CURRENT-VALUE).
223 Similarly, if CURRENT-BUFFER sees the default value, then 220 Similarly, if CURRENT-BUFFER sees the default value, then
224 DEFAULT-VALUE might be out-of-date. 221 DEFAULT-VALUE might be out-of-date.
225 222
226 Note that CURRENT-VALUE (but not DEFAULT-VALUE) can be a 223 Note that CURRENT-VALUE (but not DEFAULT-VALUE) can be a
227 forwarding pointer. Each time it is examined or set, 224 forwarding pointer. Each time it is examined or set,
228 forwarding must be done. 225 forwarding must be done.
229 */ 226 */
230 Lisp_Object default_value; 227 Lisp_Object default_value;
231 Lisp_Object current_value; 228 Lisp_Object current_value;
232 Lisp_Object current_buffer; 229 Lisp_Object current_buffer;
301 These are used in the syms_of_FILENAME functions. */ 298 These are used in the syms_of_FILENAME functions. */
302 299
303 extern void defvar_mumble (CONST char *names, 300 extern void defvar_mumble (CONST char *names,
304 CONST void *magic, int sizeof_magic); 301 CONST void *magic, int sizeof_magic);
305 302
306 #define DEFVAR_HEADER(lname, c_location, forward_type) \ 303 #define DEFVAR_HEADER(lname, c_location, forward_type) do { \
307 static CONST struct symbol_value_forward I_hate_C \ 304 static CONST struct symbol_value_forward I_hate_C \
308 = { { { { lrecord_symbol_value_forward }, (void *) (c_location), 69 }, \ 305 = { { { { lrecord_symbol_value_forward }, \
309 forward_type }, 0 }; \ 306 (struct lcrecord_header *) (c_location), 69 }, \
310 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)) 307 forward_type }, 0 }; \
311 308 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)); \
312 #define DEFVAR_MAGIC_HEADER(lname, c_location, forward_type, magicfun) \ 309 } while (0)
313 static CONST struct symbol_value_forward I_hate_C \ 310
314 = { { { { lrecord_symbol_value_forward }, (void *) (c_location), 69 }, \ 311 #define DEFVAR_MAGIC_HEADER(lname, c_location, forward_type, magicfun) do { \
315 forward_type }, magicfun }; \ 312 static CONST struct symbol_value_forward I_hate_C \
316 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)) 313 = { { { { lrecord_symbol_value_forward }, \
314 (struct lcrecord_header *) (c_location), 69 }, \
315 forward_type }, magicfun }; \
316 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)); \
317 } while (0)
317 318
318 /* These discard their DOC arg because it is snarfed by make-docfile 319 /* These discard their DOC arg because it is snarfed by make-docfile
319 * and stored in an external file. */ 320 * and stored in an external file. */
320 321
321 #define DEFVAR_LISP(lname, c_location) \ 322 #define DEFVAR_HEADER_GCPRO(lname, c_location, symbol_value_type) do { \
322 do { DEFVAR_HEADER (lname, c_location, SYMVAL_OBJECT_FORWARD); \ 323 DEFVAR_HEADER (lname, c_location, symbol_value_type); \
323 staticpro (c_location); \ 324 staticpro (c_location); \
324 } while (0) 325 } while (0)
325 #define DEFVAR_CONST_LISP(lname, c_location) \ 326
326 do { DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD); \ 327 #define DEFVAR_LISP(lname, c_location) \
327 staticpro (c_location); \ 328 DEFVAR_HEADER_GCPRO (lname, c_location, SYMVAL_OBJECT_FORWARD)
328 } while (0) 329 #define DEFVAR_CONST_LISP(lname, c_location) \
329 #define DEFVAR_SPECIFIER(lname, c_location) \ 330 DEFVAR_HEADER_GCPRO (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD)
330 do { DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD); \ 331 #define DEFVAR_SPECIFIER(lname, c_location) \
331 staticpro (c_location); \ 332 DEFVAR_HEADER_GCPRO (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD)
332 } while (0) 333 #define DEFVAR_INT(lname, c_location) \
333 #define DEFVAR_INT(lname, c_location) \ 334 DEFVAR_HEADER (lname, c_location, SYMVAL_FIXNUM_FORWARD)
334 do { DEFVAR_HEADER (lname, c_location, SYMVAL_FIXNUM_FORWARD); \ 335 #define DEFVAR_CONST_INT(lname, c_location) \
335 } while (0) 336 DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD)
336 #define DEFVAR_CONST_INT(lname, c_location) \ 337 #define DEFVAR_BOOL(lname, c_location) \
337 do { DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD); \ 338 DEFVAR_HEADER (lname, c_location, SYMVAL_BOOLEAN_FORWARD)
338 } while (0) 339 #define DEFVAR_CONST_BOOL(lname, c_location) \
339 #define DEFVAR_BOOL(lname, c_location) \ 340 DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD)
340 do { DEFVAR_HEADER (lname, c_location, SYMVAL_BOOLEAN_FORWARD);\ 341
341 } while (0) 342 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) do { \
342 #define DEFVAR_CONST_BOOL(lname, c_location) \ 343 DEFVAR_MAGIC_HEADER (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun); \
343 do { DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD); \ 344 staticpro (c_location); \
344 } while (0) 345 } while (0)
345 346 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \
346 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \ 347 DEFVAR_MAGIC_HEADER (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun);
347 do { DEFVAR_MAGIC_HEADER (lname, c_location, \ 348 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \
348 SYMVAL_OBJECT_FORWARD, magicfun); \ 349 DEFVAR_MAGIC_HEADER (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun);
349 staticpro (c_location); \
350 } while (0)
351 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \
352 do { DEFVAR_MAGIC_HEADER (lname, c_location, \
353 SYMVAL_FIXNUM_FORWARD, magicfun); \
354 } while (0)
355 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \
356 do { DEFVAR_MAGIC_HEADER (lname, c_location, \
357 SYMVAL_BOOLEAN_FORWARD, magicfun); \
358 } while (0)
359 350
360 #endif /* _XEMACS_SYMEVAL_H_ */ 351 #endif /* _XEMACS_SYMEVAL_H_ */