Upgrade to latest harfbuzz
[framework/uifw/harfbuzz.git] / src / hb-ot-shape-complex-indic-machine.hh
1
2 #line 1 "../../src/hb-ot-shape-complex-indic-machine.rl"
3 /*
4  * Copyright © 2011,2012  Google, Inc.
5  *
6  *  This is part of HarfBuzz, a text shaping library.
7  *
8  * Permission is hereby granted, without written agreement and without
9  * license or royalty fees, to use, copy, modify, and distribute this
10  * software and its documentation for any purpose, provided that the
11  * above copyright notice and the following two paragraphs appear in
12  * all copies of this software.
13  *
14  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18  * DAMAGE.
19  *
20  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
23  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25  *
26  * Google Author(s): Behdad Esfahbod
27  */
28
29 #ifndef HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH
30 #define HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH
31
32 #include "hb-private.hh"
33
34 HB_BEGIN_DECLS
35
36
37 #line 38 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
38 static const unsigned char _indic_syllable_machine_trans_keys[] = {
39         5u, 5u, 1u, 2u, 1u, 2u, 5u, 5u, 1u, 5u, 1u, 2u, 5u, 5u, 1u, 13u, 
40         4u, 11u, 4u, 11u, 5u, 11u, 1u, 10u, 1u, 10u, 10u, 10u, 10u, 10u, 4u, 10u, 
41         5u, 10u, 8u, 10u, 5u, 10u, 6u, 10u, 9u, 10u, 4u, 11u, 1u, 13u, 4u, 10u, 
42         4u, 10u, 5u, 10u, 4u, 10u, 5u, 10u, 8u, 10u, 10u, 10u, 10u, 10u, 4u, 10u, 
43         4u, 10u, 5u, 10u, 4u, 10u, 5u, 10u, 8u, 10u, 10u, 10u, 10u, 10u, 0
44 };
45
46 static const char _indic_syllable_machine_key_spans[] = {
47         1, 2, 2, 1, 5, 2, 1, 13, 
48         8, 8, 7, 10, 10, 1, 1, 7, 
49         6, 3, 6, 5, 2, 8, 13, 7, 
50         7, 6, 7, 6, 3, 1, 1, 7, 
51         7, 6, 7, 6, 3, 1, 1
52 };
53
54 static const unsigned char _indic_syllable_machine_index_offsets[] = {
55         0, 2, 5, 8, 10, 16, 19, 21, 
56         35, 44, 53, 61, 72, 83, 85, 87, 
57         95, 102, 106, 113, 119, 122, 131, 145, 
58         153, 161, 168, 176, 183, 187, 189, 191, 
59         199, 207, 214, 222, 229, 233, 235
60 };
61
62 static const char _indic_syllable_machine_indicies[] = {
63         1, 0, 2, 2, 0, 4, 4, 3, 
64         5, 3, 4, 4, 3, 3, 5, 3, 
65         7, 7, 6, 8, 6, 2, 10, 11, 
66         9, 9, 9, 9, 9, 9, 9, 9, 
67         12, 12, 9, 14, 15, 16, 16, 17, 
68         18, 19, 20, 13, 21, 15, 16, 16, 
69         17, 18, 19, 20, 13, 15, 16, 16, 
70         17, 18, 19, 20, 13, 2, 2, 13, 
71         13, 13, 22, 22, 13, 18, 19, 13, 
72         2, 2, 13, 13, 13, 13, 13, 13, 
73         18, 19, 13, 19, 13, 23, 13, 24, 
74         25, 13, 13, 17, 18, 19, 13, 25, 
75         13, 13, 17, 18, 19, 13, 17, 18, 
76         19, 13, 26, 13, 13, 17, 18, 19, 
77         13, 27, 27, 13, 18, 19, 13, 18, 
78         19, 13, 14, 28, 16, 16, 17, 18, 
79         19, 20, 13, 2, 2, 11, 13, 13, 
80         22, 22, 13, 18, 19, 13, 12, 12, 
81         13, 30, 5, 31, 32, 33, 34, 35, 
82         29, 4, 5, 31, 32, 33, 34, 35, 
83         29, 5, 31, 32, 33, 34, 35, 29, 
84         36, 37, 29, 29, 33, 34, 35, 29, 
85         37, 29, 29, 33, 34, 35, 29, 33, 
86         34, 35, 29, 35, 29, 38, 29, 40, 
87         8, 41, 41, 42, 43, 44, 39, 7, 
88         8, 41, 41, 42, 43, 44, 39, 8, 
89         41, 41, 42, 43, 44, 39, 45, 46, 
90         39, 39, 42, 43, 44, 39, 46, 39, 
91         39, 42, 43, 44, 39, 42, 43, 44, 
92         39, 44, 39, 47, 39, 0
93 };
94
95 static const char _indic_syllable_machine_trans_targs[] = {
96         7, 1, 8, 7, 25, 2, 7, 33, 
97         5, 7, 21, 23, 31, 7, 9, 11, 
98         0, 15, 13, 14, 18, 10, 12, 7, 
99         16, 17, 19, 20, 22, 7, 24, 3, 
100         4, 26, 29, 30, 27, 28, 7, 7, 
101         32, 6, 34, 37, 38, 35, 36, 7
102 };
103
104 static const char _indic_syllable_machine_trans_actions[] = {
105         1, 0, 2, 3, 2, 0, 4, 2, 
106         0, 7, 2, 2, 2, 8, 2, 0, 
107         0, 0, 0, 0, 0, 2, 0, 9, 
108         0, 0, 0, 0, 0, 10, 2, 0, 
109         0, 0, 0, 0, 0, 0, 11, 12, 
110         2, 0, 0, 0, 0, 0, 0, 13
111 };
112
113 static const char _indic_syllable_machine_to_state_actions[] = {
114         0, 0, 0, 0, 0, 0, 0, 5, 
115         0, 0, 0, 0, 0, 0, 0, 0, 
116         0, 0, 0, 0, 0, 0, 0, 0, 
117         0, 0, 0, 0, 0, 0, 0, 0, 
118         0, 0, 0, 0, 0, 0, 0
119 };
120
121 static const char _indic_syllable_machine_from_state_actions[] = {
122         0, 0, 0, 0, 0, 0, 0, 6, 
123         0, 0, 0, 0, 0, 0, 0, 0, 
124         0, 0, 0, 0, 0, 0, 0, 0, 
125         0, 0, 0, 0, 0, 0, 0, 0, 
126         0, 0, 0, 0, 0, 0, 0
127 };
128
129 static const unsigned char _indic_syllable_machine_eof_trans[] = {
130         1, 1, 4, 4, 4, 7, 7, 0, 
131         14, 14, 14, 14, 14, 14, 14, 14, 
132         14, 14, 14, 14, 14, 14, 14, 30, 
133         30, 30, 30, 30, 30, 30, 30, 40, 
134         40, 40, 40, 40, 40, 40, 40
135 };
136
137 static const int indic_syllable_machine_start = 7;
138 static const int indic_syllable_machine_first_final = 7;
139 static const int indic_syllable_machine_error = -1;
140
141 static const int indic_syllable_machine_en_main = 7;
142
143
144 #line 38 "../../src/hb-ot-shape-complex-indic-machine.rl"
145
146
147
148 #line 79 "../../src/hb-ot-shape-complex-indic-machine.rl"
149
150
151 #define process_syllable(func) \
152   HB_STMT_START { \
153     /* fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #func); */ \
154     for (unsigned int i = last; i < p+1; i++) \
155       info[i].syllable() = syllable_serial; \
156     PASTE (initial_reordering_, func) (map, buffer, mask_array, last, p+1); \
157     last = p+1; \
158     syllable_serial++; \
159     if (unlikely (!syllable_serial)) syllable_serial++; \
160   } HB_STMT_END
161
162 static void
163 find_syllables (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array)
164 {
165   unsigned int p, pe, eof, ts, te, act;
166   int cs;
167   hb_glyph_info_t *info = buffer->info;
168   
169 #line 170 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
170         {
171         cs = indic_syllable_machine_start;
172         ts = 0;
173         te = 0;
174         act = 0;
175         }
176
177 #line 101 "../../src/hb-ot-shape-complex-indic-machine.rl"
178
179
180   p = 0;
181   pe = eof = buffer->len;
182
183   unsigned int last = 0;
184   uint8_t syllable_serial = 1;
185   
186 #line 187 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
187         {
188         int _slen;
189         int _trans;
190         const unsigned char *_keys;
191         const char *_inds;
192         if ( p == pe )
193                 goto _test_eof;
194 _resume:
195         switch ( _indic_syllable_machine_from_state_actions[cs] ) {
196         case 6:
197 #line 1 "../../src/hb-ot-shape-complex-indic-machine.rl"
198         {ts = p;}
199         break;
200 #line 201 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
201         }
202
203         _keys = _indic_syllable_machine_trans_keys + (cs<<1);
204         _inds = _indic_syllable_machine_indicies + _indic_syllable_machine_index_offsets[cs];
205
206         _slen = _indic_syllable_machine_key_spans[cs];
207         _trans = _inds[ _slen > 0 && _keys[0] <=( info[p].indic_category()) &&
208                 ( info[p].indic_category()) <= _keys[1] ?
209                 ( info[p].indic_category()) - _keys[0] : _slen ];
210
211 _eof_trans:
212         cs = _indic_syllable_machine_trans_targs[_trans];
213
214         if ( _indic_syllable_machine_trans_actions[_trans] == 0 )
215                 goto _again;
216
217         switch ( _indic_syllable_machine_trans_actions[_trans] ) {
218         case 2:
219 #line 1 "../../src/hb-ot-shape-complex-indic-machine.rl"
220         {te = p+1;}
221         break;
222         case 9:
223 #line 72 "../../src/hb-ot-shape-complex-indic-machine.rl"
224         {te = p+1;{ process_syllable (consonant_syllable); }}
225         break;
226         case 11:
227 #line 73 "../../src/hb-ot-shape-complex-indic-machine.rl"
228         {te = p+1;{ process_syllable (vowel_syllable); }}
229         break;
230         case 13:
231 #line 74 "../../src/hb-ot-shape-complex-indic-machine.rl"
232         {te = p+1;{ process_syllable (standalone_cluster); }}
233         break;
234         case 7:
235 #line 75 "../../src/hb-ot-shape-complex-indic-machine.rl"
236         {te = p+1;{ process_syllable (non_indic); }}
237         break;
238         case 8:
239 #line 72 "../../src/hb-ot-shape-complex-indic-machine.rl"
240         {te = p;p--;{ process_syllable (consonant_syllable); }}
241         break;
242         case 10:
243 #line 73 "../../src/hb-ot-shape-complex-indic-machine.rl"
244         {te = p;p--;{ process_syllable (vowel_syllable); }}
245         break;
246         case 12:
247 #line 74 "../../src/hb-ot-shape-complex-indic-machine.rl"
248         {te = p;p--;{ process_syllable (standalone_cluster); }}
249         break;
250         case 1:
251 #line 72 "../../src/hb-ot-shape-complex-indic-machine.rl"
252         {{p = ((te))-1;}{ process_syllable (consonant_syllable); }}
253         break;
254         case 3:
255 #line 73 "../../src/hb-ot-shape-complex-indic-machine.rl"
256         {{p = ((te))-1;}{ process_syllable (vowel_syllable); }}
257         break;
258         case 4:
259 #line 74 "../../src/hb-ot-shape-complex-indic-machine.rl"
260         {{p = ((te))-1;}{ process_syllable (standalone_cluster); }}
261         break;
262 #line 263 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
263         }
264
265 _again:
266         switch ( _indic_syllable_machine_to_state_actions[cs] ) {
267         case 5:
268 #line 1 "../../src/hb-ot-shape-complex-indic-machine.rl"
269         {ts = 0;}
270         break;
271 #line 272 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
272         }
273
274         if ( ++p != pe )
275                 goto _resume;
276         _test_eof: {}
277         if ( p == eof )
278         {
279         if ( _indic_syllable_machine_eof_trans[cs] > 0 ) {
280                 _trans = _indic_syllable_machine_eof_trans[cs] - 1;
281                 goto _eof_trans;
282         }
283         }
284
285         }
286
287 #line 110 "../../src/hb-ot-shape-complex-indic-machine.rl"
288
289 }
290
291 HB_END_DECLS
292
293 #endif /* HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH */