module: rename MComponents -> MComponentTypes

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-03-27 11:11:20 -07:00 committed by Stephen Gutekanst
parent a83f9d5be8
commit f55aee4b50

View file

@ -15,7 +15,7 @@ fn ModuleInterface(comptime M: type) type {
if (!@hasDecl(M, "events")) @compileError(prefix ++ "must have `pub const events = .{};`");
// TODO: re-enable this validation once module event handler arguments would not pose a type dependency loop
// validateEvents("mach: module ." ++ @tagName(M.name) ++ " ", M.events);
_ = MComponents(M);
_ = MComponentTypes(M);
return M;
}
@ -375,7 +375,7 @@ pub fn Module(
) type {
const module_tag = M.name;
const State = @TypeOf(@field(@as(StateT, undefined), @tagName(module_tag)));
const components = MComponents(M){};
const components = MComponentTypes(M){};
return struct {
state: State,
entities: *Entities(NSComponents{}),
@ -701,7 +701,7 @@ fn validateEvents(comptime error_prefix: anytype, comptime events: anytype) void
pub fn ComponentTypesByName(comptime modules: anytype) type {
var fields: []const std.builtin.Type.StructField = &[0]std.builtin.Type.StructField{};
inline for (modules) |M| {
const MC = MComponents(M);
const MC = MComponentTypes(M);
fields = fields ++ [_]std.builtin.Type.StructField{.{
.name = @tagName(M.name),
.type = MC,
@ -713,7 +713,7 @@ pub fn ComponentTypesByName(comptime modules: anytype) type {
// Builtin components
// TODO: better method of injecting builtin module?
const BuiltinMC = MComponents(struct {
const BuiltinMC = MComponentTypes(struct {
pub const name = .builtin;
pub const components = .{
.{ .name = .id, .type = EntityID, .description = "Entity ID" },
@ -746,7 +746,7 @@ pub fn ComponentTypesByName(comptime modules: anytype) type {
/// rotation: @TypeOf() = .{ .type = Vec2, .description = "rotation component" },
/// }
/// ```
fn MComponents(comptime M: anytype) type {
fn MComponentTypes(comptime M: anytype) type {
const error_prefix = "mach: module ." ++ @tagName(M.name) ++ " .components ";
if (!@hasDecl(M, "components")) {
return struct {};