comparison src/symeval.h @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children a86b2b5e0111
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
21 /* Synched up with: Not in FSF. */ 21 /* Synched up with: Not in FSF. */
22 22
23 /* Fsymbol_value checks whether XSYMBOL (sym)->value is one of these, 23 /* Fsymbol_value checks whether XSYMBOL (sym)->value is one of these,
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 INCLUDED_symeval_h_
27 #define _XEMACS_SYMEVAL_H_ 27 #define INCLUDED_symeval_h_
28 28
29 enum symbol_value_type 29 enum symbol_value_type
30 { 30 {
31 /* The following tags use the 'symbol_value_forward' structure 31 /* The following tags use the 'symbol_value_forward' structure
32 and are strictly for variables DEFVARed on the C level. */ 32 and are strictly for variables DEFVARed on the C level. */
70 }; 70 };
71 71
72 struct symbol_value_magic 72 struct symbol_value_magic
73 { 73 {
74 struct lcrecord_header lcheader; 74 struct lcrecord_header lcheader;
75 void *value;
75 enum symbol_value_type type; 76 enum symbol_value_type type;
76 }; 77 };
77 #define SYMBOL_VALUE_MAGIC_P(x) \ 78 #define SYMBOL_VALUE_MAGIC_P(x) \
78 (LRECORDP (x) \ 79 (LRECORDP (x) \
79 && (XRECORD_LHEADER_IMPLEMENTATION (x)->printer \ 80 && (XRECORD_LHEADER_IMPLEMENTATION (x)->printer \
136 int flags); 137 int flags);
137 }; 138 };
138 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward); 139 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward);
139 #define XSYMBOL_VALUE_FORWARD(x) \ 140 #define XSYMBOL_VALUE_FORWARD(x) \
140 XRECORD (x, symbol_value_forward, struct symbol_value_forward) 141 XRECORD (x, symbol_value_forward, struct symbol_value_forward)
141 #define symbol_value_forward_forward(m) ((void *)((m)->magic.lcheader.next)) 142 #define symbol_value_forward_forward(m) ((void *)((m)->magic.value))
142 #define symbol_value_forward_magicfun(m) ((m)->magicfun) 143 #define symbol_value_forward_magicfun(m) ((m)->magicfun)
143 144
144 /* 2. symbol-value-buffer-local */ 145 /* 2. symbol-value-buffer-local */
145 146
146 struct symbol_value_buffer_local 147 struct symbol_value_buffer_local
279 DEFSUBR_MACRO (Fname); // in syms_of_foo(); 280 DEFSUBR_MACRO (Fname); // in syms_of_foo();
280 */ 281 */
281 void defsubr_macro (Lisp_Subr *); 282 void defsubr_macro (Lisp_Subr *);
282 #define DEFSUBR_MACRO(Fname) defsubr_macro (&S##Fname) 283 #define DEFSUBR_MACRO(Fname) defsubr_macro (&S##Fname)
283 284
284 void defsymbol (Lisp_Object *location, CONST char *name); 285 void defsymbol (Lisp_Object *location, const char *name);
285 286 void defsymbol_nodump (Lisp_Object *location, const char *name);
286 void defkeyword (Lisp_Object *location, CONST char *name); 287
287 288 void defkeyword (Lisp_Object *location, const char *name);
288 void deferror (Lisp_Object *symbol, CONST char *name, 289
289 CONST char *message, Lisp_Object inherits_from); 290 void deferror (Lisp_Object *symbol, const char *name,
291 const char *message, Lisp_Object inherits_from);
290 292
291 /* Macros we use to define forwarded Lisp variables. 293 /* Macros we use to define forwarded Lisp variables.
292 These are used in the syms_of_FILENAME functions. */ 294 These are used in the syms_of_FILENAME functions. */
293 295
294 void defvar_magic (CONST char *symbol_name, CONST struct symbol_value_forward *magic); 296 void defvar_magic (const char *symbol_name, const struct symbol_value_forward *magic);
295
296 #ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
297 # define symbol_value_forward_lheader_initializer { 1, 0, 0 }
298 #else
299 # define symbol_value_forward_lheader_initializer \
300 { lrecord_symbol_value_forward }
301 #endif
302 297
303 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \ 298 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \
304 static CONST_IF_NOT_DEBUG struct symbol_value_forward I_hate_C \ 299 static CONST_IF_NOT_DEBUG struct symbol_value_forward I_hate_C = \
305 = { { { symbol_value_forward_lheader_initializer, \ 300 { /* struct symbol_value_forward */ \
306 (struct lcrecord_header *) (c_location), 69 }, \ 301 { /* struct symbol_value_magic */ \
307 forward_type }, magicfun }; \ 302 { /* struct lcrecord_header */ \
303 { /* struct lrecord_header */ \
304 1, /* type - index into lrecord_implementations_table */ \
305 0, /* mark bit */ \
306 0, /* c_readonly bit */ \
307 0 /* lisp_readonly bit */ \
308 }, \
309 0, /* next */ \
310 0, /* uid */ \
311 0 /* free */ \
312 }, \
313 c_location, \
314 forward_type \
315 }, \
316 magicfun \
317 }; \
308 defvar_magic ((lname), &I_hate_C); \ 318 defvar_magic ((lname), &I_hate_C); \
319 } while (0)
320
321 #define DEFVAR_SYMVAL_FWD_INT(lname, c_location, forward_type, magicfun) do{ \
322 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \
323 dumpopaque (c_location, sizeof(int)); \
309 } while (0) 324 } while (0)
310 325
311 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \ 326 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \
312 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \ 327 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \
313 staticpro (c_location); \ 328 staticpro (c_location); \
319 #define DEFVAR_CONST_LISP(lname, c_location) \ 334 #define DEFVAR_CONST_LISP(lname, c_location) \
320 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0) 335 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0)
321 #define DEFVAR_SPECIFIER(lname, c_location) \ 336 #define DEFVAR_SPECIFIER(lname, c_location) \
322 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0) 337 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0)
323 #define DEFVAR_INT(lname, c_location) \ 338 #define DEFVAR_INT(lname, c_location) \
324 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0) 339 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0)
325 #define DEFVAR_CONST_INT(lname, c_location) \ 340 #define DEFVAR_CONST_INT(lname, c_location) \
326 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0) 341 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0)
327 #define DEFVAR_BOOL(lname, c_location) \ 342 #define DEFVAR_BOOL(lname, c_location) \
328 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0) 343 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0)
329 #define DEFVAR_CONST_BOOL(lname, c_location) \ 344 #define DEFVAR_CONST_BOOL(lname, c_location) \
330 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0) 345 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0)
331 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \ 346 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \
332 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun); 347 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun)
333 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \ 348 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \
334 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun); 349 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun)
335 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \ 350 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \
336 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun); 351 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun)
337 352
338 #endif /* _XEMACS_SYMEVAL_H_ */ 353 #endif /* INCLUDED_symeval_h_ */