From 9706c36d1d71aed365e594b3e9159d5392b485d7 Mon Sep 17 00:00:00 2001 From: Maxim Kolganov Date: Mon, 18 Apr 2016 22:09:06 +0300 Subject: [PATCH] Linux port WIP #655 --- projects/genie.lua | 3 +++ src/engine/core/blob.h | 2 +- src/engine/core/iallocator.h | 1 + src/engine/core/string.h | 10 ++++----- src/engine/debug/debug.h | 2 +- src/engine/lumix.h | 38 +++++++++++++++++++++++--------- src/engine/property_descriptor.h | 23 ++++++++++++++----- 7 files changed, 55 insertions(+), 24 deletions(-) diff --git a/projects/genie.lua b/projects/genie.lua index c70bffb633..cd20f79af1 100644 --- a/projects/genie.lua +++ b/projects/genie.lua @@ -87,16 +87,19 @@ function defaultConfigurations() configuration "Debug" targetdir(BINARY_DIR .. "Debug") defines { "DEBUG" } + buildoptions { "-std=c++11" } flags { "Symbols", "WinMain" } configuration "Release" targetdir(BINARY_DIR .. "Release") defines { "NDEBUG" } + buildoptions { "-std=c++11" } flags { "Optimize", "WinMain" } configuration "RelWithDebInfo" targetdir(BINARY_DIR .. "RelWithDebInfo") defines { "NDEBUG" } + buildoptions { "-std=c++11" } flags { "Symbols", "Optimize", "WinMain" } configuration {} diff --git a/src/engine/core/blob.h b/src/engine/core/blob.h index ac8488fc4f..46547b7c05 100644 --- a/src/engine/core/blob.h +++ b/src/engine/core/blob.h @@ -24,7 +24,7 @@ namespace Lumix void write(const void* data, int size); void writeString(const char* string); template void write(const T& value) { write(&value, sizeof(T)); } - template <> void write(const bool& value) { uint8 v = value; write(&v, sizeof(v)); } + void write(const bool& value) { uint8 v = value; write(&v, sizeof(v)); } void clear(); OutputBlob& operator << (const char* str); diff --git a/src/engine/core/iallocator.h b/src/engine/core/iallocator.h index 974bf3448a..677489030e 100644 --- a/src/engine/core/iallocator.h +++ b/src/engine/core/iallocator.h @@ -1,5 +1,6 @@ #pragma once +#include #include "lumix.h" diff --git a/src/engine/core/string.h b/src/engine/core/string.h index 9193ac7fe7..fc7ae96ed0 100644 --- a/src/engine/core/string.h +++ b/src/engine/core/string.h @@ -84,7 +84,7 @@ template struct StaticString return *this; } - template void add(StaticString& value) { Lumix::catString(data, size, value.data); } + template void add(StaticString& value) { Lumix::catString(data, size, value.data); } void add(const char* value) { Lumix::catString(data, size, value); } void add(char* value) { Lumix::catString(data, size, value); } @@ -275,7 +275,7 @@ template class base_string return *this; } - template base_string& cat(V value) + template base_string& cat(V value) { char tmp[30]; toCString(value, tmp, 30); @@ -283,7 +283,7 @@ template class base_string return *this; } - template <> base_string& cat(float value) + base_string& cat(float value) { char tmp[40]; toCString(value, tmp, 30, 10); @@ -291,13 +291,13 @@ template class base_string return *this; } - template <> base_string& cat(char* value) + base_string& cat(char* value) { *this += value; return *this; } - template <> base_string& cat(const char* value) + base_string& cat(const char* value) { *this += value; return *this; diff --git a/src/engine/debug/debug.h b/src/engine/debug/debug.h index 4c58717a93..57e7717670 100644 --- a/src/engine/debug/debug.h +++ b/src/engine/debug/debug.h @@ -3,7 +3,7 @@ #include "lumix.h" #include "core/iallocator.h" -#include "core/mt/sync.h" +#include "core/MT/sync.h" namespace Lumix diff --git a/src/engine/lumix.h b/src/engine/lumix.h index 16a6860751..c3579c2106 100644 --- a/src/engine/lumix.h +++ b/src/engine/lumix.h @@ -1,5 +1,6 @@ #pragma once +#include #ifdef _WIN32 #ifdef _WIN64 @@ -7,7 +8,13 @@ #else #define PLATFORM32 #endif -#else +#elif defined(__linux__) + #ifdef __x86_64__ + #define PLATFORM64 + #else + #define PLATFORM32 + #endif +#else #error Platform not supported #endif @@ -29,7 +36,7 @@ typedef unsigned int uint32; typedef long long int64; typedef unsigned long long uint64; -#ifdef _WIN64 +#ifdef PLATFORM64 typedef uint64 uintptr; #else typedef uint32 uintptr; @@ -59,20 +66,29 @@ namespace Lumix #ifndef ASSERT - #ifdef _WIN32 - #ifdef NDEBUG - #define ASSERT(x) { false ? (void)(x) : 0; } + #ifdef NDEBUG + #define ASSERT(x) { false ? (void)(x) : 0; } + #else + #ifdef _WIN32 + #define LUMIX_DEBUG_BREAK __debugbreak #else - #define ASSERT(x) { const volatile bool lumix_assert_b____ = !(x); if(lumix_assert_b____) __debugbreak(); } + #define LUMIX_DEBUG_BREAK abort #endif + #define ASSERT(x) do { const volatile bool lumix_assert_b____ = !(x); if(lumix_assert_b____) LUMIX_DEBUG_BREAK(); } while (false) #endif #endif - -#define LUMIX_LIBRARY_EXPORT __declspec(dllexport) -#define LUMIX_LIBRARY_IMPORT __declspec(dllimport) -#define LUMIX_FORCE_INLINE __forceinline -#define LUMIX_RESTRICT __restrict +#ifdef _WIN32 + #define LUMIX_LIBRARY_EXPORT __declspec(dllexport) + #define LUMIX_LIBRARY_IMPORT __declspec(dllimport) + #define LUMIX_FORCE_INLINE __forceinline + #define LUMIX_RESTRICT __restrict +#else + #define LUMIX_LIBRARY_EXPORT __attribute__((visibility("default"))) + #define LUMIX_LIBRARY_IMPORT + #define LUMIX_FORCE_INLINE __attribute__((always_inline)) inline + #define LUMIX_RESTRICT __restrict__ +#endif #ifdef STATIC_PLUGINS #define LUMIX_AUDIO_API diff --git a/src/engine/property_descriptor.h b/src/engine/property_descriptor.h index 2fb8879fac..017b6137ea 100644 --- a/src/engine/property_descriptor.h +++ b/src/engine/property_descriptor.h @@ -3,8 +3,9 @@ #include "core/blob.h" #include "core/path.h" #include "core/string.h" +#include "iplugin.h" #include "iproperty_descriptor.h" -#include "universe\universe.h" +#include "universe/universe.h" namespace Lumix @@ -538,16 +539,21 @@ class ResourcePropertyDescriptor : public FilePropertyDescriptor, public ResourcePropertyDescriptorBase { public: + using Getter = typename FilePropertyDescriptor::Getter; + using Setter = typename FilePropertyDescriptor::Setter; + using ArrayGetter = typename FilePropertyDescriptor::ArrayGetter; + using ArraySetter = typename FilePropertyDescriptor::ArraySetter; + ResourcePropertyDescriptor(const char* name, Getter getter, Setter setter, const char* file_type, uint32 resource_type, IAllocator& allocator) - : FilePropertyDescriptor(name, getter, setter, file_type, allocator) + : FilePropertyDescriptor(name, getter, setter, file_type, allocator) , ResourcePropertyDescriptorBase(resource_type) { - m_type = IPropertyDescriptor::RESOURCE; + IPropertyDescriptor::m_type = IPropertyDescriptor::RESOURCE; } ResourcePropertyDescriptor(const char* name, @@ -556,10 +562,10 @@ class ResourcePropertyDescriptor : public FilePropertyDescriptor, const char* file_type, uint32 resource_type, IAllocator& allocator) - : FilePropertyDescriptor(name, getter, setter, file_type, allocator) + : FilePropertyDescriptor(name, getter, setter, file_type, allocator) , ResourcePropertyDescriptorBase(resource_type) { - m_type = IPropertyDescriptor::RESOURCE; + IPropertyDescriptor::m_type = IPropertyDescriptor::RESOURCE; } }; @@ -803,10 +809,15 @@ template class DecimalPropertyDescriptor : public IDecimalPropertyDesc template class ColorPropertyDescriptor : public SimplePropertyDescriptor { public: + using Getter = typename SimplePropertyDescriptor::Getter; + using Setter = typename SimplePropertyDescriptor::Setter; + using ArrayGetter = typename SimplePropertyDescriptor::ArrayGetter; + using ArraySetter = typename SimplePropertyDescriptor::ArraySetter; + ColorPropertyDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator) : SimplePropertyDescriptor(name, _getter, _setter, allocator) { - m_type = COLOR; + IPropertyDescriptor::m_type = IPropertyDescriptor::COLOR; } };