guile-elisp bootstrap (lisp)
[bpt/emacs.git] / src / charset.h
index 5ca8313..4176ce5 100644 (file)
@@ -1,5 +1,5 @@
 /* Header for charset handler.
-   Copyright (C) 2001-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2014 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
@@ -29,6 +29,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <verify.h>
 
+INLINE_HEADER_BEGIN
+
 /* Index to arguments of Fdefine_charset_internal.  */
 
 enum define_charset_arg_index
@@ -168,12 +170,24 @@ struct charset
      check if a code-point is in a valid range.  */
   unsigned char *code_space_mask;
 
-  /* 1 if there's no gap in code-points.  */
-  int code_linear_p;
+  /* True if there's no gap in code-points.  */
+  bool_bf code_linear_p : 1;
+
+  /* True if the charset is treated as 96 chars in ISO-2022
+     as opposed to 94 chars.  */
+  bool_bf iso_chars_96 : 1;
+
+  /* True if the charset is compatible with ASCII.  */
+  bool_bf ascii_compatible_p : 1;
+
+  /* True if the charset is supplementary.  */
+  bool_bf supplementary_p : 1;
 
-  /* If the charset is treated as 94-chars in ISO-2022, the value is 0.
-     If the charset is treated as 96-chars in ISO-2022, the value is 1.  */
-  int iso_chars_96;
+  /* True if all the code points are representable by Lisp_Int.  */
+  bool_bf compact_codes_p : 1;
+
+  /* True if the charset is unified with Unicode.  */
+  bool_bf unified_p : 1;
 
   /* ISO final byte of the charset: 48..127.  It may be -1 if the
      charset doesn't conform to ISO-2022.  */
@@ -187,15 +201,6 @@ struct charset
      version.  Otherwise, -1.  */
   int emacs_mule_id;
 
-  /* Nonzero if the charset is compatible with ASCII.  */
-  int ascii_compatible_p;
-
-  /* Nonzero if the charset is supplementary.  */
-  int supplementary_p;
-
-  /* Nonzero if all the code points are representable by Lisp_Int.  */
-  int compact_codes_p;
-
   /* The method for encoding/decoding characters of the charset.  */
   enum charset_method method;
 
@@ -203,7 +208,7 @@ struct charset
   unsigned min_code, max_code;
 
   /* Offset value used by macros CODE_POINT_TO_INDEX and
-      INDEX_TO_CODE_POINT.  */
+      INDEX_TO_CODE_POINT.  */
   unsigned char_index_offset;
 
   /* Minimum and Maximum character codes of the charset.  If the
@@ -234,8 +239,6 @@ struct charset
   /* Offset value to calculate a character code from code-point, and
      visa versa.  */
   int code_offset;
-
-  int unified_p;
 };
 
 /* Hash table of charset symbols vs. the corresponding attribute
@@ -325,6 +328,13 @@ extern int emacs_mule_charset[256];
 #define CHARSET_DEUNIFIER(charset)     \
   (CHARSET_ATTR_DEUNIFIER (CHARSET_ATTRIBUTES (charset)))
 
+INLINE void
+set_charset_attr (struct charset *charset, enum charset_attr_index idx,
+                 Lisp_Object val)
+{
+  ASET (CHARSET_ATTRIBUTES (charset), idx, val);
+}
+
 
 /* Nonzero if OBJ is a valid charset symbol.  */
 #define CHARSETP(obj) (CHARSET_SYMBOL_HASH_INDEX (obj) >= 0)
@@ -334,7 +344,7 @@ extern int emacs_mule_charset[256];
   do {                                                         \
     if (! SYMBOLP (x) || CHARSET_SYMBOL_HASH_INDEX (x) < 0)    \
       wrong_type_argument (Qcharsetp, (x));                    \
-  } while (0)
+  } while (false)
 
 
 /* Check if X is a valid charset symbol.  If valid, set ID to the id
@@ -347,7 +357,7 @@ extern int emacs_mule_charset[256];
       wrong_type_argument (Qcharsetp, (x));                            \
     id = XINT (AREF (HASH_VALUE (XHASH_TABLE (Vcharset_hash_table), idx), \
                     charset_id));                                      \
-  } while (0)
+  } while (false)
 
 
 /* Check if X is a valid charset symbol.  If valid, set ATTR to the
@@ -356,7 +366,7 @@ extern int emacs_mule_charset[256];
   do {                                                                 \
     if (!SYMBOLP (x) || NILP (attr = CHARSET_SYMBOL_ATTRIBUTES (x)))   \
       wrong_type_argument (Qcharsetp, (x));                            \
-  } while (0)
+  } while (false)
 
 
 #define CHECK_CHARSET_GET_CHARSET(x, charset)  \
@@ -364,7 +374,7 @@ extern int emacs_mule_charset[256];
     int csid;                                  \
     CHECK_CHARSET_GET_ID (x, csid);            \
     charset = CHARSET_FROM_ID (csid);          \
-  } while (0)
+  } while (false)
 
 
 /* Lookup Vcharset_ordered_list and return the first charset that
@@ -373,7 +383,7 @@ extern int emacs_mule_charset[256];
   ((c) < 0x80 ? CHARSET_FROM_ID (charset_ascii)        \
    : char_charset ((c), Qnil, NULL))
 
-#if 0
+#if false
 /* Char-table of charset-sets.  Each element is a bool vector indexed
    by a charset ID.  */
 extern Lisp_Object Vchar_charset_set;
