Coverage Report

Created: 2023-12-13 20:01

/src/harfbuzz/src/hb-ot-shaper-khmer-machine.hh
Line
Count
Source (jump to first uncovered line)
1
2
#line 1 "hb-ot-shaper-khmer-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_SHAPER_KHMER_MACHINE_HH
30
#define HB_OT_SHAPER_KHMER_MACHINE_HH
31
32
#include "hb.hh"
33
34
#include "hb-ot-layout.hh"
35
#include "hb-ot-shaper-indic.hh"
36
37
/* buffer var allocations */
38
36.4M
#define khmer_category() ot_shaper_var_u8_category() /* khmer_category_t */
39
40
using khmer_category_t = unsigned;
41
42
49.8k
#define K_Cat(Cat) khmer_syllable_machine_ex_##Cat
43
44
enum khmer_syllable_type_t {
45
  khmer_consonant_syllable,
46
  khmer_broken_cluster,
47
  khmer_non_khmer_cluster,
48
};
49
50
51
#line 49 "hb-ot-shaper-khmer-machine.hh"
52
#define khmer_syllable_machine_ex_C 1u
53
3.00k
#define khmer_syllable_machine_ex_DOTTEDCIRCLE 11u
54
49.8k
#define khmer_syllable_machine_ex_H 4u
55
#define khmer_syllable_machine_ex_PLACEHOLDER 10u
56
124
#define khmer_syllable_machine_ex_Ra 15u
57
#define khmer_syllable_machine_ex_Robatic 25u
58
#define khmer_syllable_machine_ex_V 2u
59
#define khmer_syllable_machine_ex_VAbv 20u
60
#define khmer_syllable_machine_ex_VBlw 21u
61
24.8k
#define khmer_syllable_machine_ex_VPre 22u
62
#define khmer_syllable_machine_ex_VPst 23u
63
#define khmer_syllable_machine_ex_Xgroup 26u
64
#define khmer_syllable_machine_ex_Ygroup 27u
65
#define khmer_syllable_machine_ex_ZWJ 6u
66
#define khmer_syllable_machine_ex_ZWNJ 5u
67
68
69
#line 65 "hb-ot-shaper-khmer-machine.hh"
70
static const unsigned char _khmer_syllable_machine_trans_keys[] = {
71
  5u, 26u, 5u, 26u, 1u, 15u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 
72
  5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 1u, 15u, 5u, 26u, 5u, 26u, 
73
  5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 1u, 27u, 4u, 27u, 1u, 15u, 
74
  4u, 27u, 4u, 27u, 27u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 
75
  4u, 27u, 1u, 15u, 4u, 27u, 4u, 27u, 27u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 
76
  4u, 27u, 4u, 27u, 5u, 26u, 0
77
};
78
79
static const char _khmer_syllable_machine_key_spans[] = {
80
  22, 22, 15, 22, 22, 22, 22, 22, 
81
  22, 22, 22, 22, 22, 15, 22, 22, 
82
  22, 22, 22, 22, 22, 27, 24, 15, 
83
  24, 24, 1, 24, 24, 24, 24, 24, 
84
  24, 15, 24, 24, 1, 24, 24, 24, 
85
  24, 24, 22
86
};
87
88
static const short _khmer_syllable_machine_index_offsets[] = {
89
  0, 23, 46, 62, 85, 108, 131, 154, 
90
  177, 200, 223, 246, 269, 292, 308, 331, 
91
  354, 377, 400, 423, 446, 469, 497, 522, 
92
  538, 563, 588, 590, 615, 640, 665, 690, 
93
  715, 740, 756, 781, 806, 808, 833, 858, 
94
  883, 908, 933
95
};
96
97
static const char _khmer_syllable_machine_indicies[] = {
98
  1, 1, 0, 0, 0, 0, 0, 0, 
99
  0, 0, 0, 0, 0, 0, 0, 2, 
100
  0, 0, 0, 0, 3, 4, 0, 1, 
101
  1, 0, 0, 0, 0, 0, 0, 0, 
102
  0, 0, 0, 0, 0, 0, 0, 0, 
103
  0, 0, 0, 0, 4, 0, 5, 5, 
104
  0, 0, 0, 0, 0, 0, 0, 0, 
105
  0, 0, 0, 0, 5, 0, 1, 1, 
106
  0, 0, 0, 0, 0, 0, 0, 0, 
107
  0, 0, 0, 0, 0, 2, 0, 0, 
108
  0, 0, 0, 4, 0, 6, 6, 0, 
109
  0, 0, 0, 0, 0, 0, 0, 0, 
110
  0, 0, 0, 0, 0, 0, 0, 0, 
111
  0, 0, 2, 0, 7, 7, 0, 0, 
112
  0, 0, 0, 0, 0, 0, 0, 0, 
113
  0, 0, 0, 0, 0, 0, 0, 0, 
114
  0, 8, 0, 9, 9, 0, 0, 0, 
115
  0, 0, 0, 0, 0, 0, 0, 0, 
116
  0, 0, 2, 0, 0, 0, 0, 0, 
117
  10, 0, 9, 9, 0, 0, 0, 0, 
118
  0, 0, 0, 0, 0, 0, 0, 0, 
119
  0, 0, 0, 0, 0, 0, 0, 10, 
120
  0, 11, 11, 0, 0, 0, 0, 0, 
121
  0, 0, 0, 0, 0, 0, 0, 0, 
122
  2, 0, 0, 0, 0, 0, 12, 0, 
123
  11, 11, 0, 0, 0, 0, 0, 0, 
124
  0, 0, 0, 0, 0, 0, 0, 0, 
125
  0, 0, 0, 0, 0, 12, 0, 1, 
126
  1, 0, 0, 0, 0, 0, 0, 0, 
127
  0, 0, 0, 0, 0, 0, 2, 0, 
128
  0, 0, 0, 13, 4, 0, 15, 15, 
129
  14, 14, 14, 14, 14, 14, 14, 14, 
130
  14, 14, 14, 14, 14, 16, 14, 14, 
131
  14, 14, 17, 18, 14, 15, 15, 19, 
132
  19, 19, 19, 19, 19, 19, 19, 19, 
133
  19, 19, 19, 19, 19, 19, 19, 19, 
134
  19, 19, 18, 19, 20, 20, 14, 14, 
135
  14, 14, 14, 14, 14, 14, 14, 14, 
136
  14, 14, 20, 14, 15, 15, 14, 14, 
137
  14, 14, 14, 14, 14, 14, 14, 14, 
138
  14, 14, 14, 16, 14, 14, 14, 14, 
139
  14, 18, 14, 21, 21, 14, 14, 14, 
140
  14, 14, 14, 14, 14, 14, 14, 14, 
141
  14, 14, 14, 14, 14, 14, 14, 14, 
142
  16, 14, 22, 22, 14, 14, 14, 14, 
143
  14, 14, 14, 14, 14, 14, 14, 14, 
144
  14, 14, 14, 14, 14, 14, 14, 23, 
145
  14, 24, 24, 14, 14, 14, 14, 14, 
146
  14, 14, 14, 14, 14, 14, 14, 14, 
147
  16, 14, 14, 14, 14, 14, 25, 14, 
148
  24, 24, 14, 14, 14, 14, 14, 14, 
149
  14, 14, 14, 14, 14, 14, 14, 14, 
150
  14, 14, 14, 14, 14, 25, 14, 26, 
151
  26, 14, 14, 14, 14, 14, 14, 14, 
152
  14, 14, 14, 14, 14, 14, 16, 14, 
153
  14, 14, 14, 14, 27, 14, 26, 26, 
154
  14, 14, 14, 14, 14, 14, 14, 14, 
155
  14, 14, 14, 14, 14, 14, 14, 14, 
156
  14, 14, 14, 27, 14, 29, 29, 28, 
157
  30, 31, 31, 28, 28, 28, 13, 13, 
158
  28, 28, 28, 29, 28, 28, 28, 28, 
159
  16, 25, 27, 23, 28, 17, 18, 20, 
160
  28, 33, 34, 34, 32, 32, 32, 32, 
161
  32, 32, 32, 32, 32, 32, 32, 32, 
162
  32, 2, 10, 12, 8, 32, 13, 4, 
163
  5, 32, 35, 35, 32, 32, 32, 32, 
164
  32, 32, 32, 32, 32, 32, 32, 32, 
165
  35, 32, 33, 36, 36, 32, 32, 32, 
166
  32, 32, 32, 32, 32, 32, 32, 32, 
167
  32, 32, 2, 10, 12, 8, 32, 3, 
168
  4, 5, 32, 37, 38, 38, 32, 32, 
169
  32, 32, 32, 32, 32, 32, 32, 32, 
170
  32, 32, 32, 2, 10, 12, 8, 32, 
171
  32, 4, 5, 32, 5, 32, 37, 6, 
172
  6, 32, 32, 32, 32, 32, 32, 32, 
173
  32, 32, 32, 32, 32, 32, 32, 32, 
174
  32, 8, 32, 32, 2, 5, 32, 37, 
175
  7, 7, 32, 32, 32, 32, 32, 32, 
176
  32, 32, 32, 32, 32, 32, 32, 32, 
177
  32, 32, 32, 32, 32, 8, 5, 32, 
178
  37, 39, 39, 32, 32, 32, 32, 32, 
179
  32, 32, 32, 32, 32, 32, 32, 32, 
180
  2, 32, 32, 8, 32, 32, 10, 5, 
181
  32, 37, 40, 40, 32, 32, 32, 32, 
182
  32, 32, 32, 32, 32, 32, 32, 32, 
183
  32, 2, 10, 32, 8, 32, 32, 12, 
184
  5, 32, 33, 38, 38, 32, 32, 32, 
185
  32, 32, 32, 32, 32, 32, 32, 32, 
186
  32, 32, 2, 10, 12, 8, 32, 32, 
187
  4, 5, 32, 33, 38, 38, 32, 32, 
188
  32, 32, 32, 32, 32, 32, 32, 32, 
189
  32, 32, 32, 2, 10, 12, 8, 32, 
190
  3, 4, 5, 32, 42, 42, 41, 41, 
191
  41, 41, 41, 41, 41, 41, 41, 41, 
192
  41, 41, 42, 41, 30, 43, 43, 41, 
193
  41, 41, 41, 41, 41, 41, 41, 41, 
194
  41, 41, 41, 41, 16, 25, 27, 23, 
195
  41, 17, 18, 20, 41, 44, 45, 45, 
196
  41, 41, 41, 41, 41, 41, 41, 41, 
197
  41, 41, 41, 41, 41, 16, 25, 27, 
198
  23, 41, 41, 18, 20, 41, 20, 41, 
199
  44, 21, 21, 41, 41, 41, 41, 41, 
200
  41, 41, 41, 41, 41, 41, 41, 41, 
201
  41, 41, 41, 23, 41, 41, 16, 20, 
202
  41, 44, 22, 22, 41, 41, 41, 41, 
203
  41, 41, 41, 41, 41, 41, 41, 41, 
204
  41, 41, 41, 41, 41, 41, 41, 23, 
205
  20, 41, 44, 46, 46, 41, 41, 41, 
206
  41, 41, 41, 41, 41, 41, 41, 41, 
207
  41, 41, 16, 41, 41, 23, 41, 41, 
208
  25, 20, 41, 44, 47, 47, 41, 41, 
209
  41, 41, 41, 41, 41, 41, 41, 41, 
210
  41, 41, 41, 16, 25, 41, 23, 41, 
211
  41, 27, 20, 41, 30, 45, 45, 41, 
212
  41, 41, 41, 41, 41, 41, 41, 41, 
213
  41, 41, 41, 41, 16, 25, 27, 23, 
214
  41, 41, 18, 20, 41, 15, 15, 48, 
215
  48, 48, 48, 48, 48, 48, 48, 48, 
216
  48, 48, 48, 48, 16, 48, 48, 48, 
217
  48, 48, 18, 48, 0
218
};
219
220
static const char _khmer_syllable_machine_trans_targs[] = {
221
  21, 1, 27, 31, 25, 26, 4, 5, 
222
  28, 7, 29, 9, 30, 32, 21, 12, 
223
  37, 41, 35, 21, 36, 15, 16, 38, 
224
  18, 39, 20, 40, 21, 22, 33, 42, 
225
  21, 23, 10, 24, 0, 2, 3, 6, 
226
  8, 21, 34, 11, 13, 14, 17, 19, 
227
  21
228
};
229
230
static const char _khmer_syllable_machine_trans_actions[] = {
231
  1, 0, 2, 2, 2, 0, 0, 0, 
232
  2, 0, 2, 0, 2, 2, 3, 0, 
233
  2, 4, 4, 5, 0, 0, 0, 2, 
234
  0, 2, 0, 2, 8, 2, 0, 9, 
235
  10, 0, 0, 2, 0, 0, 0, 0, 
236
  0, 11, 4, 0, 0, 0, 0, 0, 
237
  12
238
};
239
240
static const char _khmer_syllable_machine_to_state_actions[] = {
241
  0, 0, 0, 0, 0, 0, 0, 0, 
242
  0, 0, 0, 0, 0, 0, 0, 0, 
243
  0, 0, 0, 0, 0, 6, 0, 0, 
244
  0, 0, 0, 0, 0, 0, 0, 0, 
245
  0, 0, 0, 0, 0, 0, 0, 0, 
246
  0, 0, 0
247
};
248
249
static const char _khmer_syllable_machine_from_state_actions[] = {
250
  0, 0, 0, 0, 0, 0, 0, 0, 
251
  0, 0, 0, 0, 0, 0, 0, 0, 
252
  0, 0, 0, 0, 0, 7, 0, 0, 
253
  0, 0, 0, 0, 0, 0, 0, 0, 
254
  0, 0, 0, 0, 0, 0, 0, 0, 
255
  0, 0, 0
256
};
257
258
static const short _khmer_syllable_machine_eof_trans[] = {
259
  1, 1, 1, 1, 1, 1, 1, 1, 
260
  1, 1, 1, 15, 20, 15, 15, 15, 
261
  15, 15, 15, 15, 15, 0, 33, 33, 
262
  33, 33, 33, 33, 33, 33, 33, 33, 
263
  33, 42, 42, 42, 42, 42, 42, 42, 
264
  42, 42, 49
265
};
266
267
static const int khmer_syllable_machine_start = 21;
268
static const int khmer_syllable_machine_first_final = 21;
269
static const int khmer_syllable_machine_error = -1;
270
271
static const int khmer_syllable_machine_en_main = 21;
272
273
274
#line 53 "hb-ot-shaper-khmer-machine.rl"
275
276
277
278
#line 102 "hb-ot-shaper-khmer-machine.rl"
279
280
281
#define found_syllable(syllable_type) \
282
2.61M
  HB_STMT_START { \
283
2.61M
    if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
284
5.24M
    for (unsigned int i = ts; i < te; i++) \
285
2.63M
      info[i].syllable() = (syllable_serial << 4) | syllable_type; \
286
2.61M
    syllable_serial++; \
287
2.61M
    if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
288
2.61M
  } HB_STMT_END
