~ubuntu-branches/ubuntu/quantal/icu/quantal

« back to all changes in this revision

Viewing changes to source/layout/StateTableProcessor.cpp

  • Committer: Package Import Robot
  • Author(s): Yves Arrouye
  • Date: 2002-03-03 15:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20020303153113-3ssceqlq45xbmbnc
Tags: upstream-2.0-2.1pre20020303
ImportĀ upstreamĀ versionĀ 2.0-2.1pre20020303

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * @(#)StateTableProcessor.cpp  1.6 00/03/15
 
3
 *
 
4
 * (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - All Rights Reserved
 
5
 *
 
6
 */
 
7
 
 
8
#include "LETypes.h"
 
9
#include "MorphTables.h"
 
10
#include "StateTables.h"
 
11
#include "MorphStateTables.h"
 
12
#include "SubtableProcessor.h"
 
13
#include "StateTableProcessor.h"
 
14
#include "LESwaps.h"
 
15
 
 
16
U_NAMESPACE_BEGIN
 
17
 
 
18
StateTableProcessor::StateTableProcessor()
 
19
{
 
20
}
 
21
 
 
22
StateTableProcessor::StateTableProcessor(const MorphSubtableHeader *morphSubtableHeader)
 
23
  : SubtableProcessor(morphSubtableHeader)
 
24
{
 
25
    stateTableHeader = (const MorphStateTableHeader *) morphSubtableHeader;
 
26
 
 
27
    stateSize = SWAPW(stateTableHeader->stHeader.stateSize);
 
28
    classTableOffset = SWAPW(stateTableHeader->stHeader.classTableOffset);
 
29
    stateArrayOffset = SWAPW(stateTableHeader->stHeader.stateArrayOffset);
 
30
    entryTableOffset = SWAPW(stateTableHeader->stHeader.entryTableOffset);
 
31
 
 
32
    classTable = (const ClassTable *) ((char *) &stateTableHeader->stHeader + classTableOffset);
 
33
    firstGlyph = SWAPW(classTable->firstGlyph);
 
34
    lastGlyph = firstGlyph + SWAPW(classTable->nGlyphs);
 
35
}
 
36
 
 
37
StateTableProcessor::~StateTableProcessor()
 
38
{
 
39
}
 
40
 
 
41
void StateTableProcessor::process(LEGlyphID *glyphs, le_int32 *charIndices, le_int32 glyphCount)
 
42
{
 
43
    // Start at state 0
 
44
    // XXX: How do we know when to start at state 1?
 
45
    ByteOffset currentState = stateArrayOffset;
 
46
 
 
47
    // XXX: reverse? 
 
48
    le_int32 currGlyph = 0;
 
49
 
 
50
    beginStateTable();
 
51
 
 
52
    while (currGlyph <= glyphCount) {
 
53
        ClassCode classCode = classCodeOOB;
 
54
        if (currGlyph == glyphCount) {
 
55
            // XXX: How do we handle EOT vs. EOL?
 
56
            classCode = classCodeEOT;
 
57
        } else {
 
58
            LEGlyphID glyphCode = glyphs[currGlyph];
 
59
 
 
60
            if (glyphCode == 0xFFFF) {
 
61
                classCode = classCodeDEL;
 
62
            } else if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
 
63
                classCode = classTable->classArray[glyphCode - firstGlyph];
 
64
            }
 
65
        }
 
66
 
 
67
        const EntryTableIndex *stateArray = (const EntryTableIndex *) ((char *) &stateTableHeader->stHeader + currentState);
 
68
        EntryTableIndex entryTableIndex = stateArray[(le_uint8)classCode];
 
69
 
 
70
        currentState = processStateEntry(glyphs, charIndices, currGlyph, glyphCount, entryTableIndex);
 
71
    }
 
72
 
 
73
    endStateTable();
 
74
}
 
75
 
 
76
U_NAMESPACE_END