Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 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 | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
1 /* "intern" and friends -- moved here from lread.c and data.c | 1 /* "intern" and friends -- moved here from lread.c and data.c |
2 Copyright (C) 1985-1989, 1992-1994 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1989, 1992-1994 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Ben Wing. | 3 Copyright (C) 1995, 2000 Ben Wing. |
4 | 4 |
5 This file is part of XEmacs. | 5 This file is part of XEmacs. |
6 | 6 |
7 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 |
8 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 |
115 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, function) }, | 115 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, function) }, |
116 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, plist) }, | 116 { XD_LISP_OBJECT, offsetof (Lisp_Symbol, plist) }, |
117 { XD_END } | 117 { XD_END } |
118 }; | 118 }; |
119 | 119 |
120 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("symbol", symbol, | 120 /* Symbol plists are directly accessible, so we need to protect against |
121 mark_symbol, print_symbol, 0, 0, 0, | 121 invalid property list structure */ |
122 symbol_description, Lisp_Symbol); | 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); | |
123 | 150 |
124 | 151 |
125 /**********************************************************************/ | 152 /**********************************************************************/ |
126 /* Intern */ | 153 /* Intern */ |
127 /**********************************************************************/ | 154 /**********************************************************************/ |
148 } | 175 } |
149 return obarray; | 176 return obarray; |
150 } | 177 } |
151 | 178 |
152 Lisp_Object | 179 Lisp_Object |
153 intern (CONST char *str) | 180 intern (const char *str) |
154 { | 181 { |
155 Bytecount len = strlen (str); | 182 Bytecount len = strlen (str); |
156 CONST Bufbyte *buf = (CONST Bufbyte *) str; | 183 const Bufbyte *buf = (const Bufbyte *) str; |
157 Lisp_Object obarray = Vobarray; | 184 Lisp_Object obarray = Vobarray; |
158 | 185 |
159 if (!VECTORP (obarray) || XVECTOR_LENGTH (obarray) == 0) | 186 if (!VECTORP (obarray) || XVECTOR_LENGTH (obarray) == 0) |
160 obarray = check_obarray (obarray); | 187 obarray = check_obarray (obarray); |
161 | 188 |
310 return the index into OBARRAY that the string hashes to. | 337 return the index into OBARRAY that the string hashes to. |
311 | 338 |
312 Also store the bucket number in oblookup_last_bucket_number. */ | 339 Also store the bucket number in oblookup_last_bucket_number. */ |
313 | 340 |
314 Lisp_Object | 341 Lisp_Object |
315 oblookup (Lisp_Object obarray, CONST Bufbyte *ptr, Bytecount size) | 342 oblookup (Lisp_Object obarray, const Bufbyte *ptr, Bytecount size) |
316 { | 343 { |
317 int hash, obsize; | 344 int hash, obsize; |
318 Lisp_Symbol *tail; | 345 Lisp_Symbol *tail; |
319 Lisp_Object bucket; | 346 Lisp_Object bucket; |
320 | 347 |
347 return make_int (hash); | 374 return make_int (hash); |
348 } | 375 } |
349 | 376 |
350 #if 0 /* Emacs 19.34 */ | 377 #if 0 /* Emacs 19.34 */ |
351 int | 378 int |
352 hash_string (CONST Bufbyte *ptr, Bytecount len) | 379 hash_string (const Bufbyte *ptr, Bytecount len) |
353 { | 380 { |
354 CONST Bufbyte *p = ptr; | 381 const Bufbyte *p = ptr; |
355 CONST Bufbyte *end = p + len; | 382 const Bufbyte *end = p + len; |
356 Bufbyte c; | 383 Bufbyte c; |
357 int hash = 0; | 384 int hash = 0; |
358 | 385 |
359 while (p != end) | 386 while (p != end) |
360 { | 387 { |
366 } | 393 } |
367 #endif | 394 #endif |
368 | 395 |
369 /* derived from hashpjw, Dragon Book P436. */ | 396 /* derived from hashpjw, Dragon Book P436. */ |
370 int | 397 int |
371 hash_string (CONST Bufbyte *ptr, Bytecount len) | 398 hash_string (const Bufbyte *ptr, Bytecount len) |
372 { | 399 { |
373 int hash = 0; | 400 int hash = 0; |
374 | 401 |
375 while (len-- > 0) | 402 while (len-- > 0) |
376 { | 403 { |
420 Call FUNCTION on every symbol in OBARRAY. | 447 Call FUNCTION on every symbol in OBARRAY. |
421 OBARRAY defaults to the value of `obarray'. | 448 OBARRAY defaults to the value of `obarray'. |
422 */ | 449 */ |
423 (function, obarray)) | 450 (function, obarray)) |
424 { | 451 { |
452 struct gcpro gcpro1; | |
453 | |
425 if (NILP (obarray)) | 454 if (NILP (obarray)) |
426 obarray = Vobarray; | 455 obarray = Vobarray; |
427 obarray = check_obarray (obarray); | 456 obarray = check_obarray (obarray); |
428 | 457 |
458 GCPRO1 (obarray); | |
429 map_obarray (obarray, mapatoms_1, &function); | 459 map_obarray (obarray, mapatoms_1, &function); |
460 UNGCPRO; | |
430 return Qnil; | 461 return Qnil; |
431 } | 462 } |
432 | 463 |
433 | 464 |
434 /**********************************************************************/ | 465 /**********************************************************************/ |
466 Return list of symbols found. | 497 Return list of symbols found. |
467 */ | 498 */ |
468 (regexp, predicate)) | 499 (regexp, predicate)) |
469 { | 500 { |
470 struct appropos_mapper_closure closure; | 501 struct appropos_mapper_closure closure; |
502 struct gcpro gcpro1; | |
471 | 503 |
472 CHECK_STRING (regexp); | 504 CHECK_STRING (regexp); |
473 | 505 |
474 closure.regexp = regexp; | 506 closure.regexp = regexp; |
475 closure.predicate = predicate; | 507 closure.predicate = predicate; |
476 closure.accumulation = Qnil; | 508 closure.accumulation = Qnil; |
509 GCPRO1 (closure.accumulation); | |
477 map_obarray (Vobarray, apropos_mapper, &closure); | 510 map_obarray (Vobarray, apropos_mapper, &closure); |
478 closure.accumulation = Fsort (closure.accumulation, Qstring_lessp); | 511 closure.accumulation = Fsort (closure.accumulation, Qstring_lessp); |
512 UNGCPRO; | |
479 return closure.accumulation; | 513 return closure.accumulation; |
480 } | 514 } |
481 | 515 |
482 | 516 |
483 /* Extract and set components of symbols */ | 517 /* Extract and set components of symbols */ |
979 { XD_END } | 1013 { XD_END } |
980 }; | 1014 }; |
981 | 1015 |
982 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-forward", | 1016 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-forward", |
983 symbol_value_forward, | 1017 symbol_value_forward, |
984 this_one_is_unmarkable, | 1018 0, |
985 print_symbol_value_magic, 0, 0, 0, | 1019 print_symbol_value_magic, 0, 0, 0, |
986 symbol_value_forward_description, | 1020 symbol_value_forward_description, |
987 struct symbol_value_forward); | 1021 struct symbol_value_forward); |
988 | 1022 |
989 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-buffer-local", | 1023 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-buffer-local", |
1027 | 1061 |
1028 static Lisp_Object | 1062 static Lisp_Object |
1029 do_symval_forwarding (Lisp_Object valcontents, struct buffer *buffer, | 1063 do_symval_forwarding (Lisp_Object valcontents, struct buffer *buffer, |
1030 struct console *console) | 1064 struct console *console) |
1031 { | 1065 { |
1032 CONST struct symbol_value_forward *fwd; | 1066 const struct symbol_value_forward *fwd; |
1033 | 1067 |
1034 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) | 1068 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) |
1035 return valcontents; | 1069 return valcontents; |
1036 | 1070 |
1037 fwd = XSYMBOL_VALUE_FORWARD (valcontents); | 1071 fwd = XSYMBOL_VALUE_FORWARD (valcontents); |
1095 */ | 1129 */ |
1096 /* At this point, the value cell may not contain a symbol-value-varalias | 1130 /* At this point, the value cell may not contain a symbol-value-varalias |
1097 or symbol-value-buffer-local, and if there's a handler, we should | 1131 or symbol-value-buffer-local, and if there's a handler, we should |
1098 have already called it. */ | 1132 have already called it. */ |
1099 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); | 1133 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); |
1100 CONST struct symbol_value_forward *fwd | 1134 const struct symbol_value_forward *fwd |
1101 = XSYMBOL_VALUE_FORWARD (valcontents); | 1135 = XSYMBOL_VALUE_FORWARD (valcontents); |
1102 int offset = ((char *) symbol_value_forward_forward (fwd) | 1136 int offset = ((char *) symbol_value_forward_forward (fwd) |
1103 - (char *) &buffer_local_flags); | 1137 - (char *) &buffer_local_flags); |
1104 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 1138 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
1105 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, | 1139 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, |
1108 *((Lisp_Object *) (offset + (char *) XBUFFER (Vbuffer_defaults))) | 1142 *((Lisp_Object *) (offset + (char *) XBUFFER (Vbuffer_defaults))) |
1109 = value; | 1143 = value; |
1110 | 1144 |
1111 if (mask > 0) /* Not always per-buffer */ | 1145 if (mask > 0) /* Not always per-buffer */ |
1112 { | 1146 { |
1113 Lisp_Object elt; | |
1114 | |
1115 /* Set value in each buffer which hasn't shadowed the default */ | 1147 /* Set value in each buffer which hasn't shadowed the default */ |
1116 LIST_LOOP_2 (elt, Vbuffer_alist) | 1148 LIST_LOOP_2 (elt, Vbuffer_alist) |
1117 { | 1149 { |
1118 struct buffer *b = XBUFFER (XCDR (elt)); | 1150 struct buffer *b = XBUFFER (XCDR (elt)); |
1119 if (!(b->local_var_flags & mask)) | 1151 if (!(b->local_var_flags & mask)) |
1137 */ | 1169 */ |
1138 /* At this point, the value cell may not contain a symbol-value-varalias | 1170 /* At this point, the value cell may not contain a symbol-value-varalias |
1139 or symbol-value-buffer-local, and if there's a handler, we should | 1171 or symbol-value-buffer-local, and if there's a handler, we should |
1140 have already called it. */ | 1172 have already called it. */ |
1141 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); | 1173 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); |
1142 CONST struct symbol_value_forward *fwd | 1174 const struct symbol_value_forward *fwd |
1143 = XSYMBOL_VALUE_FORWARD (valcontents); | 1175 = XSYMBOL_VALUE_FORWARD (valcontents); |
1144 int offset = ((char *) symbol_value_forward_forward (fwd) | 1176 int offset = ((char *) symbol_value_forward_forward (fwd) |
1145 - (char *) &console_local_flags); | 1177 - (char *) &console_local_flags); |
1146 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 1178 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
1147 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, | 1179 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, |
1150 *((Lisp_Object *) (offset + (char *) XCONSOLE (Vconsole_defaults))) | 1182 *((Lisp_Object *) (offset + (char *) XCONSOLE (Vconsole_defaults))) |
1151 = value; | 1183 = value; |
1152 | 1184 |
1153 if (mask > 0) /* Not always per-console */ | 1185 if (mask > 0) /* Not always per-console */ |
1154 { | 1186 { |
1155 Lisp_Object console; | |
1156 | |
1157 /* Set value in each console which hasn't shadowed the default */ | 1187 /* Set value in each console which hasn't shadowed the default */ |
1158 LIST_LOOP_2 (console, Vconsole_list) | 1188 LIST_LOOP_2 (console, Vconsole_list) |
1159 { | 1189 { |
1160 struct console *d = XCONSOLE (console); | 1190 struct console *d = XCONSOLE (console); |
1161 if (!(d->local_var_flags & mask)) | 1191 if (!(d->local_var_flags & mask)) |
1203 || !SYMBOL_VALUE_MAGIC_P (*store_pointer)); | 1233 || !SYMBOL_VALUE_MAGIC_P (*store_pointer)); |
1204 *store_pointer = newval; | 1234 *store_pointer = newval; |
1205 } | 1235 } |
1206 else | 1236 else |
1207 { | 1237 { |
1208 CONST struct symbol_value_forward *fwd = XSYMBOL_VALUE_FORWARD (ovalue); | 1238 const struct symbol_value_forward *fwd = XSYMBOL_VALUE_FORWARD (ovalue); |
1209 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, | 1239 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, |
1210 Lisp_Object in_object, int flags) | 1240 Lisp_Object in_object, int flags) |
1211 = symbol_value_forward_magicfun (fwd); | 1241 = symbol_value_forward_magicfun (fwd); |
1212 | 1242 |
1213 switch (XSYMBOL_VALUE_MAGIC_TYPE (ovalue)) | 1243 switch (XSYMBOL_VALUE_MAGIC_TYPE (ovalue)) |
1683 | 1713 |
1684 /* case SYMVAL_UNBOUND_MARKER: break; */ | 1714 /* case SYMVAL_UNBOUND_MARKER: break; */ |
1685 | 1715 |
1686 case SYMVAL_CURRENT_BUFFER_FORWARD: | 1716 case SYMVAL_CURRENT_BUFFER_FORWARD: |
1687 { | 1717 { |
1688 CONST struct symbol_value_forward *fwd | 1718 const struct symbol_value_forward *fwd |
1689 = XSYMBOL_VALUE_FORWARD (valcontents); | 1719 = XSYMBOL_VALUE_FORWARD (valcontents); |
1690 int mask = XINT (*((Lisp_Object *) | 1720 int mask = XINT (*((Lisp_Object *) |
1691 symbol_value_forward_forward (fwd))); | 1721 symbol_value_forward_forward (fwd))); |
1692 if (mask > 0) | 1722 if (mask > 0) |
1693 /* Setting this variable makes it buffer-local */ | 1723 /* Setting this variable makes it buffer-local */ |
1695 break; | 1725 break; |
1696 } | 1726 } |
1697 | 1727 |
1698 case SYMVAL_SELECTED_CONSOLE_FORWARD: | 1728 case SYMVAL_SELECTED_CONSOLE_FORWARD: |
1699 { | 1729 { |
1700 CONST struct symbol_value_forward *fwd | 1730 const struct symbol_value_forward *fwd |
1701 = XSYMBOL_VALUE_FORWARD (valcontents); | 1731 = XSYMBOL_VALUE_FORWARD (valcontents); |
1702 int mask = XINT (*((Lisp_Object *) | 1732 int mask = XINT (*((Lisp_Object *) |
1703 symbol_value_forward_forward (fwd))); | 1733 symbol_value_forward_forward (fwd))); |
1704 if (mask > 0) | 1734 if (mask > 0) |
1705 /* Setting this variable makes it console-local */ | 1735 /* Setting this variable makes it console-local */ |
1833 case SYMVAL_UNBOUND_MARKER: | 1863 case SYMVAL_UNBOUND_MARKER: |
1834 return valcontents; | 1864 return valcontents; |
1835 | 1865 |
1836 case SYMVAL_CURRENT_BUFFER_FORWARD: | 1866 case SYMVAL_CURRENT_BUFFER_FORWARD: |
1837 { | 1867 { |
1838 CONST struct symbol_value_forward *fwd | 1868 const struct symbol_value_forward *fwd |
1839 = XSYMBOL_VALUE_FORWARD (valcontents); | 1869 = XSYMBOL_VALUE_FORWARD (valcontents); |
1840 return (*((Lisp_Object *)((char *) XBUFFER (Vbuffer_defaults) | 1870 return (*((Lisp_Object *)((char *) XBUFFER (Vbuffer_defaults) |
1841 + ((char *)symbol_value_forward_forward (fwd) | 1871 + ((char *)symbol_value_forward_forward (fwd) |
1842 - (char *)&buffer_local_flags)))); | 1872 - (char *)&buffer_local_flags)))); |
1843 } | 1873 } |
1844 | 1874 |
1845 case SYMVAL_SELECTED_CONSOLE_FORWARD: | 1875 case SYMVAL_SELECTED_CONSOLE_FORWARD: |
1846 { | 1876 { |
1847 CONST struct symbol_value_forward *fwd | 1877 const struct symbol_value_forward *fwd |
1848 = XSYMBOL_VALUE_FORWARD (valcontents); | 1878 = XSYMBOL_VALUE_FORWARD (valcontents); |
1849 return (*((Lisp_Object *)((char *) XCONSOLE (Vconsole_defaults) | 1879 return (*((Lisp_Object *)((char *) XCONSOLE (Vconsole_defaults) |
1850 + ((char *)symbol_value_forward_forward (fwd) | 1880 + ((char *)symbol_value_forward_forward (fwd) |
1851 - (char *)&console_local_flags)))); | 1881 - (char *)&console_local_flags)))); |
1852 } | 1882 } |
2282 /* presto change-o! */ | 2312 /* presto change-o! */ |
2283 goto retry; | 2313 goto retry; |
2284 | 2314 |
2285 case SYMVAL_CURRENT_BUFFER_FORWARD: | 2315 case SYMVAL_CURRENT_BUFFER_FORWARD: |
2286 { | 2316 { |
2287 CONST struct symbol_value_forward *fwd | 2317 const struct symbol_value_forward *fwd |
2288 = XSYMBOL_VALUE_FORWARD (valcontents); | 2318 = XSYMBOL_VALUE_FORWARD (valcontents); |
2289 int offset = ((char *) symbol_value_forward_forward (fwd) | 2319 int offset = ((char *) symbol_value_forward_forward (fwd) |
2290 - (char *) &buffer_local_flags); | 2320 - (char *) &buffer_local_flags); |
2291 int mask = | 2321 int mask = |
2292 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 2322 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
2376 /* presto change-o! */ | 2406 /* presto change-o! */ |
2377 goto retry; | 2407 goto retry; |
2378 | 2408 |
2379 case SYMVAL_SELECTED_CONSOLE_FORWARD: | 2409 case SYMVAL_SELECTED_CONSOLE_FORWARD: |
2380 { | 2410 { |
2381 CONST struct symbol_value_forward *fwd | 2411 const struct symbol_value_forward *fwd |
2382 = XSYMBOL_VALUE_FORWARD (valcontents); | 2412 = XSYMBOL_VALUE_FORWARD (valcontents); |
2383 int offset = ((char *) symbol_value_forward_forward (fwd) | 2413 int offset = ((char *) symbol_value_forward_forward (fwd) |
2384 - (char *) &console_local_flags); | 2414 - (char *) &console_local_flags); |
2385 int mask = | 2415 int mask = |
2386 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 2416 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
2435 /* presto change-o! */ | 2465 /* presto change-o! */ |
2436 goto retry; | 2466 goto retry; |
2437 | 2467 |
2438 case SYMVAL_CURRENT_BUFFER_FORWARD: | 2468 case SYMVAL_CURRENT_BUFFER_FORWARD: |
2439 { | 2469 { |
2440 CONST struct symbol_value_forward *fwd | 2470 const struct symbol_value_forward *fwd |
2441 = XSYMBOL_VALUE_FORWARD (valcontents); | 2471 = XSYMBOL_VALUE_FORWARD (valcontents); |
2442 int mask = XINT (*((Lisp_Object *) | 2472 int mask = XINT (*((Lisp_Object *) |
2443 symbol_value_forward_forward (fwd))); | 2473 symbol_value_forward_forward (fwd))); |
2444 if ((mask <= 0) || (buffer && (buffer->local_var_flags & mask))) | 2474 if ((mask <= 0) || (buffer && (buffer->local_var_flags & mask))) |
2445 /* Already buffer-local */ | 2475 /* Already buffer-local */ |
3104 #ifndef Qnull_pointer | 3134 #ifndef Qnull_pointer |
3105 Lisp_Object Qnull_pointer; | 3135 Lisp_Object Qnull_pointer; |
3106 #endif | 3136 #endif |
3107 | 3137 |
3108 /* some losing systems can't have static vars at function scope... */ | 3138 /* some losing systems can't have static vars at function scope... */ |
3109 static struct symbol_value_magic guts_of_unbound_marker = | 3139 static const struct symbol_value_magic guts_of_unbound_marker = |
3110 { { symbol_value_forward_lheader_initializer, 0, 69}, | 3140 { /* struct symbol_value_magic */ |
3111 SYMVAL_UNBOUND_MARKER }; | 3141 { /* struct lcrecord_header */ |
3142 { /* struct lrecord_header */ | |
3143 lrecord_type_symbol_value_forward, /* lrecord_type_index */ | |
3144 1, /* mark bit */ | |
3145 1, /* c_readonly bit */ | |
3146 1, /* lisp_readonly bit */ | |
3147 }, | |
3148 0, /* next */ | |
3149 0, /* uid */ | |
3150 0, /* free */ | |
3151 }, | |
3152 0, /* value */ | |
3153 SYMVAL_UNBOUND_MARKER | |
3154 }; | |
3112 | 3155 |
3113 void | 3156 void |
3114 init_symbols_once_early (void) | 3157 init_symbols_once_early (void) |
3115 { | 3158 { |
3159 INIT_LRECORD_IMPLEMENTATION (symbol); | |
3160 INIT_LRECORD_IMPLEMENTATION (symbol_value_forward); | |
3161 INIT_LRECORD_IMPLEMENTATION (symbol_value_buffer_local); | |
3162 INIT_LRECORD_IMPLEMENTATION (symbol_value_lisp_magic); | |
3163 INIT_LRECORD_IMPLEMENTATION (symbol_value_varalias); | |
3164 | |
3116 reinit_symbols_once_early (); | 3165 reinit_symbols_once_early (); |
3117 | 3166 |
3118 /* Bootstrapping problem: Qnil isn't set when make_string_nocopy is | 3167 /* Bootstrapping problem: Qnil isn't set when make_string_nocopy is |
3119 called the first time. */ | 3168 called the first time. */ |
3120 Qnil = Fmake_symbol (make_string_nocopy ((CONST Bufbyte *) "nil", 3)); | 3169 Qnil = Fmake_symbol (make_string_nocopy ((const Bufbyte *) "nil", 3)); |
3121 XSYMBOL (Qnil)->name->plist = Qnil; | 3170 XSYMBOL (Qnil)->name->plist = Qnil; |
3122 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ | 3171 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ |
3123 XSYMBOL (Qnil)->plist = Qnil; | 3172 XSYMBOL (Qnil)->plist = Qnil; |
3124 | 3173 |
3125 Vobarray = make_vector (OBARRAY_SIZE, Qzero); | 3174 Vobarray = make_vector (OBARRAY_SIZE, Qzero); |
3132 } | 3181 } |
3133 | 3182 |
3134 { | 3183 { |
3135 /* Required to get around a GCC syntax error on certain | 3184 /* Required to get around a GCC syntax error on certain |
3136 architectures */ | 3185 architectures */ |
3137 struct symbol_value_magic *tem = &guts_of_unbound_marker; | 3186 const struct symbol_value_magic *tem = &guts_of_unbound_marker; |
3138 | 3187 |
3139 XSETSYMBOL_VALUE_MAGIC (Qunbound, tem); | 3188 XSETSYMBOL_VALUE_MAGIC (Qunbound, tem); |
3140 } | 3189 } |
3141 if ((CONST void *) XPNTR (Qunbound) != | |
3142 (CONST void *)&guts_of_unbound_marker) | |
3143 { | |
3144 /* This might happen on DATA_SEG_BITS machines. */ | |
3145 /* abort (); */ | |
3146 /* Can't represent a pointer to constant C data using a Lisp_Object. | |
3147 So heap-allocate it. */ | |
3148 struct symbol_value_magic *urk = xnew (struct symbol_value_magic); | |
3149 memcpy (urk, &guts_of_unbound_marker, sizeof (*urk)); | |
3150 XSETSYMBOL_VALUE_MAGIC (Qunbound, urk); | |
3151 } | |
3152 | 3190 |
3153 XSYMBOL (Qnil)->function = Qunbound; | 3191 XSYMBOL (Qnil)->function = Qunbound; |
3154 | 3192 |
3155 defsymbol (&Qt, "t"); | 3193 defsymbol (&Qt, "t"); |
3156 XSYMBOL (Qt)->value = Qt; /* Veritas aetera */ | 3194 XSYMBOL (Qt)->value = Qt; /* Veritas aetera */ |
3169 #endif | 3207 #endif |
3170 | 3208 |
3171 #ifndef Qnull_pointer | 3209 #ifndef Qnull_pointer |
3172 /* C guarantees that Qnull_pointer will be initialized to all 0 bits, | 3210 /* C guarantees that Qnull_pointer will be initialized to all 0 bits, |
3173 so the following is actually a no-op. */ | 3211 so the following is actually a no-op. */ |
3174 XSETOBJ (Qnull_pointer, (enum Lisp_Type) 0, 0); | 3212 XSETOBJ (Qnull_pointer, 0); |
3175 #endif | 3213 #endif |
3176 } | 3214 } |
3177 | 3215 |
3216 static void | |
3217 defsymbol_massage_name_1 (Lisp_Object *location, const char *name, int dump_p, | |
3218 int multiword_predicate_p) | |
3219 { | |
3220 char temp[500]; | |
3221 int len = strlen (name) - 1; | |
3222 int i; | |
3223 | |
3224 if (multiword_predicate_p) | |
3225 assert (len + 1 < sizeof (temp)); | |
3226 else | |
3227 assert (len < sizeof (temp)); | |
3228 strcpy (temp, name + 1); /* Remove initial Q */ | |
3229 if (multiword_predicate_p) | |
3230 { | |
3231 strcpy (temp + len - 1, "_p"); | |
3232 len++; | |
3233 } | |
3234 for (i = 0; i < len; i++) | |
3235 if (temp[i] == '_') | |
3236 temp[i] = '-'; | |
3237 *location = Fintern (make_string ((const Bufbyte *) temp, len), Qnil); | |
3238 if (dump_p) | |
3239 staticpro (location); | |
3240 else | |
3241 staticpro_nodump (location); | |
3242 } | |
3243 | |
3178 void | 3244 void |
3179 defsymbol_nodump (Lisp_Object *location, CONST char *name) | 3245 defsymbol_massage_name_nodump (Lisp_Object *location, const char *name) |
3180 { | 3246 { |
3181 *location = Fintern (make_string_nocopy ((CONST Bufbyte *) name, | 3247 defsymbol_massage_name_1 (location, name, 0, 0); |
3248 } | |
3249 | |
3250 void | |
3251 defsymbol_massage_name (Lisp_Object *location, const char *name) | |
3252 { | |
3253 defsymbol_massage_name_1 (location, name, 1, 0); | |
3254 } | |
3255 | |
3256 void | |
3257 defsymbol_massage_multiword_predicate_nodump (Lisp_Object *location, | |
3258 const char *name) | |
3259 { | |
3260 defsymbol_massage_name_1 (location, name, 0, 1); | |
3261 } | |
3262 | |
3263 void | |
3264 defsymbol_massage_multiword_predicate (Lisp_Object *location, const char *name) | |
3265 { | |
3266 defsymbol_massage_name_1 (location, name, 1, 1); | |
3267 } | |
3268 | |
3269 void | |
3270 defsymbol_nodump (Lisp_Object *location, const char *name) | |
3271 { | |
3272 *location = Fintern (make_string_nocopy ((const Bufbyte *) name, | |
3182 strlen (name)), | 3273 strlen (name)), |
3183 Qnil); | 3274 Qnil); |
3184 staticpro_nodump (location); | 3275 staticpro_nodump (location); |
3185 } | 3276 } |
3186 | 3277 |
3187 void | 3278 void |
3188 defsymbol (Lisp_Object *location, CONST char *name) | 3279 defsymbol (Lisp_Object *location, const char *name) |
3189 { | 3280 { |
3190 *location = Fintern (make_string_nocopy ((CONST Bufbyte *) name, | 3281 *location = Fintern (make_string_nocopy ((const Bufbyte *) name, |
3191 strlen (name)), | 3282 strlen (name)), |
3192 Qnil); | 3283 Qnil); |
3193 staticpro (location); | 3284 staticpro (location); |
3194 } | 3285 } |
3195 | 3286 |
3196 void | 3287 void |
3197 defkeyword (Lisp_Object *location, CONST char *name) | 3288 defkeyword (Lisp_Object *location, const char *name) |
3198 { | 3289 { |
3199 defsymbol (location, name); | 3290 defsymbol (location, name); |
3291 Fset (*location, *location); | |
3292 } | |
3293 | |
3294 void | |
3295 defkeyword_massage_name (Lisp_Object *location, const char *name) | |
3296 { | |
3297 char temp[500]; | |
3298 int len = strlen (name); | |
3299 | |
3300 assert (len < sizeof (temp)); | |
3301 strcpy (temp, name); | |
3302 temp[1] = ':'; /* it's an underscore in the C variable */ | |
3303 | |
3304 defsymbol_massage_name (location, temp); | |
3200 Fset (*location, *location); | 3305 Fset (*location, *location); |
3201 } | 3306 } |
3202 | 3307 |
3203 #ifdef DEBUG_XEMACS | 3308 #ifdef DEBUG_XEMACS |
3204 /* Check that nobody spazzed writing a DEFUN. */ | 3309 /* Check that nobody spazzed writing a DEFUN. */ |
3233 * a copy here to ensure that a real address is used. | 3338 * a copy here to ensure that a real address is used. |
3234 * | 3339 * |
3235 * Once we have copied everything across, we re-use the original static | 3340 * Once we have copied everything across, we re-use the original static |
3236 * structure to store a pointer to the newly allocated one. This will be | 3341 * structure to store a pointer to the newly allocated one. This will be |
3237 * used in emodules.c by emodules_doc_subr() to find a pointer to the | 3342 * used in emodules.c by emodules_doc_subr() to find a pointer to the |
3238 * allocated object so that we can set its doc string propperly. | 3343 * allocated object so that we can set its doc string properly. |
3239 * | 3344 * |
3240 * NOTE: We dont actually use the DOC pointer here any more, but we did | 3345 * NOTE: We don't actually use the DOC pointer here any more, but we did |
3241 * in an earlier implementation of module support. There is no harm in | 3346 * in an earlier implementation of module support. There is no harm in |
3242 * setting it here in case we ever need it in future implementations. | 3347 * setting it here in case we ever need it in future implementations. |
3243 * subr->doc will point to the new subr structure that was allocated. | 3348 * subr->doc will point to the new subr structure that was allocated. |
3244 * Code can then get this value from the statis subr structure and use | 3349 * Code can then get this value from the static subr structure and use |
3245 * it if required. | 3350 * it if required. |
3246 * | 3351 * |
3247 * FIXME: Should newsubr be staticpro()'ed? I dont think so but I need | 3352 * FIXME: Should newsubr be staticpro()'ed? I don't think so but I need |
3248 * a guru to check. | 3353 * a guru to check. |
3249 */ | 3354 */ |
3250 #define check_module_subr() \ | 3355 #define check_module_subr() \ |
3251 do { \ | 3356 do { \ |
3252 if (initialized) { \ | 3357 if (initialized) { \ |
3253 Lisp_Subr *newsubr = (Lisp_Subr *) xmalloc (sizeof (Lisp_Subr)); \ | 3358 Lisp_Subr *newsubr = (Lisp_Subr *) xmalloc (sizeof (Lisp_Subr)); \ |
3254 memcpy (newsubr, subr, sizeof (Lisp_Subr)); \ | 3359 memcpy (newsubr, subr, sizeof (Lisp_Subr)); \ |
3255 subr->doc = (CONST char *)newsubr; \ | 3360 subr->doc = (const char *)newsubr; \ |
3256 subr = newsubr; \ | 3361 subr = newsubr; \ |
3257 } \ | 3362 } \ |
3258 } while (0) | 3363 } while (0) |
3259 #else /* ! HAVE_SHLIB */ | 3364 #else /* ! HAVE_SHLIB */ |
3260 #define check_module_subr() | 3365 #define check_module_subr() |
3285 | 3390 |
3286 XSETSUBR (fun, subr); | 3391 XSETSUBR (fun, subr); |
3287 XSYMBOL (sym)->function = Fcons (Qmacro, fun); | 3392 XSYMBOL (sym)->function = Fcons (Qmacro, fun); |
3288 } | 3393 } |
3289 | 3394 |
3290 void | 3395 static void |
3291 deferror (Lisp_Object *symbol, CONST char *name, CONST char *messuhhj, | 3396 deferror_1 (Lisp_Object *symbol, const char *name, const char *messuhhj, |
3292 Lisp_Object inherits_from) | 3397 Lisp_Object inherits_from, int massage_p) |
3293 { | 3398 { |
3294 Lisp_Object conds; | 3399 Lisp_Object conds; |
3295 defsymbol (symbol, name); | 3400 if (massage_p) |
3401 defsymbol_massage_name (symbol, name); | |
3402 else | |
3403 defsymbol (symbol, name); | |
3296 | 3404 |
3297 assert (SYMBOLP (inherits_from)); | 3405 assert (SYMBOLP (inherits_from)); |
3298 conds = Fget (inherits_from, Qerror_conditions, Qnil); | 3406 conds = Fget (inherits_from, Qerror_conditions, Qnil); |
3299 Fput (*symbol, Qerror_conditions, Fcons (*symbol, conds)); | 3407 Fput (*symbol, Qerror_conditions, Fcons (*symbol, conds)); |
3300 /* NOT build_translated_string (). This function is called at load time | 3408 /* NOT build_translated_string (). This function is called at load time |
3302 in the function (display-error) in cmdloop.el.) */ | 3410 in the function (display-error) in cmdloop.el.) */ |
3303 Fput (*symbol, Qerror_message, build_string (messuhhj)); | 3411 Fput (*symbol, Qerror_message, build_string (messuhhj)); |
3304 } | 3412 } |
3305 | 3413 |
3306 void | 3414 void |
3415 deferror (Lisp_Object *symbol, const char *name, const char *messuhhj, | |
3416 Lisp_Object inherits_from) | |
3417 { | |
3418 deferror_1 (symbol, name, messuhhj, inherits_from, 0); | |
3419 } | |
3420 | |
3421 void | |
3422 deferror_massage_name (Lisp_Object *symbol, const char *name, | |
3423 const char *messuhhj, Lisp_Object inherits_from) | |
3424 { | |
3425 deferror_1 (symbol, name, messuhhj, inherits_from, 1); | |
3426 } | |
3427 | |
3428 void | |
3429 deferror_massage_name_and_message (Lisp_Object *symbol, const char *name, | |
3430 Lisp_Object inherits_from) | |
3431 { | |
3432 char temp[500]; | |
3433 int i; | |
3434 int len = strlen (name) - 1; | |
3435 | |
3436 assert (len < sizeof (temp)); | |
3437 strcpy (temp, name + 1); /* Remove initial Q */ | |
3438 temp[0] = toupper (temp[0]); | |
3439 for (i = 0; i < len; i++) | |
3440 if (temp[i] == '_') | |
3441 temp[i] = ' '; | |
3442 | |
3443 deferror_1 (symbol, name, temp, inherits_from, 1); | |
3444 } | |
3445 | |
3446 void | |
3307 syms_of_symbols (void) | 3447 syms_of_symbols (void) |
3308 { | 3448 { |
3309 defsymbol (&Qvariable_documentation, "variable-documentation"); | 3449 DEFSYMBOL (Qvariable_documentation); |
3310 defsymbol (&Qvariable_domain, "variable-domain"); /* I18N3 */ | 3450 DEFSYMBOL (Qvariable_domain); /* I18N3 */ |
3311 defsymbol (&Qad_advice_info, "ad-advice-info"); | 3451 DEFSYMBOL (Qad_advice_info); |
3312 defsymbol (&Qad_activate, "ad-activate"); | 3452 DEFSYMBOL (Qad_activate); |
3313 | 3453 |
3314 defsymbol (&Qget_value, "get-value"); | 3454 DEFSYMBOL (Qget_value); |
3315 defsymbol (&Qset_value, "set-value"); | 3455 DEFSYMBOL (Qset_value); |
3316 defsymbol (&Qbound_predicate, "bound-predicate"); | 3456 DEFSYMBOL (Qbound_predicate); |
3317 defsymbol (&Qmake_unbound, "make-unbound"); | 3457 DEFSYMBOL (Qmake_unbound); |
3318 defsymbol (&Qlocal_predicate, "local-predicate"); | 3458 DEFSYMBOL (Qlocal_predicate); |
3319 defsymbol (&Qmake_local, "make-local"); | 3459 DEFSYMBOL (Qmake_local); |
3320 | 3460 |
3321 defsymbol (&Qboundp, "boundp"); | 3461 DEFSYMBOL (Qboundp); |
3322 defsymbol (&Qglobally_boundp, "globally-boundp"); | 3462 DEFSYMBOL (Qglobally_boundp); |
3323 defsymbol (&Qmakunbound, "makunbound"); | 3463 DEFSYMBOL (Qmakunbound); |
3324 defsymbol (&Qsymbol_value, "symbol-value"); | 3464 DEFSYMBOL (Qsymbol_value); |
3325 defsymbol (&Qset, "set"); | 3465 DEFSYMBOL (Qset); |
3326 defsymbol (&Qsetq_default, "setq-default"); | 3466 DEFSYMBOL (Qsetq_default); |
3327 defsymbol (&Qdefault_boundp, "default-boundp"); | 3467 DEFSYMBOL (Qdefault_boundp); |
3328 defsymbol (&Qdefault_value, "default-value"); | 3468 DEFSYMBOL (Qdefault_value); |
3329 defsymbol (&Qset_default, "set-default"); | 3469 DEFSYMBOL (Qset_default); |
3330 defsymbol (&Qmake_variable_buffer_local, "make-variable-buffer-local"); | 3470 DEFSYMBOL (Qmake_variable_buffer_local); |
3331 defsymbol (&Qmake_local_variable, "make-local-variable"); | 3471 DEFSYMBOL (Qmake_local_variable); |
3332 defsymbol (&Qkill_local_variable, "kill-local-variable"); | 3472 DEFSYMBOL (Qkill_local_variable); |
3333 defsymbol (&Qkill_console_local_variable, "kill-console-local-variable"); | 3473 DEFSYMBOL (Qkill_console_local_variable); |
3334 defsymbol (&Qsymbol_value_in_buffer, "symbol-value-in-buffer"); | 3474 DEFSYMBOL (Qsymbol_value_in_buffer); |
3335 defsymbol (&Qsymbol_value_in_console, "symbol-value-in-console"); | 3475 DEFSYMBOL (Qsymbol_value_in_console); |
3336 defsymbol (&Qlocal_variable_p, "local-variable-p"); | 3476 DEFSYMBOL (Qlocal_variable_p); |
3337 | 3477 |
3338 defsymbol (&Qconst_integer, "const-integer"); | 3478 DEFSYMBOL (Qconst_integer); |
3339 defsymbol (&Qconst_boolean, "const-boolean"); | 3479 DEFSYMBOL (Qconst_boolean); |
3340 defsymbol (&Qconst_object, "const-object"); | 3480 DEFSYMBOL (Qconst_object); |
3341 defsymbol (&Qconst_specifier, "const-specifier"); | 3481 DEFSYMBOL (Qconst_specifier); |
3342 defsymbol (&Qdefault_buffer, "default-buffer"); | 3482 DEFSYMBOL (Qdefault_buffer); |
3343 defsymbol (&Qcurrent_buffer, "current-buffer"); | 3483 DEFSYMBOL (Qcurrent_buffer); |
3344 defsymbol (&Qconst_current_buffer, "const-current-buffer"); | 3484 DEFSYMBOL (Qconst_current_buffer); |
3345 defsymbol (&Qdefault_console, "default-console"); | 3485 DEFSYMBOL (Qdefault_console); |
3346 defsymbol (&Qselected_console, "selected-console"); | 3486 DEFSYMBOL (Qselected_console); |
3347 defsymbol (&Qconst_selected_console, "const-selected-console"); | 3487 DEFSYMBOL (Qconst_selected_console); |
3348 | 3488 |
3349 DEFSUBR (Fintern); | 3489 DEFSUBR (Fintern); |
3350 DEFSUBR (Fintern_soft); | 3490 DEFSUBR (Fintern_soft); |
3351 DEFSUBR (Funintern); | 3491 DEFSUBR (Funintern); |
3352 DEFSUBR (Fmapatoms); | 3492 DEFSUBR (Fmapatoms); |
3384 DEFSUBR (Fdontusethis_set_symbol_value_handler); | 3524 DEFSUBR (Fdontusethis_set_symbol_value_handler); |
3385 } | 3525 } |
3386 | 3526 |
3387 /* Create and initialize a Lisp variable whose value is forwarded to C data */ | 3527 /* Create and initialize a Lisp variable whose value is forwarded to C data */ |
3388 void | 3528 void |
3389 defvar_magic (CONST char *symbol_name, CONST struct symbol_value_forward *magic) | 3529 defvar_magic (const char *symbol_name, const struct symbol_value_forward *magic) |
3390 { | 3530 { |
3391 Lisp_Object sym, kludge; | 3531 Lisp_Object sym; |
3392 | |
3393 /* Check that `magic' points somewhere we can represent as a Lisp pointer */ | |
3394 XSETOBJ (kludge, Lisp_Type_Record, magic); | |
3395 if ((void *)magic != (void*) XPNTR (kludge)) | |
3396 { | |
3397 /* This might happen on DATA_SEG_BITS machines. */ | |
3398 /* abort (); */ | |
3399 /* Copy it to somewhere which is representable. */ | |
3400 struct symbol_value_forward *p = xnew (struct symbol_value_forward); | |
3401 memcpy (p, magic, sizeof *magic); | |
3402 magic = p; | |
3403 } | |
3404 | 3532 |
3405 #if defined(HAVE_SHLIB) | 3533 #if defined(HAVE_SHLIB) |
3406 /* | 3534 /* |
3407 * As with defsubr(), this will only be called in a dumped Emacs when | 3535 * As with defsubr(), this will only be called in a dumped Emacs when |
3408 * we are adding variables from a dynamically loaded module. That means | 3536 * we are adding variables from a dynamically loaded module. That means |
3410 */ | 3538 */ |
3411 if (initialized) | 3539 if (initialized) |
3412 sym = Fintern (build_string (symbol_name), Qnil); | 3540 sym = Fintern (build_string (symbol_name), Qnil); |
3413 else | 3541 else |
3414 #endif | 3542 #endif |
3415 sym = Fintern (make_string_nocopy ((CONST Bufbyte *) symbol_name, | 3543 sym = Fintern (make_string_nocopy ((const Bufbyte *) symbol_name, |
3416 strlen (symbol_name)), Qnil); | 3544 strlen (symbol_name)), Qnil); |
3417 | 3545 |
3418 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, magic); | 3546 XSETOBJ (XSYMBOL (sym)->value, magic); |
3419 } | 3547 } |
3420 | 3548 |
3421 void | 3549 void |
3422 vars_of_symbols (void) | 3550 vars_of_symbols (void) |
3423 { | 3551 { |