2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
* @(#)StateTableProcessor.cpp 1.6 00/03/15
|
|
|
|
*
|
2001-01-19 00:30:17 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - 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"
|
|
|
|
|
|
|
|
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);
|
|
|
|
lastGlyph = firstGlyph + SWAPW(classTable->nGlyphs);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2000-11-28 20:56:52 +00:00
|
|
|
LEGlyphID glyphCode = glyphs[currGlyph];
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|