@@ -393,7 +403,7 @@ extern Lisp_Object Vchar_charset_set;
    Try some optimization before calling decode_char.  */
 
 #define DECODE_CHAR(charset, code)                                     \
-  ((ASCII_BYTE_P (code) && (charset)->ascii_compatible_p)              \
+  ((ASCII_CHAR_P (code) && (charset)->ascii_compatible_p)              \
    ? (code)                                                            \
    : ((code) < (charset)->min_code || (code) > (charset)->max_code)    \
    ? -1                                                                        \
@@ -401,7 +411,7 @@ extern Lisp_Object Vchar_charset_set;
    ? decode_char ((charset), (code))                                   \
    : (charset)->method == CHARSET_METHOD_OFFSET                                \
    ? ((charset)->code_linear_p                                         \
-      ? (code) - (charset)->min_code + (charset)->code_offset          \
+      ? (int) ((code) - (charset)->min_code) + (charset)->code_offset  \
       : decode_char ((charset), (code)))                               \
    : (charset)->method == CHARSET_METHOD_MAP                           \
    ? (((charset)->code_linear_p                                                \
@@ -411,16 +421,6 @@ extern Lisp_Object Vchar_charset_set;
       : decode_char ((charset), (code)))                               \
    : decode_char ((charset), (code)))
 
-
-/* If CHARSET is a simple offset base charset, return it's offset,
-   otherwise return -1.  */
-#define CHARSET_OFFSET(charset)                                \
-  (((charset)->method == CHARSET_METHOD_OFFSET         \
-    && (charset)->code_linear_p                                \
-    && ! (charset)->unified_p)                         \
-   ? (charset)->code_offset - (charset)->min_code      \
-   : -1)
-
 extern Lisp_Object charset_work;
 
 /* Return a code point of CHAR in CHARSET.
@@ -430,7 +430,7 @@ extern Lisp_Object charset_work;
   (verify_expr                                                         \
    (sizeof (c) <= sizeof (int),                                                \
     (ASCII_CHAR_P (c) && (charset)->ascii_compatible_p                 \
-     ? (c)                                                             \
+     ? (unsigned) (c)                                                  \
      : ((charset)->unified_p                                           \
        || (charset)->method == CHARSET_METHOD_SUBSET                   \
        || (charset)->method == CHARSET_METHOD_SUPERSET)                \
@@ -439,7 +439,7 @@ extern Lisp_Object charset_work;
      ? (charset)->invalid_code                                         \
      : (charset)->method == CHARSET_METHOD_OFFSET                      \
      ? ((charset)->code_linear_p                                       \
-       ? (c) - (charset)->code_offset + (charset)->min_code            \
+       ? (unsigned) ((c) - (charset)->code_offset) + (charset)->min_code \
        : encode_char (charset, c))                                     \
      : (charset)->method == CHARSET_METHOD_MAP                         \
      ? (((charset)->compact_codes_p                                    \
@@ -447,14 +447,14 @@ extern Lisp_Object charset_work;
        ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), c), \
           (NILP (charset_work)                                         \
            ? (charset)->invalid_code                                   \
-           : XFASTINT (charset_work)))                                 \
+           : (unsigned) XFASTINT (charset_work)))                      \
        : encode_char (charset, c))                                     \
      : encode_char (charset, c))))
 
 
-/* Set to 1 when a charset map is loaded to warn that a buffer text
+/* Set to true when a charset map is loaded to warn that a buffer text
    and a string data may be relocated.  */
-extern int charset_map_loaded;
+extern bool charset_map_loaded;
 
 
 /* Set CHARSET to the charset highest priority of C, CODE to the
@@ -472,10 +472,10 @@ extern int charset_map_loaded;
    macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR).  */
 extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
 
-/* A charset of type iso2022 who has DIMENSION, CHARS, and FINAL
+/* A charset of type iso2022 who has DIMENSION, CHARS_96, and FINAL
    (final character).  */
 #define ISO_CHARSET_TABLE(dimension, chars_96, final)  \
-  iso_charset_table[(dimension) - 1][(chars_96)][(final)]
+  iso_charset_table[(dimension) - 1][chars_96][final]
 
 /* Nonzero if the charset who has FAST_MAP may contain C.  */
 #define CHARSET_FAST_MAP_REF(c, fast_map)              \
@@ -489,11 +489,11 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
       (fast_map)[(c) >> 10] |= 1 << (((c) >> 7) & 7);          \
     else                                                       \
       (fast_map)[((c) >> 15) + 62] |= 1 << (((c) >> 12) & 7);  \
-  } while (0)
+  } while (false)
 
 
 
-/* 1 if CHARSET may contain the character C.  */
+/* True if CHARSET may contain the character C.  */
 #define CHAR_CHARSET_P(c, charset)                                      \
   ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p)                  \
    || ((CHARSET_UNIFIED_P (charset)                                     \
@@ -535,7 +535,6 @@ extern int charset_unibyte;
 extern struct charset *char_charset (int, Lisp_Object, unsigned *);
 extern Lisp_Object charset_attributes (int);
 
-extern int maybe_unify_char (int, Lisp_Object);
 extern int decode_char (struct charset *, unsigned);
 extern unsigned encode_char (struct charset *, int);
 extern int string_xstring_p (Lisp_Object);
@@ -544,4 +543,6 @@ extern void map_charset_chars (void (*) (Lisp_Object, Lisp_Object),
                                Lisp_Object, Lisp_Object,
                                struct charset *, unsigned, unsigned);
 
+INLINE_HEADER_END
+
 #endif /* EMACS_CHARSET_H */