ef4317728a169c038c49d391fcb45e1ab74a6b39
[chise/xemacs-chise.git-] / src / character.h
1 /* Header for UCS-4 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 #define CHAR_INTP(x) (INTP (x) && valid_char_p (XINT (x)))
37
38 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
39
40 #ifdef ERROR_CHECK_TYPECHECK
41
42 INLINE Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj);
43 INLINE Emchar
44 XCHAR_OR_CHAR_INT (Lisp_Object obj)
45 {
46   assert (CHAR_OR_CHAR_INTP (obj));
47   return CHARP (obj) ? XCHAR (obj) : XINT (obj);
48 }
49
50 #else
51
52 #define XCHAR_OR_CHAR_INT(obj) (CHARP ((obj)) ? XCHAR ((obj)) : XINT ((obj)))
53
54 #endif
55
56 #define CHECK_CHAR_COERCE_INT(x) do {           \
57   if (CHARP (x))                                \
58      ;                                          \
59   else if (CHAR_INTP (x))                       \
60     x = make_char (XINT (x));                   \
61   else                                          \
62     x = wrong_type_argument (Qcharacterp, x);   \
63 } while (0)
64
65 #endif /* _XEMACS_CHARACTER_H */