i3 - improved tiling WM


Change the names of parser result structs

Patch status: merged

Patch by Tony Crisci

Long description:

Change the name of structs CommandResult and ConfigResult to
CommandResultIR and ConfigResultIR to show they are an intermediate
representation used during parsing.

To apply this patch, use:
curl http://cr.i3wm.org/patch/553/raw.patch | git am

b/generate-command-parser.pl

26
@@ -131,7 +131,7 @@ close($enumfh);
27
 
28
 # Third step: Generate the call function.
29
 open(my $callfh, '>', "GENERATED_${prefix}_call.h");
30
-my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'Result';
31
+my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'ResultIR';
32
 say $callfh "static void GENERATED_call(const int call_identifier, struct $resultname *result) {";
33
 say $callfh '    switch (call_identifier) {';
34
 my $call_id = 0;

b/include/commands.h

39
@@ -12,7 +12,7 @@
40
 #include "commands_parser.h"
41
 
42
 /** The beginning of the prototype for every cmd_ function. */
43
-#define I3_CMD Match *current_match, struct CommandResult *cmd_output
44
+#define I3_CMD Match *current_match, struct CommandResultIR *cmd_output
45
 
46
 /**
47
  * Initializes the specified 'Match' data structure and the initial state of

b/include/commands_parser.h

52
@@ -12,15 +12,11 @@
53
 #include <yajl/yajl_gen.h>
54
 
55
 /*
56
- * Holds the result of a call to any command. When calling
57
- * parse_command("floating enable, border none"), the parser will internally
58
- * use a struct CommandResult when calling cmd_floating and cmd_border.
59
- * parse_command will also return another struct CommandResult, whose
60
- * json_output is set to a map of individual json_outputs and whose
61
- * needs_tree_trender is true if any individual needs_tree_render was true.
62
- *
63
+ * Holds an intermediate represenation of the result of a call to any command.
64
+ * When calling parse_command("floating enable, border none"), the parser will
65
+ * internally use this struct when calling cmd_floating and cmd_border.
66
  */
