1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Initial macOS changes

Many changes are related to fixing warnings
This commit is contained in:
Brian Fiete 2019-10-14 14:08:29 -07:00
parent 75f11b1459
commit 22ec4a86b8
52 changed files with 2873 additions and 266 deletions

BIN
BeefySysLib/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -34,13 +34,24 @@ add_definitions(
-DBP_DYNAMIC
)
include_directories(
.
platform/linux
third_party
third_party/freetype/include
../extern
)
if (${APPLE})
include_directories(
.
platform/osx
platform/darwin
third_party
third_party/freetype/include
../extern
)
else()
include_directories(
.
platform/linux
third_party
third_party/freetype/include
../extern
)
endif()
############## Artefacts Output #################
# Defines outputs , depending Debug or Release. #
@ -105,10 +116,7 @@ file(GLOB SRC_FILES
HeadlessApp.cpp
MemStream.cpp
ResLib.cpp
Startup.cpp
platform/linux/BFPlatform.cpp
platform/linux/LinuxCommon.cpp
Startup.cpp
fbx/FBXReader.cpp
gfx/DrawLayer.cpp
@ -284,9 +292,22 @@ file(GLOB SRC_FILES
util/Vector.cpp
)
if (${APPLE})
file(GLOB SRC_FILES_OS
platform/darwin/BFPlatform.cpp
platform/darwin/DarwinCommon.cpp
)
else()
file(GLOB SRC_FILES_OS
platform/linux/BFPlatform.cpp
platform/linux/LinuxCommon.cpp
)
endif()
# Add library to build.
add_library(${PROJECT_NAME} SHARED
${SRC_FILES}
${SRC_FILES_OS}
)
# Link with other dependencies.

View file

@ -238,6 +238,9 @@ String Beefy::SlashString(const StringImpl& str, bool utf8decode, bool utf8encod
case UTF8PROC_CATEGORY_CF:
case UTF8PROC_CATEGORY_CO:
wantHex = true;
break;
default:
break;
}
if (wantHex)

View file

@ -212,7 +212,7 @@ void DataStream::Write(DataStream& refStream)
refStream.SetPos(0);
refStream.Read(data, size);
Write(data, size);
delete data;
delete [] data;
}
void DataStream::WriteSNZ(const StringImpl& val)

View file

@ -13,17 +13,17 @@ public:
virtual void PhysSetCursor() override { }
virtual void GetDesktopResolution(int& width, int& height) { }
virtual void GetWorkspaceRect(int& x, int& y, int& width, int& height) {}
virtual void GetDesktopResolution(int& width, int& height) override { }
virtual void GetWorkspaceRect(int& x, int& y, int& width, int& height) override {}
virtual BFWindow* CreateNewWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags) { return NULL; }
virtual DrawLayer* CreateDrawLayer(BFWindow* window) { return NULL; }
virtual BFWindow* CreateNewWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags) override { return NULL; }
virtual DrawLayer* CreateDrawLayer(BFWindow* window) override { return NULL; }
virtual void* GetClipboardData(const StringImpl& format, int* size) { return NULL; }
virtual void ReleaseClipboardData(void* ptr) { }
virtual void SetClipboardData(const StringImpl& format, const void* ptr, int size, bool resetClipboard) { }
virtual void* GetClipboardData(const StringImpl& format, int* size) override { return NULL; }
virtual void ReleaseClipboardData(void* ptr) override { }
virtual void SetClipboardData(const StringImpl& format, const void* ptr, int size, bool resetClipboard) override { }
virtual BFSysBitmap* LoadSysBitmap(const wchar_t* fileName) { return NULL; }
virtual BFSysBitmap* LoadSysBitmap(const wchar_t* fileName) override { return NULL; }
};

View file

