diff options
Diffstat (limited to 'Tools/LuaMacro/tests/dll.c')
-rw-r--r-- | Tools/LuaMacro/tests/dll.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Tools/LuaMacro/tests/dll.c b/Tools/LuaMacro/tests/dll.c new file mode 100644 index 0000000..629feae --- /dev/null +++ b/Tools/LuaMacro/tests/dll.c @@ -0,0 +1,37 @@ +// luam -C -lcexport dll.c +// expands this file into pukka C and creates/updates dll.h + +#include "dll.h" + +export { +typedef struct { + int ival; +} MyStruct; +} + +// yes we could use #define here, but it's sometimes useful to have another level +// of macro substitution +def_ alloc(T) (T*)malloc(sizeof(T)) + +// Plus, LuaMacro can do operator replacements. This is Ruby-style 'field' access +def_ @ self-> + +export MyStruct *create() { + return alloc(MyStruct); +} + +def_ This MyStruct *self + +export int one(This) { + return @ival + 1 +} + +export int two(This) { + return 2*@ival; +} + +export void set(This,int i) { + @ival = i; +} + + |