]> git.saurik.com Git - apple/icu.git/blame - icuSources/layout/StateTables.h
ICU-551.51.tar.gz
[apple/icu.git] / icuSources / layout / StateTables.h
CommitLineData
b75a7d8f 1/*
b75a7d8f 2 *
51004dcb 3 * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
b75a7d8f
A
4 *
5 */
6
7#ifndef __STATETABLES_H
8#define __STATETABLES_H
9
10/**
11 * \file
12 * \internal
13 */
14
15#include "LETypes.h"
16#include "LayoutTables.h"
17
18U_NAMESPACE_BEGIN
19
57a6839d
A
20
21
22
23/*
24 * State table loop detection.
25 * Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'.
26 *
27 * Usage (pseudocode):
28 *
29 * {
30 * LE_STATE_PATIENCE_INIT();
31 *
32 * int g=0; // the glyph index - expect it to be moving
33 *
34 * for(;;) {
35 * if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter
36 * // ran out of patience, get out.
37 * break;
38 * }
39 *
40 * LE_STATE_PATIENCE_CURR(int, g); // store the 'current'
41 * state = newState(state,g);
42 * g+= <something, could be zero>;
43 * LE_STATE_PATIENCE_INCR(g); // if g has moved, increment the patience counter. Otherwise leave it.
44 * }
45 *
46 */
47
48#define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */
49#define LE_STATE_PATIENCE_INIT() le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT
50#define LE_STATE_PATIENCE_DECR() --le_patience_count==0
51#define LE_STATE_PATIENCE_CURR(type,x) type le_patience_curr=(x)
52#define LE_STATE_PATIENCE_INCR(x) if((x)!=le_patience_curr) ++le_patience_count;
53
54
b75a7d8f
A
55struct StateTableHeader
56{
57 le_int16 stateSize;
58 ByteOffset classTableOffset;
59 ByteOffset stateArrayOffset;
60 ByteOffset entryTableOffset;
61};
62
51004dcb
A
63struct StateTableHeader2
64{
65 le_uint32 nClasses;
66 le_uint32 classTableOffset;
67 le_uint32 stateArrayOffset;
68 le_uint32 entryTableOffset;
69};
70
b75a7d8f
A
71enum ClassCodes
72{
73 classCodeEOT = 0,
74 classCodeOOB = 1,
75 classCodeDEL = 2,
76 classCodeEOL = 3,
77 classCodeFirstFree = 4,
78 classCodeMAX = 0xFF
79};
80
81typedef le_uint8 ClassCode;
82
83struct ClassTable
84{
85 TTGlyphID firstGlyph;
86 le_uint16 nGlyphs;
87 ClassCode classArray[ANY_NUMBER];
88};
57a6839d 89LE_VAR_ARRAY(ClassTable, classArray)
b75a7d8f
A
90
91enum StateNumber
92{
93 stateSOT = 0,
94 stateSOL = 1,
95 stateFirstFree = 2,
96 stateMAX = 0xFF
97};
98
99typedef le_uint8 EntryTableIndex;
100
101struct StateEntry
102{
103 ByteOffset newStateOffset;
104 le_int16 flags;
105};
106
51004dcb
A
107typedef le_uint16 EntryTableIndex2;
108
109struct StateEntry2 // same struct different interpretation
110{
111 le_uint16 newStateIndex;
112 le_uint16 flags;
113};
114
b75a7d8f
A
115U_NAMESPACE_END
116#endif
117