Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1999-2003, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | * file name: scrptrun.h |
michael@0 | 9 | * |
michael@0 | 10 | * created on: 10/17/2001 |
michael@0 | 11 | * created by: Eric R. Mader |
michael@0 | 12 | */ |
michael@0 | 13 | |
michael@0 | 14 | #ifndef __SCRPTRUN_H |
michael@0 | 15 | #define __SCRPTRUN_H |
michael@0 | 16 | |
michael@0 | 17 | #include "unicode/utypes.h" |
michael@0 | 18 | #include "unicode/uobject.h" |
michael@0 | 19 | #include "unicode/uscript.h" |
michael@0 | 20 | |
michael@0 | 21 | struct ScriptRecord |
michael@0 | 22 | { |
michael@0 | 23 | UChar32 startChar; |
michael@0 | 24 | UChar32 endChar; |
michael@0 | 25 | UScriptCode scriptCode; |
michael@0 | 26 | }; |
michael@0 | 27 | |
michael@0 | 28 | struct ParenStackEntry |
michael@0 | 29 | { |
michael@0 | 30 | int32_t pairIndex; |
michael@0 | 31 | UScriptCode scriptCode; |
michael@0 | 32 | }; |
michael@0 | 33 | |
michael@0 | 34 | class ScriptRun : public UObject { |
michael@0 | 35 | public: |
michael@0 | 36 | ScriptRun(); |
michael@0 | 37 | |
michael@0 | 38 | ScriptRun(const UChar chars[], int32_t length); |
michael@0 | 39 | |
michael@0 | 40 | ScriptRun(const UChar chars[], int32_t start, int32_t length); |
michael@0 | 41 | |
michael@0 | 42 | void reset(); |
michael@0 | 43 | |
michael@0 | 44 | void reset(int32_t start, int32_t count); |
michael@0 | 45 | |
michael@0 | 46 | void reset(const UChar chars[], int32_t start, int32_t length); |
michael@0 | 47 | |
michael@0 | 48 | int32_t getScriptStart(); |
michael@0 | 49 | |
michael@0 | 50 | int32_t getScriptEnd(); |
michael@0 | 51 | |
michael@0 | 52 | UScriptCode getScriptCode(); |
michael@0 | 53 | |
michael@0 | 54 | UBool next(); |
michael@0 | 55 | |
michael@0 | 56 | /** |
michael@0 | 57 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
michael@0 | 58 | * |
michael@0 | 59 | * @stable ICU 2.2 |
michael@0 | 60 | */ |
michael@0 | 61 | virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * ICU "poor man's RTTI", returns a UClassID for this class. |
michael@0 | 65 | * |
michael@0 | 66 | * @stable ICU 2.2 |
michael@0 | 67 | */ |
michael@0 | 68 | static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } |
michael@0 | 69 | |
michael@0 | 70 | private: |
michael@0 | 71 | |
michael@0 | 72 | static UBool sameScript(int32_t scriptOne, int32_t scriptTwo); |
michael@0 | 73 | |
michael@0 | 74 | int32_t charStart; |
michael@0 | 75 | int32_t charLimit; |
michael@0 | 76 | const UChar *charArray; |
michael@0 | 77 | |
michael@0 | 78 | int32_t scriptStart; |
michael@0 | 79 | int32_t scriptEnd; |
michael@0 | 80 | UScriptCode scriptCode; |
michael@0 | 81 | |
michael@0 | 82 | ParenStackEntry parenStack[128]; |
michael@0 | 83 | int32_t parenSP; |
michael@0 | 84 | |
michael@0 | 85 | static int8_t highBit(int32_t value); |
michael@0 | 86 | static int32_t getPairIndex(UChar32 ch); |
michael@0 | 87 | |
michael@0 | 88 | static UChar32 pairedChars[]; |
michael@0 | 89 | static const int32_t pairedCharCount; |
michael@0 | 90 | static const int32_t pairedCharPower; |
michael@0 | 91 | static const int32_t pairedCharExtra; |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * The address of this static class variable serves as this class's ID |
michael@0 | 95 | * for ICU "poor man's RTTI". |
michael@0 | 96 | */ |
michael@0 | 97 | static const char fgClassID; |
michael@0 | 98 | }; |
michael@0 | 99 | |
michael@0 | 100 | inline ScriptRun::ScriptRun() |
michael@0 | 101 | { |
michael@0 | 102 | reset(NULL, 0, 0); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | inline ScriptRun::ScriptRun(const UChar chars[], int32_t length) |
michael@0 | 106 | { |
michael@0 | 107 | reset(chars, 0, length); |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length) |
michael@0 | 111 | { |
michael@0 | 112 | reset(chars, start, length); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | inline int32_t ScriptRun::getScriptStart() |
michael@0 | 116 | { |
michael@0 | 117 | return scriptStart; |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | inline int32_t ScriptRun::getScriptEnd() |
michael@0 | 121 | { |
michael@0 | 122 | return scriptEnd; |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | inline UScriptCode ScriptRun::getScriptCode() |
michael@0 | 126 | { |
michael@0 | 127 | return scriptCode; |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | inline void ScriptRun::reset() |
michael@0 | 131 | { |
michael@0 | 132 | scriptStart = charStart; |
michael@0 | 133 | scriptEnd = charStart; |
michael@0 | 134 | scriptCode = USCRIPT_INVALID_CODE; |
michael@0 | 135 | parenSP = -1; |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | inline void ScriptRun::reset(int32_t start, int32_t length) |
michael@0 | 139 | { |
michael@0 | 140 | charStart = start; |
michael@0 | 141 | charLimit = start + length; |
michael@0 | 142 | |
michael@0 | 143 | reset(); |
michael@0 | 144 | } |
michael@0 | 145 | |
michael@0 | 146 | inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length) |
michael@0 | 147 | { |
michael@0 | 148 | charArray = chars; |
michael@0 | 149 | |
michael@0 | 150 | reset(start, length); |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | |
michael@0 | 154 | #endif |