Skip to content

Commit

Permalink
!!! Start work on replacing the parsing in __execute_command_line ...
Browse files Browse the repository at this point in the history
... with hook functions that are implemented elsewhere.  This aims
at allowing to writing and testing multiple parsers in parallel
and at moving all parsing and expansion stuff to a different
place.
  • Loading branch information
domivogt committed Oct 25, 2016
1 parent 8a6de09 commit 1d38f7a
Show file tree
Hide file tree
Showing 27 changed files with 596 additions and 274 deletions.
4 changes: 3 additions & 1 deletion fvwm/Makefile.am
Expand Up @@ -19,6 +19,7 @@ fvwm_SOURCES = \
placement.h read.h repeat.h execcontext.h schedule.h screen.h \
session.h stack.h style.h update.h virtual.h window_flags.h frame.h \
infostore.h \
cmdparser.h cmdparser_old.h \
\
menus.c style.c borders.c events.c move_resize.c builtins.c \
add_window.c icons.c fvwm.c frame.c placement.c virtual.c \
Expand All @@ -28,7 +29,8 @@ fvwm_SOURCES = \
menubindings.c decorations.c ewmh_icons.c update.c bindings.c misc.c \
cursor.c colormaps.c modconf.c ewmh_conf.c read.c schedule.c \
menucmd.c ewmh_names.c icccm2.c windowshade.c focus_policy.c repeat.c \
execcontext.c menugeometry.c menudim.c condrc.c infostore.c
execcontext.c menugeometry.c menudim.c condrc.c infostore.c \
cmdparser_old.c

fvwm_DEPENDENCIES = $(top_builddir)/libs/libfvwm.a

Expand Down
7 changes: 4 additions & 3 deletions fvwm/add_window.c
Expand Up @@ -2615,7 +2615,8 @@ FvwmWindow *AddWindow(
SET_STICKY_ACROSS_PAGES(fw, 0);
SET_STICKY_ACROSS_DESKS(fw, 0);
handle_stick(
NULL, exc2, "", stick_page, stick_desk, 1, 0);
NULL, exc2, "", NULL, stick_page, stick_desk,
1, 0);
exc_destroy_context(exc2);
}
}
Expand Down Expand Up @@ -2646,7 +2647,7 @@ FvwmWindow *AddWindow(
ecc.w.wcontext = C_WINDOW;
exc2 = exc_clone_context(
exc, &ecc, ECC_ETRIGGER | ECC_FW | ECC_WCONTEXT);
CMD_Resize(NULL, exc2, "");
CMD_Resize(NULL, exc2, "", NULL);
exc_destroy_context(exc2);
}

Expand Down Expand Up @@ -2715,7 +2716,7 @@ FvwmWindow *AddWindow(
EWMH_STATE_HAS_HINT) ? 100 : 0;
sprintf(cmd,"Maximize on %i %i", h, v);
execute_function_override_window(
NULL, NULL, cmd, 0, fw);
NULL, NULL, cmd, NULL, 0, fw);
}
}
if (HAS_EWMH_INIT_FULLSCREEN_STATE(fw) == EWMH_STATE_HAS_HINT)
Expand Down
5 changes: 3 additions & 2 deletions fvwm/builtins.c
Expand Up @@ -57,6 +57,7 @@
#include "bindings.h"
#include "misc.h"
#include "cursor.h"
#include "cmdparser.h"
#include "functions.h"
#include "commands.h"
#include "screen.h"
Expand Down Expand Up @@ -431,7 +432,7 @@ static void __remove_window_decors(F_CMD_ARGS, FvwmDecor *d)
exc2 = exc_clone_context(
exc, &ecc, ECC_FW | ECC_WCONTEXT);
execute_function(
cond_rc, exc2, "ChangeDecor Default", 0);
cond_rc, exc2, "ChangeDecor Default", pc, 0);
exc_destroy_context(exc2);
}
}
Expand Down Expand Up @@ -2072,7 +2073,7 @@ void AddToDecor(F_CMD_ARGS, FvwmDecor *decor)
return;
}
Scr.cur_decor = decor;
execute_function(cond_rc, exc, action, 0);
execute_function(F_PASS_ARGS, 0);
Scr.cur_decor = NULL;

return;
Expand Down
92 changes: 92 additions & 0 deletions fvwm/cmdparser.h
@@ -0,0 +1,92 @@
/* -*-c-*- */

#ifndef CMDPARSER_H
#define CMDPARSER_H

/* ---------------------------- included header files ---------------------- */

/* ---------------------------- global definitions ------------------------- */

#define CMDPARSER_NUM_POS_ARGS 10

/* ---------------------------- global macros ------------------------------ */

/* ---------------------------- type definitions --------------------------- */

typedef enum
{
CP_PREFIX_NONE = 0,
CP_PREFIX_MINUS = 0x1,
CP_PREFIX_SILENT = 0x2,
CP_PREFIX_KEEPRC = 0x4
} cmdparser_prefix_flags_t;

/* move this to the implementation file and use void* instead??? */

typedef struct
{
/* !!!note: need to define which bits in here may be accessed by the
* user and which are internal */
char is_created : 1;
/* the original command line */
char *line;
/* the current command line */
char *cline;
/* the expanded command line */
char *expline;
int do_free_expline : 1;
/* the command name */
char *command;
/* current function nesting depth */
int call_depth;
/* an array of positional arguments; the first array element contains
* a string with all positional arguments, the remaining ten array
* elements contain the first ten positional arguments. Any of this
* may be NULL pointers */
char *pos_args[CMDPARSER_NUM_POS_ARGS];
} cmdparser_context_t;

typedef struct
{
/* in general, functions in this structure that return int return
* 0: success
* > 0: unsuccessful but not an error condition
* < 0: unsuccessful, error
*/
int (*create_context)(
/* context structure to initialise */
cmdparser_context_t *dest_context,
/* context structure of the caller or NULL */
cmdparser_context_t *caller_context,
/* input command line */
char *line,
/* an array of positional arguments or NULL; the first array
* element contains a string with all positional arguments,
* the remaining ten array elements contain the first ten
* positional arguments, up to the first NULL pointer; may be
* NULL if not present */
char *pos_args[]
);
int (*handle_line_start)(cmdparser_context_t *context);
/* Returns a set of or'ed flags of which prefixes are present on the
* command line. The prefixes are stripped. */
cmdparser_prefix_flags_t (*handle_line_prefix)(
cmdparser_context_t *context);
/* parses and returns the command name or returns a NULL pointer if not
* possible */
const char *(*parse_command_name)(
cmdparser_context_t *context, void *func_rc, const void *exc);
/* returns 1 if the stored command is a module configuration command
* and 0 otherwise */
int (*is_module_config)(cmdparser_context_t *context);
/* returns the expanded command line */
char *(*expand_command_line)(
cmdparser_context_t *context, int is_addto, void *func_rc,
const void *exc);
/* Release the expline field from the context structure and return it.
* It is then the responsibility of the caller to free() it. */
void (*release_expanded_line)(cmdparser_context_t *context);
void (*destroy_context)(cmdparser_context_t *context);
} cmdparser_hooks_t;

#endif /* CMDPARSER_H */

0 comments on commit 1d38f7a

Please sign in to comment.