comparison src/symeval.h @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents c5d627a313b1
children 74fd4e045ea6
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
97 */ 97 */
98 98
99 struct symbol_value_forward 99 struct symbol_value_forward
100 { 100 {
101 struct symbol_value_magic magic; 101 struct symbol_value_magic magic;
102 /* void *forward; -- use magic.lcheader.next instead */ 102
103 /* Function controlling magic behavior of this forward variable. 103 /* `magicfun' is a function controlling the magic behavior of this
104 forward variable.
104 105
105 SYM is the symbol being operated on (read, set, etc.); 106 SYM is the symbol being operated on (read, set, etc.);
106 107
107 VAL is either the value to set or the value to be returned. 108 VAL is either the value to set or the value to be returned.
108 109
120 #### If this information is important, let me know 121 #### If this information is important, let me know
121 and I will look into providing it.) (Remember also 122 and I will look into providing it.) (Remember also
122 that the only console-local variables currently existing 123 that the only console-local variables currently existing
123 are built-in ones, because others can't be created.) 124 are built-in ones, because others can't be created.)
124 125
125 FLAGS gives more information about the operation being 126 FLAGS gives more information about the operation being performed.
126 performed. 127
127 128 The return value indicates what the magic function actually did.
128 The return value indicates what the magic function actually
129 did.
130 129
131 Currently FLAGS and the return value are not used. This 130 Currently FLAGS and the return value are not used. This
132 function is only called when the value of a forward variable 131 function is only called when the value of a forward variable
133 is about to be changed. Note that this can occur explicitly 132 is about to be changed. Note that this can occur explicitly
134 through a call to `set', `setq', `set-default', or `setq-default', 133 through a call to `set', `setq', `set-default', or `setq-default',
135 or implicitly by the current buffer being changed. 134 or implicitly by the current buffer being changed. */
136
137 */
138
139 int (*magicfun) (Lisp_Object sym, Lisp_Object *val, Lisp_Object in_object, 135 int (*magicfun) (Lisp_Object sym, Lisp_Object *val, Lisp_Object in_object,
140 int flags); 136 int flags);
141 }; 137 };
142 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward); 138 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward);
143 #define XSYMBOL_VALUE_FORWARD(x) \ 139 #define XSYMBOL_VALUE_FORWARD(x) \
269 XRECORD (x, symbol_value_varalias, struct symbol_value_varalias) 265 XRECORD (x, symbol_value_varalias, struct symbol_value_varalias)
270 #define SYMBOL_VALUE_VARALIAS_P(x) RECORDP (x, symbol_value_varalias) 266 #define SYMBOL_VALUE_VARALIAS_P(x) RECORDP (x, symbol_value_varalias)
271 #define symbol_value_varalias_aliasee(m) ((m)->aliasee) 267 #define symbol_value_varalias_aliasee(m) ((m)->aliasee)
272 #define symbol_value_varalias_shadowed(m) ((m)->shadowed) 268 #define symbol_value_varalias_shadowed(m) ((m)->shadowed)
273 269
274 /* DEFSUBR (Fname); 270 /* To define a Lisp primitive function using a C function `Fname', do this:
275 is how we define the symbol for function `Fname' at start-up time. */ 271 DEFUN ("name, Fname, ...); // at top level in foo.c
272 DEFSUBR (Fname); // in syms_of_foo();
273 */
274 void defsubr (Lisp_Subr *);
276 #define DEFSUBR(Fname) defsubr (&S##Fname) 275 #define DEFSUBR(Fname) defsubr (&S##Fname)
277 void defsubr (struct Lisp_Subr *); 276
277 /* To define a Lisp primitive macro using a C function `Fname', do this:
278 DEFUN ("name, Fname, ...); // at top level in foo.c
279 DEFSUBR_MACRO (Fname); // in syms_of_foo();
280 */
281 void defsubr_macro (Lisp_Subr *);
282 #define DEFSUBR_MACRO(Fname) defsubr_macro (&S##Fname)
278 283
279 void defsymbol (Lisp_Object *location, CONST char *name); 284 void defsymbol (Lisp_Object *location, CONST char *name);
280 285
281 void defkeyword (Lisp_Object *location, CONST char *name); 286 void defkeyword (Lisp_Object *location, CONST char *name);
282 287
284 CONST char *message, Lisp_Object inherits_from); 289 CONST char *message, Lisp_Object inherits_from);
285 290
286 /* Macros we use to define forwarded Lisp variables. 291 /* Macros we use to define forwarded Lisp variables.
287 These are used in the syms_of_FILENAME functions. */ 292 These are used in the syms_of_FILENAME functions. */
288 293
289 void defvar_mumble (CONST char *names, CONST void *magic, size_t sizeof_magic); 294 void defvar_magic (CONST char *symbol_name, CONST struct symbol_value_forward *magic);
290 295
291 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION 296 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
292 # define symbol_value_forward_lheader_initializer { 1, 0, 0 } 297 # define symbol_value_forward_lheader_initializer { 1, 0, 0 }
293 #else 298 #else
294 # define symbol_value_forward_lheader_initializer \ 299 # define symbol_value_forward_lheader_initializer \
295 { lrecord_symbol_value_forward } 300 { lrecord_symbol_value_forward }
296 #endif 301 #endif
297 302
298 #define DEFVAR_HEADER(lname, c_location, forward_type) \ 303 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \
299 DEFVAR_MAGIC_HEADER (lname, c_location, forward_type, 0) 304 static CONST_IF_NOT_DEBUG struct symbol_value_forward I_hate_C \
300
301 #define DEFVAR_MAGIC_HEADER(lname, c_location, forward_type, magicfun) do { \
302 static CONST struct symbol_value_forward I_hate_C \
303 = { { { symbol_value_forward_lheader_initializer, \ 305 = { { { symbol_value_forward_lheader_initializer, \
304 (struct lcrecord_header *) (c_location), 69 }, \ 306 (struct lcrecord_header *) (c_location), 69 }, \
305 forward_type }, magicfun }; \ 307 forward_type }, magicfun }; \
306 defvar_mumble ((lname), &I_hate_C, sizeof (I_hate_C)); \ 308 defvar_magic ((lname), &I_hate_C); \
307 } while (0) 309 } while (0)
308 310
309 #define DEFVAR_HEADER_GCPRO(lname, c_location, symbol_value_type) do { \ 311 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \
310 DEFVAR_HEADER (lname, c_location, symbol_value_type); \ 312 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \
311 staticpro (c_location); \ 313 staticpro (c_location); \
314 if (EQ (*c_location, Qnull_pointer)) *c_location = Qnil; \
312 } while (0) 315 } while (0)
313 316
314 #define DEFVAR_LISP(lname, c_location) \ 317 #define DEFVAR_LISP(lname, c_location) \
315 DEFVAR_HEADER_GCPRO (lname, c_location, SYMVAL_OBJECT_FORWARD) 318 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, 0)
316 #define DEFVAR_CONST_LISP(lname, c_location) \ 319 #define DEFVAR_CONST_LISP(lname, c_location) \
317 DEFVAR_HEADER_GCPRO (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD) 320 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0)
318 #define DEFVAR_SPECIFIER(lname, c_location) \ 321 #define DEFVAR_SPECIFIER(lname, c_location) \
319 DEFVAR_HEADER_GCPRO (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD) 322 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0)
320 #define DEFVAR_INT(lname, c_location) \ 323 #define DEFVAR_INT(lname, c_location) \
321 DEFVAR_HEADER (lname, c_location, SYMVAL_FIXNUM_FORWARD) 324 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0)
322 #define DEFVAR_CONST_INT(lname, c_location) \ 325 #define DEFVAR_CONST_INT(lname, c_location) \
323 DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD) 326 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0)
324 #define DEFVAR_BOOL(lname, c_location) \ 327 #define DEFVAR_BOOL(lname, c_location) \
325 DEFVAR_HEADER (lname, c_location, SYMVAL_BOOLEAN_FORWARD) 328 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0)
326 #define DEFVAR_CONST_BOOL(lname, c_location) \ 329 #define DEFVAR_CONST_BOOL(lname, c_location) \
327 DEFVAR_HEADER (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD) 330 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0)
328 331 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \
329 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) do { \ 332 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun);
330 DEFVAR_MAGIC_HEADER (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun); \
331 staticpro (c_location); \
332 } while (0)
333 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \ 333 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \
334 DEFVAR_MAGIC_HEADER (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun); 334 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun);
335 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \ 335 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \
336 DEFVAR_MAGIC_HEADER (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun); 336 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun);
337 337
338 #endif /* _XEMACS_SYMEVAL_H_ */ 338 #endif /* _XEMACS_SYMEVAL_H_ */