2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
* @(#)StateTableProcessor.cpp 1.6 00/03/15
|
|
|
|
*
|
2003-06-03 20:58:22 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
2000-11-28 20:56:52 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "MorphTables.h"
|
|
|
|
#include "StateTables.h"
|
|
|
|
#include "MorphStateTables.h"
|
|
|
|
#include "SubtableProcessor.h"
|
|
|
|
#include "StateTableProcessor.h"
|
|
|
|
#include "LESwaps.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
StateTableProcessor::StateTableProcessor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
StateTableProcessor::StateTableProcessor(const MorphSubtableHeader *morphSubtableHeader)
|
2000-11-28 20:56:52 +00:00
|
|
|
: SubtableProcessor(morphSubtableHeader)
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
stateTableHeader = (const MorphStateTableHeader *) morphSubtableHeader;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
stateSize = SWAPW(stateTableHeader->stHeader.stateSize);
|
|
|
|
classTableOffset = SWAPW(stateTableHeader->stHeader.classTableOffset);
|
|
|
|
stateArrayOffset = SWAPW(stateTableHeader->stHeader.stateArrayOffset);
|
|
|
|
entryTableOffset = SWAPW(stateTableHeader->stHeader.entryTableOffset);
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
classTable = (const ClassTable *) ((char *) &stateTableHeader->stHeader + classTableOffset);
|
2000-11-28 20:56:52 +00:00
|
|
|
firstGlyph = SWAPW(classTable->firstGlyph);
|
2003-02-05 00:05:40 +00:00
|
|
|
lastGlyph = firstGlyph + SWAPW(classTable->nGlyphs);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StateTableProcessor::~StateTableProcessor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void StateTableProcessor::process(LEGlyphID *glyphs, le_int32 *charIndices, le_int32 glyphCount)
|
|
|
|
{
|
|
|
|
// Start at state 0
|
|
|
|
// XXX: How do we know when to start at state 1?
|
|
|
|
ByteOffset currentState = stateArrayOffset;
|
|
|
|
|
|
|
|
// XXX: reverse?
|
|
|
|
le_int32 currGlyph = 0;
|
|
|
|
|
|
|
|
beginStateTable();
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
while (currGlyph <= glyphCount) {
|
2000-11-28 20:56:52 +00:00
|
|
|
ClassCode classCode = classCodeOOB;
|
2001-01-19 00:30:17 +00:00
|
|
|
if (currGlyph == glyphCount) {
|
2000-11-28 20:56:52 +00:00
|
|
|
// XXX: How do we handle EOT vs. EOL?
|
|
|
|
classCode = classCodeEOT;
|
2001-01-19 00:30:17 +00:00
|
|
|
} else {
|
2003-02-05 22:08:20 +00:00
|
|
|
TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(glyphs[currGlyph]);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
if (glyphCode == 0xFFFF) {
|
2000-11-28 20:56:52 +00:00
|
|
|
classCode = classCodeDEL;
|
2001-01-19 00:30:17 +00:00
|
|
|
} else if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
|
2000-11-28 20:56:52 +00:00
|
|
|
classCode = classTable->classArray[glyphCode - firstGlyph];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
const EntryTableIndex *stateArray = (const EntryTableIndex *) ((char *) &stateTableHeader->stHeader + currentState);
|
2000-11-28 20:56:52 +00:00
|
|
|
EntryTableIndex entryTableIndex = stateArray[(le_uint8)classCode];
|
|
|
|
|
|
|
|
currentState = processStateEntry(glyphs, charIndices, currGlyph, glyphCount, entryTableIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
endStateTable();
|
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|