]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /* |
b75a7d8f | 2 | * |
2ca993e8 | 3 | * (C) Copyright IBM Corp. and others 1998-2016 - All Rights Reserved |
b75a7d8f A |
4 | * |
5 | */ | |
6 | ||
7 | #ifndef __STATETABLES_H | |
8 | #define __STATETABLES_H | |
9 | ||
10 | /** | |
11 | * \file | |
12 | * \internal | |
13 | */ | |
14 | ||
15 | #include "LETypes.h" | |
16 | #include "LayoutTables.h" | |
2ca993e8 | 17 | #include "LETableReference.h" |
b75a7d8f A |
18 | |
19 | U_NAMESPACE_BEGIN | |
20 | ||
57a6839d A |
21 | |
22 | ||
23 | ||
24 | /* | |
25 | * State table loop detection. | |
26 | * Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'. | |
27 | * | |
28 | * Usage (pseudocode): | |
29 | * | |
30 | * { | |
31 | * LE_STATE_PATIENCE_INIT(); | |
32 | * | |
33 | * int g=0; // the glyph index - expect it to be moving | |
34 | * | |
35 | * for(;;) { | |
36 | * if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter | |
37 | * // ran out of patience, get out. | |
38 | * break; | |
39 | * } | |
40 | * | |
41 | * LE_STATE_PATIENCE_CURR(int, g); // store the 'current' | |
42 | * state = newState(state,g); | |
43 | * g+= <something, could be zero>; | |
44 | * LE_STATE_PATIENCE_INCR(g); // if g has moved, increment the patience counter. Otherwise leave it. | |
45 | * } | |
46 | * | |
47 | */ | |
48 | ||
49 | #define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */ | |
50 | #define LE_STATE_PATIENCE_INIT() le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT | |
51 | #define LE_STATE_PATIENCE_DECR() --le_patience_count==0 | |
52 | #define LE_STATE_PATIENCE_CURR(type,x) type le_patience_curr=(x) | |
53 | #define LE_STATE_PATIENCE_INCR(x) if((x)!=le_patience_curr) ++le_patience_count; | |
54 | ||
55 | ||
b75a7d8f A |
56 | struct StateTableHeader |
57 | { | |
58 | le_int16 stateSize; | |
59 | ByteOffset classTableOffset; | |
60 | ByteOffset stateArrayOffset; | |
61 | ByteOffset entryTableOffset; | |
62 | }; | |
63 | ||
51004dcb A |
64 | struct StateTableHeader2 |
65 | { | |
66 | le_uint32 nClasses; | |
67 | le_uint32 classTableOffset; | |
68 | le_uint32 stateArrayOffset; | |
69 | le_uint32 entryTableOffset; | |
70 | }; | |
71 | ||
b75a7d8f A |
72 | enum ClassCodes |
73 | { | |
74 | classCodeEOT = 0, | |
75 | classCodeOOB = 1, | |
76 | classCodeDEL = 2, | |
77 | classCodeEOL = 3, | |
78 | classCodeFirstFree = 4, | |
79 | classCodeMAX = 0xFF | |
80 | }; | |
81 | ||
82 | typedef le_uint8 ClassCode; | |
83 | ||
84 | struct ClassTable | |
85 | { | |
86 | TTGlyphID firstGlyph; | |
87 | le_uint16 nGlyphs; | |
88 | ClassCode classArray[ANY_NUMBER]; | |
89 | }; | |
57a6839d | 90 | LE_VAR_ARRAY(ClassTable, classArray) |
b75a7d8f A |
91 | |
92 | enum StateNumber | |
93 | { | |
94 | stateSOT = 0, | |
95 | stateSOL = 1, | |
96 | stateFirstFree = 2, | |
97 | stateMAX = 0xFF | |
98 | }; | |
99 | ||
100 | typedef le_uint8 EntryTableIndex; | |
101 | ||
102 | struct StateEntry | |
103 | { | |
104 | ByteOffset newStateOffset; | |
105 | le_int16 flags; | |
106 | }; | |
107 | ||
51004dcb A |
108 | typedef le_uint16 EntryTableIndex2; |
109 | ||
110 | struct StateEntry2 // same struct different interpretation | |
111 | { | |
112 | le_uint16 newStateIndex; | |
113 | le_uint16 flags; | |
114 | }; | |
115 | ||
b75a7d8f A |
116 | U_NAMESPACE_END |
117 | #endif | |
118 |