Rename getX() functions to simply x()

main
copygirl 9 months ago
parent e3ce7b52f2
commit e695213f65
  1. 56
      src/entity.zig
  2. 2
      src/id.zig
  3. 20
      src/pair.zig
  4. 6
      src/path.zig
  5. 128
      src/test/flecs/entity.zig
  6. 2
      src/world.zig

@ -91,11 +91,11 @@ pub fn Entity(comptime ctx: anytype) type {
@compileError("Adding more than FLECS_ID_DESC_MAX ids");
var id = if (config.id) |i| i.raw else null;
var name = config.name;
var name_ = config.name;
var scope = if (config.parent) |p| p.raw else null;
if (config.path) |path| {
if (path.absolute) {
if (config.path) |path_| {
if (path_.absolute) {
// Specifying parent with an absolute path is invalid.
if (config.parent != null) return error.ParentMismatch;
scope = 0;
@ -104,33 +104,33 @@ pub fn Entity(comptime ctx: anytype) type {
// Ensure that if `id` or `name` is used alongside path,
// their values do actually match. Also sets these so they
// can be passed to the `ecs_entity_desc_t` struct.
switch (path.parts[path.parts.len - 1]) {
switch (path_.parts[path_.parts.len - 1]) {
.id => |path_id| {
if (path_id == 0) return error.InvalidParameter;
if (id) |i| if (path_id != i) return error.IdMismatch;
id = path_id;
},
.name => |path_name| {
if (name) |n| if (!std.mem.eql(u8, path_name, n)) return error.NameMismatch;
name = path_name;
if (name_) |n| if (!std.mem.eql(u8, path_name, n)) return error.NameMismatch;
name_ = path_name;
},
}
// Ensure the parent entities specified in `path` exist, or create them.
for (path.parts[0..(path.parts.len - 1)]) |part| {
const parent = scope orelse c.ecs_get_scope(world.raw);
for (path_.parts[0..(path_.parts.len - 1)]) |part| {
const parent_ = scope orelse c.ecs_get_scope(world.raw);
switch (part) {
.id => |i| {
const found = c.ecs_get_alive(world.raw, i);
if (found == 0) return error.EntityNotFound;
if (parent != c.ecs_get_parent(world.raw, found)) return error.ParentMismatch;
if (parent_ != c.ecs_get_parent(world.raw, found)) return error.ParentMismatch;
scope = found;
},
.name => |n| {
const found = c.ecs_lookup_child(world.raw, parent, n.ptr);
const found = c.ecs_lookup_child(world.raw, parent_, n.ptr);
if (found == 0) {
var desc = std.mem.zeroInit(c.ecs_entity_desc_t, .{ .sep = "".ptr, .name = n.ptr });
desc.add[0] = c.ecs_pair(c.EcsChildOf, parent);
desc.add[0] = c.ecs_pair(c.EcsChildOf, parent_);
scope = c.ecs_entity_init(world.raw, &desc);
if (scope == 0) return flecs.getLastErrorOrUnknown();
} else scope = found;
@ -147,7 +147,7 @@ pub fn Entity(comptime ctx: anytype) type {
var desc = std.mem.zeroInit(c.ecs_entity_desc_t, .{
.sep = "".ptr, // Disable tokenization.
.id = if (id) |i| i else 0,
.name = if (name) |n| n.ptr else null,
.name = if (name_) |n| n.ptr else null,
.symbol = if (config.symbol) |s| s.ptr else null,
.use_low_id = config.use_low_id,
});
@ -200,11 +200,11 @@ pub fn Entity(comptime ctx: anytype) type {
return .{ .world = self.world, .raw = self.raw };
}
pub fn getEntityId(self: Self) u32 {
pub fn entityId(self: Self) u32 {
return @intCast(self.raw & c.ECS_ENTITY_MASK);
}
pub fn getGeneration(self: Self) u16 {
pub fn generation(self: Self) u16 {
return @intCast(c.ECS_GENERATION(self.raw));
}
@ -216,7 +216,7 @@ pub fn Entity(comptime ctx: anytype) type {
/// Returns the full, absolute `Path` of this `Entity`.
/// The entity is assumed to be alive.
/// See also: `Path.fromEntity(...)`.
pub fn getPath(self: Self, alloc: Allocator) !Path {
pub fn path(self: Self, alloc: Allocator) !Path {
return Path.fromEntity(ctx, null, self, alloc);
}
@ -224,27 +224,27 @@ pub fn Entity(comptime ctx: anytype) type {
///
/// The returned string is owned by Flecs and may only be valid while
/// the entity is alive and its name doesn't change.
pub fn getName(self: Self) ?[:0]const u8 {
pub fn name(self: Self) ?[:0]const u8 {
const result = c.ecs_get_name(self.world.raw, self.raw);
return std.mem.sliceTo(result, 0);
}
/// Sets the name of this `Entity` to the specified value, if any.
///
/// Flecs does not take ownership of the provided value.
pub fn setName(self: Self, value: ?[*:0]const u8) void {
_ = c.ecs_set_name(self.world.raw, self.raw, value);
}
/// Gets the symbol of this `Entity`, or `null` if none.
///
/// The returned string is owned by Flecs and may only be valid while
/// the entity is alive and its symbol doesn't change.
pub fn getSymbol(self: Self) ?[:0]const u8 {
pub fn symbol(self: Self) ?[:0]const u8 {
const result = c.ecs_get_symbol(self.world.raw, self.raw);
return std.mem.sliceTo(result, 0);
}
/// Sets the name of this `Entity` to the specified value, if any.
///
/// Flecs does not take ownership of the provided value.
pub fn setName(self: Self, value: ?[*:0]const u8) void {
_ = c.ecs_set_name(self.world.raw, self.raw, value);
}
/// Sets the symbol of this `Entity` to the specified value, if any.
///
/// Flecs does not take ownership of the provided value.
@ -253,19 +253,19 @@ pub fn Entity(comptime ctx: anytype) type {
}
/// Gets the parent of this `Entity`, or `null` if it has none.
pub fn getParent(self: Self) ?Self {
pub fn parent(self: Self) ?Self {
const result = c.ecs_get_parent(self.world.raw, self.raw);
return if (result != 0) fromRaw(self.world, result) else null;
}
/// Returns an iterator that yields each of this `Entity`s children.
pub fn getChildren(self: Self) World.TermIterator {
pub fn children(self: Self) World.TermIterator {
return self.world.term(.{ c.EcsChildOf, self });
}
/// Returns an iterator that yields each of the targets of the
/// specified `relation` that this `Entity` has, if any.
pub fn getTargets(self: Self, relation: anytype) TargetIterator {
pub fn targets(self: Self, relation: anytype) TargetIterator {
const rel = Context.anyToEntity(relation);
return .{ .world = self.world, .entity = self.raw, .relation = rel.raw };
}
@ -308,7 +308,7 @@ pub fn Entity(comptime ctx: anytype) type {
return if (typed_ptr) |p| p.* else null;
}
pub fn get_mut(self: Self, comptime T: type) ?*T {
pub fn getMut(self: Self, comptime T: type) ?*T {
const id = Context.lookup(T).*;
const ptr = c.ecs_get_mut_id(self.world.raw, self.raw, id);
return @alignCast(@ptrCast(ptr));

@ -150,7 +150,7 @@ pub fn Id(comptime ctx: anytype) type {
/// - If `.relation` has the `Tag` property, `null` is returned.
/// - If `.target` is a component, it is returned.
/// - Otherwise, `null` is returned.
pub fn getTypeId(self: Self) ?Entity {
pub fn typeId(self: Self) ?Entity {
const raw = c.ecs_get_typeid(self.world.raw, self.raw);
return if (raw != 0) Entity.fromRaw(self.world, raw);
}

@ -19,7 +19,7 @@ pub const PairError = error{
/// `Pair`s are created using `init()`, or can be converted from `Id`s using
/// `Id.asPair()` (fails if the id isn't a pair). They can be turned back
/// to an `Id` with `asId()` (always succeeds). Elements of the relationship
/// can be extracted by calling `getRelation()` and `getTarget()`.
/// can be extracted by calling `relation()` and `target()`.
pub fn Pair(comptime ctx: anytype) type {
return struct {
const Self = @This();
@ -34,9 +34,9 @@ pub fn Pair(comptime ctx: anytype) type {
/// Build a pair from the specified `relation` and `target` entities.
/// The specified entities must be alive in the world.
pub fn init(relation: Entity, target: Entity) !Self {
const raw = c.ecs_make_pair(relation.ensureAlive().raw, target.ensureAlive().raw);
return .{ .world = relation.world, .raw = raw };
pub fn init(relation_: Entity, target_: Entity) !Self {
const raw = c.ecs_make_pair(relation_.ensureAlive().raw, target_.ensureAlive().raw);
return .{ .world = relation_.world, .raw = raw };
}
/// Ensures this `Pair` is valid and its `relation` and `target`
@ -44,27 +44,27 @@ pub fn Pair(comptime ctx: anytype) type {
pub fn ensureAlive(self: Self) !void {
if (self.raw == 0) return error.IsNone;
if (!c.ecs_id_is_pair(self.raw)) return error.IsntPair;
try self.getRelation().ensureAlive();
try self.getTarget().ensureAlive();
try self.relation().ensureAlive();
try self.target().ensureAlive();
}
/// Ensures this `Pair` and its elements are valid.
pub fn ensureValid(self: Self) !void {
if (self.raw == 0) return error.IsNone;
if (!c.ecs_id_is_pair(self.raw)) return error.IsntPair;
try self.getRelation().ensureValid();
try self.getTarget().ensureValid();
try self.relation().ensureValid();
try self.target().ensureValid();
}
pub fn asId(self: Self) Id {
return .{ .world = self.world, .raw = self.raw };
}
pub fn getRelation(self: Self) Entity {
pub fn relation(self: Self) Entity {
return Entity.fromRaw(self.world, c.ECS_PAIR_FIRST(self.raw));
}
pub fn getTarget(self: Self) Entity {
pub fn target(self: Self) Entity {
return Entity.fromRaw(self.world, c.ECS_PAIR_SECOND(self.raw));
}

@ -169,14 +169,14 @@ pub fn fromEntity(comptime ctx: type, parent: ?Entity(ctx), child: Entity(ctx),
var current = child;
while (true) {
std.debug.assert(num_parts == 0 or current.raw != child.raw); // Cycle detected.
parts[num_parts] = if (current.getName()) |name|
parts[num_parts] = if (current.name()) |name|
.{ .name = name }
else
.{ .id = current.getEntityId() };
.{ .id = current.entityId() };
num_parts += 1;
// Move to the parent entity, if any.
current = current.getParent() orelse
current = current.parent() orelse
// If `parent` wasn't specified, we reached the root. Done.
// Otherwise, if the parent wasn't found, return an error.
if (parent == null) break else return error.ParentNotFound;

@ -31,9 +31,9 @@ test "Entity_init_id_name" {
defer world.deinit();
const e = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("foo", "{}", .{path});
}
@ -46,9 +46,9 @@ test "Entity_init_id_path" {
const e_parts = Path.buildParts(.{ "parent", "child" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
}
@ -90,7 +90,7 @@ test "Entity_init_id_w_scope" {
const scope = try world.entity(.{}, .{});
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e = try world.entity(.{}, .{});
@ -103,17 +103,17 @@ test "Entity_init_id_name_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e = try world.entity(.{ .name = "child" }, .{});
try expect.true(e.has(.{ c.EcsChildOf, scope }));
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
}
@ -124,18 +124,18 @@ test "Entity_init_id_path_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e_parts = Path.buildParts(.{ "child", "grandchild" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("grandchild", e.getName());
try expect.equal("grandchild", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child.grandchild", "{}", .{path});
}
@ -146,18 +146,18 @@ test "Entity_init_id_fullpath_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const p = try Path.fromString("::parent.child.grandchild", .{ .root_sep = "::", .sep = "." }, flecs.allocator);
defer p.deinit();
const e = try world.entity(.{ .path = p }, .{});
try expect.equal("grandchild", e.getName());
try expect.equal("grandchild", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child.grandchild", "{}", .{path});
}
@ -168,10 +168,10 @@ test "Entity_init_id_fullpath_w_scope_existing" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const p = try Path.fromString("::parent.child.grandchild", .{ .root_sep = "::", .sep = "." }, flecs.allocator);
defer p.deinit();
@ -180,9 +180,9 @@ test "Entity_init_id_fullpath_w_scope_existing" {
const r = try world.entity(.{ .path = p }, .{});
try expect.equal(e, r);
try expect.equal("grandchild", e.getName());
try expect.equal("grandchild", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child.grandchild", "{}", .{path});
}
@ -198,9 +198,9 @@ test "Entity_init_id_name_1_comp" {
const e = try world.entity(.{ .name = "foo" }, .{TagA});
try expect.true(e.has(TagA));
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("foo", "{}", .{path});
}
@ -218,9 +218,9 @@ test "Entity_init_id_name_2_comp" {
const e = try world.entity(.{ .name = "foo" }, .{ TagA, TagB });
try expect.true(e.has(TagA));
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("foo", "{}", .{path});
}
@ -237,16 +237,16 @@ test "Entity_init_id_name_2_comp_w_scope" {
_ = try world.tag(TagB);
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e = try world.entity(.{ .name = "child" }, .{ TagA, TagB });
try expect.true(e.has(TagA));
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
}
@ -292,9 +292,9 @@ test "Entity_init_id_path_w_sep" {
const p = try Path.fromString("parent::child", .{ .root_sep = null, .sep = "::" }, flecs.allocator);
defer p.deinit();
const e = try world.entity(.{ .path = p }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
}
@ -305,7 +305,7 @@ test "Entity_find_id_name" {
defer world.deinit();
const e = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const r = try world.entity(.{ .name = "foo" }, .{});
try expect.equal(e, r);
@ -320,7 +320,7 @@ test "Entity_find_w_existing_id_name" {
const e = try world.entity(.{ .id = id, .name = "foo" }, .{});
try expect.equal(e, id);
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const r = try world.entity(.{ .name = "foo" }, .{});
try expect.equal(e, r);
@ -332,15 +332,15 @@ test "Entity_find_id_name_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e = try world.entity(.{ .name = "child" }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
@ -356,9 +356,9 @@ test "Entity_find_id_path" {
const e_parts = Path.buildParts(.{ "parent", "child" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
@ -372,17 +372,17 @@ test "Entity_find_id_path_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e_parts = Path.buildParts(.{ "child", "grandchild" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("grandchild", e.getName());
try expect.equal("grandchild", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child.grandchild", "{}", .{path});
@ -396,7 +396,7 @@ test "Entity_find_id_name_match" {
defer world.deinit();
const e = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const r = try world.entity(.{ .id = e, .name = "foo" }, .{});
try expect.equal(e, r);
@ -408,15 +408,15 @@ test "Entity_find_id_name_match_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e = try world.entity(.{ .name = "child" }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const path = try e.getPath(flecs.allocator);
const path = try e.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.child", "{}", .{path});
@ -439,7 +439,7 @@ test "Entity_find_id_path_match" {
const e_parts = Path.buildParts(.{ "parent", "child" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const r = try world.entity(.{ .id = e, .path = e_path }, .{});
try expect.equal(e, r);
@ -451,15 +451,15 @@ test "Entity_find_id_path_match_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e_parts = Path.buildParts(.{ "child", "grandchild" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("grandchild", e.getName());
try expect.equal("grandchild", e.name());
const r1 = try world.entity(.{ .id = e, .path = e_path }, .{});
try expect.equal(e, r1);
@ -478,7 +478,7 @@ test "Entity_find_id_name_mismatch" {
defer world.deinit();
const e = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
_ = try world.entity(.{ .name = "bar" }, .{});
@ -495,13 +495,13 @@ test "Entity_find_id_name_mismatch_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e = try world.entity(.{ .name = "child" }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const prev_log_level = c.ecs_log_set_level(-4);
defer _ = c.ecs_log_set_level(prev_log_level);
@ -518,7 +518,7 @@ test "Entity_find_id_path_mismatch" {
const e_parts = Path.buildParts(.{ "parent", "child" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("child", e.getName());
try expect.equal("child", e.name());
const prev_log_level = c.ecs_log_set_level(-4);
defer _ = c.ecs_log_set_level(prev_log_level);
@ -535,15 +535,15 @@ test "Entity_find_id_path_mismatch_w_scope" {
defer world.deinit();
const scope = try world.entity(.{ .name = "parent" }, .{});
try expect.equal("parent", scope.getName());
try expect.equal("parent", scope.name());
_ = world.setScope(scope);
try expect.equal(scope, world.getScope());
try expect.equal(scope, world.scope());
const e_parts = Path.buildParts(.{ "child", "grandchild" });
const e_path = Path.fromParts(false, &e_parts);
const e = try world.entity(.{ .path = e_path }, .{});
try expect.equal("grandchild", e.getName());
try expect.equal("grandchild", e.name());
const unnamed_parts = Path.buildParts(.{ "child", "foo" });
const unnamed_path = Path.fromParts(false, &unnamed_parts);
@ -566,7 +566,7 @@ test "Entity_find_id_add_1_comp" {
_ = try world.tag(TagA);
const e = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const r = try world.entity(.{ .name = "foo" }, .{TagA});
try expect.equal(e, r);
@ -585,7 +585,7 @@ test "Entity_find_id_add_2_comp" {
_ = try world.tag(TagB);
const e = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", e.getName());
try expect.equal("foo", e.name());
const r = try world.entity(.{ .name = "foo" }, .{ TagA, TagB });
try expect.equal(e, r);
@ -607,9 +607,9 @@ test "Entity_init_w_scope_name" {
_ = world.setScope(foo);
const child = try world.entity(.{ .name = "foo" }, .{});
try expect.equal("foo", child.getName());
try expect.equal("foo", child.name());
const path = try child.getPath(flecs.allocator);
const path = try child.path(flecs.allocator);
defer path.deinit();
try expect.fmt("parent.foo.foo", "{}", .{path});
}

@ -244,7 +244,7 @@ pub fn World(comptime ctx: anytype) type {
};
/// Gets the current scope of this `World`. See also: `setScope()`.
pub fn getScope(self: *Self) ?Entity {
pub fn scope(self: *Self) ?Entity {
const result = c.ecs_get_scope(self.raw);
return if (result != 0) Entity.fromRaw(self, result) else null;
}

Loading…
Cancel
Save