You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

248 lines
6.6 KiB

#ifndef STRUCTS_H
#define STRUCTS_H
#ifdef __cplusplus
extern "C" {
#endif
// Structs
// =======
// For structs, a combination is needed to define the type of struct
// IS = Struct (Empty or incomplete, neither primitive nor complex)
// PS = Primitive struct (struct containing only primitive types)
// CS = Complex struct (struct containing other structs and primitive)
// NPS = Nested primitive struct
// Covered combinations
// ====================
// [ _ - unaliased | A - aliased ] incomplete struct
// --------------------------------------------------
// _IS = incomplete struct without a typedef (forward decl)
// IS = incomplete struct
// AIS = alias of an incomplete struct
// [ _ - unaliased | A - aliased ] [ P - primitive | C - complex ] struct [ I - incomplete ] [ a - array ]
// --------------------------------------------------------------------------------------------------------
// _PS = primitive struct without a an alias
// PS = primitive struct
// Incomplete Array in struct makes no sense
// Cant be initialized, so always stays nothing and nada
// [
// _PSIa = primitive struct without an alias containing an incomplete array
// PSIa = primitive struct containing an incomplete array
// APSIa = alias of a primitive struct containing an incomplete array/
// ]
// _PSa = primitive struct without an alias containing an array
// PSa = primitive struct containing an array
// APSa = alias of a primitive struct containing an array
// APS = Alias of primitive struct
// _CS = complex struct without a an alias
// CS = complex struct
// ACS = alias of a complex struct
// _CCS = complex complex struct without an alias
// CCS = complex complex struct
// ACCS = alias of a complex complex struct
//
// Nested structs
// --------------
// there is always a hosting struct and a nesting struct
// in case of double nesting it can be both
//
// simply nested struct [ primitive | complex ]
// --------------------------------------------
// (aliased) hosting struct (complex always)
// _HS = hosting struct without an alias
// HS = hosting struct
// AHS = alias of a hosting struct
// _NPS = nested primitive struct without an alias
// _NCS = nested complex struct without an alias
//
// doubly nested struct (complex always)
// -------------------------------------
// _HHS = hosting hosting struct without an alias
// HHS = hosting hosting struct
// AHHS = alias of a hosting hosting struct
// _NHS = nested hosting struct
// _NNPS = nested nested struct
// _NNCS = nested nested complex struct
//
// enums in structs
// _NEHS = nested enum in hosting struct
// _NENHS = nested enum in nested hosting struct
//
//
// Struct containing array fields
// ------------------------------
// Caution: The array combinations are covered in a not entirely systematic way.
// There are designated primitive structs that contain complete array fields.
// BUT, the use of array fields has been scattered a bit randomly in an attempt to cover the most important
// combinations of struct fields:
// - a_P
// - a_PSa
// - aAPSa
// - aACS
//
// So, a few of the possible field types are missing.
// Additionally, it gets a little blury with the complex structs (CS) because they dont further
// specify exactly the types of their fields
// _IS = incomplete struct without a typedef (forward decl)
struct _IS;
// IS = incomplete struct
// AIS = alias of an incomplete struct
typedef struct IS AIS;
//
// (aliased) struct [ primitive | complex ]
// ----------------------------------------
// _PS = primitive struct without a an alias
struct _PS {
int field__P_1;
int field__P_2;
};
// PS = primitive struct
// APS = Alias of primitive struct
typedef struct PS {
int field__P_1;
int field__P_2;
} APS;
// _PSa = primitive struct containing an array without an alias
struct _PSa {
int field__P_1;
char field__Pa_1[3];
};
// PSa = primitive struct containing an array
// APSa = alias of a primitive struct containing an array
typedef struct PSa {
int field__P_1;
char field__Pa_1[3];
} APSa;
// _CS = complex struct without a an alias
struct _CS {
struct _PS field__PS_1;
APS field_APS_1;
struct _PSa fiedld__PSa_1[3];
APSa field_APSa_1[3];
};
// CS = complex struct
// ACS = alias of a complex struct
typedef struct CS {
struct _PS field__PS_1;
APS field_APS_1;
struct _PSa fiedld__PSa_1[3];
APSa field_APSa_1[3];
} ACS;
// _CCS = complex complex struct without an alias
struct _CCS {
struct _CS field__CS_1;
ACS field_ACS_1[3];
};
// CCS = complex complex struct
// ACCS = alias of a complex complex struct
typedef struct CCS {
struct _CS field__CS_1;
ACS field_ACS_1[3];
} ACCS;
// Nested structs
// --------------
// there is always a hosting struct and a nesting struct
// in case of double nesting it can be both
//
// simply nested struct [ primitive | complex ]
// --------------------------------------------
// _HS = hosting struct without an alias
// _NCS = nested complex struct without an alias
struct _HS {
int field__P_1;
int field__P_2;
struct _NCS {
ACS field_ACS_1;
} field__NCS_1;
};
// (aliased) hosting struct (complex always)
// HS = hosting struct
// AHS = alias of a hosting struct
// _NPS = nested primitive struct (never has alias)
typedef struct HS {
struct _NPS {
int field__P_1;
int field__P_2;
} field__NPS_1;
int field__P_1;
int field__P_2;
} AHS;
// doubly nested struct (complex always)
// -------------------------------------
// (And enums in struct)
//
// _HHS = hosting hosting struct without an alias
// _NHS = nested hosting struct
// _NNPS = nested nested primitve struct
struct _HHS {
int field__P_1;
int field__P_2;
struct _NHS {
int field__P_1;
int field__P_2;
struct _NNPS {
int field__P_1;
int field__P_2;
} field__NNPS_1;
} field__NHS;
};
// HHS = hosting hosting struct
// AHHS = alias of a hosting hosting struct
// _NNCS = nested nested complex struct
// _NENHS = nested enum in nested hosting struct
typedef struct HHS {
int field__P_1;
int field__P_2;
struct _NHS1 {
int field__P_1;
int field__P_2;
struct _NNCS {
struct _CS field__CS_1;
} field__NNCS_1;
enum _NENHS {
_NENHS1,
_NENHS2,
_NENHS3
} field__NENHS_1;
} field__NHS1_1;
} AHHS;
// _NEHS = nested enum in hosting struct
struct _HS1 {
int field__P_1;
int field__P_2;
enum _NEHS {
_NEHS1,
_NEHS2,
_NEHS3
} field__NEHS_1;
};
#ifdef __cplusplus
}
#endif
#endif //STRUCTS_H