1class Type {}
2
3class NamedType<string name> : Type {
4  string Name = name;
5}
6
7class Field<string name, Type type> {
8  string Name = name;
9  Type FieldType = type;
10}
11
12// Class to describe concrete structs specified by a standard.
13class Struct<string name> : NamedType<name> {
14  list<Field> Fields;
15}
16
17class EnumNameValue<string name, string value = "__default_enum_value__"> {
18  string Name = name;
19  string Value = value;
20}
21
22class Enum<string name, list<EnumNameValue> enumerations> : NamedType<name> {
23  list<EnumNameValue> Enumerations = enumerations;
24}
25
26class PtrType<Type type> : Type {
27  Type PointeeType = type;
28}
29
30class ConstType<Type type> : Type {
31  Type UnqualifiedType = type;
32}
33
34class RestrictedPtrType<Type type> : Type {
35  Type PointeeType = type;
36}
37
38// Builtin types.
39def VarArgType : Type {}
40def VoidType : NamedType<"void">;
41def IntType : NamedType<"int">;
42def FloatType : NamedType<"float">;
43def DoubleType : NamedType<"double">;
44def LongDoubleType : NamedType<"long double">;
45def CharType : NamedType<"char">;
46
47// Common types
48def VoidPtr : PtrType<VoidType>;
49def ConstVoidPtr : ConstType<VoidPtr>;
50def SizeTType : NamedType<"size_t">;
51def LongDoublePtr : PtrType<LongDoubleType>;
52
53// _Noreturn is really not a type, but it is convenient to treat it as a type.
54def NoReturn : NamedType<"_Noreturn void">;
55
56//types moved from stdc.td
57def VoidRestrictedPtr : RestrictedPtrType<VoidType>;
58def ConstVoidRestrictedPtr : ConstType<VoidRestrictedPtr>;
59
60def CharPtr : PtrType<CharType>;
61def ConstCharPtr : ConstType<CharPtr>;
62def CharRestrictedPtr : RestrictedPtrType<CharType>;
63def ConstCharRestrictedPtr : ConstType<CharRestrictedPtr>;
64
65def OnceFlagType : NamedType<"once_flag">;
66def OnceFlagTypePtr : PtrType<OnceFlagType>;
67// TODO(sivachandra): Remove this non-standard type when a formal
68// way to describe callable types is available.
69def CallOnceFuncType : NamedType<"__call_once_func_t">;
70def MtxTType : NamedType<"mtx_t">;
71def MtxTTypePtr : PtrType<MtxTType>;
72def ThrdStartTType : NamedType<"thrd_start_t">;
73def ThrdTType : NamedType<"thrd_t">;
74def ThrdTTypePtr : PtrType<ThrdTType>;
75
76def IntPtr : PtrType<IntType>;
77def FloatPtr : PtrType<FloatType>;
78def DoublePtr : PtrType<DoubleType>;
79
80def SigHandlerT : NamedType<"__sighandler_t">;
81
82def TimeTType : NamedType<"time_t">;
83
84//added because __assert_fail needs it.
85def UnsignedType : NamedType<"unsigned">;
86
87
88class Macro<string name> {
89  string Name = name;
90}
91
92class EnumeratedNameValue<string name, string value = "__default__"> {
93  string Name = name;
94  string Value = value;
95}
96
97class Annotation {}
98
99class RetValSpec<Type type, list<Annotation> annotations = []> {
100  Type ReturnType = type;
101  list<Annotation> Annotations = annotations;
102}
103
104class ArgSpec<Type type, list<Annotation> annotations = [], string name = ""> {
105  Type ArgType = type;
106  list<Annotation> Annotations = annotations;
107  string Name = name;
108}
109
110class FunctionSpec<string name, RetValSpec return, list<ArgSpec> args> {
111  string Name = name;
112  RetValSpec Return = return;
113  list<ArgSpec> Args = args;
114}
115
116class HeaderSpec<string name,
117                list<Macro> macros = [],
118                list<Type> types = [],
119                list<EnumeratedNameValue> enumerations = [],
120                list<FunctionSpec> functions = []> {
121  string Name = name;
122  list<FunctionSpec> Functions = functions;
123  list<Type> Types = types;
124  list<Macro> Macros = macros;
125  list<EnumeratedNameValue> Enumerations = enumerations;
126}
127
128class StandardSpec<string name> {
129  string Name = name;
130  list<HeaderSpec> Headers;
131}
132