Browse Source

Merge pull request #454 from dpogue/osx-fixes

OSX Clang fixes
Joseph Davies 10 years ago
parent
commit
cd80f9b3fd
  1. 3
      CMakeLists.txt
  2. 1
      Sources/Plasma/CoreLib/hsAlignedAllocator.hpp
  3. 20
      Sources/Plasma/CoreLib/plString.cpp
  4. 12
      Sources/Plasma/CoreLib/plString.h
  5. 2
      Sources/Plasma/FeatureLib/pfPython/pyGlueHelpers.cpp
  6. 2
      Sources/Plasma/NucleusLib/pnUUID/CMakeLists.txt
  7. 2
      Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp

3
CMakeLists.txt

@ -21,6 +21,9 @@ endif(WIN32 AND NOT CYGWIN)
if(UNIX)
add_definitions(-DHS_BUILD_FOR_UNIX)
endif(UNIX)
if(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(-DHS_BUILD_FOR_OSX)
endif(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# End HeadSpin Configuration
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

1
Sources/Plasma/CoreLib/hsAlignedAllocator.hpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include <stdexcept>
#include <new>
template<class T, size_t ALIGNMENT=16>

20
Sources/Plasma/CoreLib/plString.cpp

@ -168,7 +168,7 @@ void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
while (sp < utf16 + size) {
if (*sp >= 0xD800 && *sp <= 0xDFFF) {
// Surrogate pair
UniChar unichar = 0x10000;
plUniChar unichar = 0x10000;
if (sp + 1 >= utf16 + size) {
hsAssert(0, "Incomplete surrogate pair in UTF-16 data");
@ -209,11 +209,11 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
// We assume that if sizeof(wchar_t) == 2, the data is UTF-16 already
IConvertFromUtf16((const uint16_t *)wstr, size);
#else
IConvertFromUtf32((const UniChar *)wstr, size);
IConvertFromUtf32((const plUniChar *)wstr, size);
#endif
}
void plString::IConvertFromUtf32(const UniChar *ustr, size_t size)
void plString::IConvertFromUtf32(const plUniChar *ustr, size_t size)
{
hsAssert(size == STRLEN_AUTO || size < FREAKING_BIG, "Your string is WAAAAAY too big");
@ -226,7 +226,7 @@ void plString::IConvertFromUtf32(const UniChar *ustr, size_t size)
// Calculate the UTF-8 size
size_t convlen = 0;
const UniChar *sp = ustr;
const plUniChar *sp = ustr;
while (sp < ustr + size) {
if (*sp > 0x10FFFF) {
hsAssert(0, "UTF-32 character out of range");
@ -341,7 +341,7 @@ plStringBuffer<uint16_t> plString::ToUtf16() const
uint16_t *dp = ustr;
sp = utf8;
while (sp < utf8 + srcSize) {
UniChar unichar;
plUniChar unichar;
if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12;
@ -408,7 +408,7 @@ plStringBuffer<char> plString::ToIso8859_1() const
char *dp = astr;
sp = utf8;
while (sp < utf8 + srcSize) {
UniChar unichar;
plUniChar unichar;
if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12;
@ -455,11 +455,11 @@ plUnicodeBuffer plString::GetUnicodeArray() const
}
// And perform the actual conversion
UniChar *ustr = result.CreateWritableBuffer(convlen);
UniChar *dp = ustr;
plUniChar *ustr = result.CreateWritableBuffer(convlen);
plUniChar *dp = ustr;
sp = utf8;
while (sp < utf8 + srcSize) {
UniChar unichar;
plUniChar unichar;
if ((*sp & 0xF8) == 0xF0) {
unichar = (*sp++ & 0x07) << 18;
unichar |= (*sp++ & 0x3F) << 12;
@ -942,7 +942,7 @@ plStringStream &plStringStream::operator<<(double num)
return operator<<(buffer);
}
size_t ustrlen(const UniChar *ustr)
size_t ustrlen(const plUniChar *ustr)
{
size_t length = 0;
for ( ; *ustr++; ++length)

12
Sources/Plasma/CoreLib/plString.h

@ -47,7 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <vector>
/** Single Unicode character code unit */
typedef unsigned int UniChar;
typedef unsigned int plUniChar;
#define SSO_CHARS (16)
#define STRING_STACK_SIZE (256)
@ -227,7 +227,7 @@ public:
};
/** A plStringBuffer for storing fully-expanded Unicode data */
typedef plStringBuffer<UniChar> plUnicodeBuffer;
typedef plStringBuffer<plUniChar> plUnicodeBuffer;
/** Unicode-capable and (mostly) binary safe string class.
* plString stores SSO-optimized or reference counted strings (automatically
@ -251,7 +251,7 @@ private:
void IConvertFromUtf8(const char *utf8, size_t size);
void IConvertFromUtf16(const uint16_t *utf16, size_t size);
void IConvertFromWchar(const wchar_t *wstr, size_t size);
void IConvertFromUtf32(const UniChar *ustr, size_t size);
void IConvertFromUtf32(const plUniChar *ustr, size_t size);
void IConvertFromIso8859_1(const char *astr, size_t size);
public:
@ -357,7 +357,7 @@ public:
}
/** Create a new plString object from the UTF-32 formatted data in \a utf32. */
static inline plString FromUtf32(const UniChar *utf32, size_t size = STRLEN_AUTO)
static inline plString FromUtf32(const plUniChar *utf32, size_t size = STRLEN_AUTO)
{
plString str;
str.IConvertFromUtf32(utf32, size);
@ -799,7 +799,7 @@ private:
bool ICanHasHeap() const { return fBufSize > STRING_STACK_SIZE; }
};
/** \p strlen implementation for UniChar based C-style string buffers. */
size_t ustrlen(const UniChar *ustr);
/** \p strlen implementation for plUniChar based C-style string buffers. */
size_t ustrlen(const plUniChar *ustr);
#endif //plString_Defined

2
Sources/Plasma/FeatureLib/pfPython/pyGlueHelpers.cpp

@ -54,7 +54,7 @@ plString PyString_AsStringEx(PyObject* obj)
#if (Py_UNICODE_SIZE == 2)
return plString::FromUtf16(reinterpret_cast<const uint16_t *>(PyUnicode_AsUnicode(obj)));
#elif (Py_UNICODE_SIZE == 4)
return plString::FromUtf32(reinterpret_cast<const UniChar *>(PyUnicode_AsUnicode(obj)));
return plString::FromUtf32(reinterpret_cast<const plUniChar *>(PyUnicode_AsUnicode(obj)));
#else
# error "Py_UNICODE is an unexpected size"
#endif

2
Sources/Plasma/NucleusLib/pnUUID/CMakeLists.txt

@ -22,7 +22,7 @@ target_link_libraries(pnUUID CoreLib)
if(WIN32)
target_link_libraries(pnUUID pnUtils)
target_link_libraries(pnUUID rpcrt4)
else(WIN32)
elseif(NOT APPLE)
target_link_libraries(pnUUID uuid)
endif(WIN32)

2
Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp

@ -448,7 +448,7 @@ plUnifiedTime::operator timeval() const
// tv_secs should be a time_t, but on Windows it is a long
struct timeval t = {(long)fSecs, (long)fMicros};
#else
struct timeval t = {fSecs, fMicros};
struct timeval t = {fSecs, (suseconds_t)fMicros};
#endif
return t;
}

Loading…
Cancel
Save