@ -488,7 +488,7 @@ void FFTShift1D(BFComplex* array, int size, int pitch, int dir)
for (int i = 0; i < size; i++)
array[i * pitch] = prev[((i + dir) % size)];
delete prev;
delete [] prev;
}
static void FFTShift2D(BFComplex* data, int cols, int rows)
@ -543,7 +543,7 @@ static void FFTConvert(ImageData* source)
source->mBits[i] = 0xFF000000 | val | (val << 8) | (val << 16);
}
delete fFTLog;
delete [] fFTLog;
delete [] nums;
}
@ -563,7 +563,7 @@ void DCT_1D(double* array, int size, int pitch)
array[idxOut*pitch] = 0.5 * scale * val;
}
delete prev;
delete [] prev;
}
void IDCT_1D(double* array, int size, int pitch)
@ -583,7 +583,7 @@ void IDCT_1D(double* array, int size, int pitch)
array[idxOut*pitch] = 0.5 * val;
}
delete prev;
delete [] prev;
}
const int DCT_1D_I_TABLE[64] =
@ -619,7 +619,7 @@ void DCT_1D_I(int* array, int size, int pitch)
}
delete prev;
delete [] prev;
}
const int IDCT_1D_I_TABLE[64] =

View file

@ -85,7 +85,7 @@ bool ImageData::LoadFromFile(const StringImpl& path)
int size = 0;
uint8* aData = LoadBinaryData(path, &size);
if (aData == NULL)
return NULL;
return false;
SetSrcData(aData, size);
bool result = ReadData();
if (mKeepSrcDataValid)

View file

@ -441,7 +441,7 @@ void SoftBlur(uint32* data, int w, int h, float radius, uint32 defaultValue)
BoxBlur(tempBuffer, data, h, w, d, defaultValue);
}
}
delete tempBuffer;
delete [] tempBuffer;
}
static int gAlphaCheckOfs [][2] =
@ -1705,7 +1705,7 @@ void ChokedPixelTransform(ImageData* src, ImageData* dest, float radius, float c
}
}
delete tempBuffer;
delete [] tempBuffer;
}
void ImageOuterGlowEffect::Apply(PSDLayerInfo* layerInfo, ImageData* imageData, ImageData* destImageData)
@ -2251,7 +2251,7 @@ void ImageBevelEffect::Apply(int pass, int style, PSDLayerInfo* layerInfo, Image
}
}
delete normalMap;
delete [] normalMap;
}
void ImageBevelEffect::Apply(ImageEffectCtx* ctx)

View file

@ -152,7 +152,7 @@ public:
public:
virtual void Init() override;
virtual void CreateContourAndGradientData();
virtual int GetNeededBorderSize();
virtual int GetNeededBorderSize() override;
};
class ImageOuterGlowEffect : public ImageGlowEffect
@ -266,9 +266,9 @@ public:
void Init() override;
void Apply(PSDLayerInfo* layerInfo, ImageData* imageData, ImageData* destImageData) override;
virtual void Apply(ImageEffectCtx* ctx) override;
virtual int GetMixType();
virtual int GetMixType() override;
void Apply(int pass, int style, PSDLayerInfo* layerInfo, ImageData* imageData, ImageData* hiliteImage, ImageData* shadowImage);
virtual int GetNeededBorderSize();
virtual int GetNeededBorderSize() override;
};
typedef std::vector<BaseImageEffect*> ImageEffectVector;
@ -286,10 +286,10 @@ public:
bool mInvert;
public:
virtual void Init();
virtual void Init() override;
virtual void Apply(PSDLayerInfo* layerInfo, ImageData* imageData, ImageData* destImageData) override;
virtual int GetMixType(); // Default:Interior
virtual int GetNeededBorderSize();
virtual int GetMixType() override; // Default:Interior
virtual int GetNeededBorderSize() override;
};
class ImageColorOverlayEffect : public BaseImageEffect
@ -334,8 +334,8 @@ public:
public:
virtual void Apply(PSDLayerInfo* layerInfo, ImageData* imageData, ImageData* destImageData) override;
virtual void Apply(ImageEffectCtx* ctx) override;
virtual int GetMixType(); // Default:Interior
virtual int GetNeededBorderSize();
virtual int GetMixType() override; // Default:Interior
virtual int GetNeededBorderSize() override;
virtual bool NeedsOrigBits(ImageEffects* effects) override;
};

View file

