0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A *
0N/A */
0N/A
0N/A/*
0N/A *
0N/A * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
0N/A *
0N/A */
0N/A
0N/A#include "LETypes.h"
0N/A#include "MorphTables.h"
0N/A#include "StateTables.h"
0N/A#include "MorphStateTables.h"
0N/A#include "SubtableProcessor.h"
0N/A#include "StateTableProcessor.h"
0N/A#include "LEGlyphStorage.h"
0N/A#include "LESwaps.h"
0N/A
1693N/AU_NAMESPACE_BEGIN
1693N/A
0N/AStateTableProcessor::StateTableProcessor()
0N/A{
0N/A}
0N/A
5980N/AStateTableProcessor::StateTableProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)
5980N/A : SubtableProcessor(morphSubtableHeader, success), stateTableHeader(morphSubtableHeader, success),
5980N/A stHeader(stateTableHeader, success, (const StateTableHeader*)&stateTableHeader->stHeader)
0N/A{
5980N/A if(LE_FAILURE(success)) return;
0N/A stateSize = SWAPW(stateTableHeader->stHeader.stateSize);
0N/A classTableOffset = SWAPW(stateTableHeader->stHeader.classTableOffset);
0N/A stateArrayOffset = SWAPW(stateTableHeader->stHeader.stateArrayOffset);
0N/A entryTableOffset = SWAPW(stateTableHeader->stHeader.entryTableOffset);
0N/A
5980N/A classTable = LEReferenceTo<ClassTable>(stateTableHeader, success, ((char *) &stateTableHeader->stHeader + classTableOffset));
5980N/A if(LE_FAILURE(success)) return;
0N/A firstGlyph = SWAPW(classTable->firstGlyph);
0N/A lastGlyph = firstGlyph + SWAPW(classTable->nGlyphs);
0N/A}
0N/A
0N/AStateTableProcessor::~StateTableProcessor()
0N/A{
0N/A}
0N/A
5980N/Avoid StateTableProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
0N/A{
5980N/A if (LE_FAILURE(success)) return;
5971N/A LE_STATE_PATIENCE_INIT();
5971N/A
0N/A // Start at state 0
0N/A // XXX: How do we know when to start at state 1?
0N/A ByteOffset currentState = stateArrayOffset;
0N/A
0N/A // XXX: reverse?
0N/A le_int32 currGlyph = 0;
0N/A le_int32 glyphCount = glyphStorage.getGlyphCount();
0N/A
0N/A beginStateTable();
0N/A
0N/A while (currGlyph <= glyphCount) {
5971N/A if(LE_STATE_PATIENCE_DECR()) break; // patience exceeded.
0N/A ClassCode classCode = classCodeOOB;
0N/A if (currGlyph == glyphCount) {
0N/A // XXX: How do we handle EOT vs. EOL?
0N/A classCode = classCodeEOT;
0N/A } else {
0N/A TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(glyphStorage[currGlyph]);
0N/A
0N/A if (glyphCode == 0xFFFF) {
0N/A classCode = classCodeDEL;
0N/A } else if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
0N/A classCode = classTable->classArray[glyphCode - firstGlyph];
0N/A }
0N/A }
0N/A
5980N/A LEReferenceToArrayOf<EntryTableIndex> stateArray(stHeader, success, currentState, LE_UNBOUNDED_ARRAY);
5980N/A EntryTableIndex entryTableIndex = stateArray.getObject((le_uint8)classCode, success);
5971N/A LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
0N/A currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex);
5971N/A LE_STATE_PATIENCE_INCR(currGlyph);
0N/A }
0N/A
0N/A endStateTable();
0N/A}
1693N/A
1693N/AU_NAMESPACE_END