diff --git a/gen/data/input/test_data/enums.h b/gen/data/input/test_data/enums.h index 13e3033..8b49aca 100644 --- a/gen/data/input/test_data/enums.h +++ b/gen/data/input/test_data/enums.h @@ -1,18 +1,37 @@ #ifndef ENUMS_H #define ENUMS_H -// typedeffed enum -typedef enum _keys { - PIANO, - RHODES, - HAMMOND -} numbers; - -// untypedeffed enum -enum _drums { - KICK, - SNARE, - TOM +// Covered combinations +// ==================== +// _IE = incomplete enum without an alias +// IE = incomplete enum +// AIE = alias of an incomplete enum +// _E = enum without an alias +// E = enum +// AE = alias of an enum + + +// _IE = incomplete enum without anb alias +enum _IE; + +// IE = incomplete enum +// AIE = alias of an incomplete enum +typedef enum IE AIE; + +// _E = enum without an alias +enum _E { + _E1, + _E2, + _E3 }; +// E = enum +// AE = alias of an enum +typedef enum E { + E1, + E3, + E2, +} AE; + + #endif //ENUMS_H diff --git a/gen/data/input/test_data/functions.h b/gen/data/input/test_data/functions.h index 3ce3a2a..65ffd70 100644 --- a/gen/data/input/test_data/functions.h +++ b/gen/data/input/test_data/functions.h @@ -2,8 +2,9 @@ #define FUNCTIONS_H #include "typedefs.h" -#include "structs.h" #include "enums.h" +#include "structs.h" + // ret: void // arg: void @@ -17,37 +18,37 @@ void func1(int a); // arg: primitive int func2(int a); -// ret: aliased primitive -// arg: aliased primitive +// ret: aliased_primitive +// arg: aliased_primitive C func3(B a); -// ret: primitive_struct +// ret: aliased_primitive_struct // arg: primitive -primitive_struct func4(int x); +APS func4(int x); // ret: primitive -// arg: primitive_struct -int func5(primitive_struct a); +// arg: APS +int func5(APS a); -// ret: primitive_struct -// arg: primitive_struct -primitive_struct func6(primitive_struct a); +// ret: APS +// arg: APS +APS func6(APS a); -// ret: complex_struct1 +// ret: ACS // arg: primitive -complex_struct1 func7(int a); +ACS func7(int a); // ret: int -// arg: complex_struct1 -int func8(complex_struct1 a); +// arg: ACS +int func8(ACS a); -// ret: struct _complex_struct2 +// ret: struct _CCS // arg: int -struct _complex_struct2 func9(int a); +struct _CCS func9(int a); // ret: int -// arg: struct _complex_struct2 -int func10(struct _complex_struct2 a); +// arg: struct _CCS +int func10(struct _CCS a); // nested structs // ret: int @@ -62,8 +63,8 @@ host_struct func12(int a); //void ret , incomplete type arg // ret: void -// arg: struct _incomplete_struct -void func99(struct _incomplete_struct a); +// arg: struct _incomplete_S +void func99(struct _incomplete_S a); diff --git a/gen/data/input/test_data/structs.h b/gen/data/input/test_data/structs.h index 83c67d5..0074250 100644 --- a/gen/data/input/test_data/structs.h +++ b/gen/data/input/test_data/structs.h @@ -1,49 +1,24 @@ #ifndef STRUCTS_H #define STRUCTS_H -// Theory -// ====== -// P = Primitive Type -// S = Struct -// E = Enum -// A = Alias -// N = Nested (Structs only, cant be aliased) -// H = Hosting (Structs only, containing the nested struct, cant be primitive) -// T = typedef - // Structs // ------- // For structs, a combination is needed to define the type of struct -// S = Struct (Empty or incomplete, neither primitive nor complex) +// 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 -// Alias vs. Typedef -// ----------------- -// aliased means direct typedef directly, like -/* - * typedef struct _X { - int x; - * } X; - * - */ - -// Typedef means, not typdeffed directly, but anywhere, like -// typedef _X X; - -// Covered combinations -// ==================== -// -// (alias) primitive -// ================= -// _P = primitive type without a an alias -// P = primitive type -// AP = Alias of primitive type +// Some Possible combinations +// ========================== // +// _IS = incomplete struct without a typedef (forward decl) +// IS = incomplete struct +// AIS = alias of an incomplete struct + // (aliased) struct [ primitive | complex ] -// ======================================== +// ---------------------------------------- // _PS = primitive struct without a an alias // PS = primitive struct // APS = Alias of primitive struct @@ -55,16 +30,16 @@ // 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 complex struct without an alias -// HS = hosting complex struct -// AHS = hosting primitive struct +// _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 // @@ -74,59 +49,138 @@ // HHS = hosting hosting struct // AHHS = alias of a hosting hosting struct // _NHS = nested hosting struct -// _NNS = nested nested 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 -// incomplete type / forward decl -struct _incomplete_S; +// Covered combinations +// ===================== +// _IS = incomplete struct without a typedef (forward decl) +struct _IS; -// an empty struct -struct _empty_S { -}; +// 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 x; - int y; + int x, y; }; +// PS = primitive struct +// APS = Alias of primitive struct typedef struct PS { - int x; - int y; + int x, y; } APS; +// _CS = complex struct without a an alias struct _CS { - int x; - APS p; + struct _PS *x; + APS *y; }; +// CS = complex struct +// ACS = alias of a complex struct typedef struct CS { - int x; - APS p; + APS *y; + struct _PS *x; } ACS; +// _CCS = complex complex struct without an alias struct _CCS { - APS *p; - ACS *c; + ACS *x; }; -struct CCS { - int p; - ACS *c; +// CCS = complex complex struct +// ACCS = alias of a complex complex struct +typedef struct CCS { + ACS *x; } ACCS; -// nested structs, semantic parent is global -// type: host2 -typedef struct _host_struct { - int x; - int y; - // type: _nested_struct - struct _nested_struct { - int x; - int y; - } nested1; -} host_struct; - -typedef struct _nested_struct nested_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 ] +// -------------------------------------------- + +// _HS = hosting struct without an alias +// _NCS = nested primitive struct without an alias +struct _HS { + int x, y; + struct _NCS { + ACS *x; + } _ncs; +}; + +// (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 x, y; + } _nps; + int x, y; +} 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 x, y; + struct _NHS { + int x, y; + struct _NNPS { + int x,y; + } _nnps; + } _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 x, y; + struct _NHS1 { + int x, y; + struct _NNCS { + struct _CS *a; + } _nncs; + enum _NENHS { + _NENHS1, + _NENHS2, + _NENHS3 + }; + } _nhs1; +} AHHS; + + +// _NEHS = nested enum in hosting struct +struct _HS1 { + int x, y; + enum _NEHS { + _NEHS1, + _NEHS2, + _NEHS3 + } _nehs; +}; + #endif //STRUCTS_H diff --git a/gen/data/input/test_data/test_lib.h b/gen/data/input/test_data/test_lib.h index d2baaa8..5dceda3 100644 --- a/gen/data/input/test_data/test_lib.h +++ b/gen/data/input/test_data/test_lib.h @@ -5,5 +5,41 @@ #include "enums.h" #include "structs.h" #include "functions.h" +#include "vars.h" + +// Types +// ===== +// V = Void already defined +// P = Primitive Type already defined +// S = Struct -> struct.h +// E = Enum -> enums.h +// A = Alias -> structs.h/enums.h +// N = Nested (Structs only, cant be aliased) -> structs.h +// H = Hosting (Structs only -> structs.h +// containing the nested struct, cant be primitive) +// T = typedef -> typedefs.h +// I = Incomplete / (forward decl) -> struct.h/enums.h +// +// func_ = function -> functions.h +// var_ = variable -> vars.h + + +// Alias vs. Typedef +// ----------------- +// aliased means direct typedef directly, like +// structs and enums only +/* + * typedef struct _X { + int x; + * } X; + * + */ + +// Typedef means, not typdeffed directly, but anywhere, like +/* + * typedef _X X; + * + */ + #endif //MAIN_INCLUDE_H diff --git a/gen/data/input/test_data/typedefs.h b/gen/data/input/test_data/typedefs.h index 7ed87d4..56ce845 100644 --- a/gen/data/input/test_data/typedefs.h +++ b/gen/data/input/test_data/typedefs.h @@ -1,36 +1,108 @@ #ifndef TYPEDEFS_H #define TYPEDEFS_H +#include "structs.h" +#include "enums.h" -// recursive typdefs resolving to primitive_struct data type -// Type A,B,C are int -typedef int A; -typedef A B; -typedef B C; +// Covered combinations +// ==================== +// +// typedef Void +// ------------ +// TV = Typedef of Void +// +// typedef primitive +// ------------------- +// TP = Typedef of primitive type +// +// typedef structs +// ---------------- +// T_IS = typedef of an incomplete struct without a typedef (forward decl) +// TIS = typedef of an incomplete struct +// TAIS = typedef of an alias of an incomplete struct +// T_PS = typedef of a primitive struct without a an alias +// TPS = typedef of a primitive struct +// TAPS = typedef of an Alias of primitive struct +// +// nested struct +// T_NPS = typedef of a nested primitive struct without an alias +// T_NNPS = typedef of a nested primitive struct without an alias +// +// (typedef) enum +// ---------------- +// T_IE = typedef of an incomplete enum without an alias +// TIE = typedef of an incomplete enum +// TAIE = typedef of an alias of an incomplete enum +// T_E = typedef of an enum without an alias +// TE = typedef of an enum +// TAE = typedef of an alias of an enum +// TT* = typedef of typedef of anything -// recursive typdefs resolving to struct -// AS,BS,CS : aliased_struct -typedef struct _aliased_struct { - int x; -} aliased_struct; -typedef aliased_struct AS; -typedef AS BS; -typedef BS CS; +// typedef Void +// ------------ +// TV = Typedef of Void +typedef void TV; -// recursive typdefs resolving to an enum -// AE,BE,CE : aliased_enum -typedef enum _aliased_enum { - ONE, - TWO -} aliased_enum; -typedef aliased_enum AE; -typedef AE BE; -typedef BE CE; +// typedef primitive +// ------------------- +// TP = Typedef of primitive type +typedef int TP; -// typedef of incomplete type -typedef struct _incomplete_struct incomplete; +// typedef structs +// ---------------- +// T_IS = typedef of an incomplete struct without a typedef (forward decl) +typedef struct _IS T_IS; +// TIS = typedef of an incomplete struct +typedef struct IS TIS; +// TAIS = typedef of an alias of an incomplete struct +typedef AIS TAIS; +// T_PS = typedef of a primitive struct without a an alias +typedef struct _PS T_PS; +// TPS = typedef of a primitive struct +typedef struct PS TPS; +// TAPS = typedef of an Alias of primitive struct +typedef APS TAPS; +// nested struct +// T_NPS = typedef of a nested primitive struct without an alias +typedef struct _NPS T_NPS; +// T_NNPS = typedef of a nested primitive struct without an alias +typedef struct _NNPS T_NNPS; + +// (typedef) enum +// ---------------- +// T_IE = typedef of an incomplete enum without an alias +typedef enum _IE T_IE; +// TIE = typedef of an incomplete enum +typedef enum IE TIE; +// TAIE = typedef of an alias of an incomplete enum +typedef AIE TAIE; +// T_E = typedef of an enum without an alias +typedef enum _E T_E; +// TE = typedef of an enum +typedef enum E TE; +// TAE = typedef of an alias of an enum +typedef AE TAE; + + +// TT* = typedef of all typedefs +typedef TV TTV; +typedef TP TTP; +typedef T_IS TT_IS; +typedef TIS TTIS; +typedef TAIS TTAIS; +typedef T_PS TT_PS; +typedef TPS TTPS; +typedef TAPS TTAPS; +typedef T_NPS TT_NPS; +typedef T_NNPS TT_NNPS; +typedef T_IE TT_IE; +typedef TIE TTIE; +typedef TAIE TTAIE; +typedef T_E TT_E; +typedef TE TTE; +typedef TAE TTAE; #endif //TYPEDEFS_H diff --git a/gen/data/input/test_data/vars.h b/gen/data/input/test_data/vars.h new file mode 100644 index 0000000..0a72c16 --- /dev/null +++ b/gen/data/input/test_data/vars.h @@ -0,0 +1,72 @@ +#ifndef VARS_H +#define VARS_H + +#include "typedefs.h" +#include "enums.h" +#include "structs.h" + +// Variables +// ========= +// V = Void +//void var_V; + +// _P +char b; + +// P +int x; + + +// enums +// ===== +// Incomplete types: +// enum _IE var__IE; +// enum IE var_IE; +// AIE var_AIE; + +enum _E var__E ; +enum E var_E; +AE var_AE; + + +// structs +// ======= +// Incomplete types: +// struct _IS var__IS; +// struct IS var_IS; +// AIS var_AIS; + +struct _PS var__PS; +struct PS var_PS; +APS var_APS; + +struct _CS var__CS; +struct CS var_CS; +ACS var_ACS; + +struct _CCS var__CCS; +struct CCS var_CCS; +ACCS var_ACCS; + +struct _HS var__HS; +struct _NCS var__NCS; + +struct HS var_HS; +struct _NPS var__NSP; +AHS var_AHS; + +struct _HHS var__HHS; +struct _NHS var__NHS; +struct _NNPS var__NNPS; + +struct HHS var_HHS; +struct _NHS1 var__NHS1; +struct _NNCS var__NNCS; +enum _NENHS var__NENHS; +AHHS var_ASHS; + +struct _HS1 var__HS1; +enum _NEHS var_NEHS1; + + +#endif // VARS_H