Parse system set into SystemSet
This commit is contained in:
@@ -3,7 +3,7 @@ const utils = @import("utils.zig");
|
||||
const Controller = @import("controller.zig");
|
||||
|
||||
function_runner: *const fn ([]const *anyopaque) void,
|
||||
requested_types: []const Request,
|
||||
requested_types: []const utils.SystemRequest,
|
||||
requires_dud: ?Dud.Id,
|
||||
submit_dud: ?Dud.Id,
|
||||
label: []const u8,
|
||||
@@ -13,35 +13,3 @@ pub const Dud = struct {
|
||||
|
||||
required_count: u16 = 0,
|
||||
};
|
||||
|
||||
pub const Request = union(enum) {
|
||||
resource: utils.Hash,
|
||||
controller: void,
|
||||
// TODO:
|
||||
// - Params
|
||||
};
|
||||
|
||||
const Self = @This();
|
||||
pub fn fromFunction(comptime function: anytype, alloc: std.mem.Allocator) !Self {
|
||||
utils.validateSystem(function);
|
||||
|
||||
var requests: [@typeInfo(@TypeOf(function)).@"fn".params.len]Request = undefined;
|
||||
inline for (0.., @typeInfo(@TypeOf(function)).@"fn".params) |i, param| {
|
||||
switch (@typeInfo(param.type.?).pointer.child) {
|
||||
Controller => requests[i] = .controller,
|
||||
else => |resource_type| requests[i] = .{ .resource = utils.hashType(resource_type) },
|
||||
}
|
||||
}
|
||||
|
||||
return Self{
|
||||
.requested_types = try alloc.dupe(Request, &requests),
|
||||
.function_runner = utils.generateRunner(function),
|
||||
.requires_dud = null,
|
||||
.submit_dud = null,
|
||||
.label = @typeName(@TypeOf(function)),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: *const Self, alloc: std.mem.Allocator) void {
|
||||
alloc.free(self.requested_types);
|
||||
}
|
||||
|
Reference in New Issue
Block a user