mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
39 lines
999 B
Zig
39 lines
999 B
Zig
const std = @import("std");
|
|
|
|
fn NamespacedComponents(comptime modules: anytype) type {
|
|
return @Type(.{
|
|
.Struct = .{
|
|
.layout = .Auto,
|
|
.is_tuple = false,
|
|
.fields = &.{.{
|
|
.name = "components",
|
|
.type = @TypeOf(modules.components),
|
|
.default_value = null,
|
|
.is_comptime = false,
|
|
.alignment = @alignOf(@TypeOf(modules.components)),
|
|
}},
|
|
.decls = &[_]std.builtin.Type.Declaration{},
|
|
},
|
|
});
|
|
}
|
|
|
|
fn namespacedComponents(comptime modules: anytype) NamespacedComponents(modules) {
|
|
var x: NamespacedComponents(modules) = undefined;
|
|
x.components = modules.components;
|
|
return x;
|
|
}
|
|
|
|
pub fn World(comptime modules: anytype) type {
|
|
const all_components = namespacedComponents(modules);
|
|
_ = all_components;
|
|
return struct {};
|
|
}
|
|
|
|
test {
|
|
_ = World(.{
|
|
.components = .{
|
|
.location = struct {},
|
|
},
|
|
});
|
|
}
|