Change how we specify custom built-in names

main
copygirl 7 months ago
parent 3e2e603e9c
commit 5e1ad2b90a
  1. 11
      src/builtin/flecs.core.zig
  2. 4
      src/context.zig

@ -122,15 +122,14 @@ pub const Panic = struct {};
// Query markers // Query markers
// zig fmt: off
/// Query marker to express `$this` variable. /// Query marker to express `$this` variable.
pub const This = struct {}; pub const This = struct { pub const name = "$"; };
pub const _This_Name = "$";
/// Query marker to express match all wildcard (`*` in query DSL). /// Query marker to express match all wildcard (`*` in query DSL).
pub const Wildcard = struct {}; pub const Wildcard = struct { pub const name = "*"; };
pub const _Wildcard_Name = "*";
/// Query marker to express match at least one wildcard (`_` in query DSL). /// Query marker to express match at least one wildcard (`_` in query DSL).
pub const Any = struct {}; pub const Any = struct { pub const name = "_"; };
pub const _Any_Name = "_"; // zig fmt: on
/// Query marker to express `==` operator. /// Query marker to express `==` operator.
pub const PredEq = struct {}; pub const PredEq = struct {};

@ -150,8 +150,8 @@ pub fn Context(comptime ctx: anytype) type {
if (@TypeOf(ChildType) != type) continue; if (@TypeOf(ChildType) != type) continue;
comptime var child_name = decl.name; comptime var child_name = decl.name;
if (@hasDecl(T, "_" ++ decl.name ++ "_Name")) if (@hasDecl(ChildType, "name"))
child_name = @field(T, "_" ++ decl.name ++ "_Name"); child_name = @field(ChildType, "name");
const child = try lookupAndRegister(world, parent, child_name, ChildType, error_writer); const child = try lookupAndRegister(world, parent, child_name, ChildType, error_writer);
try lookupAndRegisterDeclarations(world, child, ChildType, error_writer); try lookupAndRegisterDeclarations(world, child, ChildType, error_writer);

Loading…
Cancel
Save