From 7bc6abfac7147659adc0d122d1b7efbd692fca60 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 24 Jul 2013 10:14:42 +0800 Subject: [PATCH] Compilation error fixes, since CCLog has been renamed to 'log', all platforms should implement it. --- cocos2dx/platform/android/CCCommon.cpp | 13 +++++++++++++ cocos2dx/platform/emscripten/CCCommon.cpp | 13 +++++++++++++ cocos2dx/platform/ios/CCCommon.mm | 13 +++++++++++++ cocos2dx/platform/linux/CCCommon.cpp | 21 +++++++++++++++++++++ cocos2dx/platform/nacl/CCCommon.cpp | 21 +++++++++++++++++++++ cocos2dx/platform/tizen/CCCommon.cpp | 21 +++++++++++++++++++++ cocos2dx/platform/win32/CCCommon.cpp | 19 +++++++++++++++++++ 7 files changed, 121 insertions(+) diff --git a/cocos2dx/platform/android/CCCommon.cpp b/cocos2dx/platform/android/CCCommon.cpp index 16b48899be..e00c05dbec 100644 --- a/cocos2dx/platform/android/CCCommon.cpp +++ b/cocos2dx/platform/android/CCCommon.cpp @@ -32,6 +32,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char buf[MAX_LEN]; @@ -44,6 +45,18 @@ void CCLog(const char * pszFormat, ...) __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf); } +void log(const char * pszFormat, ...) +{ + char buf[MAX_LEN]; + + va_list args; + va_start(args, pszFormat); + vsnprintf(buf, MAX_LEN, pszFormat, args); + va_end(args); + + __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { showDialogJNI(pszMsg, pszTitle); diff --git a/cocos2dx/platform/emscripten/CCCommon.cpp b/cocos2dx/platform/emscripten/CCCommon.cpp index cf0618745b..daca5f79f2 100644 --- a/cocos2dx/platform/emscripten/CCCommon.cpp +++ b/cocos2dx/platform/emscripten/CCCommon.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char buf[MAX_LEN]; @@ -40,6 +41,18 @@ void CCLog(const char * pszFormat, ...) fprintf(stderr, "cocos2d-x debug info %s\n", buf); } +void log(const char * pszFormat, ...) +{ + char buf[MAX_LEN]; + + va_list args; + va_start(args, pszFormat); + vsnprintf(buf, MAX_LEN, pszFormat, args); + va_end(args); + + fprintf(stderr, "cocos2d-x debug info %s\n", buf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { // MessageBoxA(NULL, pszMsg, pszTitle, MB_OK); diff --git a/cocos2dx/platform/ios/CCCommon.mm b/cocos2dx/platform/ios/CCCommon.mm index 10ccdf74ad..c0e6ac3863 100644 --- a/cocos2dx/platform/ios/CCCommon.mm +++ b/cocos2dx/platform/ios/CCCommon.mm @@ -31,6 +31,19 @@ NS_CC_BEGIN +// XXX deprecated +void CCLog(const char * pszFormat, ...) +{ + printf("Cocos2d: "); + char szBuf[kMaxLogLen+1] = {0}; + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, kMaxLogLen, pszFormat, ap); + va_end(ap); + printf("%s", szBuf); + printf("\n"); +} + void log(const char * pszFormat, ...) { printf("Cocos2d: "); diff --git a/cocos2dx/platform/linux/CCCommon.cpp b/cocos2dx/platform/linux/CCCommon.cpp index d46c8cd794..19f672591c 100644 --- a/cocos2dx/platform/linux/CCCommon.cpp +++ b/cocos2dx/platform/linux/CCCommon.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -48,6 +49,26 @@ void CCLog(const char * pszFormat, ...) fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + + // Strip any trailing newlines from log message. + size_t len = strlen(szBuf); + while (len && szBuf[len-1] == '\n') + { + szBuf[len-1] = '\0'; + len--; + } + + fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { CCLog("%s: %s", pszTitle, pszMsg); diff --git a/cocos2dx/platform/nacl/CCCommon.cpp b/cocos2dx/platform/nacl/CCCommon.cpp index 01601ab744..a21d302b56 100644 --- a/cocos2dx/platform/nacl/CCCommon.cpp +++ b/cocos2dx/platform/nacl/CCCommon.cpp @@ -29,6 +29,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -49,6 +50,26 @@ void CCLog(const char * pszFormat, ...) fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf( szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + + // Strip any trailing newlines from log message. + size_t len = strlen(szBuf); + while (len && szBuf[len-1] == '\n') + { + szBuf[len-1] = '\0'; + len--; + } + + fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { CCLog("%s: %s", pszTitle, pszMsg); diff --git a/cocos2dx/platform/tizen/CCCommon.cpp b/cocos2dx/platform/tizen/CCCommon.cpp index 22c8364a9c..fc182d9123 100644 --- a/cocos2dx/platform/tizen/CCCommon.cpp +++ b/cocos2dx/platform/tizen/CCCommon.cpp @@ -31,6 +31,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -51,6 +52,26 @@ void CCLog(const char * pszFormat, ...) AppLog("cocos2d-x debug info [%s]\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + + // Strip any trailing newlines from log message. + size_t len = strlen(szBuf); + while (len && szBuf[len-1] == '\n') + { + szBuf[len-1] = '\0'; + len--; + } + + AppLog("cocos2d-x debug info [%s]\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { CCLog("%s: %s", pszTitle, pszMsg); diff --git a/cocos2dx/platform/win32/CCCommon.cpp b/cocos2dx/platform/win32/CCCommon.cpp index 178f6f1983..2a66aaf49e 100644 --- a/cocos2dx/platform/win32/CCCommon.cpp +++ b/cocos2dx/platform/win32/CCCommon.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -46,6 +47,24 @@ void CCLog(const char * pszFormat, ...) printf("%s\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap); + va_end(ap); + + WCHAR wszBuf[MAX_LEN] = {0}; + MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf)); + OutputDebugStringW(wszBuf); + OutputDebugStringA("\n"); + + WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE); + printf("%s\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);