Change how we specify custom built-in names

main
copygirl 8 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
// 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 {};

@ -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);

Loading…
Cancel
Save