authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-26 22:38:05+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-26 22:38:05+02:00
log0d55075de44ed037799b088a8e1ecf0783491da6
tree599d620effd235c0561688ff576f472cc84dd713
parent798d05dd02a1c350c1ae48b25b84c0b88db9f449
signaturelock-open Commit is signed but in an unrecognized format.

fix command functions not being async pointers


1 files changed, 11 insertions(+), 6 deletions(-)

src-self-hosted/main.zig+11-6
......@@ -49,7 +49,7 @@ const usage =
4949
5050const Command = struct {
5151 name: []const u8,
52 exec: fn (*Allocator, []const []const u8) anyerror!void,
52 exec: async fn (*Allocator, []const []const u8) anyerror!void,
5353};
5454
5555pub fn main() !void {
......@@ -118,9 +118,12 @@ pub fn main() !void {
118118 },
119119 };
120120
121 for (commands) |command| {
121 inline for (commands) |command| {
122122 if (mem.eql(u8, command.name, args[1])) {
123 return command.exec(allocator, args[2..]);
123 var frame = try allocator.create(@Frame(command.exec));
124 defer allocator.destroy(frame);
125 frame.* = async command.exec(allocator, args[2..]);
126 return await frame;
124127 }
125128 }
126129
......@@ -852,10 +855,12 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void {
852855 .exec = cmdInternalBuildInfo,
853856 }};
854857
855 for (sub_commands) |sub_command| {
858 inline for (sub_commands) |sub_command| {
856859 if (mem.eql(u8, sub_command.name, args[0])) {
857 try sub_command.exec(allocator, args[1..]);
858 return;
860 var frame = try allocator.create(@Frame(sub_command.exec));
861 defer allocator.destroy(frame);
862 frame.* = async sub_command.exec(allocator, args[1..]);
863 return await frame;
859864 }
860865 }
861866