comparison src/symbols.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents e121b013d1f0
children a2f645c6b9f8
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
2015 } 2015 }
2016 } 2016 }
2017 2017
2018 { 2018 {
2019 struct symbol_value_buffer_local *bfwd 2019 struct symbol_value_buffer_local *bfwd
2020 = alloc_lcrecord (sizeof (struct symbol_value_buffer_local), 2020 = alloc_lcrecord_type (struct symbol_value_buffer_local,
2021 lrecord_symbol_value_buffer_local); 2021 lrecord_symbol_value_buffer_local);
2022 Lisp_Object foo = Qnil; 2022 Lisp_Object foo = Qnil;
2023 bfwd->magic.type = SYMVAL_BUFFER_LOCAL; 2023 bfwd->magic.type = SYMVAL_BUFFER_LOCAL;
2024 2024
2025 bfwd->default_value = find_symbol_value (variable); 2025 bfwd->default_value = find_symbol_value (variable);
2026 bfwd->current_value = valcontents; 2026 bfwd->current_value = valcontents;
2122 abort (); 2122 abort ();
2123 } 2123 }
2124 } 2124 }
2125 2125
2126 /* Make sure variable is set up to hold per-buffer values */ 2126 /* Make sure variable is set up to hold per-buffer values */
2127 bfwd = alloc_lcrecord (sizeof (struct symbol_value_buffer_local), 2127 bfwd = alloc_lcrecord_type (struct symbol_value_buffer_local,
2128 lrecord_symbol_value_buffer_local); 2128 lrecord_symbol_value_buffer_local);
2129 bfwd->magic.type = SYMVAL_SOME_BUFFER_LOCAL; 2129 bfwd->magic.type = SYMVAL_SOME_BUFFER_LOCAL;
2130 2130
2131 bfwd->current_buffer = Qnil; 2131 bfwd->current_buffer = Qnil;
2132 bfwd->current_alist_element = Qnil; 2132 bfwd->current_alist_element = Qnil;
2133 bfwd->current_value = valcontents; 2133 bfwd->current_value = valcontents;
2660 magic behavior is provided. HANDLER-TYPE is a symbol specifying 2660 magic behavior is provided. HANDLER-TYPE is a symbol specifying
2661 which behavior is being controlled, and HANDLER is the function 2661 which behavior is being controlled, and HANDLER is the function
2662 that will be called to control this behavior. HARG is a 2662 that will be called to control this behavior. HARG is a
2663 value that will be passed to HANDLER but is otherwise 2663 value that will be passed to HANDLER but is otherwise
2664 uninterpreted. KEEP-EXISTING specifies what to do with existing 2664 uninterpreted. KEEP-EXISTING specifies what to do with existing
2665 handlers of the same type; nil means \"erase them all\", t means 2665 handlers of the same type; nil means "erase them all", t means
2666 \"keep them but insert at the beginning\", the list (t) means 2666 "keep them but insert at the beginning", the list (t) means
2667 \"keep them but insert at the end\", a function means \"keep 2667 "keep them but insert at the end", a function means "keep
2668 them but insert before the specified function\", a list containing 2668 them but insert before the specified function", a list containing
2669 a function means \"keep them but insert after the specified 2669 a function means "keep them but insert after the specified
2670 function\". 2670 function".
2671 2671
2672 You can specify magic behavior for any type of variable at all, 2672 You can specify magic behavior for any type of variable at all,
2673 and for any handler types that are unspecified, the standard 2673 and for any handler types that are unspecified, the standard
2674 behavior applies. This allows you, for example, to use 2674 behavior applies. This allows you, for example, to use
2675 `defvaralias' in conjunction with this function. (For that 2675 `defvaralias' in conjunction with this function. (For that
2876 CHECK_SYMBOL (handler_type); 2876 CHECK_SYMBOL (handler_type);
2877 htype = decode_magic_handler_type (handler_type); 2877 htype = decode_magic_handler_type (handler_type);
2878 valcontents = XSYMBOL (variable)->value; 2878 valcontents = XSYMBOL (variable)->value;
2879 if (!SYMBOL_VALUE_LISP_MAGIC_P (valcontents)) 2879 if (!SYMBOL_VALUE_LISP_MAGIC_P (valcontents))
2880 { 2880 {
2881 bfwd = alloc_lcrecord (sizeof (struct symbol_value_lisp_magic), 2881 bfwd = alloc_lcrecord_type (struct symbol_value_lisp_magic,
2882 lrecord_symbol_value_lisp_magic); 2882 lrecord_symbol_value_lisp_magic);
2883 bfwd->magic.type = SYMVAL_LISP_MAGIC; 2883 bfwd->magic.type = SYMVAL_LISP_MAGIC;
2884 for (i = 0; i < MAGIC_HANDLER_MAX; i++) 2884 for (i = 0; i < MAGIC_HANDLER_MAX; i++)
2885 { 2885 {
2886 bfwd->handler[i] = Qnil; 2886 bfwd->handler[i] = Qnil;
2887 bfwd->harg[i] = Qnil; 2887 bfwd->harg[i] = Qnil;
3016 if (SYMBOL_VALUE_MAGIC_P (valcontents) 3016 if (SYMBOL_VALUE_MAGIC_P (valcontents)
3017 && !UNBOUNDP (valcontents)) 3017 && !UNBOUNDP (valcontents))
3018 signal_simple_error ("Variable is magic and cannot be aliased", variable); 3018 signal_simple_error ("Variable is magic and cannot be aliased", variable);
3019 reject_constant_symbols (variable, Qunbound, 0, Qt); 3019 reject_constant_symbols (variable, Qunbound, 0, Qt);
3020 3020
3021 bfwd = alloc_lcrecord (sizeof (struct symbol_value_varalias), 3021 bfwd = alloc_lcrecord_type (struct symbol_value_varalias,
3022 lrecord_symbol_value_varalias); 3022 lrecord_symbol_value_varalias);
3023 bfwd->magic.type = SYMVAL_VARALIAS; 3023 bfwd->magic.type = SYMVAL_VARALIAS;
3024 bfwd->aliasee = alias; 3024 bfwd->aliasee = alias;
3025 bfwd->shadowed = valcontents; 3025 bfwd->shadowed = valcontents;
3026 3026
3027 XSETSYMBOL_VALUE_MAGIC (valcontents, bfwd); 3027 XSETSYMBOL_VALUE_MAGIC (valcontents, bfwd);
3137 { 3137 {
3138 /* This might happen on DATA_SEG_BITS machines. */ 3138 /* This might happen on DATA_SEG_BITS machines. */
3139 /* abort (); */ 3139 /* abort (); */
3140 /* Can't represent a pointer to constant C data using a Lisp_Object. 3140 /* Can't represent a pointer to constant C data using a Lisp_Object.
3141 So heap-allocate it. */ 3141 So heap-allocate it. */
3142 struct symbol_value_magic *urk = xmalloc (sizeof (*urk)); 3142 struct symbol_value_magic *urk = xnew (struct symbol_value_magic);
3143 memcpy (urk, &guts_of_unbound_marker, sizeof (*urk)); 3143 memcpy (urk, &guts_of_unbound_marker, sizeof (*urk));
3144 XSETSYMBOL_VALUE_MAGIC (Qunbound, urk); 3144 XSETSYMBOL_VALUE_MAGIC (Qunbound, urk);
3145 } 3145 }
3146 3146
3147 XSYMBOL (Qnil)->function = Qunbound; 3147 XSYMBOL (Qnil)->function = Qunbound;
3296 strlen (namestring), 3296 strlen (namestring),
3297 1), 3297 1),
3298 Qnil); 3298 Qnil);
3299 3299
3300 /* Check that magic points somewhere we can represent as a Lisp pointer */ 3300 /* Check that magic points somewhere we can represent as a Lisp pointer */
3301 XSETOBJ (kludge, Lisp_Record, magic); 3301 XSETOBJ (kludge, Lisp_Type_Record, magic);
3302 if (magic != (CONST void *) XPNTR (kludge)) 3302 if (magic != (CONST void *) XPNTR (kludge))
3303 { 3303 {
3304 /* This might happen on DATA_SEG_BITS machines. */ 3304 /* This might happen on DATA_SEG_BITS machines. */
3305 /* abort (); */ 3305 /* abort (); */
3306 /* Copy it to somewhere which is representable. */ 3306 /* Copy it to somewhere which is representable. */
3307 void *f = xmalloc (sizeof_magic); 3307 void *f = xmalloc (sizeof_magic);
3308 memcpy (f, magic, sizeof_magic); 3308 memcpy (f, magic, sizeof_magic);
3309 XSETOBJ (XSYMBOL (sym)->value, Lisp_Record, f); 3309 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, f);
3310 } 3310 }
3311 else 3311 else
3312 XSETOBJ (XSYMBOL (sym)->value, Lisp_Record, magic); 3312 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, magic);
3313 } 3313 }
3314 3314
3315 void 3315 void
3316 vars_of_symbols (void) 3316 vars_of_symbols (void)
3317 { 3317 {