Refactor the interface of commands.c
This change has two implications: 1) tree_render() will now be called precisely once for input which consists of multiple commands (like "focus left; focus right"). Also, the caller of parse_command() has to call it. This makes us able to fix tickets such as ticket #608 (where multiple tree_render() calls are noticable). 2) The output of a command is now a JSON array of return values of the individual subcommands. In the case of "focus left; focus right", this is: [{"success":true}, {"success":true}] While this is incompatible with what i3 returned before, the return value of commands was undocumented and therefore not subject to our API stability.
This commit is contained in:
@ -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/\(/(¤t_match/;
|
||||
$real_cmd =~ s/\(/(¤t_match, result/;
|
||||
} else {
|
||||
$real_cmd =~ s/\(/(¤t_match, /;
|
||||
$real_cmd =~ s/\(/(¤t_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);
|
||||
|
||||
|
Reference in New Issue
Block a user