@ -1907,12 +1907,12 @@ bool PSDLayerInfo::ReadData()
}
}
delete rowData;
delete [] rowData;
}
}
}
delete rowLengths;
delete [] rowLengths;
if (((mLayerMask != NULL) || (mVectorMask != NULL)) && (!mLayerMaskHidesEffects))
ApplyMask(this);

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,220 @@
#define BOOST_DETAIL_NO_CONTAINER_FWD
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
//#include <libkern/OSAtomic.h>
#include <cstdlib>
#include <unistd.h>
#include <wchar.h>
#include <math.h>
#include <stdarg.h>
#include <string.h>
#include <pthread.h>
#include <wctype.h>
#include <stddef.h>
#include <mach/error.h>
//#define errno (*__error())
//#define offsetof(type, member) __builtin_offsetof (type, member)
extern "C"
{
//#define FFI_BUILDING
//#include "third_party/libffi/x86_64-apple-darwin12.5.0/include/ffi.h"
}
#define BF_ENDIAN_LITTLE
#define _NOEXCEPT noexcept
#define NTAPI
#define FFI_STDCALL FFI_DEFAULT_ABI
#define FFI_THISCALL FFI_DEFAULT_ABI
#define FFI_FASTCALL FFI_DEFAULT_ABI
#define INVALID_SOCKET -1
typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef unsigned int uint;
#define BF_PLATFORM_LINUX
#define BF_PLATFORM_NAME "BF_PLATFORM_LINUX"
//#define BF_PLATFORM_SDL
#define NOP
//#define BF_NOTHROW throw ()
//#define BF_NOTHROW noexcept
#define BF_NOTHROW
#ifdef BF64
typedef int64 intptr;
typedef uint64 uintptr;
#else
typedef int32 intptr;
typedef uint32 uintptr;
#endif
typedef wchar_t* BSTR;
typedef int HRESULT;
typedef uint8 BYTE;
typedef uint16 WORD;
typedef uint32 DWORD;
typedef int32 LONG;
typedef pthread_key_t BFTlsKey;
typedef pthread_t BF_THREADID;
typedef pthread_t BF_THREADHANDLE;
#define BF_TLS_DECLSPEC thread_local
//:int64 abs(int64 val);
#define _stricmp stricmp
#define strnicmp strncasecmp
struct IID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[ 8 ];
};
typedef void* HANDLE;
typedef void* HMODULE;
// We only need the stdcall attribute for x32?
//#define BFSTDCALL __attribute__((stdcall))
//#include "../notwin/NotWin.h"
#ifdef DEBUG
#define _DEBUG
#endif
#define NOT_IMPL throw "Unimplemented";
//ARM
#if defined(__x86_64__) || defined(__i386__)
#define BF_FULL_MEMORY_FENCE() __asm__ __volatile__("mfence": : :"memory")
#define BF_SPINWAIT_NOP() __asm__ volatile ("pause\n" : : : "memory" );
#else
#define BF_FULL_MEMORY_FENCE() __sync_synchronize()
#define BF_SPINWAIT_NOP() ((void) 0)
#endif
#define BF_COMPILER_FENCE() __asm__ __volatile__("": : :"memory")
#define BF_THREAD_YIELD() sched_yield()
#if defined _DEBUG || defined BF_DEBUG_ASSERTS
#define BF_ASSERT(_Expression) (void)( (!!(_Expression)) || (Beefy::BFFatalError(#_Expression, __FILE__, __LINE__), 0) )
#else
#define BF_ASSERT(_Expression) (void)(0)
#endif
#define BF_ASSERT_REL(_Expression) (void)( (!!(_Expression)) || (Beefy::BFFatalError(#_Expression, __FILE__, __LINE__), 0) )
#define BF_FATAL(msg) (void) ((Beefy::BFFatalError(msg, __FILE__, __LINE__), 0) )
#if defined _DEBUG || defined BF_DEBUG_ASSERTS
#define BF_DBG_FATAL(msg) (void) ((Beefy::BFFatalError(msg, __FILE__, __LINE__), 0) )
#else
#define BF_DBG_FATAL(msg)
#endif
#define BF_NOINLINE __attribute__ ((noinline))
#define BF_NAKED
#define stricmp strcasecmp
#define _alloca alloca
#define DIR_SEP_CHAR '/'
#define DIR_SEP_CHAR_ALT '\\'
static char* itoa(int value, char* str, int base)
{
if (base == 16)
sprintf(str, "%X", value);
else
sprintf(str, "%d", value);
return str;
}
inline uint32 InterlockedCompareExchange(volatile uint32* dest, uint32 exch, uint32 comp)
{
return __sync_val_compare_and_swap(dest, comp, exch);
}
inline uint64 InterlockedCompareExchange64(volatile int64* dest, int64 exch, int64 comp)
{
return __sync_val_compare_and_swap(dest, comp, exch);
}
inline void* InterlockedCompareExchangePointer(void* volatile* dest, void* exch, void* comp)
{
return __sync_val_compare_and_swap(dest, comp, exch);
}
inline uint32 InterlockedExchange(volatile uint32* dest, uint32 val)
{
return __sync_lock_test_and_set(dest, val);
}
inline uint64 InterlockedExchange64(volatile int64* dest, int64 val)
{
return __sync_lock_test_and_set(dest, val);
}
inline uint32 InterlockedExchangeAdd(volatile uint32* dest, uint32 val)
{
return __sync_add_and_fetch(dest, val);
}
inline int32 InterlockedIncrement(volatile uint32* val)
{
return __sync_add_and_fetch(val, 1);
}
inline int64 InterlockedIncrement64(volatile int64* val)
{
return __sync_add_and_fetch(val, 1);
}
inline int32 InterlockedDecrement(volatile uint32* val)
{
return __sync_add_and_fetch(val, -1);
}
inline int64 InterlockedDecrement64(volatile int64* val)
{
return __sync_add_and_fetch(val, -1);
}
#if 0
#pragma once
#ifdef __LP64__
#define BF64
#else
#define BF32
#endif
#define BOOST_DETAIL_NO_CONTAINER_FWD
#include <stdint.h>
#include <stdlib.h>
#include <pthread.h>
@ -64,7 +278,7 @@ typedef int32 LONG;
typedef pthread_key_t BFTlsKey;
typedef pthread_t BF_THREADID;
int64 abs(int64 val);
int64 abs(int64 val) noexcept;
struct IID
{
@ -320,3 +534,5 @@ inline int64 InterlockedDecrement64(volatile int64* val)
{
return OSAtomicDecrement64Barrier(val);
}
#endif

View file

@ -1,9 +1,11 @@
#pragma once
#include "../sdl/SdlBFApp.h"
//include "../sdl/SdlBFApp.h"
#include "../../HeadlessApp.h"
NS_BF_BEGIN;
typedef SdlBFApp PlatformBFApp;
//typedef SdlBFApp PlatformBFApp;
typedef HeadlessApp PlatformBFApp;
NS_BF_END;

View file

@ -1233,7 +1233,7 @@ BFP_EXPORT void BFP_CALLTYPE BfpThread_Sleep(int sleepMS)
BFP_EXPORT bool BFP_CALLTYPE BfpThread_Yield()
{
sched_yield();
return sched_yield() == 0;
}
struct BfpCritSect
@ -1814,24 +1814,24 @@ BFP_EXPORT void BFP_CALLTYPE BfpFile_Flush(BfpFile* file)
::fsync(file->mHandle);
}
BFP_EXPORT intptr BFP_CALLTYPE BfpFile_GetFileSize(BfpFile* file)
BFP_EXPORT int64 BFP_CALLTYPE BfpFile_GetFileSize(BfpFile* file)
{
int64 oldPos = (int64)lseek64(file->mHandle, 0, SEEK_CUR);
int64 size = (int64)lseek64(file->mHandle, 0, SEEK_END);
lseek64(file->mHandle, oldPos, SEEK_SET);
return (intptr)size;
return (int64)size;
}
BFP_EXPORT intptr BFP_CALLTYPE BfpFile_Seek(BfpFile* file, intptr offset, BfpFileSeekKind seekKind)
BFP_EXPORT int64 BFP_CALLTYPE BfpFile_Seek(BfpFile* file, int64 offset, BfpFileSeekKind seekKind)
{
int whence;
if (seekKind = BfpFileSeekKind_Absolute)
if (seekKind == BfpFileSeekKind_Absolute)
whence = SEEK_SET;
else if (seekKind = BfpFileSeekKind_Relative)
else if (seekKind == BfpFileSeekKind_Relative)
whence = SEEK_CUR;
else
whence = SEEK_END;
lseek64(file->mHandle, offset, whence);
return seek64(file->mHandle, offset, whence);
}
BFP_EXPORT void BFP_CALLTYPE BfpFile_Truncate(BfpFile* file)

