add packaging
[platform/upstream/fribidi.git] / lib / fribidi-types.h
1 /* FriBidi
2  * fribidi-types.h - define data types for the rest of the library
3  *
4  * $Id: fribidi-types.h,v 1.13 2010-02-24 19:40:04 behdad Exp $
5  * $Author: behdad $
6  * $Date: 2010-02-24 19:40:04 $
7  * $Revision: 1.13 $
8  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-types.h,v $
9  *
10  * Author:
11  *   Behdad Esfahbod, 2001, 2002, 2004
12  *
13  * Copyright (C) 2004 Sharif FarsiWeb, Inc.
14  * Copyright (C) 2001,2002 Behdad Esfahbod
15  * 
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.
20  * 
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.
25  * 
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., 51 Franklin Street, Fifth Floor,
29  * Boston, MA 02110-1301, USA
30  *
31  * For licensing issues, contact <license@farsiweb.info>.
32  */
33 #ifndef _FRIBIDI_TYPES_H
34 #define _FRIBIDI_TYPES_H
35
36 #include "fribidi-common.h"
37
38 #include "fribidi-begindecls.h"
39
40
41 #if FRIBIDI_USE_GLIB+0
42 # ifndef __FRIBIDI_DOC
43 #  include <glib.h>
44 # endif /* !__FRIBIDI_DOC */
45 # define FRIBIDI_INT8_LOCAL             gint8
46 # define FRIBIDI_INT16_LOCAL            gint16
47 # define FRIBIDI_INT32_LOCAL            gint32
48 # define FRIBIDI_UINT8_LOCAL            guint8
49 # define FRIBIDI_UINT16_LOCAL           guint16
50 # define FRIBIDI_UINT32_LOCAL           guint32
51 # define FRIBIDI_BOOLEAN_LOCAL          gboolean
52 # define FRIBIDI_UNICHAR_LOCAL          gunichar
53 #else /* !FRIBIDI_USE_GLIB */
54 # if defined(HAVE_INTTYPES_H) || defined(HAVE_STDINT_H)
55 #  ifndef __FRIBIDI_DOC
56 #   if HAVE_INTTYPES_H
57 #    include <inttypes.h>
58 #   elif HAVE_STDINT_H
59 #    include <stdint.h>
60 #   endif /* !HAVE_STDINT_H */
61 #  endif /* !__FRIBIDI_DOC */
62 #  define FRIBIDI_INT8_LOCAL            int8_t
63 #  define FRIBIDI_INT16_LOCAL           int16_t
64 #  define FRIBIDI_INT32_LOCAL           int32_t
65 #  define FRIBIDI_UINT8_LOCAL           uint8_t
66 #  define FRIBIDI_UINT16_LOCAL          uint16_t
67 #  define FRIBIDI_UINT32_LOCAL          uint32_t
68 # else /* no int types */
69 #  define FRIBIDI_INT8_LOCAL            signed char
70 #  define FRIBIDI_UINT8_LOCAL           unsigned char
71 #  if !defined(FRIBIDI_SIZEOF_INT) || FRIBIDI_SIZEOF_INT >= 4
72 #   define FRIBIDI_INT16_LOCAL          signed short
73 #   define FRIBIDI_UINT16_LOCAL         unsigned short
74 #   define FRIBIDI_INT32_LOCAL          signed int
75 #   define FRIBIDI_UINT32_LOCAL         unsigned int
76 #  else /* SIZEOF_INT < 4 */
77 #   define FRIBIDI_INT16_LOCAL          signed int
78 #   define FRIBIDI_UINT16_LOCAL         unsigned int
79 #   define FRIBIDI_INT32_LOCAL          signed long
80 #   define FRIBIDI_UINT32_LOCAL         unsigned long
81 #  endif /* SIZEOF_INT < 4 */
82 # endif /* no int types */
83 # define FRIBIDI_BOOLEAN_LOCAL          int
84 # if SIZEOF_WCHAR_T >= 4
85 #  ifndef __FRIBIDI_DOC
86 #   if STDC_HEADERS
87 #    include <stdlib.h>
88 #    include <stddef.h>
89 #   else /* !STDC_HEADERS */
90 #    if HAVE_STDLIB_H
91 #     include <stdlib.h>
92 #    endif /* !HAVE_STDLIB_H */
93 #   endif /* !STDC_HEADERS */
94 #  endif /* !__FRIBIDI_DOC */
95 #  define FRIBIDI_UNICHAR_LOCAL         wchar_t
96 # else /* SIZEOF_WCHAR_T < 4 */
97 #  define FRIBIDI_UNICHAR_LOCAL         fribidi_uint32
98 # endif /* SIZEOF_WCHAR_T < 4 */
99 #endif /* !FRIBIDI_USE_GLIB */
100
101 #if FRIBIDI_INT_TYPES+0
102 #else
103 # define FRIBIDI_INT8   FRIBIDI_INT8_LOCAL
104 # define FRIBIDI_INT16  FRIBIDI_INT16_LOCAL
105 # define FRIBIDI_INT32  FRIBIDI_INT32_LOCAL
106 # define FRIBIDI_UINT8  FRIBIDI_UINT8_LOCAL
107 # define FRIBIDI_UINT16 FRIBIDI_UINT16_LOCAL
108 # define FRIBIDI_UINT32 FRIBIDI_UINT32_LOCAL
109 #endif /* !FRIBIDI_INT_TYPES */
110 #ifndef FRIBIDI_BOOLEAN
111 # define FRIBIDI_BOOLEAN        FRIBIDI_BOOLEAN_LOCAL
112 #endif /* !FRIBIDI_BOOLEAN */
113 #ifndef FRIBIDI_UNICHAR
114 # define FRIBIDI_UNICHAR FRIBIDI_UNICHAR_LOCAL
115 #endif /* !FRIBIDI_UNICHAR */
116 #ifndef FRIBIDI_STR_INDEX
117 # define FRIBIDI_STR_INDEX int
118 #endif /* FRIBIDI_STR_INDEX */
119
120
121 typedef FRIBIDI_UINT8 fribidi_int8;
122 typedef FRIBIDI_INT16 fribidi_int16;
123 typedef FRIBIDI_INT32 fribidi_int32;
124 typedef FRIBIDI_UINT8 fribidi_uint8;
125 typedef FRIBIDI_UINT16 fribidi_uint16;
126 typedef FRIBIDI_UINT32 fribidi_uint32;
127 typedef FRIBIDI_BOOLEAN fribidi_boolean;
128
129 typedef FRIBIDI_UNICHAR FriBidiChar;
130 typedef FRIBIDI_STR_INDEX FriBidiStrIndex;
131
132
133 #ifndef FRIBIDI_MAX_STRING_LENGTH
134 # define FRIBIDI_MAX_STRING_LENGTH (sizeof (FriBidiStrIndex) == 2 ?     \
135                 0x7FFF : (sizeof (FriBidiStrIndex) == 1 ? \
136                 0x7F : 0x7FFFFFFFL))
137 #endif
138
139 /* A few macros for working with bits */
140
141 #define FRIBIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
142
143 #define FRIBIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
144
145 #define FRIBIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
146
147 #define FRIBIDI_SET_BITS(x, mask)       ((x) |= (mask))
148
149 #define FRIBIDI_UNSET_BITS(x, mask)     ((x) &= ~(mask))
150
151 #define FRIBIDI_ADJUST_BITS(x, mask, cond)      \
152         ((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
153
154 #define FRIBIDI_ADJUST_AND_TEST_BITS(x, mask, cond)     \
155         FRIBIDI_TEST_BITS(FRIBIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
156
157 #include "fribidi-enddecls.h"
158
159 #endif /* !_FRIBIDI_TYPES_H */
160 /* Editor directions:
161  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
162  */