more rua cleanups: now just one init function to call (it calls the rest)

This commit is contained in:
Bill Currie 2004-01-16 07:03:58 +00:00
parent 01392c78bb
commit e7ffad8772
19 changed files with 121 additions and 80 deletions

View file

@ -9,8 +9,8 @@ EXTRA_DIST = asm_i386.h alsa_funcs_list.h adivtab.h anorm_dots.h anorms.h \
gib_thread.h gib_tree.h gib_vars.h gl_warp_sin.h in_win.h logos.h menu.h \
net_dgrm.h net_loop.h net_udp.h net_vcr.h net_wins.h netchan.h netmain.h \
old_keys.h ops.h qstring.h quakeasm.h regex.h r_cvar.h r_dynamic.h \
r_local.h r_screen.h r_shared.h sbar.h skin_stencil.h snd_render.h \
varrays.h vgamodes.h view.h vregset.h winquake.h world.h \
r_local.h r_screen.h r_shared.h rua_internal.h sbar.h skin_stencil.h \
snd_render.h varrays.h vgamodes.h view.h vregset.h winquake.h world.h \
\
win32/fnmatch.h \
\

View file

@ -32,35 +32,10 @@
#ifndef __QF_ruamoko_h
#define __QF_ruamoko_h
struct progs_s;
struct cbuf_s;
void RUA_Init (void);
void RUA_Cbuf_Init (struct progs_s *pr);
void Cbuf_Progs_SetCbuf (struct progs_s *pr, struct cbuf_s *cbuf);
void RUA_Cmd_Init (struct progs_s *pr);
void RUA_Cvar_Init (struct progs_s *pr);
void RUA_File_Init (struct progs_s *pr);
void RUA_Hash_Init (struct progs_s *pr);
void RUA_Plist_Init (struct progs_s *pr);
void RUA_String_Init (struct progs_s *pr);
#include "QF/quakeio.h"
#define QFILE_MAX_HANDLES 20
typedef struct {
QFile *handles[QFILE_MAX_HANDLES];
} qfile_resources_t;
void RUA_QFile_Init (struct progs_s *pr, int secure);
QFile **QFile_AllocHandle (struct progs_s *pr, qfile_resources_t *res);
void RUA_QFS_Init (struct progs_s *pr);
void RUA_Init (struct progs_s *pr, int secure);
void RUA_Cbuf_SetCbuf (struct progs_s *pr, struct cbuf_s *cbuf);
#endif//__QF_ruamoko_h

60
include/rua_internal.h Normal file
View file

