[plugin] Clean up the rest of the plugin structs

This commit is contained in:
Bill Currie 2021-06-22 19:47:20 +09:00
parent db322ce88b
commit c9319966ce
15 changed files with 85 additions and 121 deletions

View file

@ -88,11 +88,11 @@ typedef struct plugin_s {
/*
General plugin info return function type
*/
typedef plugin_t * (*P_PluginInfo) (void);
typedef plugin_t *(*plugin_info_t) (void);
typedef struct plugin_list_s {
const char *name;
P_PluginInfo info;
const char *name;
plugin_info_t info;
} plugin_list_t;
/*

View file

@ -24,33 +24,24 @@
Boston, MA 02111-1307, USA
*/
#ifndef __QF_plugin_cd_h_
#define __QF_plugin_cd_h_
#ifndef __QF_plugin_cd_h
#define __QF_plugin_cd_h
#include <QF/plugin.h>
#include <QF/qtypes.h>
/*
All CDAudio plugins must export these functions
*/
typedef void (*P_CDAudio_CD_f) (void); //
typedef void (*P_CDAudio_Pause) (void);
typedef void (*P_CDAudio_Play) (int, qboolean);
typedef void (*P_CDAudio_Resume) (void);
typedef void (*P_CDAudio_Shutdown) (void);
typedef void (*P_CDAudio_Update) (void);
typedef void (*P_CDAudio_Init) (void);
typedef struct cd_funcs_s {
P_CDAudio_CD_f pCD_f; //
P_CDAudio_Pause pCDAudio_Pause;
P_CDAudio_Play pCDAudio_Play;
P_CDAudio_Resume pCDAudio_Resume;
P_CDAudio_Update pCDAudio_Update;
void (*cd_f) (void); //
void (*pause) (void);
void (*play) (int, qboolean);
void (*resume) (void);
void (*shutdown) (void);
void (*update) (void);
void (*init) (void);
} cd_funcs_t;
typedef struct cd_data_s {
int unused; /* C requires that a struct or union has at least one member */
int unused;
} cd_data_t;
#endif // __QF_plugin_cd_h_
#endif // __QF_plugin_cd_h

View file

@ -25,8 +25,8 @@
*/
#ifndef __QF_plugin_console_h_
#define __QF_plugin_console_h_
#ifndef __QF_plugin_console_h
#define __QF_plugin_console_h
#include <stdarg.h>
@ -34,36 +34,29 @@
#include <QF/plugin.h>
#include <QF/qtypes.h>
typedef void (*P_C_Print) (const char *fmt, va_list args) __attribute__((format(PRINTF, 1, 0)));
typedef void (*P_C_ProcessInput) (void);
typedef void (*P_C_KeyEvent) (knum_t key, short unicode, qboolean down);
typedef void (*P_C_DrawConsole) (void);
typedef void (*P_C_CheckResize) (void);
typedef void (*P_C_NewMap) (void);
typedef struct console_funcs_s {
P_C_Print pC_Print;
P_C_ProcessInput pC_ProcessInput;
P_C_KeyEvent pC_KeyEvent;
P_C_DrawConsole pC_DrawConsole;
P_C_CheckResize pC_CheckResize;
P_C_NewMap pC_NewMap;
void (*print) (const char *fmt, va_list args) __attribute__((format(PRINTF, 1, 0)));
void (*process_input) (void);
void (*key_event) (knum_t key, short unicode, qboolean down);
void (*draw_console) (void);
void (*check_resize) (void);
void (*new_map) (void);
} console_funcs_t;
typedef struct console_data_s {
struct dstring_s *dl_name;
int *dl_percent;
double *realtime;
double *frametime;
int force_commandline;
int ormask;
void (*quit)(void);
struct cbuf_s *cbuf;
struct view_s *view;
struct view_s *status_view;
float lines;
int (*exec_line)(void *data, const char *line);
void *exec_data;
struct dstring_s *dl_name;
int *dl_percent;
double *realtime;
double *frametime;
int force_commandline;
int ormask;
void (*quit) (void);
struct cbuf_s *cbuf;
struct view_s *view;
struct view_s *status_view;
float lines;
int (*exec_line)(void *data, const char *line);
void *exec_data;
} console_data_t;
#endif // __QF_plugin_console_h_
#endif // __QF_plugin_console_h

View file

@ -25,28 +25,21 @@
*/
#ifndef __QF_plugin_general_h_
#define __QF_plugin_general_h_
#ifndef __QF_plugin_general_h
#define __QF_plugin_general_h
#include <QF/plugin.h>
#include <QF/qtypes.h>
/*
All plugins, of all types, must export these functions
*/
typedef void (*P_Init) (void);
typedef void (*P_Shutdown) (void);
typedef struct general_funcs_s {
P_Init p_Init;
P_Shutdown p_Shutdown;
void (*init) (void);
void (*shutdown) (void);
} general_funcs_t;
#define PIF_GLOBAL 1
typedef struct general_data_s {
int flag;
int flag;
} general_data_t;
#endif // __QF_plugin_general_h_
#endif // __QF_plugin_general_h

View file

@ -25,29 +25,16 @@
*/
#ifndef __QF_plugin_input_h_
#define __QF_plugin_input_h_
#ifndef __QF_plugin_input_h
#define __QF_plugin_input_h
#include <QF/plugin.h>
#include <QF/qtypes.h>
/*
All input plugins must export these functions
*/
typedef void (*P_IN_Commands) (void);
typedef void (*P_IN_SendKeyEvents) (void);
typedef void (*P_IN_Move) (void);
typedef void (*P_IN_ModeChanged) (void);
typedef struct input_funcs_s {
P_IN_Commands pIN_Commands;
P_IN_SendKeyEvents pIN_SendKeyEvents;
P_IN_Move pIN_Move;
P_IN_ModeChanged pIN_ModeChanged;
} input_funcs_t;
typedef struct input_data_s {
int unused; /* C requires that a struct or union has at least one member */
} input_data_t;
#endif // __QF_plugin_input_h_
#endif // __QF_plugin_input_h

View file

@ -24,8 +24,8 @@
Boston, MA 02111-1307, USA
*/
#ifndef __QF_plugin_snd_output_h_
#define __QF_plugin_snd_output_h_
#ifndef __QF_plugin_snd_output_h
#define __QF_plugin_snd_output_h
#include <QF/plugin.h>
#include <QF/qtypes.h>
@ -54,4 +54,4 @@ typedef struct snd_output_data_s {
unsigned *paintedtime;
} snd_output_data_t;
#endif // __QF_plugin_snd_output_h_
#endif // __QF_plugin_snd_output_h

View file

@ -24,8 +24,8 @@
Boston, MA 02111-1307, USA
*/
#ifndef __QF_plugin_snd_render_h_
#define __QF_plugin_snd_render_h_
#ifndef __QF_plugin_snd_render_h
#define __QF_plugin_snd_render_h
#include <QF/plugin.h>
#include <QF/qtypes.h>
@ -64,4 +64,4 @@ typedef struct snd_render_data_s {
struct plugin_s *output;
} snd_render_data_t;
#endif // __QF_plugin_snd_render_h_
#endif // __QF_plugin_snd_render_h

View file

@ -24,8 +24,8 @@
Boston, MA 02111-1307, USA
*/
#ifndef __QF_plugin_vid_render_h_
#define __QF_plugin_vid_render_h_
#ifndef __QF_plugin_vid_render_h
#define __QF_plugin_vid_render_h
#include <QF/draw.h>
#include <QF/plugin.h>
@ -199,4 +199,4 @@ typedef struct vid_render_data_s {
vec_t *vup;
} vid_render_data_t;
#endif // __QF_plugin_vid_render_h_
#endif // __QF_plugin_vid_render_h

View file

@ -52,42 +52,42 @@ VISIBLE void
CDAudio_Pause (void)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Pause ();
cdmodule->functions->cd->pause ();
}
VISIBLE void
CDAudio_Play (int track, qboolean looping)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Play (track, looping);
cdmodule->functions->cd->play (track, looping);
}
VISIBLE void
CDAudio_Resume (void)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Resume ();
cdmodule->functions->cd->resume ();
}
static void
CDAudio_shutdown (void *data)
{
if (cdmodule)
cdmodule->functions->general->p_Shutdown ();
cdmodule->functions->general->shutdown ();
}
VISIBLE void
CDAudio_Update (void)
{
if (cdmodule)
cdmodule->functions->cd->pCDAudio_Update ();
cdmodule->functions->cd->update ();
}
static void
CD_f (void)
{
if (cdmodule)
cdmodule->functions->cd->pCD_f ();
cdmodule->functions->cd->cd_f ();
}
VISIBLE int
@ -111,7 +111,7 @@ CDAudio_Init (void)
Sys_Printf ("Loading of cd module: %s failed!\n", cd_plugin->string);
return -1;
}
cdmodule->functions->general->p_Init ();
cdmodule->functions->general->init ();
Cmd_AddCommand (
"cd", CD_f, "Control the CD player.\n"
"Commands:\n"

View file

@ -99,8 +99,8 @@ S_Init (int *viewentity, double *host_frametime)
host_frametime;
snd_render_module->data->snd_render->output = snd_output_module;
snd_output_module->functions->general->p_Init ();
snd_render_module->functions->general->p_Init ();
snd_output_module->functions->general->init ();
snd_render_module->functions->general->init ();
snd_output_module->data->snd_output->soundtime
= snd_render_module->data->snd_render->soundtime;

View file

@ -552,8 +552,8 @@ PLUGIN_INFO(snd_output, alsa)
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_general_funcs.init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;

View file

@ -410,8 +410,8 @@ PLUGIN_INFO(snd_output, oss)
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_general_funcs.init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;

View file

@ -90,7 +90,7 @@ static void
Con_shutdown (void *data)
{
if (con_module) {
con_module->functions->general->p_Shutdown ();
con_module->functions->general->shutdown ();
PI_UnloadPlugin (con_module);
}
}
@ -102,8 +102,8 @@ Con_Init (const char *plugin_name)
con_module = PI_LoadPlugin ("console", plugin_name);
if (con_module) {
con_module->functions->general->p_Init ();
Sys_SetStdPrintf (con_module->functions->console->pC_Print);
con_module->functions->general->init ();
Sys_SetStdPrintf (con_module->functions->console->print);
} else {
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
}
@ -143,7 +143,7 @@ Con_Printf (const char *fmt, ...)
va_start (args, fmt);
if (con_module)
con_module->functions->console->pC_Print (fmt, args);
con_module->functions->console->print (fmt, args);
else
vfprintf (stdout, fmt, args);
va_end (args);
@ -153,7 +153,7 @@ VISIBLE void
Con_Print (const char *fmt, va_list args)
{
if (con_module)
con_module->functions->console->pC_Print (fmt, args);
con_module->functions->console->print (fmt, args);
else
vfprintf (stdout, fmt, args);
}
@ -162,7 +162,7 @@ VISIBLE void
Con_ProcessInput (void)
{
if (con_module) {
con_module->functions->console->pC_ProcessInput ();
con_module->functions->console->process_input ();
} else {
static int been_there_done_that = 0;
@ -177,7 +177,7 @@ VISIBLE void
Con_KeyEvent (knum_t key, short unicode, qboolean down)
{
if (con_module)
con_module->functions->console->pC_KeyEvent (key, unicode, down);
con_module->functions->console->key_event (key, unicode, down);
}
VISIBLE void
@ -191,19 +191,19 @@ VISIBLE void
Con_DrawConsole (void)
{
if (con_module)
con_module->functions->console->pC_DrawConsole ();
con_module->functions->console->draw_console ();
}
VISIBLE void
Con_CheckResize (void)
{
if (con_module)
con_module->functions->console->pC_CheckResize ();
con_module->functions->console->check_resize ();
}
VISIBLE void
Con_NewMap (void)
{
if (con_module)
con_module->functions->console->pC_NewMap ();
con_module->functions->console->new_map ();
}

View file

@ -201,8 +201,8 @@ PI_Plugin_Load_f (void)
Sys_Printf ("Error loading plugin %s %s\n", type, name);
else if (pi->functions && pi->functions->general &&
pi->functions->general->p_Init)
pi->functions->general->p_Init ();
pi->functions->general->init)
pi->functions->general->init ();
}
static void
@ -274,7 +274,7 @@ PI_LoadPlugin (const char *type, const char *name)
const char *tmpname;
void *dlhand = 0;
plugin_t *plugin = 0;
P_PluginInfo plugin_info = 0;
plugin_info_t plugin_info = 0;
plugin_list_t *pl;
loaded_plugin_t *lp;
@ -388,8 +388,8 @@ PI_UnloadPlugin (plugin_t *plugin)
if (plugin
&& plugin->functions
&& plugin->functions->general
&& plugin->functions->general->p_Shutdown) {
plugin->functions->general->p_Shutdown ();
&& plugin->functions->general->shutdown) {
plugin->functions->general->shutdown ();
} else {
Sys_MaskPrintf (SYS_dev,
"Warning: No shutdown function for type %d plugin!\n",

View file

@ -68,8 +68,8 @@ static U void (*const r_scrapdelete)(rscrap_t *) = R_ScrapDelete;
static void
R_shutdown (void *data)
{
if (vidrendmodule->functions->general->p_Shutdown) {
vidrendmodule->functions->general->p_Shutdown ();
if (vidrendmodule->functions->general->shutdown) {
vidrendmodule->functions->general->shutdown ();
}
}
@ -89,7 +89,7 @@ R_LoadModule (vid_internal_t *vid_internal)
r_data = vidrendmodule->data->vid_render;
r_data->vid->vid_internal = vid_internal;
vidrendmodule->functions->general->p_Init ();
vidrendmodule->functions->general->init ();
Sys_RegisterShutdown (R_shutdown, 0);
}