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

source code of gtk/subprojects/fribidi/lib/run.h