(Fput_char_attribute): Forgot to `CHECK_CHAR'.
[chise/xemacs-chise.git-] / src / character.h
1 /* Header for character representation.
2    Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
3    Licensed to the Free Software Foundation.
4
5 This file is part of XEmacs.
6
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING.  If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Rewritten by MORIOKA Tomohiko <tomo@m17n.org>. */
23
24 #ifndef _XEMACS_CHARACTER_H
25 #define _XEMACS_CHARACTER_H
26
27 #if !defined(MULE) /* unibyte representation */
28 # include "char-1byte.h"
29 #elif !defined(CHAR_IS_UCS4) /* leading-byte representation */
30 # include "char-lb.h"
31 #else /* CHAR_IS_UCS4 */
32 # include "char-ucs.h"
33 #endif /* CHAR_IS_UCS4 */
34
35 /********************************/
36 /*                              */
37 /*   Interface for characters   */
38 /*                              */
39 /********************************/
40 /*
41    valid_char_p (ch):
42         Return whether the given Emchar is valid.
43
44    CHARP (ch):
45         Return whether the given Lisp_Object is a character.
46
47    CHECK_CHAR_COERCE_INT (ch):
48         Signal an error if CH is not a valid character or integer
49         Lisp_Object.
50         If CH is an integer Lisp_Object, convert it to a character
51         Lisp_Object, but merely by repackaging, without performing
52         tests for char validity.
53
54 Functions/macros when MULE is defined:
55
56    CHAR_ASCII_P (ch):
57         Return whether the given Emchar is ASCII.
58
59    MAKE_CHAR (CHARSET, B1, B2):
60         Return a character whose coded-charset is CHARSET and
61         position-codes are B1 and B2.  1 byte character ignores B2.
62
63    BREAKUP_CHAR (ch, charset, B1, B2):
64         Break up the given Emchar, and store found coded-charset and
65         position-codes to CHARSET, B1 and B2.
66
67    CHAR_CHARSET (CH):
68         Return coded-charset object of Emchar CH.
69
70    CHAR_LEADING_BYTE (CH):
71         Return Charset-ID of Emchar CH.
72 */
73
74 #define CHAR_INTP(x) (INTP (x) && valid_char_p (XINT (x)))
75
76 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
77
78 #ifdef ERROR_CHECK_TYPECHECK
79
80 INLINE Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj);
81 INLINE Emchar
82 XCHAR_OR_CHAR_INT (Lisp_Object obj)
83 {
84   assert (CHAR_OR_CHAR_INTP (obj));
85   return CHARP (obj) ? XCHAR (obj) : XINT (obj);
86 }
87
88 #else
89
90 #define XCHAR_OR_CHAR_INT(obj) (CHARP ((obj)) ? XCHAR ((obj)) : XINT ((obj)))
91
92 #endif
93
94 #define CHECK_CHAR_COERCE_INT(x) do {           \
95   if (CHARP (x))                                \
96      ;                                          \
97   else if (CHAR_INTP (x))                       \
98     x = make_char (XINT (x));                   \
99   else                                          \
100     x = wrong_type_argument (Qcharacterp, x);   \
101 } while (0)
102
103 #endif /* _XEMACS_CHARACTER_H */