[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/10] Reorder buffer.h for upcoming rework of BVAR
From: |
Spencer Baugh |
Subject: |
[PATCH 07/10] Reorder buffer.h for upcoming rework of BVAR |
Date: |
Thu, 19 Nov 2020 10:38:11 -0500 |
This is just rearranging these constants so that everything is
properly in scope for the new definition of BVAR.
---
src/buffer.h | 288 +++++++++++++++++++++++++--------------------------
1 file changed, 144 insertions(+), 144 deletions(-)
diff --git a/src/buffer.h b/src/buffer.h
index ae2d785aff..6e384640b7 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -280,13 +280,6 @@ struct buffer_text
bool_bf redisplay : 1;
};
-/* Most code should use this macro to access Lisp fields in struct buffer. */
-
-#define BVAR(buf, field) ((void)0, (buf)->field ## _)
-
-/* Access a BVAR from buffer_defaults */
-#define BVAR_DEFAULT(field) (buffer_defaults.field ## _)
-
/* Max number of builtin per-buffer variables. */
enum { MAX_PER_BUFFER_VARS = 50 };
@@ -695,6 +688,150 @@ struct buffer
Lisp_Object undo_list_;
};
+/* This structure holds the default values of the buffer-local variables
+ that have special slots in each buffer.
+ The default value occupies the same slot in this structure
+ as an individual buffer's value occupies in that buffer.
+ Setting the default value also goes through the alist of buffers
+ and stores into each buffer that does not say it has a local value. */
+
+extern struct buffer buffer_defaults;
+
+/* This structure marks which slots in a buffer have corresponding
+ default values in buffer_defaults.
+ Each such slot has a nonzero value in this structure.
+ The value has only one nonzero bit.
+
+ When a buffer has its own local value for a slot,
+ the entry for that slot (found in the same slot in this structure)
+ is turned on in the buffer's local_flags array.
+
+ If a slot in this structure is zero, then even though there may
+ be a Lisp-level local variable for the slot, it has no default value,
+ and the corresponding slot in buffer_defaults is not used. */
+
+
+extern struct buffer buffer_local_flags;
+
+/* For each buffer slot, this points to the Lisp symbol name
+ for that slot in the current buffer. It is 0 for slots
+ that don't have such names. */
+
+extern struct buffer buffer_local_symbols;
+
+/***********************************************************************
+ Buffer-local Variables
+ ***********************************************************************/
+
+/* Return the offset in bytes of member VAR of struct buffer
+ from the start of a buffer structure. */
+
+#define PER_BUFFER_VAR_OFFSET(VAR) \
+ offsetof (struct buffer, VAR ## _)
+
+/* Used to iterate over normal Lisp_Object fields of struct buffer (all
+ Lisp_Objects except undo_list). If you add, remove, or reorder
+ Lisp_Objects in a struct buffer, make sure that this is still correct. */
+
+#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \
+ for (offset = PER_BUFFER_VAR_OFFSET (name); \
+ offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
+ offset += word_size)
+
+/* Return the index of buffer-local variable VAR. Each per-buffer
+ variable has an index > 0 associated with it, except when it always
+ has buffer-local values, in which case the index is -1. If this is
+ 0, this is a bug and means that the slot of VAR in
+ buffer_local_flags wasn't initialized. */
+
+#define PER_BUFFER_VAR_IDX(VAR) \
+ PER_BUFFER_IDX (PER_BUFFER_VAR_OFFSET (VAR))
+
+extern bool valid_per_buffer_idx (int);
+
+/* Value is true if the variable with index IDX has a local value
+ in buffer B. */
+
+INLINE bool
+PER_BUFFER_VALUE_P (struct buffer *b, int idx)
+{
+ eassert (valid_per_buffer_idx (idx));
+ return b->local_flags[idx];
+}
+
+/* Set whether per-buffer variable with index IDX has a buffer-local
+ value in buffer B. VAL zero means it hasn't. */
+
+INLINE void
+SET_PER_BUFFER_VALUE_P (struct buffer *b, int idx, bool val)
+{
+ eassert (valid_per_buffer_idx (idx));
+ b->local_flags[idx] = val;
+}
+
+/* Return the index value of the per-buffer variable at offset OFFSET
+ in the buffer structure.
+
+ If the slot OFFSET has a corresponding default value in
+ buffer_defaults, the index value is positive and has only one
+ nonzero bit. When a buffer has its own local value for a slot, the
+ bit for that slot (found in the same slot in this structure) is
+ turned on in the buffer's local_flags array.
+
+ If the index value is -1, even though there may be a
+ DEFVAR_PER_BUFFER for the slot, there is no default value for it;
+ and the corresponding slot in buffer_defaults is not used.
+
+ If the index value is -2, then there is no DEFVAR_PER_BUFFER for
+ the slot, but there is a default value which is copied into each
+ new buffer.
+
+ If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
+ zero, that is a bug. */
+
+INLINE int
+PER_BUFFER_IDX (ptrdiff_t offset)
+{
+ return XFIXNUM (*(Lisp_Object *) (offset + (char *) &buffer_local_flags));
+}
+
+/* Functions to get and set default value of the per-buffer
+ variable at offset OFFSET in the buffer structure. */
+
+INLINE Lisp_Object
+per_buffer_default (int offset)
+{
+ return *(Lisp_Object *)(offset + (char *) &buffer_defaults);
+}
+
+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. */
+
+INLINE Lisp_Object
+per_buffer_value (struct buffer *b, int offset)
+{
+ return *(Lisp_Object *)(offset + (char *) b);
+}
+
+INLINE void
+set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
+{
+ *(Lisp_Object *)(offset + (char *) b) = value;
+}
+
+/* Most code should use this macro to access Lisp fields in struct buffer. */
+
+#define BVAR(buf, field) ((void)0, (buf)->field ## _)
+
+/* Access a BVAR from buffer_defaults */
+#define BVAR_DEFAULT(field) (buffer_defaults.field ## _)
+
INLINE bool
BUFFERP (Lisp_Object a)
{
@@ -1109,37 +1246,6 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
}
}
-/* This structure holds the default values of the buffer-local variables
- that have special slots in each buffer.
- The default value occupies the same slot in this structure
- as an individual buffer's value occupies in that buffer.
- Setting the default value also goes through the alist of buffers
- and stores into each buffer that does not say it has a local value. */
-
-extern struct buffer buffer_defaults;
-
-/* This structure marks which slots in a buffer have corresponding
- default values in buffer_defaults.
- Each such slot has a nonzero value in this structure.
- The value has only one nonzero bit.
-
- When a buffer has its own local value for a slot,
- the entry for that slot (found in the same slot in this structure)
- is turned on in the buffer's local_flags array.
-
- If a slot in this structure is zero, then even though there may
- be a Lisp-level local variable for the slot, it has no default value,
- and the corresponding slot in buffer_defaults is not used. */
-
-
-extern struct buffer buffer_local_flags;
-
-/* For each buffer slot, this points to the Lisp symbol name
- for that slot in the current buffer. It is 0 for slots
- that don't have such names. */
-
-extern struct buffer buffer_local_symbols;
-
/* verify_interval_modification saves insertion hooks here
to be run later by report_interval_modification. */
extern Lisp_Object interval_insert_behind_hooks;
@@ -1393,112 +1499,6 @@ OVERLAY_POSITION (Lisp_Object p)
}
-/***********************************************************************
- Buffer-local Variables
- ***********************************************************************/
-
-/* Return the offset in bytes of member VAR of struct buffer
- from the start of a buffer structure. */
-
-#define PER_BUFFER_VAR_OFFSET(VAR) \
- offsetof (struct buffer, VAR ## _)
-
-/* Used to iterate over normal Lisp_Object fields of struct buffer (all
- Lisp_Objects except undo_list). If you add, remove, or reorder
- Lisp_Objects in a struct buffer, make sure that this is still correct. */
-
-#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \
- for (offset = PER_BUFFER_VAR_OFFSET (name); \
- offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
- offset += word_size)
-
-/* Return the index of buffer-local variable VAR. Each per-buffer
- variable has an index > 0 associated with it, except when it always
- has buffer-local values, in which case the index is -1. If this is
- 0, this is a bug and means that the slot of VAR in
- buffer_local_flags wasn't initialized. */
-
-#define PER_BUFFER_VAR_IDX(VAR) \
- PER_BUFFER_IDX (PER_BUFFER_VAR_OFFSET (VAR))
-
-extern bool valid_per_buffer_idx (int);
-
-/* Value is true if the variable with index IDX has a local value
- in buffer B. */
-
-INLINE bool
-PER_BUFFER_VALUE_P (struct buffer *b, int idx)
-{
- eassert (valid_per_buffer_idx (idx));
- return b->local_flags[idx];
-}
-
-/* Set whether per-buffer variable with index IDX has a buffer-local
- value in buffer B. VAL zero means it hasn't. */
-
-INLINE void
-SET_PER_BUFFER_VALUE_P (struct buffer *b, int idx, bool val)
-{
- eassert (valid_per_buffer_idx (idx));
- b->local_flags[idx] = val;
-}
-
-/* Return the index value of the per-buffer variable at offset OFFSET
- in the buffer structure.
-
- If the slot OFFSET has a corresponding default value in
- buffer_defaults, the index value is positive and has only one
- nonzero bit. When a buffer has its own local value for a slot, the
- bit for that slot (found in the same slot in this structure) is
- turned on in the buffer's local_flags array.
-
- If the index value is -1, even though there may be a
- DEFVAR_PER_BUFFER for the slot, there is no default value for it;
- and the corresponding slot in buffer_defaults is not used.
-
- If the index value is -2, then there is no DEFVAR_PER_BUFFER for
- the slot, but there is a default value which is copied into each
- new buffer.
-
- If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
- zero, that is a bug. */
-
-INLINE int
-PER_BUFFER_IDX (ptrdiff_t offset)
-{
- return XFIXNUM (*(Lisp_Object *) (offset + (char *) &buffer_local_flags));
-}
-
-/* Functions to get and set default value of the per-buffer
- variable at offset OFFSET in the buffer structure. */
-
-INLINE Lisp_Object
-per_buffer_default (int offset)
-{
- return *(Lisp_Object *)(offset + (char *) &buffer_defaults);
-}
-
-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. */
-
-INLINE Lisp_Object
-per_buffer_value (struct buffer *b, int offset)
-{
- return *(Lisp_Object *)(offset + (char *) b);
-}
-
-INLINE void
-set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
-{
- *(Lisp_Object *)(offset + (char *) b) = value;
-}
-
/* Downcase a character C, or make no change if that cannot be done. */
INLINE int
downcase (int c)
--
2.28.0
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, (continued)
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Eli Zaretskii, 2020/11/22
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Stefan Monnier, 2020/11/22
- [PATCH 03/10] Use bset_last_selected_window everywhere, Spencer Baugh, 2020/11/19
- [PATCH 01/10] Take buffer field name in DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/19
- [PATCH 06/10] Disallow using BVAR as an lvalue, Spencer Baugh, 2020/11/19
- [PATCH 09/10] Access buffer_defaults in BVAR if there's no local binding, Spencer Baugh, 2020/11/19
- Re: [PATCH 09/10] Access buffer_defaults in BVAR if there's no local binding, Stefan Monnier, 2020/11/19
- Re: [PATCH 09/10] Access buffer_defaults in BVAR if there's no local binding, Eli Zaretskii, 2020/11/19
- [PATCH 05/10] Add BVAR_DEFAULT for access to buffer defaults, Spencer Baugh, 2020/11/19
- [PATCH 08/10] Make cache_long_scans buffer-local when setting it, Spencer Baugh, 2020/11/19
- [PATCH 07/10] Reorder buffer.h for upcoming rework of BVAR,
Spencer Baugh <=
- [PATCH 10/10] Don't iterate over all buffers in set_default_internal, Spencer Baugh, 2020/11/19
- Re: [PATCH 10/10] Don't iterate over all buffers in set_default_internal, Stefan Monnier, 2020/11/19