+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.
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);
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);
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));
}
}
{
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;
&& 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);
}
#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)
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:
b = XBUFFER (lbuf);
if (! PER_BUFFER_VALUE_P (b, idx))
- PER_BUFFER_VALUE (b, offset) = newval;
+ set_per_buffer_value (b, offset, newval);
}
}
break;
if (buf == NULL)
buf = current_buffer;
- PER_BUFFER_VALUE (buf, offset) = newval;
+ set_per_buffer_value (buf, offset, newval);
}
break;
{
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. */
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. */
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;
}
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;