comparison src/symbols.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents aabb7f5b1c81
children a86b2b5e0111
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
61 Lisp_Object Qad_advice_info, Qad_activate; 61 Lisp_Object Qad_advice_info, Qad_activate;
62 62
63 Lisp_Object Qget_value, Qset_value, Qbound_predicate, Qmake_unbound; 63 Lisp_Object Qget_value, Qset_value, Qbound_predicate, Qmake_unbound;
64 Lisp_Object Qlocal_predicate, Qmake_local; 64 Lisp_Object Qlocal_predicate, Qmake_local;
65 65
66 Lisp_Object Qboundp, Qfboundp, Qglobally_boundp, Qmakunbound; 66 Lisp_Object Qboundp, Qglobally_boundp, Qmakunbound;
67 Lisp_Object Qsymbol_value, Qset, Qdefault_boundp, Qdefault_value; 67 Lisp_Object Qsymbol_value, Qset, Qdefault_boundp, Qdefault_value;
68 Lisp_Object Qset_default, Qsetq_default; 68 Lisp_Object Qset_default, Qsetq_default;
69 Lisp_Object Qmake_variable_buffer_local, Qmake_local_variable; 69 Lisp_Object Qmake_variable_buffer_local, Qmake_local_variable;
70 Lisp_Object Qkill_local_variable, Qkill_console_local_variable; 70 Lisp_Object Qkill_local_variable, Qkill_console_local_variable;
71 Lisp_Object Qsymbol_value_in_buffer, Qsymbol_value_in_console; 71 Lisp_Object Qsymbol_value_in_buffer, Qsymbol_value_in_console;
84 static Lisp_Object *value_slot_past_magic (Lisp_Object sym); 84 static Lisp_Object *value_slot_past_magic (Lisp_Object sym);
85 static Lisp_Object follow_varalias_pointers (Lisp_Object symbol, 85 static Lisp_Object follow_varalias_pointers (Lisp_Object symbol,
86 Lisp_Object follow_past_lisp_magic); 86 Lisp_Object follow_past_lisp_magic);
87 87
88 88
89 #ifdef LRECORD_SYMBOL
90
91 static Lisp_Object 89 static Lisp_Object
92 mark_symbol (Lisp_Object obj, void (*markobj) (Lisp_Object)) 90 mark_symbol (Lisp_Object obj)
93 { 91 {
94 struct Lisp_Symbol *sym = XSYMBOL (obj); 92 Lisp_Symbol *sym = XSYMBOL (obj);
95 Lisp_Object pname; 93 Lisp_Object pname;
96 94
97 markobj (sym->value); 95 mark_object (sym->value);
98 markobj (sym->function); 96 mark_object (sym->function);
99 /* No need to mark through ->obarray, because it only holds nil or t. */
100 /* markobj (sym->obarray);*/
101 XSETSTRING (pname, sym->name); 97 XSETSTRING (pname, sym->name);
102 markobj (pname); 98 mark_object (pname);
103 if (!symbol_next (sym)) 99 if (!symbol_next (sym))
104 return sym->plist; 100 return sym->plist;
105 else 101 else
106 { 102 {
107 markobj (sym->plist); 103 mark_object (sym->plist);
108 /* Mark the rest of the symbols in the obarray hash-chain */ 104 /* Mark the rest of the symbols in the obarray hash-chain */
109 sym = symbol_next (sym); 105 sym = symbol_next (sym);
110 XSETSYMBOL (obj, sym); 106 XSETSYMBOL (obj, sym);
111 return obj; 107 return obj;
112 } 108 }
113 } 109 }
114 110
115 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("symbol", symbol, 111 static const struct lrecord_description symbol_description[] = {
116 mark_symbol, print_symbol, 0, 0, 0, 112 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, next) },
117 struct Lisp_Symbol); 113 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, name) },
118 #endif /* LRECORD_SYMBOL */ 114 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, value) },
115 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, function) },
116 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, plist) },
117 { XD_END }
118 };
119
120 /* Symbol plists are directly accessible, so we need to protect against
121 invalid property list structure */
122
123 static Lisp_Object
124 symbol_getprop (Lisp_Object symbol, Lisp_Object property)
125 {
126 return external_plist_get (&XSYMBOL (symbol)->plist, property, 0, ERROR_ME);
127 }
128
129 static int
130 symbol_putprop (Lisp_Object symbol, Lisp_Object property, Lisp_Object value)
131 {
132 external_plist_put (&XSYMBOL (symbol)->plist, property, value, 0, ERROR_ME);
133 return 1;
134 }
135
136 static int
137 symbol_remprop (Lisp_Object symbol, Lisp_Object property)
138 {
139 return external_remprop (&XSYMBOL (symbol)->plist, property, 0, ERROR_ME);
140 }
141
142 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS ("symbol", symbol,
143 mark_symbol, print_symbol,
144 0, 0, 0, symbol_description,
145 symbol_getprop,
146 symbol_putprop,
147 symbol_remprop,
148 Fsymbol_plist,
149 Lisp_Symbol);
119 150
120 151
121 /**********************************************************************/ 152 /**********************************************************************/
122 /* Intern */ 153 /* Intern */
123 /**********************************************************************/ 154 /**********************************************************************/
144 } 175 }
145 return obarray; 176 return obarray;
146 } 177 }
147 178
148 Lisp_Object 179 Lisp_Object
149 intern (CONST char *str) 180 intern (const char *str)
150 { 181 {
151 Bytecount len = strlen (str); 182 Bytecount len = strlen (str);
152 CONST Bufbyte *buf = (CONST Bufbyte *) str; 183 const Bufbyte *buf = (const Bufbyte *) str;
153 Lisp_Object obarray = Vobarray; 184 Lisp_Object obarray = Vobarray;
154 185
155 if (!VECTORP (obarray) || XVECTOR_LENGTH (obarray) == 0) 186 if (!VECTORP (obarray) || XVECTOR_LENGTH (obarray) == 0)
156 obarray = check_obarray (obarray); 187 obarray = check_obarray (obarray);
157 188
159 Lisp_Object tem = oblookup (obarray, buf, len); 190 Lisp_Object tem = oblookup (obarray, buf, len);
160 if (SYMBOLP (tem)) 191 if (SYMBOLP (tem))
161 return tem; 192 return tem;
162 } 193 }
163 194
164 return Fintern ((purify_flag 195 return Fintern (make_string (buf, len), obarray);
165 ? make_pure_pname (buf, len, 0)
166 : make_string (buf, len)),
167 obarray);
168 } 196 }
169 197
170 DEFUN ("intern", Fintern, 1, 2, 0, /* 198 DEFUN ("intern", Fintern, 1, 2, 0, /*
171 Return the canonical symbol whose name is STRING. 199 Return the canonical symbol whose name is STRING.
172 If there is none, one is created by this function and returned. 200 If there is none, one is created by this function and returned.
173 A second optional argument specifies the obarray to use; 201 A second optional argument specifies the obarray to use;
174 it defaults to the value of `obarray'. 202 it defaults to the value of `obarray'.
175 */ 203 */
176 (string, obarray)) 204 (string, obarray))
177 { 205 {
178 Lisp_Object sym, *ptr; 206 Lisp_Object object, *ptr;
207 Lisp_Symbol *symbol;
179 Bytecount len; 208 Bytecount len;
180 209
181 if (NILP (obarray)) obarray = Vobarray; 210 if (NILP (obarray)) obarray = Vobarray;
182 obarray = check_obarray (obarray); 211 obarray = check_obarray (obarray);
183 212
184 CHECK_STRING (string); 213 CHECK_STRING (string);
185 214
186 len = XSTRING_LENGTH (string); 215 len = XSTRING_LENGTH (string);
187 sym = oblookup (obarray, XSTRING_DATA (string), len); 216 object = oblookup (obarray, XSTRING_DATA (string), len);
188 if (!INTP (sym)) 217 if (!INTP (object))
189 /* Found it */ 218 /* Found it */
190 return sym; 219 return object;
191 220
192 ptr = &XVECTOR_DATA (obarray)[XINT (sym)]; 221 ptr = &XVECTOR_DATA (obarray)[XINT (object)];
193 222
194 if (purify_flag && ! purified (string)) 223 object = Fmake_symbol (string);
195 string = make_pure_pname (XSTRING_DATA (string), len, 0); 224 symbol = XSYMBOL (object);
196 sym = Fmake_symbol (string);
197 /* FSFmacs places OBARRAY here, but it is pointless because we do
198 not mark through this slot, so it is not usable later (because
199 the obarray might have been collected). Marking through the
200 ->obarray slot is an even worse idea, because it would keep
201 obarrays from being collected because of symbols pointed to them.
202
203 NOTE: We place Qt here only if OBARRAY is actually Vobarray. It
204 is safer to do it this way, to avoid hosing with symbols within
205 pure objects. */
206 if (EQ (obarray, Vobarray))
207 XSYMBOL (sym)->obarray = Qt;
208 225
209 if (SYMBOLP (*ptr)) 226 if (SYMBOLP (*ptr))
210 symbol_next (XSYMBOL (sym)) = XSYMBOL (*ptr); 227 symbol_next (symbol) = XSYMBOL (*ptr);
211 else 228 else
212 symbol_next (XSYMBOL (sym)) = 0; 229 symbol_next (symbol) = 0;
213 *ptr = sym; 230 *ptr = object;
214 return sym; 231
232 if (string_byte (symbol_name (symbol), 0) == ':' && EQ (obarray, Vobarray))
233 {
234 /* The LISP way is to put keywords in their own package, but we
235 don't have packages, so we do something simpler. Someday,
236 maybe we'll have packages and then this will be reworked.
237 --Stig. */
238 symbol_value (symbol) = object;
239 }
240
241 return object;
215 } 242 }
216 243
217 DEFUN ("intern-soft", Fintern_soft, 1, 2, 0, /* 244 DEFUN ("intern-soft", Fintern_soft, 1, 2, 0, /*
218 Return the canonical symbol whose name is STRING, or nil if none exists. 245 Return the canonical symbol named NAME, or nil if none exists.
246 NAME may be a string or a symbol. If it is a symbol, that exact
247 symbol is searched for.
219 A second optional argument specifies the obarray to use; 248 A second optional argument specifies the obarray to use;
220 it defaults to the value of `obarray'. 249 it defaults to the value of `obarray'.
221 */ 250 */
222 (string, obarray)) 251 (name, obarray))
223 { 252 {
253 /* #### Bug! (intern-soft "nil") returns nil. Perhaps we should
254 add a DEFAULT-IF-NOT-FOUND arg, like in get. */
224 Lisp_Object tem; 255 Lisp_Object tem;
256 Lisp_String *string;
225 257
226 if (NILP (obarray)) obarray = Vobarray; 258 if (NILP (obarray)) obarray = Vobarray;
227 obarray = check_obarray (obarray); 259 obarray = check_obarray (obarray);
228 260
229 CHECK_STRING (string); 261 if (!SYMBOLP (name))
230 262 {
231 tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); 263 CHECK_STRING (name);
232 return !INTP (tem) ? tem : Qnil; 264 string = XSTRING (name);
265 }
266 else
267 string = symbol_name (XSYMBOL (name));
268
269 tem = oblookup (obarray, string_data (string), string_length (string));
270 if (INTP (tem) || (SYMBOLP (name) && !EQ (name, tem)))
271 return Qnil;
272 else
273 return tem;
233 } 274 }
234 275
235 DEFUN ("unintern", Funintern, 1, 2, 0, /* 276 DEFUN ("unintern", Funintern, 1, 2, 0, /*
236 Delete the symbol named NAME, if any, from OBARRAY. 277 Delete the symbol named NAME, if any, from OBARRAY.
237 The value is t if a symbol was found and deleted, nil otherwise. 278 The value is t if a symbol was found and deleted, nil otherwise.
239 is deleted, if it belongs to OBARRAY--no other symbol is deleted. 280 is deleted, if it belongs to OBARRAY--no other symbol is deleted.
240 OBARRAY defaults to the value of the variable `obarray' 281 OBARRAY defaults to the value of the variable `obarray'
241 */ 282 */
242 (name, obarray)) 283 (name, obarray))
243 { 284 {
244 Lisp_Object string, tem; 285 Lisp_Object tem;
286 Lisp_String *string;
245 int hash; 287 int hash;
246 288
247 if (NILP (obarray)) obarray = Vobarray; 289 if (NILP (obarray)) obarray = Vobarray;
248 obarray = check_obarray (obarray); 290 obarray = check_obarray (obarray);
249 291
250 if (SYMBOLP (name)) 292 if (SYMBOLP (name))
251 XSETSTRING (string, XSYMBOL (name)->name); 293 string = symbol_name (XSYMBOL (name));
252 else 294 else
253 { 295 {
254 CHECK_STRING (name); 296 CHECK_STRING (name);
255 string = name; 297 string = XSTRING (name);
256 } 298 }
257 299
258 tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); 300 tem = oblookup (obarray, string_data (string), string_length (string));
259 if (INTP (tem)) 301 if (INTP (tem))
260 return Qnil; 302 return Qnil;
261 /* If arg was a symbol, don't delete anything but that symbol itself. */ 303 /* If arg was a symbol, don't delete anything but that symbol itself. */
262 if (SYMBOLP (name) && !EQ (name, tem)) 304 if (SYMBOLP (name) && !EQ (name, tem))
263 return Qnil; 305 return Qnil;
285 XSYMBOL (tail)->next = XSYMBOL (following)->next; 327 XSYMBOL (tail)->next = XSYMBOL (following)->next;
286 break; 328 break;
287 } 329 }
288 } 330 }
289 } 331 }
290 XSYMBOL (tem)->obarray = Qnil;
291 return Qt; 332 return Qt;
292 } 333 }
293 334
294 /* Return the symbol in OBARRAY whose names matches the string 335 /* Return the symbol in OBARRAY whose names matches the string
295 of SIZE characters at PTR. If there is no such symbol in OBARRAY, 336 of SIZE characters at PTR. If there is no such symbol in OBARRAY,
296 return the index into OBARRAY that the string hashes to. 337 return the index into OBARRAY that the string hashes to.
297 338
298 Also store the bucket number in oblookup_last_bucket_number. */ 339 Also store the bucket number in oblookup_last_bucket_number. */
299 340
300 Lisp_Object 341 Lisp_Object
301 oblookup (Lisp_Object obarray, CONST Bufbyte *ptr, Bytecount size) 342 oblookup (Lisp_Object obarray, const Bufbyte *ptr, Bytecount size)
302 { 343 {
303 int hash, obsize; 344 int hash, obsize;
304 struct Lisp_Symbol *tail; 345 Lisp_Symbol *tail;
305 Lisp_Object bucket; 346 Lisp_Object bucket;
306 347
307 if (!VECTORP (obarray) || 348 if (!VECTORP (obarray) ||
308 (obsize = XVECTOR_LENGTH (obarray)) == 0) 349 (obsize = XVECTOR_LENGTH (obarray)) == 0)
309 { 350 {
310 obarray = check_obarray (obarray); 351 obarray = check_obarray (obarray);
311 obsize = XVECTOR_LENGTH (obarray); 352 obsize = XVECTOR_LENGTH (obarray);
312 } 353 }
313 #if 0 /* FSFmacs */
314 /* #### Huh? */
315 /* This is sometimes needed in the middle of GC. */
316 obsize &= ~ARRAY_MARK_FLAG;
317 #endif
318 hash = hash_string (ptr, size) % obsize; 354 hash = hash_string (ptr, size) % obsize;
319 oblookup_last_bucket_number = hash; 355 oblookup_last_bucket_number = hash;
320 bucket = XVECTOR_DATA (obarray)[hash]; 356 bucket = XVECTOR_DATA (obarray)[hash];
321 if (ZEROP (bucket)) 357 if (ZEROP (bucket))
322 ; 358 ;
338 return make_int (hash); 374 return make_int (hash);
339 } 375 }
340 376
341 #if 0 /* Emacs 19.34 */ 377 #if 0 /* Emacs 19.34 */
342 int 378 int
343 hash_string (CONST Bufbyte *ptr, Bytecount len) 379 hash_string (const Bufbyte *ptr, Bytecount len)
344 { 380 {
345 CONST Bufbyte *p = ptr; 381 const Bufbyte *p = ptr;
346 CONST Bufbyte *end = p + len; 382 const Bufbyte *end = p + len;
347 Bufbyte c; 383 Bufbyte c;
348 int hash = 0; 384 int hash = 0;
349 385
350 while (p != end) 386 while (p != end)
351 { 387 {
357 } 393 }
358 #endif 394 #endif
359 395
360 /* derived from hashpjw, Dragon Book P436. */ 396 /* derived from hashpjw, Dragon Book P436. */
361 int 397 int
362 hash_string (CONST Bufbyte *ptr, Bytecount len) 398 hash_string (const Bufbyte *ptr, Bytecount len)
363 { 399 {
364 int hash = 0; 400 int hash = 0;
365 401
366 while (len-- > 0) 402 while (len-- > 0)
367 { 403 {
387 { 423 {
388 Lisp_Object tail = XVECTOR_DATA (obarray)[i]; 424 Lisp_Object tail = XVECTOR_DATA (obarray)[i];
389 if (SYMBOLP (tail)) 425 if (SYMBOLP (tail))
390 while (1) 426 while (1)
391 { 427 {
392 struct Lisp_Symbol *next; 428 Lisp_Symbol *next;
393 if ((*fn) (tail, arg)) 429 if ((*fn) (tail, arg))
394 return; 430 return;
395 next = symbol_next (XSYMBOL (tail)); 431 next = symbol_next (XSYMBOL (tail));
396 if (!next) 432 if (!next)
397 break; 433 break;
556 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SPECIFIER_FORWARD) 592 XSYMBOL_VALUE_MAGIC_TYPE (val) == SYMVAL_CONST_SPECIFIER_FORWARD)
557 signal_simple_error ("Use `set-specifier' to change a specifier's value", 593 signal_simple_error ("Use `set-specifier' to change a specifier's value",
558 sym); 594 sym);
559 595
560 if (symbol_is_constant (sym, val) 596 if (symbol_is_constant (sym, val)
561 || (SYMBOL_IS_KEYWORD (sym) && !EQ (newval, sym) 597 || (SYMBOL_IS_KEYWORD (sym) && !EQ (newval, sym)))
562 && !NILP (XSYMBOL (sym)->obarray)))
563 signal_error (Qsetting_constant, 598 signal_error (Qsetting_constant,
564 UNBOUNDP (newval) ? list1 (sym) : list2 (sym, newval)); 599 UNBOUNDP (newval) ? list1 (sym) : list2 (sym, newval));
565 } 600 }
566 601
567 /* Verify that it's ok to make SYM buffer-local. This rejects 602 /* Verify that it's ok to make SYM buffer-local. This rejects
764 SYMVAL_BOOLEAN_FORWARD, respectively, except that the value cannot 799 SYMVAL_BOOLEAN_FORWARD, respectively, except that the value cannot
765 be changed. 800 be changed.
766 801
767 SYMVAL_CONST_SPECIFIER_FORWARD: 802 SYMVAL_CONST_SPECIFIER_FORWARD:
768 (declare with DEFVAR_SPECIFIER) 803 (declare with DEFVAR_SPECIFIER)
769 Exactly like SYMVAL_CONST_OBJECT_FORWARD except that error message 804 Exactly like SYMVAL_CONST_OBJECT_FORWARD except that the error
770 you get when attempting to set the value says to use 805 message you get when attempting to set the value says to use
771 `set-specifier' instead. 806 `set-specifier' instead.
772 807
773 SYMVAL_CURRENT_BUFFER_FORWARD: 808 SYMVAL_CURRENT_BUFFER_FORWARD:
774 (declare with DEFVAR_BUFFER_LOCAL) 809 (declare with DEFVAR_BUFFER_LOCAL)
775 This is used for built-in buffer-local variables -- i.e. 810 This is used for built-in buffer-local variables -- i.e.
890 low-level functions below do not accept them; you need 925 low-level functions below do not accept them; you need
891 to call follow_varalias_pointers to get the actual 926 to call follow_varalias_pointers to get the actual
892 symbol to operate on. */ 927 symbol to operate on. */
893 928
894 static Lisp_Object 929 static Lisp_Object
895 mark_symbol_value_buffer_local (Lisp_Object obj, 930 mark_symbol_value_buffer_local (Lisp_Object obj)
896 void (*markobj) (Lisp_Object))
897 { 931 {
898 struct symbol_value_buffer_local *bfwd; 932 struct symbol_value_buffer_local *bfwd;
899 933
900 #ifdef ERROR_CHECK_TYPECHECK 934 #ifdef ERROR_CHECK_TYPECHECK
901 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_BUFFER_LOCAL || 935 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_BUFFER_LOCAL ||
902 XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_SOME_BUFFER_LOCAL); 936 XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_SOME_BUFFER_LOCAL);
903 #endif 937 #endif
904 938
905 bfwd = XSYMBOL_VALUE_BUFFER_LOCAL (obj); 939 bfwd = XSYMBOL_VALUE_BUFFER_LOCAL (obj);
906 markobj (bfwd->default_value); 940 mark_object (bfwd->default_value);
907 markobj (bfwd->current_value); 941 mark_object (bfwd->current_value);
908 markobj (bfwd->current_buffer); 942 mark_object (bfwd->current_buffer);
909 return bfwd->current_alist_element; 943 return bfwd->current_alist_element;
910 } 944 }
911 945
912 static Lisp_Object 946 static Lisp_Object
913 mark_symbol_value_lisp_magic (Lisp_Object obj, 947 mark_symbol_value_lisp_magic (Lisp_Object obj)
914 void (*markobj) (Lisp_Object))
915 { 948 {
916 struct symbol_value_lisp_magic *bfwd; 949 struct symbol_value_lisp_magic *bfwd;
917 int i; 950 int i;
918 951
919 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_LISP_MAGIC); 952 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_LISP_MAGIC);
920 953
921 bfwd = XSYMBOL_VALUE_LISP_MAGIC (obj); 954 bfwd = XSYMBOL_VALUE_LISP_MAGIC (obj);
922 for (i = 0; i < MAGIC_HANDLER_MAX; i++) 955 for (i = 0; i < MAGIC_HANDLER_MAX; i++)
923 { 956 {
924 markobj (bfwd->handler[i]); 957 mark_object (bfwd->handler[i]);
925 markobj (bfwd->harg[i]); 958 mark_object (bfwd->harg[i]);
926 } 959 }
927 return bfwd->shadowed; 960 return bfwd->shadowed;
928 } 961 }
929 962
930 static Lisp_Object 963 static Lisp_Object
931 mark_symbol_value_varalias (Lisp_Object obj, 964 mark_symbol_value_varalias (Lisp_Object obj)
932 void (*markobj) (Lisp_Object))
933 { 965 {
934 struct symbol_value_varalias *bfwd; 966 struct symbol_value_varalias *bfwd;
935 967
936 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_VARALIAS); 968 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_VARALIAS);
937 969
938 bfwd = XSYMBOL_VALUE_VARALIAS (obj); 970 bfwd = XSYMBOL_VALUE_VARALIAS (obj);
939 markobj (bfwd->shadowed); 971 mark_object (bfwd->shadowed);
940 return bfwd->aliasee; 972 return bfwd->aliasee;
941 } 973 }
942 974
943 /* Should never, ever be called. (except by an external debugger) */ 975 /* Should never, ever be called. (except by an external debugger) */
944 void 976 void
951 XSYMBOL_VALUE_MAGIC_TYPE (obj), 983 XSYMBOL_VALUE_MAGIC_TYPE (obj),
952 (long) XPNTR (obj)); 984 (long) XPNTR (obj));
953 write_c_string (buf, printcharfun); 985 write_c_string (buf, printcharfun);
954 } 986 }
955 987
988 static const struct lrecord_description symbol_value_forward_description[] = {
989 { XD_END }
990 };
991
992 static const struct lrecord_description symbol_value_buffer_local_description[] = {
993 { XD_LISP_OBJECT, offsetof (struct symbol_value_buffer_local, default_value) },
994 { XD_LO_RESET_NIL, offsetof (struct symbol_value_buffer_local, current_value), 3 },
995 { XD_END }
996 };
997
998 static const struct lrecord_description symbol_value_lisp_magic_description[] = {
999 { XD_LISP_OBJECT_ARRAY, offsetof (struct symbol_value_lisp_magic, handler), 2*MAGIC_HANDLER_MAX+1 },
1000 { XD_END }
1001 };
1002
1003 static const struct lrecord_description symbol_value_varalias_description[] = {
1004 { XD_LISP_OBJECT, offsetof (struct symbol_value_varalias, aliasee) },
1005 { XD_LISP_OBJECT, offsetof (struct symbol_value_varalias, shadowed) },
1006 { XD_END }
1007 };
1008
956 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-forward", 1009 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-forward",
957 symbol_value_forward, 1010 symbol_value_forward,
958 this_one_is_unmarkable, 1011 this_one_is_unmarkable,
959 print_symbol_value_magic, 0, 0, 0, 1012 print_symbol_value_magic, 0, 0, 0,
1013 symbol_value_forward_description,
960 struct symbol_value_forward); 1014 struct symbol_value_forward);
961 1015
962 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-buffer-local", 1016 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-buffer-local",
963 symbol_value_buffer_local, 1017 symbol_value_buffer_local,
964 mark_symbol_value_buffer_local, 1018 mark_symbol_value_buffer_local,
965 print_symbol_value_magic, 0, 0, 0, 1019 print_symbol_value_magic, 0, 0, 0,
1020 symbol_value_buffer_local_description,
966 struct symbol_value_buffer_local); 1021 struct symbol_value_buffer_local);
967 1022
968 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-lisp-magic", 1023 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-lisp-magic",
969 symbol_value_lisp_magic, 1024 symbol_value_lisp_magic,
970 mark_symbol_value_lisp_magic, 1025 mark_symbol_value_lisp_magic,
971 print_symbol_value_magic, 0, 0, 0, 1026 print_symbol_value_magic, 0, 0, 0,
1027 symbol_value_lisp_magic_description,
972 struct symbol_value_lisp_magic); 1028 struct symbol_value_lisp_magic);
973 1029
974 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-varalias", 1030 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-varalias",
975 symbol_value_varalias, 1031 symbol_value_varalias,
976 mark_symbol_value_varalias, 1032 mark_symbol_value_varalias,
977 print_symbol_value_magic, 0, 0, 0, 1033 print_symbol_value_magic, 0, 0, 0,
1034 symbol_value_varalias_description,
978 struct symbol_value_varalias); 1035 struct symbol_value_varalias);
979 1036
980 1037
981 /* Getting and setting values of symbols */ 1038 /* Getting and setting values of symbols */
982 1039
997 1054
998 static Lisp_Object 1055 static Lisp_Object
999 do_symval_forwarding (Lisp_Object valcontents, struct buffer *buffer, 1056 do_symval_forwarding (Lisp_Object valcontents, struct buffer *buffer,
1000 struct console *console) 1057 struct console *console)
1001 { 1058 {
1002 CONST struct symbol_value_forward *fwd; 1059 const struct symbol_value_forward *fwd;
1003 1060
1004 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) 1061 if (!SYMBOL_VALUE_MAGIC_P (valcontents))
1005 return valcontents; 1062 return valcontents;
1006 1063
1007 fwd = XSYMBOL_VALUE_FORWARD (valcontents); 1064 fwd = XSYMBOL_VALUE_FORWARD (valcontents);
1065 */ 1122 */
1066 /* At this point, the value cell may not contain a symbol-value-varalias 1123 /* At this point, the value cell may not contain a symbol-value-varalias
1067 or symbol-value-buffer-local, and if there's a handler, we should 1124 or symbol-value-buffer-local, and if there's a handler, we should
1068 have already called it. */ 1125 have already called it. */
1069 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); 1126 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt);
1070 CONST struct symbol_value_forward *fwd 1127 const struct symbol_value_forward *fwd
1071 = XSYMBOL_VALUE_FORWARD (valcontents); 1128 = XSYMBOL_VALUE_FORWARD (valcontents);
1072 int offset = ((char *) symbol_value_forward_forward (fwd) 1129 int offset = ((char *) symbol_value_forward_forward (fwd)
1073 - (char *) &buffer_local_flags); 1130 - (char *) &buffer_local_flags);
1074 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); 1131 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd)));
1075 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, 1132 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object,
1107 */ 1164 */
1108 /* At this point, the value cell may not contain a symbol-value-varalias 1165 /* At this point, the value cell may not contain a symbol-value-varalias
1109 or symbol-value-buffer-local, and if there's a handler, we should 1166 or symbol-value-buffer-local, and if there's a handler, we should
1110 have already called it. */ 1167 have already called it. */
1111 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); 1168 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt);
1112 CONST struct symbol_value_forward *fwd 1169 const struct symbol_value_forward *fwd
1113 = XSYMBOL_VALUE_FORWARD (valcontents); 1170 = XSYMBOL_VALUE_FORWARD (valcontents);
1114 int offset = ((char *) symbol_value_forward_forward (fwd) 1171 int offset = ((char *) symbol_value_forward_forward (fwd)
1115 - (char *) &console_local_flags); 1172 - (char *) &console_local_flags);
1116 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); 1173 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd)));
1117 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, 1174 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object,
1173 || !SYMBOL_VALUE_MAGIC_P (*store_pointer)); 1230 || !SYMBOL_VALUE_MAGIC_P (*store_pointer));
1174 *store_pointer = newval; 1231 *store_pointer = newval;
1175 } 1232 }
1176 else 1233 else
1177 { 1234 {
1178 CONST struct symbol_value_forward *fwd = XSYMBOL_VALUE_FORWARD (ovalue); 1235 const struct symbol_value_forward *fwd = XSYMBOL_VALUE_FORWARD (ovalue);
1179 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, 1236 int (*magicfun) (Lisp_Object simm, Lisp_Object *val,
1180 Lisp_Object in_object, int flags) 1237 Lisp_Object in_object, int flags)
1181 = symbol_value_forward_magicfun (fwd); 1238 = symbol_value_forward_magicfun (fwd);
1182 1239
1183 switch (XSYMBOL_VALUE_MAGIC_TYPE (ovalue)) 1240 switch (XSYMBOL_VALUE_MAGIC_TYPE (ovalue))
1191 1248
1192 case SYMVAL_BOOLEAN_FORWARD: 1249 case SYMVAL_BOOLEAN_FORWARD:
1193 if (magicfun) 1250 if (magicfun)
1194 magicfun (sym, &newval, Qnil, 0); 1251 magicfun (sym, &newval, Qnil, 0);
1195 *((int *) symbol_value_forward_forward (fwd)) 1252 *((int *) symbol_value_forward_forward (fwd))
1196 = ((NILP (newval)) ? 0 : 1); 1253 = !NILP (newval);
1197 return; 1254 return;
1198 1255
1199 case SYMVAL_OBJECT_FORWARD: 1256 case SYMVAL_OBJECT_FORWARD:
1200 if (magicfun) 1257 if (magicfun)
1201 magicfun (sym, &newval, Qnil, 0); 1258 magicfun (sym, &newval, Qnil, 0);
1524 else 1581 else
1525 { 1582 {
1526 /* This can also get called while we're preparing to shutdown. 1583 /* This can also get called while we're preparing to shutdown.
1527 #### What should really happen in that case? Should we 1584 #### What should really happen in that case? Should we
1528 actually fix things so we can't get here in that case? */ 1585 actually fix things so we can't get here in that case? */
1586 #ifndef PDUMP
1529 assert (!initialized || preparing_for_armageddon); 1587 assert (!initialized || preparing_for_armageddon);
1588 #endif
1530 con = 0; 1589 con = 0;
1531 } 1590 }
1532 1591
1533 return find_symbol_value_1 (sym, current_buffer, con, 1, Qnil, 1); 1592 return find_symbol_value_1 (sym, current_buffer, con, 1, Qnil, 1);
1534 } 1593 }
1560 else 1619 else
1561 { 1620 {
1562 /* This can also get called while we're preparing to shutdown. 1621 /* This can also get called while we're preparing to shutdown.
1563 #### What should really happen in that case? Should we 1622 #### What should really happen in that case? Should we
1564 actually fix things so we can't get here in that case? */ 1623 actually fix things so we can't get here in that case? */
1624 #ifndef PDUMP
1565 assert (!initialized || preparing_for_armageddon); 1625 assert (!initialized || preparing_for_armageddon);
1626 #endif
1566 con = 0; 1627 con = 0;
1567 } 1628 }
1568 1629
1569 return find_symbol_value_1 (sym, current_buffer, con, 1, 1630 return find_symbol_value_1 (sym, current_buffer, con, 1,
1570 find_it_p ? symbol_cons : Qnil, 1631 find_it_p ? symbol_cons : Qnil,
1588 Set SYMBOL's value to NEWVAL, and return NEWVAL. 1649 Set SYMBOL's value to NEWVAL, and return NEWVAL.
1589 */ 1650 */
1590 (symbol, newval)) 1651 (symbol, newval))
1591 { 1652 {
1592 REGISTER Lisp_Object valcontents; 1653 REGISTER Lisp_Object valcontents;
1593 struct Lisp_Symbol *sym; 1654 Lisp_Symbol *sym;
1594 /* remember, we're called by Fmakunbound() as well */ 1655 /* remember, we're called by Fmakunbound() as well */
1595 1656
1596 CHECK_SYMBOL (symbol); 1657 CHECK_SYMBOL (symbol);
1597 1658
1598 retry: 1659 retry:
1612 } 1673 }
1613 1674
1614 reject_constant_symbols (symbol, newval, 0, 1675 reject_constant_symbols (symbol, newval, 0,
1615 UNBOUNDP (newval) ? Qmakunbound : Qset); 1676 UNBOUNDP (newval) ? Qmakunbound : Qset);
1616 1677
1617 retry_2:
1618
1619 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) 1678 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents))
1620 { 1679 {
1621 case SYMVAL_LISP_MAGIC: 1680 case SYMVAL_LISP_MAGIC:
1622 { 1681 {
1623 Lisp_Object retval;
1624
1625 if (UNBOUNDP (newval)) 1682 if (UNBOUNDP (newval))
1626 retval = maybe_call_magic_handler (symbol, Qmakunbound, 0); 1683 {
1684 maybe_call_magic_handler (symbol, Qmakunbound, 0);
1685 return XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed = Qunbound;
1686 }
1627 else 1687 else
1628 retval = maybe_call_magic_handler (symbol, Qset, 1, newval); 1688 {
1629 if (!UNBOUNDP (retval)) 1689 maybe_call_magic_handler (symbol, Qset, 1, newval);
1630 return newval; 1690 return XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed = newval;
1631 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; 1691 }
1632 /* semi-change-o */
1633 goto retry_2;
1634 } 1692 }
1635 1693
1636 case SYMVAL_VARALIAS: 1694 case SYMVAL_VARALIAS:
1637 symbol = follow_varalias_pointers (symbol, 1695 symbol = follow_varalias_pointers (symbol,
1638 UNBOUNDP (newval) 1696 UNBOUNDP (newval)
1652 1710
1653 /* case SYMVAL_UNBOUND_MARKER: break; */ 1711 /* case SYMVAL_UNBOUND_MARKER: break; */
1654 1712
1655 case SYMVAL_CURRENT_BUFFER_FORWARD: 1713 case SYMVAL_CURRENT_BUFFER_FORWARD:
1656 { 1714 {
1657 CONST struct symbol_value_forward *fwd 1715 const struct symbol_value_forward *fwd
1658 = XSYMBOL_VALUE_FORWARD (valcontents); 1716 = XSYMBOL_VALUE_FORWARD (valcontents);
1659 int mask = XINT (*((Lisp_Object *) 1717 int mask = XINT (*((Lisp_Object *)
1660 symbol_value_forward_forward (fwd))); 1718 symbol_value_forward_forward (fwd)));
1661 if (mask > 0) 1719 if (mask > 0)
1662 /* Setting this variable makes it buffer-local */ 1720 /* Setting this variable makes it buffer-local */
1664 break; 1722 break;
1665 } 1723 }
1666 1724
1667 case SYMVAL_SELECTED_CONSOLE_FORWARD: 1725 case SYMVAL_SELECTED_CONSOLE_FORWARD:
1668 { 1726 {
1669 CONST struct symbol_value_forward *fwd 1727 const struct symbol_value_forward *fwd
1670 = XSYMBOL_VALUE_FORWARD (valcontents); 1728 = XSYMBOL_VALUE_FORWARD (valcontents);
1671 int mask = XINT (*((Lisp_Object *) 1729 int mask = XINT (*((Lisp_Object *)
1672 symbol_value_forward_forward (fwd))); 1730 symbol_value_forward_forward (fwd)));
1673 if (mask > 0) 1731 if (mask > 0)
1674 /* Setting this variable makes it console-local */ 1732 /* Setting this variable makes it console-local */
1802 case SYMVAL_UNBOUND_MARKER: 1860 case SYMVAL_UNBOUND_MARKER:
1803 return valcontents; 1861 return valcontents;
1804 1862
1805 case SYMVAL_CURRENT_BUFFER_FORWARD: 1863 case SYMVAL_CURRENT_BUFFER_FORWARD:
1806 { 1864 {
1807 CONST struct symbol_value_forward *fwd 1865 const struct symbol_value_forward *fwd
1808 = XSYMBOL_VALUE_FORWARD (valcontents); 1866 = XSYMBOL_VALUE_FORWARD (valcontents);
1809 return (*((Lisp_Object *)((char *) XBUFFER (Vbuffer_defaults) 1867 return (*((Lisp_Object *)((char *) XBUFFER (Vbuffer_defaults)
1810 + ((char *)symbol_value_forward_forward (fwd) 1868 + ((char *)symbol_value_forward_forward (fwd)
1811 - (char *)&buffer_local_flags)))); 1869 - (char *)&buffer_local_flags))));
1812 } 1870 }
1813 1871
1814 case SYMVAL_SELECTED_CONSOLE_FORWARD: 1872 case SYMVAL_SELECTED_CONSOLE_FORWARD:
1815 { 1873 {
1816 CONST struct symbol_value_forward *fwd 1874 const struct symbol_value_forward *fwd
1817 = XSYMBOL_VALUE_FORWARD (valcontents); 1875 = XSYMBOL_VALUE_FORWARD (valcontents);
1818 return (*((Lisp_Object *)((char *) XCONSOLE (Vconsole_defaults) 1876 return (*((Lisp_Object *)((char *) XCONSOLE (Vconsole_defaults)
1819 + ((char *)symbol_value_forward_forward (fwd) 1877 + ((char *)symbol_value_forward_forward (fwd)
1820 - (char *)&console_local_flags)))); 1878 - (char *)&console_local_flags))));
1821 } 1879 }
2033 } 2091 }
2034 2092
2035 { 2093 {
2036 struct symbol_value_buffer_local *bfwd 2094 struct symbol_value_buffer_local *bfwd
2037 = alloc_lcrecord_type (struct symbol_value_buffer_local, 2095 = alloc_lcrecord_type (struct symbol_value_buffer_local,
2038 lrecord_symbol_value_buffer_local); 2096 &lrecord_symbol_value_buffer_local);
2039 Lisp_Object foo; 2097 Lisp_Object foo;
2040 bfwd->magic.type = SYMVAL_BUFFER_LOCAL; 2098 bfwd->magic.type = SYMVAL_BUFFER_LOCAL;
2041 2099
2042 bfwd->default_value = find_symbol_value (variable); 2100 bfwd->default_value = find_symbol_value (variable);
2043 bfwd->current_value = valcontents; 2101 bfwd->current_value = valcontents;
2141 } 2199 }
2142 } 2200 }
2143 2201
2144 /* Make sure variable is set up to hold per-buffer values */ 2202 /* Make sure variable is set up to hold per-buffer values */
2145 bfwd = alloc_lcrecord_type (struct symbol_value_buffer_local, 2203 bfwd = alloc_lcrecord_type (struct symbol_value_buffer_local,
2146 lrecord_symbol_value_buffer_local); 2204 &lrecord_symbol_value_buffer_local);
2147 bfwd->magic.type = SYMVAL_SOME_BUFFER_LOCAL; 2205 bfwd->magic.type = SYMVAL_SOME_BUFFER_LOCAL;
2148 2206
2149 bfwd->current_buffer = Qnil; 2207 bfwd->current_buffer = Qnil;
2150 bfwd->current_alist_element = Qnil; 2208 bfwd->current_alist_element = Qnil;
2151 bfwd->current_value = valcontents; 2209 bfwd->current_value = valcontents;
2251 /* presto change-o! */ 2309 /* presto change-o! */
2252 goto retry; 2310 goto retry;
2253 2311
2254 case SYMVAL_CURRENT_BUFFER_FORWARD: 2312 case SYMVAL_CURRENT_BUFFER_FORWARD:
2255 { 2313 {
2256 CONST struct symbol_value_forward *fwd 2314 const struct symbol_value_forward *fwd
2257 = XSYMBOL_VALUE_FORWARD (valcontents); 2315 = XSYMBOL_VALUE_FORWARD (valcontents);
2258 int offset = ((char *) symbol_value_forward_forward (fwd) 2316 int offset = ((char *) symbol_value_forward_forward (fwd)
2259 - (char *) &buffer_local_flags); 2317 - (char *) &buffer_local_flags);
2260 int mask = 2318 int mask =
2261 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); 2319 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd)));
2345 /* presto change-o! */ 2403 /* presto change-o! */
2346 goto retry; 2404 goto retry;
2347 2405
2348 case SYMVAL_SELECTED_CONSOLE_FORWARD: 2406 case SYMVAL_SELECTED_CONSOLE_FORWARD:
2349 { 2407 {
2350 CONST struct symbol_value_forward *fwd 2408 const struct symbol_value_forward *fwd
2351 = XSYMBOL_VALUE_FORWARD (valcontents); 2409 = XSYMBOL_VALUE_FORWARD (valcontents);
2352 int offset = ((char *) symbol_value_forward_forward (fwd) 2410 int offset = ((char *) symbol_value_forward_forward (fwd)
2353 - (char *) &console_local_flags); 2411 - (char *) &console_local_flags);
2354 int mask = 2412 int mask =
2355 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); 2413 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd)));
2404 /* presto change-o! */ 2462 /* presto change-o! */
2405 goto retry; 2463 goto retry;
2406 2464
2407 case SYMVAL_CURRENT_BUFFER_FORWARD: 2465 case SYMVAL_CURRENT_BUFFER_FORWARD:
2408 { 2466 {
2409 CONST struct symbol_value_forward *fwd 2467 const struct symbol_value_forward *fwd
2410 = XSYMBOL_VALUE_FORWARD (valcontents); 2468 = XSYMBOL_VALUE_FORWARD (valcontents);
2411 int mask = XINT (*((Lisp_Object *) 2469 int mask = XINT (*((Lisp_Object *)
2412 symbol_value_forward_forward (fwd))); 2470 symbol_value_forward_forward (fwd)));
2413 if ((mask <= 0) || (buffer && (buffer->local_var_flags & mask))) 2471 if ((mask <= 0) || (buffer && (buffer->local_var_flags & mask)))
2414 /* Already buffer-local */ 2472 /* Already buffer-local */
2814 int i; 2872 int i;
2815 enum lisp_magic_handler htype; 2873 enum lisp_magic_handler htype;
2816 Lisp_Object legerdemain; 2874 Lisp_Object legerdemain;
2817 struct symbol_value_lisp_magic *bfwd; 2875 struct symbol_value_lisp_magic *bfwd;
2818 2876
2819 assert (nargs >= 0 && nargs < 20); 2877 assert (nargs >= 0 && nargs < countof (args));
2820 legerdemain = XSYMBOL (sym)->value; 2878 legerdemain = XSYMBOL (sym)->value;
2821 assert (SYMBOL_VALUE_LISP_MAGIC_P (legerdemain)); 2879 assert (SYMBOL_VALUE_LISP_MAGIC_P (legerdemain));
2822 bfwd = XSYMBOL_VALUE_LISP_MAGIC (legerdemain); 2880 bfwd = XSYMBOL_VALUE_LISP_MAGIC (legerdemain);
2823 2881
2824 va_start (vargs, nargs); 2882 va_start (vargs, nargs);
2861 htype = decode_magic_handler_type (handler_type); 2919 htype = decode_magic_handler_type (handler_type);
2862 valcontents = XSYMBOL (variable)->value; 2920 valcontents = XSYMBOL (variable)->value;
2863 if (!SYMBOL_VALUE_LISP_MAGIC_P (valcontents)) 2921 if (!SYMBOL_VALUE_LISP_MAGIC_P (valcontents))
2864 { 2922 {
2865 bfwd = alloc_lcrecord_type (struct symbol_value_lisp_magic, 2923 bfwd = alloc_lcrecord_type (struct symbol_value_lisp_magic,
2866 lrecord_symbol_value_lisp_magic); 2924 &lrecord_symbol_value_lisp_magic);
2867 bfwd->magic.type = SYMVAL_LISP_MAGIC; 2925 bfwd->magic.type = SYMVAL_LISP_MAGIC;
2868 for (i = 0; i < MAGIC_HANDLER_MAX; i++) 2926 for (i = 0; i < MAGIC_HANDLER_MAX; i++)
2869 { 2927 {
2870 bfwd->handler[i] = Qnil; 2928 bfwd->handler[i] = Qnil;
2871 bfwd->harg[i] = Qnil; 2929 bfwd->harg[i] = Qnil;
2997 && !UNBOUNDP (valcontents)) 3055 && !UNBOUNDP (valcontents))
2998 signal_simple_error ("Variable is magic and cannot be aliased", variable); 3056 signal_simple_error ("Variable is magic and cannot be aliased", variable);
2999 reject_constant_symbols (variable, Qunbound, 0, Qt); 3057 reject_constant_symbols (variable, Qunbound, 0, Qt);
3000 3058
3001 bfwd = alloc_lcrecord_type (struct symbol_value_varalias, 3059 bfwd = alloc_lcrecord_type (struct symbol_value_varalias,
3002 lrecord_symbol_value_varalias); 3060 &lrecord_symbol_value_varalias);
3003 bfwd->magic.type = SYMVAL_VARALIAS; 3061 bfwd->magic.type = SYMVAL_VARALIAS;
3004 bfwd->aliasee = alias; 3062 bfwd->aliasee = alias;
3005 bfwd->shadowed = valcontents; 3063 bfwd->shadowed = valcontents;
3006 3064
3007 XSETSYMBOL_VALUE_MAGIC (valcontents, bfwd); 3065 XSETSYMBOL_VALUE_MAGIC (valcontents, bfwd);
3074 Lisp_Object Qnull_pointer; 3132 Lisp_Object Qnull_pointer;
3075 #endif 3133 #endif
3076 3134
3077 /* some losing systems can't have static vars at function scope... */ 3135 /* some losing systems can't have static vars at function scope... */
3078 static struct symbol_value_magic guts_of_unbound_marker = 3136 static struct symbol_value_magic guts_of_unbound_marker =
3079 { { symbol_value_forward_lheader_initializer, 0, 69}, 3137 { /* struct symbol_value_magic */
3080 SYMVAL_UNBOUND_MARKER }; 3138 { /* struct lcrecord_header */
3081 3139 { /* struct lrecord_header */
3082 Lisp_Object Vpure_uninterned_symbol_table; 3140 1, /* type - index into lrecord_implementations_table */
3141 0, /* mark */
3142 0, /* c_readonly */
3143 0, /* lisp_readonly */
3144 },
3145 0, /* next */
3146 0, /* uid */
3147 0, /* free */
3148 },
3149 0, /* value */
3150 SYMVAL_UNBOUND_MARKER
3151 };
3083 3152
3084 void 3153 void
3085 init_symbols_once_early (void) 3154 init_symbols_once_early (void)
3086 { 3155 {
3087 #ifndef Qzero 3156 reinit_symbols_once_early ();
3088 Qzero = make_int (0); /* Only used if Lisp_Object is a union type */ 3157
3089 #endif 3158 /* Bootstrapping problem: Qnil isn't set when make_string_nocopy is
3090
3091 #ifndef Qnull_pointer
3092 /* C guarantees that Qnull_pointer will be initialized to all 0 bits,
3093 so the following is actually a no-op. */
3094 XSETOBJ (Qnull_pointer, (enum Lisp_Type) 0, 0);
3095 #endif
3096
3097 /* see comment in Fpurecopy() */
3098 Vpure_uninterned_symbol_table =
3099 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
3100 staticpro (&Vpure_uninterned_symbol_table);
3101
3102 Qnil = Fmake_symbol (make_pure_pname ((CONST Bufbyte *) "nil", 3, 1));
3103 /* Bootstrapping problem: Qnil isn't set when make_pure_pname is
3104 called the first time. */ 3159 called the first time. */
3160 Qnil = Fmake_symbol (make_string_nocopy ((const Bufbyte *) "nil", 3));
3105 XSYMBOL (Qnil)->name->plist = Qnil; 3161 XSYMBOL (Qnil)->name->plist = Qnil;
3106 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ 3162 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */
3107 XSYMBOL (Qnil)->plist = Qnil; 3163 XSYMBOL (Qnil)->plist = Qnil;
3108 3164
3109 Vobarray = make_vector (OBARRAY_SIZE, Qzero); 3165 Vobarray = make_vector (OBARRAY_SIZE, Qzero);
3111 staticpro (&initial_obarray); 3167 staticpro (&initial_obarray);
3112 /* Intern nil in the obarray */ 3168 /* Intern nil in the obarray */
3113 { 3169 {
3114 int hash = hash_string (string_data (XSYMBOL (Qnil)->name), 3); 3170 int hash = hash_string (string_data (XSYMBOL (Qnil)->name), 3);
3115 XVECTOR_DATA (Vobarray)[hash % OBARRAY_SIZE] = Qnil; 3171 XVECTOR_DATA (Vobarray)[hash % OBARRAY_SIZE] = Qnil;
3116 XSYMBOL (Qnil)->obarray = Qt;
3117 } 3172 }
3118 3173
3119 { 3174 {
3120 /* Required to get around a GCC syntax error on certain 3175 /* Required to get around a GCC syntax error on certain
3121 architectures */ 3176 architectures */
3122 struct symbol_value_magic *tem = &guts_of_unbound_marker; 3177 struct symbol_value_magic *tem = &guts_of_unbound_marker;
3123 3178
3124 XSETSYMBOL_VALUE_MAGIC (Qunbound, tem); 3179 XSETSYMBOL_VALUE_MAGIC (Qunbound, tem);
3125 } 3180 }
3126 if ((CONST void *) XPNTR (Qunbound) != 3181 if ((const void *) XPNTR (Qunbound) !=
3127 (CONST void *)&guts_of_unbound_marker) 3182 (const void *)&guts_of_unbound_marker)
3128 { 3183 {
3129 /* This might happen on DATA_SEG_BITS machines. */ 3184 /* This might happen on DATA_SEG_BITS machines. */
3130 /* abort (); */ 3185 /* abort (); */
3131 /* Can't represent a pointer to constant C data using a Lisp_Object. 3186 /* Can't represent a pointer to constant C data using a Lisp_Object.
3132 So heap-allocate it. */ 3187 So heap-allocate it. */
3138 XSYMBOL (Qnil)->function = Qunbound; 3193 XSYMBOL (Qnil)->function = Qunbound;
3139 3194
3140 defsymbol (&Qt, "t"); 3195 defsymbol (&Qt, "t");
3141 XSYMBOL (Qt)->value = Qt; /* Veritas aetera */ 3196 XSYMBOL (Qt)->value = Qt; /* Veritas aetera */
3142 Vquit_flag = Qnil; 3197 Vquit_flag = Qnil;
3198
3199 pdump_wire (&Qnil);
3200 pdump_wire (&Qunbound);
3201 pdump_wire (&Vquit_flag);
3143 } 3202 }
3144 3203
3145 void 3204 void
3146 defsymbol (Lisp_Object *location, CONST char *name) 3205 reinit_symbols_once_early (void)
3147 { 3206 {
3148 *location = Fintern (make_pure_pname ((CONST Bufbyte *) name, 3207 #ifndef Qzero
3149 strlen (name), 1), 3208 Qzero = make_int (0); /* Only used if Lisp_Object is a union type */
3209 #endif
3210
3211 #ifndef Qnull_pointer
3212 /* C guarantees that Qnull_pointer will be initialized to all 0 bits,
3213 so the following is actually a no-op. */
3214 XSETOBJ (Qnull_pointer, (enum Lisp_Type) 0, 0);
3215 #endif
3216 }
3217
3218 void
3219 defsymbol_nodump (Lisp_Object *location, const char *name)
3220 {
3221 *location = Fintern (make_string_nocopy ((const Bufbyte *) name,
3222 strlen (name)),
3223 Qnil);
3224 staticpro_nodump (location);
3225 }
3226
3227 void
3228 defsymbol (Lisp_Object *location, const char *name)
3229 {
3230 *location = Fintern (make_string_nocopy ((const Bufbyte *) name,
3231 strlen (name)),
3150 Qnil); 3232 Qnil);
3151 staticpro (location); 3233 staticpro (location);
3152 } 3234 }
3153 3235
3154 void 3236 void
3155 defkeyword (Lisp_Object *location, CONST char *name) 3237 defkeyword (Lisp_Object *location, const char *name)
3156 { 3238 {
3157 defsymbol (location, name); 3239 defsymbol (location, name);
3158 Fset (*location, *location); 3240 Fset (*location, *location);
3159 } 3241 }
3160 3242
3203 * it if required. 3285 * it if required.
3204 * 3286 *
3205 * FIXME: Should newsubr be staticpro()'ed? I dont think so but I need 3287 * FIXME: Should newsubr be staticpro()'ed? I dont think so but I need
3206 * a guru to check. 3288 * a guru to check.
3207 */ 3289 */
3208 #define check_module_subr() \ 3290 #define check_module_subr() \
3209 do { \ 3291 do { \
3210 if (initialized) { \ 3292 if (initialized) { \
3211 struct Lisp_Subr *newsubr; \ 3293 Lisp_Subr *newsubr = (Lisp_Subr *) xmalloc (sizeof (Lisp_Subr)); \
3212 newsubr = (Lisp_Subr *)xmalloc(sizeof(struct Lisp_Subr)); \ 3294 memcpy (newsubr, subr, sizeof (Lisp_Subr)); \
3213 memcpy (newsubr, subr, sizeof(struct Lisp_Subr)); \ 3295 subr->doc = (const char *)newsubr; \
3214 subr->doc = (CONST char *)newsubr; \ 3296 subr = newsubr; \
3215 subr = newsubr; \ 3297 } \
3216 } \
3217 } while (0) 3298 } while (0)
3218 #else /* ! HAVE_SHLIB */ 3299 #else /* ! HAVE_SHLIB */
3219 #define check_module_subr() 3300 #define check_module_subr()
3220 #endif 3301 #endif
3221 3302
3245 XSETSUBR (fun, subr); 3326 XSETSUBR (fun, subr);
3246 XSYMBOL (sym)->function = Fcons (Qmacro, fun); 3327 XSYMBOL (sym)->function = Fcons (Qmacro, fun);
3247 } 3328 }
3248 3329
3249 void 3330 void
3250 deferror (Lisp_Object *symbol, CONST char *name, CONST char *messuhhj, 3331 deferror (Lisp_Object *symbol, const char *name, const char *messuhhj,
3251 Lisp_Object inherits_from) 3332 Lisp_Object inherits_from)
3252 { 3333 {
3253 Lisp_Object conds; 3334 Lisp_Object conds;
3254 defsymbol (symbol, name); 3335 defsymbol (symbol, name);
3255 3336
3256 assert (SYMBOLP (inherits_from)); 3337 assert (SYMBOLP (inherits_from));
3257 conds = Fget (inherits_from, Qerror_conditions, Qnil); 3338 conds = Fget (inherits_from, Qerror_conditions, Qnil);
3258 pure_put (*symbol, Qerror_conditions, Fcons (*symbol, conds)); 3339 Fput (*symbol, Qerror_conditions, Fcons (*symbol, conds));
3259 /* NOT build_translated_string (). This function is called at load time 3340 /* NOT build_translated_string (). This function is called at load time
3260 and the string needs to get translated at run time. (This happens 3341 and the string needs to get translated at run time. (This happens
3261 in the function (display-error) in cmdloop.el.) */ 3342 in the function (display-error) in cmdloop.el.) */
3262 pure_put (*symbol, Qerror_message, build_string (messuhhj)); 3343 Fput (*symbol, Qerror_message, build_string (messuhhj));
3263 } 3344 }
3264 3345
3265 void 3346 void
3266 syms_of_symbols (void) 3347 syms_of_symbols (void)
3267 { 3348 {
3276 defsymbol (&Qmake_unbound, "make-unbound"); 3357 defsymbol (&Qmake_unbound, "make-unbound");
3277 defsymbol (&Qlocal_predicate, "local-predicate"); 3358 defsymbol (&Qlocal_predicate, "local-predicate");
3278 defsymbol (&Qmake_local, "make-local"); 3359 defsymbol (&Qmake_local, "make-local");
3279 3360
3280 defsymbol (&Qboundp, "boundp"); 3361 defsymbol (&Qboundp, "boundp");
3281 defsymbol (&Qfboundp, "fboundp");
3282 defsymbol (&Qglobally_boundp, "globally-boundp"); 3362 defsymbol (&Qglobally_boundp, "globally-boundp");
3283 defsymbol (&Qmakunbound, "makunbound"); 3363 defsymbol (&Qmakunbound, "makunbound");
3284 defsymbol (&Qsymbol_value, "symbol-value"); 3364 defsymbol (&Qsymbol_value, "symbol-value");
3285 defsymbol (&Qset, "set"); 3365 defsymbol (&Qset, "set");
3286 defsymbol (&Qsetq_default, "setq-default"); 3366 defsymbol (&Qsetq_default, "setq-default");
3344 DEFSUBR (Fdontusethis_set_symbol_value_handler); 3424 DEFSUBR (Fdontusethis_set_symbol_value_handler);
3345 } 3425 }
3346 3426
3347 /* Create and initialize a Lisp variable whose value is forwarded to C data */ 3427 /* Create and initialize a Lisp variable whose value is forwarded to C data */
3348 void 3428 void
3349 defvar_magic (CONST char *symbol_name, CONST struct symbol_value_forward *magic) 3429 defvar_magic (const char *symbol_name, const struct symbol_value_forward *magic)
3350 { 3430 {
3351 Lisp_Object sym, kludge; 3431 Lisp_Object sym, kludge;
3352 3432
3353 /* Check that `magic' points somewhere we can represent as a Lisp pointer */ 3433 /* Check that `magic' points somewhere we can represent as a Lisp pointer */
3354 XSETOBJ (kludge, Lisp_Type_Record, magic); 3434 XSETOBJ (kludge, Lisp_Type_Record, magic);
3370 */ 3450 */
3371 if (initialized) 3451 if (initialized)
3372 sym = Fintern (build_string (symbol_name), Qnil); 3452 sym = Fintern (build_string (symbol_name), Qnil);
3373 else 3453 else
3374 #endif 3454 #endif
3375 sym = Fintern (make_pure_pname ((CONST Bufbyte *) symbol_name, 3455 sym = Fintern (make_string_nocopy ((const Bufbyte *) symbol_name,
3376 strlen (symbol_name), 1), Qnil); 3456 strlen (symbol_name)), Qnil);
3377 3457
3378 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, magic); 3458 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, magic);
3379 } 3459 }
3380 3460
3381 void 3461 void