]> git.eshelyaron.com Git - emacs.git/commitdiff
Use SYMBOL_VALUE/SET_SYMBOL_VALUE macros instead of accessing
authorGerd Moellmann <gerd@gnu.org>
Thu, 4 Oct 2001 08:57:51 +0000 (08:57 +0000)
committerGerd Moellmann <gerd@gnu.org>
Thu, 4 Oct 2001 08:57:51 +0000 (08:57 +0000)
symbols' value directly.

src/ChangeLog
src/abbrev.c
src/buffer.c
src/coding.c
src/fns.c
src/frame.c
src/keyboard.c
src/minibuf.c
src/sunfns.c
src/w16select.c

index bc2c8c2bfb5c8a588b2794a68eb76b255791edf1..268d0b4c186ece631de94b679aaf3b4c74a712b4 100644 (file)
@@ -1,3 +1,63 @@
+2001-10-04  Gerd Moellmann  <gerd@gnu.org>
+
+       This adds `defvaralias' and `indirect-variable'.  Changes not
+       directly related to this feature are there to gain the same
+       performance again as before variable aliases.  
+
+       You must use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros in C
+       code to get and set symbol values, to take defvaralias into
+       account.
+       
+       (Note: the new `constant' bit-flag in symbols would make it
+       possible to define arbitrary read-only variables, e.g. with
+       `defconst'.)
+
+       Documentation is in lispref/variables.texi.
+
+       * lisp.h (enum symbol_interned): New enumeration.
+       (struct Lisp_Symbol): Remove member `obarray', add
+       `indirect_variable', `constant', and `interned'.
+       (SYMBOL_INTERNED_P, SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P)
+       (SYMBOL_CONSTANT_P, SYMBOL_VALUE, SET_SYMBOL_VALUE): New macros.
+       (indirect_variable): Add prototype.
+
+       * print.c (print_preprocess, print_object): Test internedness of
+       symbols differently.
+
+       * lread.c (Fintern, Funintern): Set symbol's interned and constant
+       bit-fields.
+       (init_obarray): Likewise for t and nil.
+
+       * eval.c Use SYMBOL_VALUE/SET_SYMBOL_VALUE.
+       (Fdefvaralias): New function.
+       (specbind): Simplify the test if symbol is a constant.
+       (syms_of_eval): Defsubr Fdefvaralias.
+
+       * data.c: Use SYMBOL_VALUE/SET_SYMBOL_VALUE.
+       (Qcyclic_variable_indirection): New variable.
+       (Fkeywordp): Check for internedness differently.
+       (Fmakunbound): Simplify the test if symbol is a constant.
+       (indirect_variable, Findirect_variable): New functions.
+       (swap_in_symval_forwarding): If SYMBOL is an alias, use the
+       aliased symbol.
+       (let_shadows_buffer_binding_p): Check for variable aliases.
+       (set_internal): Simplify the test if SYMBOL is a constant.  If
+       SYMBOL has a buffer-local value and is an alias, use the aliased
+       symbol instead.
+       (syms_of_data): Initialize Qcyclic_variable_indirection and defsubr
+       Sindirect_variable.
+
+       * bytecode.c (Fbyte_code) <varref>: Use SYMBOL_VALUE.
+       (Fbyte_code) <varset>: Simplify the test if symbol's value can be
+       set directly.
+
+       * alloc.c (Fmake_symbol): Adapt to changes of struct Lisp_Symbol.
+
+       * abbrev.c, buffer.c, coding.c, fns.c, frame.c, keyboard.c: 
+       * minibuf.c, sunfns.c, w16select.c: Use SYMBOL_VALUE/
+       SET_SYMBOL_VALUE macros instead of accessing symbol values
+       directly.
+
 2001-10-03  Miles Bader  <miles@gnu.org>
 
        * callproc.c (syms_of_callproc): Explicitly state in the
index f30986db3434544abf982c99bef37ee41d674eb5..06bb1f98e5e409856742f2812a68df739f2768b3 100644 (file)
@@ -1,5 +1,6 @@
 /* Primitives for word-abbrev mode.
-   Copyright (C) 1985, 1986, 1993, 1996, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993, 1996, 1998, 2001
+   Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -128,7 +129,7 @@ which is incremented each time the abbrev is used.")
 
   sym = Fintern (name, table);
 
-  oexp = XSYMBOL (sym)->value;
+  oexp = SYMBOL_VALUE (sym);
   ohook = XSYMBOL (sym)->function;
   if (!((EQ (oexp, expansion)
         || (STRINGP (oexp) && STRINGP (expansion)
@@ -189,12 +190,13 @@ The default is to try buffer's mode-specific abbrev table, then global table.")
       sym = Qnil;
       if (!NILP (current_buffer->abbrev_table))
        sym = Fintern_soft (abbrev, current_buffer->abbrev_table);
-      if (NILP (XSYMBOL (sym)->value))
+      if (NILP (SYMBOL_VALUE (sym)))
        sym = Qnil;
       if (NILP (sym))
        sym = Fintern_soft (abbrev, Vglobal_abbrev_table);
     }
-  if (NILP (XSYMBOL (sym)->value)) return Qnil;
+  if (NILP (SYMBOL_VALUE (sym)))
+    return Qnil;
   return sym;
 }
 
@@ -290,10 +292,10 @@ Returns the abbrev symbol, if expansion took place.")
                    wordend - wordstart, wordend_byte - wordstart_byte);
   else
     XSETFASTINT (sym, 0);
-  if (INTEGERP (sym) || NILP (XSYMBOL (sym)->value))
+  if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
     sym = oblookup (Vglobal_abbrev_table, buffer,
                    wordend - wordstart, wordend_byte - wordstart_byte);
-  if (INTEGERP (sym) || NILP (XSYMBOL (sym)->value))
+  if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
     return value;
 
   if (INTERACTIVE && !EQ (minibuf_window, selected_window))
@@ -318,7 +320,7 @@ Returns the abbrev symbol, if expansion took place.")
 
   /* If this abbrev has an expansion, delete the abbrev
      and insert the expansion.  */
-  expansion = XSYMBOL (sym)->value;
+  expansion = SYMBOL_VALUE (sym);
   if (STRINGP (expansion))
     {
       SET_PT (wordstart);
@@ -404,7 +406,7 @@ is not undone.")
       Lisp_Object val;
       int zv_before;
 
-      val = XSYMBOL (Vlast_abbrev)->value;
+      val = SYMBOL_VALUE (Vlast_abbrev);
       if (!STRINGP (val))
        error ("value of abbrev-symbol must be a string");
       zv_before = ZV;
@@ -426,13 +428,13 @@ write_abbrev (sym, stream)
      Lisp_Object sym, stream;
 {
   Lisp_Object name;
-  if (NILP (XSYMBOL (sym)->value))
+  if (NILP (SYMBOL_VALUE (sym)))
     return;
   insert ("    (", 5);
   XSETSTRING (name, XSYMBOL (sym)->name);
   Fprin1 (name, stream);
   insert (" ", 1);
-  Fprin1 (XSYMBOL (sym)->value, stream);
+  Fprin1 (SYMBOL_VALUE (sym), stream);
   insert (" ", 1);
   Fprin1 (XSYMBOL (sym)->function, stream);
   insert (" ", 1);
@@ -446,14 +448,14 @@ describe_abbrev (sym, stream)
 {
   Lisp_Object one;
 
-  if (NILP (XSYMBOL (sym)->value))
+  if (NILP (SYMBOL_VALUE (sym)))
     return;
   one = make_number (1);
   Fprin1 (Fsymbol_name (sym), stream);
   Findent_to (make_number (15), one);
   Fprin1 (XSYMBOL (sym)->plist, stream);
   Findent_to (make_number (20), one);
-  Fprin1 (XSYMBOL (sym)->value, stream);
+  Fprin1 (SYMBOL_VALUE (sym), stream);
   if (!NILP (XSYMBOL (sym)->function))
     {
       Findent_to (make_number (45), one);
index a20b2250209ee01d35bd2c6a13d01c79728f4ac0..198139019ea75f8d493d55f719ac2dda4753433f 100644 (file)
@@ -1683,7 +1683,7 @@ set_buffer_internal_1 (b)
 
   for (tail = b->local_var_alist; !NILP (tail); tail = XCDR (tail))
     {
-      valcontents = XSYMBOL (XCAR (XCAR (tail)))->value;
+      valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
       if ((BUFFER_LOCAL_VALUEP (valcontents)
           || SOME_BUFFER_LOCAL_VALUEP (valcontents))
          && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
@@ -1698,7 +1698,7 @@ set_buffer_internal_1 (b)
   if (old_buf)
     for (tail = old_buf->local_var_alist; !NILP (tail); tail = XCDR (tail))
       {
-       valcontents = XSYMBOL (XCAR (XCAR (tail)))->value;
+       valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
        if ((BUFFER_LOCAL_VALUEP (valcontents)
             || SOME_BUFFER_LOCAL_VALUEP (valcontents))
            && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
@@ -2260,26 +2260,26 @@ swap_out_buffer_local_variables (b)
       sym = XCAR (XCAR (alist));
 
       /* Need not do anything if some other buffer's binding is now encached.  */
-      tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer;
+      tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer;
       if (BUFFERP (tem) && XBUFFER (tem) == current_buffer)
        {
          /* Symbol is set up for this buffer's old local value.
             Set it up for the current buffer with the default value.  */
 
-         tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr;
+         tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->cdr;
          /* Store the symbol's current value into the alist entry
             it is currently set up for.  This is so that, if the
             local is marked permanent, and we make it local again
             later in Fkill_all_local_variables, we don't lose the value.  */
          XCDR (XCAR (tem))
-           = do_symval_forwarding (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->realvalue);
+           = do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue);
          /* Switch to the symbol's default-value alist entry.  */
          XCAR (tem) = tem;
          /* Mark it as current for buffer B.  */
-         XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer = buffer;
+         XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer;
          /* Store the current value into any forwarding in the symbol.  */
          store_symval_forwarding (sym,
-                                  XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->realvalue,
+                                  XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue,
                                   XCDR (tem), NULL);
        }
     }
index b59bbce7edd14f6da07667c01bc868f8371efda8..43f1867d9f8d622d29863ecbacf8fe9ee2959fd2 100644 (file)
@@ -4110,7 +4110,7 @@ detect_coding (coding, src, src_bytes)
   if (! mask)
     idx = CODING_CATEGORY_IDX_RAW_TEXT;
 
-  val = XSYMBOL (XVECTOR (Vcoding_category_table)->contents[idx])->value;
+  val = SYMBOL_VALUE (XVECTOR (Vcoding_category_table)->contents[idx]);
 
   if (coding->eol_type != CODING_EOL_UNDECIDED)
     {
@@ -6881,7 +6881,7 @@ call this function")
     {
       Lisp_Object val;
 
-      val = XSYMBOL (XVECTOR (Vcoding_category_table)->contents[i])->value;
+      val = SYMBOL_VALUE (XVECTOR (Vcoding_category_table)->contents[i]);
       if (!NILP (val))
        {
          if (! coding_system_table[i])
index f99ab1514428f0f7d686d8ae22516532e6d19fb2..b8cc9566d22f76208de5375c3c76a4759647136c 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -5020,7 +5020,7 @@ guesswork fails.  Normally, an error is signaled in such case.")
 
          if (STRING_MULTIBYTE (object))
            /* use default, we can't guess correct value */
-           coding_system = XSYMBOL (XCAR (Vcoding_category_list))->value;
+           coding_system = SYMBOL_VALUE (XCAR (Vcoding_category_list));
          else 
            coding_system = Qraw_text;
        }
index 818402bdadebe366ef6bb63c8022ce807e4f8b4e..3fb507b7752e56179e6cead5be1e7d3e2e2805ff 100644 (file)
@@ -1915,7 +1915,7 @@ store_frame_param (f, prop, val)
   if (SYMBOLP (prop))
     {
       Lisp_Object valcontents;
-      valcontents = XSYMBOL (prop)->value;
+      valcontents = SYMBOL_VALUE (prop);
       if ((BUFFER_LOCAL_VALUEP (valcontents)
           || SOME_BUFFER_LOCAL_VALUEP (valcontents))
          && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
index c3847bf1451c8a53d5f49f9598ddf85140372306..1f5f6de50eabfa045854c5d2dff578378bb653b1 100644 (file)
@@ -10717,7 +10717,7 @@ This is measured in microseconds.");
     "Normal hook run when clearing the echo area.");
 #endif
   Qecho_area_clear_hook = intern ("echo-area-clear-hook");
-  XSYMBOL (Qecho_area_clear_hook)->value = Qnil;
+  SET_SYMBOL_VALUE (Qecho_area_clear_hook, Qnil);
 
   DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
     "t means menu bar, specified Lucid style, needs to be recomputed.");
index 51ea67a10e85f5d1bd5c5f68531e05db05cedefd..da681c39cf26e4b99f425646013e723547f77610 100644 (file)
@@ -602,7 +602,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
       Lisp_Object histval;
 
       /* If variable is unbound, make it nil.  */
-      if (EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound))
+      if (EQ (SYMBOL_VALUE (Vminibuffer_history_variable), Qunbound))
        Fset (Vminibuffer_history_variable, Qnil);
 
       histval = Fsymbol_value (Vminibuffer_history_variable);
index 065e2490828fa1d54f006578c308f7ba04a062a6..c5261002576d3c2aee4c27b1557912b0258385df 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions for Sun Windows menus and selection buffer.
-   Copyright (C) 1987, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1999, 2001 Free Software Foundation, Inc.
 
 This file is probably totally obsolete.  In any case, the FSF is
 unwilling to support it.  We agreed to include it in our distribution
@@ -366,7 +366,7 @@ sun_item_create (Pair)
   CHECK_STRING(String, 0);
   Value = Fcdr(Pair);
   if (SYMBOLP (Value))
-    Value = XSYMBOL(Value)->value;
+    Value = SYMBOL_VALUE (Value);
   if (VECTORP (Value)) {
     submenu = sun_menu_create (Value);
     menu_item = menu_create_item
index df739a1356c919a53402d6edbff2f40531d488a0..f92e1a8c173c79fe500f7138c8038a7f1ded64b8 100644 (file)
@@ -1,5 +1,5 @@
 /* 16-bit Windows Selection processing for emacs on MS-Windows
-   Copyright (C) 1996, 1997 Free Software Foundation.
+   Copyright (C) 1996, 1997, 2001 Free Software Foundation.
    
 This file is part of GNU Emacs.
 
@@ -714,8 +714,8 @@ and t is the same as `SECONDARY'.")
      into the clipboard if we run under Windows, so we cannot check
      the clipboard alone.)  */
   if ((EQ (selection, Qnil) || EQ (selection, QPRIMARY))
-      && ! NILP (XSYMBOL (Fintern_soft (build_string ("kill-ring"),
-                                       Qnil))->value))
+      && ! NILP (SYMBOL_VALUE (Fintern_soft (build_string ("kill-ring"),
+                                            Qnil))))
     return Qt;
 
   if (EQ (selection, QCLIPBOARD))