Skip to content

Commit

Permalink
Linux port WIP nem0#655
Browse files Browse the repository at this point in the history
  • Loading branch information
MAnyKey committed Apr 19, 2016
1 parent 1bdb86c commit 9706c36
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 24 deletions.
3 changes: 3 additions & 0 deletions projects/genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/core/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Lumix
void write(const void* data, int size);
void writeString(const char* string);
template <class T> void write(const T& value) { write(&value, sizeof(T)); }
template <> void write<bool>(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);
Expand Down
1 change: 1 addition & 0 deletions src/engine/core/iallocator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstring>

#include "lumix.h"

Expand Down
10 changes: 5 additions & 5 deletions src/engine/core/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ template <int size> struct StaticString
return *this;
}

template <int size> void add(StaticString<size>& value) { Lumix::catString(data, size, value.data); }
template <int value_size> void add(StaticString<value_size>& 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); }

Expand Down Expand Up @@ -275,29 +275,29 @@ template <class T> class base_string
return *this;
}

template <class V> base_string<T>& cat(V value)
template <class V> base_string& cat(V value)
{
char tmp[30];
toCString(value, tmp, 30);
*this += tmp;
return *this;
}

template <> base_string<T>& cat<float>(float value)
base_string& cat(float value)
{
char tmp[40];
toCString(value, tmp, 30, 10);
*this += tmp;
return *this;
}

template <> base_string<T>& cat<char*>(char* value)
base_string& cat(char* value)
{
*this += value;
return *this;
}

template <> base_string<T>& cat<const char*>(const char* value)
base_string& cat(const char* value)
{
*this += value;
return *this;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/debug/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "lumix.h"
#include "core/iallocator.h"
#include "core/mt/sync.h"
#include "core/MT/sync.h"


namespace Lumix
Expand Down
38 changes: 27 additions & 11 deletions src/engine/lumix.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#pragma once

#include <cstdlib>

#ifdef _WIN32
#ifdef _WIN64
#define PLATFORM64
#else
#define PLATFORM32
#endif
#else
#elif defined(__linux__)
#ifdef __x86_64__
#define PLATFORM64
#else
#define PLATFORM32
#endif
#else
#error Platform not supported
#endif

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
23 changes: 17 additions & 6 deletions src/engine/property_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -538,16 +539,21 @@ class ResourcePropertyDescriptor : public FilePropertyDescriptor<T>,
public ResourcePropertyDescriptorBase
{
public:
using Getter = typename FilePropertyDescriptor<T>::Getter;
using Setter = typename FilePropertyDescriptor<T>::Setter;
using ArrayGetter = typename FilePropertyDescriptor<T>::ArrayGetter;
using ArraySetter = typename FilePropertyDescriptor<T>::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<T>(name, getter, setter, file_type, allocator)
, ResourcePropertyDescriptorBase(resource_type)
{
m_type = IPropertyDescriptor::RESOURCE;
IPropertyDescriptor::m_type = IPropertyDescriptor::RESOURCE;
}

ResourcePropertyDescriptor(const char* name,
Expand All @@ -556,10 +562,10 @@ class ResourcePropertyDescriptor : public FilePropertyDescriptor<T>,
const char* file_type,
uint32 resource_type,
IAllocator& allocator)
: FilePropertyDescriptor(name, getter, setter, file_type, allocator)
: FilePropertyDescriptor<T>(name, getter, setter, file_type, allocator)
, ResourcePropertyDescriptorBase(resource_type)
{
m_type = IPropertyDescriptor::RESOURCE;
IPropertyDescriptor::m_type = IPropertyDescriptor::RESOURCE;
}

};
Expand Down Expand Up @@ -803,10 +809,15 @@ template <class S> class DecimalPropertyDescriptor : public IDecimalPropertyDesc
template <class S> class ColorPropertyDescriptor : public SimplePropertyDescriptor<Vec3, S>
{
public:
using Getter = typename SimplePropertyDescriptor<Vec3, S>::Getter;
using Setter = typename SimplePropertyDescriptor<Vec3, S>::Setter;
using ArrayGetter = typename SimplePropertyDescriptor<Vec3, S>::ArrayGetter;
using ArraySetter = typename SimplePropertyDescriptor<Vec3, S>::ArraySetter;

ColorPropertyDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator)
: SimplePropertyDescriptor<Vec3, S>(name, _getter, _setter, allocator)
{
m_type = COLOR;
IPropertyDescriptor::m_type = IPropertyDescriptor::COLOR;
}
};

Expand Down

0 comments on commit 9706c36

Please sign in to comment.