tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

hb-ot-shaper-khmer-machine.hh (12157B)


      1 #line 1 "hb-ot-shaper-khmer-machine.rl"
      2 /*
      3 * Copyright © 2011,2012  Google, Inc.
      4 *
      5 *  This is part of HarfBuzz, a text shaping library.
      6 *
      7 * Permission is hereby granted, without written agreement and without
      8 * license or royalty fees, to use, copy, modify, and distribute this
      9 * software and its documentation for any purpose, provided that the
     10 * above copyright notice and the following two paragraphs appear in
     11 * all copies of this software.
     12 *
     13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
     14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
     15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
     16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
     17 * DAMAGE.
     18 *
     19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
     20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     21 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
     22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
     23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
     24 *
     25 * Google Author(s): Behdad Esfahbod
     26 */
     27 
     28 #ifndef HB_OT_SHAPER_KHMER_MACHINE_HH
     29 #define HB_OT_SHAPER_KHMER_MACHINE_HH
     30 
     31 #include "hb.hh"
     32 
     33 #include "hb-ot-layout.hh"
     34 #include "hb-ot-shaper-indic.hh"
     35 
     36 /* buffer var allocations */
     37 #define khmer_category() ot_shaper_var_u8_category() /* khmer_category_t */
     38 
     39 using khmer_category_t = unsigned;
     40 
     41 #define K_Cat(Cat) khmer_syllable_machine_ex_##Cat
     42 
     43 enum khmer_syllable_type_t {
     44  khmer_consonant_syllable,
     45  khmer_broken_cluster,
     46  khmer_non_khmer_cluster,
     47 };
     48 
     49 
     50 #line 49 "hb-ot-shaper-khmer-machine.hh"
     51 #define khmer_syllable_machine_ex_C 1u
     52 #define khmer_syllable_machine_ex_DOTTEDCIRCLE 11u
     53 #define khmer_syllable_machine_ex_H 4u
     54 #define khmer_syllable_machine_ex_PLACEHOLDER 10u
     55 #define khmer_syllable_machine_ex_Ra 15u
     56 #define khmer_syllable_machine_ex_Robatic 25u
     57 #define khmer_syllable_machine_ex_V 2u
     58 #define khmer_syllable_machine_ex_VAbv 20u
     59 #define khmer_syllable_machine_ex_VBlw 21u
     60 #define khmer_syllable_machine_ex_VPre 22u
     61 #define khmer_syllable_machine_ex_VPst 23u
     62 #define khmer_syllable_machine_ex_Xgroup 26u
     63 #define khmer_syllable_machine_ex_Ygroup 27u
     64 #define khmer_syllable_machine_ex_ZWJ 6u
     65 #define khmer_syllable_machine_ex_ZWNJ 5u
     66 
     67 
     68 #line 65 "hb-ot-shaper-khmer-machine.hh"
     69 static const unsigned char _khmer_syllable_machine_trans_keys[] = {
     70 5u, 26u, 5u, 26u, 1u, 15u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 
     71 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 1u, 15u, 5u, 26u, 5u, 26u, 
     72 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 1u, 27u, 4u, 27u, 1u, 15u, 
     73 4u, 27u, 4u, 27u, 27u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 
     74 4u, 27u, 1u, 15u, 4u, 27u, 4u, 27u, 27u, 27u, 4u, 27u, 4u, 27u, 4u, 27u, 
     75 4u, 27u, 4u, 27u, 5u, 26u, 0
     76 };
     77 
     78 static const char _khmer_syllable_machine_key_spans[] = {
     79 22, 22, 15, 22, 22, 22, 22, 22, 
     80 22, 22, 22, 22, 22, 15, 22, 22, 
     81 22, 22, 22, 22, 22, 27, 24, 15, 
     82 24, 24, 1, 24, 24, 24, 24, 24, 
     83 24, 15, 24, 24, 1, 24, 24, 24, 
     84 24, 24, 22
     85 };
     86 
     87 static const short _khmer_syllable_machine_index_offsets[] = {
     88 0, 23, 46, 62, 85, 108, 131, 154, 
     89 177, 200, 223, 246, 269, 292, 308, 331, 
     90 354, 377, 400, 423, 446, 469, 497, 522, 
     91 538, 563, 588, 590, 615, 640, 665, 690, 
     92 715, 740, 756, 781, 806, 808, 833, 858, 
     93 883, 908, 933
     94 };
     95 
     96 static const char _khmer_syllable_machine_indicies[] = {
     97 1, 1, 0, 0, 0, 0, 0, 0, 
     98 0, 0, 0, 0, 0, 0, 0, 2, 
     99 0, 0, 0, 0, 3, 4, 0, 1, 
    100 1, 0, 0, 0, 0, 0, 0, 0, 
    101 0, 0, 0, 0, 0, 0, 0, 0, 
    102 0, 0, 0, 0, 4, 0, 5, 5, 
    103 0, 0, 0, 0, 0, 0, 0, 0, 
    104 0, 0, 0, 0, 5, 0, 1, 1, 
    105 0, 0, 0, 0, 0, 0, 0, 0, 
    106 0, 0, 0, 0, 0, 2, 0, 0, 
    107 0, 0, 0, 4, 0, 6, 6, 0, 
    108 0, 0, 0, 0, 0, 0, 0, 0, 
    109 0, 0, 0, 0, 0, 0, 0, 0, 
    110 0, 0, 2, 0, 7, 7, 0, 0, 
    111 0, 0, 0, 0, 0, 0, 0, 0, 
    112 0, 0, 0, 0, 0, 0, 0, 0, 
    113 0, 8, 0, 9, 9, 0, 0, 0, 
    114 0, 0, 0, 0, 0, 0, 0, 0, 
    115 0, 0, 2, 0, 0, 0, 0, 0, 
    116 10, 0, 9, 9, 0, 0, 0, 0, 
    117 0, 0, 0, 0, 0, 0, 0, 0, 
    118 0, 0, 0, 0, 0, 0, 0, 10, 
    119 0, 11, 11, 0, 0, 0, 0, 0, 
    120 0, 0, 0, 0, 0, 0, 0, 0, 
    121 2, 0, 0, 0, 0, 0, 12, 0, 
    122 11, 11, 0, 0, 0, 0, 0, 0, 
    123 0, 0, 0, 0, 0, 0, 0, 0, 
    124 0, 0, 0, 0, 0, 12, 0, 1, 
    125 1, 0, 0, 0, 0, 0, 0, 0, 
    126 0, 0, 0, 0, 0, 0, 2, 0, 
    127 0, 0, 0, 13, 4, 0, 15, 15, 
    128 14, 14, 14, 14, 14, 14, 14, 14, 
    129 14, 14, 14, 14, 14, 16, 14, 14, 
    130 14, 14, 17, 18, 14, 15, 15, 19, 
    131 19, 19, 19, 19, 19, 19, 19, 19, 
    132 19, 19, 19, 19, 19, 19, 19, 19, 
    133 19, 19, 18, 19, 20, 20, 14, 14, 
    134 14, 14, 14, 14, 14, 14, 14, 14, 
    135 14, 14, 20, 14, 15, 15, 14, 14, 
    136 14, 14, 14, 14, 14, 14, 14, 14, 
    137 14, 14, 14, 16, 14, 14, 14, 14, 
    138 14, 18, 14, 21, 21, 14, 14, 14, 
    139 14, 14, 14, 14, 14, 14, 14, 14, 
    140 14, 14, 14, 14, 14, 14, 14, 14, 
    141 16, 14, 22, 22, 14, 14, 14, 14, 
    142 14, 14, 14, 14, 14, 14, 14, 14, 
    143 14, 14, 14, 14, 14, 14, 14, 23, 
    144 14, 24, 24, 14, 14, 14, 14, 14, 
    145 14, 14, 14, 14, 14, 14, 14, 14, 
    146 16, 14, 14, 14, 14, 14, 25, 14, 
    147 24, 24, 14, 14, 14, 14, 14, 14, 
    148 14, 14, 14, 14, 14, 14, 14, 14, 
    149 14, 14, 14, 14, 14, 25, 14, 26, 
    150 26, 14, 14, 14, 14, 14, 14, 14, 
    151 14, 14, 14, 14, 14, 14, 16, 14, 
    152 14, 14, 14, 14, 27, 14, 26, 26, 
    153 14, 14, 14, 14, 14, 14, 14, 14, 
    154 14, 14, 14, 14, 14, 14, 14, 14, 
    155 14, 14, 14, 27, 14, 29, 29, 28, 
    156 30, 31, 31, 28, 28, 28, 13, 13, 
    157 28, 28, 28, 29, 28, 28, 28, 28, 
    158 16, 25, 27, 23, 28, 17, 18, 20, 
    159 28, 33, 34, 34, 32, 32, 32, 32, 
    160 32, 32, 32, 32, 32, 32, 32, 32, 
    161 32, 2, 10, 12, 8, 32, 13, 4, 
    162 5, 32, 35, 35, 32, 32, 32, 32, 
    163 32, 32, 32, 32, 32, 32, 32, 32, 
    164 35, 32, 33, 36, 36, 32, 32, 32, 
    165 32, 32, 32, 32, 32, 32, 32, 32, 
    166 32, 32, 2, 10, 12, 8, 32, 3, 
    167 4, 5, 32, 37, 38, 38, 32, 32, 
    168 32, 32, 32, 32, 32, 32, 32, 32, 
    169 32, 32, 32, 2, 10, 12, 8, 32, 
    170 32, 4, 5, 32, 5, 32, 37, 6, 
    171 6, 32, 32, 32, 32, 32, 32, 32, 
    172 32, 32, 32, 32, 32, 32, 32, 32, 
    173 32, 8, 32, 32, 2, 5, 32, 37, 
    174 7, 7, 32, 32, 32, 32, 32, 32, 
    175 32, 32, 32, 32, 32, 32, 32, 32, 
    176 32, 32, 32, 32, 32, 8, 5, 32, 
    177 37, 39, 39, 32, 32, 32, 32, 32, 
    178 32, 32, 32, 32, 32, 32, 32, 32, 
    179 2, 32, 32, 8, 32, 32, 10, 5, 
    180 32, 37, 40, 40, 32, 32, 32, 32, 
    181 32, 32, 32, 32, 32, 32, 32, 32, 
    182 32, 2, 10, 32, 8, 32, 32, 12, 
    183 5, 32, 33, 38, 38, 32, 32, 32, 
    184 32, 32, 32, 32, 32, 32, 32, 32, 
    185 32, 32, 2, 10, 12, 8, 32, 32, 
    186 4, 5, 32, 33, 38, 38, 32, 32, 
    187 32, 32, 32, 32, 32, 32, 32, 32, 
    188 32, 32, 32, 2, 10, 12, 8, 32, 
    189 3, 4, 5, 32, 42, 42, 41, 41, 
    190 41, 41, 41, 41, 41, 41, 41, 41, 
    191 41, 41, 42, 41, 30, 43, 43, 41, 
    192 41, 41, 41, 41, 41, 41, 41, 41, 
    193 41, 41, 41, 41, 16, 25, 27, 23, 
    194 41, 17, 18, 20, 41, 44, 45, 45, 
    195 41, 41, 41, 41, 41, 41, 41, 41, 
    196 41, 41, 41, 41, 41, 16, 25, 27, 
    197 23, 41, 41, 18, 20, 41, 20, 41, 
    198 44, 21, 21, 41, 41, 41, 41, 41, 
    199 41, 41, 41, 41, 41, 41, 41, 41, 
    200 41, 41, 41, 23, 41, 41, 16, 20, 
    201 41, 44, 22, 22, 41, 41, 41, 41, 
    202 41, 41, 41, 41, 41, 41, 41, 41, 
    203 41, 41, 41, 41, 41, 41, 41, 23, 
    204 20, 41, 44, 46, 46, 41, 41, 41, 
    205 41, 41, 41, 41, 41, 41, 41, 41, 
    206 41, 41, 16, 41, 41, 23, 41, 41, 
    207 25, 20, 41, 44, 47, 47, 41, 41, 
    208 41, 41, 41, 41, 41, 41, 41, 41, 
    209 41, 41, 41, 16, 25, 41, 23, 41, 
    210 41, 27, 20, 41, 30, 45, 45, 41, 
    211 41, 41, 41, 41, 41, 41, 41, 41, 
    212 41, 41, 41, 41, 16, 25, 27, 23, 
    213 41, 41, 18, 20, 41, 15, 15, 48, 
    214 48, 48, 48, 48, 48, 48, 48, 48, 
    215 48, 48, 48, 48, 16, 48, 48, 48, 
    216 48, 48, 18, 48, 0
    217 };
    218 
    219 static const char _khmer_syllable_machine_trans_targs[] = {
    220 21, 1, 27, 31, 25, 26, 4, 5, 
    221 28, 7, 29, 9, 30, 32, 21, 12, 
    222 37, 41, 35, 21, 36, 15, 16, 38, 
    223 18, 39, 20, 40, 21, 22, 33, 42, 
    224 21, 23, 10, 24, 0, 2, 3, 6, 
    225 8, 21, 34, 11, 13, 14, 17, 19, 
    226 21
    227 };
    228 
    229 static const char _khmer_syllable_machine_trans_actions[] = {
    230 1, 0, 2, 2, 2, 0, 0, 0, 
    231 2, 0, 2, 0, 2, 2, 3, 0, 
    232 2, 4, 4, 5, 0, 0, 0, 2, 
    233 0, 2, 0, 2, 8, 2, 0, 9, 
    234 10, 0, 0, 2, 0, 0, 0, 0, 
    235 0, 11, 4, 0, 0, 0, 0, 0, 
    236 12
    237 };
    238 
    239 static const char _khmer_syllable_machine_to_state_actions[] = {
    240 0, 0, 0, 0, 0, 0, 0, 0, 
    241 0, 0, 0, 0, 0, 0, 0, 0, 
    242 0, 0, 0, 0, 0, 6, 0, 0, 
    243 0, 0, 0, 0, 0, 0, 0, 0, 
    244 0, 0, 0, 0, 0, 0, 0, 0, 
    245 0, 0, 0
    246 };
    247 
    248 static const char _khmer_syllable_machine_from_state_actions[] = {
    249 0, 0, 0, 0, 0, 0, 0, 0, 
    250 0, 0, 0, 0, 0, 0, 0, 0, 
    251 0, 0, 0, 0, 0, 7, 0, 0, 
    252 0, 0, 0, 0, 0, 0, 0, 0, 
    253 0, 0, 0, 0, 0, 0, 0, 0, 
    254 0, 0, 0
    255 };
    256 
    257 static const short _khmer_syllable_machine_eof_trans[] = {
    258 1, 1, 1, 1, 1, 1, 1, 1, 
    259 1, 1, 1, 15, 20, 15, 15, 15, 
    260 15, 15, 15, 15, 15, 0, 33, 33, 
    261 33, 33, 33, 33, 33, 33, 33, 33, 
    262 33, 42, 42, 42, 42, 42, 42, 42, 
    263 42, 42, 49
    264 };
    265 
    266 static const int khmer_syllable_machine_start = 21;
    267 static const int khmer_syllable_machine_first_final = 21;
    268 static const int khmer_syllable_machine_error = -1;
    269 
    270 static const int khmer_syllable_machine_en_main = 21;
    271 
    272 
    273 #line 53 "hb-ot-shaper-khmer-machine.rl"
    274 
    275 
    276 
    277 #line 102 "hb-ot-shaper-khmer-machine.rl"
    278 
    279 
    280 #define found_syllable(syllable_type) \
    281  HB_STMT_START { \
    282    if (0) fprintf (stderr, "syllable %u..%u %s\n", ts, te, #syllable_type); \
    283    for (unsigned int i = ts; i < te; i++) \
    284      info[i].syllable() = (syllable_serial << 4) | syllable_type; \
    285    syllable_serial++; \
    286    if (syllable_serial == 16) syllable_serial = 1; \
    287  } HB_STMT_END
    288 
    289 inline void
    290 find_syllables_khmer (hb_buffer_t *buffer)
    291 {
    292  unsigned int p, pe, eof, ts, te, act HB_UNUSED;
    293  int cs;
    294  hb_glyph_info_t *info = buffer->info;
    295  
    296 #line 287 "hb-ot-shaper-khmer-machine.hh"
    297 {
    298 cs = khmer_syllable_machine_start;
    299 ts = 0;
    300 te = 0;
    301 act = 0;
    302 }
    303 
    304 #line 122 "hb-ot-shaper-khmer-machine.rl"
    305 
    306 
    307  p = 0;
    308  pe = eof = buffer->len;
    309 
    310  unsigned int syllable_serial = 1;
    311  
    312 #line 299 "hb-ot-shaper-khmer-machine.hh"
    313 {
    314 int _slen;
    315 int _trans;
    316 const unsigned char *_keys;
    317 const char *_inds;
    318 if ( p == pe )
    319 	goto _test_eof;
    320 _resume:
    321 switch ( _khmer_syllable_machine_from_state_actions[cs] ) {
    322 case 7:
    323 #line 1 "NONE"
    324 {ts = p;}
    325 break;
    326 #line 311 "hb-ot-shaper-khmer-machine.hh"
    327 }
    328 
    329 _keys = _khmer_syllable_machine_trans_keys + (cs<<1);
    330 _inds = _khmer_syllable_machine_indicies + _khmer_syllable_machine_index_offsets[cs];
    331 
    332 _slen = _khmer_syllable_machine_key_spans[cs];
    333 _trans = _inds[ _slen > 0 && _keys[0] <=( info[p].khmer_category()) &&
    334 	( info[p].khmer_category()) <= _keys[1] ?
    335 	( info[p].khmer_category()) - _keys[0] : _slen ];
    336 
    337 _eof_trans:
    338 cs = _khmer_syllable_machine_trans_targs[_trans];
    339 
    340 if ( _khmer_syllable_machine_trans_actions[_trans] == 0 )
    341 	goto _again;
    342 
    343 switch ( _khmer_syllable_machine_trans_actions[_trans] ) {
    344 case 2:
    345 #line 1 "NONE"
    346 {te = p+1;}
    347 break;
    348 case 8:
    349 #line 98 "hb-ot-shaper-khmer-machine.rl"
    350 {te = p+1;{ found_syllable (khmer_non_khmer_cluster); }}
    351 break;
    352 case 10:
    353 #line 96 "hb-ot-shaper-khmer-machine.rl"
    354 {te = p;p--;{ found_syllable (khmer_consonant_syllable); }}
    355 break;
    356 case 11:
    357 #line 97 "hb-ot-shaper-khmer-machine.rl"
    358 {te = p;p--;{ found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }}
    359 break;
    360 case 12:
    361 #line 98 "hb-ot-shaper-khmer-machine.rl"
    362 {te = p;p--;{ found_syllable (khmer_non_khmer_cluster); }}
    363 break;
    364 case 1:
    365 #line 96 "hb-ot-shaper-khmer-machine.rl"
    366 {{p = ((te))-1;}{ found_syllable (khmer_consonant_syllable); }}
    367 break;
    368 case 3:
    369 #line 97 "hb-ot-shaper-khmer-machine.rl"
    370 {{p = ((te))-1;}{ found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }}
    371 break;
    372 case 5:
    373 #line 1 "NONE"
    374 {	switch( act ) {
    375 case 2:
    376 {{p = ((te))-1;} found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }
    377 break;
    378 case 3:
    379 {{p = ((te))-1;} found_syllable (khmer_non_khmer_cluster); }
    380 break;
    381 }
    382 }
    383 break;
    384 case 4:
    385 #line 1 "NONE"
    386 {te = p+1;}
    387 #line 97 "hb-ot-shaper-khmer-machine.rl"
    388 {act = 2;}
    389 break;
    390 case 9:
    391 #line 1 "NONE"
    392 {te = p+1;}
    393 #line 98 "hb-ot-shaper-khmer-machine.rl"
    394 {act = 3;}
    395 break;
    396 #line 368 "hb-ot-shaper-khmer-machine.hh"
    397 }
    398 
    399 _again:
    400 switch ( _khmer_syllable_machine_to_state_actions[cs] ) {
    401 case 6:
    402 #line 1 "NONE"
    403 {ts = 0;}
    404 break;
    405 #line 375 "hb-ot-shaper-khmer-machine.hh"
    406 }
    407 
    408 if ( ++p != pe )
    409 	goto _resume;
    410 _test_eof: {}
    411 if ( p == eof )
    412 {
    413 if ( _khmer_syllable_machine_eof_trans[cs] > 0 ) {
    414 	_trans = _khmer_syllable_machine_eof_trans[cs] - 1;
    415 	goto _eof_trans;
    416 }
    417 }
    418 
    419 }
    420 
    421 #line 130 "hb-ot-shaper-khmer-machine.rl"
    422 
    423 }
    424 
    425 #undef found_syllable
    426 
    427 #endif /* HB_OT_SHAPER_KHMER_MACHINE_HH */