diff --git a/src/entity.zig b/src/entity.zig index e91509e..a98fe05 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -2,6 +2,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const meta = @import("./meta.zig"); +const errors = @import("./errors.zig"); const flecszigble = @import("./main.zig"); const Path = flecszigble.Path; const c = flecszigble.c; @@ -133,7 +134,7 @@ pub fn Entity(comptime ctx: anytype) type { var desc = std.mem.zeroInit(c.ecs_entity_desc_t, .{ .sep = "".ptr, .name = n.ptr }); desc.add[0] = c.ecs_pair(c.EcsChildOf, parent_); scope = c.ecs_entity_init(world.raw, &desc); - if (scope == 0) return flecszigble.getLastErrorOrUnknown(); + if (scope == 0) return errors.getLastErrorOrUnknown(); } else scope = found; }, } @@ -162,7 +163,7 @@ pub fn Entity(comptime ctx: anytype) type { return error.FoundChildOf; const result = c.ecs_entity_init(world.raw, &desc); - if (result == 0) return flecszigble.getLastErrorOrUnknown(); + if (result == 0) return errors.getLastErrorOrUnknown(); return Self.fromRaw(world, result); } diff --git a/src/error.zig b/src/errors.zig similarity index 100% rename from src/error.zig rename to src/errors.zig diff --git a/src/main.zig b/src/main.zig index dcc4ea6..9fbfbb1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2,9 +2,13 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const meta = @import("./meta.zig"); +// Meant for internal use, but exposed since flecs-zig-ble +// doesn't wrap nearly enough of Flecs' available features. +pub const errors = @import("./errors.zig"); pub const c = @import("./c.zig"); -pub usingnamespace @import("./error.zig"); +pub const FlecsError = errors.FlecsError; +pub const Path = @import("./path.zig"); pub usingnamespace @import("./entity.zig"); pub usingnamespace @import("./id.zig"); @@ -12,8 +16,6 @@ pub usingnamespace @import("./iter.zig"); pub usingnamespace @import("./pair.zig"); pub usingnamespace @import("./world.zig"); -pub const Path = @import("./path.zig"); - pub var is_initialized = false; pub var allocator: Allocator = undefined; diff --git a/src/world.zig b/src/world.zig index 97f95e8..cea48ef 100644 --- a/src/world.zig +++ b/src/world.zig @@ -2,6 +2,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const meta = @import("./meta.zig"); +const errors = @import("./errors.zig"); const flecszigble = @import("./main.zig"); const Path = flecszigble.Path; const c = flecszigble.c; @@ -112,7 +113,7 @@ pub fn World(comptime ctx: anytype) type { }); const result = c.ecs_component_init(self.raw, &desc); - if (result == 0) return flecszigble.getLastErrorOrUnknown(); + if (result == 0) return errors.getLastErrorOrUnknown(); Context.lookupMut(T).* = result; return Entity.fromRaw(self, result); } @@ -175,7 +176,7 @@ pub fn World(comptime ctx: anytype) type { desc.query.filter.expr = expr; const result = c.ecs_system_init(self.raw, &desc); - if (result == 0) return flecszigble.getLastErrorOrUnknown(); + if (result == 0) return errors.getLastErrorOrUnknown(); return Entity.fromRaw(self, result); }