Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 5118:e0db3c197671 ben-lisp-object
merge up to latest default branch, doesn't compile yet
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 21:18:49 -0600 |
parents | 3742ea8250b5 8f1ee2d15784 |
children | 623d57b7fbe8 |
comparison
equal
deleted
inserted
replaced
5117:3742ea8250b5 | 5118:e0db3c197671 |
---|---|
82 static Lisp_Object fetch_value_maybe_past_magic (Lisp_Object sym, | 82 static Lisp_Object fetch_value_maybe_past_magic (Lisp_Object sym, |
83 Lisp_Object follow_past_lisp_magic); | 83 Lisp_Object follow_past_lisp_magic); |
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 static Lisp_Object map_varalias_chain (Lisp_Object symbol, | |
88 Lisp_Object follow_past_lisp_magic, | |
89 Lisp_Object (*fn) (Lisp_Object arg)); | |
87 | 90 |
88 | 91 |
89 static Lisp_Object | 92 static Lisp_Object |
90 mark_symbol (Lisp_Object obj) | 93 mark_symbol (Lisp_Object obj) |
91 { | 94 { |
134 symbol_remprop (Lisp_Object symbol, Lisp_Object property) | 137 symbol_remprop (Lisp_Object symbol, Lisp_Object property) |
135 { | 138 { |
136 return external_remprop (&XSYMBOL (symbol)->plist, property, 0, ERROR_ME); | 139 return external_remprop (&XSYMBOL (symbol)->plist, property, 0, ERROR_ME); |
137 } | 140 } |
138 | 141 |
139 DEFINE_BASIC_LISP_OBJECT_WITH_PROPS ("symbol", symbol, | 142 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT_WITH_PROPS ("symbol", symbol, |
140 mark_symbol, print_symbol, | 143 mark_symbol, print_symbol, |
141 0, 0, 0, symbol_description, | 144 0, 0, 0, symbol_description, |
142 symbol_getprop, | 145 symbol_getprop, |
143 symbol_putprop, | 146 symbol_putprop, |
144 symbol_remprop, | 147 symbol_remprop, |
253 } | 256 } |
254 | 257 |
255 return object; | 258 return object; |
256 } | 259 } |
257 | 260 |
258 DEFUN ("intern-soft", Fintern_soft, 1, 2, 0, /* | 261 DEFUN ("intern-soft", Fintern_soft, 1, 3, 0, /* |
259 Return the canonical symbol named NAME, or nil if none exists. | 262 Return the canonical symbol named NAME, or nil if none exists. |
260 NAME may be a string or a symbol. If it is a symbol, that exact | 263 NAME may be a string or a symbol. If it is a symbol, that exact |
261 symbol is searched for. | 264 symbol is searched for. |
262 Optional second argument OBARRAY specifies the obarray to use; | 265 Optional second argument OBARRAY specifies the obarray to use; |
263 it defaults to the value of the variable `obarray'. | 266 it defaults to the value of the variable `obarray'. |
264 */ | 267 Optional third argument DEFAULT says what Lisp object to return if there is |
265 (name, obarray)) | 268 no canonical symbol named NAME, and defaults to nil. |
266 { | 269 */ |
267 /* #### Bug! (intern-soft "nil") returns nil. Perhaps we should | 270 (name, obarray, default_)) |
268 add a DEFAULT-IF-NOT-FOUND arg, like in get. */ | 271 { |
269 Lisp_Object tem; | 272 Lisp_Object tem; |
270 Lisp_Object string; | 273 Lisp_Object string; |
271 | 274 |
272 if (NILP (obarray)) obarray = Vobarray; | 275 if (NILP (obarray)) obarray = Vobarray; |
273 obarray = check_obarray (obarray); | 276 obarray = check_obarray (obarray); |
280 else | 283 else |
281 string = symbol_name (XSYMBOL (name)); | 284 string = symbol_name (XSYMBOL (name)); |
282 | 285 |
283 tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); | 286 tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); |
284 if (INTP (tem) || (SYMBOLP (name) && !EQ (name, tem))) | 287 if (INTP (tem) || (SYMBOLP (name) && !EQ (name, tem))) |
285 return Qnil; | 288 return default_; |
286 else | 289 else |
287 return tem; | 290 return tem; |
288 } | 291 } |
289 | 292 |
290 DEFUN ("unintern", Funintern, 1, 2, 0, /* | 293 DEFUN ("unintern", Funintern, 1, 2, 0, /* |
712 */ | 715 */ |
713 (symbol, newdef)) | 716 (symbol, newdef)) |
714 { | 717 { |
715 /* This function can GC */ | 718 /* This function can GC */ |
716 Ffset (symbol, newdef); | 719 Ffset (symbol, newdef); |
717 LOADHIST_ATTACH (symbol); | 720 LOADHIST_ATTACH (Fcons (Qdefun, symbol)); |
718 return newdef; | 721 return newdef; |
719 } | 722 } |
720 | 723 |
724 DEFUN ("subr-name", Fsubr_name, 1, 1, 0, /* | |
725 Return name of function SUBR. | |
726 SUBR must be a built-in function. | |
727 */ | |
728 (subr)) | |
729 { | |
730 const char *name; | |
731 CHECK_SUBR (subr); | |
732 | |
733 name = XSUBR (subr)->name; | |
734 return make_string ((const Ibyte *)name, strlen (name)); | |
735 } | |
736 | |
737 DEFUN ("special-form-p", Fspecial_form_p, 1, 1, 0, /* | |
738 Return whether SUBR is a special form. | |
739 | |
740 A special form is a built-in function (a subr, that is a function | |
741 implemented in C, not Lisp) which does not necessarily evaluate all its | |
742 arguments. Much of the basic XEmacs Lisp syntax is implemented by means of | |
743 special forms; examples are `let', `condition-case', `defun', `setq' and so | |
744 on. | |
745 | |
746 If you intend to write a Lisp function that does not necessarily evaluate | |
747 all its arguments, the portable (across emacs variants, and across Lisp | |
748 implementations) way to go about it is to write a macro instead. See | |
749 `defmacro' and `backquote'. | |
750 */ | |
751 (subr)) | |
752 { | |
753 subr = indirect_function (subr, 0); | |
754 return (SUBRP (subr) && XSUBR (subr)->max_args == UNEVALLED) ? Qt : Qnil; | |
755 } | |
721 | 756 |
722 DEFUN ("setplist", Fsetplist, 2, 2, 0, /* | 757 DEFUN ("setplist", Fsetplist, 2, 2, 0, /* |
723 Set SYMBOL's property list to NEWPLIST, and return NEWPLIST. | 758 Set SYMBOL's property list to NEWPLIST, and return NEWPLIST. |
724 */ | 759 */ |
725 (symbol, newplist)) | 760 (symbol, newplist)) |
1006 | 1041 |
1007 static const struct memory_description symbol_value_forward_description[] = { | 1042 static const struct memory_description symbol_value_forward_description[] = { |
1008 { XD_END } | 1043 { XD_END } |
1009 }; | 1044 }; |
1010 | 1045 |
1011 DEFINE_LISP_OBJECT ("symbol-value-forward", | 1046 DEFINE_DUMPABLE_LISP_OBJECT ("symbol-value-forward", |
1012 symbol_value_forward, | 1047 symbol_value_forward, |
1013 0, | 1048 0, |
1014 print_symbol_value_magic, 0, 0, 0, | 1049 print_symbol_value_magic, 0, 0, 0, |
1015 symbol_value_forward_description, | 1050 symbol_value_forward_description, |
1016 struct symbol_value_forward); | 1051 struct symbol_value_forward); |
1017 | 1052 |
1018 DEFINE_LISP_OBJECT ("symbol-value-buffer-local", | 1053 DEFINE_DUMPABLE_LISP_OBJECT ("symbol-value-buffer-local", |
1019 symbol_value_buffer_local, | 1054 symbol_value_buffer_local, |
1020 mark_symbol_value_buffer_local, | 1055 mark_symbol_value_buffer_local, |
1021 print_symbol_value_magic, 0, 0, 0, | 1056 print_symbol_value_magic, 0, 0, 0, |
1022 symbol_value_buffer_local_description, | 1057 symbol_value_buffer_local_description, |
1023 struct symbol_value_buffer_local); | 1058 struct symbol_value_buffer_local); |
1024 | 1059 |
1025 DEFINE_LISP_OBJECT ("symbol-value-lisp-magic", | 1060 DEFINE_DUMPABLE_LISP_OBJECT ("symbol-value-lisp-magic", |
1026 symbol_value_lisp_magic, | 1061 symbol_value_lisp_magic, |
1027 mark_symbol_value_lisp_magic, | 1062 mark_symbol_value_lisp_magic, |
1028 print_symbol_value_magic, 0, 0, 0, | 1063 print_symbol_value_magic, 0, 0, 0, |
1029 symbol_value_lisp_magic_description, | 1064 symbol_value_lisp_magic_description, |
1030 struct symbol_value_lisp_magic); | 1065 struct symbol_value_lisp_magic); |
1031 | 1066 |
1032 DEFINE_LISP_OBJECT ("symbol-value-varalias", | 1067 DEFINE_DUMPABLE_LISP_OBJECT ("symbol-value-varalias", |
1033 symbol_value_varalias, | 1068 symbol_value_varalias, |
1034 mark_symbol_value_varalias, | 1069 mark_symbol_value_varalias, |
1035 print_symbol_value_magic, 0, 0, 0, | 1070 print_symbol_value_magic, 0, 0, 0, |
1036 symbol_value_varalias_description, | 1071 symbol_value_varalias_description, |
1037 struct symbol_value_varalias); | 1072 struct symbol_value_varalias); |
2104 Fsignal (Qwrong_number_of_arguments, | 2139 Fsignal (Qwrong_number_of_arguments, |
2105 list2 (Qsetq_default, make_int (nargs))); | 2140 list2 (Qsetq_default, make_int (nargs))); |
2106 | 2141 |
2107 GC_PROPERTY_LIST_LOOP_3 (symbol, val, args) | 2142 GC_PROPERTY_LIST_LOOP_3 (symbol, val, args) |
2108 { | 2143 { |
2109 val = Feval (val); | 2144 val = IGNORE_MULTIPLE_VALUES (Feval (val)); |
2110 Fset_default (symbol, val); | 2145 Fset_default (symbol, val); |
2111 retval = val; | 2146 retval = val; |
2112 } | 2147 } |
2113 | 2148 |
2114 END_GC_PROPERTY_LIST_LOOP (symbol); | 2149 END_GC_PROPERTY_LIST_LOOP (symbol); |
2715 if (NILP (after_set)) | 2750 if (NILP (after_set)) |
2716 return local_info > 0 ? Qt : Qnil; | 2751 return local_info > 0 ? Qt : Qnil; |
2717 else | 2752 else |
2718 return local_info != 0 ? Qt : Qnil; | 2753 return local_info != 0 ? Qt : Qnil; |
2719 } | 2754 } |
2755 | |
2756 DEFUN ("custom-variable-p", Fcustom_variable_p, 1, 1, 0, /* | |
2757 Return non-nil if SYMBOL names a custom variable. | |
2758 Does not follow the variable alias chain. | |
2759 */ | |
2760 (symbol)) | |
2761 { | |
2762 return (!(NILP (Fget(symbol, intern ("standard-value"), Qnil))) | |
2763 || !(NILP (Fget(symbol, intern ("custom-autoload"), Qnil)))) ? | |
2764 Qt: Qnil; | |
2765 } | |
2766 | |
2767 static Lisp_Object | |
2768 user_variable_alias_check_fun (Lisp_Object symbol) | |
2769 { | |
2770 Lisp_Object documentation = Fget (symbol, Qvariable_documentation, Qnil); | |
2771 | |
2772 if ((INTP (documentation) && XINT (documentation) < 0) || | |
2773 (STRINGP (documentation) && | |
2774 (string_byte (documentation, 0) == '*')) || | |
2775 /* If (STRING . INTEGER), a negative integer means a user variable. */ | |
2776 (CONSP (documentation) | |
2777 && STRINGP (XCAR (documentation)) | |
2778 && INTP (XCDR (documentation)) | |
2779 && XINT (XCDR (documentation)) < 0) || | |
2780 !NILP (Fcustom_variable_p (symbol))) | |
2781 { | |
2782 return make_int(1); | |
2783 } | |
2784 | |
2785 return Qzero; | |
2786 } | |
2787 | |
2788 DEFUN ("user-variable-p", Fuser_variable_p, 1, 1, 0, /* | |
2789 Return t if SYMBOL names a variable intended to be set and modified by users. | |
2790 \(The alternative is a variable used internally in a Lisp program.) | |
2791 A symbol names a user variable if | |
2792 \(1) the first character of its documentation is `*', or | |
2793 \(2) it is customizable (`custom-variable-p' gives t), or | |
2794 \(3) it names a variable alias that eventually resolves to another user variable. | |
2795 | |
2796 The GNU Emacs implementation of `user-variable-p' returns nil if there is a | |
2797 loop in the chain of symbols. Since this is indistinguishable from the case | |
2798 where a symbol names a non-user variable, XEmacs signals a | |
2799 `cyclic-variable-indirection' error instead; use `condition-case' to catch | |
2800 this error if you really want to avoid this. | |
2801 */ | |
2802 (symbol)) | |
2803 { | |
2804 Lisp_Object mapped; | |
2805 | |
2806 if (!SYMBOLP (symbol)) | |
2807 { | |
2808 return Qnil; | |
2809 } | |
2810 | |
2811 /* Called for its side-effects, we want it to signal if there's a loop. */ | |
2812 follow_varalias_pointers (symbol, Qt); | |
2813 | |
2814 /* Look through the various aliases. */ | |
2815 mapped = map_varalias_chain (symbol, Qt, user_variable_alias_check_fun); | |
2816 if (EQ (Qzero, mapped)) | |
2817 { | |
2818 return Qnil; | |
2819 } | |
2820 | |
2821 assert (EQ (make_int (1), mapped)); | |
2822 | |
2823 return Qt; | |
2824 } | |
2825 | |
2826 | |
2720 | 2827 |
2721 | 2828 |
2722 /* | 2829 /* |
2723 I've gone ahead and partially implemented this because it's | 2830 I've gone ahead and partially implemented this because it's |
2724 super-useful for dealing with the compatibility problems in supporting | 2831 super-useful for dealing with the compatibility problems in supporting |
2990 If you do, suffer the wrath of Ben, who is likely to rename | 3097 If you do, suffer the wrath of Ben, who is likely to rename |
2991 this function (or change the semantics of its arguments) without | 3098 this function (or change the semantics of its arguments) without |
2992 pity, thereby invalidating your code. | 3099 pity, thereby invalidating your code. |
2993 */ | 3100 */ |
2994 (variable, handler_type, handler, harg, | 3101 (variable, handler_type, handler, harg, |
2995 UNUSED (keep_existing))) | 3102 UNUSED (keep_existing ))) |
2996 { | 3103 { |
2997 Lisp_Object valcontents; | 3104 Lisp_Object valcontents; |
2998 struct symbol_value_lisp_magic *bfwd; | 3105 struct symbol_value_lisp_magic *bfwd; |
2999 enum lisp_magic_handler htype; | 3106 enum lisp_magic_handler htype; |
3000 int i; | 3107 int i; |
3098 } | 3205 } |
3099 | 3206 |
3100 return hare; | 3207 return hare; |
3101 } | 3208 } |
3102 | 3209 |
3103 DEFUN ("defvaralias", Fdefvaralias, 2, 2, 0, /* | 3210 /* Map FN over the chain of variable aliases for SYMBOL. If FN returns |
3211 something other than Qzero for some link in the chain, return that | |
3212 immediately. Otherwise return Qzero (which is not a symbol). | |
3213 | |
3214 FN may be called twice on the same symbol if the varalias chain is | |
3215 cyclic. Prevent this by calling follow_varalias_pointers first for its | |
3216 side-effects. | |
3217 | |
3218 Signals a cyclic-variable-indirection error if a cyclic structure is | |
3219 detected. */ | |
3220 | |
3221 static Lisp_Object | |
3222 map_varalias_chain (Lisp_Object symbol, | |
3223 Lisp_Object follow_past_lisp_magic, | |
3224 Lisp_Object (*fn) (Lisp_Object arg)) | |
3225 { | |
3226 #define VARALIAS_INDIRECTION_SUSPICION_LENGTH 16 | |
3227 Lisp_Object tortoise, hare, val, res; | |
3228 int count; | |
3229 | |
3230 assert (fn); | |
3231 | |
3232 /* quick out just in case */ | |
3233 if (!SYMBOL_VALUE_MAGIC_P (XSYMBOL (symbol)->value)) | |
3234 { | |
3235 return (fn)(symbol); | |
3236 } | |
3237 | |
3238 /* Compare implementation of indirect_function(). */ | |
3239 for (hare = tortoise = symbol, count = 0; | |
3240 val = fetch_value_maybe_past_magic (hare, follow_past_lisp_magic), | |
3241 SYMBOL_VALUE_VARALIAS_P (val); | |
3242 hare = symbol_value_varalias_aliasee (XSYMBOL_VALUE_VARALIAS (val)), | |
3243 count++) | |
3244 { | |
3245 res = (fn) (hare); | |
3246 if (!EQ (Qzero, res)) | |
3247 { | |
3248 return res; | |
3249 } | |
3250 | |
3251 if (count < VARALIAS_INDIRECTION_SUSPICION_LENGTH) continue; | |
3252 | |
3253 if (count & 1) | |
3254 tortoise = symbol_value_varalias_aliasee | |
3255 (XSYMBOL_VALUE_VARALIAS (fetch_value_maybe_past_magic | |
3256 (tortoise, follow_past_lisp_magic))); | |
3257 if (EQ (hare, tortoise)) | |
3258 return Fsignal (Qcyclic_variable_indirection, list1 (symbol)); | |
3259 } | |
3260 | |
3261 return (fn) (hare); | |
3262 } | |
3263 | |
3264 /* | |
3265 | |
3266 OED entry, 2nd edition, IPA transliterated using Kirshenbaum: | |
3267 | |
3268 alias ('eIlI@s, '&lI@s), adv. and n. | |
3269 [...] | |
3270 B. n. (with pl. aliases.) | |
3271 1. Another name, an assumed name. | |
3272 1605 Camden Rem. (1614) 147 An Alias or double name cannot preiudice the honest. | |
3273 1831 Edin. Rev. LIII. 364 He has been assuming various aliases. | |
3274 1861 Macaulay Hist. Eng. V. 92 The monk who was sometimes called Harrison | |
3275 and sometimes went by the alias of Johnson. | |
3276 | |
3277 The alias is the fake name. Let's try to follow that usage in our | |
3278 documentation. | |
3279 | |
3280 */ | |
3281 | |
3282 DEFUN ("defvaralias", Fdefvaralias, 2, 3, 0, /* | |
3104 Define a variable as an alias for another variable. | 3283 Define a variable as an alias for another variable. |
3105 Thenceforth, any operations performed on VARIABLE will actually be | 3284 Thenceforth, any operations performed on VARIABLE will actually be |
3106 performed on ALIAS. Both VARIABLE and ALIAS should be symbols. | 3285 performed on ALIASED. Both VARIABLE and ALIASED should be symbols. |
3107 If ALIAS is nil, remove any aliases for VARIABLE. | 3286 If ALIASED is nil and VARIABLE is an existing alias, remove that alias. |
3108 ALIAS can itself be aliased, and the chain of variable aliases | 3287 ALIASED can itself be an alias, and the chain of variable aliases |
3109 will be followed appropriately. | 3288 will be followed appropriately. |
3110 If VARIABLE already has a value, this value will be shadowed | 3289 If VARIABLE already has a value, this value will be shadowed |
3111 until the alias is removed, at which point it will be restored. | 3290 until the alias is removed, at which point it will be restored. |
3112 Currently VARIABLE cannot be a built-in variable, a variable that | 3291 Currently VARIABLE cannot be a built-in variable, a variable that |
3113 has a buffer-local value in any buffer, or the symbols nil or t. | 3292 has a buffer-local value in any buffer, or the symbols nil or t. |
3114 \(ALIAS, however, can be any type of variable.) | 3293 \(ALIASED, however, can be any type of variable.) |
3115 */ | 3294 |
3116 (variable, alias)) | 3295 Optional argument DOCSTRING is documentation for VARIABLE in its use as an |
3296 alias for ALIASED. The XEmacs help code ignores this documentation, using | |
3297 the documentation of ALIASED instead, and the docstring, if specified, is | |
3298 not shadowed in the same way that the value is. Only use it if you know | |
3299 what you're doing. | |
3300 */ | |
3301 (variable, aliased, docstring)) | |
3117 { | 3302 { |
3118 struct symbol_value_varalias *bfwd; | 3303 struct symbol_value_varalias *bfwd; |
3119 Lisp_Object valcontents; | 3304 Lisp_Object valcontents; |
3120 | 3305 |
3121 CHECK_SYMBOL (variable); | 3306 CHECK_SYMBOL (variable); |
3122 reject_constant_symbols (variable, Qunbound, 0, Qt); | 3307 reject_constant_symbols (variable, Qunbound, 0, Qt); |
3123 | 3308 |
3124 valcontents = XSYMBOL (variable)->value; | 3309 valcontents = XSYMBOL (variable)->value; |
3125 | 3310 |
3126 if (NILP (alias)) | 3311 if (NILP (aliased)) |
3127 { | 3312 { |
3128 if (SYMBOL_VALUE_VARALIAS_P (valcontents)) | 3313 if (SYMBOL_VALUE_VARALIAS_P (valcontents)) |
3129 { | 3314 { |
3130 XSYMBOL (variable)->value = | 3315 XSYMBOL (variable)->value = |
3131 symbol_value_varalias_shadowed | 3316 symbol_value_varalias_shadowed |
3132 (XSYMBOL_VALUE_VARALIAS (valcontents)); | 3317 (XSYMBOL_VALUE_VARALIAS (valcontents)); |
3133 } | 3318 } |
3134 return Qnil; | 3319 return Qnil; |
3135 } | 3320 } |
3136 | 3321 |
3137 CHECK_SYMBOL (alias); | 3322 CHECK_SYMBOL (aliased); |
3323 | |
3324 if (!NILP (docstring)) | |
3325 Fput (variable, Qvariable_documentation, docstring); | |
3326 | |
3138 if (SYMBOL_VALUE_VARALIAS_P (valcontents)) | 3327 if (SYMBOL_VALUE_VARALIAS_P (valcontents)) |
3139 { | 3328 { |
3140 /* transmogrify */ | 3329 /* transmogrify */ |
3141 XSYMBOL_VALUE_VARALIAS (valcontents)->aliasee = alias; | 3330 XSYMBOL_VALUE_VARALIAS (valcontents)->aliasee = aliased; |
3142 return Qnil; | 3331 return Qnil; |
3143 } | 3332 } |
3144 | 3333 |
3145 if (SYMBOL_VALUE_MAGIC_P (valcontents) | 3334 if (SYMBOL_VALUE_MAGIC_P (valcontents) |
3146 && !UNBOUNDP (valcontents)) | 3335 && !UNBOUNDP (valcontents)) |
3148 reject_constant_symbols (variable, Qunbound, 0, Qt); | 3337 reject_constant_symbols (variable, Qunbound, 0, Qt); |
3149 | 3338 |
3150 bfwd = | 3339 bfwd = |
3151 XSYMBOL_VALUE_VARALIAS (ALLOC_LISP_OBJECT (symbol_value_varalias)); | 3340 XSYMBOL_VALUE_VARALIAS (ALLOC_LISP_OBJECT (symbol_value_varalias)); |
3152 bfwd->magic.type = SYMVAL_VARALIAS; | 3341 bfwd->magic.type = SYMVAL_VARALIAS; |
3153 bfwd->aliasee = alias; | 3342 bfwd->aliasee = aliased; |
3154 bfwd->shadowed = valcontents; | 3343 bfwd->shadowed = valcontents; |
3155 | 3344 |
3156 valcontents = wrap_symbol_value_magic (bfwd); | 3345 valcontents = wrap_symbol_value_magic (bfwd); |
3157 XSYMBOL (variable)->value = valcontents; | 3346 XSYMBOL (variable)->value = valcontents; |
3158 return Qnil; | 3347 return Qnil; |
3159 } | 3348 } |
3160 | 3349 |
3161 DEFUN ("variable-alias", Fvariable_alias, 1, 2, 0, /* | 3350 DEFUN ("variable-alias", Fvariable_alias, 1, 2, 0, /* |
3162 If VARIABLE is aliased to another variable, return that variable. | 3351 If VARIABLE is an alias of another variable, return that variable. |
3163 VARIABLE should be a symbol. If VARIABLE is not aliased, return nil. | 3352 VARIABLE should be a symbol. If VARIABLE is not an alias, return nil. |
3164 Variable aliases are created with `defvaralias'. See also | 3353 Variable aliases are created with `defvaralias'. See also |
3165 `indirect-variable'. | 3354 `indirect-variable'. |
3166 */ | 3355 */ |
3167 (variable, follow_past_lisp_magic)) | 3356 (variable, follow_past_lisp_magic)) |
3168 { | 3357 { |
3246 #endif | 3435 #endif |
3247 #ifndef Qnull_pointer | 3436 #ifndef Qnull_pointer |
3248 Lisp_Object Qnull_pointer; | 3437 Lisp_Object Qnull_pointer; |
3249 #endif | 3438 #endif |
3250 | 3439 |
3251 #ifndef MC_ALLOC | 3440 #ifndef NEW_GC |
3252 /* some losing systems can't have static vars at function scope... */ | 3441 /* some losing systems can't have static vars at function scope... */ |
3253 static const struct symbol_value_magic guts_of_unbound_marker = | 3442 static const struct symbol_value_magic guts_of_unbound_marker = |
3254 { /* struct symbol_value_magic */ | 3443 { /* struct symbol_value_magic */ |
3255 { /* struct old_lcrecord_header */ | 3444 { /* struct old_lcrecord_header */ |
3256 { /* struct lrecord_header */ | 3445 { /* struct lrecord_header */ |
3264 0, /* free */ | 3453 0, /* free */ |
3265 }, | 3454 }, |
3266 0, /* value */ | 3455 0, /* value */ |
3267 SYMVAL_UNBOUND_MARKER | 3456 SYMVAL_UNBOUND_MARKER |
3268 }; | 3457 }; |
3269 #endif /* not MC_ALLOC */ | 3458 #endif /* not NEW_GC */ |
3270 | 3459 |
3271 void | 3460 void |
3272 init_symbols_once_early (void) | 3461 init_symbols_once_early (void) |
3273 { | 3462 { |
3274 INIT_LISP_OBJECT (symbol); | 3463 INIT_LISP_OBJECT (symbol); |
3296 } | 3485 } |
3297 | 3486 |
3298 { | 3487 { |
3299 /* Required to get around a GCC syntax error on certain | 3488 /* Required to get around a GCC syntax error on certain |
3300 architectures */ | 3489 architectures */ |
3301 #ifdef MC_ALLOC | 3490 #ifdef NEW_GC |
3302 struct symbol_value_magic *tem = (struct symbol_value_magic *) | 3491 struct symbol_value_magic *tem = (struct symbol_value_magic *) |
3303 mc_alloc (sizeof (struct symbol_value_magic)); | 3492 mc_alloc (sizeof (struct symbol_value_magic)); |
3304 MARK_LRECORD_AS_LISP_READONLY (tem); | 3493 MARK_LRECORD_AS_LISP_READONLY (tem); |
3305 MARK_LRECORD_AS_NOT_FREE (tem); | 3494 MARK_LRECORD_AS_NOT_FREE (tem); |
3306 tem->header.type = lrecord_type_symbol_value_forward; | 3495 tem->header.type = lrecord_type_symbol_value_forward; |
3309 tem->type = SYMVAL_UNBOUND_MARKER; | 3498 tem->type = SYMVAL_UNBOUND_MARKER; |
3310 #ifdef ALLOC_TYPE_STATS | 3499 #ifdef ALLOC_TYPE_STATS |
3311 inc_lrecord_stats (sizeof (struct symbol_value_magic), | 3500 inc_lrecord_stats (sizeof (struct symbol_value_magic), |
3312 (const struct lrecord_header *) tem); | 3501 (const struct lrecord_header *) tem); |
3313 #endif /* ALLOC_TYPE_STATS */ | 3502 #endif /* ALLOC_TYPE_STATS */ |
3314 #else /* not MC_ALLOC */ | 3503 #else /* not NEW_GC */ |
3315 const struct symbol_value_magic *tem = &guts_of_unbound_marker; | 3504 const struct symbol_value_magic *tem = &guts_of_unbound_marker; |
3316 #endif /* not MC_ALLOC */ | 3505 #endif /* not NEW_GC */ |
3317 | 3506 |
3318 Qunbound = wrap_symbol_value_magic (tem); | 3507 Qunbound = wrap_symbol_value_magic (tem); |
3319 } | 3508 } |
3320 | 3509 |
3321 XSYMBOL (Qnil)->function = Qunbound; | 3510 XSYMBOL (Qnil)->function = Qunbound; |
3448 #else | 3637 #else |
3449 #define check_sane_subr(subr, sym) /* nothing */ | 3638 #define check_sane_subr(subr, sym) /* nothing */ |
3450 #endif | 3639 #endif |
3451 | 3640 |
3452 #ifdef HAVE_SHLIB | 3641 #ifdef HAVE_SHLIB |
3453 #ifndef MC_ALLOC | 3642 #ifndef NEW_GC |
3454 /* | 3643 /* |
3455 * If we are not in a pure undumped Emacs, we need to make a duplicate of | 3644 * If we are not in a pure undumped Emacs, we need to make a duplicate of |
3456 * the subr. This is because the only time this function will be called | 3645 * the subr. This is because the only time this function will be called |
3457 * in a running Emacs is when a dynamically loaded module is adding a | 3646 * in a running Emacs is when a dynamically loaded module is adding a |
3458 * subr, and we need to make sure that the subr is in allocated, Lisp- | 3647 * subr, and we need to make sure that the subr is in allocated, Lisp- |
3508 memcpy (newsubr, subr, sizeof (Lisp_Subr)); \ | 3697 memcpy (newsubr, subr, sizeof (Lisp_Subr)); \ |
3509 subr->doc = (const char *)newsubr; \ | 3698 subr->doc = (const char *)newsubr; \ |
3510 subr = newsubr; \ | 3699 subr = newsubr; \ |
3511 } \ | 3700 } \ |
3512 } while (0) | 3701 } while (0) |
3513 #else /* MC_ALLOC */ | 3702 #else /* NEW_GC */ |
3514 /* | 3703 /* |
3515 * If we have the new allocator enabled, we do not need to make a | 3704 * If we have the new allocator enabled, we do not need to make a |
3516 * duplicate of the subr. The new allocator already does allocate all | 3705 * duplicate of the subr. The new allocator already does allocate all |
3517 * subrs in Lisp-accessible memory rather than have it in the static | 3706 * subrs in Lisp-accessible memory rather than have it in the static |
3518 * subr struct. | 3707 * subr struct. |
3546 f = XSYMBOL (sym)->function; \ | 3735 f = XSYMBOL (sym)->function; \ |
3547 if (!UNBOUNDP (f) && (!CONSP (f) || !EQ (XCAR (f), Qautoload))) \ | 3736 if (!UNBOUNDP (f) && (!CONSP (f) || !EQ (XCAR (f), Qautoload))) \ |
3548 signal_ferror (Qdll_error, "Attempt to redefine %s", subr_name (subr)); \ | 3737 signal_ferror (Qdll_error, "Attempt to redefine %s", subr_name (subr)); \ |
3549 } \ | 3738 } \ |
3550 } while (0) | 3739 } while (0) |
3551 #endif /* MC_ALLOC */ | 3740 #endif /* NEW_GC */ |
3552 #else /* ! HAVE_SHLIB */ | 3741 #else /* ! HAVE_SHLIB */ |
3553 #define check_module_subr(subr) | 3742 #define check_module_subr(subr) |
3554 #endif | 3743 #endif |
3555 | 3744 |
3556 void | 3745 void |
3700 DEFSUBR (Fglobally_boundp); | 3889 DEFSUBR (Fglobally_boundp); |
3701 DEFSUBR (Ffboundp); | 3890 DEFSUBR (Ffboundp); |
3702 DEFSUBR (Ffset); | 3891 DEFSUBR (Ffset); |
3703 DEFSUBR (Fdefine_function); | 3892 DEFSUBR (Fdefine_function); |
3704 Ffset (intern ("defalias"), intern ("define-function")); | 3893 Ffset (intern ("defalias"), intern ("define-function")); |
3894 DEFSUBR (Fsubr_name); | |
3895 DEFSUBR (Fspecial_form_p); | |
3705 DEFSUBR (Fsetplist); | 3896 DEFSUBR (Fsetplist); |
3706 DEFSUBR (Fsymbol_value_in_buffer); | 3897 DEFSUBR (Fsymbol_value_in_buffer); |
3707 DEFSUBR (Fsymbol_value_in_console); | 3898 DEFSUBR (Fsymbol_value_in_console); |
3708 DEFSUBR (Fbuilt_in_variable_type); | 3899 DEFSUBR (Fbuilt_in_variable_type); |
3709 DEFSUBR (Fsymbol_value); | 3900 DEFSUBR (Fsymbol_value); |
3715 DEFSUBR (Fmake_variable_buffer_local); | 3906 DEFSUBR (Fmake_variable_buffer_local); |
3716 DEFSUBR (Fmake_local_variable); | 3907 DEFSUBR (Fmake_local_variable); |
3717 DEFSUBR (Fkill_local_variable); | 3908 DEFSUBR (Fkill_local_variable); |
3718 DEFSUBR (Fkill_console_local_variable); | 3909 DEFSUBR (Fkill_console_local_variable); |
3719 DEFSUBR (Flocal_variable_p); | 3910 DEFSUBR (Flocal_variable_p); |
3911 DEFSUBR (Fcustom_variable_p); | |
3912 DEFSUBR (Fuser_variable_p); | |
3720 DEFSUBR (Fdefvaralias); | 3913 DEFSUBR (Fdefvaralias); |
3721 DEFSUBR (Fvariable_alias); | 3914 DEFSUBR (Fvariable_alias); |
3722 DEFSUBR (Findirect_variable); | 3915 DEFSUBR (Findirect_variable); |
3723 DEFSUBR (Fvariable_binding_locus); | 3916 DEFSUBR (Fvariable_binding_locus); |
3724 DEFSUBR (Fdontusethis_set_symbol_value_handler); | 3917 DEFSUBR (Fdontusethis_set_symbol_value_handler); |