diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index 5ce55047..19033255 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -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', diff --git a/sourcepawn/compiler/libpawnc.c b/sourcepawn/compiler/libpawnc.cpp similarity index 95% rename from sourcepawn/compiler/libpawnc.c rename to sourcepawn/compiler/libpawnc.cpp index f0953d9e..594b3e3f 100644 --- a/sourcepawn/compiler/libpawnc.c +++ b/sourcepawn/compiler/libpawnc.cpp @@ -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 diff --git a/sourcepawn/compiler/memfile.c b/sourcepawn/compiler/memfile.cpp similarity index 100% rename from sourcepawn/compiler/memfile.c rename to sourcepawn/compiler/memfile.cpp diff --git a/sourcepawn/compiler/memfile.h b/sourcepawn/compiler/memfile.h index 8fbf38a7..225e4d87 100644 --- a/sourcepawn/compiler/memfile.h +++ b/sourcepawn/compiler/memfile.h @@ -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 diff --git a/sourcepawn/compiler/pawncc.c b/sourcepawn/compiler/pawncc.cpp similarity index 95% rename from sourcepawn/compiler/pawncc.c rename to sourcepawn/compiler/pawncc.cpp index 6750b45c..e81cfbb2 100644 --- a/sourcepawn/compiler/pawncc.c +++ b/sourcepawn/compiler/pawncc.cpp @@ -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; diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 4b309769..8217ca5d 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -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); diff --git a/sourcepawn/compiler/scmemfil.c b/sourcepawn/compiler/scmemfil.cpp similarity index 94% rename from sourcepawn/compiler/scmemfil.c rename to sourcepawn/compiler/scmemfil.cpp index a8dd0aae..59eb3875 100644 --- a/sourcepawn/compiler/scmemfil.c +++ b/sourcepawn/compiler/scmemfil.cpp @@ -34,8 +34,6 @@ #if defined FORTIFY #include #endif -typedef memfile_t MEMFILE; -#define tMEMFILE 1 #include "sc.h" diff --git a/sourcepawn/compiler/sp_file.c b/sourcepawn/compiler/sp_file.cpp similarity index 85% rename from sourcepawn/compiler/sp_file.c rename to sourcepawn/compiler/sp_file.cpp index 6a6b2c1d..b849c311 100644 --- a/sourcepawn/compiler/sp_file.c +++ b/sourcepawn/compiler/sp_file.cpp @@ -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