TeX in C
Explore TeX with modern c compiler.
tex_types.h
浏览该文件的文档.
1 #pragma once
2 #ifndef INC_TEX_TYPES
4 #define INC_TEX_TYPES
5 #include <stdbool.h>
6 #include <stdint.h>
7 #include <stddef.h> // size_t
8 
9 #ifdef _STDBOOL
10 // use <stdbool.h>
11 typedef bool Boolean;
12 #else
13 // fallback
14 typedef unsigned char Boolean;
15 #define true 1
16 #define false 0
17 #endif // _STDBOOL
18 
19 
20 /*
21  Pascal data types
22 
23 ref:
24  - [Standard type - Lazarus wiki](https://wiki.freepascal.org/Standard_type)
25  - [Integer (computer science) -
26 Wikipedia](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types)
27 
28 Types:
29  UChar(8), Char(8), SChar(8)
30  Integer(64), UInteger(64), Pointer(64)
31  Real(64)
32 */
33 
34 typedef double Real;
35 
36 #ifdef _STDINT
37 // use <stdint.h>
38 typedef uint8_t UChar;
39 typedef UChar Char;
40 typedef int8_t SChar;
41 
42 typedef int64_t Integer;
43 typedef uint64_t UInteger;
45 typedef size_t Pointer;
46 
47 typedef int16_t Int16;
48 typedef uint16_t UInt16;
49 #else
50 // fallback
51 typedef unsigned char UChar;
52 typedef UChar Char;
53 typedef signed char SChar;
54 
55 typedef long long Integer;
56 typedef unsigned long long UInteger;
57 typedef size_t Pointer;
58 
59 typedef short Int16;
60 typedef unsigned short UInt16;
61 #endif // _STDINT
62 
63 
64 /*
65  #18: Types in the outer block
66 
67 Sections:
68  18, 25, 38, 101, 109,
69  113, 150, 212, 269, 300,
70  [548], [594], 920, 925.
71 
72 All types:
73  #18: ASCIICode::UChar(8)
74  #25: EightBits::UChar(8)
75  #38: PackedASCIICode::UChar(8)
76  #101 :Scaled::Integer(64)
77  #101: NonNegativeInteger::UInteger(64)
78  #101: SmallNumber::UChar(8)
79  #109: GlueRatio::Real(64)
80  #113: QuarterWord(8=>16)
81  #113: HalfWord(16=>32)
82  #113: TwoHalves(64)
83  #113: FourQuarters(64)
84  #113: MemoryWord(64)
85  #150: GlueOrd(8)
86  #212: ListStateRecord(366)
87  #269: GroupCode(8)
88  #300: InStateRecord(1344)
89  #920: TriePointer::Pointer(64)
90  #925: HyphPointer::Pointer(64)
91 
92 */
93 
98 typedef UChar EightBits; // end group S25x37_P13x18
100 
102 
106 typedef Integer Scaled;
115 typedef Real GlueRatio;
116 
117 
122 // [p43#113]
123 // 这里类型的大小人为扩大了一倍
124 #ifdef _STDINT
125 // use <stdint.h>
126 typedef uint16_t QuarterWord;
127 typedef uint32_t HalfWord;
128 #else
129 // fallback
130 typedef unsigned short QuarterWord;
131 typedef unsigned int HalfWord;
132 #endif // _STDINT
133 
134 // _NOT_USE_
135 #if false
136 typedef UChar TwoChoices;
137 typedef UChar fourchoices;
138 typedef char ManyChoices;
139 #endif
140 
144 typedef struct {
146  union {
148  struct {
150  } U2;
151  } UU;
152 } TwoHalves;
153 
159 typedef struct {
160  QuarterWord b0, b1, b2, b3;
161 } FourQuarters;
162 
164 typedef union {
170 } MemoryWord; // end group S110x114_P42x43
172 
173 
178 typedef UChar GlueOrd;
179 
184 typedef UChar GroupCode;
185 
192 
193 #endif // INC_TEX_TYPES
uint16_t QuarterWord
[p43#113]: QuarterWord(8=>16) .
Definition: tex_types.h:126
uint32_t HalfWord
[p43#113]: HalfWord(16=>32) .
Definition: tex_types.h:127
UChar EightBits
[#25]: EightBits::UChar(8) = [0, 255]
Definition: tex_types.h:98
[p43#113]: FourQuarters(64) .
Definition: tex_types.h:159
QuarterWord b0
Definition: tex_types.h:160
[p43#113]: TwoHalves(64) .
Definition: tex_types.h:144
QuarterWord b0
Definition: tex_types.h:149
HalfWord rh
(32)
Definition: tex_types.h:145
HalfWord lh
(32)
Definition: tex_types.h:147
UChar GroupCode
#269: GroupCode(8) save level for a level boundary.
Definition: tex_types.h:184
Real GlueRatio
one-word representation of a glue expansion factor.
Definition: tex_types.h:115
int64_t Integer
Integer(64) =
Definition: tex_types.h:42
Integer Scaled
[p38#101]: Scaled::Integer(64) = we need Pascal's Integer(32/64), dependent upon the bit size of the...
Definition: tex_types.h:106
size_t Pointer
Pointer::size_t(64), a flag or a location in mem or eqtb.
Definition: tex_types.h:45
bool Boolean
布尔类型定义
Definition: tex_types.h:11
double Real
Real::double(64) .
Definition: tex_types.h:34
UChar PackedASCIICode
#38: PackedASCIICode::UChar(8) = [0, 255]
Definition: tex_types.h:101
uint8_t UChar
UChar(8) = [0, 255]
Definition: tex_types.h:38
int16_t Int16
Int16(16) =
Definition: tex_types.h:47
Pointer HyphPointer
an index into the ordered hash table; [0, HYPH_SIZE=307].
Definition: tex_types.h:191
int8_t SChar
SChar(8) = [−127, +127]
Definition: tex_types.h:40
uint16_t UInt16
UInt16(16) = = [0, 65536)
Definition: tex_types.h:48
UChar SmallNumber
[p38#101]: SmallNumber::UChar(8) = [0, 255] only need: (6bit)[0, 63] .
Definition: tex_types.h:112
UInteger NonNegativeInteger
[p38#101]: NonNegativeInteger::UInteger(64) = only need: (31bit)[0, 2^31) .
Definition: tex_types.h:109
Pointer TriePointer
an index into trie; [0, TRIE_SIZE=131000].
Definition: tex_types.h:188
UChar GlueOrd
INFINITY to the 0, 1, 2, or 3 power.
Definition: tex_types.h:178
uint64_t UInteger
UInteger(64) = .
Definition: tex_types.h:43
UChar Char
Char(8) = [0, 255]
Definition: tex_types.h:39
[p43#113]: MemoryWord(64) .
Definition: tex_types.h:164
GlueRatio gr
(64)
Definition: tex_types.h:166
Integer sc
(64)
Definition: tex_types.h:169
Integer int_
(64)
Definition: tex_types.h:165
FourQuarters qqqq
(64)
Definition: tex_types.h:168
TwoHalves hh
(64)
Definition: tex_types.h:167