1
0
Fork 0
forked from fte/fteqw

Trying to clean up qclib a little.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3220 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-06-13 11:57:52 +00:00
parent bd51fb8e9d
commit b3b885c122
13 changed files with 147 additions and 175 deletions

View file

@ -3,6 +3,7 @@ QCC_OBJS=qccmain.o qcc_pr_comp.o qcc_pr_lex.o
VM_OBJS=pr_exec.o pr_edict.o pr_multi.o initlib.o qcdecomp.o
GTKGUI_OBJS=qcc_gtk.o qccguistuff.o
WIN32GUI_OBJS=qccgui.o qccguistuff.o
TUI_OBJS=qcctui.o
LIB_OBJS=
CC=gcc -Wall
@ -31,10 +32,10 @@ nocyg:
win:
$(MAKE) USEGUI_CFLAGS="-DUSEGUI -DQCCONLY" R_win
R_qcc: $(QCC_OBJS) $(COMMON_OBJS)
$(CC) $(BASE_CFLAGS) -o fteqcc.bin -O3 -s $(QCC_OBJS) $(COMMON_OBJS)
R_qcc: $(QCC_OBJS) $(COMMON_OBJS) $(TUI_OBJS)
$(CC) $(BASE_CFLAGS) -o fteqcc.bin -O3 -s $(QCC_OBJS) $(TUI_OBJS) $(COMMON_OBJS)
qcc:
$(MAKE) USEGUI_CFLAGS="-DQCCONLY" R_qcc
$(MAKE) USEGUI_CFLAGS="" R_qcc
qccmain.o: qccmain.c qcc.h
$(DO_CC)
@ -82,4 +83,4 @@ testapp.bin: qcvm.so test.o
$(CC) $(BASE_CFLAGS) -o testapp.bin -O3 -s qcvm.so test.o
regressiontest: testapp.bin
./testapp.bin regression.dat -srcfile regression.src
./testapp.bin regression.dat -srcfile regression.src

View file

