Inline getter and setter functions for per-buffer values.
authorDmitry Antipov <dmantipov@yandex.ru>
Mon, 20 Aug 2012 07:42:06 +0000 (11:42 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Mon, 20 Aug 2012 07:42:06 +0000 (11:42 +0400)
* buffer.h (per_buffer_default, set_per_buffer_default)
(per_buffer_value, set_per_buffer_value): New functions.
(PER_BUFFER_VALUE, PER_BUFFER_DEFAULT): Remove.
* buffer.c, data.c: Adjust users.

src/ChangeLog
src/buffer.c
src/buffer.h
src/data.c

index 8cffccd..c5ab370 100644 (file)
@@ -1,3 +1,11 @@
+2012-08-20  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Inline getter and setter functions for per-buffer values.
+       * buffer.h (per_buffer_default, set_per_buffer_default)
+       (per_buffer_value, set_per_buffer_value): New functions.
+       (PER_BUFFER_VALUE, PER_BUFFER_DEFAULT): Remove.
+       * buffer.c, data.c: Adjust users.
+
 2012-08-20  Juanma Barranquero  <lekktu@gmail.com>
 
        * makefile.w32-in ($(BLD)/vm-limit.$(O)): Update dependencies.
index 9373e3c..c900ef8 100644 (file)
@@ -695,7 +695,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
       if (offset == PER_BUFFER_VAR_OFFSET (name))
        continue;
 
-      obj = PER_BUFFER_VALUE (from, offset);
+      obj = per_buffer_value (from, offset);
       if (MARKERP (obj) && XMARKER (obj)->buffer == from)
        {
          struct Lisp_Marker *m = XMARKER (obj);
@@ -704,7 +704,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
          XMARKER (obj)->insertion_type = m->insertion_type;
        }
 
-      PER_BUFFER_VALUE (to, offset) = obj;
+      set_per_buffer_value (to, offset, obj);
     }
 
   memcpy (to->local_flags, from->local_flags, sizeof to->local_flags);
@@ -1063,7 +1063,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
       if ((idx > 0
           && (permanent_too
               || buffer_permanent_local_flags[idx] == 0)))
-       PER_BUFFER_VALUE (b, offset) = PER_BUFFER_DEFAULT (offset);
+       set_per_buffer_value (b, offset, per_buffer_default (offset));
     }
 }
 
@@ -1239,7 +1239,7 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
       {
        union Lisp_Fwd *fwd = SYMBOL_FWD (sym);
        if (BUFFER_OBJFWDP (fwd))
-         result = PER_BUFFER_VALUE (buf, XBUFFER_OBJFWD (fwd)->offset);
+         result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset);
        else
          result = Fdefault_value (variable);
        break;
@@ -1319,7 +1319,7 @@ No argument or nil as argument means use current buffer as BUFFER.  */)
            && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
          {
            Lisp_Object sym = PER_BUFFER_SYMBOL (offset);
-           Lisp_Object val = PER_BUFFER_VALUE (buf, offset);
+           Lisp_Object val = per_buffer_value (buf, offset);
            result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val),
                            result);
          }
index 510a8e5..6c63c52 100644 (file)
@@ -1203,18 +1203,36 @@ extern int last_per_buffer_idx;
 #define PER_BUFFER_IDX(OFFSET) \
       XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags))
 
-/* Return the default value of the per-buffer variable at offset
-   OFFSET in the buffer structure.  */
+/* Functions to get and set default value of the per-buffer
+   variable at offset OFFSET in the buffer structure.  */
 
-#define PER_BUFFER_DEFAULT(OFFSET) \
-      (*(Lisp_Object *)((OFFSET) + (char *) &buffer_defaults))
+BUFFER_INLINE Lisp_Object
+per_buffer_default (int offset)
+{
+  return *(Lisp_Object *)(offset + (char *) &buffer_defaults);
+}
 
-/* Return the buffer-local value of the per-buffer variable at offset
-   OFFSET in the buffer structure.  */
+BUFFER_INLINE void
+set_per_buffer_default (int offset, Lisp_Object value)
+{
+  *(Lisp_Object *)(offset + (char *) &buffer_defaults) = value;
+}
+
+/* Functions to get and set buffer-local value of the per-buffer
+   variable at offset OFFSET in the buffer structure.  */
+
+BUFFER_INLINE Lisp_Object
+per_buffer_value (struct buffer *b, int offset)
+{
+  return *(Lisp_Object *)(offset + (char *) b);
+}
+
+BUFFER_INLINE void
+set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
+{
+  *(Lisp_Object *)(offset + (char *) b) = value;
+}
 
-#define PER_BUFFER_VALUE(BUFFER, OFFSET) \
-      (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER)))
-\f
 /* Downcase a character C, or make no change if that cannot be done.  */
 BUFFER_INLINE int
 downcase (int c)
index 6dd852d..f812c28 100644 (file)
@@ -847,7 +847,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
       return *XOBJFWD (valcontents)->objvar;
 
     case Lisp_Fwd_Buffer_Obj:
-      return PER_BUFFER_VALUE (current_buffer,
+      return per_buffer_value (current_buffer,
                               XBUFFER_OBJFWD (valcontents)->offset);
 
     case Lisp_Fwd_Kboard_Obj:
@@ -919,7 +919,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
              b = XBUFFER (lbuf);
 
              if (! PER_BUFFER_VALUE_P (b, idx))
-               PER_BUFFER_VALUE (b, offset) = newval;
+               set_per_buffer_value (b, offset, newval);
            }
        }
       break;
@@ -937,7 +937,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
 
        if (buf == NULL)
          buf = current_buffer;
-       PER_BUFFER_VALUE (buf, offset) = newval;
+       set_per_buffer_value (buf, offset, newval);
       }
       break;
 
@@ -1309,7 +1309,7 @@ default_value (Lisp_Object symbol)
          {
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
            if (PER_BUFFER_IDX (offset) != 0)
-             return PER_BUFFER_DEFAULT (offset);
+             return per_buffer_default (offset);
          }
 
        /* For other variables, get the current value.  */
@@ -1396,7 +1396,7 @@ for this variable.  */)
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
            int idx = PER_BUFFER_IDX (offset);
 
-           PER_BUFFER_DEFAULT (offset) = value;
+           set_per_buffer_default (offset, value);
 
            /* If this variable is not always local in all buffers,
               set it in the buffers that don't nominally have a local value.  */
@@ -1406,7 +1406,7 @@ for this variable.  */)
 
                FOR_EACH_BUFFER (b)
                  if (!PER_BUFFER_VALUE_P (b, idx))
-                   PER_BUFFER_VALUE (b, offset) = value;
+                   set_per_buffer_value (b, offset, value);
              }
            return value;
          }
@@ -1705,8 +1705,8 @@ From now on the default value will apply in this buffer.  Return VARIABLE.  */)
            if (idx > 0)
              {
                SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
-               PER_BUFFER_VALUE (current_buffer, offset)
-                 = PER_BUFFER_DEFAULT (offset);
+               set_per_buffer_value (current_buffer, offset,
+                                     per_buffer_default (offset));
              }
          }
        return variable;