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 =...@@ -49,7 +49,7 @@ const usage =
4949
50const Command = struct {50const Command = struct {
51 name: []const u8,51 name: []const u8,
52 exec: fn (*Allocator, []const []const u8) anyerror!void,52 exec: async fn (*Allocator, []const []const u8) anyerror!void,
53};53};
5454
55pub fn main() !void {55pub fn main() !void {
...@@ -118,9 +118,12 @@ pub fn main() !void {...@@ -118,9 +118,12 @@ pub fn main() !void {
118 },118 },
119 };119 };
120120
121 for (commands) |command| {121 inline for (commands) |command| {
122 if (mem.eql(u8, command.name, args[1])) {122 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;
124 }127 }
125 }128 }
126129
...@@ -852,10 +855,12 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void {...@@ -852,10 +855,12 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void {
852 .exec = cmdInternalBuildInfo,855 .exec = cmdInternalBuildInfo,
853 }};856 }};
854857
855 for (sub_commands) |sub_command| {858 inline for (sub_commands) |sub_command| {
856 if (mem.eql(u8, sub_command.name, args[0])) {859 if (mem.eql(u8, sub_command.name, args[0])) {
857 try sub_command.exec(allocator, args[1..]);860 var frame = try allocator.create(@Frame(sub_command.exec));
858 return;861 defer allocator.destroy(frame);
862 frame.* = async sub_command.exec(allocator, args[1..]);
863 return await frame;
859 }864 }
860 }865 }
861866