I have a macro that works as expected, but I want to make some changes to make it cleaner to use.
#define FuncCreate(func_name, func, ...)
int func_name(lua_State *ms) {
func(__VA_ARGS__);
return 0;
}
FuncCreate(appEvent, app_event, lua_touserdata(ms, 1), lua_tointeger(ms, 2), lua_tostring(ms, 3));
FuncCreate(GdEvent, gd_event, lua_touserdata(ms, 1), lua_touserdata(ms, 2), lua_tostring(ms, 3), lua_tointeger(ms, 4), lua_tostring(ms, 5));
I want to change the way I use arguments in the macro
I want to make use of key from data types e.g.
FuncCreate(appEvent, app_event, struct, int, const char*);
FuncCreate(GdEvent, gd_event, struct, int, const char*, int, const char*);
How can the macro take for example get the names
struct
pass as argument to func
the lua_touserdata
pass int
as an argument to func
or lua_tointeger
Would it be better to create a variadic function? How can I do this ? Remembering that I want to use the key name of the data types