I want to double check I am not missing some way to fix the parameters for this function. Right now it looks like this:
// Assume MyStruct has a recalculate_speed function
var entity = try readEntity(MyStruct, &my_struct,
\\panel name "coffee" image "cat"
\\minimum width=33 height=120
\\horizontal style tinted
\\on_resized "recalculate_speed"
)
Basically I am extracting a function list from the anytype so that I can 'attach' names of functions to the concrete 'handler' pointed to by anyopaque:
pub fn readEntity(
comptime handler_type: anytype,
handler: *anyopaque, data: []const u8
) Error!?Entity {
const so = @typeInfo(handler_type);
if (so != .@"struct") @compileError("callback parameter must be a pointer to a struct");
const callbacks = comptime
callbackFunctionList(handler_type);
//...
}