@ -41,11 +41,11 @@ void qccClearHunk(void)
qcchunk=NULL;
}
}
int qccpersisthunk;
void PostCompile(void)
{
#ifndef QCCONLY //QCCONLY has a frontend that browses defs.
qccClearHunk();
#endif
if (!qccpersisthunk)
qccClearHunk();
if (asmfile)
{

View file

@ -4,7 +4,7 @@ void EditFile(char *name, int line);
void GUI_SetDefaultOpts(void);
int GUI_BuildParms(char *args, char **argv);
char *QCC_ReadFile (char *fname, void *buffer, int len);
unsigned char *QCC_ReadFile (char *fname, void *buffer, int len);
int QCC_FileSize (char *fname);
pbool QCC_WriteFile (char *name, void *data, int len);
void GUI_DialogPrint(char *title, char *text);

View file

@ -587,7 +587,7 @@ progfuncs_t deffuncs = {
#endif
filefromprogs,
filefromnewprogs,
NULL,//filefromnewprogs,
SaveEnts,
LoadEnts,

View file

@ -25,19 +25,6 @@ vec3_t vec3_origin;
//int pr_max_edict_size;
//unsigned short pr_crc;
const unsigned int type_size[12] = {1, //void
sizeof(string_t)/4, //string
1, //float
3, //vector
1, //entity
1, //field
sizeof(func_t)/4,//function
sizeof(void *)/4,//pointer
1, //integer
1, //fixme: how big should a variant be?
0, //ev_struct. variable sized.
0 //ev_union. variable sized.
};
fdef_t *ED_FieldAtOfs (progfuncs_t *progfuncs, unsigned int ofs);
pbool ED_ParseEpair (progfuncs_t *progfuncs, void *base, ddefXX_t *key, char *s, int bits);

View file

@ -210,6 +210,25 @@ SOURCE=.\QccMain.c
# End Source File
# Begin Source File
SOURCE=.\qcctui.c
!IF "$(CFG)" == "qcc - Win32 Release"
!ELSEIF "$(CFG)" == "qcc - Win32 Debug"
!ELSEIF "$(CFG)" == "qcc - Win32 GUIDebug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "qcc - Win32 GUIRelease"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\qcd_main.c
# End Source File
# End Group

View file

@ -24,7 +24,7 @@
#define progfuncs qccprogfuncs
extern progfuncs_t *qccprogfuncs;
#if _WIN32 && !defined(MINGW)
#if defined(_WIN32) && !defined(MINGW)
#define inline _inline
#endif

View file

@ -17,6 +17,20 @@ char **myargv;
char qcc_token[1024];
int qcc_eof;
const unsigned int type_size[12] = {1, //void
sizeof(string_t)/4, //string
1, //float
3, //vector
1, //entity
1, //field
sizeof(func_t)/4,//function
sizeof(void *)/4,//pointer
1, //integer
1, //fixme: how big should a variant be?
0, //ev_struct. variable sized.
0 //ev_union. variable sized.
};
/*
============================================================================

View file

@ -67,22 +67,6 @@ QCC_type_t *type_variant;// = {ev_integer/*, &def_integer*/};
QCC_type_t *type_floatfield;// = {ev_field/*, &def_field*/, NULL, &type_float};
#ifdef QCCONLY
const unsigned int type_size[12] = {1, //void
sizeof(string_t)/4, //string
1, //float
3, //vector
1, //entity
1, //field
sizeof(func_t)/4,//function
sizeof(void *)/4,//pointer
1, //integer
1, //fixme: how big should a variant be?
0, //ev_struct. variable sized.
0 //ev_union. variable sized.
};
#endif
/*QCC_def_t def_void = {type_void, "temp"};
QCC_def_t def_string = {type_string, "temp"};
QCC_def_t def_float = {type_float, "temp"};

View file

@ -8,6 +8,106 @@
#include "qcc.h"
#include "gui.h"
/*
==============
LoadFile
==============
*/
unsigned char *QCC_ReadFile (char *fname, void *buffer, int len)
{
long length;
FILE *f;
f = fopen(fname, "rb");
if (!f)
return NULL;
length = fread(buffer, 1, len, f);
fclose(f);
if (length != len)
return NULL;
return buffer;
}
int QCC_FileSize (char *fname)
{
long length;
FILE *f;
f = fopen(fname, "rb");
if (!f)
return -1;
fseek(f, 0, SEEK_END);
length = ftell(f);
fclose(f);
return length;
}
pbool QCC_WriteFile (char *name, void *data, int len)
{
long length;
FILE *f;
f = fopen(name, "wb");
if (!f)
return false;
length = fwrite(data, 1, len, f);
fclose(f);
if (length != len)
return false;
return true;
}
#undef printf
#undef Sys_Error
void Sys_Error(const char *text, ...)
{
va_list argptr;
static char msg[2048];
va_start (argptr,text);
QC_vsnprintf (msg,sizeof(msg)-1, text,argptr);
va_end (argptr);
QCC_Error(ERR_INTERNAL, "%s", msg);
}
FILE *logfile;
int logprintf(const char *format, ...)
{
va_list argptr;
static char string[1024];
va_start (argptr, format);
#ifdef _WIN32
_vsnprintf (string,sizeof(string)-1, format,argptr);
#else
vsnprintf (string,sizeof(string), format,argptr);
#endif
va_end (argptr);
printf("%s", string);
if (logfile)
fputs(string, logfile);
return 0;
}
#define Edit_Redo(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_REDO, 0L, 0L))
@ -23,9 +123,6 @@
int GUIprintf(const char *msg, ...);
void GUIPrint(HWND wnd, char *msg);
char *QCC_ReadFile (char *fname, void *buffer, int len);
int QCC_FileSize (char *fname);
pbool QCC_WriteFile (char *name, void *data, int len);
char finddef[256];

View file

@ -13,6 +13,7 @@ char parameters[16384];
char progssrcname[256];
char progssrcdir[256];
int qccpersisthunk = 1;
void GoToDefinition(char *name)
{
QCC_def_t *def;

View file

@ -3431,134 +3431,4 @@ void new_QCC_ContinueCompile(void)
}*/
#ifdef QCCONLY
progfuncs_t *progfuncs;
/*
==============
LoadFile
==============
*/
unsigned char *QCC_ReadFile (char *fname, void *buffer, int len)
{
long length;
FILE *f;
f = fopen(fname, "rb");
if (!f)
return NULL;
length = fread(buffer, 1, len, f);
fclose(f);
if (length != len)
return NULL;
return buffer;
}
int QCC_FileSize (char *fname)
{
long length;
FILE *f;
f = fopen(fname, "rb");
if (!f)
return -1;
fseek(f, 0, SEEK_END);
length = ftell(f);
fclose(f);
return length;
}
pbool QCC_WriteFile (char *name, void *data, int len)
{
long length;
FILE *f;
f = fopen(name, "wb");
if (!f)
return false;
length = fwrite(data, 1, len, f);
fclose(f);
if (length != len)
return false;
return true;
}
#undef printf
#undef Sys_Error
void Sys_Error(const char *text, ...)
{
va_list argptr;
static char msg[2048];
va_start (argptr,text);
QC_vsnprintf (msg,sizeof(msg)-1, text,argptr);
va_end (argptr);
QCC_Error(ERR_INTERNAL, "%s", msg);
}
#ifndef USEGUI
#include <stdarg.h>
FILE *logfile;
int logprintf(const char *format, ...)
{
va_list argptr;
static char string[1024];
va_start (argptr, format);
#ifdef _WIN32
_vsnprintf (string,sizeof(string)-1, format,argptr);
#else
vsnprintf (string,sizeof(string), format,argptr);
#endif
va_end (argptr);
printf("%s", string);
if (logfile)
fputs(string, logfile);
return 0;
}
int main (int argc, char **argv)
{
int sucess;
progexterns_t ext;
progfuncs_t funcs;
progfuncs = &funcs;
memset(&funcs, 0, sizeof(funcs));
funcs.parms = &ext;
memset(&ext, 0, sizeof(progexterns_t));
funcs.parms->ReadFile = QCC_ReadFile;
funcs.parms->FileSize = QCC_FileSize;
funcs.parms->WriteFile = QCC_WriteFile;
funcs.parms->printf = logprintf;
funcs.parms->Sys_Error = Sys_Error;
logfile = fopen("fteqcc.log", "wt");
sucess = CompileParams(&funcs, true, argc, argv);
qccClearHunk();
if (logfile)
fclose(logfile);
#ifdef _WIN32
// fgetc(stdin); //wait for keypress
#endif
return !sucess;
}
#endif//usegui
#endif//qcconly
#endif//minimal

View file

@ -186,7 +186,7 @@ char *filefromprogs(progfuncs_t *progfuncs, progsnum_t prnum, char *fname, int *
return NULL;
}
#ifndef QCCONLY
/*
char *filefromnewprogs(progfuncs_t *progfuncs, char *prname, char *fname, int *size, char *buffer)
{
int num;
@ -225,5 +225,4 @@ char *filefromnewprogs(progfuncs_t *progfuncs, char *prname, char *fname, int *s
*size = 0;
return NULL;
}
#endif
*/