Skip to content

Commit

Permalink
Fix for Xcode on Mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcad committed Aug 22, 2014
1 parent b4bf295 commit e6d606b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions interface/core/module/moduleitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand All @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion interface/core/nonplugin/scanplugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
9 changes: 6 additions & 3 deletions interface/core/observer/fireevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ template <class EventType, class Break = FireEvent0NotBreak >
class FireEvent0 : public FireEventBase<EventType>
{
public:
typedef FireEventBase<EventType> Base;
typedef FireEvent0<EventType, Break> This;
FireEvent0() {}
This& fireEvent() { _fireEvent(dispatcher); return *this; }
This& fireEvent() { Base::_fireEvent(dispatcher); return *this; }

private:
static bool dispatcher(PROC handler, void*) {
Expand Down Expand Up @@ -99,11 +100,12 @@ template <class EventType, typename ParamT, class Break = FireEvent1NotBreak >
class FireEvent1 : public FireEventBase<EventType>
{
public:
typedef FireEventBase<EventType> Base;
typedef FireEvent1<EventType, ParamT, Break> 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&);
Expand Down Expand Up @@ -136,12 +138,13 @@ template <class EventType, typename Param1,
class FireEvent2 : public FireEventBase<EventType>
{
public:
typedef FireEventBase<EventType> Base;
typedef FireEvent2<EventType, Param1, Param2, Break> 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&);
Expand Down
15 changes: 9 additions & 6 deletions interface/core/observer/fireobjevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ template <class EventType, class Break = FireObjectEvent0NotBreak >
class FireObjectEvent0 : public FireObjEventBase<EventType>
{
public:
typedef FireObjEventBase<EventType> Base;
typedef FireObjectEvent0<EventType, Break> 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);
}
};
Expand All @@ -117,11 +118,12 @@ template <class EventType, typename ParamT, class Break = FireObjectEvent1NotBre
class FireObjectEvent1 : public FireObjEventBase<EventType>
{
public:
typedef FireObjEventBase<EventType> Base;
typedef FireObjectEvent1<EventType, ParamT, Break> 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&);
Expand All @@ -130,7 +132,7 @@ class FireObjectEvent1 : public FireObjEventBase<EventType>

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);
}
};
Expand All @@ -156,12 +158,13 @@ template <class EventType, typename Param1, typename Param2 = Param1,
class FireObjectEvent2 : public FireObjEventBase<EventType>
{
public:
typedef FireObjEventBase<EventType> Base;
typedef FireObjectEvent2<EventType, Param1, Param2, Break> 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&);
Expand All @@ -173,7 +176,7 @@ class FireObjectEvent2 : public FireObjEventBase<EventType>
This* p = (This*)data;
typename EventType::Handler handler;

cast(handler, hd);
Base::cast(handler, hd);
return Break::call(obj, handler, &p->param1, &p->param2);
}
};
Expand Down
11 changes: 2 additions & 9 deletions interface/core/portability/func_s.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
#include <wctype.h>
#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, ...)
Expand Down Expand Up @@ -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; }
Expand Down
6 changes: 3 additions & 3 deletions interface/core/portability/pathstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
{
Expand All @@ -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)
{
Expand All @@ -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]))
{
Expand Down
6 changes: 3 additions & 3 deletions interface/core/portability/uniximpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion interface/core/utilfunc/convstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(str.data()), len, NULL, NULL);
Expand Down
8 changes: 4 additions & 4 deletions interface/core/utilfunc/vecfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ bool has_value(const _Ta& arr, const _Tp& p)
\return element count.
*/
template<class _Ta> inline
long GetSize(const _Ta& arr)
int GetSize(const _Ta& arr)
{
return static_cast<long>(arr.size());
return static_cast<int>(arr.size());
}

//! Checks a position index is in range or out of range of a container.
Expand All @@ -134,9 +134,9 @@ long GetSize(const _Ta& arr)
\return true if the position index is in range of the container.
*/
template<class _Ta> inline
bool IsValidIndexOf(const _Ta& arr, long index)
bool IsValidIndexOf(const _Ta& arr, int index)
{
return index >= 0 && index < static_cast<long>(arr.size());
return index >= 0 && index < static_cast<int>(arr.size());
}

} // x3
Expand Down

0 comments on commit e6d606b

Please sign in to comment.