From e6d606bfab51e120711ab759b0d44d818f960c40 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Fri, 22 Aug 2014 11:25:06 +0800 Subject: [PATCH] Fix for Xcode on Mac. --- interface/core/module/moduleitem.h | 4 ++-- interface/core/nonplugin/scanplugins.h | 2 +- interface/core/observer/fireevent.h | 9 ++++++--- interface/core/observer/fireobjevent.h | 15 +++++++++------ interface/core/portability/func_s.h | 11 ++--------- interface/core/portability/pathstr.h | 6 +++--- interface/core/portability/uniximpl.h | 6 +++--- interface/core/utilfunc/convstr.h | 2 +- interface/core/utilfunc/vecfunc.h | 8 ++++---- 9 files changed, 31 insertions(+), 32 deletions(-) mode change 100644 => 100755 interface/core/portability/func_s.h diff --git a/interface/core/module/moduleitem.h b/interface/core/module/moduleitem.h index 217f518..6b7bcbe 100644 --- a/interface/core/module/moduleitem.h +++ b/interface/core/module/moduleitem.h @@ -28,7 +28,7 @@ class ModuleItem { if (items()) { - for (int i = index(); i < maxCount(); i++) + for (long i = index(); i < maxCount(); i++) { if (i >= 0 && items()[i]) { @@ -55,7 +55,7 @@ class ModuleItem } private: - int _index; // index in the single instance stack. + long _index; // index in the single instance stack. static long& maxCount() { diff --git a/interface/core/nonplugin/scanplugins.h b/interface/core/nonplugin/scanplugins.h index df69e79..c360cd2 100644 --- a/interface/core/nonplugin/scanplugins.h +++ b/interface/core/nonplugin/scanplugins.h @@ -72,7 +72,7 @@ void unloadScanPlugins() #define CREATEOBJECTIMPL class IObject; -bool createObject(const char* clsid, long iid, IObject** p) +LOCALAPI bool createObject(const char* clsid, long iid, IObject** p) { typedef bool (*F)(const char*, long, IObject**); F f = (F)GetProcAddress(s_modules[0], "x3CreateObject"); diff --git a/interface/core/observer/fireevent.h b/interface/core/observer/fireevent.h index 2b9b5f5..7a1f001 100644 --- a/interface/core/observer/fireevent.h +++ b/interface/core/observer/fireevent.h @@ -69,9 +69,10 @@ template class FireEvent0 : public FireEventBase { public: + typedef FireEventBase Base; typedef FireEvent0 This; FireEvent0() {} - This& fireEvent() { _fireEvent(dispatcher); return *this; } + This& fireEvent() { Base::_fireEvent(dispatcher); return *this; } private: static bool dispatcher(PROC handler, void*) { @@ -99,11 +100,12 @@ template class FireEvent1 : public FireEventBase { public: + typedef FireEventBase Base; typedef FireEvent1 This; ParamT param; FireEvent1(ParamT p) : param(p) {} - This& fireEvent() { _fireEvent(dispatcher); return *this; } + This& fireEvent() { Base::_fireEvent(dispatcher); return *this; } private: FireEvent1(const This&); @@ -136,12 +138,13 @@ template { public: + typedef FireEventBase Base; typedef FireEvent2 This; Param1 param1; Param2 param2; FireEvent2(Param1 p1, Param2 p2) : param1(p1), param2(p2) {} - This& fireEvent() { _fireEvent(dispatcher); return *this; } + This& fireEvent() { Base::_fireEvent(dispatcher); return *this; } private: FireEvent2(const This&); diff --git a/interface/core/observer/fireobjevent.h b/interface/core/observer/fireobjevent.h index 1461464..de6a1c1 100644 --- a/interface/core/observer/fireobjevent.h +++ b/interface/core/observer/fireobjevent.h @@ -85,14 +85,15 @@ template class FireObjectEvent0 : public FireObjEventBase { public: + typedef FireObjEventBase Base; typedef FireObjectEvent0 This; FireObjectEvent0() {} - This& fireEvent() { _fireEvent(dispatcher); return *this; } + This& fireEvent() { Base::_fireEvent(dispatcher); return *this; } private: static bool dispatcher(ObserverObject* obj, ON_EVENT hd, void*) { typename EventType::Handler handler; - cast(handler, hd); + Base::cast(handler, hd); return Break::call(obj, handler); } }; @@ -117,11 +118,12 @@ template { public: + typedef FireObjEventBase Base; typedef FireObjectEvent1 This; ParamT param; FireObjectEvent1(ParamT p) : param(p) {} - This& fireEvent() { _fireEvent(dispatcher); return *this; } + This& fireEvent() { Base::_fireEvent(dispatcher); return *this; } private: FireObjectEvent1(const This&); @@ -130,7 +132,7 @@ class FireObjectEvent1 : public FireObjEventBase static bool dispatcher(ObserverObject* obj, ON_EVENT hd, void* data) { typename EventType::Handler handler; - cast(handler, hd); + Base::cast(handler, hd); return Break::call(obj, handler, &((This*)data)->param); } }; @@ -156,12 +158,13 @@ template { public: + typedef FireObjEventBase Base; typedef FireObjectEvent2 This; Param1 param1; Param2 param2; FireObjectEvent2(Param1 p1, Param2 p2) : param1(p1), param2(p2) {} - This& fireEvent() { _fireEvent(dispatcher); return *this; } + This& fireEvent() { Base::_fireEvent(dispatcher); return *this; } private: FireObjectEvent2(const This&); @@ -173,7 +176,7 @@ class FireObjectEvent2 : public FireObjEventBase This* p = (This*)data; typename EventType::Handler handler; - cast(handler, hd); + Base::cast(handler, hd); return Break::call(obj, handler, &p->param1, &p->param2); } }; diff --git a/interface/core/portability/func_s.h b/interface/core/portability/func_s.h old mode 100644 new mode 100755 index 47325f3..39d0b8a --- a/interface/core/portability/func_s.h +++ b/interface/core/portability/func_s.h @@ -11,13 +11,6 @@ #include #endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif - #if defined(_STDIO_DEFINED) // stdio.h inline int sprintf_s(char *buffer, size_t, const char *format, ...) @@ -56,9 +49,9 @@ inline int wcscpy_s(wchar_t *str, size_t size, const wchar_t *src) { return wcsncpy(str, src, size) ? 0 : -1; } inline int strncpy_s(char *str, size_t size, const char *src, size_t len) - { return strncpy(str, src, min(size, len)) ? 0 : -1; } + { return strncpy(str, src, size < len ? size : len) ? 0 : -1; } inline int wcsncpy_s(wchar_t *str, size_t size, const wchar_t *src, size_t len) - { return wcsncpy(str, src, min(size, len)) ? 0 : -1; } + { return wcsncpy(str, src, size < len ? size : len) ? 0 : -1; } inline int strcat_s(char *str, size_t, const char *src) { return strcat(str, src) ? 0 : -1; } diff --git a/interface/core/portability/pathstr.h b/interface/core/portability/pathstr.h index eca517a..f793102 100644 --- a/interface/core/portability/pathstr.h +++ b/interface/core/portability/pathstr.h @@ -71,7 +71,7 @@ void PathRemoveExtensionA(char* path) void PathRemoveBackslashA(char* path) { - int len = path ? strlen(path) : 0; + size_t len = path ? strlen(path) : 0; if (len > 0 && IsPathSlash(path[len - 1])) { @@ -90,7 +90,7 @@ void PathAppendA(char* path, const char* more) return; } - int len = strlen(path); + size_t len = strlen(path); if (len > 0 && !IsPathSlash(path[len - 1]) && *more) { @@ -101,7 +101,7 @@ void PathAppendA(char* path, const char* more) char* PathAddBackslashA(char* path) { - int len = path ? strlen(path) : 0; + size_t len = path ? strlen(path) : 0; if (len > 0 && !IsPathSlash(path[len - 1])) { diff --git a/interface/core/portability/uniximpl.h b/interface/core/portability/uniximpl.h index add5b63..cc1f3a6 100644 --- a/interface/core/portability/uniximpl.h +++ b/interface/core/portability/uniximpl.h @@ -147,7 +147,7 @@ void GetModuleFileNameA(HMODULE hmod, char* filename, int size) if (!hmod) { - int bytes = readlink("/proc/self/exe", filename, size); + size_t bytes = readlink("/proc/self/exe", filename, size); if (bytes > 0) filename[bytes < size - 1 ? bytes : size - 1] = '\0'; } @@ -169,14 +169,14 @@ int WideCharToMultiByte(int /*codepage*/, DWORD /*flags*/, char* astr, int achars, const char*, void*) { - return astr ? wcstombs(astr, wstr, achars) : (wchars * sizeof(char)); + return (int)(astr ? wcstombs(astr, wstr, achars) : (wchars * sizeof(char))); } int MultiByteToWideChar(int /*codepage*/, DWORD /*flags*/, const char* astr, int achars, wchar_t* wstr, int wchars) { - return wstr ? mbstowcs(wstr, astr, wchars) : achars; + return wstr ? (int)mbstowcs(wstr, astr, wchars) : achars; } int _stricmp(const char* s1, const char* s2) diff --git a/interface/core/utilfunc/convstr.h b/interface/core/utilfunc/convstr.h index 73691c2..94ef69b 100644 --- a/interface/core/utilfunc/convstr.h +++ b/interface/core/utilfunc/convstr.h @@ -27,7 +27,7 @@ inline std::string w2a(const wchar_t* s, int codepage = 0) if (wlen > 0) { - long len = WideCharToMultiByte(codepage, 0, s, wlen, NULL, 0, NULL, NULL); + int len = WideCharToMultiByte(codepage, 0, s, wlen, NULL, 0, NULL, NULL); str.resize(len); WideCharToMultiByte(codepage, 0, s, wlen, const_cast(str.data()), len, NULL, NULL); diff --git a/interface/core/utilfunc/vecfunc.h b/interface/core/utilfunc/vecfunc.h index 8f1c8ec..55f14fc 100644 --- a/interface/core/utilfunc/vecfunc.h +++ b/interface/core/utilfunc/vecfunc.h @@ -121,9 +121,9 @@ bool has_value(const _Ta& arr, const _Tp& p) \return element count. */ template inline -long GetSize(const _Ta& arr) +int GetSize(const _Ta& arr) { - return static_cast(arr.size()); + return static_cast(arr.size()); } //! Checks a position index is in range or out of range of a container. @@ -134,9 +134,9 @@ long GetSize(const _Ta& arr) \return true if the position index is in range of the container. */ template inline -bool IsValidIndexOf(const _Ta& arr, long index) +bool IsValidIndexOf(const _Ta& arr, int index) { - return index >= 0 && index < static_cast(arr.size()); + return index >= 0 && index < static_cast(arr.size()); } } // x3