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 FloatPtr : PtrType<FloatType>; 52 53// _Noreturn is really not a type, but it is convenient to treat it as a type. 54def NoReturn : NamedType<"_Noreturn void">; 55 56class Macro<string name> { 57 string Name = name; 58} 59 60class EnumeratedNameValue<string name, string value = "__default__"> { 61 string Name = name; 62 string Value = value; 63} 64 65class Annotation {} 66 67class RetValSpec<Type type, list<Annotation> annotations = []> { 68 Type ReturnType = type; 69 list<Annotation> Annotations = annotations; 70} 71 72class ArgSpec<Type type, list<Annotation> annotations = [], string name = ""> { 73 Type ArgType = type; 74 list<Annotation> Annotations = annotations; 75 string Name = name; 76} 77 78class FunctionSpec<string name, RetValSpec return, list<ArgSpec> args> { 79 string Name = name; 80 RetValSpec Return = return; 81 list<ArgSpec> Args = args; 82} 83 84class HeaderSpec<string name, 85 list<Macro> macros = [], 86 list<Type> types = [], 87 list<EnumeratedNameValue> enumerations = [], 88 list<FunctionSpec> functions = []> { 89 string Name = name; 90 list<FunctionSpec> Functions = functions; 91 list<Type> Types = types; 92 list<Macro> Macros = macros; 93 list<EnumeratedNameValue> Enumerations = enumerations; 94} 95 96class StandardSpec<string name> { 97 string Name = name; 98 list<HeaderSpec> Headers; 99} 100