Port a bunch of legwork files to C++.

This commit is contained in:
David Anderson 2014-08-21 23:53:11 -07:00
parent 5a4c50ce55
commit 261188fd1b
8 changed files with 24 additions and 68 deletions

View File

@ -78,10 +78,10 @@ elif builder.target_platform == 'mac':
]
binary.sources += [
'libpawnc.c',
'libpawnc.cpp',
'lstring.c',
'memfile.c',
'pawncc.c',
'memfile.cpp',
'pawncc.cpp',
'sc1.c',
'sc2.c',
'sc3.c',
@ -92,11 +92,11 @@ binary.sources += [
'scexpand.c',
'sci18n.c',
'sclist.c',
'scmemfil.c',
'scmemfil.cpp',
'scstate.c',
'sctracker.c',
'scvars.c',
'sp_file.c',
'sp_file.cpp',
'zlib/adler32.c',
'zlib/compress.c',
'zlib/crc32.c',

View File

@ -69,10 +69,9 @@ int pc_printf(const char *message,...)
*/
int pc_error(int number,char *message,char *filename,int firstline,int lastline,va_list argptr)
{
static char *prefix[3]={ "error", "fatal error", "warning" };
static const char *prefix[3]={ "error", "fatal error", "warning" };
if (number!=0) {
char *pre;
int idx;
if (number < 160)
@ -82,7 +81,7 @@ static char *prefix[3]={ "error", "fatal error", "warning" };
else
idx = 2;
pre=prefix[idx];
const char *pre=prefix[idx];
if (firstline>=0)
fprintf(stdout,"%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
else

View File

@ -52,4 +52,15 @@ long memfile_tell(memfile_t *mf);
*/
void memfile_reset(memfile_t *mf);
typedef memfile_t MEMFILE;
MEMFILE *mfcreate(const char *filename);
void mfclose(MEMFILE *mf);
int mfdump(MEMFILE *mf);
long mflength(const MEMFILE *mf);
long mfseek(MEMFILE *mf,long offset,int whence);
unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size);
unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size);
char *mfgets(MEMFILE *mf,char *string,unsigned int size);
int mfputs(MEMFILE *mf,const char *string);
#endif //_INCLUDE_MEMFILE_H

View File

@ -36,8 +36,8 @@ enum FileSections
FS_Number,
};
int pc_printf(const char *message,...);
int pc_compile(int argc, char **argv);
extern "C" int pc_printf(const char *message,...);
extern "C" int pc_compile(int argc, char **argv);
void sfwrite(const void *buf, size_t size, size_t count, sp_file_t *spf);
memfile_t *bin_file = NULL;
@ -518,7 +518,7 @@ void sfwrite(const void *buf, size_t size, size_t count, sp_file_t *spf)
longjmp(brkout, 1);
}
void sp_fdbg_ntv_start(int num_natives)
extern "C" void sp_fdbg_ntv_start(int num_natives)
{
if (num_natives == 0)
return;
@ -529,7 +529,7 @@ void sp_fdbg_ntv_start(int num_natives)
#include "sc.h"
void sp_fdbg_ntv_hook(int index, symbol *sym)
extern "C" void sp_fdbg_ntv_hook(int index, symbol *sym)
{
int i, j;
t_native *native;

View File

@ -612,8 +612,8 @@ long pc_lengthbin(void *handle); /* return the length of the file */
#define SC_VDEFINE
#endif
void sp_fdbg_ntv_start(int num_natives);
void sp_fdbg_ntv_hook(int index, symbol *sym);
SC_FUNC void sp_fdbg_ntv_start(int num_natives);
SC_FUNC void sp_fdbg_ntv_hook(int index, symbol *sym);
/* function prototypes in SC1.C */
SC_FUNC void set_extension(char *filename,char *extension,int force);
@ -838,21 +838,6 @@ SC_FUNC char *get_dbgstring(int index);
SC_FUNC void delete_dbgstringtable(void);
SC_FUNC stringlist *get_dbgstrings();
/* function prototypes in SCMEMFILE.C */
#if !defined tMEMFILE
typedef unsigned char MEMFILE;
#define tMEMFILE 1
#endif
MEMFILE *mfcreate(const char *filename);
void mfclose(MEMFILE *mf);
int mfdump(MEMFILE *mf);
long mflength(const MEMFILE *mf);
long mfseek(MEMFILE *mf,long offset,int whence);
unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size);
unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size);
char *mfgets(MEMFILE *mf,char *string,unsigned int size);
int mfputs(MEMFILE *mf,const char *string);
/* function prototypes in SCI18N.C */
#define MAXCODEPAGE 12
SC_FUNC int cp_path(const char *root,const char *directory);

View File

@ -34,8 +34,6 @@
#if defined FORTIFY
#include <alloc/fortify.h>
#endif
typedef memfile_t MEMFILE;
#define tMEMFILE 1
#include "sc.h"

View File

@ -211,40 +211,3 @@ int mf_setpos(void *handle, size_t pos)
return 1;
}
#if UNUSED_FOR_NOW
/**
* Default file operations...
* Based on C standard library calls.
*/
void *fp_open(const char *name)
{
return fopen(name, "wb");
}
void fp_close(void *handle)
{
fclose((FILE *)handle);
}
size_t fp_write(const void *buf, size_t size, size_t count, void *handle)
{
return fwrite(buf, size, count, (FILE *)handle);
}
size_t fp_read(void *buf, size_t size, size_t count, void *handle)
{
return fread(buf, size, count, (FILE *)handle);
}
size_t fp_getpos(void *handle)
{
return (size_t)ftell((FILE *)handle);
}
int fp_setpos(void *handle, size_t pos)
{
return fseek((FILE *)handle, (long)pos, SEEK_SET);
}
#endif