From 7b49a5c9f9aa8a0a988f403a833c40cb89bb9784 Mon Sep 17 00:00:00 2001 From: heck Date: Mon, 14 Dec 2020 13:46:21 +0100 Subject: [PATCH] pyBind generator more tests --- gen/data/input/Makefile | 10 ++++ gen/data/input/test_data/Makefile | 25 ++++++++++ gen/data/input/test_data/enums.h | 18 +++++++ gen/data/input/test_data/functions.h | 70 ++++++++++++++++++++++++++++ gen/data/input/test_data/main.c | 8 ++++ gen/data/input/test_data/structs.h | 58 +++++++++++++++++++++++ gen/data/input/test_data/test_lib.c | 2 + gen/data/input/test_data/test_lib.h | 9 ++++ gen/data/input/test_data/typedefs.h | 36 ++++++++++++++ 9 files changed, 236 insertions(+) create mode 100644 gen/data/input/Makefile create mode 100644 gen/data/input/test_data/Makefile create mode 100644 gen/data/input/test_data/enums.h create mode 100644 gen/data/input/test_data/functions.h create mode 100644 gen/data/input/test_data/main.c create mode 100644 gen/data/input/test_data/structs.h create mode 100644 gen/data/input/test_data/test_lib.c create mode 100644 gen/data/input/test_data/test_lib.h create mode 100644 gen/data/input/test_data/typedefs.h diff --git a/gen/data/input/Makefile b/gen/data/input/Makefile new file mode 100644 index 0000000..16f8f4b --- /dev/null +++ b/gen/data/input/Makefile @@ -0,0 +1,10 @@ +.PHONY: all clean + +all: + $(MAKE) -C synth_shed + $(MAKE) -C test_data + +clean: + $(MAKE) -C synth_shed clean + $(MAKE) -C test_data clean + diff --git a/gen/data/input/test_data/Makefile b/gen/data/input/test_data/Makefile new file mode 100644 index 0000000..5445db3 --- /dev/null +++ b/gen/data/input/test_data/Makefile @@ -0,0 +1,25 @@ +TARGET=test_lib + +SRCS+=$(wildcard *.c) +CFLAGS+=-std=c99 -g +INCLUDES+= +LIB_DIRS+= +LIBS+= +LDFLAGS+= + + +CXXFLAGS+=$(INCLUDES) +LDFLAGS+=$(LIB_DIRS+) +LDFLAGS+=$(LIBS) +OBJS+=$(SRCS:.c=.o) + +.PHONY: all, clean + +all: $(TARGET) + +$(TARGET) : $(OBJS) + $(CC) $(LDFLAGS) -o $@ $^ + +clean: + rm -f $(TARGET) + rm -f $(OBJS) diff --git a/gen/data/input/test_data/enums.h b/gen/data/input/test_data/enums.h new file mode 100644 index 0000000..13e3033 --- /dev/null +++ b/gen/data/input/test_data/enums.h @@ -0,0 +1,18 @@ +#ifndef ENUMS_H +#define ENUMS_H + +// typedeffed enum +typedef enum _keys { + PIANO, + RHODES, + HAMMOND +} numbers; + +// untypedeffed enum +enum _drums { + KICK, + SNARE, + TOM +}; + +#endif //ENUMS_H diff --git a/gen/data/input/test_data/functions.h b/gen/data/input/test_data/functions.h new file mode 100644 index 0000000..3ce3a2a --- /dev/null +++ b/gen/data/input/test_data/functions.h @@ -0,0 +1,70 @@ +#ifndef FUNCTIONS_H +#define FUNCTIONS_H + +#include "typedefs.h" +#include "structs.h" +#include "enums.h" + +// ret: void +// arg: void +void nada(); + +// ret: void +// arg: primitive +void func1(int a); + +// ret: primitive +// arg: primitive +int func2(int a); + +// ret: aliased primitive +// arg: aliased primitive +C func3(B a); + +// ret: primitive_struct +// arg: primitive +primitive_struct func4(int x); + +// ret: primitive +// arg: primitive_struct +int func5(primitive_struct a); + +// ret: primitive_struct +// arg: primitive_struct +primitive_struct func6(primitive_struct a); + +// ret: complex_struct1 +// arg: primitive +complex_struct1 func7(int a); + +// ret: int +// arg: complex_struct1 +int func8(complex_struct1 a); + +// ret: struct _complex_struct2 +// arg: int +struct _complex_struct2 func9(int a); + +// ret: int +// arg: struct _complex_struct2 +int func10(struct _complex_struct2 a); + +// nested structs +// ret: int +// arg: host_struct +int func11(host_struct a); + +// nested structs +// ret: int +// arg: host_struct +host_struct func12(int a); + + +//void ret , incomplete type arg +// ret: void +// arg: struct _incomplete_struct +void func99(struct _incomplete_struct a); + + + +#endif //FUNCTIONS_H diff --git a/gen/data/input/test_data/main.c b/gen/data/input/test_data/main.c new file mode 100644 index 0000000..58cbc5d --- /dev/null +++ b/gen/data/input/test_data/main.c @@ -0,0 +1,8 @@ +#include "test_lib.h" +#include + + +int main() { + return 0; +} + diff --git a/gen/data/input/test_data/structs.h b/gen/data/input/test_data/structs.h new file mode 100644 index 0000000..29c792d --- /dev/null +++ b/gen/data/input/test_data/structs.h @@ -0,0 +1,58 @@ +#ifndef STRUCTS_H +#define STRUCTS_H + +// incomplete type +// type: _incomplete_struct +struct _incomplete_struct; + +// an empty struct +// type: _empty_struct +struct _empty_struct { +}; + +// a struct withouth typdef +// type: struct _untypedeffed_struct +struct _untypedeffed_struct { + int x; + int y; +}; + +// a struct containing primititve fields only +// type: primitive_struct +typedef struct _primitive_struct { + int x; + float y; + const char* str; + char one; +} primitive_struct; + +// a struct that has one typeref +// type: complex_struct1 +typedef struct _complex_struct1 { + int x; + primitive_struct p; +} complex_struct1; + +// struct containing typeref to complex_struct1 struct +// type: _complex_struct2 +struct _complex_struct2 { + primitive_struct *p; + complex_struct1 *c; +}; + +// 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; + +#endif //STRUCTS_H + diff --git a/gen/data/input/test_data/test_lib.c b/gen/data/input/test_data/test_lib.c new file mode 100644 index 0000000..58e75a8 --- /dev/null +++ b/gen/data/input/test_data/test_lib.c @@ -0,0 +1,2 @@ +#include "test_lib.h" + diff --git a/gen/data/input/test_data/test_lib.h b/gen/data/input/test_data/test_lib.h new file mode 100644 index 0000000..d2baaa8 --- /dev/null +++ b/gen/data/input/test_data/test_lib.h @@ -0,0 +1,9 @@ +#ifndef MAIN_INCLUDE_H +#define MAIN_INCLUDE_H + +#include "typedefs.h" +#include "enums.h" +#include "structs.h" +#include "functions.h" + +#endif //MAIN_INCLUDE_H diff --git a/gen/data/input/test_data/typedefs.h b/gen/data/input/test_data/typedefs.h new file mode 100644 index 0000000..7ed87d4 --- /dev/null +++ b/gen/data/input/test_data/typedefs.h @@ -0,0 +1,36 @@ +#ifndef TYPEDEFS_H +#define TYPEDEFS_H + +// recursive typdefs resolving to primitive_struct data type +// Type A,B,C are int +typedef int A; +typedef A B; +typedef B C; + + +// 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; + + +// 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 of incomplete type +typedef struct _incomplete_struct incomplete; + + +#endif //TYPEDEFS_H +