From 5e1ad2b90ac98d05c2b831b7983d1d73bb13e18b Mon Sep 17 00:00:00 2001 From: copygirl Date: Wed, 17 Apr 2024 14:33:13 +0200 Subject: [PATCH] Change how we specify custom built-in names --- src/builtin/flecs.core.zig | 11 +++++------ src/context.zig | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/builtin/flecs.core.zig b/src/builtin/flecs.core.zig index 544b2d9..63db67c 100644 --- a/src/builtin/flecs.core.zig +++ b/src/builtin/flecs.core.zig @@ -122,15 +122,14 @@ pub const Panic = struct {}; // Query markers +// zig fmt: off /// Query marker to express `$this` variable. -pub const This = struct {}; -pub const _This_Name = "$"; +pub const This = struct { pub const name = "$"; }; /// Query marker to express match all wildcard (`*` in query DSL). -pub const Wildcard = struct {}; -pub const _Wildcard_Name = "*"; +pub const Wildcard = struct { pub const name = "*"; }; /// Query marker to express match at least one wildcard (`_` in query DSL). -pub const Any = struct {}; -pub const _Any_Name = "_"; +pub const Any = struct { pub const name = "_"; }; +// zig fmt: on /// Query marker to express `==` operator. pub const PredEq = struct {}; diff --git a/src/context.zig b/src/context.zig index 7956c96..80dcb03 100644 --- a/src/context.zig +++ b/src/context.zig @@ -150,8 +150,8 @@ pub fn Context(comptime ctx: anytype) type { if (@TypeOf(ChildType) != type) continue; comptime var child_name = decl.name; - if (@hasDecl(T, "_" ++ decl.name ++ "_Name")) - child_name = @field(T, "_" ++ decl.name ++ "_Name"); + if (@hasDecl(ChildType, "name")) + child_name = @field(ChildType, "name"); const child = try lookupAndRegister(world, parent, child_name, ChildType, error_writer); try lookupAndRegisterDeclarations(world, child, ChildType, error_writer);