File: StateTables.h

package info (click to toggle)
icu 52.1-8
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 112,788 kB
  • sloc: cpp: 337,445; ansic: 162,558; makefile: 5,336; sh: 4,005; xml: 3,707; perl: 3,054; python: 460; sed: 35
file content (117 lines) | stat: -rw-r--r-- 2,412 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 *
 * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
 *
 */

#ifndef __STATETABLES_H
#define __STATETABLES_H

/**
 * \file
 * \internal
 */

#include "LETypes.h"
#include "LayoutTables.h"

U_NAMESPACE_BEGIN




/* 
 * State table loop detection. 
 * Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'.
 * 
 * Usage (pseudocode):
 *
 * {
 *   LE_STATE_PATIENCE_INIT();
 *
 *   int g=0; // the glyph index - expect it to be moving
 * 
 *   for(;;) {
 *     if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter
 *        // ran out of patience, get out.
 *        break;
 *     }
 *     
 *     LE_STATE_PATIENCE_CURR(int, g); // store the 'current'
 *     state = newState(state,g);
 *     g+= <something, could be zero>;
 *     LE_STATE_PATIENCE_INCR(g);  // if g has moved, increment the patience counter. Otherwise leave it.
 *   }
 * 
 */

#define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */
#define LE_STATE_PATIENCE_INIT()  le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT
#define LE_STATE_PATIENCE_DECR()  --le_patience_count==0
#define LE_STATE_PATIENCE_CURR(type,x)  type le_patience_curr=(x)
#define LE_STATE_PATIENCE_INCR(x)    if((x)!=le_patience_curr) ++le_patience_count;


struct StateTableHeader
{
    le_int16 stateSize;
    ByteOffset classTableOffset;
    ByteOffset stateArrayOffset;
    ByteOffset entryTableOffset;
};

struct StateTableHeader2 
{
    le_uint32 nClasses;
    le_uint32 classTableOffset;
    le_uint32 stateArrayOffset;
    le_uint32 entryTableOffset;
};

enum ClassCodes
{
    classCodeEOT = 0,
    classCodeOOB = 1,
    classCodeDEL = 2,
    classCodeEOL = 3,
    classCodeFirstFree = 4,
    classCodeMAX = 0xFF
};

typedef le_uint8 ClassCode;

struct ClassTable
{
    TTGlyphID firstGlyph;
    le_uint16 nGlyphs;
    ClassCode classArray[ANY_NUMBER];
};
LE_VAR_ARRAY(ClassTable, classArray)

enum StateNumber
{
    stateSOT        = 0,
    stateSOL        = 1,
    stateFirstFree  = 2,
    stateMAX        = 0xFF
};

typedef le_uint8 EntryTableIndex;

struct StateEntry
{
    ByteOffset  newStateOffset;
    le_int16    flags;
};

typedef le_uint16 EntryTableIndex2;

struct StateEntry2 // same struct different interpretation
{
    le_uint16    newStateIndex;
    le_uint16    flags;
};

U_NAMESPACE_END
#endif