@ -0,0 +1,60 @@
/*
rua_internal.h
ruamoko internal prototypes
Copyright (C) 2001 Bill Currie
Author: Bill Currie
Date: 2003/1/15
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __rua_internal_h
#define __rua_internal_h
#include "QF/quakeio.h"
#define QFILE_MAX_HANDLES 20
typedef struct {
QFile *handles[QFILE_MAX_HANDLES];
} qfile_resources_t;
void RUA_Cbuf_Init (struct progs_s *pr, int secure);
void RUA_Cmd_Init (struct progs_s *pr, int secure);
void RUA_Cvar_Init (struct progs_s *pr, int secure);
void RUA_File_Init (struct progs_s *pr, int secure);
void RUA_Hash_Init (struct progs_s *pr, int secure);
void RUA_Plist_Init (struct progs_s *pr, int secure);
void RUA_String_Init (struct progs_s *pr, int secure);
void RUA_QFile_Init (struct progs_s *pr, int secure);
QFile **QFile_AllocHandle (struct progs_s *pr, qfile_resources_t *res);
void RUA_QFS_Init (struct progs_s *pr, int secure);
#endif//__rua_internal_h

View file

@ -445,28 +445,20 @@ Menu_Init (void)
menu_pr_state.free_progs_mem = menu_free_progs_mem;
menu_pr_state.load_file = menu_load_file;
PR_Resources_Init (&menu_pr_state);
menu_hash = Hash_NewTable (61, menu_get_key, menu_free, 0);
PR_RegisterBuiltins (&menu_pr_state, builtins);
PR_Obj_Progs_Init (&menu_pr_state);
RUA_Init (&menu_pr_state, 1);
InputLine_Progs_Init (&menu_pr_state);
Key_Progs_Init (&menu_pr_state);
GIB_Progs_Init (&menu_pr_state);
PR_Cmds_Init (&menu_pr_state);
R_Progs_Init (&menu_pr_state);
RUA_Cbuf_Init (&menu_pr_state);
RUA_Cmd_Init (&menu_pr_state);
RUA_Cvar_Init (&menu_pr_state);
RUA_File_Init (&menu_pr_state);
RUA_QFile_Init (&menu_pr_state, 1);
RUA_QFS_Init (&menu_pr_state);
RUA_String_Init (&menu_pr_state);
PR_AddLoadFunc (&menu_pr_state, menu_resolve_globals);
confirm_quit = Cvar_Get ("confirm_quit", "1", CVAR_ARCHIVE, NULL,
@ -508,7 +500,7 @@ Menu_Load (void)
Con_SetOrMask (0x00);
return;
}
Cbuf_Progs_SetCbuf (&menu_pr_state, con_data.cbuf);
RUA_Cbuf_SetCbuf (&menu_pr_state, con_data.cbuf);
InputLine_Progs_SetDraw (&menu_pr_state, C_DrawInputLine);
PR_ExecuteProgram (&menu_pr_state, menu_init);
}

View file

@ -38,6 +38,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/progs.h"
#include "QF/ruamoko.h"
#include "rua_internal.h"
typedef struct {
cbuf_t *cbuf;
@ -111,7 +112,7 @@ static builtin_t builtins[] = {
};
void
RUA_Cbuf_Init (progs_t *pr)
RUA_Cbuf_Init (progs_t *pr, int secure)
{
cbuf_resources_t *res = calloc (sizeof (cbuf_resources_t), 1);
PR_Resources_Register (pr, "Cbuf", res, bi_cbuf_clear);
@ -119,7 +120,7 @@ RUA_Cbuf_Init (progs_t *pr)
}
void
Cbuf_Progs_SetCbuf (progs_t *pr, cbuf_t *cbuf)
RUA_Cbuf_SetCbuf (progs_t *pr, cbuf_t *cbuf)
{
cbuf_resources_t *res = PR_Resources_Find (pr, "Cbuf");
res->cbuf = cbuf;

View file

@ -45,9 +45,10 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/cmd.h"
#include "QF/hash.h"
#include "QF/progs.h"
#include "QF/ruamoko.h"
#include "QF/sys.h"
#include "rua_internal.h"
typedef struct bi_cmd_s {
struct bi_cmd_s *next;
char *name;
@ -156,7 +157,7 @@ static builtin_t builtins[] = {
};
void
RUA_Cmd_Init (progs_t *pr)
RUA_Cmd_Init (progs_t *pr, int secure)
{
cmd_resources_t *res = malloc (sizeof (cmd_resources_t));

View file

@ -40,9 +40,10 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/cvar.h"
#include "QF/progs.h"
#include "QF/ruamoko.h"
#include "QF/zone.h"
#include "rua_internal.h"
/*
bi_Cvar_GetCvarString
@ -62,7 +63,7 @@ static builtin_t builtins[] = {
};
void
RUA_Cvar_Init (progs_t *pr)
RUA_Cvar_Init (progs_t *pr, int secure)
{
PR_RegisterBuiltins (pr, builtins);
}

View file

@ -56,10 +56,11 @@ int fnmatch (const char *__pattern, const char *__string, int __flags);
#include "QF/cvar.h"
#include "QF/progs.h"
#include "QF/quakefs.h"
#include "QF/ruamoko.h"
#include "QF/va.h"
#include "QF/zone.h"
#include "rua_internal.h"
static const char *file_ban_list[] = {
"default.cfg{,.gz}",
"demo1.dem{,.gz}",
@ -179,7 +180,7 @@ static builtin_t builtins[] = {
};
void
RUA_File_Init (progs_t *pr)
RUA_File_Init (progs_t *pr, int secure)
{
PR_RegisterBuiltins (pr, builtins);
}

View file

@ -44,7 +44,8 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/hash.h"
#include "QF/progs.h"
#include "QF/ruamoko.h"
#include "rua_internal.h"
typedef struct bi_hashtab_s {
struct bi_hashtab_s *next;
@ -325,7 +326,7 @@ static builtin_t builtins[] = {
};
void
RUA_Hash_Init (progs_t *pr)
RUA_Hash_Init (progs_t *pr, int secure)
{
hash_resources_t *res = malloc (sizeof (hash_resources_t));
res->tabs = 0;

View file

@ -34,20 +34,26 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/progs.h"
#include "QF/ruamoko.h"
#define U __attribute__ ((unused))
static U void (*const cbuf_progs_init)(progs_t *) = RUA_Cbuf_Init;
static U void (*const cmd_progs_init)(progs_t *) = RUA_Cmd_Init;
static U void (*const cvar_progs_init)(progs_t *) = RUA_Cvar_Init;
static U void (*const file_progs_init)(progs_t *) = RUA_File_Init;
static U void (*const hash_progs_init)(progs_t *) = RUA_Hash_Init;
static U void (*const plist_progs_init)(progs_t *) = RUA_Plist_Init;
static U void (*const qfile_progs_init)(progs_t *, int) = RUA_QFile_Init;
static U void (*const qfs_progs_init)(progs_t *) = RUA_QFS_Init;
static U void (*const string_progs_init)(progs_t *) = RUA_String_Init;
#undef U
#include "rua_internal.h"
static void (*init_funcs[])(progs_t *, int) = {
RUA_Cbuf_Init,
RUA_Cmd_Init,
RUA_Cvar_Init,
RUA_File_Init,
RUA_Hash_Init,
RUA_Plist_Init,
RUA_QFile_Init,
RUA_QFS_Init,
RUA_String_Init,
};
void
RUA_Init (void)
RUA_Init (progs_t *pr, int secure)
{
// do nothing stub for now. used to force linking
int i;
PR_Resources_Init (pr);
for (i = 0; i < sizeof (init_funcs) / sizeof (init_funcs[0]); i++)
init_funcs[i] (pr, secure);
}

View file

@ -45,7 +45,8 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/hash.h"
#include "QF/progs.h"
#include "QF/qfplist.h"
#include "QF/ruamoko.h"
#include "rua_internal.h"
typedef struct {
hashtab_t *items;
@ -184,7 +185,7 @@ static builtin_t builtins[] = {
};
void
RUA_Plist_Init (progs_t *pr)
RUA_Plist_Init (progs_t *pr, int secure)
{
plist_resources_t *res = malloc (sizeof (plist_resources_t));
res->items = Hash_NewTable (1021, 0, 0, 0);

View file

@ -41,10 +41,11 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/progs.h"
#include "QF/quakefs.h"
#include "QF/ruamoko.h"
#include "QF/va.h"
#include "QF/zone.h"
#include "rua_internal.h"
static void
bi_qfile_clear (progs_t *pr, void *data)
{

View file

@ -41,10 +41,11 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/progs.h"
#include "QF/quakefs.h"
#include "QF/ruamoko.h"
#include "QF/va.h"
#include "QF/zone.h"
#include "rua_internal.h"
static void
check_buffer (progs_t *pr, pr_type_t *buf, int count, const char *name)
{
@ -125,7 +126,7 @@ static builtin_t builtins[] = {
};
void
RUA_QFS_Init (progs_t *pr)
RUA_QFS_Init (progs_t *pr, int secure)
{
PR_RegisterBuiltins (pr, builtins);
}

View file

@ -44,7 +44,8 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/dstring.h"
#include "QF/progs.h"
#include "QF/ruamoko.h"
#include "rua_internal.h"
static void
bi_str_new (progs_t *pr)
@ -86,7 +87,7 @@ static builtin_t builtins[] = {
};
void
RUA_String_Init (progs_t *pr)
RUA_String_Init (progs_t *pr, int secure)
{
PR_RegisterBuiltins (pr, builtins);
}

View file

@ -44,7 +44,6 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/plugin.h"
#include "QF/progs.h"
#include "QF/qargs.h"
#include "QF/ruamoko.h"
#include "QF/screen.h"
#include "QF/sys.h"
#include "QF/va.h"
@ -917,7 +916,6 @@ Host_Init (void)
V_Init_Cvars ();
PR_Init ();
RUA_Init ();
V_Init ();
Game_Init ();

View file

@ -44,6 +44,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/msg.h"
#include "QF/ruamoko.h"
#include "QF/sys.h"
#include "QF/va.h"
@ -1411,8 +1412,10 @@ static builtin_t builtins[] = {
void
SV_PR_Cmds_Init ()
{
PR_Cmds_Init (&sv_pr_state);
PR_Obj_Progs_Init (&sv_pr_state);
RUA_Init (&sv_pr_state, 1);
PR_Cmds_Init (&sv_pr_state);
PR_RegisterBuiltins (&sv_pr_state, builtins);
}

View file

@ -1685,7 +1685,6 @@ Host_Init (void)
VID_Init_Cvars ();
PR_Init ();
RUA_Init ();
CL_Chat_Init ();

View file

@ -44,6 +44,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/cmd.h"
#include "QF/cvar.h"
#include "QF/msg.h"
#include "QF/ruamoko.h"
#include "QF/sys.h"
#include "QF/va.h"
@ -2006,9 +2007,11 @@ void
SV_PR_Cmds_Init ()
{
builtin_t *bi;
PR_Cmds_Init (&sv_pr_state);
PR_Obj_Progs_Init (&sv_pr_state);
PR_Obj_Progs_Init (&sv_pr_state);
RUA_Init (&sv_pr_state, 1);
PR_Cmds_Init (&sv_pr_state);
// (override standard builtin)
// float (string s) cvar
bi = PR_FindBuiltin (&sv_pr_state, "cvar");

View file

@ -38,7 +38,6 @@
#include "QF/cmd.h"
#include "QF/cvar.h"
#include "QF/quakefs.h"
#include "QF/ruamoko.h"
#include "QF/sys.h"
#include "compat.h"
@ -392,11 +391,8 @@ SV_Progs_Init (void)
sv_pr_state.free_edict = free_edict; // eww, I hate the need for this :(
sv_pr_state.bi_map = bi_map;
PR_Resources_Init (&sv_pr_state);
SV_PR_Cmds_Init ();
SV_PR_QWE_Init (&sv_pr_state);
RUA_Cmd_Init (&sv_pr_state);
RUA_Hash_Init (&sv_pr_state);
Cmd_AddCommand ("edict", ED_PrintEdict_f, "Report information on a given "
"edict in the game. (edict (edict number))");