gfx/harfbuzz/src/hb-ot-shape-complex-myanmar-machine.rl

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright © 2011,2012 Google, Inc.
michael@0 3 *
michael@0 4 * This is part of HarfBuzz, a text shaping library.
michael@0 5 *
michael@0 6 * Permission is hereby granted, without written agreement and without
michael@0 7 * license or royalty fees, to use, copy, modify, and distribute this
michael@0 8 * software and its documentation for any purpose, provided that the
michael@0 9 * above copyright notice and the following two paragraphs appear in
michael@0 10 * all copies of this software.
michael@0 11 *
michael@0 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
michael@0 13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
michael@0 14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
michael@0 15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
michael@0 16 * DAMAGE.
michael@0 17 *
michael@0 18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
michael@0 19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
michael@0 20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
michael@0 21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
michael@0 22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
michael@0 23 *
michael@0 24 * Google Author(s): Behdad Esfahbod
michael@0 25 */
michael@0 26
michael@0 27 #ifndef HB_OT_SHAPE_COMPLEX_MYANMAR_MACHINE_HH
michael@0 28 #define HB_OT_SHAPE_COMPLEX_MYANMAR_MACHINE_HH
michael@0 29
michael@0 30 #include "hb-private.hh"
michael@0 31
michael@0 32 %%{
michael@0 33 machine myanmar_syllable_machine;
michael@0 34 alphtype unsigned char;
michael@0 35 write data;
michael@0 36 }%%
michael@0 37
michael@0 38 %%{
michael@0 39
michael@0 40 # Same order as enum myanmar_category_t. Not sure how to avoid duplication.
michael@0 41 A = 10;
michael@0 42 As = 18;
michael@0 43 C = 1;
michael@0 44 D = 19;
michael@0 45 D0 = 20;
michael@0 46 DB = 3;
michael@0 47 GB = 12;
michael@0 48 H = 4;
michael@0 49 IV = 2;
michael@0 50 MH = 21;
michael@0 51 MR = 22;
michael@0 52 MW = 23;
michael@0 53 MY = 24;
michael@0 54 PT = 25;
michael@0 55 V = 8;
michael@0 56 VAbv = 26;
michael@0 57 VBlw = 27;
michael@0 58 VPre = 28;
michael@0 59 VPst = 29;
michael@0 60 VS = 30;
michael@0 61 ZWJ = 6;
michael@0 62 ZWNJ = 5;
michael@0 63 Ra = 16;
michael@0 64 P = 31;
michael@0 65
michael@0 66 j = ZWJ|ZWNJ; # Joiners
michael@0 67 k = (Ra As H); # Kinzi
michael@0 68
michael@0 69 c = C|Ra; # is_consonant
michael@0 70
michael@0 71 medial_group = MY? MR? ((MW MH? | MH) As?)?;
michael@0 72 main_vowel_group = VPre* VAbv* VBlw* A* (DB As?)?;
michael@0 73 post_vowel_group = VPst MH? As* VAbv* A* (DB As?)?;
michael@0 74 pwo_tone_group = PT A* DB? As?;
michael@0 75
michael@0 76 complex_syllable_tail = As* medial_group main_vowel_group post_vowel_group* pwo_tone_group* V* j?;
michael@0 77 syllable_tail = (H | complex_syllable_tail);
michael@0 78
michael@0 79 consonant_syllable = k? (c|IV|D|GB).VS? (H (c|IV).VS?)* syllable_tail;
michael@0 80 punctuation_cluster = P V;
michael@0 81 broken_cluster = k? VS? syllable_tail;
michael@0 82 other = any;
michael@0 83
michael@0 84 main := |*
michael@0 85 consonant_syllable => { found_syllable (consonant_syllable); };
michael@0 86 j => { found_syllable (non_myanmar_cluster); };
michael@0 87 punctuation_cluster => { found_syllable (punctuation_cluster); };
michael@0 88 broken_cluster => { found_syllable (broken_cluster); };
michael@0 89 other => { found_syllable (non_myanmar_cluster); };
michael@0 90 *|;
michael@0 91
michael@0 92
michael@0 93 }%%
michael@0 94
michael@0 95 #define found_syllable(syllable_type) \
michael@0 96 HB_STMT_START { \
michael@0 97 if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
michael@0 98 for (unsigned int i = last; i < p+1; i++) \
michael@0 99 info[i].syllable() = (syllable_serial << 4) | syllable_type; \
michael@0 100 last = p+1; \
michael@0 101 syllable_serial++; \
michael@0 102 if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
michael@0 103 } HB_STMT_END
michael@0 104
michael@0 105 static void
michael@0 106 find_syllables (hb_buffer_t *buffer)
michael@0 107 {
michael@0 108 unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
michael@0 109 int cs;
michael@0 110 hb_glyph_info_t *info = buffer->info;
michael@0 111 %%{
michael@0 112 write init;
michael@0 113 getkey info[p].myanmar_category();
michael@0 114 }%%
michael@0 115
michael@0 116 p = 0;
michael@0 117 pe = eof = buffer->len;
michael@0 118
michael@0 119 unsigned int last = 0;
michael@0 120 unsigned int syllable_serial = 1;
michael@0 121 %%{
michael@0 122 write exec;
michael@0 123 }%%
michael@0 124 }
michael@0 125
michael@0 126 #undef found_syllable
michael@0 127
michael@0 128 #endif /* HB_OT_SHAPE_COMPLEX_MYANMAR_MACHINE_HH */

mercurial