comparison src/symeval.h @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents a86b2b5e0111
children 41dbb7a9d5f2
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
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 INCLUDED_symeval_h_ 26 #ifndef _XEMACS_SYMEVAL_H_
27 #define INCLUDED_symeval_h_ 27 #define _XEMACS_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;
76 enum symbol_value_type type; 75 enum symbol_value_type type;
77 }; 76 };
78 #define SYMBOL_VALUE_MAGIC_P(x) \ 77 #define SYMBOL_VALUE_MAGIC_P(x) \
79 (LRECORDP (x) && \ 78 (LRECORDP (x) \
80 XRECORD_LHEADER (x)->type <= lrecord_type_max_symbol_value_magic) 79 && (XRECORD_LHEADER_IMPLEMENTATION (x)->printer \
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 void print_symbol_value_magic (Lisp_Object, Lisp_Object, int); 84 void print_symbol_value_magic (Lisp_Object, Lisp_Object, int);
85 85
136 int flags); 136 int flags);
137 }; 137 };
138 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward); 138 DECLARE_LRECORD (symbol_value_forward, struct symbol_value_forward);
139 #define XSYMBOL_VALUE_FORWARD(x) \ 139 #define XSYMBOL_VALUE_FORWARD(x) \
140 XRECORD (x, symbol_value_forward, struct symbol_value_forward) 140 XRECORD (x, symbol_value_forward, struct symbol_value_forward)
141 #define symbol_value_forward_forward(m) ((void *)((m)->magic.value)) 141 #define symbol_value_forward_forward(m) ((void *)((m)->magic.lcheader.next))
142 #define symbol_value_forward_magicfun(m) ((m)->magicfun) 142 #define symbol_value_forward_magicfun(m) ((m)->magicfun)
143 143
144 /* 2. symbol-value-buffer-local */ 144 /* 2. symbol-value-buffer-local */
145 145
146 struct symbol_value_buffer_local 146 struct symbol_value_buffer_local
279 DEFSUBR_MACRO (Fname); // in syms_of_foo(); 279 DEFSUBR_MACRO (Fname); // in syms_of_foo();
280 */ 280 */
281 void defsubr_macro (Lisp_Subr *); 281 void defsubr_macro (Lisp_Subr *);
282 #define DEFSUBR_MACRO(Fname) defsubr_macro (&S##Fname) 282 #define DEFSUBR_MACRO(Fname) defsubr_macro (&S##Fname)
283 283
284 void defsymbol (Lisp_Object *location, const char *name); 284 void defsymbol (Lisp_Object *location, CONST char *name);
285 void defsymbol_nodump (Lisp_Object *location, const char *name); 285
286 286 void defkeyword (Lisp_Object *location, CONST char *name);
287 void defkeyword (Lisp_Object *location, const char *name); 287
288 288 void deferror (Lisp_Object *symbol, CONST char *name,
289 void deferror (Lisp_Object *symbol, const char *name, 289 CONST char *message, Lisp_Object inherits_from);
290 const char *message, Lisp_Object inherits_from);
291 290
292 /* Macros we use to define forwarded Lisp variables. 291 /* Macros we use to define forwarded Lisp variables.
293 These are used in the syms_of_FILENAME functions. */ 292 These are used in the syms_of_FILENAME functions. */
294 293
295 void defvar_magic (const char *symbol_name, const struct symbol_value_forward *magic); 294 void defvar_magic (CONST char *symbol_name, CONST struct symbol_value_forward *magic);
295
296 #define symbol_value_forward_lheader_initializer { 1, { 0, 0, 0 } }
296 297
297 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \ 298 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \
298 static const struct symbol_value_forward I_hate_C = \ 299 static CONST_IF_NOT_DEBUG struct symbol_value_forward I_hate_C \
299 { /* struct symbol_value_forward */ \ 300 = { { { symbol_value_forward_lheader_initializer, \
300 { /* struct symbol_value_magic */ \ 301 (struct lcrecord_header *) (c_location), 69 }, \
301 { /* struct lcrecord_header */ \ 302 forward_type }, magicfun }; \
302 { /* struct lrecord_header */ \
303 lrecord_type_symbol_value_forward, /* lrecord_type_index */ \
304 1, /* mark bit */ \
305 1, /* c_readonly bit */ \
306 1 /* lisp_readonly bit */ \
307 }, \
308 0, /* next */ \
309 0, /* uid */ \
310 0 /* free */ \
311 }, \
312 c_location, \
313 forward_type \
314 }, \
315 magicfun \
316 }; \
317 defvar_magic ((lname), &I_hate_C); \ 303 defvar_magic ((lname), &I_hate_C); \
318 } while (0)
319
320 #define DEFVAR_SYMVAL_FWD_INT(lname, c_location, forward_type, magicfun) do{ \
321 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \
322 dumpopaque (c_location, sizeof(int)); \
323 } while (0) 304 } while (0)
324 305
325 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \ 306 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \
326 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \ 307 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \
327 staticpro (c_location); \ 308 staticpro (c_location); \
333 #define DEFVAR_CONST_LISP(lname, c_location) \ 314 #define DEFVAR_CONST_LISP(lname, c_location) \
334 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0) 315 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0)
335 #define DEFVAR_SPECIFIER(lname, c_location) \ 316 #define DEFVAR_SPECIFIER(lname, c_location) \
336 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0) 317 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0)
337 #define DEFVAR_INT(lname, c_location) \ 318 #define DEFVAR_INT(lname, c_location) \
338 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0) 319 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0)
339 #define DEFVAR_CONST_INT(lname, c_location) \ 320 #define DEFVAR_CONST_INT(lname, c_location) \
340 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0) 321 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0)
341 #define DEFVAR_BOOL(lname, c_location) \ 322 #define DEFVAR_BOOL(lname, c_location) \
342 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0) 323 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0)
343 #define DEFVAR_CONST_BOOL(lname, c_location) \ 324 #define DEFVAR_CONST_BOOL(lname, c_location) \
344 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0) 325 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0)
345 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \ 326 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \
346 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun) 327 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun);
347 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \ 328 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \
348 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun) 329 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun);
349 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \ 330 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \
350 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun) 331 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun);
351 332
352 #endif /* INCLUDED_symeval_h_ */ 333 #endif /* _XEMACS_SYMEVAL_H_ */