From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: [PATCH 07/10] Reorder buffer.h for upcoming rework of BVAR Date: Thu, 19 Nov 2020 10:38:11 -0500 Message-ID: <20201119153814.17541-8-sbaugh@catern.com> References: <87mtzil519.fsf@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32005"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh , Arnold Noronha , Stefan Monnier , Dmitry Gutov To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 19 16:48:17 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfmAT-0008E1-Dy for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Nov 2020 16:48:17 +0100 Original-Received: from localhost ([::1]:48806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfmAS-0002Dj-D2 for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Nov 2020 10:48:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfm0t-0005OL-W6 for emacs-devel@gnu.org; Thu, 19 Nov 2020 10:38:24 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:54698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfm0q-0000eG-B6 for emacs-devel@gnu.org; Thu, 19 Nov 2020 10:38:23 -0500 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235; helo=localhost; envelope-from=sbaugh@catern.com; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail; t=1605800299; bh=DJsaLJVkGmUTUrTt51843MaqSt2wKNKUXhnNoGfiTF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TQ77WK3zvivdXtdOJwXvoMog0p5UDBoRNCG51sJikRsHDTWJDe0OojP3ShSePQjdW 6tJFh71SOUM57RJXzh+jJgn/SQcLE4TW9p+jvvClR5SreV6hbBDTdbJXWpGjDh24Et 23MNlHmhv9otC6FoxKvLn64vIo+RlMTxiwRh9Xhk= Original-Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235]) by venus.catern.com (Postfix) with ESMTPSA id 2BC582DDAB8; Thu, 19 Nov 2020 15:38:19 +0000 (UTC) X-Mailer: git-send-email 2.28.0 In-Reply-To: <87mtzil519.fsf@catern.com> Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@catern.com; helo=venus.catern.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/19 09:22:08 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259439 Archived-At: 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