View file

@ -1,13 +1,16 @@
#pragma once
#define BFSTDCALL __stdcall
#define BFSTDCALL
#include "../darwin/DarwinCommon.h"
#include <string>
#define BF_PLATFORM_OSX
#define BF_IMPORT extern "C"
#ifdef BFSYSLIB_DYNAMIC
#define BF_EXPORT extern "C" __declspec(dllexport)
#define BF_EXPORT extern "C"
#define BF_CALLTYPE
#else
#define BF_EXPORT extern "C"
@ -21,3 +24,6 @@
#define BF_REGISTER_COUNT 15
#endif
#define BF_DEBUG_BREAK()
#include "../PlatformInterface.h"

View file

@ -711,3 +711,18 @@ DrawLayer* SdlBFApp::CreateDrawLayer(BFWindow* window)
}
return drawLayer;
}
void SdlBFApp::GetDesktopResolution(int& width, int& height) override
{
width = 1024;
height = 768;
}
void SdlBFApp::GetWorkspaceRect(int& x, int& y, int& width, int& height) override
{
x = 0;
y = 0;
width = 1024;
height = 768;
}

View file

@ -2,6 +2,7 @@
#include "BFApp.h"
#include "BFWindow.h"
#include <map>
struct SDL_Window;
@ -56,13 +57,15 @@ public:
virtual void Run() override;
virtual BFWindow* CreateNewWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags) override;
virtual DrawLayer* CreateDrawLayer(BFWindow* window);
virtual DrawLayer* CreateDrawLayer(BFWindow* window) override;
virtual void* GetClipboardData(const StringImpl& format, int* size) override;
virtual void ReleaseClipboardData(void* ptr) override;
virtual void SetClipboardData(const StringImpl& format, const void* ptr, int size, bool resetClipboard) override;
virtual BFSysBitmap* LoadSysBitmap(const wchar_t* fileName) override;
virtual void GetDesktopResolution(int& width, int& height) override;
virtual void GetWorkspaceRect(int& x, int& y, int& width, int& height) override;
};
NS_BF_END;