289
290
inline void
291
find_syllables_khmer (hb_buffer_t *buffer)
292
3.00k
{
293
3.00k
  unsigned int p, pe, eof, ts, te, act HB_UNUSED;
294
3.00k
  int cs;
295
3.00k
  hb_glyph_info_t *info = buffer->info;
296
  
297
3.00k
#line 287 "hb-ot-shaper-khmer-machine.hh"
298
3.00k
  {
299
3.00k
  cs = khmer_syllable_machine_start;
300
3.00k
  ts = 0;
301
3.00k
  te = 0;
302
3.00k
  act = 0;
303
3.00k
  }
304
305
3.00k
#line 122 "hb-ot-shaper-khmer-machine.rl"
306
307
308
3.00k
  p = 0;
309
3.00k
  pe = eof = buffer->len;
310
311
3.00k
  unsigned int syllable_serial = 1;
312
  
313
3.00k
#line 299 "hb-ot-shaper-khmer-machine.hh"
314
3.00k
  {
315
3.00k
  int _slen;
316
3.00k
  int _trans;
317
3.00k
  const unsigned char *_keys;
318
3.00k
  const char *_inds;
319
3.00k
  if ( p == pe )
320
30
    goto _test_eof;
321
13.5M
_resume:
322
13.5M
  switch ( _khmer_syllable_machine_from_state_actions[cs] ) {
323
2.61M
  case 7:
324
2.61M
#line 1 "NONE"
325
2.61M
  {ts = p;}
326
2.61M
  break;
327
13.5M
#line 311 "hb-ot-shaper-khmer-machine.hh"
328
13.5M
  }
329
330
13.5M
  _keys = _khmer_syllable_machine_trans_keys + (cs<<1);
331
13.5M
  _inds = _khmer_syllable_machine_indicies + _khmer_syllable_machine_index_offsets[cs];
332
333
13.5M
  _slen = _khmer_syllable_machine_key_spans[cs];
334
13.5M
  _trans = _inds[ _slen > 0 && _keys[0] <=( info[p].khmer_category()) &&
335
13.5M
    ( info[p].khmer_category()) <= _keys[1] ?
336
11.4M
    ( info[p].khmer_category()) - _keys[0] : _slen ];
337
338
13.5M
_eof_trans:
339
13.5M
  cs = _khmer_syllable_machine_trans_targs[_trans];
340
341
13.5M
  if ( _khmer_syllable_machine_trans_actions[_trans] == 0 )
342
10.6M
    goto _again;
343
344
2.94M
  switch ( _khmer_syllable_machine_trans_actions[_trans] ) {
345
224k
  case 2:
346
224k
#line 1 "NONE"
347
224k
  {te = p+1;}
348
224k
  break;
349
2.21M
  case 8:
350
2.21M
#line 98 "hb-ot-shaper-khmer-machine.rl"
351
2.21M
  {te = p+1;{ found_syllable (khmer_non_khmer_cluster); }}
352
2.21M
  break;
353
112k
  case 10:
354
112k
#line 96 "hb-ot-shaper-khmer-machine.rl"
355
112k
  {te = p;p--;{ found_syllable (khmer_consonant_syllable); }}
356
112k
  break;
357
249k
  case 11:
358
249k
#line 97 "hb-ot-shaper-khmer-machine.rl"
359
249k
  {te = p;p--;{ found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }}
360
249k
  break;
361
1.15k
  case 12:
362
1.15k
#line 98 "hb-ot-shaper-khmer-machine.rl"
363
1.15k
  {te = p;p--;{ found_syllable (khmer_non_khmer_cluster); }}
364
1.15k
  break;
365
211
  case 1:
366
211
#line 96 "hb-ot-shaper-khmer-machine.rl"
367
211
  {{p = ((te))-1;}{ found_syllable (khmer_consonant_syllable); }}
368
211
  break;
369
322
  case 3:
370
322
#line 97 "hb-ot-shaper-khmer-machine.rl"
371
322
  {{p = ((te))-1;}{ found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }}
372
322
  break;
373
31.7k
  case 5:
374
31.7k
#line 1 "NONE"
375
31.7k
  { switch( act ) {
376
81
  case 2:
377
81
  {{p = ((te))-1;} found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }
378
81
  break;
379
31.6k
  case 3:
380
31.6k
  {{p = ((te))-1;} found_syllable (khmer_non_khmer_cluster); }
381
31.6k
  break;
382
31.7k
  }
383
31.7k
  }
384
31.7k
  break;
385
76.8k
  case 4:
386
76.8k
#line 1 "NONE"
387
76.8k
  {te = p+1;}
388
76.8k
#line 97 "hb-ot-shaper-khmer-machine.rl"
389
76.8k
  {act = 2;}
390
76.8k
  break;
391
32.8k
  case 9:
392
32.8k
#line 1 "NONE"
393
32.8k
  {te = p+1;}
394
32.8k
#line 98 "hb-ot-shaper-khmer-machine.rl"
395
32.8k
  {act = 3;}
396
32.8k
  break;
397
2.94M
#line 368 "hb-ot-shaper-khmer-machine.hh"
398
2.94M
  }
399
400
13.5M
_again:
401
13.5M
  switch ( _khmer_syllable_machine_to_state_actions[cs] ) {
402
2.61M
  case 6:
403
2.61M
#line 1 "NONE"
404
2.61M
  {ts = 0;}
405
2.61M
  break;
406
13.5M
#line 375 "hb-ot-shaper-khmer-machine.hh"
407
13.5M
  }
408
409
13.5M
  if ( ++p != pe )
410
13.5M
    goto _resume;
411
4.63k
  _test_eof: {}
412
4.63k
  if ( p == eof )
413
4.63k
  {
414
4.63k
  if ( _khmer_syllable_machine_eof_trans[cs] > 0 ) {
415
1.63k
    _trans = _khmer_syllable_machine_eof_trans[cs] - 1;
416
1.63k
    goto _eof_trans;
417
1.63k
  }
418
4.63k
  }
419
420
4.63k
  }
421
422
4.63k
#line 130 "hb-ot-shaper-khmer-machine.rl"
423
424
4.63k
}
425
426
#undef found_syllable
427
428
#endif /* HB_OT_SHAPER_KHMER_MACHINE_HH */