Mercurial > hg > xemacs-beta
comparison src/symeval.h @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 1ccc32a20af4 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
1 /* Definitions of symbol-value forwarding for XEmacs Lisp interpreter. | 1 /* Definitions of symbol-value forwarding for XEmacs Lisp interpreter. |
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc. |
3 Copyright (C) 2000 Ben Wing. | |
3 | 4 |
4 This file is part of XEmacs. | 5 This file is part of XEmacs. |
5 | 6 |
6 XEmacs is free software; you can redistribute it and/or modify it | 7 XEmacs is free software; you can redistribute it and/or modify it |
7 under the terms of the GNU General Public License as published by the | 8 under the terms of the GNU General Public License as published by the |
70 }; | 71 }; |
71 | 72 |
72 struct symbol_value_magic | 73 struct symbol_value_magic |
73 { | 74 { |
74 struct lcrecord_header lcheader; | 75 struct lcrecord_header lcheader; |
76 void *value; | |
75 enum symbol_value_type type; | 77 enum symbol_value_type type; |
76 }; | 78 }; |
77 #define SYMBOL_VALUE_MAGIC_P(x) \ | 79 #define SYMBOL_VALUE_MAGIC_P(x) \ |
78 (LRECORDP (x) \ | 80 (LRECORDP (x) && \ |
79 && (XRECORD_LHEADER_IMPLEMENTATION (x)->printer \ | 81 XRECORD_LHEADER (x)->type <= lrecord_type_max_symbol_value_magic) |
80 == print_symbol_value_magic)) | |
81 #define XSYMBOL_VALUE_MAGIC_TYPE(v) \ | 82 #define XSYMBOL_VALUE_MAGIC_TYPE(v) \ |
82 (((struct symbol_value_magic *) XPNTR (v))->type) | 83 (((struct symbol_value_magic *) XPNTR (v))->type) |
83 #define XSETSYMBOL_VALUE_MAGIC(s, p) XSETOBJ (s, Lisp_Type_Record, p) | 84 #define XSETSYMBOL_VALUE_MAGIC(s, p) XSETOBJ (s, p) |
84 void print_symbol_value_magic (Lisp_Object, Lisp_Object, int); | 85 void print_symbol_value_magic (Lisp_Object, Lisp_Object, int); |
85 | 86 |
86 /********** The various different symbol-value-magic types ***********/ | 87 /********** The various different symbol-value-magic types ***********/ |
87 | 88 |
88 /* 1. symbol-value-forward */ | 89 /* 1. symbol-value-forward */ |
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_massage_name (Lisp_Object *location, const char *name); |
285 void defsymbol_nodump (Lisp_Object *location, CONST char *name); | 286 void defsymbol_massage_name_nodump (Lisp_Object *location, const char *name); |
286 | 287 void defsymbol_massage_multiword_predicate (Lisp_Object *location, |
287 void defkeyword (Lisp_Object *location, CONST char *name); | 288 const char *name); |
288 | 289 void defsymbol_massage_multiword_predicate_nodump (Lisp_Object *location, |
289 void deferror (Lisp_Object *symbol, CONST char *name, | 290 const char *name); |
290 CONST char *message, Lisp_Object inherits_from); | 291 void defsymbol (Lisp_Object *location, const char *name); |
292 void defsymbol_nodump (Lisp_Object *location, const char *name); | |
293 | |
294 #define DEFSYMBOL(name) defsymbol_massage_name (&name, #name) | |
295 #define DEFSYMBOL_NO_DUMP(name) defsymbol_massage_name_nodump (&name, #name) | |
296 #define DEFSYMBOL_MULTIWORD_PREDICATE(name) \ | |
297 defsymbol_massage_multiword_predicate (&name, #name) | |
298 #define DEFSYMBOL_MULTIWORD_PREDICATE_NO_DUMP(name) \ | |
299 defsymbol_massage_multiword_predicate_nodump (&name, #name) | |
300 | |
301 void defkeyword (Lisp_Object *location, const char *name); | |
302 void defkeyword_massage_name (Lisp_Object *location, const char *name); | |
303 #define DEFKEYWORD(name) defkeyword_massage_name (&name, #name) | |
304 | |
305 void deferror (Lisp_Object *symbol, const char *name, | |
306 const char *message, Lisp_Object inherits_from); | |
307 void deferror_massage_name (Lisp_Object *symbol, const char *name, | |
308 const char *message, Lisp_Object inherits_from); | |
309 void deferror_massage_name_and_message (Lisp_Object *symbol, const char *name, | |
310 Lisp_Object inherits_from); | |
311 #define DEFERROR(name, message, inherits_from) \ | |
312 deferror_massage_name (&name, #name, message, inherits_from) | |
313 /* In this case, the error message is the same as the name, modulo some | |
314 prettifying */ | |
315 #define DEFERROR_STANDARD(name, inherits_from) \ | |
316 deferror_massage_name_and_message (&name, #name, inherits_from) | |
291 | 317 |
292 /* Macros we use to define forwarded Lisp variables. | 318 /* Macros we use to define forwarded Lisp variables. |
293 These are used in the syms_of_FILENAME functions. */ | 319 These are used in the syms_of_FILENAME functions. */ |
294 | 320 |
295 void defvar_magic (CONST char *symbol_name, CONST struct symbol_value_forward *magic); | 321 void defvar_magic (const char *symbol_name, const struct symbol_value_forward *magic); |
296 | |
297 #define symbol_value_forward_lheader_initializer { 1, 0, 0, 0 } | |
298 | 322 |
299 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \ | 323 #define DEFVAR_SYMVAL_FWD(lname, c_location, forward_type, magicfun) do { \ |
300 static CONST_IF_NOT_DEBUG struct symbol_value_forward I_hate_C \ | 324 static const struct symbol_value_forward I_hate_C = \ |
301 = { { { symbol_value_forward_lheader_initializer, \ | 325 { /* struct symbol_value_forward */ \ |
302 (struct lcrecord_header *) (c_location), 69 }, \ | 326 { /* struct symbol_value_magic */ \ |
303 forward_type }, magicfun }; \ | 327 { /* struct lcrecord_header */ \ |
328 { /* struct lrecord_header */ \ | |
329 lrecord_type_symbol_value_forward, /* lrecord_type_index */ \ | |
330 1, /* mark bit */ \ | |
331 1, /* c_readonly bit */ \ | |
332 1 /* lisp_readonly bit */ \ | |
333 }, \ | |
334 0, /* next */ \ | |
335 0, /* uid */ \ | |
336 0 /* free */ \ | |
337 }, \ | |
338 c_location, \ | |
339 forward_type \ | |
340 }, \ | |
341 magicfun \ | |
342 }; \ | |
304 defvar_magic ((lname), &I_hate_C); \ | 343 defvar_magic ((lname), &I_hate_C); \ |
344 } while (0) | |
345 | |
346 #define DEFVAR_SYMVAL_FWD_INT(lname, c_location, forward_type, magicfun) do{ \ | |
347 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \ | |
348 dumpopaque (c_location, sizeof(int)); \ | |
305 } while (0) | 349 } while (0) |
306 | 350 |
307 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \ | 351 #define DEFVAR_SYMVAL_FWD_OBJECT(lname, c_location, forward_type, magicfun) do{ \ |
308 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \ | 352 DEFVAR_SYMVAL_FWD (lname, c_location, forward_type, magicfun); \ |
309 staticpro (c_location); \ | 353 staticpro (c_location); \ |
315 #define DEFVAR_CONST_LISP(lname, c_location) \ | 359 #define DEFVAR_CONST_LISP(lname, c_location) \ |
316 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0) | 360 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_OBJECT_FORWARD, 0) |
317 #define DEFVAR_SPECIFIER(lname, c_location) \ | 361 #define DEFVAR_SPECIFIER(lname, c_location) \ |
318 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0) | 362 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_CONST_SPECIFIER_FORWARD, 0) |
319 #define DEFVAR_INT(lname, c_location) \ | 363 #define DEFVAR_INT(lname, c_location) \ |
320 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0) | 364 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_FIXNUM_FORWARD, 0) |
321 #define DEFVAR_CONST_INT(lname, c_location) \ | 365 #define DEFVAR_CONST_INT(lname, c_location) \ |
322 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0) | 366 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_CONST_FIXNUM_FORWARD, 0) |
323 #define DEFVAR_BOOL(lname, c_location) \ | 367 #define DEFVAR_BOOL(lname, c_location) \ |
324 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0) | 368 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_BOOLEAN_FORWARD, 0) |
325 #define DEFVAR_CONST_BOOL(lname, c_location) \ | 369 #define DEFVAR_CONST_BOOL(lname, c_location) \ |
326 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0) | 370 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_CONST_BOOLEAN_FORWARD, 0) |
327 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \ | 371 #define DEFVAR_LISP_MAGIC(lname, c_location, magicfun) \ |
328 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun) | 372 DEFVAR_SYMVAL_FWD_OBJECT (lname, c_location, SYMVAL_OBJECT_FORWARD, magicfun) |
329 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \ | 373 #define DEFVAR_INT_MAGIC(lname, c_location, magicfun) \ |
330 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun) | 374 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_FIXNUM_FORWARD, magicfun) |
331 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \ | 375 #define DEFVAR_BOOL_MAGIC(lname, c_location, magicfun) \ |
332 DEFVAR_SYMVAL_FWD (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun) | 376 DEFVAR_SYMVAL_FWD_INT (lname, c_location, SYMVAL_BOOLEAN_FORWARD, magicfun) |
333 | 377 |
334 #endif /* INCLUDED_symeval_h_ */ | 378 #endif /* INCLUDED_symeval_h_ */ |