1 
2 #line 1 "../../src/hb-ot-shape-complex-sea-machine.rl"
3 /*
4  * Copyright © 2011,2012,2013  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_SEA_MACHINE_HH
30 #define HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH
31 
32 #include "hb-private.hh"
33 
34 
35 #line 36 "hb-ot-shape-complex-sea-machine.hh.tmp"
36 static const unsigned char _sea_syllable_machine_trans_keys[] = {
37 	1u, 1u, 1u, 1u, 1u, 29u, 3u, 29u, 3u, 29u, 1u, 1u, 0
38 };
39 
40 static const char _sea_syllable_machine_key_spans[] = {
41 	1, 1, 29, 27, 27, 1
42 };
43 
44 static const char _sea_syllable_machine_index_offsets[] = {
45 	0, 2, 4, 34, 62, 90
46 };
47 
48 static const char _sea_syllable_machine_indicies[] = {
49 	1, 0, 3, 2, 1, 1, 3, 5,
50 	4, 4, 4, 4, 4, 3, 4, 1,
51 	4, 4, 4, 4, 3, 4, 4, 4,
52 	4, 3, 4, 4, 4, 3, 3, 3,
53 	3, 4, 1, 7, 6, 6, 6, 6,
54 	6, 1, 6, 6, 6, 6, 6, 6,
55 	1, 6, 6, 6, 6, 1, 6, 6,
56 	6, 1, 1, 1, 1, 6, 3, 9,
57 	8, 8, 8, 8, 8, 3, 8, 8,
58 	8, 8, 8, 8, 3, 8, 8, 8,
59 	8, 3, 8, 8, 8, 3, 3, 3,
60 	3, 8, 3, 10, 0
61 };
62 
63 static const char _sea_syllable_machine_trans_targs[] = {
64 	2, 3, 2, 4, 2, 5, 2, 0,
65 	2, 1, 2
66 };
67 
68 static const char _sea_syllable_machine_trans_actions[] = {
69 	1, 2, 3, 2, 6, 0, 7, 0,
70 	8, 0, 9
71 };
72 
73 static const char _sea_syllable_machine_to_state_actions[] = {
74 	0, 0, 4, 0, 0, 0
75 };
76 
77 static const char _sea_syllable_machine_from_state_actions[] = {
78 	0, 0, 5, 0, 0, 0
79 };
80 
81 static const char _sea_syllable_machine_eof_trans[] = {
82 	1, 3, 0, 7, 9, 11
83 };
84 
85 static const int sea_syllable_machine_start = 2;
86 static const int sea_syllable_machine_first_final = 2;
87 static const int sea_syllable_machine_error = -1;
88 
89 static const int sea_syllable_machine_en_main = 2;
90 
91 
92 #line 36 "../../src/hb-ot-shape-complex-sea-machine.rl"
93 
94 
95 
96 #line 67 "../../src/hb-ot-shape-complex-sea-machine.rl"
97 
98 
99 #define found_syllable(syllable_type) \
100   HB_STMT_START { \
101     if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
102     for (unsigned int i = last; i < p+1; i++) \
103       info[i].syllable() = (syllable_serial << 4) | syllable_type; \
104     last = p+1; \
105     syllable_serial++; \
106     if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
107   } HB_STMT_END
108 
109 static void
find_syllables(hb_buffer_t * buffer)110 find_syllables (hb_buffer_t *buffer)
111 {
112   unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
113   int cs;
114   hb_glyph_info_t *info = buffer->info;
115 
116 #line 117 "hb-ot-shape-complex-sea-machine.hh.tmp"
117 	{
118 	cs = sea_syllable_machine_start;
119 	ts = 0;
120 	te = 0;
121 	act = 0;
122 	}
123 
124 #line 88 "../../src/hb-ot-shape-complex-sea-machine.rl"
125 
126 
127   p = 0;
128   pe = eof = buffer->len;
129 
130   unsigned int last = 0;
131   unsigned int syllable_serial = 1;
132 
133 #line 134 "hb-ot-shape-complex-sea-machine.hh.tmp"
134 	{
135 	int _slen;
136 	int _trans;
137 	const unsigned char *_keys;
138 	const char *_inds;
139 	if ( p == pe )
140 		goto _test_eof;
141 _resume:
142 	switch ( _sea_syllable_machine_from_state_actions[cs] ) {
143 	case 5:
144 #line 1 "NONE"
145 	{ts = p;}
146 	break;
147 #line 148 "hb-ot-shape-complex-sea-machine.hh.tmp"
148 	}
149 
150 	_keys = _sea_syllable_machine_trans_keys + (cs<<1);
151 	_inds = _sea_syllable_machine_indicies + _sea_syllable_machine_index_offsets[cs];
152 
153 	_slen = _sea_syllable_machine_key_spans[cs];
154 	_trans = _inds[ _slen > 0 && _keys[0] <=( info[p].sea_category()) &&
155 		( info[p].sea_category()) <= _keys[1] ?
156 		( info[p].sea_category()) - _keys[0] : _slen ];
157 
158 _eof_trans:
159 	cs = _sea_syllable_machine_trans_targs[_trans];
160 
161 	if ( _sea_syllable_machine_trans_actions[_trans] == 0 )
162 		goto _again;
163 
164 	switch ( _sea_syllable_machine_trans_actions[_trans] ) {
165 	case 2:
166 #line 1 "NONE"
167 	{te = p+1;}
168 	break;
169 	case 6:
170 #line 63 "../../src/hb-ot-shape-complex-sea-machine.rl"
171 	{te = p+1;{ found_syllable (non_sea_cluster); }}
172 	break;
173 	case 7:
174 #line 61 "../../src/hb-ot-shape-complex-sea-machine.rl"
175 	{te = p;p--;{ found_syllable (consonant_syllable); }}
176 	break;
177 	case 8:
178 #line 62 "../../src/hb-ot-shape-complex-sea-machine.rl"
179 	{te = p;p--;{ found_syllable (broken_cluster); }}
180 	break;
181 	case 9:
182 #line 63 "../../src/hb-ot-shape-complex-sea-machine.rl"
183 	{te = p;p--;{ found_syllable (non_sea_cluster); }}
184 	break;
185 	case 1:
186 #line 61 "../../src/hb-ot-shape-complex-sea-machine.rl"
187 	{{p = ((te))-1;}{ found_syllable (consonant_syllable); }}
188 	break;
189 	case 3:
190 #line 62 "../../src/hb-ot-shape-complex-sea-machine.rl"
191 	{{p = ((te))-1;}{ found_syllable (broken_cluster); }}
192 	break;
193 #line 194 "hb-ot-shape-complex-sea-machine.hh.tmp"
194 	}
195 
196 _again:
197 	switch ( _sea_syllable_machine_to_state_actions[cs] ) {
198 	case 4:
199 #line 1 "NONE"
200 	{ts = 0;}
201 	break;
202 #line 203 "hb-ot-shape-complex-sea-machine.hh.tmp"
203 	}
204 
205 	if ( ++p != pe )
206 		goto _resume;
207 	_test_eof: {}
208 	if ( p == eof )
209 	{
210 	if ( _sea_syllable_machine_eof_trans[cs] > 0 ) {
211 		_trans = _sea_syllable_machine_eof_trans[cs] - 1;
212 		goto _eof_trans;
213 	}
214 	}
215 
216 	}
217 
218 #line 97 "../../src/hb-ot-shape-complex-sea-machine.rl"
219 
220 }
221 
222 #undef found_syllable
223 
224 #endif /* HB_OT_SHAPE_COMPLEX_SEA_MACHINE_HH */
225