* got rid of CDECL

* got rid of scumm_strrev
* added DISABLE_TEXT_CONSOLE flag which disables printf, warning, debug (but not error)

svn-id: r35038
This commit is contained in:
Max Horn 2008-11-13 11:26:47 +00:00
parent c0786313fa
commit a6502da9ac
5 changed files with 56 additions and 59 deletions

View File

@ -208,7 +208,6 @@
#define PLUGIN_EXPORT __declspec(dllexport)
#if _WIN32_WCE < 300
#define CDECL __cdecl
#define SMALL_SCREEN_DEVICE
#endif
@ -404,10 +403,6 @@
#define FORCEINLINE inline
#endif
#ifndef CDECL
#define CDECL
#endif
#ifndef PLUGIN_EXPORT
#define PLUGIN_EXPORT
#endif

View File

@ -458,7 +458,7 @@ uint32 getEnabledSpecialDebugLevels() {
*/
int gDebugLevel = -1;
#ifndef DISABLE_TEXT_CONSOLE
static void debugHelper(const char *in_buf, bool caret = true) {
char buf[STRINGBUFLEN];
@ -490,7 +490,7 @@ static void debugHelper(const char *in_buf, bool caret = true) {
fflush(stdout);
}
void CDECL debug(int level, const char *s, ...) {
void debug(int level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
@ -504,7 +504,7 @@ void CDECL debug(int level, const char *s, ...) {
debugHelper(buf);
}
void CDECL debugN(int level, const char *s, ...) {
void debugN(int level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
@ -518,7 +518,7 @@ void CDECL debugN(int level, const char *s, ...) {
debugHelper(buf, false);
}
void CDECL debug(const char *s, ...) {
void debug(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
@ -529,7 +529,7 @@ void CDECL debug(const char *s, ...) {
debugHelper(buf);
}
void CDECL debugC(int level, uint32 engine_level, const char *s, ...) {
void debugC(int level, uint32 engine_level, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
@ -544,7 +544,33 @@ void CDECL debugC(int level, uint32 engine_level, const char *s, ...) {
debugHelper(buf);
}
void NORETURN CDECL error(const char *s, ...) {
void warning(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
#if !defined (__SYMBIAN32__)
fprintf(stderr, "WARNING: %s!\n", buf);
#endif
#if defined( USE_WINDBG )
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#endif
}
#endif
void NORETURN error(const char *s, ...) {
char buf_input[STRINGBUFLEN];
char buf_output[STRINGBUFLEN];
va_list va;
@ -612,43 +638,6 @@ void NORETURN CDECL error(const char *s, ...) {
exit(1);
}
void CDECL warning(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
va_start(va, s);
vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
#if !defined (__SYMBIAN32__)
fprintf(stderr, "WARNING: %s!\n", buf);
#endif
#if defined( USE_WINDBG )
strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
OutputDebugString(buf_unicode);
#else
OutputDebugString(buf);
#endif
#endif
}
char *scumm_strrev(char *str) {
if (!str)
return str;
int len = strlen(str);
if (len < 2)
return str;
char *p1, *p2;
for (p1 = str, p2 = str + len - 1; p1 < p2; p1++, p2--) {
SWAP(*p1, *p2);
}
return str;
}
Common::String tag2string(uint32 tag) {
char str[5];
str[0] = (char)(tag >> 24);

View File

@ -306,22 +306,35 @@ uint32 getEnabledSpecialDebugLevels();
#if defined(__GNUC__)
void CDECL error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN;
void error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN;
#else
void CDECL NORETURN error(const char *s, ...);
void NORETURN error(const char *s, ...);
#endif
void CDECL warning(const char *s, ...) GCC_PRINTF(1, 2);
#ifdef DISABLE_TEXT_CONSOLE
void CDECL debug(int level, const char *s, ...) GCC_PRINTF(2, 3);
void CDECL debug(const char *s, ...) GCC_PRINTF(1, 2);
void CDECL debugN(int level, const char *s, ...) GCC_PRINTF(2, 3);
void CDECL debugC(int level, uint32 engine_level, const char *s, ...) GCC_PRINTF(3, 4);
inline void printf(const char *s, ...) {}
inline void warning(const char *s, ...) {}
inline void debug(int level, const char *s, ...) {}
inline void debug(const char *s, ...) {}
inline void debugN(int level, const char *s, ...) {}
inline void debugC(int level, uint32 engine_level, const char *s, ...) {}
#else
void warning(const char *s, ...) GCC_PRINTF(1, 2);
void debug(int level, const char *s, ...) GCC_PRINTF(2, 3);
void debug(const char *s, ...) GCC_PRINTF(1, 2);
void debugN(int level, const char *s, ...) GCC_PRINTF(2, 3);
void debugC(int level, uint32 engine_level, const char *s, ...) GCC_PRINTF(3, 4);
#endif
extern int gDebugLevel;
char *scumm_strrev(char *str);
Common::String tag2string(uint32 tag);
#define tag2str(x) tag2string(x).c_str()

View File

@ -41,7 +41,7 @@
namespace Scumm {
void CDECL debugC(int channel, const char *s, ...) {
void debugC(int channel, const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;

View File

@ -130,7 +130,7 @@ enum GameFeatures {
};
/* SCUMM Debug Channels */
void CDECL debugC(int level, const char *s, ...);
void debugC(int level, const char *s, ...);
enum {
DEBUG_GENERAL = 1 << 0, // General debug