module: basic event handler parameter validation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
92a9836c61
commit
b4a479fb3f
5 changed files with 28 additions and 23 deletions
|
|
@ -36,7 +36,6 @@ pub fn Modules(comptime modules2: anytype) type {
|
||||||
pub const modules = modules2;
|
pub const modules = modules2;
|
||||||
|
|
||||||
// TODO: add runtime module support
|
// TODO: add runtime module support
|
||||||
|
|
||||||
pub const ModuleID = u32;
|
pub const ModuleID = u32;
|
||||||
pub const EventID = u32;
|
pub const EventID = u32;
|
||||||
|
|
||||||
|
|
@ -706,6 +705,12 @@ fn validateEvents(comptime error_prefix: anytype, comptime events: anytype) void
|
||||||
error_prefix ++ ".{s} field .handler expected `.handler = fn` or `.handler = @TypeOf(fn)`, found found: {s}",
|
error_prefix ++ ".{s} field .handler expected `.handler = fn` or `.handler = @TypeOf(fn)`, found found: {s}",
|
||||||
.{ field.name, @typeName(@TypeOf(event.handler)) },
|
.{ field.name, @typeName(@TypeOf(event.handler)) },
|
||||||
));
|
));
|
||||||
|
|
||||||
|
switch (@typeInfo(@TypeOf(event.handler))) {
|
||||||
|
.Fn => _ = UninjectedArgsTuple(@TypeOf(event.handler)),
|
||||||
|
.Type => _ = UninjectedArgsTuple(event.handler),
|
||||||
|
else => unreachable,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue