- fixed dependency problems with OSD definitions being used in another header.

This commit is contained in:
Christoph Oelckers 2019-11-05 00:39:00 +01:00
parent 5b67d653ed
commit e37cb782ca
3 changed files with 16 additions and 14 deletions

View file

@ -6,16 +6,17 @@
#define osd_h_ #define osd_h_
#include <functional> #include <functional>
#include "vfs.h"
#include "compat.h"
#include "mutex.h" #include "mutex.h"
typedef struct { struct osdfuncparm_t
int32_t numparms; {
const char *name; int32_t numparms;
const char **parms; const char* name;
const char *raw; const char** parms;
} osdfuncparm_t; const char* raw;
};
using osdcmdptr_t = osdfuncparm_t const * const; using osdcmdptr_t = osdfuncparm_t const * const;
@ -156,7 +157,7 @@ typedef struct
typedef struct typedef struct
{ {
buildvfs_FILE fp; FILE *fp;
int32_t cutoff; int32_t cutoff;
int32_t errors; int32_t errors;
int32_t lines; int32_t lines;
@ -187,7 +188,7 @@ typedef struct
extern osdmain_t *osd; extern osdmain_t *osd;
extern buildvfs_FILE osdlog; extern FILE * osdlog;
extern const char* osdlogfn; extern const char* osdlogfn;
enum osdflags_t enum osdflags_t
@ -279,12 +280,11 @@ int OSD_RegisterFunction(const char *pszName, const char *pszDesc, int (*func)(o
int osdcmd_cvar_set(osdcmdptr_t parm); int osdcmd_cvar_set(osdcmdptr_t parm);
void OSD_RegisterCvar(osdcvardata_t * cvar, int (*func)(osdcmdptr_t)); void OSD_RegisterCvar(osdcvardata_t * cvar, int (*func)(osdcmdptr_t));
void OSD_WriteAliases(buildvfs_FILE fp);
static inline void OSD_SetHistory(int idx, const char *src) static inline void OSD_SetHistory(int idx, const char *src)
{ {
osd->history.buf[idx] = (char *)Xmalloc(OSDEDITLENGTH); osd->history.buf[idx] = (char *)malloc(OSDEDITLENGTH);
Bstrncpyz(osd->history.buf[idx], src, OSDEDITLENGTH); strncpy(osd->history.buf[idx], src, OSDEDITLENGTH);
} }
extern int osdcmd_restartvid(osdcmdptr_t parm); extern int osdcmd_restartvid(osdcmdptr_t parm);

View file

@ -32,12 +32,14 @@
** **
*/ */
class FConfigFile; class FConfigFile;
struct osdfuncparm_t;
// Class that can parse command lines // Class that can parse command lines
class FCommandLine class FCommandLine
{ {
friend int OSD_RegisterFunction(const char* pszName, const char* pszDesc, int (*func)(osdfuncparm_t const* const));
public: public:
FCommandLine (const char *commandline, bool no_escapes = false); FCommandLine (const char *commandline, bool no_escapes = false);
~FCommandLine (); ~FCommandLine ();

View file

@ -1036,7 +1036,7 @@ static TArray<FConsoleCommand*> dynccmds; // This needs to be explicitly deleted
int OSD_RegisterFunction(const char* pszName, const char* pszDesc, int (*func)(osdcmdptr_t)) int OSD_RegisterFunction(const char* pszName, const char* pszDesc, int (*func)(osdcmdptr_t))
{ {
FString nname = pszName; FString nname = pszName;
auto callback = [nname, pszDesc, func](FCommandLine& args, int key) auto callback = [nname, pszDesc, func](FCommandLine& args, void *, int key)
{ {
if (args.argc() > 0) args.operator[](0); if (args.argc() > 0) args.operator[](0);
osdfuncparm_t param = { args.argc(), nname.GetChars(), (const char**)args._argv + 1, args.cmd }; osdfuncparm_t param = { args.argc(), nname.GetChars(), (const char**)args._argv + 1, args.cmd };