2
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Sun designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Sun in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
21 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
22 |
* have any questions.
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
|
28 |
* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
|
|
32 |
#include "LETypes.h"
|
|
33 |
#include "MorphTables.h"
|
|
34 |
#include "StateTables.h"
|
|
35 |
#include "MorphStateTables.h"
|
|
36 |
#include "SubtableProcessor.h"
|
|
37 |
#include "StateTableProcessor.h"
|
|
38 |
#include "LEGlyphStorage.h"
|
|
39 |
#include "LESwaps.h"
|
|
40 |
|
3935
|
41 |
U_NAMESPACE_BEGIN
|
|
42 |
|
2
|
43 |
StateTableProcessor::StateTableProcessor()
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
StateTableProcessor::StateTableProcessor(const MorphSubtableHeader *morphSubtableHeader)
|
|
48 |
: SubtableProcessor(morphSubtableHeader)
|
|
49 |
{
|
|
50 |
stateTableHeader = (const MorphStateTableHeader *) morphSubtableHeader;
|
|
51 |
|
|
52 |
stateSize = SWAPW(stateTableHeader->stHeader.stateSize);
|
|
53 |
classTableOffset = SWAPW(stateTableHeader->stHeader.classTableOffset);
|
|
54 |
stateArrayOffset = SWAPW(stateTableHeader->stHeader.stateArrayOffset);
|
|
55 |
entryTableOffset = SWAPW(stateTableHeader->stHeader.entryTableOffset);
|
|
56 |
|
|
57 |
classTable = (const ClassTable *) ((char *) &stateTableHeader->stHeader + classTableOffset);
|
|
58 |
firstGlyph = SWAPW(classTable->firstGlyph);
|
|
59 |
lastGlyph = firstGlyph + SWAPW(classTable->nGlyphs);
|
|
60 |
}
|
|
61 |
|
|
62 |
StateTableProcessor::~StateTableProcessor()
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
void StateTableProcessor::process(LEGlyphStorage &glyphStorage)
|
|
67 |
{
|
|
68 |
// Start at state 0
|
|
69 |
// XXX: How do we know when to start at state 1?
|
|
70 |
ByteOffset currentState = stateArrayOffset;
|
|
71 |
|
|
72 |
// XXX: reverse?
|
|
73 |
le_int32 currGlyph = 0;
|
|
74 |
le_int32 glyphCount = glyphStorage.getGlyphCount();
|
|
75 |
|
|
76 |
beginStateTable();
|
|
77 |
|
|
78 |
while (currGlyph <= glyphCount) {
|
|
79 |
ClassCode classCode = classCodeOOB;
|
|
80 |
if (currGlyph == glyphCount) {
|
|
81 |
// XXX: How do we handle EOT vs. EOL?
|
|
82 |
classCode = classCodeEOT;
|
|
83 |
} else {
|
|
84 |
TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(glyphStorage[currGlyph]);
|
|
85 |
|
|
86 |
if (glyphCode == 0xFFFF) {
|
|
87 |
classCode = classCodeDEL;
|
|
88 |
} else if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
|
|
89 |
classCode = classTable->classArray[glyphCode - firstGlyph];
|
|
90 |
}
|
|
91 |
}
|
|
92 |
|
|
93 |
const EntryTableIndex *stateArray = (const EntryTableIndex *) ((char *) &stateTableHeader->stHeader + currentState);
|
|
94 |
EntryTableIndex entryTableIndex = stateArray[(le_uint8)classCode];
|
|
95 |
|
|
96 |
currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex);
|
|
97 |
}
|
|
98 |
|
|
99 |
endStateTable();
|
|
100 |
}
|
3935
|
101 |
|
|
102 |
U_NAMESPACE_END
|