]> git.sur5r.net Git - i3/i3/blobdiff - generate-command-parser.pl
Refactor the interface of commands.c
[i3/i3] / generate-command-parser.pl
index 175d7101592839e379b546845f347cd3df70187d..993c64fcaa570dcc73d229ef4bc6130223078369 100755 (executable)
@@ -118,8 +118,7 @@ close($enumfh);
 
 # Third step: Generate the call function.
 open(my $callfh, '>', 'GENERATED_call.h');
-say $callfh 'static char *GENERATED_call(const int call_identifier) {';
-say $callfh '    char *output = NULL;';
+say $callfh 'static void GENERATED_call(const int call_identifier, struct CommandResult *result) {';
 say $callfh '    switch (call_identifier) {';
 my $call_id = 0;
 for my $state (@keys) {
@@ -143,11 +142,11 @@ for my $state (@keys) {
         say $callfh '#ifndef TEST_PARSER';
         my $real_cmd = $cmd;
         if ($real_cmd =~ /\(\)/) {
-            $real_cmd =~ s/\(/(&current_match/;
+            $real_cmd =~ s/\(/(&current_match, result/;
         } else {
-            $real_cmd =~ s/\(/(&current_match, /;
+            $real_cmd =~ s/\(/(&current_match, result, /;
         }
-        say $callfh "             output = $real_cmd;";
+        say $callfh "             $real_cmd;";
         say $callfh '#else';
         # debug
         $cmd =~ s/[^(]+\(//;
@@ -164,7 +163,6 @@ for my $state (@keys) {
 say $callfh '        default:';
 say $callfh '            printf("BUG in the parser. state = %d\n", call_identifier);';
 say $callfh '    }';
-say $callfh '    return output;';
 say $callfh '}';
 close($callfh);