2 * fribidi-types.h - define data types for the rest of the library
4 * $Id: fribidi-types.h,v 1.12 2006/01/31 03:23:13 behdad Exp $
6 * $Date: 2006/01/31 03:23:13 $
8 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-types.h,v $
11 * Behdad Esfahbod, 2001, 2002, 2004
13 * Copyright (C) 2004 Sharif FarsiWeb, Inc.
14 * Copyright (C) 2001,2002 Behdad Esfahbod
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with this library, in a file named COPYING; if not, write to the
28 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
29 * Boston, MA 02111-1307, USA
31 * For licensing issues, contact <license@farsiweb.info>.
33 #ifndef _FRIBIDI_TYPES_H
34 #define _FRIBIDI_TYPES_H
36 #include "fribidi-common.h"
38 #include "fribidi-begindecls.h"
41 #if FRIBIDI_USE_GLIB+0
42 # ifndef __FRIBIDI_DOC
43 # include <glib/gtypes.h>
44 # include <glib/gunicode.h>
45 # endif /* !__FRIBIDI_DOC */
46 # define FRIBIDI_INT8_LOCAL gint8
47 # define FRIBIDI_INT16_LOCAL gint16
48 # define FRIBIDI_INT32_LOCAL gint32
49 # define FRIBIDI_UINT8_LOCAL guint8
50 # define FRIBIDI_UINT16_LOCAL guint16
51 # define FRIBIDI_UINT32_LOCAL guint32
52 # define FRIBIDI_BOOLEAN_LOCAL gboolean
53 # define FRIBIDI_UNICHAR_LOCAL gunichar
54 #else /* !FRIBIDI_USE_GLIB */
55 # if defined(HAVE_INTTYPES_H) || defined(HAVE_STDINT_H)
56 # ifndef __FRIBIDI_DOC
58 # include <inttypes.h>
61 # endif /* !HAVE_STDINT_H */
62 # endif /* !__FRIBIDI_DOC */
63 # define FRIBIDI_INT8_LOCAL int8_t
64 # define FRIBIDI_INT16_LOCAL int16_t
65 # define FRIBIDI_INT32_LOCAL int32_t
66 # define FRIBIDI_UINT8_LOCAL uint8_t
67 # define FRIBIDI_UINT16_LOCAL uint16_t
68 # define FRIBIDI_UINT32_LOCAL uint32_t
69 # else /* no int types */
70 # define FRIBIDI_INT8_LOCAL signed char
71 # define FRIBIDI_UINT8_LOCAL unsigned char
72 # if !defined(FRIBIDI_SIZEOF_INT) || FRIBIDI_SIZEOF_INT >= 4
73 # define FRIBIDI_INT16_LOCAL signed short
74 # define FRIBIDI_UINT16_LOCAL unsigned short
75 # define FRIBIDI_INT32_LOCAL signed int
76 # define FRIBIDI_UINT32_LOCAL unsigned int
77 # else /* SIZEOF_INT < 4 */
78 # define FRIBIDI_INT16_LOCAL signed int
79 # define FRIBIDI_UINT16_LOCAL unsigned int
80 # define FRIBIDI_INT32_LOCAL signed long
81 # define FRIBIDI_UINT32_LOCAL unsigned long
82 # endif /* SIZEOF_INT < 4 */
83 # endif /* no int types */
84 # define FRIBIDI_BOOLEAN_LOCAL int
85 # if SIZEOF_WCHAR_T >= 4
86 # ifndef __FRIBIDI_DOC
90 # else /* !STDC_HEADERS */
93 # endif /* !HAVE_STDLIB_H */
94 # endif /* !STDC_HEADERS */
95 # endif /* !__FRIBIDI_DOC */
96 # define FRIBIDI_UNICHAR_LOCAL wchar_t
97 # else /* SIZEOF_WCHAR_T < 4 */
98 # define FRIBIDI_UNICHAR_LOCAL fribidi_uint32
99 # endif /* SIZEOF_WCHAR_T < 4 */
100 #endif /* !FRIBIDI_USE_GLIB */
102 #if FRIBIDI_INT_TYPES+0
104 # define FRIBIDI_INT8 FRIBIDI_INT8_LOCAL
105 # define FRIBIDI_INT16 FRIBIDI_INT16_LOCAL
106 # define FRIBIDI_INT32 FRIBIDI_INT32_LOCAL
107 # define FRIBIDI_UINT8 FRIBIDI_UINT8_LOCAL
108 # define FRIBIDI_UINT16 FRIBIDI_UINT16_LOCAL
109 # define FRIBIDI_UINT32 FRIBIDI_UINT32_LOCAL
110 #endif /* !FRIBIDI_INT_TYPES */
111 #ifndef FRIBIDI_BOOLEAN
112 # define FRIBIDI_BOOLEAN FRIBIDI_BOOLEAN_LOCAL
113 #endif /* !FRIBIDI_BOOLEAN */
114 #ifndef FRIBIDI_UNICHAR
115 # define FRIBIDI_UNICHAR FRIBIDI_UNICHAR_LOCAL
116 #endif /* !FRIBIDI_UNICHAR */
117 #ifndef FRIBIDI_STR_INDEX
118 # define FRIBIDI_STR_INDEX int
119 #endif /* FRIBIDI_STR_INDEX */
122 typedef FRIBIDI_UINT8 fribidi_int8;
123 typedef FRIBIDI_INT16 fribidi_int16;
124 typedef FRIBIDI_INT32 fribidi_int32;
125 typedef FRIBIDI_UINT8 fribidi_uint8;
126 typedef FRIBIDI_UINT16 fribidi_uint16;
127 typedef FRIBIDI_UINT32 fribidi_uint32;
128 typedef FRIBIDI_BOOLEAN fribidi_boolean;
130 typedef FRIBIDI_UNICHAR FriBidiChar;
131 typedef FRIBIDI_STR_INDEX FriBidiStrIndex;
134 #ifndef FRIBIDI_MAX_STRING_LENGTH
135 # define FRIBIDI_MAX_STRING_LENGTH (sizeof (FriBidiStrIndex) == 2 ? \
136 0x7FFF : (sizeof (FriBidiStrIndex) == 1 ? \
140 /* A few macros for working with bits */
142 #define FRIBIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
144 #define FRIBIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
146 #define FRIBIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
148 #define FRIBIDI_SET_BITS(x, mask) ((x) |= (mask))
150 #define FRIBIDI_UNSET_BITS(x, mask) ((x) &= ~(mask))
152 #define FRIBIDI_ADJUST_BITS(x, mask, cond) \
153 ((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
155 #define FRIBIDI_ADJUST_AND_TEST_BITS(x, mask, cond) \
156 FRIBIDI_TEST_BITS(FRIBIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
158 #include "fribidi-enddecls.h"
160 #endif /* !_FRIBIDI_TYPES_H */
161 /* Editor directions:
162 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent