X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/5725bd2cc0e691dadc31bd958f210b1bbcf17c49..d696d62fea48096680d6d511a71c4df56d00a51f:/src/category.h diff --git a/src/category.h b/src/category.h index f29034acff..02f9a193ae 100644 --- a/src/category.h +++ b/src/category.h @@ -22,6 +22,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ +#ifndef EMACS_CATEGORY_H +#define EMACS_CATEGORY_H /* We introduce here three types of object: category, category set, and category table. @@ -53,20 +55,17 @@ along with GNU Emacs. If not, see . */ The second extra slot is a version number of the category table. But, for the moment, we are not using this slot. */ +#include "lisp.h" + INLINE_HEADER_BEGIN -#ifndef CATEGORY_INLINE -# define CATEGORY_INLINE INLINE -#endif #define CATEGORYP(x) RANGED_INTEGERP (0x20, x, 0x7E) #define CHECK_CATEGORY(x) \ CHECK_TYPE (CATEGORYP (x), Qcategoryp, x) -#define XCATEGORY_SET XBOOL_VECTOR - #define CATEGORY_SET_P(x) \ - (BOOL_VECTOR_P (x) && XBOOL_VECTOR (x)->size == 128) + (BOOL_VECTOR_P (x) && bool_vector_size (x) == 128) /* Return a new empty category set. */ #define MAKE_CATEGORY_SET (Fmake_bool_vector (make_number (128), Qnil)) @@ -77,14 +76,16 @@ INLINE_HEADER_BEGIN /* Return the category set of character C in the current category table. */ #define CATEGORY_SET(c) char_category_set (c) -/* Return 1 if CATEGORY_SET contains CATEGORY, else return 0. - The faster version of `!NILP (Faref (category_set, category))'. */ -#define CATEGORY_MEMBER(category, category_set) \ - ((XCATEGORY_SET (category_set)->data[(category) / 8] \ - >> ((category) % 8)) & 1) +/* Return true if CATEGORY_SET contains CATEGORY. + Faster than '!NILP (Faref (category_set, make_number (category)))'. */ +INLINE bool +CATEGORY_MEMBER (EMACS_INT category, Lisp_Object category_set) +{ + return bool_vector_bitref (category_set, category); +} -/* Return 1 if category set of CH contains CATEGORY, else return 0. */ -CATEGORY_INLINE int +/* Return true if category set of CH contains CATEGORY. */ +INLINE bool CHAR_HAS_CATEGORY (int ch, int category) { Lisp_Object category_set = CATEGORY_SET (ch); @@ -96,22 +97,28 @@ CHAR_HAS_CATEGORY (int ch, int category) #define Vstandard_category_table BVAR (&buffer_defaults, category_table) /* Return the doc string of CATEGORY in category table TABLE. */ -#define CATEGORY_DOCSTRING(table, category) \ - XVECTOR (Fchar_table_extra_slot (table, make_number (0)))->contents[(category) - ' '] +#define CATEGORY_DOCSTRING(table, category) \ + AREF (Fchar_table_extra_slot (table, make_number (0)), ((category) - ' ')) + +/* Set the doc string of CATEGORY to VALUE in category table TABLE. */ +#define SET_CATEGORY_DOCSTRING(table, category, value) \ + ASET (Fchar_table_extra_slot (table, make_number (0)), ((category) - ' '), value) /* Return the version number of category table TABLE. Not used for the moment. */ #define CATEGORY_TABLE_VERSION (table) \ Fchar_table_extra_slot (table, make_number (1)) -/* Return 1 if there is a word boundary between two word-constituent - characters C1 and C2 if they appear in this order, else return 0. +/* Return true if there is a word boundary between two + word-constituent characters C1 and C2 if they appear in this order. There is no word boundary between two word-constituent ASCII and Latin-1 characters. */ #define WORD_BOUNDARY_P(c1, c2) \ (!(SINGLE_BYTE_CHAR_P (c1) && SINGLE_BYTE_CHAR_P (c2)) \ && word_boundary_p (c1, c2)) -extern int word_boundary_p (int, int); +extern bool word_boundary_p (int, int); INLINE_HEADER_END + +#endif /* EMACS_CATEGORY_H */