67
-struct CommandResult {
68
+struct CommandResultIR {
69
     /* The JSON generator to append a reply to. */
70
     yajl_gen json_gen;
71
 
72
@@ -33,4 +29,4 @@ struct CommandResult {
73
     bool needs_tree_render;
74
 };
75
 
76
-struct CommandResult *parse_command(const char *input);
77
+struct CommandResultIR *parse_command(const char *input);

b/include/config_directives.h

82
@@ -18,7 +18,7 @@
83
 uint32_t modifiers_from_str(const char *str);
84
 
85
 /** The beginning of the prototype for every cfg_ function. */
86
-#define I3_CFG Match *current_match, struct ConfigResult *result
87
+#define I3_CFG Match *current_match, struct ConfigResultIR *result
88
 
89
 /* Defines a configuration function, that is, anything that can be called by
90
  * using 'call cfg_foo()' in parser-specs/.*.spec. Useful so that we don’t need

b/include/config_parser.h

95
@@ -14,11 +14,12 @@
96
 extern pid_t config_error_nagbar_pid;
97
 
98
 /*
99
- * The result of a parse_config call. Currently unused, but the JSON output
100
- * will be useful in the future when we implement a config parsing IPC command.
101
+ * An intermediate reprsentation of the result of a parse_config call.
102
+ * Currently unused, but the JSON output will be useful in the future when we
103
+ * implement a config parsing IPC command.
104
  *
105
  */
106
-struct ConfigResult {
107
+struct ConfigResultIR {
108
     /* The JSON generator to append a reply to. */
109
     yajl_gen json_gen;
110
 
111
@@ -28,7 +29,7 @@ struct ConfigResult {
112
     int next_state;
113
 };
114
 
115
-struct ConfigResult *parse_config(const char *input, struct context *context);
116
+struct ConfigResultIR *parse_config(const char *input, struct context *context);
117
 
118
 /**
119
  * Parses the given file by first replacing the variables, then calling

b/src/assignments.c

124
@@ -45,7 +45,7 @@ void run_assignments(i3Window *window) {
125
             DLOG("execute command %s\n", current->dest.command);
126
             char *full_command;
127
             sasprintf(&full_command, "[id=\"%d\"] %s", window->id, current->dest.command);
128
-            struct CommandResult *command_output = parse_command(full_command);
129
+            struct CommandResultIR *command_output = parse_command(full_command);
130
             free(full_command);
131
 
132
             if (command_output->needs_tree_render)

b/src/commands.c

137
@@ -95,7 +95,7 @@ static Output *get_output_of_con(Con *con) {
138
  * and return true, signaling that no further workspace switching should occur in the calling function.
139
  *
140
  */
141
-static bool maybe_back_and_forth(struct CommandResult *cmd_output, char *name) {
142
+static bool maybe_back_and_forth(struct CommandResultIR *cmd_output, char *name) {
143
     Con *ws = con_get_workspace(focused);
144
 
145
     /* If we switched to a different workspace, do nothing */

b/src/commands_parser.c

150
@@ -179,8 +179,8 @@ static cmdp_state state;
151
 #ifndef TEST_PARSER
152
 static Match current_match;
153
 #endif
154
-static struct CommandResult subcommand_output;
155
-static struct CommandResult command_output;
156
+static struct CommandResultIR subcommand_output;
157
+static struct CommandResultIR command_output;
158
 
159
 #include "GENERATED_command_call.h"
160
 
161
@@ -205,7 +205,7 @@ static void next_state(const cmdp_token *token) {
162
     }
163
 }
164
 
165
-struct CommandResult *parse_command(const char *input) {
166
+struct CommandResultIR *parse_command(const char *input) {
167
     DLOG("COMMAND: *%s*\n", input);
168
     state = INITIAL;
169
 

b/src/config_parser.c

174
@@ -232,8 +232,8 @@ static void clear_criteria(void *unused_criteria) {
175
 
176
 static cmdp_state state;
177
 static Match current_match;
178
-static struct ConfigResult subcommand_output;
179
-static struct ConfigResult command_output;
180
+static struct ConfigResultIR subcommand_output;
181
+static struct ConfigResultIR command_output;
182
 
183
 /* A list which contains the states that lead to the current state, e.g.
184
  * INITIAL, WORKSPACE_LAYOUT.
185
@@ -304,7 +304,7 @@ static char *single_line(const char *start) {
186
     return result;
187
 }
188
 
189
-struct ConfigResult *parse_config(const char *input, struct context *context) {
190
+struct ConfigResultIR *parse_config(const char *input, struct context *context) {
191
     /* Dump the entire config file into the debug log. We cannot just use
192
      * DLOG("%s", input); because one log message must not exceed 4 KiB. */
193
     const char *dumpwalk = input;
194
@@ -1000,7 +1000,7 @@ void parse_file(const char *f) {
195
     context = scalloc(sizeof(struct context));
196
     context->filename = f;
197
 
198
-    struct ConfigResult *config_output = parse_config(new, context);
199
+    struct ConfigResultIR *config_output = parse_config(new, context);
200
     yajl_gen_free(config_output->json_gen);
201
 
202
     check_for_duplicate_bindings(context);

b/src/ipc.c

207
@@ -117,7 +117,7 @@ IPC_HANDLER(command) {
208
     char *command = scalloc(message_size + 1);
209
     strncpy(command, (const char*)message, message_size);
210
     LOG("IPC: received: *%s*\n", command);
211
-    struct CommandResult *command_output = parse_command((const char*)command);
212
+    struct CommandResultIR *command_output = parse_command((const char*)command);
213
     free(command);
214
 
215
     if (command_output->needs_tree_render)

b/src/key_press.c

220
@@ -73,7 +73,7 @@ void handle_key_press(xcb_key_press_event_t *event) {
221
         return;
222
 
223
     char *command_copy = sstrdup(bind->command);
224
-    struct CommandResult *command_output = parse_command(command_copy);
225
+    struct CommandResultIR *command_output = parse_command(command_copy);
226
     free(command_copy);
227
 
228
     if (command_output->needs_tree_render)