View file

@ -137,6 +137,21 @@ public:
{
return mPtr < val2.mPtr;
}
bool operator>(const iterator& val2) const
{
return mPtr > val2.mPtr;
}
bool operator<=(const iterator& val2) const
{
return mPtr <= val2.mPtr;
}
bool operator>=(const iterator& val2) const
{
return mPtr >= val2.mPtr;
}
};
struct const_iterator
@ -1041,7 +1056,7 @@ class Array : public ArrayImpl<T, TAlloc, std::is_pod<T>::value>
public:
typedef ArrayImpl<T, TAlloc, std::is_pod<T>::value> _ArrayImpl;
using _ArrayImpl::ArrayImpl;
using ArrayImpl<T, TAlloc, std::is_pod<T>::value>::ArrayImpl;
using _ArrayImpl::operator=;
using _ArrayImpl::operator==;
using _ArrayImpl::operator!=;

View file

@ -17,6 +17,14 @@ typedef fd_set FD_SET;
#define closesocket close
#endif
#ifdef BF_PLATFORM_OSX
#include <sys/socket.h>
#include <mach/error.h>
#include <mach/mach.h>
#include <cerrno>
//#define errno (*__error())
#endif
//#include <rpcdce.h>
#pragma comment(lib,"wsock32.lib")

View file

@ -1049,7 +1049,7 @@ class Deque : public DequeImpl<T, TAlloc, std::is_pod<T>::value>
public:
typedef DequeImpl<T, TAlloc, std::is_pod<T>::value> _DequeImpl;
using _DequeImpl::DequeImpl;
using DequeImpl<T, TAlloc, std::is_pod<T>::value>::DequeImpl;
using _DequeImpl::operator=;
using _DequeImpl::operator==;
using _DequeImpl::operator!=;

View file

@ -44,7 +44,7 @@ void PolySpline2D::Calculate()
for (int i=0; i<n; i++)
mCoefs[i] = mat[i];
delete mat;
delete [] mat;
}
float PolySpline2D::Evaluate(float x)

View file

@ -834,7 +834,7 @@ public:
typename _Base::TStorage mInternalBuffer[TInternalSize - 1];
public:
using _Base::SizedArrayImpl;
using SizedArrayImpl<T, TAlloc>::SizedArrayImpl;
using _Base::operator=;
using _Base::operator==;
using _Base::operator!=;

View file

@ -723,7 +723,7 @@ bool StringImpl::HasMultibyteChars()
{
auto ptr = GetPtr();
for (int i = 0; i < (int)mLength; i++)
if (ptr[i] >= 0x80)
if ((uint8)ptr[i] >= (uint8)0x80)
return true;
return false;
}