HELLO,
I want to write down some comptime wrapper for zig functions to be converted into lua CFunctions, but Im stuck with constructing argument object for @call.
For now i try to do something like:
const info = @typeInfo(@TypeOf(function));
const infoFn = info.@"fn";
//...
// V- not sure about backing int for now, but thats not the problem
const Args = @Struct(.auto, u32, &.{}, infoFn.param_types, infoFn.param_attrs);
//...
const v = struct {
fn wrapper(state: ?*lua.lua_State) callconv(.c) c_int {
var args: Args = undefined;
inline for (info.@"fn".param_types[1..]) |param_type| {
// do something with args, or Args???
//...
}
@call(.auto, function, args);
//...
return 0;
}
}
return v.wrapper;
but with that I dont even provide property names, and the param_types is []?type, where @Struct expects it to be []type
So, how can I setup args to depend on anything?
Unless I should just use for my functions (that are to be wrapped) fn (*lua_State, args: anytype) anytype and then just loop over those (anytype) args which at least I can try to instanciate or append to.