add packaging
[platform/upstream/fribidi.git] / lib / run.h
1 /* FriBidi
2  * run.h - text run data type
3  *
4  * $Id: run.h,v 1.10 2011-05-04 18:04:29 behdad Exp $
5  * $Author: behdad $
6  * $Date: 2011-05-04 18:04:29 $
7  * $Revision: 1.10 $
8  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/run.h,v $
9  *
10  * Authors:
11  *   Behdad Esfahbod, 2001, 2002, 2004
12  *   Dov Grobgeld, 1999, 2000
13  *
14  * Copyright (C) 2004 Sharif FarsiWeb, Inc
15  * Copyright (C) 2001,2002 Behdad Esfahbod
16  * Copyright (C) 1999,2000 Dov Grobgeld
17  * 
18  * This library is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU Lesser General Public
20  * License as published by the Free Software Foundation; either
21  * version 2.1 of the License, or (at your option) any later version.
22  * 
23  * This library is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26  * Lesser General Public License for more details.
27  * 
28  * You should have received a copy of the GNU Lesser General Public License
29  * along with this library, in a file named COPYING; if not, write to the
30  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
31  * Boston, MA 02110-1301, USA
32  * 
33  * For licensing issues, contact <license@farsiweb.info>.
34  */
35 #ifndef _RUN_H
36 #define _RUN_H
37
38 #include "common.h"
39
40 #include <fribidi-common.h>
41
42 #include <fribidi-types.h>
43 #include <fribidi-bidi-types.h>
44
45 #include <fribidi-begindecls.h>
46
47 typedef struct _FriBidiRunStruct FriBidiRun;
48
49 struct _FriBidiRunStruct
50 {
51   FriBidiRun *prev;
52   FriBidiRun *next;
53
54   FriBidiStrIndex pos, len;
55   FriBidiCharType type;
56   FriBidiLevel level;
57 };
58
59
60 #define new_run FRIBIDI_PRIVATESPACE(new_run)
61 FriBidiRun *
62 new_run (
63   void
64 )
65      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_MALLOC FRIBIDI_GNUC_WARN_UNUSED;
66
67 #define free_run FRIBIDI_PRIVATESPACE(free_run)
68      void free_run (
69   FriBidiRun *run
70 ) FRIBIDI_GNUC_HIDDEN;
71
72 #define new_run_list FRIBIDI_PRIVATESPACE(new_run_list)
73      FriBidiRun *new_run_list (
74   void
75 )
76      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_MALLOC FRIBIDI_GNUC_WARN_UNUSED;
77
78 #define free_run_list FRIBIDI_PRIVATESPACE(free_run_list)
79      void free_run_list (
80   FriBidiRun *run_list
81 ) FRIBIDI_GNUC_HIDDEN;
82
83 #define run_list_encode_bidi_types FRIBIDI_PRIVATESPACE(run_list_encode_bidi_types)
84      FriBidiRun *run_list_encode_bidi_types (
85   const FriBidiCharType *bidi_types,
86   const FriBidiStrIndex len
87 )
88      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_WARN_UNUSED;
89
90 #define shadow_run_list FRIBIDI_PRIVATESPACE(shadow_run_list)
91      fribidi_boolean shadow_run_list (
92   FriBidiRun *base,
93   FriBidiRun *over,
94   fribidi_boolean preserve_length
95 )
96      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_WARN_UNUSED;
97
98
99 #define swap(a,b) \
100         FRIBIDI_BEGIN_STMT \
101         void *t; \
102         (t) = (a); \
103         (a) = (b); \
104         (b) = (t); \
105         FRIBIDI_END_STMT
106
107 #define merge_lists(a,b) \
108         FRIBIDI_BEGIN_STMT \
109         swap((a)->prev->next, (b)->prev->next); \
110         swap((a)->prev, (b)->prev); \
111         FRIBIDI_END_STMT
112
113 #define delete_node(x) \
114         FRIBIDI_BEGIN_STMT \
115         (x)->prev->next = (x)->next; \
116         (x)->next->prev = (x)->prev; \
117         FRIBIDI_END_STMT
118
119 #define insert_node_before(x, list) \
120         FRIBIDI_BEGIN_STMT \
121         (x)->prev = (list)->prev; \
122         (list)->prev->next = (x); \
123         (x)->next = (list); \
124         (list)->prev = (x); \
125         FRIBIDI_END_STMT
126
127 #define move_node_before(x, list) \
128         FRIBIDI_BEGIN_STMT \
129         if ((x)->prev) { \
130           delete_node(x); \
131         } \
132         insert_node_before((x), (list)); \
133         FRIBIDI_END_STMT
134
135 #define for_run_list(x, list) \
136         for ((x) = (list)->next; (x)->type != FRIBIDI_TYPE_SENTINEL; (x) = (x)->next)
137
138
139 #if DEBUG+0
140
141 #define fribidi_validate_run_list FRIBIDI_PRIVATESPACE(validate_run_list)
142      void fribidi_validate_run_list (
143   FriBidiRun *run_list          /* input run list */
144 ) FRIBIDI_GNUC_HIDDEN;
145
146 #else /* !DEBUG */
147
148 #define fribidi_validate_run_list(run_list) fribidi_assert(run_list)
149
150 #endif /* !DEBUG */
151
152 #include <fribidi-enddecls.h>
153
154 #endif /* !_RUN_H */
155 /* Editor directions:
156  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
157  */