# Third step: Generate the call function.
open(my $callfh, '>', "GENERATED_${prefix}_call.h");
-my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'Result';
+my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'ResultIR';
say $callfh "static void GENERATED_call(const int call_identifier, struct $resultname *result) {";
say $callfh ' switch (call_identifier) {';
my $call_id = 0;
#include "commands_parser.h"
/** The beginning of the prototype for every cmd_ function. */
-#define I3_CMD Match *current_match, struct CommandResult *cmd_output
+#define I3_CMD Match *current_match, struct CommandResultIR *cmd_output
/**
* Initializes the specified 'Match' data structure and the initial state of
#include <yajl/yajl_gen.h>
/*
- * Holds the result of a call to any command. When calling
- * parse_command("floating enable, border none"), the parser will internally
- * use a struct CommandResult when calling cmd_floating and cmd_border.
- * parse_command will also return another struct CommandResult, whose
- * json_output is set to a map of individual json_outputs and whose
- * needs_tree_trender is true if any individual needs_tree_render was true.
- *
+ * Holds an intermediate represenation of the result of a call to any command.
+ * When calling parse_command("floating enable, border none"), the parser will
+ * internally use this struct when calling cmd_floating and cmd_border.
*/
-struct CommandResult {
+struct CommandResultIR {
/* The JSON generator to append a reply to. */
yajl_gen json_gen;
bool needs_tree_render;
};
-struct CommandResult *parse_command(const char *input);
+struct CommandResultIR *parse_command(const char *input);
uint32_t modifiers_from_str(const char *str);
/** The beginning of the prototype for every cfg_ function. */
-#define I3_CFG Match *current_match, struct ConfigResult *result
+#define I3_CFG Match *current_match, struct ConfigResultIR *result
/* Defines a configuration function, that is, anything that can be called by
* using 'call cfg_foo()' in parser-specs/.*.spec. Useful so that we don’t need
extern pid_t config_error_nagbar_pid;
/*
- * The result of a parse_config call. Currently unused, but the JSON output
- * will be useful in the future when we implement a config parsing IPC command.
+ * An intermediate reprsentation of the result of a parse_config call.
+ * Currently unused, but the JSON output will be useful in the future when we
+ * implement a config parsing IPC command.
*
*/
-struct ConfigResult {
+struct ConfigResultIR {
/* The JSON generator to append a reply to. */
yajl_gen json_gen;
int next_state;
};
-struct ConfigResult *parse_config(const char *input, struct context *context);
+struct ConfigResultIR *parse_config(const char *input, struct context *context);
/**
* Parses the given file by first replacing the variables, then calling
DLOG("execute command %s\n", current->dest.command);
char *full_command;
sasprintf(&full_command, "[id=\"%d\"] %s", window->id, current->dest.command);
- struct CommandResult *command_output = parse_command(full_command);
+ struct CommandResultIR *command_output = parse_command(full_command);
free(full_command);
if (command_output->needs_tree_render)
* and return true, signaling that no further workspace switching should occur in the calling function.
*
*/
-static bool maybe_back_and_forth(struct CommandResult *cmd_output, char *name) {
+static bool maybe_back_and_forth(struct CommandResultIR *cmd_output, char *name) {
Con *ws = con_get_workspace(focused);
/* If we switched to a different workspace, do nothing */
#ifndef TEST_PARSER
static Match current_match;
#endif
-static struct CommandResult subcommand_output;
-static struct CommandResult command_output;
+static struct CommandResultIR subcommand_output;
+static struct CommandResultIR command_output;
#include "GENERATED_command_call.h"
}
}
-struct CommandResult *parse_command(const char *input) {
+struct CommandResultIR *parse_command(const char *input) {
DLOG("COMMAND: *%s*\n", input);
state = INITIAL;
static cmdp_state state;
static Match current_match;
-static struct ConfigResult subcommand_output;
-static struct ConfigResult command_output;
+static struct ConfigResultIR subcommand_output;
+static struct ConfigResultIR command_output;
/* A list which contains the states that lead to the current state, e.g.
* INITIAL, WORKSPACE_LAYOUT.
return result;
}
-struct ConfigResult *parse_config(const char *input, struct context *context) {
+struct ConfigResultIR *parse_config(const char *input, struct context *context) {
/* Dump the entire config file into the debug log. We cannot just use
* DLOG("%s", input); because one log message must not exceed 4 KiB. */
const char *dumpwalk = input;
context = scalloc(sizeof(struct context));
context->filename = f;
- struct ConfigResult *config_output = parse_config(new, context);
+ struct ConfigResultIR *config_output = parse_config(new, context);
yajl_gen_free(config_output->json_gen);
check_for_duplicate_bindings(context);
char *command = scalloc(message_size + 1);
strncpy(command, (const char*)message, message_size);
LOG("IPC: received: *%s*\n", command);
- struct CommandResult *command_output = parse_command((const char*)command);
+ struct CommandResultIR *command_output = parse_command((const char*)command);
free(command);
if (command_output->needs_tree_render)
return;
char *command_copy = sstrdup(bind->command);
- struct CommandResult *command_output = parse_command(command_copy);
+ struct CommandResultIR *command_output = parse_command(command_copy);
free(command_copy);
if (command_output->needs_tree_render)