From 67d0e0a689c0b9e78e132c33afa32934973baeb0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Feb 2020 15:17:28 +0100 Subject: [PATCH 01/25] Switch to C++17 --- build/scripts/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 7ca78b9af..f7aabaaad 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -811,7 +811,7 @@ function NazaraBuild:PrepareGeneric() "UndefinedIdentifiers" }) - cppdialect("C++14") + cppdialect("C++17") self:FilterLibDirectory("../thirdparty/genlib/", libdirs) self:FilterLibDirectory("../thirdparty/lib/", libdirs) From 3d223211090a00177d613f1f6d411b2131b1f3d5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 00:42:22 +0100 Subject: [PATCH 02/25] Big f***ing cleanup part 1 --- SDK/include/NDK/Lua/LuaBinding_Core.hpp | 2 - SDK/include/NDK/LuaAPI.inl | 2 +- SDK/src/NDK/Lua/LuaBinding_Audio.cpp | 8 +- SDK/src/NDK/Lua/LuaBinding_Core.cpp | 84 +-- SDK/src/NDK/Lua/LuaBinding_Graphics.cpp | 26 +- examples/DopplerEffect/main.cpp | 4 +- examples/MeshInfos/main.cpp | 29 +- examples/Particles/main.cpp | 2 +- include/Nazara/Audio/Music.hpp | 2 +- include/Nazara/Audio/Sound.hpp | 2 +- include/Nazara/Audio/SoundBuffer.hpp | 2 +- include/Nazara/Audio/SoundStream.hpp | 5 +- include/Nazara/Core.hpp | 9 +- include/Nazara/Core/Algorithm.hpp | 27 + include/Nazara/Core/Clock.hpp | 8 - include/Nazara/Core/ConditionVariable.hpp | 42 -- include/Nazara/Core/ConditionVariable.inl | 14 - include/Nazara/Core/Config.hpp | 11 - include/Nazara/Core/Directory.hpp | 82 -- include/Nazara/Core/DynLib.hpp | 24 +- include/Nazara/Core/Error.hpp | 4 +- include/Nazara/Core/File.hpp | 58 +- include/Nazara/Core/File.inl | 4 +- include/Nazara/Core/FileLogger.hpp | 6 +- include/Nazara/Core/LockGuard.hpp | 34 - include/Nazara/Core/LockGuard.inl | 83 --- include/Nazara/Core/Log.hpp | 6 - include/Nazara/Core/Mutex.hpp | 41 - include/Nazara/Core/Mutex.inl | 17 - include/Nazara/Core/PluginManager.hpp | 23 +- include/Nazara/Core/RefCounted.hpp | 6 - include/Nazara/Core/Resource.hpp | 8 +- include/Nazara/Core/ResourceLoader.hpp | 10 +- include/Nazara/Core/ResourceLoader.inl | 19 +- include/Nazara/Core/ResourceManager.hpp | 17 +- include/Nazara/Core/ResourceManager.inl | 18 +- include/Nazara/Core/ResourceSaver.hpp | 15 +- include/Nazara/Core/ResourceSaver.inl | 18 +- include/Nazara/Core/Semaphore.hpp | 40 - include/Nazara/Core/SparsePtr.hpp | 2 +- include/Nazara/Core/SparsePtr.inl | 2 +- include/Nazara/Core/Stream.hpp | 9 +- include/Nazara/Core/StringExt.hpp | 61 ++ include/Nazara/Core/StringExt.inl | 82 ++ include/Nazara/Core/Thread.hpp | 75 -- include/Nazara/Core/Thread.inl | 55 -- include/Nazara/Core/ThreadSafety.hpp | 23 - include/Nazara/Core/ThreadSafetyOff.hpp | 21 - include/Nazara/Graphics/Material.hpp | 23 +- include/Nazara/Graphics/Material.inl | 20 +- include/Nazara/Graphics/Model.hpp | 10 +- include/Nazara/Graphics/Sprite.hpp | 8 +- include/Nazara/Lua/LuaState.hpp | 5 +- include/Nazara/Lua/LuaState.inl | 15 + include/Nazara/Network/NetPacket.hpp | 4 +- include/Nazara/Platform/Window.hpp | 10 +- include/Nazara/Platform/Window.inl | 8 +- include/Nazara/Renderer/Shader.hpp | 3 +- include/Nazara/Renderer/ShaderStage.hpp | 3 +- include/Nazara/Renderer/Texture.hpp | 12 +- .../Renderer/UberShaderPreprocessor.hpp | 2 +- include/Nazara/Utility/Animation.hpp | 30 +- include/Nazara/Utility/Font.hpp | 2 +- .../Nazara/Utility/Formats/MD5MeshParser.hpp | 8 +- include/Nazara/Utility/Formats/MTLParser.hpp | 37 +- include/Nazara/Utility/Formats/MTLParser.inl | 16 +- include/Nazara/Utility/Formats/OBJParser.hpp | 55 +- include/Nazara/Utility/Formats/OBJParser.inl | 48 +- include/Nazara/Utility/Image.hpp | 12 +- include/Nazara/Utility/IndexBuffer.hpp | 34 +- include/Nazara/Utility/IndexBuffer.inl | 18 +- include/Nazara/Utility/Mesh.hpp | 56 +- include/Nazara/Utility/SkeletalMesh.hpp | 6 +- include/Nazara/Utility/Skeleton.hpp | 10 +- include/Nazara/Utility/StaticMesh.hpp | 6 +- include/Nazara/Utility/SubMesh.hpp | 10 +- include/Nazara/Utility/VertexBuffer.hpp | 34 +- include/Nazara/Utility/VertexBuffer.inl | 10 +- include/Nazara/Utility/VertexMapper.hpp | 4 +- include/Nazara/Utility/VertexMapper.inl | 4 +- plugins/Assimp/Plugin.cpp | 18 +- src/Nazara/Audio/Formats/sndfileLoader.cpp | 18 +- src/Nazara/Audio/Music.cpp | 90 ++- src/Nazara/Audio/OpenAL.cpp | 6 +- src/Nazara/Audio/Sound.cpp | 4 +- src/Nazara/Audio/SoundBuffer.cpp | 2 +- src/Nazara/Audio/SoundStream.cpp | 2 +- src/Nazara/Core/Clock.cpp | 16 - src/Nazara/Core/ConditionVariable.cpp | 105 --- src/Nazara/Core/Directory.cpp | 535 -------------- src/Nazara/Core/DynLib.cpp | 61 +- src/Nazara/Core/Error.cpp | 38 +- src/Nazara/Core/File.cpp | 475 +----------- src/Nazara/Core/FileLogger.cpp | 15 +- src/Nazara/Core/Mutex.cpp | 80 -- src/Nazara/Core/PluginManager.cpp | 62 +- .../Core/Posix/ConditionVariableImpl.cpp | 52 -- .../Core/Posix/ConditionVariableImpl.hpp | 36 - src/Nazara/Core/Posix/DirectoryImpl.cpp | 120 --- src/Nazara/Core/Posix/DirectoryImpl.hpp | 52 -- src/Nazara/Core/Posix/FileImpl.cpp | 126 +--- src/Nazara/Core/Posix/FileImpl.hpp | 13 +- src/Nazara/Core/Posix/MutexImpl.cpp | 38 - src/Nazara/Core/Posix/MutexImpl.hpp | 31 - src/Nazara/Core/Posix/SemaphoreImpl.cpp | 73 -- src/Nazara/Core/Posix/SemaphoreImpl.hpp | 31 - src/Nazara/Core/Posix/ThreadImpl.cpp | 78 -- src/Nazara/Core/Posix/ThreadImpl.hpp | 42 -- src/Nazara/Core/Resource.cpp | 4 +- src/Nazara/Core/Semaphore.cpp | 86 --- src/Nazara/Core/Stream.cpp | 28 +- src/Nazara/Core/StringExt.cpp | 226 ++++++ src/Nazara/Core/Thread.cpp | 280 ------- .../Core/Win32/ConditionVariableImpl.cpp | 84 --- .../Core/Win32/ConditionVariableImpl.hpp | 53 -- src/Nazara/Core/Win32/DirectoryImpl.cpp | 122 --- src/Nazara/Core/Win32/DirectoryImpl.hpp | 52 -- src/Nazara/Core/Win32/DynLibImpl.cpp | 31 +- src/Nazara/Core/Win32/DynLibImpl.hpp | 10 +- src/Nazara/Core/Win32/FileImpl.cpp | 124 +--- src/Nazara/Core/Win32/FileImpl.hpp | 14 +- src/Nazara/Core/Win32/MutexImpl.cpp | 38 - src/Nazara/Core/Win32/MutexImpl.hpp | 32 - src/Nazara/Core/Win32/SemaphoreImpl.cpp | 67 -- src/Nazara/Core/Win32/SemaphoreImpl.hpp | 31 - src/Nazara/Core/Win32/ThreadImpl.cpp | 122 --- src/Nazara/Core/Win32/ThreadImpl.hpp | 42 -- src/Nazara/Graphics/Formats/MeshLoader.cpp | 9 +- src/Nazara/Graphics/Material.cpp | 50 +- src/Nazara/Graphics/MaterialPipeline.cpp | 5 +- src/Nazara/Graphics/Model.cpp | 10 +- src/Nazara/Graphics/Sprite.cpp | 8 +- src/Nazara/Lua/LuaState.cpp | 4 +- src/Nazara/Network/NetPacket.cpp | 9 +- src/Nazara/Platform/Win32/WindowImpl.cpp | 37 +- src/Nazara/Platform/Win32/WindowImpl.hpp | 10 +- src/Nazara/Platform/Window.cpp | 24 +- src/Nazara/Renderer/RenderWindow.cpp | 4 +- src/Nazara/Renderer/Shader.cpp | 2 +- src/Nazara/Renderer/ShaderStage.cpp | 4 +- src/Nazara/Renderer/Texture.cpp | 12 +- .../Renderer/UberShaderPreprocessor.cpp | 4 +- src/Nazara/Renderer/Win32/ContextImpl.cpp | 7 +- src/Nazara/Utility/Animation.cpp | 40 +- src/Nazara/Utility/Font.cpp | 2 +- src/Nazara/Utility/Formats/DDSLoader.cpp | 2 +- src/Nazara/Utility/Formats/FreeTypeLoader.cpp | 19 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 10 +- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 15 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 16 +- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 93 ++- src/Nazara/Utility/Formats/MTLParser.cpp | 698 +++++++++++------- src/Nazara/Utility/Formats/OBJLoader.cpp | 92 +-- src/Nazara/Utility/Formats/OBJParser.cpp | 163 ++-- src/Nazara/Utility/Formats/OBJSaver.cpp | 64 +- src/Nazara/Utility/Formats/PCXLoader.cpp | 2 +- src/Nazara/Utility/Formats/STBLoader.cpp | 2 +- src/Nazara/Utility/Formats/STBSaver.cpp | 6 +- src/Nazara/Utility/Image.cpp | 12 +- src/Nazara/Utility/IndexBuffer.cpp | 22 +- src/Nazara/Utility/Mesh.cpp | 98 ++- src/Nazara/Utility/SkeletalMesh.cpp | 2 +- src/Nazara/Utility/Skeleton.cpp | 22 +- src/Nazara/Utility/StaticMesh.cpp | 2 +- src/Nazara/Utility/SubMesh.cpp | 18 +- src/Nazara/Utility/VertexBuffer.cpp | 34 +- tests/Engine/Audio/Music.cpp | 10 +- tests/Engine/Audio/Sound.cpp | 12 +- tests/Engine/Audio/SoundEmitter.cpp | 2 - tests/Engine/Core/Clock.cpp | 5 +- tests/Engine/Core/Directory.cpp | 34 - tests/Engine/Core/File.cpp | 25 +- tests/Engine/Network/TCP.cpp | 5 +- thirdparty/include/Utfcpp/utf8.h | 4 + thirdparty/include/Utfcpp/utf8/checked.h | 43 +- thirdparty/include/Utfcpp/utf8/core.h | 26 +- thirdparty/include/Utfcpp/utf8/cpp11.h | 103 +++ thirdparty/include/Utfcpp/utf8/unchecked.h | 71 +- 178 files changed, 2190 insertions(+), 5113 deletions(-) delete mode 100644 include/Nazara/Core/ConditionVariable.hpp delete mode 100644 include/Nazara/Core/ConditionVariable.inl delete mode 100644 include/Nazara/Core/Directory.hpp delete mode 100644 include/Nazara/Core/LockGuard.hpp delete mode 100644 include/Nazara/Core/LockGuard.inl delete mode 100644 include/Nazara/Core/Mutex.hpp delete mode 100644 include/Nazara/Core/Mutex.inl delete mode 100644 include/Nazara/Core/Semaphore.hpp create mode 100644 include/Nazara/Core/StringExt.hpp create mode 100644 include/Nazara/Core/StringExt.inl delete mode 100644 include/Nazara/Core/Thread.hpp delete mode 100644 include/Nazara/Core/Thread.inl delete mode 100644 include/Nazara/Core/ThreadSafety.hpp delete mode 100644 include/Nazara/Core/ThreadSafetyOff.hpp delete mode 100644 src/Nazara/Core/ConditionVariable.cpp delete mode 100644 src/Nazara/Core/Directory.cpp delete mode 100644 src/Nazara/Core/Mutex.cpp delete mode 100644 src/Nazara/Core/Posix/ConditionVariableImpl.cpp delete mode 100644 src/Nazara/Core/Posix/ConditionVariableImpl.hpp delete mode 100644 src/Nazara/Core/Posix/DirectoryImpl.cpp delete mode 100644 src/Nazara/Core/Posix/DirectoryImpl.hpp delete mode 100644 src/Nazara/Core/Posix/MutexImpl.cpp delete mode 100644 src/Nazara/Core/Posix/MutexImpl.hpp delete mode 100644 src/Nazara/Core/Posix/SemaphoreImpl.cpp delete mode 100644 src/Nazara/Core/Posix/SemaphoreImpl.hpp delete mode 100644 src/Nazara/Core/Posix/ThreadImpl.cpp delete mode 100644 src/Nazara/Core/Posix/ThreadImpl.hpp delete mode 100644 src/Nazara/Core/Semaphore.cpp create mode 100644 src/Nazara/Core/StringExt.cpp delete mode 100644 src/Nazara/Core/Thread.cpp delete mode 100644 src/Nazara/Core/Win32/ConditionVariableImpl.cpp delete mode 100644 src/Nazara/Core/Win32/ConditionVariableImpl.hpp delete mode 100644 src/Nazara/Core/Win32/DirectoryImpl.cpp delete mode 100644 src/Nazara/Core/Win32/DirectoryImpl.hpp delete mode 100644 src/Nazara/Core/Win32/MutexImpl.cpp delete mode 100644 src/Nazara/Core/Win32/MutexImpl.hpp delete mode 100644 src/Nazara/Core/Win32/SemaphoreImpl.cpp delete mode 100644 src/Nazara/Core/Win32/SemaphoreImpl.hpp delete mode 100644 src/Nazara/Core/Win32/ThreadImpl.cpp delete mode 100644 src/Nazara/Core/Win32/ThreadImpl.hpp delete mode 100644 tests/Engine/Core/Directory.cpp create mode 100644 thirdparty/include/Utfcpp/utf8/cpp11.h diff --git a/SDK/include/NDK/Lua/LuaBinding_Core.hpp b/SDK/include/NDK/Lua/LuaBinding_Core.hpp index 3149fdcc8..4277936e0 100644 --- a/SDK/include/NDK/Lua/LuaBinding_Core.hpp +++ b/SDK/include/NDK/Lua/LuaBinding_Core.hpp @@ -8,7 +8,6 @@ #define NDK_LUABINDING_CORE_HPP #include -#include #include #include #include @@ -24,7 +23,6 @@ namespace Ndk void Register(Nz::LuaState& state) override; Nz::LuaClass clock; - Nz::LuaClass directory; Nz::LuaClass file; Nz::LuaClass stream; }; diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 01c797e89..b867e90fe 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -385,7 +385,7 @@ namespace Nz params->loadHeightMap = state.CheckField("LoadHeightMap", params->loadHeightMap); params->loadNormalMap = state.CheckField("LoadNormalMap", params->loadNormalMap); params->loadSpecularMap = state.CheckField("LoadSpecularMap", params->loadSpecularMap); - params->shaderName = state.CheckField("ShaderName", params->shaderName); + params->shaderName = state.CheckField("ShaderName", params->shaderName); return 1; } diff --git a/SDK/src/NDK/Lua/LuaBinding_Audio.cpp b/SDK/src/NDK/Lua/LuaBinding_Audio.cpp index c95b5d0ce..df97a7d38 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Audio.cpp @@ -80,7 +80,7 @@ namespace Ndk music.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("Music("); - ss << instance.GetFilePath() << ')'; + ss << instance.GetFilePath().generic_u8string() << ')'; lua.PushString(ss); return 1; @@ -169,9 +169,9 @@ namespace Ndk Nz::StringStream ss("SoundBuffer("); if (instance->IsValid()) { - Nz::String filePath = instance->GetFilePath(); - if (!filePath.IsEmpty()) - ss << "File: " << filePath << ", "; + std::filesystem::path filePath = instance->GetFilePath(); + if (!filePath.empty()) + ss << "File: " << filePath.generic_u8string() << ", "; ss << "Duration: " << instance->GetDuration() / 1000.f << "s"; } diff --git a/SDK/src/NDK/Lua/LuaBinding_Core.cpp b/SDK/src/NDK/Lua/LuaBinding_Core.cpp index 6091c88e2..49a7642f4 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Core.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Core.cpp @@ -115,60 +115,6 @@ namespace Ndk }); } - /********************************* Nz::Directory ********************************/ - directory.Reset("Directory"); - { - directory.SetConstructor([] (Nz::LuaState& lua, Nz::Directory* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 1U); - - int argIndex = 2; - switch (argCount) - { - case 0: - Nz::PlacementNew(instance); - return true; - - case 1: - Nz::PlacementNew(instance, lua.Check(&argIndex)); - return true; - } - - return false; - }); - - directory.BindMethod("Close", &Nz::Directory::Close); - directory.BindMethod("Exists", &Nz::Directory::Exists); - directory.BindMethod("GetPath", &Nz::Directory::GetPath); - directory.BindMethod("GetPattern", &Nz::Directory::GetPattern); - directory.BindMethod("GetResultName", &Nz::Directory::GetResultName); - directory.BindMethod("GetResultPath", &Nz::Directory::GetResultPath); - directory.BindMethod("GetResultSize", &Nz::Directory::GetResultSize); - directory.BindMethod("IsOpen", &Nz::Directory::IsOpen); - directory.BindMethod("IsResultDirectory", &Nz::Directory::IsResultDirectory); - directory.BindMethod("NextResult", &Nz::Directory::NextResult, true); - directory.BindMethod("Open", &Nz::Directory::Open); - directory.BindMethod("SetPath", &Nz::Directory::SetPath); - directory.BindMethod("SetPattern", &Nz::Directory::SetPattern); - - directory.BindStaticMethod("Copy", Nz::Directory::Copy); - directory.BindStaticMethod("Create", Nz::Directory::Create); - directory.BindStaticMethod("Exists", Nz::Directory::Exists); - directory.BindStaticMethod("GetCurrent", Nz::Directory::GetCurrent); - directory.BindStaticMethod("Remove", Nz::Directory::Remove); - directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent); - - // Manual - directory.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream ss("Directory("); - ss << instance.GetPath(); - ss << ')'; - - lua.PushString(ss); - return 1; - }); - } - /*********************************** Nz::File ***********************************/ file.Reset("File"); { @@ -187,7 +133,7 @@ namespace Ndk case 1: { - Nz::String filePath = lua.Check(&argIndex); + std::string filePath = lua.Check(&argIndex); Nz::PlacementNew(instance, filePath); return true; @@ -195,7 +141,7 @@ namespace Ndk case 2: { - Nz::String filePath = lua.Check(&argIndex); + std::string filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex); Nz::PlacementNew(instance, filePath, openMode); @@ -212,29 +158,8 @@ namespace Ndk file.BindMethod("Delete", &Nz::File::Delete); file.BindMethod("EndOfFile", &Nz::File::EndOfFile); file.BindMethod("Exists", &Nz::File::Exists); - file.BindMethod("GetCreationTime", &Nz::File::GetCreationTime); file.BindMethod("GetFileName", &Nz::File::GetFileName); - file.BindMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime); - file.BindMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime); file.BindMethod("IsOpen", &Nz::File::IsOpen); - file.BindMethod("Rename", &Nz::File::GetLastWriteTime); - file.BindMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime); - file.BindMethod("SetFile", &Nz::File::GetLastWriteTime); - - file.BindStaticMethod("AbsolutePath", &Nz::File::AbsolutePath); - file.BindStaticMethod("ComputeHash", (Nz::ByteArray(*)(Nz::HashType, const Nz::String&)) &Nz::File::ComputeHash); - file.BindStaticMethod("Copy", &Nz::File::Copy); - file.BindStaticMethod("Delete", &Nz::File::Delete); - file.BindStaticMethod("Exists", &Nz::File::Exists); - //fileClass.SetStaticMethod("GetCreationTime", &Nz::File::GetCreationTime); - file.BindStaticMethod("GetDirectory", &Nz::File::GetDirectory); - //fileClass.SetStaticMethod("GetLastAccessTime", &Nz::File::GetLastAccessTime); - //fileClass.SetStaticMethod("GetLastWriteTime", &Nz::File::GetLastWriteTime); - file.BindStaticMethod("GetSize", &Nz::File::GetSize); - file.BindStaticMethod("IsAbsolute", &Nz::File::IsAbsolute); - file.BindStaticMethod("NormalizePath", &Nz::File::NormalizePath); - file.BindStaticMethod("NormalizeSeparators", &Nz::File::NormalizeSeparators); - file.BindStaticMethod("Rename", &Nz::File::Rename); // Manual file.BindMethod("Open", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t argumentCount) -> int @@ -250,7 +175,7 @@ namespace Ndk case 2: { - Nz::String filePath = lua.Check(&argIndex); + std::string filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex, Nz::OpenMode_NotOpen); return lua.Push(instance.Open(filePath, openMode)); } @@ -285,7 +210,7 @@ namespace Ndk file.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int { Nz::StringStream ss("File("); if (instance.IsOpen()) - ss << "Path: " << instance.GetPath(); + ss << "Path: " << instance.GetPath().generic_u8string(); ss << ')'; @@ -304,7 +229,6 @@ namespace Ndk { // Classes clock.Register(state); - directory.Register(state); file.Register(state); stream.Register(state); diff --git a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp index fc764866a..5ed660089 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp @@ -94,7 +94,7 @@ namespace Ndk } else { - Nz::PlacementNew(instance, Nz::Material::New(lua.Check(&argIndex))); + Nz::PlacementNew(instance, Nz::Material::New(lua.Check(&argIndex))); return true; } } @@ -114,7 +114,7 @@ namespace Ndk } else { - lua.Push(instance->Configure(lua.Check(&argIndex))); + lua.Push(instance->Configure(lua.Check(&argIndex))); return 1; } }); @@ -214,7 +214,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetAlphaMap(lua.Check(&argIndex))); + return lua.Push(instance->SetAlphaMap(lua.Check(&argIndex))); }); material.BindMethod("SetDiffuseMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int @@ -226,7 +226,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetDiffuseMap(lua.Check(&argIndex))); + return lua.Push(instance->SetDiffuseMap(lua.Check(&argIndex))); }); material.BindMethod("SetEmissiveMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int @@ -238,7 +238,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetEmissiveMap(lua.Check(&argIndex))); + return lua.Push(instance->SetEmissiveMap(lua.Check(&argIndex))); }); material.BindMethod("SetHeightMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int @@ -250,7 +250,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetHeightMap(lua.Check(&argIndex))); + return lua.Push(instance->SetHeightMap(lua.Check(&argIndex))); }); material.BindMethod("SetNormalMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int @@ -262,7 +262,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetNormalMap(lua.Check(&argIndex))); + return lua.Push(instance->SetNormalMap(lua.Check(&argIndex))); }); material.BindMethod("SetShader", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int @@ -274,7 +274,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetShader(lua.Check(&argIndex))); + return lua.Push(instance->SetShader(lua.Check(&argIndex))); }); material.BindMethod("SetSpecularMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int @@ -286,7 +286,7 @@ namespace Ndk return 0; } else - return lua.Push(instance->SetSpecularMap(lua.Check(&argIndex))); + return lua.Push(instance->SetSpecularMap(lua.Check(&argIndex))); }); } @@ -326,7 +326,7 @@ namespace Ndk } else if (lua.IsOfType(argIndex, Nz::LuaType_String)) { - Nz::String subMesh(lua.Check(&argIndex)); + std::string subMesh(lua.Check(&argIndex)); Nz::MaterialRef mat(lua.Check(&argIndex)); instance->SetMaterial(subMesh, std::move(mat)); @@ -351,7 +351,7 @@ namespace Ndk else if (lua.IsOfType(argIndex, Nz::LuaType_String)) { std::size_t skinIndex(lua.Check(&argIndex)); - Nz::String subMesh(lua.Check(&argIndex)); + std::string subMesh(lua.Check(&argIndex)); Nz::MaterialRef materialRef(lua.Check(&argIndex)); instance->SetMaterial(skinIndex, subMesh, std::move(materialRef)); @@ -423,7 +423,7 @@ namespace Ndk if (lua.IsOfType(argIndex, "Material")) instance->SetMaterial(skinIndex, *static_cast(lua.ToUserdata(argIndex)), resizeSprite); else - instance->SetMaterial(skinIndex, lua.Check(&argIndex), resizeSprite); + instance->SetMaterial(skinIndex, lua.Check(&argIndex), resizeSprite); } return 0; @@ -452,7 +452,7 @@ namespace Ndk if (lua.IsOfType(argIndex, "Texture")) instance->SetTexture(skinIndex, *static_cast(lua.ToUserdata(argIndex)), resizeSprite); else - instance->SetTexture(skinIndex, lua.Check(&argIndex), resizeSprite); + instance->SetTexture(skinIndex, lua.Check(&argIndex), resizeSprite); } return 0; diff --git a/examples/DopplerEffect/main.cpp b/examples/DopplerEffect/main.cpp index 24120a2f5..b0c7a8f62 100644 --- a/examples/DopplerEffect/main.cpp +++ b/examples/DopplerEffect/main.cpp @@ -10,10 +10,10 @@ #include #include -#include // Thread::Sleep #include #include #include +#include #include int main() @@ -61,7 +61,7 @@ int main() int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS if (sleepTime > 0) - Nz::Thread::Sleep(sleepTime); + std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime)); // On bouge la source du son en fonction du temps depuis chaque mise à jour Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds(); diff --git a/examples/MeshInfos/main.cpp b/examples/MeshInfos/main.cpp index e7b3feaeb..8d7d25adb 100644 --- a/examples/MeshInfos/main.cpp +++ b/examples/MeshInfos/main.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -26,25 +25,17 @@ int main() for (;;) { - Nz::Directory resourceDirectory("resources"); - if (!resourceDirectory.Open()) + std::vector models; + for (auto& p : std::filesystem::directory_iterator("resources")) { - std::cerr << "Failed to open resource directory" << std::endl; - std::getchar(); - return EXIT_FAILURE; - } + if (!p.is_regular_file()) + continue; - std::vector models; - while (resourceDirectory.NextResult()) - { - Nz::String path = resourceDirectory.GetResultName(); - Nz::String ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne - if (Nz::MeshLoader::IsExtensionSupported(ext)) // L'extension est-elle supportée par le MeshLoader ? - models.push_back(path); + const std::filesystem::path& filePath = p.path(); + if (Nz::MeshLoader::IsExtensionSupported(filePath.extension().generic_u8string())) // L'extension est-elle supportée par le MeshLoader ? + models.push_back(filePath); } - resourceDirectory.Close(); - if (models.empty()) { std::cout << "No loadable mesh found in resource directory" << std::endl; @@ -71,7 +62,7 @@ int main() if (iChoice == 0) break; - Nz::MeshRef mesh = Nz::Mesh::LoadFromFile(resourceDirectory.GetPath() + '/' + models[iChoice-1]); + Nz::MeshRef mesh = Nz::Mesh::LoadFromFile(models[iChoice-1]); if (!mesh) { std::cout << "Failed to load mesh" << std::endl; @@ -123,8 +114,8 @@ int main() } } - Nz::String animationPath = mesh->GetAnimation(); - if (!animationPath.IsEmpty()) + std::filesystem::path animationPath = mesh->GetAnimation(); + if (!animationPath.empty()) { Nz::AnimationRef animation = Nz::Animation::LoadFromFile(animationPath); if (animation) diff --git a/examples/Particles/main.cpp b/examples/Particles/main.cpp index e4940c63d..7f1571989 100644 --- a/examples/Particles/main.cpp +++ b/examples/Particles/main.cpp @@ -173,7 +173,7 @@ int main() window.CopyToImage(&screenshot); static unsigned int counter = 1; - screenshot.SaveToFile("screenshot_" + Nz::String::Number(counter++) + ".png"); + screenshot.SaveToFile("screenshot_" + std::to_string(counter++) + ".png"); break; } diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index 331624a8d..0f0acc1b7 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -39,7 +39,7 @@ namespace Nz bool IsLooping() const override; - bool OpenFromFile(const String& filePath, const SoundStreamParams& params = SoundStreamParams()); + bool OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params = SoundStreamParams()); bool OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams()); bool OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams()); diff --git a/include/Nazara/Audio/Sound.hpp b/include/Nazara/Audio/Sound.hpp index 55cc2f97a..1c1415dc8 100644 --- a/include/Nazara/Audio/Sound.hpp +++ b/include/Nazara/Audio/Sound.hpp @@ -34,7 +34,7 @@ namespace Nz bool IsPlayable() const; bool IsPlaying() const; - bool LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams()); + bool LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams()); bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams()); bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams()); diff --git a/include/Nazara/Audio/SoundBuffer.hpp b/include/Nazara/Audio/SoundBuffer.hpp index 4cf5e50df..0a7ab4f63 100644 --- a/include/Nazara/Audio/SoundBuffer.hpp +++ b/include/Nazara/Audio/SoundBuffer.hpp @@ -71,7 +71,7 @@ namespace Nz static bool IsFormatSupported(AudioFormat format); - static SoundBufferRef LoadFromFile(const String& filePath, const SoundBufferParams& params = SoundBufferParams()); + static SoundBufferRef LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams()); static SoundBufferRef LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams()); static SoundBufferRef LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams()); diff --git a/include/Nazara/Audio/SoundStream.hpp b/include/Nazara/Audio/SoundStream.hpp index d33997d26..89b229317 100644 --- a/include/Nazara/Audio/SoundStream.hpp +++ b/include/Nazara/Audio/SoundStream.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Nz { @@ -40,7 +41,7 @@ namespace Nz virtual UInt32 GetDuration() const = 0; virtual AudioFormat GetFormat() const = 0; - virtual Mutex& GetMutex() = 0; + virtual std::mutex& GetMutex() = 0; virtual UInt64 GetSampleCount() const = 0; virtual UInt32 GetSampleRate() const = 0; @@ -48,7 +49,7 @@ namespace Nz virtual void Seek(UInt64 offset) = 0; virtual UInt64 Tell() = 0; - static SoundStreamRef OpenFromFile(const String& filePath, const SoundStreamParams& params = SoundStreamParams()); + static SoundStreamRef OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params = SoundStreamParams()); static SoundStreamRef OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams()); static SoundStreamRef OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams()); diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp index bb5e6e682..579a0c267 100644 --- a/include/Nazara/Core.hpp +++ b/include/Nazara/Core.hpp @@ -34,14 +34,13 @@ #include #include #include +#include #include #include #include #include -#include #include #include -#include #include #include #include @@ -56,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -64,13 +62,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -79,7 +77,6 @@ #include #include #include -#include #include #include #include @@ -88,9 +85,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index faf80e6cb..f42fefd27 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -31,6 +31,33 @@ namespace Nz template void HashCombine(std::size_t& seed, const T& v); template T ReverseBits(T integer); + template + struct AlwaysFalse : std::false_type {}; + + template + struct OverloadResolver + { + template + constexpr auto operator()(R(T::* ptr)(Args...)) const noexcept + { + return ptr; + } + + template + constexpr auto operator()(R(T::* ptr)(Args...) const) const noexcept + { + return ptr; + } + + template + constexpr auto operator()(R(*ptr)(Args...)) const noexcept + { + return ptr; + } + }; + + template constexpr OverloadResolver Overload = {}; + template struct PointedType { diff --git a/include/Nazara/Core/Clock.hpp b/include/Nazara/Core/Clock.hpp index a6b464db6..f37f78a52 100644 --- a/include/Nazara/Core/Clock.hpp +++ b/include/Nazara/Core/Clock.hpp @@ -9,12 +9,6 @@ #include -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_CLOCK -#include -#else -#include -#endif - namespace Nz { class NAZARA_CORE_API Clock @@ -39,8 +33,6 @@ namespace Nz Clock& operator=(Clock&& clock) = default; private: - NazaraMutexAttrib(m_mutex, mutable) - UInt64 m_elapsedTime; UInt64 m_refTime; bool m_paused; diff --git a/include/Nazara/Core/ConditionVariable.hpp b/include/Nazara/Core/ConditionVariable.hpp deleted file mode 100644 index 4b69926d3..000000000 --- a/include/Nazara/Core/ConditionVariable.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONDITIONVARIABLE_HPP -#define NAZARA_CONDITIONVARIABLE_HPP - -#include -#include - -namespace Nz -{ - class ConditionVariableImpl; - class Mutex; - - class NAZARA_CORE_API ConditionVariable - { - public: - ConditionVariable(); - ConditionVariable(const ConditionVariable&) = delete; - ConditionVariable(ConditionVariable&& condition) noexcept = default; - ~ConditionVariable(); - - void Signal(); - void SignalAll(); - - void Wait(Mutex* mutex); - bool Wait(Mutex* mutex, UInt32 timeout); - - ConditionVariable& operator=(const ConditionVariable&) = delete; - ConditionVariable& operator=(ConditionVariable&& condition) noexcept = default; - - private: - MovablePtr m_impl; - }; -} - -#include - -#endif // NAZARA_CONDITIONVARIABLE_HPP diff --git a/include/Nazara/Core/ConditionVariable.inl b/include/Nazara/Core/ConditionVariable.inl deleted file mode 100644 index 71866b880..000000000 --- a/include/Nazara/Core/ConditionVariable.inl +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include - -namespace Nz -{ - /*! - * \class Nz::ConditionVariable - */ -} - -#include diff --git a/include/Nazara/Core/Config.hpp b/include/Nazara/Core/Config.hpp index 976db4512..e4362f80a 100644 --- a/include/Nazara/Core/Config.hpp +++ b/include/Nazara/Core/Config.hpp @@ -58,17 +58,6 @@ // Activate the security tests based on the code (Advised for development) #define NAZARA_CORE_SAFE 1 -// Protect the classes against data race -#define NAZARA_CORE_THREADSAFE 1 - -// Classes to protect against data race -#define NAZARA_THREADSAFETY_CLOCK 0 // Clock -#define NAZARA_THREADSAFETY_DIRECTORY 1 // Directory -#define NAZARA_THREADSAFETY_DYNLIB 1 // DynLib -#define NAZARA_THREADSAFETY_FILE 1 // File -#define NAZARA_THREADSAFETY_LOG 1 // Log -#define NAZARA_THREADSAFETY_REFCOUNTED 1 // RefCounted - // Number of spinlocks to use with the Windows critical sections (0 to disable) #define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096 diff --git a/include/Nazara/Core/Directory.hpp b/include/Nazara/Core/Directory.hpp deleted file mode 100644 index 1ac3af76b..000000000 --- a/include/Nazara/Core/Directory.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_DIRECTORY_HPP -#define NAZARA_DIRECTORY_HPP - -#include -#include -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #define NAZARA_DIRECTORY_SEPARATOR '\\' -#elif defined(NAZARA_PLATFORM_LINUX) - #define NAZARA_DIRECTORY_SEPARATOR '/' -#else - #error OS not handled - #define NAZARA_DIRECTORY_SEPARATOR '/' -#endif - -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DIRECTORY - #include -#else - #include -#endif - -namespace Nz -{ - class DirectoryImpl; - - class NAZARA_CORE_API Directory - { - public: - Directory(); - Directory(const String& dirPath); - Directory(const Directory&) = delete; - Directory(Directory&&) noexcept = default; - ~Directory(); - - void Close(); - - bool Exists() const; - - String GetPath() const; - String GetPattern() const; - String GetResultName() const; - String GetResultPath() const; - UInt64 GetResultSize() const; - - bool IsOpen() const; - bool IsResultDirectory() const; - - bool NextResult(bool skipDots = true); - - bool Open(); - - void SetPath(const String& dirPath); - void SetPattern(const String& pattern); - - static bool Copy(const String& sourcePath, const String& destPath); - static bool Create(const String& dirPath, bool recursive = false); - static bool Exists(const String& dirPath); - static String GetCurrent(); - static const char* GetCurrentFileRelativeToEngine(const char* currentFile); - static bool Remove(const String& dirPath, bool emptyDirectory = false); - static bool SetCurrent(const String& dirPath); - - Directory& operator=(const Directory&) = delete; - Directory& operator=(Directory&&) noexcept = delete; - - private: - NazaraMutexAttrib(m_mutex, mutable) - - String m_dirPath; - String m_pattern; - MovablePtr m_impl; - }; -} - -#endif // NAZARA_DIRECTORY_HPP diff --git a/include/Nazara/Core/DynLib.hpp b/include/Nazara/Core/DynLib.hpp index 266334b3e..71730d6e1 100644 --- a/include/Nazara/Core/DynLib.hpp +++ b/include/Nazara/Core/DynLib.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #if defined(NAZARA_PLATFORM_WINDOWS) #define NAZARA_DYNLIB_EXTENSION ".dll" @@ -21,12 +21,6 @@ #error OS not handled #endif -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DYNLIB - #include -#else - #include -#endif - namespace Nz { using DynLibFunc = int (*)(); // "Generic" type of pointer to function @@ -38,25 +32,23 @@ namespace Nz public: DynLib(); DynLib(const DynLib&) = delete; - DynLib(DynLib&&) noexcept = default; + DynLib(DynLib&&) noexcept; ~DynLib(); - String GetLastError() const; - DynLibFunc GetSymbol(const String& symbol) const; + std::string GetLastError() const; + DynLibFunc GetSymbol(const char* symbol) const; bool IsLoaded() const; - bool Load(const String& libraryPath); + bool Load(const std::filesystem::path& libraryPath); void Unload(); DynLib& operator=(const DynLib&) = delete; - DynLib& operator=(DynLib&& lib) noexcept = default; + DynLib& operator=(DynLib&& lib) noexcept; private: - NazaraMutexAttrib(m_mutex, mutable) - - mutable String m_lastError; - MovablePtr m_impl; + mutable std::string m_lastError; + std::unique_ptr m_impl; }; } diff --git a/include/Nazara/Core/Error.hpp b/include/Nazara/Core/Error.hpp index 8081340f7..16c7d6ca7 100644 --- a/include/Nazara/Core/Error.hpp +++ b/include/Nazara/Core/Error.hpp @@ -33,7 +33,7 @@ namespace Nz static UInt32 GetFlags(); static String GetLastError(const char** file = nullptr, unsigned int* line = nullptr, const char** function = nullptr); static unsigned int GetLastSystemErrorCode(); - static String GetLastSystemError(unsigned int code = GetLastSystemErrorCode()); + static std::string GetLastSystemError(unsigned int code = GetLastSystemErrorCode()); static void SetFlags(UInt32 flags); @@ -41,6 +41,8 @@ namespace Nz static void Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function); private: + static const char* GetCurrentFileRelativeToEngine(const char* file); + static UInt32 s_flags; static String s_lastError; static const char* s_lastErrorFunction; diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index ce3025ca5..10e37a31b 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -13,14 +13,9 @@ #include #include #include - -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE - #include -#else - #include -#endif - #include +#include +#include namespace Nz { @@ -30,13 +25,13 @@ namespace Nz { public: File(); - File(const String& filePath); - File(const String& filePath, OpenModeFlags openMode); + File(const std::filesystem::path& filePath); + File(const std::filesystem::path& filePath, OpenModeFlags openMode); File(const File&) = delete; - File(File&& file) noexcept = default; + File(File&& file) noexcept; ~File(); - bool Copy(const String& newFilePath); + void Copy(const std::filesystem::path& newFilePath); void Close(); bool Delete(); @@ -46,56 +41,35 @@ namespace Nz bool Exists() const; - time_t GetCreationTime() const; UInt64 GetCursorPos() const override; - String GetDirectory() const override; - String GetFileName() const; - time_t GetLastAccessTime() const; - time_t GetLastWriteTime() const; - String GetPath() const override; + std::filesystem::path GetDirectory() const override; + std::filesystem::path GetFileName() const; + std::filesystem::path GetPath() const override; UInt64 GetSize() const override; bool IsOpen() const; bool Open(OpenModeFlags openMode = OpenMode_NotOpen); - bool Open(const String& filePath, OpenModeFlags openMode = OpenMode_NotOpen); - - bool Rename(const String& newFilePath); + bool Open(const std::filesystem::path& filePath, OpenModeFlags openMode = OpenMode_NotOpen); bool SetCursorPos(CursorPosition pos, Int64 offset = 0); bool SetCursorPos(UInt64 offset) override; - bool SetFile(const String& filePath); + bool SetFile(const std::filesystem::path& filePath); bool SetSize(UInt64 size); - File& operator=(const String& filePath); File& operator=(const File&) = delete; - File& operator=(File&& file) noexcept = default; + File& operator=(File&& file) noexcept; - static String AbsolutePath(const String& filePath); - static inline ByteArray ComputeHash(HashType hash, const String& filePath); - static inline ByteArray ComputeHash(AbstractHash* hash, const String& filePath); - static bool Copy(const String& sourcePath, const String& targetPath); - static bool Delete(const String& filePath); - static bool Exists(const String& filePath); - static time_t GetCreationTime(const String& filePath); - static String GetDirectory(const String& filePath); - static time_t GetLastAccessTime(const String& filePath); - static time_t GetLastWriteTime(const String& filePath); - static UInt64 GetSize(const String& filePath); - static bool IsAbsolute(const String& filePath); - static String NormalizePath(const String& filePath); - static String NormalizeSeparators(const String& filePath); - static bool Rename(const String& sourcePath, const String& targetPath); + static inline ByteArray ComputeHash(HashType hash, const std::filesystem::path& filePath); + static inline ByteArray ComputeHash(AbstractHash* hash, const std::filesystem::path& filePath); private: - NazaraMutexAttrib(m_mutex, mutable) - void FlushStream() override; std::size_t ReadBlock(void* buffer, std::size_t size) override; std::size_t WriteBlock(const void* buffer, std::size_t size) override; - String m_filePath; - MovablePtr m_impl; + std::filesystem::path m_filePath; + std::unique_ptr m_impl; }; NAZARA_CORE_API bool HashAppend(AbstractHash* hash, const File& originalFile); diff --git a/include/Nazara/Core/File.inl b/include/Nazara/Core/File.inl index 8a93fbc28..d23daf953 100644 --- a/include/Nazara/Core/File.inl +++ b/include/Nazara/Core/File.inl @@ -15,7 +15,7 @@ namespace Nz * \param filePath Path for the file */ - inline ByteArray File::ComputeHash(HashType hash, const String& filePath) + inline ByteArray File::ComputeHash(HashType hash, const std::filesystem::path& filePath) { return ComputeHash(AbstractHash::Get(hash).get(), filePath); } @@ -28,7 +28,7 @@ namespace Nz * \param filePath Path for the file */ - inline ByteArray File::ComputeHash(AbstractHash* hash, const String& filePath) + inline ByteArray File::ComputeHash(AbstractHash* hash, const std::filesystem::path& filePath) { return Nz::ComputeHash(hash, File(filePath)); } diff --git a/include/Nazara/Core/FileLogger.hpp b/include/Nazara/Core/FileLogger.hpp index c722b3290..f61ba8046 100644 --- a/include/Nazara/Core/FileLogger.hpp +++ b/include/Nazara/Core/FileLogger.hpp @@ -9,8 +9,9 @@ #include #include -#include #include +#include +#include namespace Nz { @@ -35,7 +36,8 @@ namespace Nz FileLogger& operator=(FileLogger&&) noexcept = default; private: - File m_outputFile; + std::fstream m_outputFile; + std::filesystem::path m_outputPath; StdLogger m_stdLogger; bool m_forceStdOutput; bool m_stdReplicationEnabled; diff --git a/include/Nazara/Core/LockGuard.hpp b/include/Nazara/Core/LockGuard.hpp deleted file mode 100644 index 59ece007c..000000000 --- a/include/Nazara/Core/LockGuard.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_LOCKGUARD_HPP -#define NAZARA_LOCKGUARD_HPP - -#include - -namespace Nz -{ - class Mutex; - - class LockGuard - { - public: - inline LockGuard(Mutex& mutex, bool lock = true); - inline ~LockGuard(); - - inline void Lock(); - inline bool TryLock(); - inline void Unlock(); - - private: - Mutex& m_mutex; - bool m_locked; - }; -} - -#include - -#endif // NAZARA_LOCKGUARD_HPP diff --git a/include/Nazara/Core/LockGuard.inl b/include/Nazara/Core/LockGuard.inl deleted file mode 100644 index 4fa95884f..000000000 --- a/include/Nazara/Core/LockGuard.inl +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::LockGuard - * \brief Core class that represents a mutex wrapper that provides a convenient RAII-style mechanism - */ - - /*! - * \brief Constructs a LockGuard object with a mutex - * - * \param mutex Mutex to lock - * \param lock Should the mutex be locked by the constructor - */ - inline LockGuard::LockGuard(Mutex& mutex, bool lock) : - m_mutex(mutex), - m_locked(false) - { - if (lock) - { - m_mutex.Lock(); - m_locked = true; - } - } - - /*! - * \brief Destructs a LockGuard object and unlocks the mutex if it was previously locked - */ - inline LockGuard::~LockGuard() - { - if (m_locked) - m_mutex.Unlock(); - } - - /*! - * \brief Locks the underlying mutex - * - * \see Mutex::Lock - */ - inline void LockGuard::Lock() - { - NazaraAssert(!m_locked, "Mutex is already locked"); - - m_mutex.Lock(); - } - - /*! - * \brief Tries to lock the underlying mutex - * - * \see Mutex::TryLock - * - * \return true if the lock was acquired successfully - */ - inline bool LockGuard::TryLock() - { - NazaraAssert(!m_locked, "Mutex is already locked"); - - return m_mutex.TryLock(); - } - - /*! - * \brief Unlocks the underlying mutex - * - * \see Mutex::Unlock - */ - inline void LockGuard::Unlock() - { - NazaraAssert(m_locked, "Mutex is not locked"); - - m_mutex.Unlock(); - } -} - -#include diff --git a/include/Nazara/Core/Log.hpp b/include/Nazara/Core/Log.hpp index edb8f7947..c398b76a7 100644 --- a/include/Nazara/Core/Log.hpp +++ b/include/Nazara/Core/Log.hpp @@ -11,12 +11,6 @@ #include #include -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG - #include -#else - #include -#endif - #ifdef NAZARA_DEBUG #define NazaraDebug(txt) NazaraNotice(txt) #else diff --git a/include/Nazara/Core/Mutex.hpp b/include/Nazara/Core/Mutex.hpp deleted file mode 100644 index d5d5180bb..000000000 --- a/include/Nazara/Core/Mutex.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_MUTEX_HPP -#define NAZARA_MUTEX_HPP - -#include -#include - -namespace Nz -{ - class MutexImpl; - - class NAZARA_CORE_API Mutex - { - friend class ConditionVariable; - - public: - Mutex(); - Mutex(const Mutex&) = delete; - Mutex(Mutex&&) noexcept = default; - ~Mutex(); - - void Lock(); - bool TryLock(); - void Unlock(); - - Mutex& operator=(const Mutex&) = delete; - Mutex& operator=(Mutex&&) noexcept = default; - - private: - MovablePtr m_impl; - }; -} - -#include - -#endif // NAZARA_MUTEX_HPP diff --git a/include/Nazara/Core/Mutex.inl b/include/Nazara/Core/Mutex.inl deleted file mode 100644 index ca9e5ec2f..000000000 --- a/include/Nazara/Core/Mutex.inl +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::Mutex - */ -} - -#include diff --git a/include/Nazara/Core/PluginManager.hpp b/include/Nazara/Core/PluginManager.hpp index 13b384109..a13f1f0b0 100644 --- a/include/Nazara/Core/PluginManager.hpp +++ b/include/Nazara/Core/PluginManager.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -24,23 +24,32 @@ namespace Nz PluginManager() = delete; ~PluginManager() = delete; - static void AddDirectory(const String& directoryPath); + static void AddDirectory(const std::filesystem::path& directoryPath); static bool Initialize(); static bool Mount(Plugin plugin); - static bool Mount(const String& pluginPath, bool appendExtension = true); + static bool Mount(const std::filesystem::path& pluginPath, bool appendExtension = true); - static void RemoveDirectory(const String& directoryPath); + static void RemoveDirectory(const std::filesystem::path& directoryPath); static void Unmount(Plugin plugin); - static void Unmount(const String& pluginPath); + static void Unmount(const std::filesystem::path& pluginPath); static void Uninitialize(); private: - static std::set s_directories; - static std::unordered_map s_plugins; + // https://stackoverflow.com/questions/51065244/is-there-no-standard-hash-for-stdfilesystempath + struct PathHash + { + std::size_t operator()(const std::filesystem::path& p) const + { + return hash_value(p); + } + }; + + static std::set s_directories; + static std::unordered_map, PathHash> s_plugins; static bool s_initialized; }; } diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index d348d9280..a108653f7 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -10,12 +10,6 @@ #include #include -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED - #include -#else - #include -#endif - namespace Nz { class NAZARA_CORE_API RefCounted diff --git a/include/Nazara/Core/Resource.hpp b/include/Nazara/Core/Resource.hpp index 6f651ecf8..d1cc1bc2e 100644 --- a/include/Nazara/Core/Resource.hpp +++ b/include/Nazara/Core/Resource.hpp @@ -8,7 +8,7 @@ #define NAZARA_RESOURCE_HPP #include -#include +#include namespace Nz { @@ -20,15 +20,15 @@ namespace Nz Resource(Resource&&) noexcept = default; virtual ~Resource(); - const String& GetFilePath() const; + const std::filesystem::path& GetFilePath() const; - void SetFilePath(const String& filePath); + void SetFilePath(const std::filesystem::path& filePath); Resource& operator=(const Resource&) = default; Resource& operator=(Resource&&) noexcept = default; private: - String m_filePath; + std::filesystem::path m_filePath; }; } diff --git a/include/Nazara/Core/ResourceLoader.hpp b/include/Nazara/Core/ResourceLoader.hpp index 1bee093ee..c3a0918a9 100644 --- a/include/Nazara/Core/ResourceLoader.hpp +++ b/include/Nazara/Core/ResourceLoader.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,8 +29,8 @@ namespace Nz friend Type; public: - using ExtensionGetter = bool (*)(const String& extension); - using FileLoader = ObjectRef (*)(const String& filePath, const Parameters& parameters); + using ExtensionGetter = bool (*)(const std::string& extension); + using FileLoader = ObjectRef (*)(const std::filesystem::path& filePath, const Parameters& parameters); using MemoryLoader = ObjectRef (*)(const void* data, std::size_t size, const Parameters& parameters); using StreamChecker = Ternary (*)(Stream& stream, const Parameters& parameters); using StreamLoader = ObjectRef (*)(Stream& stream, const Parameters& parameters); @@ -38,9 +38,9 @@ namespace Nz ResourceLoader() = delete; ~ResourceLoader() = delete; - static bool IsExtensionSupported(const String& extension); + static bool IsExtensionSupported(const std::string& extension); - static ObjectRef LoadFromFile(const String& filePath, const Parameters& parameters = Parameters()); + static ObjectRef LoadFromFile(const std::filesystem::path& filePath, const Parameters& parameters = Parameters()); static ObjectRef LoadFromMemory(const void* data, std::size_t size, const Parameters& parameters = Parameters()); static ObjectRef LoadFromStream(Stream& stream, const Parameters& parameters = Parameters()); diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index db143c3b0..65ae38803 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace Nz @@ -24,7 +25,7 @@ namespace Nz * \param extension Extension of the file */ template - bool ResourceLoader::IsExtensionSupported(const String& extension) + bool ResourceLoader::IsExtensionSupported(const std::string& extension) { for (Loader& loader : Type::s_loaders) { @@ -53,19 +54,21 @@ namespace Nz * \remark Produces a NazaraError if all loaders failed or no loader was found */ template - ObjectRef ResourceLoader::LoadFromFile(const String& filePath, const Parameters& parameters) + ObjectRef ResourceLoader::LoadFromFile(const std::filesystem::path& filePath, const Parameters& parameters) { NazaraAssert(parameters.IsValid(), "Invalid parameters"); - String path = File::NormalizePath(filePath); - String ext = path.SubStringFrom('.', -1, true).ToLower(); - if (ext.IsEmpty()) + std::string ext = ToLower(filePath.extension().generic_u8string()); + if (ext.empty()) { - NazaraError("Failed to get file extension from \"" + filePath + '"'); + NazaraError("Failed to get file extension from \"" + filePath.generic_u8string() + '"'); return nullptr; } - File file(path); // Open only if needed + if (ext[0] == '.') + ext.erase(ext.begin()); + + File file(filePath.generic_u8string()); // Open only if needed bool found = false; for (Loader& loader : Type::s_loaders) @@ -82,7 +85,7 @@ namespace Nz { if (!file.Open(OpenMode_ReadOnly)) { - NazaraError("Failed to load file: unable to open \"" + filePath + '"'); + NazaraError("Failed to load file: unable to open \"" + filePath.generic_u8string() + '"'); return nullptr; } } diff --git a/include/Nazara/Core/ResourceManager.hpp b/include/Nazara/Core/ResourceManager.hpp index c99e84f78..c8b5f8f68 100644 --- a/include/Nazara/Core/ResourceManager.hpp +++ b/include/Nazara/Core/ResourceManager.hpp @@ -25,19 +25,28 @@ namespace Nz static void Clear(); - static ObjectRef Get(const String& filePath); + static ObjectRef Get(const std::filesystem::path& filePath); static const Parameters& GetDefaultParameters(); static void Purge(); - static void Register(const String& filePath, ObjectRef resource); + static void Register(const std::filesystem::path& filePath, ObjectRef resource); static void SetDefaultParameters(const Parameters& params); - static void Unregister(const String& filePath); + static void Unregister(const std::filesystem::path& filePath); private: static bool Initialize(); static void Uninitialize(); - using ManagerMap = std::unordered_map>; + // https://stackoverflow.com/questions/51065244/is-there-no-standard-hash-for-stdfilesystempath + struct PathHash + { + std::size_t operator()(const std::filesystem::path& p) const + { + return hash_value(p); + } + }; + + using ManagerMap = std::unordered_map, PathHash>; using ManagerParams = Parameters; }; } diff --git a/include/Nazara/Core/ResourceManager.inl b/include/Nazara/Core/ResourceManager.inl index ca381fce7..8da2c138e 100644 --- a/include/Nazara/Core/ResourceManager.inl +++ b/include/Nazara/Core/ResourceManager.inl @@ -31,20 +31,20 @@ namespace Nz * \param filePath Path to the asset that will be loaded */ template - ObjectRef ResourceManager::Get(const String& filePath) + ObjectRef ResourceManager::Get(const std::filesystem::path& filePath) { - String absolutePath = File::AbsolutePath(filePath); + std::filesystem::path absolutePath = std::filesystem::canonical(filePath); auto it = Type::s_managerMap.find(absolutePath); if (it == Type::s_managerMap.end()) { ObjectRef resource = Type::LoadFromFile(absolutePath, GetDefaultParameters()); if (!resource) { - NazaraError("Failed to load resource from file: " + absolutePath); + NazaraError("Failed to load resource from file: " + absolutePath.generic_u8string()); return ObjectRef(); } - NazaraDebug("Loaded resource from file " + absolutePath); + NazaraDebug("Loaded resource from file " + absolutePath.generic_u8string()); it = Type::s_managerMap.insert(std::make_pair(absolutePath, resource)).first; } @@ -74,7 +74,7 @@ namespace Nz const ObjectRef& ref = it->second; if (ref->GetReferenceCount() == 1) // Are we the only ones to own the resource ? { - NazaraDebug("Purging resource from file " + ref->GetFilePath()); + NazaraDebug("Purging resource from file " + ref->GetFilePath().generic_u8string()); Type::s_managerMap.erase(it++); // Then we erase it } else @@ -89,9 +89,9 @@ namespace Nz * \param resource Object to associate with */ template - void ResourceManager::Register(const String& filePath, ObjectRef resource) + void ResourceManager::Register(const std::filesystem::path& filePath, ObjectRef resource) { - String absolutePath = File::AbsolutePath(filePath); + std::filesystem::path absolutePath = std::filesystem::canonical(filePath); Type::s_managerMap[absolutePath] = resource; } @@ -113,9 +113,9 @@ namespace Nz * \param filePath Path for the resource */ template - void ResourceManager::Unregister(const String& filePath) + void ResourceManager::Unregister(const std::filesystem::path& filePath) { - String absolutePath = File::AbsolutePath(filePath); + std::filesystem::path absolutePath = std::filesystem::canonical(filePath); Type::s_managerMap.erase(absolutePath); } diff --git a/include/Nazara/Core/ResourceSaver.hpp b/include/Nazara/Core/ResourceSaver.hpp index 08e7ae745..3a122013f 100644 --- a/include/Nazara/Core/ResourceSaver.hpp +++ b/include/Nazara/Core/ResourceSaver.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -27,18 +28,18 @@ namespace Nz friend Type; public: - using ExtensionGetter = bool (*)(const String& extension); - using FormatQuerier = bool (*)(const String& format); - using FileSaver = bool (*)(const Type& resource, const String& filePath, const Parameters& parameters); - using StreamSaver = bool (*)(const Type& resource, const String& format, Stream& stream, const Parameters& parameters); + using ExtensionGetter = bool (*)(const std::string& extension); + using FormatQuerier = bool (*)(const std::string& format); + using FileSaver = bool (*)(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters); + using StreamSaver = bool (*)(const Type& resource, const std::string& format, Stream& stream, const Parameters& parameters); ResourceSaver() = delete; ~ResourceSaver() = delete; - static bool IsFormatSupported(const String& extension); + static bool IsFormatSupported(const std::string& extension); - static bool SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters = Parameters()); - static bool SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters = Parameters()); + static bool SaveToFile(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters = Parameters()); + static bool SaveToStream(const Type& resource, Stream& stream, const std::string& format, const Parameters& parameters = Parameters()); static void RegisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver = nullptr); static void UnregisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver = nullptr); diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index 007f4cc75..57d038843 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace Nz @@ -24,7 +25,7 @@ namespace Nz * \param extension Extension of the file */ template - bool ResourceSaver::IsFormatSupported(const String& extension) + bool ResourceSaver::IsFormatSupported(const std::string& extension) { for (Saver& saver : Type::s_savers) { @@ -51,19 +52,18 @@ namespace Nz * \see SaveToStream */ template - bool ResourceSaver::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters) + bool ResourceSaver::SaveToFile(const Type& resource, const std::filesystem::path& filePath, const Parameters& parameters) { NazaraAssert(parameters.IsValid(), "Invalid parameters"); - String path = File::NormalizePath(filePath); - String ext = path.SubStringFrom('.', -1, true).ToLower(); - if (ext.IsEmpty()) + std::string ext = ToLower(filePath.extension().generic_u8string()); + if (ext.empty()) { - NazaraError("Failed to get file extension from \"" + filePath + '"'); + NazaraError("Failed to get file extension from \"" + filePath.generic_u8string() + '"'); return false; } - File file(path); // Opened only is required + File file(filePath.generic_u8string()); // Opened only is required bool found = false; for (Saver& saver : Type::s_savers) @@ -86,7 +86,7 @@ namespace Nz { if (!file.Open(OpenMode_WriteOnly | OpenMode_Truncate)) { - NazaraError("Failed to save to file: unable to open \"" + filePath + "\" in write mode"); + NazaraError("Failed to save to file: unable to open \"" + filePath.generic_u8string() + "\" in write mode"); return false; } @@ -117,7 +117,7 @@ namespace Nz * \see SaveToFile */ template - bool ResourceSaver::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters) + bool ResourceSaver::SaveToStream(const Type& resource, Stream& stream, const std::string& format, const Parameters& parameters) { NazaraAssert(stream.IsWritable(), "Stream is not writable"); NazaraAssert(parameters.IsValid(), "Invalid parameters"); diff --git a/include/Nazara/Core/Semaphore.hpp b/include/Nazara/Core/Semaphore.hpp deleted file mode 100644 index cb7fdbe56..000000000 --- a/include/Nazara/Core/Semaphore.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SEMAPHORE_HPP -#define NAZARA_SEMAPHORE_HPP - -#include -#include - -namespace Nz -{ - class SemaphoreImpl; - - class NAZARA_CORE_API Semaphore - { - public: - Semaphore(unsigned int count); - Semaphore(const Semaphore&) = delete; - Semaphore(Semaphore&&) noexcept = default; - ~Semaphore(); - - unsigned int GetCount() const; - - void Post(); - - void Wait(); - bool Wait(UInt32 timeout); - - Semaphore& operator=(const Semaphore&) = delete; - Semaphore& operator=(Semaphore&&) noexcept = default; - - private: - MovablePtr m_impl; - }; -} - -#endif // NAZARA_SEMAPHORE_HPP diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index 862ddba4c..aad0e453e 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -46,7 +46,7 @@ namespace Nz operator T*() const; T& operator*() const; T* operator->() const; - T& operator[](int index) const; + T& operator[](std::size_t index) const; SparsePtr& operator=(const SparsePtr& ptr) = default; diff --git a/include/Nazara/Core/SparsePtr.inl b/include/Nazara/Core/SparsePtr.inl index ba9400188..db3a60c33 100644 --- a/include/Nazara/Core/SparsePtr.inl +++ b/include/Nazara/Core/SparsePtr.inl @@ -247,7 +247,7 @@ namespace Nz */ template - T& SparsePtr::operator[](int index) const + T& SparsePtr::operator[](std::size_t index) const { return *reinterpret_cast(m_ptr + index * m_stride); } diff --git a/include/Nazara/Core/Stream.hpp b/include/Nazara/Core/Stream.hpp index a1f86e12e..128ccf099 100644 --- a/include/Nazara/Core/Stream.hpp +++ b/include/Nazara/Core/Stream.hpp @@ -10,11 +10,12 @@ #include #include #include +#include +#include namespace Nz { class ByteArray; - class String; //< Do not include String.hpp in this file class NAZARA_CORE_API Stream { @@ -30,15 +31,15 @@ namespace Nz inline void Flush(); virtual UInt64 GetCursorPos() const = 0; - virtual String GetDirectory() const; - virtual String GetPath() const; + virtual std::filesystem::path GetDirectory() const; + virtual std::filesystem::path GetPath() const; inline OpenModeFlags GetOpenMode() const; inline StreamOptionFlags GetStreamOptions() const; virtual UInt64 GetSize() const = 0; inline std::size_t Read(void* buffer, std::size_t size); - virtual String ReadLine(unsigned int lineSize = 0); + virtual std::string ReadLine(unsigned int lineSize = 0); inline bool IsReadable() const; inline bool IsSequential() const; diff --git a/include/Nazara/Core/StringExt.hpp b/include/Nazara/Core/StringExt.hpp new file mode 100644 index 000000000..4d38014e7 --- /dev/null +++ b/include/Nazara/Core/StringExt.hpp @@ -0,0 +1,61 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CORE_STRING_EXT_HPP +#define NAZARA_CORE_STRING_EXT_HPP + +#include +#include +#include + +namespace Nz +{ + struct CaseIndependent {}; + struct UnicodeAware {}; + + // std::string is assumed to contains UTF-8 + NAZARA_CORE_API std::string FromUtf16String(const char16_t* u16str); + NAZARA_CORE_API std::string FromUtf16String(const std::u16string_view& u16str); + + NAZARA_CORE_API std::string FromUtf32String(const char32_t* u32str); + NAZARA_CORE_API std::string FromUtf32String(const std::u32string_view& u32str); + + NAZARA_CORE_API std::string FromWideString(const wchar_t* wstr); + NAZARA_CORE_API std::string FromWideString(const std::wstring_view& str); + + inline bool IsNumber(const char* str); + inline bool IsNumber(const std::string_view& str); + + template bool StartsWith(const std::string_view& str, const char* s, Args&&... args); + inline bool StartsWith(const std::string_view& str, const std::string_view& s); + NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent); + NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent, UnicodeAware); + + inline std::string ToLower(const char* str); + NAZARA_CORE_API std::string ToLower(const std::string_view& str); + + inline std::string ToLower(const char* str, UnicodeAware); + NAZARA_CORE_API std::string ToLower(const std::string_view& str, UnicodeAware); + + inline std::string ToUpper(const char* str); + NAZARA_CORE_API std::string ToUpper(const std::string_view& str); + + inline std::string ToUpper(const char* str, UnicodeAware); + NAZARA_CORE_API std::string ToUpper(const std::string_view& str, UnicodeAware); + + inline std::u16string ToUtf16String(const char* str); + NAZARA_CORE_API std::u16string ToUtf16String(const std::string_view& str); + + inline std::u32string ToUtf32String(const char* str); + NAZARA_CORE_API std::u32string ToUtf32String(const std::string_view& str); + + inline std::wstring ToWideString(const char* str); + NAZARA_CORE_API std::wstring ToWideString(const std::string_view& str); +} + +#include + +#endif // NAZARA_ALGORITHM_CORE_HPP diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl new file mode 100644 index 000000000..064ca8be6 --- /dev/null +++ b/include/Nazara/Core/StringExt.inl @@ -0,0 +1,82 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + bool IsNumber(const char* str) + { + std::size_t size = std::strlen(str); + return IsNumber(std::string_view(str, size)); + } + + bool IsNumber(const std::string_view& str) + { + return !str.empty() && std::find_if(str.begin(), str.end(), [](unsigned char c) { return !std::isdigit(c); }) == str.end(); + } + + template bool StartsWith(const std::string_view& str, const char* s, Args&&... args) + { + std::size_t size = std::strlen(s); + return StartsWith(str, std::string_view(s, size), std::forward(args)...); + } + + bool StartsWith(const std::string_view& str, const std::string_view& s) + { + //FIXME: Replace with proper C++20 value once it's available +#if __cplusplus > 201703L + // C++20 + return str.starts_with(s); +#else + return str.compare(0, s.size(), s.data()) == 0; +#endif + } + + inline std::string ToLower(const char* str) + { + std::size_t size = std::strlen(str); + return ToLower(std::string_view(str, size)); + } + + inline std::string ToLower(const char* str, UnicodeAware) + { + std::size_t size = std::strlen(str); + return ToLower(std::string_view(str, size), UnicodeAware{}); + } + + inline std::string ToUpper(const char* str) + { + std::size_t size = std::strlen(str); + return ToUpper(std::string_view(str, size)); + } + + inline std::string ToUpper(const char* str, UnicodeAware) + { + std::size_t size = std::strlen(str); + return ToUpper(std::string_view(str, size), UnicodeAware{}); + } + + inline std::u16string ToUtf16String(const char* str) + { + std::size_t size = std::strlen(str); + return ToUtf16String(std::string_view(str, size)); + } + + inline std::u32string ToUtf32String(const char* str) + { + std::size_t size = std::strlen(str); + return ToUtf32String(std::string_view(str, size)); + } + + inline std::wstring ToWideString(const char* str) + { + std::size_t size = std::strlen(str); + return ToWideString(std::string_view(str, size)); + } + +} + +#include diff --git a/include/Nazara/Core/Thread.hpp b/include/Nazara/Core/Thread.hpp deleted file mode 100644 index 7143a881f..000000000 --- a/include/Nazara/Core/Thread.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_THREAD_HPP -#define NAZARA_THREAD_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class String; - class ThreadImpl; - - class NAZARA_CORE_API Thread - { - public: - class Id; - - Thread(); - template Thread(F function); - template Thread(F function, Args&&... args); - template Thread(void (C::*function)(), C* object); - Thread(const Thread&) = delete; - Thread(Thread&& other) noexcept = default; - ~Thread(); - - void Detach(); - Id GetId() const; - bool IsJoinable() const; - void Join(); - void SetName(const String& name); - - Thread& operator=(const Thread&) = delete; - Thread& operator=(Thread&& thread) noexcept = default; - - static unsigned int HardwareConcurrency(); - static void SetCurrentThreadName(const String& name); - static void Sleep(UInt32 milliseconds); - - private: - void CreateImpl(Functor* functor); - - MovablePtr m_impl; - }; - - class NAZARA_CORE_API Thread::Id - { - friend Thread; - - public: - NAZARA_CORE_API friend bool operator==(const Id& lhs, const Id& rhs); - NAZARA_CORE_API friend bool operator!=(const Id& lhs, const Id& rhs); - NAZARA_CORE_API friend bool operator<(const Id& lhs, const Id& rhs); - NAZARA_CORE_API friend bool operator<=(const Id& lhs, const Id& rhs); - NAZARA_CORE_API friend bool operator>(const Id& lhs, const Id& rhs); - NAZARA_CORE_API friend bool operator>=(const Id& lhs, const Id& rhs); - - NAZARA_CORE_API friend std::ostream& operator<<(std::ostream& o, const Id& id); - - private: - explicit Id(ThreadImpl* thread); - - ThreadImpl* m_id = nullptr; - }; -} - -#include - -#endif // NAZARA_THREAD_HPP diff --git a/include/Nazara/Core/Thread.inl b/include/Nazara/Core/Thread.inl deleted file mode 100644 index f2065adfa..000000000 --- a/include/Nazara/Core/Thread.inl +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::Thread - * \brief Core class that represents a thread - */ - - /*! - * \brief Constructs a Thread object with a function - * - * \param function Task the thread will execute in parallel - */ - - template - Thread::Thread(F function) - { - CreateImpl(new FunctorWithoutArgs(function)); - } - - /*! - * \brief Constructs a Thread object with a function and its parameters - * - * \param function Task the thread will execute in parallel - * \param args Arguments of the function - */ - - template - Thread::Thread(F function, Args&&... args) - { - CreateImpl(new FunctorWithArgs(function, std::forward(args)...)); - } - - /*! - * \brief Constructs a Thread object with a member function and its object - * - * \param function Task the thread will execute in parallel - * \param object Object on which the method will be called - */ - - template - Thread::Thread(void (C::*function)(), C* object) - { - CreateImpl(new MemberWithoutArgs(function, object)); - } -} - -#include diff --git a/include/Nazara/Core/ThreadSafety.hpp b/include/Nazara/Core/ThreadSafety.hpp deleted file mode 100644 index 271d6c474..000000000 --- a/include/Nazara/Core/ThreadSafety.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// No header guard - -#include -#include - -// These macroes can change for any file which uses it in the same unit of compilation -#undef NazaraLock -#undef NazaraMutex -#undef NazaraMutexAttrib -#undef NazaraMutexLock -#undef NazaraMutexUnlock -#undef NazaraNamedLock - -#define NazaraLock(mutex) Nz::LockGuard lock_mutex(mutex); -#define NazaraMutex(name) Nz::Mutex name; -#define NazaraMutexAttrib(name, attribute) attribute Mutex name; -#define NazaraMutexLock(mutex) mutex.Lock(); -#define NazaraMutexUnlock(mutex) mutex.Unlock(); -#define NazaraNamedLock(mutex, name) Nz::LockGuard lock_##name(mutex); diff --git a/include/Nazara/Core/ThreadSafetyOff.hpp b/include/Nazara/Core/ThreadSafetyOff.hpp deleted file mode 100644 index 196ef7d07..000000000 --- a/include/Nazara/Core/ThreadSafetyOff.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// No header guard - -// These macroes can change for any file which uses it in the same unit of compilation -#undef NazaraLock -#undef NazaraMutex -#undef NazaraMutexAttrib -#undef NazaraMutexLock -#undef NazaraMutexUnlock -#undef NazaraNamedLock - -#define NazaraLock(mutex) -#define NazaraMutex(name) -#define NazaraMutexAttrib(name, attribute) -#define NazaraMutexLock(mutex) -#define NazaraMutexUnlock(mutex) -#define NazaraNamedLock(mutex, name) - diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 00cbbcbdb..71aff5332 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,7 @@ namespace Nz bool loadHeightMap = true; bool loadNormalMap = true; bool loadSpecularMap = true; - String shaderName = "Basic"; + std::string shaderName = "Basic"; bool IsValid() const; }; @@ -59,7 +58,7 @@ namespace Nz inline Material(); inline Material(const MaterialPipeline* pipeline); inline Material(const MaterialPipelineInfo& pipelineInfo); - inline Material(const String& pipelineName); + inline Material(const std::string& pipelineName); inline Material(const Material& material); inline ~Material(); @@ -69,7 +68,7 @@ namespace Nz inline void Configure(const MaterialPipeline* pipeline); inline void Configure(const MaterialPipelineInfo& pipelineInfo); - inline bool Configure(const String& pipelineName); + inline bool Configure(const std::string& pipelineName); inline void EnableAlphaTest(bool alphaTest); inline void EnableBlending(bool blending); @@ -141,33 +140,33 @@ namespace Nz void SaveToParameters(ParameterList* matData); - inline bool SetAlphaMap(const String& textureName); + inline bool SetAlphaMap(const std::string& textureName); inline void SetAlphaMap(TextureRef alphaMap); inline void SetAlphaThreshold(float alphaThreshold); inline void SetAmbientColor(const Color& ambient); inline void SetDepthFunc(RendererComparison depthFunc); inline void SetDepthMaterial(MaterialRef depthMaterial); inline void SetDiffuseColor(const Color& diffuse); - inline bool SetDiffuseMap(const String& textureName); + inline bool SetDiffuseMap(const std::string& textureName); inline void SetDiffuseMap(TextureRef diffuseMap); inline void SetDiffuseSampler(const TextureSampler& sampler); inline void SetDstBlend(BlendFunc func); - inline bool SetEmissiveMap(const String& textureName); + inline bool SetEmissiveMap(const std::string& textureName); inline void SetEmissiveMap(TextureRef textureName); inline void SetFaceCulling(FaceSide faceSide); inline void SetFaceFilling(FaceFilling filling); - inline bool SetHeightMap(const String& textureName); + inline bool SetHeightMap(const std::string& textureName); inline void SetHeightMap(TextureRef textureName); inline void SetLineWidth(float lineWidth); - inline bool SetNormalMap(const String& textureName); + inline bool SetNormalMap(const std::string& textureName); inline void SetNormalMap(TextureRef textureName); inline void SetPointSize(float pointSize); inline void SetReflectionMode(ReflectionMode reflectionMode); inline void SetShader(UberShaderConstRef uberShader); - inline bool SetShader(const String& uberShaderName); + inline bool SetShader(const std::string& uberShaderName); inline void SetShininess(float shininess); inline void SetSpecularColor(const Color& specular); - inline bool SetSpecularMap(const String& textureName); + inline bool SetSpecularMap(const std::string& textureName); inline void SetSpecularMap(TextureRef specularMap); inline void SetSpecularSampler(const TextureSampler& sampler); inline void SetSrcBlend(BlendFunc func); @@ -177,7 +176,7 @@ namespace Nz inline static MaterialRef GetDefault(); inline static int GetTextureUnit(TextureMap textureMap); - static inline MaterialRef LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams()); + static inline MaterialRef LoadFromFile(const std::filesystem::path& filePath, const MaterialParams& params = MaterialParams()); static inline MaterialRef LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams()); static inline MaterialRef LoadFromStream(Stream& stream, const MaterialParams& params = MaterialParams()); diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 66c34e19c..ac22ea266 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -57,7 +57,7 @@ namespace Nz * * \see Configure */ - inline Material::Material(const String& pipelineName) + inline Material::Material(const std::string& pipelineName) { ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -139,7 +139,7 @@ namespace Nz * * \see Configure */ - inline bool Material::Configure(const String& pipelineName) + inline bool Material::Configure(const std::string& pipelineName) { MaterialPipelineRef pipeline = MaterialPipelineLibrary::Query(pipelineName); if (!pipeline) @@ -909,7 +909,7 @@ namespace Nz * * \param textureName Named texture */ - inline bool Material::SetAlphaMap(const String& textureName) + inline bool Material::SetAlphaMap(const std::string& textureName) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -1005,7 +1005,7 @@ namespace Nz * * \remark Invalidates the pipeline */ - inline bool Material::SetDiffuseMap(const String& textureName) + inline bool Material::SetDiffuseMap(const std::string& textureName) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -1071,7 +1071,7 @@ namespace Nz * * \see GetEmissiveMap */ - inline bool Material::SetEmissiveMap(const String& textureName) + inline bool Material::SetEmissiveMap(const std::string& textureName) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -1140,7 +1140,7 @@ namespace Nz * * \see GetHeightMap */ - inline bool Material::SetHeightMap(const String& textureName) + inline bool Material::SetHeightMap(const std::string& textureName) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -1202,7 +1202,7 @@ namespace Nz * * \see GetNormalMap */ - inline bool Material::SetNormalMap(const String& textureName) + inline bool Material::SetNormalMap(const std::string& textureName) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -1305,7 +1305,7 @@ namespace Nz * * \param uberShaderName Named shader */ - inline bool Material::SetShader(const String& uberShaderName) + inline bool Material::SetShader(const std::string& uberShaderName) { UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName); if (!uberShader) @@ -1343,7 +1343,7 @@ namespace Nz * * \remark Invalidates the pipeline */ - inline bool Material::SetSpecularMap(const String& textureName) + inline bool Material::SetSpecularMap(const std::string& textureName) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -1444,7 +1444,7 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the material */ - inline MaterialRef Material::LoadFromFile(const String& filePath, const MaterialParams& params) + inline MaterialRef Material::LoadFromFile(const std::filesystem::path& filePath, const MaterialParams& params) { return MaterialLoader::LoadFromFile(filePath, params); } diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index db73d4f98..70be0d70c 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -59,22 +59,22 @@ namespace Nz std::unique_ptr Clone() const override; using InstancedRenderable::GetMaterial; - const MaterialRef& GetMaterial(const String& subMeshName) const; - const MaterialRef& GetMaterial(std::size_t skinIndex, const String& subMeshName) const; + const MaterialRef& GetMaterial(const std::string& subMeshName) const; + const MaterialRef& GetMaterial(std::size_t skinIndex, const std::string& subMeshName) const; Mesh* GetMesh() const; virtual bool IsAnimated() const; using InstancedRenderable::SetMaterial; - bool SetMaterial(const String& subMeshName, MaterialRef material); - bool SetMaterial(std::size_t skinIndex, const String& subMeshName, MaterialRef material); + bool SetMaterial(const std::string& subMeshName, MaterialRef material); + bool SetMaterial(std::size_t skinIndex, const std::string& subMeshName, MaterialRef material); virtual void SetMesh(Mesh* mesh); Model& operator=(const Model& node) = default; Model& operator=(Model&& node) = delete; - static ModelRef LoadFromFile(const String& filePath, const ModelParameters& params = ModelParameters()); + static ModelRef LoadFromFile(const std::filesystem::path& filePath, const ModelParameters& params = ModelParameters()); static ModelRef LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params = ModelParameters()); static ModelRef LoadFromStream(Stream& stream, const ModelParameters& params = ModelParameters()); diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 587060467..cba7195df 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -47,15 +47,15 @@ namespace Nz inline void SetCornerColor(RectCorner corner, const Color& color); inline void SetDefaultMaterial(); inline void SetMaterial(MaterialRef material, bool resizeSprite = true); - bool SetMaterial(String materialName, bool resizeSprite = true); + bool SetMaterial(std::string materialName, bool resizeSprite = true); inline void SetMaterial(std::size_t skinIndex, MaterialRef material, bool resizeSprite = true); - bool SetMaterial(std::size_t skinIndex, String materialName, bool resizeSprite = true); + bool SetMaterial(std::size_t skinIndex, std::string materialName, bool resizeSprite = true); inline void SetOrigin(const Vector3f& origin); inline void SetSize(const Vector2f& size); inline void SetSize(float sizeX, float sizeY); - bool SetTexture(String textureName, bool resizeSprite = true); + bool SetTexture(std::string textureName, bool resizeSprite = true); inline void SetTexture(TextureRef texture, bool resizeSprite = true); - bool SetTexture(std::size_t skinIndex, String textureName, bool resizeSprite = true); + bool SetTexture(std::size_t skinIndex, std::string textureName, bool resizeSprite = true); inline void SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeSprite = true); inline void SetTextureCoords(const Rectf& coords); inline void SetTextureRect(const Rectui& rect); diff --git a/include/Nazara/Lua/LuaState.hpp b/include/Nazara/Lua/LuaState.hpp index 4890eae30..8f401a6c3 100644 --- a/include/Nazara/Lua/LuaState.hpp +++ b/include/Nazara/Lua/LuaState.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -87,7 +88,7 @@ namespace Nz void Error(const String& message) const; bool Execute(const String& code, int errorHandler = 0); - bool ExecuteFromFile(const String& filePath, int errorHandler = 0); + bool ExecuteFromFile(const std::filesystem::path& filePath, int errorHandler = 0); bool ExecuteFromMemory(const void* data, std::size_t size, int errorHandler = 0); bool ExecuteFromStream(Stream& stream, int errorHandler = 0); @@ -115,7 +116,7 @@ namespace Nz bool IsValid(int index) const; bool Load(const String& code); - bool LoadFromFile(const String& filePath); + bool LoadFromFile(const std::filesystem::path& filePath); bool LoadFromMemory(const void* data, std::size_t size); bool LoadFromStream(Stream& stream); diff --git a/include/Nazara/Lua/LuaState.inl b/include/Nazara/Lua/LuaState.inl index 97a0827b0..a3a71ef65 100644 --- a/include/Nazara/Lua/LuaState.inl +++ b/include/Nazara/Lua/LuaState.inl @@ -43,6 +43,16 @@ namespace Nz return 1; } + inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, std::filesystem::path* arg, TypeTag) + { + std::size_t strLength = 0; + const char* str = instance.CheckString(index, &strLength); + + arg->assign(std::string_view(str, strLength)); + + return 1; + } + inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, std::string* arg, TypeTag) { std::size_t strLength = 0; @@ -272,6 +282,11 @@ namespace Nz return 1; } + inline int LuaImplReplyVal(const LuaState& instance, std::filesystem::path&& val, TypeTag) + { + return LuaImplReplyVal(instance, val.generic_u8string(), TypeTag()); + } + template inline int LuaImplReplyVal(const LuaState& instance, std::vector&& valContainer, TypeTag>) { diff --git a/include/Nazara/Network/NetPacket.hpp b/include/Nazara/Network/NetPacket.hpp index 37003e14c..be515b81a 100644 --- a/include/Nazara/Network/NetPacket.hpp +++ b/include/Nazara/Network/NetPacket.hpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include namespace Nz { @@ -64,7 +64,7 @@ namespace Nz MemoryStream m_memoryStream; UInt16 m_netCode; - static std::unique_ptr s_availableBuffersMutex; + static std::mutex s_availableBuffersMutex; static std::vector>> s_availableBuffers; }; } diff --git a/include/Nazara/Platform/Window.hpp b/include/Nazara/Platform/Window.hpp index 47d416930..4cfff0bed 100644 --- a/include/Nazara/Platform/Window.hpp +++ b/include/Nazara/Platform/Window.hpp @@ -10,9 +10,7 @@ #define NAZARA_WINDOW_HPP #include -#include #include -#include #include #include #include @@ -23,6 +21,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -126,13 +126,13 @@ namespace Nz std::queue m_events; std::vector m_pendingEvents; - ConditionVariable m_eventCondition; + std::condition_variable m_eventCondition; CursorController m_cursorController; CursorRef m_cursor; EventHandler m_eventHandler; IconRef m_icon; - Mutex m_eventMutex; - Mutex m_eventConditionMutex; + std::mutex m_eventMutex; + std::mutex m_eventConditionMutex; bool m_asyncWindow; bool m_closed; bool m_closeOnQuit; diff --git a/include/Nazara/Platform/Window.inl b/include/Nazara/Platform/Window.inl index 1be1a773f..c18ebd26e 100644 --- a/include/Nazara/Platform/Window.inl +++ b/include/Nazara/Platform/Window.inl @@ -4,7 +4,6 @@ #include #include -#include #include namespace Nz @@ -98,16 +97,15 @@ namespace Nz else { { - LockGuard eventLock(m_eventMutex); + std::lock_guard eventLock(m_eventMutex); m_pendingEvents.push_back(event); } if (m_waitForEvent) { - m_eventConditionMutex.Lock(); - m_eventCondition.Signal(); - m_eventConditionMutex.Unlock(); + std::lock_guard lock(m_eventConditionMutex); + m_eventCondition.notify_all(); } } } diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp index 42e8ba26e..b169f32fc 100644 --- a/include/Nazara/Renderer/Shader.hpp +++ b/include/Nazara/Renderer/Shader.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace Nz { @@ -43,7 +44,7 @@ namespace Nz ~Shader(); void AttachStage(ShaderStageType stage, const ShaderStage& shaderStage); - bool AttachStageFromFile(ShaderStageType stage, const String& filePath); + bool AttachStageFromFile(ShaderStageType stage, const std::filesystem::path& filePath); bool AttachStageFromSource(ShaderStageType stage, const char* source, unsigned int length); bool AttachStageFromSource(ShaderStageType stage, const String& source); diff --git a/include/Nazara/Renderer/ShaderStage.hpp b/include/Nazara/Renderer/ShaderStage.hpp index dea80d611..c0ec6d824 100644 --- a/include/Nazara/Renderer/ShaderStage.hpp +++ b/include/Nazara/Renderer/ShaderStage.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace Nz { @@ -36,7 +37,7 @@ namespace Nz void SetSource(const char* source, unsigned int length); void SetSource(const String& source); - bool SetSourceFromFile(const String& filePath); + bool SetSourceFromFile(const std::filesystem::path& filePath); ShaderStage& operator=(const ShaderStage&) = delete; ShaderStage& operator=(ShaderStage&& shader); diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index b4108f357..69b88f3bf 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -68,13 +68,13 @@ namespace Nz bool IsValid() const; // LoadFace - bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams()); + bool LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams()); bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams()); // Save - bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams()); - bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams()); + bool SaveToFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); + bool SaveToStream(Stream& stream, const std::string& format, const ImageParams& params = ImageParams()); bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel); @@ -96,19 +96,19 @@ namespace Nz static bool IsTypeSupported(ImageType type); // Load - static TextureRef LoadFromFile(const String& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true); + static TextureRef LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true); static TextureRef LoadFromImage(const Image* image, bool generateMipmaps = true); static TextureRef LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true); static TextureRef LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true); // LoadArray - static TextureRef LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); + static TextureRef LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); static TextureRef LoadArrayFromImage(const Image* image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); static TextureRef LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); static TextureRef LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); // LoadCubemap - static TextureRef LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); + static TextureRef LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); static TextureRef LoadCubemapFromImage(const Image* image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams()); static TextureRef LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); static TextureRef LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.hpp b/include/Nazara/Renderer/UberShaderPreprocessor.hpp index 2c45f9d00..924135290 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.hpp +++ b/include/Nazara/Renderer/UberShaderPreprocessor.hpp @@ -32,7 +32,7 @@ namespace Nz UberShaderInstance* Get(const ParameterList& parameters) const override; void SetShader(ShaderStageType stage, const String& source, const String& shaderFlags, const String& requiredFlags = String()); - bool SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags = String()); + bool SetShaderFromFile(ShaderStageType stage, const std::filesystem::path& filePath, const String& shaderFlags, const String& requiredFlags = String()); static bool IsSupported(); template static UberShaderPreprocessorRef New(Args&&... args); diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index 85f3f3bc8..a1f8f7ffe 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -26,9 +26,9 @@ namespace Nz struct NAZARA_UTILITY_API AnimationParams : ResourceParameters { // La frame de fin à charger - UInt32 endFrame = 0xFFFFFFFF; + std::size_t endFrame = 0xFFFFFFFF; // La frame de début à charger - UInt32 startFrame = 0; + std::size_t startFrame = 0; bool IsValid() const; }; @@ -58,37 +58,37 @@ namespace Nz ~Animation(); bool AddSequence(const Sequence& sequence); - void AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const; + void AnimateSkeleton(Skeleton* targetSkeleton, std::size_t frameA, std::size_t frameB, float interpolation) const; - bool CreateSkeletal(UInt32 frameCount, UInt32 jointCount); + bool CreateSkeletal(std::size_t frameCount, std::size_t jointCount); void Destroy(); void EnableLoopPointInterpolation(bool loopPointInterpolation); - UInt32 GetFrameCount() const; - UInt32 GetJointCount() const; + std::size_t GetFrameCount() const; + std::size_t GetJointCount() const; Sequence* GetSequence(const String& sequenceName); - Sequence* GetSequence(UInt32 index); + Sequence* GetSequence(std::size_t index); const Sequence* GetSequence(const String& sequenceName) const; - const Sequence* GetSequence(UInt32 index) const; - UInt32 GetSequenceCount() const; - UInt32 GetSequenceIndex(const String& sequenceName) const; - SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0); - const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const; + const Sequence* GetSequence(std::size_t index) const; + std::size_t GetSequenceCount() const; + std::size_t GetSequenceIndex(const String& sequenceName) const; + SequenceJoint* GetSequenceJoints(std::size_t frameIndex = 0); + const SequenceJoint* GetSequenceJoints(std::size_t frameIndex = 0) const; AnimationType GetType() const; bool HasSequence(const String& sequenceName) const; - bool HasSequence(UInt32 index = 0) const; + bool HasSequence(std::size_t index = 0) const; bool IsLoopPointInterpolationEnabled() const; bool IsValid() const; void RemoveSequence(const String& sequenceName); - void RemoveSequence(UInt32 index); + void RemoveSequence(std::size_t index); template static AnimationRef New(Args&&... args); - static AnimationRef LoadFromFile(const String& filePath, const AnimationParams& params = AnimationParams()); + static AnimationRef LoadFromFile(const std::filesystem::path& filePath, const AnimationParams& params = AnimationParams()); static AnimationRef LoadFromMemory(const void* data, std::size_t size, const AnimationParams& params = AnimationParams()); static AnimationRef LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams()); diff --git a/include/Nazara/Utility/Font.hpp b/include/Nazara/Utility/Font.hpp index 70cbf6150..bf2561201 100644 --- a/include/Nazara/Utility/Font.hpp +++ b/include/Nazara/Utility/Font.hpp @@ -89,7 +89,7 @@ namespace Nz static unsigned int GetDefaultGlyphBorder(); static unsigned int GetDefaultMinimumStepSize(); - static FontRef OpenFromFile(const String& filePath, const FontParams& params = FontParams()); + static FontRef OpenFromFile(const std::filesystem::path& filePath, const FontParams& params = FontParams()); static FontRef OpenFromMemory(const void* data, std::size_t size, const FontParams& params = FontParams()); static FontRef OpenFromStream(Stream& stream, const FontParams& params = FontParams()); diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index f5cdb8637..ce8df1630 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -49,7 +49,7 @@ namespace Nz std::vector triangles; std::vector vertices; std::vector weights; - String shader; + std::string shader; }; MD5MeshParser(Stream& stream); @@ -66,17 +66,17 @@ namespace Nz private: bool Advance(bool required = true); - void Error(const String& message); + void Error(const std::string& message); bool ParseJoints(); bool ParseMesh(); - void Warning(const String& message); + void Warning(const std::string& message); void UnrecognizedLine(bool error = false); std::vector m_joints; std::vector m_meshes; Stream& m_stream; StreamOptionFlags m_streamFlags; - String m_currentLine; + std::string m_currentLine; bool m_keepLastLine; unsigned int m_lineCount; unsigned int m_meshIndex; diff --git a/include/Nazara/Utility/Formats/MTLParser.hpp b/include/Nazara/Utility/Formats/MTLParser.hpp index 7eb10aaa9..fcc9ec7fb 100644 --- a/include/Nazara/Utility/Formats/MTLParser.hpp +++ b/include/Nazara/Utility/Formats/MTLParser.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -23,12 +22,12 @@ namespace Nz MTLParser() = default; ~MTLParser() = default; - inline Material* AddMaterial(const String& matName); + inline Material* AddMaterial(const std::string& matName); inline void Clear(); - inline const Material* GetMaterial(const String& materialName) const; - inline const std::unordered_map& GetMaterials() const; + inline const Material* GetMaterial(const std::string& materialName) const; + inline const std::unordered_map& GetMaterials() const; bool Parse(Stream& stream); @@ -39,17 +38,17 @@ namespace Nz Color ambient = Color::White; Color diffuse = Color::White; Color specular = Color::White; - String alphaMap; - String ambientMap; - String bumpMap; - String decalMap; - String diffuseMap; - String displacementMap; - String emissiveMap; //< Custom addition: not present in MTL - String normalMap; //< Custom addition: not present in MTL - String reflectionMap; - String shininessMap; - String specularMap; + std::string alphaMap; + std::string ambientMap; + std::string bumpMap; + std::string decalMap; + std::string diffuseMap; + std::string displacementMap; + std::string emissiveMap; //< Custom addition: not present in MTL + std::string normalMap; //< Custom addition: not present in MTL + std::string reflectionMap; + std::string shininessMap; + std::string specularMap; float alpha = 1.f; float refractionIndex = 1.f; float shininess = 1.f; @@ -61,14 +60,14 @@ namespace Nz template void Emit(const T& text) const; inline void EmitLine() const; template void EmitLine(const T& line) const; - inline void Error(const String& message); + inline void Error(const std::string& message); inline void Flush() const; - inline void Warning(const String& message); + inline void Warning(const std::string& message); inline void UnrecognizedLine(bool error = false); - std::unordered_map m_materials; + std::unordered_map m_materials; mutable Stream* m_currentStream; - String m_currentLine; + std::string m_currentLine; mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; diff --git a/include/Nazara/Utility/Formats/MTLParser.inl b/include/Nazara/Utility/Formats/MTLParser.inl index cde870fee..20c95dc9c 100644 --- a/include/Nazara/Utility/Formats/MTLParser.inl +++ b/include/Nazara/Utility/Formats/MTLParser.inl @@ -7,7 +7,7 @@ namespace Nz { - inline MTLParser::Material* MTLParser::AddMaterial(const String& matName) + inline MTLParser::Material* MTLParser::AddMaterial(const std::string& matName) { return &m_materials[matName]; } @@ -17,7 +17,7 @@ namespace Nz m_materials.clear(); } - inline const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const + inline const MTLParser::Material* MTLParser::GetMaterial(const std::string& materialName) const { auto it = m_materials.find(materialName); if (it != m_materials.end()) @@ -26,7 +26,7 @@ namespace Nz return nullptr; } - inline const std::unordered_map& MTLParser::GetMaterials() const + inline const std::unordered_map& MTLParser::GetMaterials() const { return m_materials; } @@ -51,9 +51,9 @@ namespace Nz Emit('\n'); } - inline void MTLParser::Error(const String& message) + inline void MTLParser::Error(const std::string& message) { - NazaraError(message + " at line #" + String::Number(m_lineCount)); + NazaraError(message + " at line #" + std::to_string(m_lineCount)); } inline void MTLParser::Flush() const @@ -62,14 +62,14 @@ namespace Nz m_outputStream.Clear(); } - inline void MTLParser::Warning(const String& message) + inline void MTLParser::Warning(const std::string& message) { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + NazaraWarning(message + " at line #" + std::to_string(m_lineCount)); } inline void MTLParser::UnrecognizedLine(bool error) { - String message = "Unrecognized \"" + m_currentLine + '"'; + std::string message = "Unrecognized \"" + m_currentLine + '"'; if (error) Error(message); diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 91c82e4d9..4a7a7d50a 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -8,7 +8,6 @@ #define NAZARA_FORMATS_OBJPARSER_HPP #include -#include #include #include #include @@ -28,53 +27,53 @@ namespace Nz bool Check(Stream& stream); - inline String* GetMaterials(); - inline const String* GetMaterials() const; - inline UInt32 GetMaterialCount() const; + inline std::string* GetMaterials(); + inline const std::string* GetMaterials() const; + inline std::size_t GetMaterialCount() const; inline Mesh* GetMeshes(); inline const Mesh* GetMeshes() const; - inline UInt32 GetMeshCount() const; - inline const String& GetMtlLib() const; + inline std::size_t GetMeshCount() const; + inline const std::filesystem::path& GetMtlLib() const; inline Vector3f* GetNormals(); inline const Vector3f* GetNormals() const; - inline UInt32 GetNormalCount() const; + inline std::size_t GetNormalCount() const; inline Vector4f* GetPositions(); inline const Vector4f* GetPositions() const; - inline UInt32 GetPositionCount() const; + inline std::size_t GetPositionCount() const; inline Vector3f* GetTexCoords(); inline const Vector3f* GetTexCoords() const; - inline UInt32 GetTexCoordCount() const; + inline std::size_t GetTexCoordCount() const; - bool Parse(Stream& stream, UInt32 reservedVertexCount = 100); + bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); bool Save(Stream& stream) const; - inline String* SetMaterialCount(UInt32 materialCount); - inline Mesh* SetMeshCount(UInt32 meshCount); - inline void SetMtlLib(const String& mtlLib); - inline Vector3f* SetNormalCount(UInt32 normalCount); - inline Vector4f* SetPositionCount(UInt32 positionCount); - inline Vector3f* SetTexCoordCount(UInt32 texCoordCount); + inline std::string* SetMaterialCount(std::size_t materialCount); + inline Mesh* SetMeshCount(std::size_t meshCount); + inline void SetMtlLib(const std::filesystem::path& mtlLib); + inline Vector3f* SetNormalCount(std::size_t normalCount); + inline Vector4f* SetPositionCount(std::size_t positionCount); + inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); struct Face { - UInt32 firstVertex; - UInt32 vertexCount; + std::size_t firstVertex; + std::size_t vertexCount; }; struct FaceVertex { - UInt32 normal; - UInt32 position; - UInt32 texCoord; + std::size_t normal; + std::size_t position; + std::size_t texCoord; }; struct Mesh { std::vector faces; std::vector vertices; - String name; - UInt32 material; + std::string name; + std::size_t material; }; private: @@ -82,19 +81,19 @@ namespace Nz template void Emit(const T& text) const; inline void EmitLine() const; template void EmitLine(const T& line) const; - inline void Error(const String& message); + inline void Error(const std::string& message); inline void Flush() const; - inline void Warning(const String& message); + inline void Warning(const std::string& message); inline bool UnrecognizedLine(bool error = false); std::vector m_meshes; - std::vector m_materials; + std::vector m_materials; std::vector m_normals; std::vector m_positions; std::vector m_texCoords; mutable Stream* m_currentStream; - String m_currentLine; - String m_mtlLib; + std::string m_currentLine; + std::filesystem::path m_mtlLib; mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index e1d821a44..af36929a2 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -16,19 +16,19 @@ namespace Nz m_texCoords.clear(); } - inline String* OBJParser::GetMaterials() + inline std::string* OBJParser::GetMaterials() { return m_materials.data(); } - inline const String* OBJParser::GetMaterials() const + inline const std::string* OBJParser::GetMaterials() const { return m_materials.data(); } - inline UInt32 OBJParser::GetMaterialCount() const + inline std::size_t OBJParser::GetMaterialCount() const { - return static_cast(m_materials.size()); + return m_materials.size(); } inline OBJParser::Mesh* OBJParser::GetMeshes() @@ -41,12 +41,12 @@ namespace Nz return m_meshes.data(); } - inline UInt32 OBJParser::GetMeshCount() const + inline std::size_t OBJParser::GetMeshCount() const { - return static_cast(m_meshes.size()); + return m_meshes.size(); } - inline const String& OBJParser::GetMtlLib() const + inline const std::filesystem::path& OBJParser::GetMtlLib() const { return m_mtlLib; } @@ -61,9 +61,9 @@ namespace Nz return m_normals.data(); } - inline UInt32 OBJParser::GetNormalCount() const + inline std::size_t OBJParser::GetNormalCount() const { - return static_cast(m_normals.size()); + return m_normals.size(); } inline Vector4f* OBJParser::GetPositions() @@ -76,9 +76,9 @@ namespace Nz return m_positions.data(); } - inline UInt32 OBJParser::GetPositionCount() const + inline std::size_t OBJParser::GetPositionCount() const { - return static_cast(m_positions.size()); + return m_positions.size(); } inline Vector3f* OBJParser::GetTexCoords() @@ -91,41 +91,41 @@ namespace Nz return m_texCoords.data(); } - inline UInt32 OBJParser::GetTexCoordCount() const + inline std::size_t OBJParser::GetTexCoordCount() const { - return static_cast(m_texCoords.size()); + return m_texCoords.size(); } - inline String* OBJParser::SetMaterialCount(UInt32 materialCount) + inline std::string* OBJParser::SetMaterialCount(std::size_t materialCount) { m_materials.resize(materialCount); return m_materials.data(); } - inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount) + inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount) { m_meshes.resize(meshCount); return m_meshes.data(); } - inline void OBJParser::SetMtlLib(const String& mtlLib) + inline void OBJParser::SetMtlLib(const std::filesystem::path& mtlLib) { m_mtlLib = mtlLib; } - inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount) + inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) { m_normals.resize(normalCount); return m_normals.data(); } - inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount) + inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount) { m_positions.resize(positionCount); return m_positions.data(); } - inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount) + inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount) { m_texCoords.resize(texCoordCount); return m_texCoords.data(); @@ -151,9 +151,9 @@ namespace Nz Emit('\n'); } - inline void OBJParser::Error(const String& message) + inline void OBJParser::Error(const std::string& message) { - NazaraError(message + " at line #" + String::Number(m_lineCount)); + NazaraError(message + " at line #" + std::to_string(m_lineCount)); } inline void OBJParser::Flush() const @@ -162,14 +162,14 @@ namespace Nz m_outputStream.Clear(); } - inline void OBJParser::Warning(const String& message) + inline void OBJParser::Warning(const std::string& message) { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + NazaraWarning(message + " at line #" + std::to_string(m_lineCount)); } inline bool OBJParser::UnrecognizedLine(bool error) { - String message = "Unrecognized \"" + m_currentLine + '"'; + std::string message = "Unrecognized \"" + m_currentLine + '"'; if (error) Error(message); diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 3c3427b88..1ee0011dc 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -94,13 +94,13 @@ namespace Nz bool IsValid() const; // LoadFace - bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams()); + bool LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams()); bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams()); // Save - bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams()); - bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams()); + bool SaveToFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); + bool SaveToStream(Stream& stream, const std::string& format, const ImageParams& params = ImageParams()); //TODO: SaveArray, SaveCubemap, SaveFace @@ -118,18 +118,18 @@ namespace Nz static UInt8 GetMaxLevel(ImageType type, unsigned int width, unsigned int height, unsigned int depth = 1); // Load - static ImageRef LoadFromFile(const String& filePath, const ImageParams& params = ImageParams()); + static ImageRef LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); static ImageRef LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams()); static ImageRef LoadFromStream(Stream& stream, const ImageParams& params = ImageParams()); // LoadArray - static ImageRef LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2)); + static ImageRef LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2)); static ImageRef LoadArrayFromImage(const Image* image, const Vector2ui& atlasSize = Vector2ui(2, 2)); static ImageRef LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2)); static ImageRef LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), const Vector2ui& atlasSize = Vector2ui(2, 2)); // LoadCubemap - static ImageRef LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams()); + static ImageRef LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams()); static ImageRef LoadCubemapFromImage(const Image* image, const CubemapParams& params = CubemapParams()); static ImageRef LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams()); static ImageRef LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams()); diff --git a/include/Nazara/Utility/IndexBuffer.hpp b/include/Nazara/Utility/IndexBuffer.hpp index 7feee06e8..fb229f124 100644 --- a/include/Nazara/Utility/IndexBuffer.hpp +++ b/include/Nazara/Utility/IndexBuffer.hpp @@ -24,39 +24,39 @@ namespace Nz public: IndexBuffer() = default; IndexBuffer(bool largeIndices, BufferRef buffer); - IndexBuffer(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size); - IndexBuffer(bool largeIndices, UInt32 length, DataStorage storage, BufferUsageFlags usage); + IndexBuffer(bool largeIndices, BufferRef buffer, std::size_t offset, std::size_t size); + IndexBuffer(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage); IndexBuffer(const IndexBuffer& indexBuffer); IndexBuffer(IndexBuffer&&) = delete; ~IndexBuffer(); unsigned int ComputeCacheMissCount() const; - bool Fill(const void* data, UInt32 startIndex, UInt32 length); - bool FillRaw(const void* data, UInt32 offset, UInt32 size); + bool Fill(const void* data, std::size_t startIndex, std::size_t length); + bool FillRaw(const void* data, std::size_t offset, std::size_t size); inline const BufferRef& GetBuffer() const; - inline UInt32 GetEndOffset() const; - inline UInt32 GetIndexCount() const; + inline std::size_t GetEndOffset() const; + inline std::size_t GetIndexCount() const; inline DataStorage GetStorage() const; - inline UInt32 GetStride() const; - inline UInt32 GetStartOffset() const; + inline std::size_t GetStride() const; + inline std::size_t GetStartOffset() const; inline bool HasLargeIndices() const; inline bool IsValid() const; - inline void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0); - inline void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0) const; - void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0); - void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const; + inline void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0); + inline void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0) const; + void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0); + void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0) const; void Optimize(); void Reset(); void Reset(bool largeIndices, BufferRef buffer); - void Reset(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size); - void Reset(bool largeIndices, UInt32 length, DataStorage storage, BufferUsageFlags usage); + void Reset(bool largeIndices, BufferRef buffer, std::size_t offset, std::size_t size); + void Reset(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage); void Reset(const IndexBuffer& indexBuffer); void Unmap() const; @@ -71,9 +71,9 @@ namespace Nz private: BufferRef m_buffer; - UInt32 m_endOffset; - UInt32 m_indexCount; - UInt32 m_startOffset; + std::size_t m_endOffset; + std::size_t m_indexCount; + std::size_t m_startOffset; bool m_largeIndices; }; } diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 1bcf60b26..8c09ae706 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -12,12 +12,12 @@ namespace Nz return m_buffer; } - inline UInt32 IndexBuffer::GetEndOffset() const + inline std::size_t IndexBuffer::GetEndOffset() const { return m_endOffset; } - inline UInt32 IndexBuffer::GetIndexCount() const + inline std::size_t IndexBuffer::GetIndexCount() const { return m_indexCount; } @@ -27,12 +27,12 @@ namespace Nz return DataStorage(); } - inline UInt32 IndexBuffer::GetStride() const + inline std::size_t IndexBuffer::GetStride() const { - return static_cast((m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16)); + return static_cast((m_largeIndices) ? sizeof(std::size_t) : sizeof(UInt16)); } - inline UInt32 IndexBuffer::GetStartOffset() const + inline std::size_t IndexBuffer::GetStartOffset() const { return m_startOffset; } @@ -47,15 +47,15 @@ namespace Nz return m_buffer.IsValid(); } - inline void* IndexBuffer::Map(BufferAccess access, UInt32 startIndex, UInt32 length) + inline void* IndexBuffer::Map(BufferAccess access, std::size_t startIndex, std::size_t length) { - UInt32 stride = GetStride(); + std::size_t stride = GetStride(); return MapRaw(access, startIndex*stride, length*stride); } - inline void* IndexBuffer::Map(BufferAccess access, UInt32 startIndex, UInt32 length) const + inline void* IndexBuffer::Map(BufferAccess access, std::size_t startIndex, std::size_t length) const { - UInt32 stride = GetStride(); + std::size_t stride = GetStride(); return MapRaw(access, startIndex*stride, length*stride); } diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 3c1169bfc..634a66629 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -89,12 +89,12 @@ namespace Nz inline ~Mesh(); void AddSubMesh(SubMesh* subMesh); - void AddSubMesh(const String& identifier, SubMesh* subMesh); + void AddSubMesh(const std::string& identifier, SubMesh* subMesh); SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams()); void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams()); - bool CreateSkeletal(UInt32 jointCount); + bool CreateSkeletal(std::size_t jointCount); bool CreateStatic(); void Destroy(); @@ -103,25 +103,25 @@ namespace Nz void GenerateTangents(); const Boxf& GetAABB() const; - String GetAnimation() const; + std::filesystem::path GetAnimation() const; AnimationType GetAnimationType() const; - UInt32 GetJointCount() const; - ParameterList& GetMaterialData(UInt32 index); - const ParameterList& GetMaterialData(UInt32 index) const; - UInt32 GetMaterialCount() const; + std::size_t GetJointCount() const; + ParameterList& GetMaterialData(std::size_t index); + const ParameterList& GetMaterialData(std::size_t index) const; + std::size_t GetMaterialCount() const; Skeleton* GetSkeleton(); const Skeleton* GetSkeleton() const; - SubMesh* GetSubMesh(const String& identifier); - SubMesh* GetSubMesh(UInt32 index); - const SubMesh* GetSubMesh(const String& identifier) const; - const SubMesh* GetSubMesh(UInt32 index) const; - UInt32 GetSubMeshCount() const; - UInt32 GetSubMeshIndex(const String& identifier) const; - UInt32 GetTriangleCount() const; - UInt32 GetVertexCount() const; + SubMesh* GetSubMesh(const std::string& identifier); + SubMesh* GetSubMesh(std::size_t index); + const SubMesh* GetSubMesh(const std::string& identifier) const; + const SubMesh* GetSubMesh(std::size_t index) const; + std::size_t GetSubMeshCount() const; + std::size_t GetSubMeshIndex(const std::string& identifier) const; + std::size_t GetTriangleCount() const; + std::size_t GetVertexCount() const; - bool HasSubMesh(const String& identifier) const; - bool HasSubMesh(UInt32 index = 0) const; + bool HasSubMesh(const std::string& identifier) const; + bool HasSubMesh(std::size_t index = 0) const; void InvalidateAABB() const; @@ -130,22 +130,22 @@ namespace Nz void Recenter(); - void RemoveSubMesh(const String& identifier); - void RemoveSubMesh(UInt32 index); + void RemoveSubMesh(const std::string& identifier); + void RemoveSubMesh(std::size_t index); - bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams()); - bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams()); + bool SaveToFile(const std::filesystem::path& filePath, const MeshParams& params = MeshParams()); + bool SaveToStream(Stream& stream, const std::string& format, const MeshParams& params = MeshParams()); - void SetAnimation(const String& animationPath); - void SetMaterialCount(UInt32 matCount); - void SetMaterialData(UInt32 matIndex, ParameterList data); + void SetAnimation(const std::filesystem::path& animationPath); + void SetMaterialCount(std::size_t matCount); + void SetMaterialData(std::size_t matIndex, ParameterList data); void Transform(const Matrix4f& matrix); Mesh& operator=(const Mesh&) = delete; Mesh& operator=(Mesh&&) = delete; - static MeshRef LoadFromFile(const String& filePath, const MeshParams& params = MeshParams()); + static MeshRef LoadFromFile(const std::filesystem::path& filePath, const MeshParams& params = MeshParams()); static MeshRef LoadFromMemory(const void* data, std::size_t size, const MeshParams& params = MeshParams()); static MeshRef LoadFromStream(Stream& stream, const MeshParams& params = MeshParams()); @@ -164,16 +164,16 @@ namespace Nz NazaraSlot(SubMesh, OnSubMeshInvalidateAABB, onSubMeshInvalidated); }; - std::unordered_map m_subMeshMap; + std::unordered_map m_subMeshMap; std::vector m_materialData; std::vector m_subMeshes; AnimationType m_animationType; mutable Boxf m_aabb; Skeleton m_skeleton; // Only used by skeletal meshes - String m_animationPath; + std::filesystem::path m_animationPath; mutable bool m_aabbUpdated; bool m_isValid; - UInt32 m_jointCount; // Only used by skeletal meshes + std::size_t m_jointCount; // Only used by skeletal meshes static bool Initialize(); static void Uninitialize(); diff --git a/include/Nazara/Utility/SkeletalMesh.hpp b/include/Nazara/Utility/SkeletalMesh.hpp index ebba1cfb5..051e87a8b 100644 --- a/include/Nazara/Utility/SkeletalMesh.hpp +++ b/include/Nazara/Utility/SkeletalMesh.hpp @@ -36,13 +36,13 @@ namespace Nz void Destroy(); const Boxf& GetAABB() const override; - AnimationType GetAnimationType() const final override; + AnimationType GetAnimationType() const final; const IndexBuffer* GetIndexBuffer() const override; VertexBuffer* GetVertexBuffer(); const VertexBuffer* GetVertexBuffer() const; - unsigned int GetVertexCount() const override; + std::size_t GetVertexCount() const override; - bool IsAnimated() const final override; + bool IsAnimated() const final; bool IsValid() const; void SetAABB(const Boxf& aabb); diff --git a/include/Nazara/Utility/Skeleton.hpp b/include/Nazara/Utility/Skeleton.hpp index 75341b9d7..eab57a02b 100644 --- a/include/Nazara/Utility/Skeleton.hpp +++ b/include/Nazara/Utility/Skeleton.hpp @@ -37,21 +37,21 @@ namespace Nz Skeleton(const Skeleton& skeleton); ~Skeleton(); - bool Create(UInt32 jointCount); + bool Create(std::size_t jointCount); void Destroy(); const Boxf& GetAABB() const; Joint* GetJoint(const String& jointName); - Joint* GetJoint(UInt32 index); + Joint* GetJoint(std::size_t index); const Joint* GetJoint(const String& jointName) const; - const Joint* GetJoint(UInt32 index) const; + const Joint* GetJoint(std::size_t index) const; Joint* GetJoints(); const Joint* GetJoints() const; - UInt32 GetJointCount() const; + std::size_t GetJointCount() const; int GetJointIndex(const String& jointName) const; void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation); - void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount); + void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, std::size_t* indices, std::size_t indiceCount); bool IsValid() const; diff --git a/include/Nazara/Utility/StaticMesh.hpp b/include/Nazara/Utility/StaticMesh.hpp index 534157fb6..a1b7c5020 100644 --- a/include/Nazara/Utility/StaticMesh.hpp +++ b/include/Nazara/Utility/StaticMesh.hpp @@ -37,13 +37,13 @@ namespace Nz bool GenerateAABB(); const Boxf& GetAABB() const override; - AnimationType GetAnimationType() const final override; + AnimationType GetAnimationType() const final; const IndexBuffer* GetIndexBuffer() const override; VertexBuffer* GetVertexBuffer(); const VertexBuffer* GetVertexBuffer() const; - unsigned int GetVertexCount() const override; + std::size_t GetVertexCount() const override; - bool IsAnimated() const final override; + bool IsAnimated() const final; bool IsValid() const; void SetAABB(const Boxf& aabb); diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index cfbde074c..19a8aedc5 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -44,14 +44,14 @@ namespace Nz virtual const Boxf& GetAABB() const = 0; virtual AnimationType GetAnimationType() const = 0; virtual const IndexBuffer* GetIndexBuffer() const = 0; - UInt32 GetMaterialIndex() const; + std::size_t GetMaterialIndex() const; PrimitiveMode GetPrimitiveMode() const; - UInt32 GetTriangleCount() const; - virtual UInt32 GetVertexCount() const = 0; + std::size_t GetTriangleCount() const; + virtual std::size_t GetVertexCount() const = 0; virtual bool IsAnimated() const = 0; - void SetMaterialIndex(UInt32 matIndex); + void SetMaterialIndex(std::size_t matIndex); void SetPrimitiveMode(PrimitiveMode mode); SubMesh& operator=(const SubMesh&) = delete; @@ -63,7 +63,7 @@ namespace Nz protected: PrimitiveMode m_primitiveMode; - UInt32 m_matIndex; + std::size_t m_matIndex; }; } diff --git a/include/Nazara/Utility/VertexBuffer.hpp b/include/Nazara/Utility/VertexBuffer.hpp index ca9a20a10..481327a40 100644 --- a/include/Nazara/Utility/VertexBuffer.hpp +++ b/include/Nazara/Utility/VertexBuffer.hpp @@ -26,33 +26,33 @@ namespace Nz public: VertexBuffer() = default; VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer); - VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, UInt32 offset, UInt32 size); - VertexBuffer(VertexDeclarationConstRef vertexDeclaration, UInt32 length, DataStorage storage, BufferUsageFlags usage); + VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, std::size_t offset, std::size_t size); + VertexBuffer(VertexDeclarationConstRef vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage); VertexBuffer(const VertexBuffer& vertexBuffer); VertexBuffer(VertexBuffer&&) = delete; ~VertexBuffer(); - bool Fill(const void* data, UInt32 startVertex, UInt32 length); - bool FillRaw(const void* data, UInt32 offset, UInt32 size); + bool Fill(const void* data, std::size_t startVertex, std::size_t length); + bool FillRaw(const void* data, std::size_t offset, std::size_t size); inline const BufferRef& GetBuffer() const; - inline UInt32 GetEndOffset() const; - inline UInt32 GetStartOffset() const; - inline UInt32 GetStride() const; - inline UInt32 GetVertexCount() const; + inline std::size_t GetEndOffset() const; + inline std::size_t GetStartOffset() const; + inline std::size_t GetStride() const; + inline std::size_t GetVertexCount() const; inline const VertexDeclarationConstRef& GetVertexDeclaration() const; inline bool IsValid() const; - void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0); - void* Map(BufferAccess access, UInt32 startVertex = 0, UInt32 length = 0) const; - void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0); - void* MapRaw(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const; + void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0); + void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0) const; + void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0); + void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0) const; void Reset(); void Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer); - void Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, UInt32 offset, UInt32 size); - void Reset(VertexDeclarationConstRef vertexDeclaration, UInt32 length, DataStorage storage, BufferUsageFlags usage); + void Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, std::size_t offset, std::size_t size); + void Reset(VertexDeclarationConstRef vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage); void Reset(const VertexBuffer& vertexBuffer); void SetVertexDeclaration(VertexDeclarationConstRef vertexDeclaration); @@ -69,9 +69,9 @@ namespace Nz private: BufferRef m_buffer; - UInt32 m_endOffset; - UInt32 m_startOffset; - UInt32 m_vertexCount; + std::size_t m_endOffset; + std::size_t m_startOffset; + std::size_t m_vertexCount; VertexDeclarationConstRef m_vertexDeclaration; }; } diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index 09f701d12..f7091752e 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -12,22 +12,22 @@ namespace Nz return m_buffer; } - inline UInt32 VertexBuffer::GetEndOffset() const + inline std::size_t VertexBuffer::GetEndOffset() const { return m_endOffset; } - inline UInt32 VertexBuffer::GetStride() const + inline std::size_t VertexBuffer::GetStride() const { - return static_cast(m_vertexDeclaration->GetStride()); + return static_cast(m_vertexDeclaration->GetStride()); } - inline UInt32 VertexBuffer::GetStartOffset() const + inline std::size_t VertexBuffer::GetStartOffset() const { return m_startOffset; } - inline UInt32 VertexBuffer::GetVertexCount() const + inline std::size_t VertexBuffer::GetVertexCount() const { return m_vertexCount; } diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 1b0bfbf3a..d76d830a6 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -28,7 +28,7 @@ namespace Nz template SparsePtr GetComponentPtr(VertexComponent component); inline const VertexBuffer* GetVertexBuffer() const; - inline UInt32 GetVertexCount() const; + inline std::size_t GetVertexCount() const; template bool HasComponentOfType(VertexComponent component) const; diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index f3861541c..bdb1edfc2 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -32,7 +32,7 @@ namespace Nz return m_mapper.GetBuffer(); } - inline UInt32 VertexMapper::GetVertexCount() const + inline std::size_t VertexMapper::GetVertexCount() const { return GetVertexBuffer()->GetVertexCount(); } diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 3f1e5200a..79efd69f0 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -74,10 +74,10 @@ void ProcessJoints(aiNode* node, Skeleton* skeleton, const std::set& ProcessJoints(node->mChildren[i], skeleton, joints); } -bool IsSupported(const String& extension) +bool IsSupported(const std::string& extension) { - String dotExt = '.' + extension; - return (aiIsExtensionSupported(dotExt.GetConstBuffer()) == AI_TRUE); + std::string dotExt = '.' + extension; + return (aiIsExtensionSupported(dotExt.data()) == AI_TRUE); } Ternary CheckAnimation(Stream& /*stream*/, const AnimationParams& parameters) @@ -91,10 +91,10 @@ Ternary CheckAnimation(Stream& /*stream*/, const AnimationParams& parameters) AnimationRef LoadAnimation(Stream& stream, const AnimationParams& parameters) { - Nz::String streamPath = stream.GetPath(); + std::string streamPath = stream.GetPath().generic_u8string(); FileIOUserdata userdata; - userdata.originalFilePath = (!streamPath.IsEmpty()) ? streamPath.GetConstBuffer() : StreamPath; + userdata.originalFilePath = (!streamPath.empty()) ? streamPath.data() : StreamPath; userdata.originalStream = &stream; aiFileIO fileIO; @@ -186,10 +186,10 @@ Ternary CheckMesh(Stream& /*stream*/, const MeshParams& parameters) MeshRef LoadMesh(Stream& stream, const MeshParams& parameters) { - Nz::String streamPath = stream.GetPath(); + std::string streamPath = stream.GetPath().generic_u8string(); FileIOUserdata userdata; - userdata.originalFilePath = (!streamPath.IsEmpty()) ? streamPath.GetConstBuffer() : StreamPath; + userdata.originalFilePath = (!streamPath.empty()) ? streamPath.data() : StreamPath; userdata.originalStream = &stream; aiFileIO fileIO; @@ -377,7 +377,7 @@ MeshRef LoadMesh(Stream& stream, const MeshParams& parameters) aiTextureMapMode mapMode[3]; if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS) { - matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); + matData.SetParameter(textureKey, (stream.GetDirectory() / std::string_view(path.data, path.length)).generic_u8string()); if (wrapKey) { @@ -563,7 +563,7 @@ MeshRef LoadMesh(Stream& stream, const MeshParams& parameters) aiTextureMapMode mapMode[3]; if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS) { - matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); + matData.SetParameter(textureKey, (stream.GetDirectory() / std::string_view(path.data, path.length)).generic_u8string()); if (wrapKey) { diff --git a/src/Nazara/Audio/Formats/sndfileLoader.cpp b/src/Nazara/Audio/Formats/sndfileLoader.cpp index 75bb3e62f..5d297fc4f 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.cpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.cpp @@ -14,9 +14,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -99,7 +97,7 @@ namespace Nz return m_format; } - Mutex& GetMutex() override + std::mutex& GetMutex() override { return m_mutex; } @@ -114,11 +112,11 @@ namespace Nz return m_sampleRate; } - bool Open(const String& filePath, bool forceMono) + bool Open(const std::filesystem::path& filePath, bool forceMono) { // Nous devons gérer nous-même le flux car il doit rester ouvert après le passage du loader // (les flux automatiquement ouverts par le ResourceLoader étant fermés après celui-ci) - std::unique_ptr file(new File); + std::unique_ptr file = std::make_unique(); if (!file->Open(filePath, OpenMode_ReadOnly)) { NazaraError("Failed to open stream from file: " + Error::GetLastError()); @@ -219,15 +217,15 @@ namespace Nz AudioFormat m_format; SNDFILE* m_handle; bool m_mixToMono; - Mutex m_mutex; + std::mutex m_mutex; UInt32 m_duration; UInt32 m_sampleRate; UInt64 m_sampleCount; }; - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { - static std::set supportedExtensions = { + static std::set supportedExtensions = { "aiff", "au", "avr", "caf", "flac", "htk", "ircam", "mat4", "mat5", "mpc2k", "nist","ogg", "pvf", "raw", "rf64", "sd2", "sds", "svx", "voc", "w64", "wav", "wve" }; @@ -253,9 +251,9 @@ namespace Nz return Ternary_False; } - SoundStreamRef LoadSoundStreamFile(const String& filePath, const SoundStreamParams& parameters) + SoundStreamRef LoadSoundStreamFile(const std::filesystem::path& filePath, const SoundStreamParams& parameters) { - std::unique_ptr soundStream(new sndfileStream); + std::unique_ptr soundStream = std::make_unique(); if (!soundStream->Open(filePath, parameters.forceMono)) { NazaraError("Failed to open sound stream"); diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index 356b1b51a..85bdc764e 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -5,12 +5,11 @@ #include #include #include -#include -#include -#include #include +#include #include -#include +#include +#include #include #include @@ -29,9 +28,9 @@ namespace Nz ALenum audioFormat; std::atomic processedSamples; std::vector chunkSamples; - Mutex bufferLock; + std::mutex bufferLock; SoundStreamRef stream; - Thread thread; + std::thread thread; UInt64 playingOffset; bool loop = false; bool streaming = false; @@ -142,7 +141,7 @@ namespace Nz NazaraAssert(m_impl, "Music not created"); // Prevent music thread from enqueing new buffers while we're getting the count - Nz::LockGuard lock(m_impl->bufferLock); + std::lock_guard lock(m_impl->bufferLock); ALint samples = 0; alGetSourcei(m_source, AL_SAMPLE_OFFSET, &samples); @@ -215,7 +214,7 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the music */ - bool Music::OpenFromFile(const String& filePath, const SoundStreamParams& params) + bool Music::OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params) { if (SoundStreamRef soundStream = SoundStream::OpenFromFile(filePath, params)) return Create(soundStream); @@ -305,7 +304,7 @@ namespace Nz { // Starting streaming's thread m_impl->streaming = true; - m_impl->thread = Thread(&Music::MusicThread, this); + m_impl->thread = std::thread(&Music::MusicThread, this); } } @@ -351,30 +350,29 @@ namespace Nz { std::size_t sampleCount = m_impl->chunkSamples.size(); std::size_t sampleRead = 0; - - Nz::LockGuard lock(m_impl->stream->GetMutex()); - - m_impl->stream->Seek(m_impl->playingOffset); - - // Fill the buffer by reading from the stream - for (;;) { - sampleRead += m_impl->stream->Read(&m_impl->chunkSamples[sampleRead], sampleCount - sampleRead); - if (sampleRead < sampleCount && m_impl->loop) + std::lock_guard lock(m_impl->stream->GetMutex()); + + m_impl->stream->Seek(m_impl->playingOffset); + + // Fill the buffer by reading from the stream + for (;;) { - // In case we read less than expected, assume we reached the end of the stream and seek back to the beginning - m_impl->stream->Seek(0); - continue; + sampleRead += m_impl->stream->Read(&m_impl->chunkSamples[sampleRead], sampleCount - sampleRead); + if (sampleRead < sampleCount && m_impl->loop) + { + // In case we read less than expected, assume we reached the end of the stream and seek back to the beginning + m_impl->stream->Seek(0); + continue; + } + + // Either we read the size we wanted, either we're not looping + break; } - // Either we read the size we wanted, either we're not looping - break; + m_impl->playingOffset = m_impl->stream->Tell(); } - m_impl->playingOffset = m_impl->stream->Tell(); - - lock.Unlock(); - // Update the buffer (send it to OpenAL) and queue it if we got any data if (sampleRead > 0) { @@ -410,31 +408,31 @@ namespace Nz break; } - Nz::LockGuard lock(m_impl->bufferLock); - - // We treat read buffers - ALint processedCount = 0; - alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &processedCount); - while (processedCount--) { - ALuint buffer; - alSourceUnqueueBuffers(m_source, 1, &buffer); + std::lock_guard lock(m_impl->bufferLock); - ALint bits, size; - alGetBufferi(buffer, AL_BITS, &bits); - alGetBufferi(buffer, AL_SIZE, &size); + // We treat read buffers + ALint processedCount = 0; + alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &processedCount); + while (processedCount--) + { + ALuint buffer; + alSourceUnqueueBuffers(m_source, 1, &buffer); - if (bits != 0) - m_impl->processedSamples += (8 * size) / bits; + ALint bits, size; + alGetBufferi(buffer, AL_BITS, &bits); + alGetBufferi(buffer, AL_SIZE, &size); - if (FillAndQueueBuffer(buffer)) - break; + if (bits != 0) + m_impl->processedSamples += (8 * size) / bits; + + if (FillAndQueueBuffer(buffer)) + break; + } } - lock.Unlock(); - // We go back to sleep - Thread::Sleep(50); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); } // Stop playing of the sound (in the case where it has not been already done) @@ -456,7 +454,7 @@ namespace Nz if (m_impl->streaming) { m_impl->streaming = false; - m_impl->thread.Join(); + m_impl->thread.join(); } } } diff --git a/src/Nazara/Audio/OpenAL.cpp b/src/Nazara/Audio/OpenAL.cpp index 755a68a0b..f9e5b346b 100644 --- a/src/Nazara/Audio/OpenAL.cpp +++ b/src/Nazara/Audio/OpenAL.cpp @@ -41,7 +41,7 @@ namespace Nz std::size_t length; while ((length = std::strlen(deviceString)) > 0) { - devices.push_back(String(deviceString, length)); + devices.emplace_back(deviceString, length); deviceString += length + 1; } @@ -140,7 +140,7 @@ namespace Nz bool succeeded = false; for (const char* path : libs) { - String libPath(path); + std::filesystem::path libPath(path); if (!s_library.Load(libPath)) continue; @@ -248,7 +248,7 @@ namespace Nz } catch (const std::exception& e) { - NazaraWarning(libPath + " loading failed: " + String(e.what())); + NazaraWarning(libPath.generic_u8string() + " loading failed: " + std::string(e.what())); continue; } } diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index d4a9e8e06..707ed3a21 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -149,12 +149,12 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromFile(const String& filePath, const SoundBufferParams& params) + bool Sound::LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::LoadFromFile(filePath, params); if (!buffer) { - NazaraError("Failed to load buffer from file (" + filePath + ')'); + NazaraError("Failed to load buffer from file (" + filePath.generic_u8string() + ')'); return false; } diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index e1570b36e..5641e3e57 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -269,7 +269,7 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the sound buffer */ - SoundBufferRef SoundBuffer::LoadFromFile(const String& filePath, const SoundBufferParams& params) + SoundBufferRef SoundBuffer::LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Audio/SoundStream.cpp b/src/Nazara/Audio/SoundStream.cpp index 0051b5596..6bfdaafbe 100644 --- a/src/Nazara/Audio/SoundStream.cpp +++ b/src/Nazara/Audio/SoundStream.cpp @@ -21,7 +21,7 @@ namespace Nz SoundStream::~SoundStream() = default; - SoundStreamRef SoundStream::OpenFromFile(const String& filePath, const SoundStreamParams& params) + SoundStreamRef SoundStream::OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params) { return SoundStreamLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Core/Clock.cpp b/src/Nazara/Core/Clock.cpp index 13554a1fa..ee7e32acb 100644 --- a/src/Nazara/Core/Clock.cpp +++ b/src/Nazara/Core/Clock.cpp @@ -12,12 +12,6 @@ #error OS not handled #endif -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_CLOCK - #include -#else - #include -#endif - #include namespace Nz @@ -78,8 +72,6 @@ namespace Nz */ UInt64 Clock::GetMicroseconds() const { - NazaraLock(m_mutex); - UInt64 elapsedMicroseconds = m_elapsedTime; if (!m_paused) elapsedMicroseconds += (GetElapsedMicroseconds() - m_refTime); @@ -106,8 +98,6 @@ namespace Nz */ bool Clock::IsPaused() const { - NazaraLock(m_mutex); - return m_paused; } @@ -121,8 +111,6 @@ namespace Nz */ void Clock::Pause() { - NazaraLock(m_mutex); - if (!m_paused) { m_elapsedTime += GetElapsedMicroseconds() - m_refTime; @@ -139,8 +127,6 @@ namespace Nz */ UInt64 Clock::Restart() { - NazaraLock(m_mutex); - Nz::UInt64 now = GetElapsedMicroseconds(); Nz::UInt64 elapsedTime = m_elapsedTime; @@ -164,8 +150,6 @@ namespace Nz */ void Clock::Unpause() { - NazaraLock(m_mutex); - if (m_paused) { m_refTime = GetElapsedMicroseconds(); diff --git a/src/Nazara/Core/ConditionVariable.cpp b/src/Nazara/Core/ConditionVariable.cpp deleted file mode 100644 index f4314870c..000000000 --- a/src/Nazara/Core/ConditionVariable.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_POSIX) - #include -#else - #error Condition variable has no implementation -#endif - -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::ConditionVariable - * \brief Core class that represents a condition variable - * - * The ConditionVariable class is a synchronization primitive that can be used to block a thread, or multiple threads at the same time, until another thread both modifies a shared variable (the condition), and notifies the ConditionVariable - */ - - /*! - * \brief Constructs a ConditionVariable object by default - */ - - ConditionVariable::ConditionVariable() - { - m_impl = new ConditionVariableImpl; - } - - /*! - * \brief Destructs the object - */ - - ConditionVariable::~ConditionVariable() - { - delete m_impl; - } - - /*! - * \brief Sends a signal to one thread waiting on the condition - * - * If any threads are waiting on *this, calling Signal unblocks one of the waiting threads - * - * \see SignalAll - */ - - void ConditionVariable::Signal() - { - m_impl->Signal(); - } - - /*! - * \brief Sends a signal to every threads waiting on the condition - * - * Unblocks all threads currently waiting for *this - * - * \see Signal - */ - - void ConditionVariable::SignalAll() - { - m_impl->SignalAll(); - } - - /*! - * \brief Makes the thread wait on the condition - * - * Wait causes the current thread to block until the condition variable is notified or a spurious wakeup occurs - * - * \param mutex Mutex for the condition - * - * \remark Produces a NazaraAssert if mutex is invalid - */ - - void ConditionVariable::Wait(Mutex* mutex) - { - NazaraAssert(mutex != nullptr, "Mutex must be valid"); - m_impl->Wait(mutex->m_impl); - } - - /*! - * \brief Makes the thread wait on the condition for a certain amount of time - * - * Wait causes the current thread to block until the condition variable is notified, a specific time is reached, or a spurious wakeup occurs - * - * \param mutex Mutex for the condition - * \param timeout Time before expiration of the waiting - * - * \remark Produces a NazaraAssert if mutex is invalid - */ - - bool ConditionVariable::Wait(Mutex* mutex, UInt32 timeout) - { - NazaraAssert(mutex != nullptr, "Mutex must be valid"); - return m_impl->Wait(mutex->m_impl, timeout); - } -} diff --git a/src/Nazara/Core/Directory.cpp b/src/Nazara/Core/Directory.cpp deleted file mode 100644 index 04a2eeb94..000000000 --- a/src/Nazara/Core/Directory.cpp +++ /dev/null @@ -1,535 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_POSIX) - #include -#else - #error OS not handled -#endif - -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DIRECTORY - #include -#else - #include -#endif - -#include - -namespace Nz -{ - namespace - { - //FIXME: MinGW seems to dislike thread_local shared_ptr.. (using a std::string is a working hackfix) - thread_local std::string currentPath(DirectoryImpl::GetCurrent().ToStdString()); - } - - /*! - * \ingroup core - * \class Nz::Directory - * \brief Core class that represents a directory - */ - - /*! - * \brief Constructs a Directory object by default - */ - - Directory::Directory() : - m_pattern('*'), - m_impl(nullptr) - { - } - - /*! - * \brief Constructs a Directory object with a path - * - * \param dirPath Path to the directory - */ - - Directory::Directory(const String& dirPath) : - m_dirPath(dirPath), - m_pattern('*'), - m_impl(nullptr) - { - } - - /*! - * \brief Destructs the object and calls Close - * - * \see Close - */ - - Directory::~Directory() - { - Close(); - } - - /*! - * \brief Closes the directory - */ - - void Directory::Close() - { - NazaraLock(m_mutex); - - if (m_impl) - { - m_impl->Close(); - delete m_impl; - m_impl = nullptr; - } - } - - /*! - * \brief Checks whether the directory exists - * \return true if directory exists - */ - - bool Directory::Exists() const - { - NazaraLock(m_mutex); - - if (IsOpen()) - return true; // If directory is open, then it exists - else - return Exists(m_dirPath); - } - - /*! - * \brief Gets the path of the directory - * \return Path of the directory - */ - - String Directory::GetPath() const - { - NazaraLock(m_mutex); - - return m_dirPath; - } - - /*! - * \brief Gets the pattern for the path of the directory - * \return Pattern for the path of the directory - */ - - String Directory::GetPattern() const - { - NazaraLock(m_mutex); - - return m_pattern; - } - - /*! - * \brief Gets the result name of the directory - * \return Resulting name - * - * \remark Produces a NazaraError if directory is not open with NAZARA_CORE_SAFE defined - */ - - String Directory::GetResultName() const - { - NazaraLock(m_mutex); - - #if NAZARA_CORE_SAFE - if (!IsOpen()) - { - NazaraError("Directory not opened"); - return String(); - } - #endif - - return m_impl->GetResultName(); - } - - /*! - * \brief Gets the result path of the directory - * \return Resulting path - * - * \remark Produces a NazaraError if directory is not open with NAZARA_CORE_SAFE defined - */ - - String Directory::GetResultPath() const - { - NazaraLock(m_mutex); - - #if NAZARA_CORE_SAFE - if (!IsOpen()) - { - NazaraError("Directory not opened"); - return String(); - } - #endif - - return m_dirPath + NAZARA_DIRECTORY_SEPARATOR + m_impl->GetResultName(); - } - - /*! - * \brief Gets the resulting size of the directory - * \return Size of the directory - * - * \remark Produces a NazaraError if directory is not open with NAZARA_CORE_SAFE defined - */ - - UInt64 Directory::GetResultSize() const - { - NazaraLock(m_mutex); - - #if NAZARA_CORE_SAFE - if (!IsOpen()) - { - NazaraError("Directory not opened"); - return 0; - } - #endif - - return m_impl->GetResultSize(); - } - - /*! - * \brief Checks whether the directory is open - * \return true if open - */ - - bool Directory::IsOpen() const - { - NazaraLock(m_mutex); - - return m_impl != nullptr; - } - - /*! - * \brief Checks whether the directory is result - * \return true if result - * - * \remark Produces a NazaraError if directory is not open with NAZARA_CORE_SAFE defined - */ - - bool Directory::IsResultDirectory() const - { - NazaraLock(m_mutex); - - #if NAZARA_CORE_SAFE - if (!IsOpen()) - { - NazaraError("Directory not opened"); - return false; - } - #endif - - return m_impl->IsResultDirectory(); - } - - /*! - * \brief Sets the next result in the directory - * \return true if directory has a next result - * - * \param skipDots Skips the dots in the path - * - * \remark Produces a NazaraError if directory is not open with NAZARA_CORE_SAFE defined - */ - - bool Directory::NextResult(bool skipDots) - { - NazaraLock(m_mutex); - - #if NAZARA_CORE_SAFE - if (!IsOpen()) - { - NazaraError("Directory not opened"); - return false; - } - #endif - - String name; - for (;;) - { - if (!m_impl->NextResult()) - return false; - - name = m_impl->GetResultName(); - - if (skipDots && (name == '.' || name == "..")) - continue; - - if (name.Match(m_pattern)) - break; - } - - return true; - } - - /*! - * \brief Opens the directory - * \return true if opening is successful - */ - - bool Directory::Open() - { - NazaraLock(m_mutex); - - Close(); - - if (!Exists(m_dirPath)) - return false; - - m_impl = new DirectoryImpl(this); - if (!m_impl->Open(m_dirPath)) - { - delete m_impl; - m_impl = nullptr; - - return false; - } - - return true; - } - - /*! - * \brief Sets the path of the directory - * - * \param dirPath Path of the directory - */ - - void Directory::SetPath(const String& dirPath) - { - NazaraLock(m_mutex); - - Close(); - - m_dirPath = File::AbsolutePath(dirPath); - } - - /*! - * \brief Sets the pattern of the directory - * - * \param pattern Pattern of the directory - */ - - void Directory::SetPattern(const String& pattern) - { - NazaraLock(m_mutex); - - m_pattern = pattern; - } - - /*! - * \brief Copies the first directory to a new directory path - * \return true if copy is successful - * - * \param sourcePath Path of the original directory - * \param destPath Path of the copied directory - * - * \remark Produces a NazaraError if could not create destination directory - * \remark Produces a NazaraError if could not open origin directory - * \remark Produces a NazaraError if could not copy a file - */ - - bool Directory::Copy(const String& sourcePath, const String& destPath) - { - if (sourcePath.IsEmpty() || destPath.IsEmpty()) - return false; - - String dirPath(sourcePath); - String dest(File::NormalizePath(destPath)); - - if (!Create(destPath, true)) - { - NazaraError("Unable to create \"" + destPath + '"'); - return false; - } - - Directory dir(dirPath); - if (!dir.Open()) - { - NazaraError("Unable to open \"" + destPath + '"'); - return false; - } - - while (dir.NextResult(true)) - { - if (dir.IsResultDirectory()) - { - if (!Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName())) - return false; - } - else if (!File::Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName())) - { - NazaraError("Failed to copy \"" + dir.GetResultPath() + "\" to \"" + dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName() + '"'); - return false; - } - } - - dir.Close(); - - return true; - } - - /*! - * \brief Creates a directory from a path - * \return true if creation is successful - * - * \param dirPath Path of the directory - * \param recursive Creates subdirectories - */ - - bool Directory::Create(const String& dirPath, bool recursive) - { - if (dirPath.IsEmpty()) - return false; - - if (recursive) - { - String path = File::NormalizePath(dirPath); - std::size_t foundPos = path.Find(NAZARA_DIRECTORY_SEPARATOR); - if (foundPos == String::npos) - return false; - - #ifdef NAZARA_PLATFORM_WINDOWS - // Unlike to disk (Ex: "C:"), the network path is not considered as a directory (Ex: "\\Laptop") - if (path.Match("\\\\*")) - { - foundPos = path.Find('\\', 2); - if (foundPos == String::npos) - return false; - - foundPos = path.Find('\\', foundPos + 1); - if (foundPos == String::npos) - return false; - } - #endif - - for (;;) - { - String p = path.SubString(0, foundPos); - if (p.EndsWith(NAZARA_DIRECTORY_SEPARATOR)) - p = p.SubString(0, -2); - - if (!p.IsEmpty()) - { - if (!DirectoryImpl::Exists(p) && !DirectoryImpl::Create(p)) - return false; - - if (foundPos == String::npos) - break; - } - - foundPos = path.Find(NAZARA_DIRECTORY_SEPARATOR, foundPos + 1); - } - - return true; - } - else - return DirectoryImpl::Create(File::NormalizePath(dirPath)); - } - - /*! - * \brief Checks whether the directory exists - * \return true if directory exists - * - * \param dirPath Path of the directory - */ - - bool Directory::Exists(const String& dirPath) - { - if (dirPath.IsEmpty()) - return false; - - return DirectoryImpl::Exists(File::NormalizePath(dirPath)); - } - - /*! - * \brief Gets the current path of this directory - * \return Current path - */ - - String Directory::GetCurrent() - { - return currentPath; - } - - /*! - * \brief Gets this current file relative to the engine - * \return Path to this file - */ - - const char* Directory::GetCurrentFileRelativeToEngine(const char* currentFile) - { - ///FIXME: Is this method in the right place ? - const char* ptr = std::strstr(currentFile, "NazaraEngine/"); - if (!ptr) - ptr = std::strstr(currentFile, "NazaraEngine\\"); - - if (!ptr) - ptr = currentFile; - - return ptr; - } - - /*! - * \brief Removes the directory - * \return true if remove is successful - * - * \param dirPath Path of the directory - * \param emptyDirectory Remove recursively - */ - - bool Directory::Remove(const String& dirPath, bool emptyDirectory) - { - if (dirPath.IsEmpty()) - return false; - - if (emptyDirectory) - { - Directory dir(dirPath); - if (!dir.Open()) - return DirectoryImpl::Remove(dirPath); // If we can't open the directory, we try to delete it - - while (dir.NextResult(true)) - { - if (dir.IsResultDirectory()) - { - if (!Remove(dir.GetResultPath(), true)) - return false; - } - else if (!File::Delete(dir.GetResultPath())) - { - NazaraError(dir.GetResultPath()); - return false; - } - } - - dir.Close(); - } - - return DirectoryImpl::Remove(File::NormalizePath(dirPath)); - } - - /*! - * \brief Sets the current directory - * \return true if directory path exists - * - * \param dirPath Path of the directory - */ - - bool Directory::SetCurrent(const String& dirPath) - { - String path = File::AbsolutePath(dirPath); - if (DirectoryImpl::Exists(path)) - { - currentPath = path.ToStdString(); - return true; - } - else - return false; - } -} diff --git a/src/Nazara/Core/DynLib.cpp b/src/Nazara/Core/DynLib.cpp index 1558f5a37..486d628b8 100644 --- a/src/Nazara/Core/DynLib.cpp +++ b/src/Nazara/Core/DynLib.cpp @@ -15,12 +15,6 @@ #error No implementation for this platform #endif -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DYNLIB - #include -#else - #include -#endif - #include namespace Nz @@ -31,35 +25,16 @@ namespace Nz * \brief Core class that represents a dynamic library loader */ - /*! - * \brief Constructs a DynLib object by default - */ - - DynLib::DynLib() : - m_impl(nullptr) - { - } - - /*! - * \brief Destructs the object and calls Unload - * - * \see Unload - */ - - DynLib::~DynLib() - { - Unload(); - } + DynLib::DynLib() = default; + DynLib::DynLib(DynLib&&) noexcept = default; + DynLib::~DynLib() = default; /*! * \brief Gets the last error * \return Last error */ - - String DynLib::GetLastError() const + std::string DynLib::GetLastError() const { - NazaraLock(m_mutex) - return m_lastError; } @@ -69,11 +44,8 @@ namespace Nz * * \remark Produces a NazaraError if library is not loaded with NAZARA_CORE_SAFE defined */ - - DynLibFunc DynLib::GetSymbol(const String& symbol) const + DynLibFunc DynLib::GetSymbol(const char* symbol) const { - NazaraLock(m_mutex) - #if NAZARA_CORE_SAFE if (!IsLoaded()) { @@ -89,7 +61,6 @@ namespace Nz * \brief Checks whether the library is loaded * \return true if loaded */ - bool DynLib::IsLoaded() const { return m_impl != nullptr; @@ -103,38 +74,28 @@ namespace Nz * * \remark Produces a NazaraError if library is could not be loaded */ - - bool DynLib::Load(const String& libraryPath) + bool DynLib::Load(const std::filesystem::path& libraryPath) { - NazaraLock(m_mutex) - Unload(); - std::unique_ptr impl(new DynLibImpl(this)); + auto impl = std::make_unique(this); if (!impl->Load(libraryPath, &m_lastError)) { NazaraError("Failed to load library: " + m_lastError); return false; } - m_impl = impl.release(); - + m_impl = std::move(impl); return true; } /*! * \brief Unloads the library */ - void DynLib::Unload() { - NazaraLock(m_mutex) - - if (IsLoaded()) - { - m_impl->Unload(); - delete m_impl; - m_impl = nullptr; - } + m_impl.reset(); } + + DynLib& DynLib::operator=(DynLib&&) noexcept = default; } diff --git a/src/Nazara/Core/Error.cpp b/src/Nazara/Core/Error.cpp index b5c689971..424a898d0 100644 --- a/src/Nazara/Core/Error.cpp +++ b/src/Nazara/Core/Error.cpp @@ -3,8 +3,9 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include +#include #include #include @@ -82,25 +83,21 @@ namespace Nz * \param code Code of the error */ - String Error::GetLastSystemError(unsigned int code) + std::string Error::GetLastSystemError(unsigned int code) { #if defined(NAZARA_PLATFORM_WINDOWS) wchar_t* buffer = nullptr; FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, - code, - 0, - reinterpret_cast(&buffer), - 0, - nullptr); + nullptr, + code, + 0, + reinterpret_cast(&buffer), + 0, + nullptr); - String error(String::Unicode(buffer)); - LocalFree(buffer); - - error.Trim(); // For an unknown reason, Windows put two-three line return after the message - - return error; + CallOnExit freeOnExit([buffer] { LocalFree(buffer); }); + return FromWideString(buffer); #elif defined(NAZARA_PLATFORM_POSIX) return std::strerror(code); #else @@ -166,7 +163,7 @@ namespace Nz void Error::Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function) { - file = Nz::Directory::GetCurrentFileRelativeToEngine(file); + file = GetCurrentFileRelativeToEngine(file); if (type == ErrorType_AssertFailed || (s_flags & ErrorFlag_Silent) == 0 || (s_flags & ErrorFlag_SilentDisabled) != 0) Log::WriteError(type, error, line, file, function); @@ -186,6 +183,17 @@ namespace Nz throw std::runtime_error(error.ToStdString()); } + const char* Error::GetCurrentFileRelativeToEngine(const char* file) + { + if (const char* ptr = std::strstr(file, "NazaraEngine/")) + return ptr; + + if (const char* ptr = std::strstr(file, "NazaraEngine\\")) + return ptr; + + return file; + } + UInt32 Error::s_flags = ErrorFlag_None; String Error::s_lastError; const char* Error::s_lastErrorFunction = ""; diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 6181f7d1b..c11b92c1f 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -19,12 +18,6 @@ #error OS not handled #endif -#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE - #include -#else - #include -#endif - #include namespace Nz @@ -39,10 +32,7 @@ namespace Nz * \brief Constructs a File object by default */ - File::File() : - m_impl(nullptr) - { - } + File::File() = default; /*! * \brief Constructs a File object with a file path @@ -50,7 +40,7 @@ namespace Nz * \param filePath Path to the file */ - File::File(const String& filePath) : + File::File(const std::filesystem::path& filePath) : File() { SetFile(filePath); @@ -63,7 +53,7 @@ namespace Nz * \param openMode Flag of the file */ - File::File(const String& filePath, OpenModeFlags openMode) : + File::File(const std::filesystem::path& filePath, OpenModeFlags openMode) : File() { Open(filePath, openMode); @@ -75,6 +65,8 @@ namespace Nz * \see Close */ + File::File(File&& file) noexcept = default; + File::~File() { Close(); @@ -82,14 +74,12 @@ namespace Nz /*! * \brief Copies this file to a new file path - * \return true if copy is successful * * \param newFilePath Path of the new file */ - - bool File::Copy(const String& newFilePath) + void File::Copy(const std::filesystem::path& newFilePath) { - return Copy(m_filePath, newFilePath); + std::filesystem::copy(m_filePath, newFilePath); } /*! @@ -98,13 +88,9 @@ namespace Nz void File::Close() { - NazaraLock(m_mutex) - if (m_impl) { - m_impl->Close(); - delete m_impl; - m_impl = nullptr; + m_impl.reset(); m_openMode = OpenMode_NotOpen; } @@ -117,11 +103,9 @@ namespace Nz bool File::Delete() { - NazaraLock(m_mutex) - Close(); - return Delete(m_filePath); + return std::filesystem::remove(m_filePath); } /*! @@ -133,8 +117,6 @@ namespace Nz bool File::EndOfFile() const { - NazaraLock(m_mutex) - #if NAZARA_CORE_SAFE if (!IsOpen()) { @@ -167,24 +149,10 @@ namespace Nz bool File::Exists() const { - NazaraLock(m_mutex) - if (IsOpen()) return true; // Le fichier est ouvert, donc il existe else - return Exists(m_filePath); - } - - /*! - * \brief Gets the creation time of the file - * \return Information about the creation time - */ - - time_t File::GetCreationTime() const - { - NazaraLock(m_mutex) - - return GetCreationTime(m_filePath); + return std::filesystem::exists(m_filePath); } /*! @@ -196,8 +164,6 @@ namespace Nz UInt64 File::GetCursorPos() const { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); return m_impl->GetCursorPos(); @@ -207,72 +173,32 @@ namespace Nz * \brief Gets the directory of the file * \return Directory of the file */ - - String File::GetDirectory() const + std::filesystem::path File::GetDirectory() const { - NazaraLock(m_mutex) - - return m_filePath.SubStringTo(NAZARA_DIRECTORY_SEPARATOR, -1, true, true); + return m_filePath.parent_path(); } /*! * \brief Gets the name of the file * \return Name of the file */ - - String File::GetFileName() const + std::filesystem::path File::GetFileName() const { - NazaraLock(m_mutex) - - return m_filePath.SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true); - } - - /*! - * \brief Gets the last time the file was accessed - * \return Information about the last access time - */ - - time_t File::GetLastAccessTime() const - { - NazaraLock(m_mutex) - - return GetLastAccessTime(m_filePath); - } - - /*! - * \brief Gets the last time the file was written - * \return Information about the last writing time - */ - - time_t File::GetLastWriteTime() const - { - NazaraLock(m_mutex) - - return GetLastWriteTime(m_filePath); + return m_filePath.filename(); } /*! * \brief Gets the path of the file * \return Path of the file */ - - String File::GetPath() const + std::filesystem::path File::GetPath() const { - NazaraLock(m_mutex) - return m_filePath; } - /*! - * \brief Gets the size of the file - * \return Size of the file - */ - UInt64 File::GetSize() const { - NazaraLock(m_mutex) - - return GetSize(m_filePath); + return std::filesystem::file_size(m_filePath); } /*! @@ -282,8 +208,6 @@ namespace Nz bool File::IsOpen() const { - NazaraLock(m_mutex) - return m_impl != nullptr; } @@ -298,26 +222,24 @@ namespace Nz bool File::Open(OpenModeFlags openMode) { - NazaraLock(m_mutex) - Close(); - if (m_filePath.IsEmpty()) + if (m_filePath.empty()) return false; if (openMode == OpenMode_NotOpen) return false; - std::unique_ptr impl(new FileImpl(this)); + std::unique_ptr impl = std::make_unique(this); if (!impl->Open(m_filePath, openMode)) { ErrorFlags flags(ErrorFlag_Silent); // Silent by default - NazaraError("Failed to open \"" + m_filePath + "\": " + Error::GetLastSystemError()); + NazaraError("Failed to open \"" + m_filePath.generic_u8string() + "\": " + Error::GetLastSystemError()); return false; } m_openMode = openMode; - m_impl = impl.release(); + m_impl = std::move(impl); if (m_openMode & OpenMode_Text) m_streamOptions |= StreamOption_Text; @@ -337,38 +259,14 @@ namespace Nz * \remark Produces a NazaraError if OS error to open a file */ - bool File::Open(const String& filePath, OpenModeFlags openMode) + bool File::Open(const std::filesystem::path& filePath, OpenModeFlags openMode) { - NazaraLock(m_mutex) - Close(); SetFile(filePath); return Open(openMode); } - /*! - * \brief Renames the file with a new name - * \return true if rename is successful - */ - - bool File::Rename(const String& newFilePath) - { - NazaraLock(m_mutex) - - bool open = IsOpen(); - Close(); - - bool success = Rename(m_filePath, newFilePath); - if (success) - m_filePath = NormalizePath(newFilePath); - - if (open) - Open(); - - return success; - } - /*! * \brief Sets the position of the cursor * \return true if cursor is successfully positioned @@ -381,8 +279,6 @@ namespace Nz bool File::SetCursorPos(CursorPosition pos, Int64 offset) { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); return m_impl->SetCursorPos(pos, offset); @@ -399,8 +295,6 @@ namespace Nz bool File::SetCursorPos(UInt64 offset) { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); return m_impl->SetCursorPos(CursorPosition_AtBegin, offset); @@ -413,29 +307,24 @@ namespace Nz * \remark Produces a NazaraError if file path can not be open */ - bool File::SetFile(const String& filePath) + bool File::SetFile(const std::filesystem::path& filePath) { - NazaraLock(m_mutex) - if (IsOpen()) { - if (filePath.IsEmpty()) + if (filePath.empty()) return false; - std::unique_ptr impl(new FileImpl(this)); + std::unique_ptr impl = std::make_unique(this); if (!impl->Open(filePath, m_openMode)) { NazaraError("Failed to open new file; " + Error::GetLastSystemError()); return false; } - m_impl->Close(); - delete m_impl; - - m_impl = impl.release(); + m_impl = std::move(impl); } - m_filePath = AbsolutePath(filePath); + m_filePath = std::filesystem::absolute(filePath); return true; } @@ -450,317 +339,13 @@ namespace Nz */ bool File::SetSize(UInt64 size) { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); NazaraAssert(IsWritable(), "File is not writable"); return m_impl->SetSize(size); } - /*! - * \brief Sets the file path - * \return A reference to this - * - * \remark Produces a NazaraError if file path can not be open - */ - - File& File::operator=(const String& filePath) - { - SetFile(filePath); - - return *this; - } - - /*! - * \brief Gets the absolute path of the file - * \return Absolute path of the file - * - * \param filePath Path of the file - * - * \remark Produces a NazaraError if filePath is weird with NAZARA_PLATFORM_WINDOWS defined - */ - - String File::AbsolutePath(const String& filePath) - { - // We don't use OS functions because they only work for existing path - String path = NormalizePath(filePath); - if (path.IsEmpty()) - return String(); - - String base; - unsigned int start; - #ifdef NAZARA_PLATFORM_WINDOWS - if (path.Match("?:*")) - start = 1; - else if (path.Match("\\\\*")) - { - base = "\\\\"; - start = 2; - } - else if (path.StartsWith('\\')) // Special : '\' refering to root - { - String drive = Directory::GetCurrent().SubStringTo('\\'); - String end = path.SubString(1, -1); - if (end.IsEmpty()) - path = drive; - else - path = drive + '\\' + end; - - start = 1; - } - else - { - NazaraError("Path unrecognized"); - return path; - } - #elif defined(NAZARA_PLATFORM_POSIX) - base = '/'; - start = 0; - #else - #error OS case not implemented - #endif - - static String upDir = NAZARA_DIRECTORY_SEPARATOR + String('.'); - - if (path.Find(upDir) == String::npos) - return path; - - std::vector sep; - if (path.Split(sep, NAZARA_DIRECTORY_SEPARATOR) <= 1) - return path; - - // We have the absolute path, but we need to clean it up - for (unsigned int i = 0; i < sep.size(); ++i) - { - if (sep[i] == '.') - sep.erase(sep.begin() + i--); - else if (sep[i] == "..") - { - if (i > start) // If we are not in the protected area - sep.erase(sep.begin() + i--); - - sep.erase(sep.begin() + i--); - } - } - - StringStream stream(base); - for (unsigned int i = 0; i < sep.size(); ++i) - { - if (i != sep.size()-1) - stream << sep[i] << NAZARA_DIRECTORY_SEPARATOR; - else - stream << sep[i]; - } - - return stream; - } - - /*! - * \brief Copies the first file to a new file path - * \return true if copy is successful - * - * \param sourcePath Path of the original file - * \param targetPath Path of the copied file - */ - - bool File::Copy(const String& sourcePath, const String& targetPath) - { - if (sourcePath.IsEmpty() || targetPath.IsEmpty()) - return false; - - return FileImpl::Copy(NormalizePath(sourcePath), NormalizePath(targetPath)); - } - - /*! - * \brief Deletes the file - * \return true if delete is successful - * - * \param filePath Path of the file - */ - - bool File::Delete(const String& filePath) - { - if (filePath.IsEmpty()) - return false; - - return FileImpl::Delete(NormalizePath(filePath)); - } - - /*! - * \brief Checks whether the file exists - * \return true if file exists - * - * \param filePath Path of the file - */ - - bool File::Exists(const String& filePath) - { - if (filePath.IsEmpty()) - return false; - - return FileImpl::Exists(NormalizePath(filePath)); - } - - /*! - * \brief Gets the creation time of the file - * \return Information about the creation time - * - * \param filePath Path of the file - */ - - time_t File::GetCreationTime(const String& filePath) - { - if (filePath.IsEmpty()) - return 0; - - return FileImpl::GetCreationTime(NormalizePath(filePath)); - } - - /*! - * \brief Gets the directory of the file - * \return Directory of the file - * - * \param filePath Path of the file - */ - - String File::GetDirectory(const String& filePath) - { - return filePath.SubStringTo(NAZARA_DIRECTORY_SEPARATOR, -1, true, true); - } - /*! - * \brief Gets the last time the file was accessed - * \return Information about the last access time - * - * \param filePath Path of the file - */ - - time_t File::GetLastAccessTime(const String& filePath) - { - if (filePath.IsEmpty()) - return 0; - - return FileImpl::GetLastAccessTime(NormalizePath(filePath)); - } - - /*! - * \brief Gets the last time the file was written - * \return Information about the last writing time - * - * \param filePath Path of the file - */ - - time_t File::GetLastWriteTime(const String& filePath) - { - if (filePath.IsEmpty()) - return 0; - - return FileImpl::GetLastWriteTime(NormalizePath(filePath)); - } - - /*! - * \brief Gets the size of the file - * \return Size of the file - * - * \param filePath Path of the file - */ - - UInt64 File::GetSize(const String& filePath) - { - if (filePath.IsEmpty()) - return 0; - - return FileImpl::GetSize(NormalizePath(filePath)); - } - - /*! - * \brief Checks whether the file path is absolute - * \return true if path is absolute - * - * \param filePath Path to test - */ - - bool File::IsAbsolute(const String& filePath) - { - String path(filePath.Trimmed()); - if (path.IsEmpty()) - return false; - - path = NormalizeSeparators(path); - - #ifdef NAZARA_PLATFORM_WINDOWS - if (path.Match("?:*")) // Ex: C:\Hello - return true; - else if (path.Match("\\\\*")) // Ex: \\Laptop - return true; - else if (path.StartsWith('\\')) // Special : '\' referring to the root - return true; - else - return false; - #elif defined(NAZARA_PLATFORM_POSIX) - return path.StartsWith('/'); - #else - #error OS case not implemented - #endif - } - - /*! - * \brief Normalizes the file path - * \return Path normalized (replacing '/' with '\\' on Windows, ...) - * - * \param filePath Path to normalize - */ - - String File::NormalizePath(const String& filePath) - { - String path = NormalizeSeparators(filePath.Trimmed()); - - if (!IsAbsolute(path)) - path = Directory::GetCurrent() + NAZARA_DIRECTORY_SEPARATOR + path; - - while (path.EndsWith(NAZARA_DIRECTORY_SEPARATOR)) - path.Resize(-1); - - return path; - } - - /*! - * \brief Normalizes the path separator - * \return Path normalized (replacing '/' with '\\' on Windows, ...) - * - * \param filePath Path to normalize - */ - - String File::NormalizeSeparators(const String& filePath) - { - String path(filePath); - - #if defined(NAZARA_PLATFORM_WINDOWS) - path.Replace('/', '\\'); - #elif defined(NAZARA_PLATFORM_LINUX) - path.Replace('\\', '/'); - #else - #error OS case not implemented - #endif - - return path; - } - - /*! - * \brief Renames the file with a new name - * \return true if rename is successful - * - * \param sourcePath Path of the original file - * \param targetPath Path of the renamed file - */ - - bool File::Rename(const String& sourcePath, const String& targetPath) - { - if (sourcePath.IsEmpty() || targetPath.IsEmpty()) - return false; - - return FileImpl::Rename(NormalizePath(sourcePath), NormalizePath(targetPath)); - } + File& File::operator=(File&& file) noexcept = default; /*! * \brief Flushes the stream @@ -770,8 +355,6 @@ namespace Nz void File::FlushStream() { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); m_impl->Flush(); @@ -789,8 +372,6 @@ namespace Nz std::size_t File::ReadBlock(void* buffer, std::size_t size) { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); if (size == 0) @@ -822,8 +403,6 @@ namespace Nz std::size_t File::WriteBlock(const void* buffer, std::size_t size) { - NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); if (size == 0) diff --git a/src/Nazara/Core/FileLogger.cpp b/src/Nazara/Core/FileLogger.cpp index 6dadfdcf1..3d4b4a0f9 100644 --- a/src/Nazara/Core/FileLogger.cpp +++ b/src/Nazara/Core/FileLogger.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -25,7 +27,7 @@ namespace Nz */ FileLogger::FileLogger(const String& logPath) : - m_outputFile(logPath), + m_outputPath(logPath.ToStdString()), m_forceStdOutput(false), m_stdReplicationEnabled(true), m_timeLoggingEnabled(true) @@ -107,9 +109,10 @@ namespace Nz m_forceStdOutput = false; }); - if (!m_outputFile.IsOpen()) + if (!m_outputFile.is_open()) { - if (!m_outputFile.Open(OpenMode_Text | OpenMode_Truncate | OpenMode_WriteOnly)) + m_outputFile.open(m_outputPath, std::ios_base::trunc | std::ios_base::out); + if (!m_outputFile.is_open()) { NazaraError("Failed to open output file"); return; @@ -117,7 +120,7 @@ namespace Nz } // Apply some processing before writing - StringStream stream; + std::ostringstream stream; if (m_timeLoggingEnabled) { std::array buffer; @@ -130,7 +133,7 @@ namespace Nz stream << string << '\n'; - m_outputFile.Write(stream); + m_outputFile << stream.str(); } /*! @@ -148,6 +151,6 @@ namespace Nz void FileLogger::WriteError(ErrorType type, const String& error, unsigned int line, const char* file, const char* function) { AbstractLogger::WriteError(type, error, line, file, function); - m_outputFile.Flush(); + m_outputFile.flush(); } } diff --git a/src/Nazara/Core/Mutex.cpp b/src/Nazara/Core/Mutex.cpp deleted file mode 100644 index 473ee233e..000000000 --- a/src/Nazara/Core/Mutex.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_POSIX) - #include -#else - #error Lack of implementation: Mutex -#endif - -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::Mutex - * \brief Core class that represents a binary semaphore, a mutex - * - * \remark The mutex is recursive, it means that a thread who owns the mutex can call the same function which needs the same mutex - */ - - /*! - * \brief Constructs a Mutex object by default - */ - - Mutex::Mutex() - { - m_impl = new MutexImpl; - } - - /*! - * \brief Destructs the object - */ - - Mutex::~Mutex() - { - delete m_impl; - } - - /*! - * \brief Locks the mutex - * - * If another thread has already locked the mutex, a call to lock will block execution until the lock is acquired. A thread may call lock on a recursive mutex repeatedly. Ownership will only be released after the thread makes a matching number of calls to unlock - */ - - void Mutex::Lock() - { - NazaraAssert(m_impl, "Cannot lock a moved mutex"); - m_impl->Lock(); - } - - /*! - * \brief Tries to lock the mutex - * \return true if the lock was acquired successfully - */ - - bool Mutex::TryLock() - { - NazaraAssert(m_impl, "Cannot lock a moved mutex"); - return m_impl->TryLock(); - } - - /*! - * \brief Unlocks the mutex - * - * Unlocks the mutex if its level of ownership is 1 (there was exactly one more call to Lock() than there were calls to Unlock() made by this thread), reduces the level of ownership by 1 otherwise - */ - - void Mutex::Unlock() - { - NazaraAssert(m_impl, "Cannot unlock a moved mutex"); - m_impl->Unlock(); - } -} diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index 14bc6744e..8d0769c5e 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -3,10 +3,8 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include -#include #include #include @@ -17,7 +15,7 @@ namespace Nz using PluginLoad = int (*)(); using PluginUnload = void (*)(); - String s_pluginFiles[] = + std::filesystem::path s_pluginFiles[] = { "PluginAssimp", // Plugin_Assimp }; @@ -37,7 +35,7 @@ namespace Nz * \remark Produces a NazaraError if not initialized */ - void PluginManager::AddDirectory(const String& directoryPath) + void PluginManager::AddDirectory(const std::filesystem::path& directoryPath) { if (!Initialize()) { @@ -45,7 +43,7 @@ namespace Nz return; } - s_directories.insert(File::AbsolutePath(directoryPath)); + s_directories.insert(std::filesystem::absolute(directoryPath)); } /*! @@ -79,9 +77,13 @@ namespace Nz bool PluginManager::Mount(Plugin plugin) { - Nz::String pluginName = s_pluginFiles[plugin]; + std::filesystem::path pluginName = s_pluginFiles[plugin]; + #ifdef NAZARA_DEBUG - if (Mount(pluginName + "-d", true)) + std::filesystem::path debugPath = pluginName; + debugPath += "-d"; + + if (Mount(debugPath, true)) return true; #endif @@ -102,7 +104,7 @@ namespace Nz * \remark Produces a NazaraError if fail to initialize the plugin with PluginLoad */ - bool PluginManager::Mount(const String& pluginPath, bool appendExtension) + bool PluginManager::Mount(const std::filesystem::path& pluginPath, bool appendExtension) { if (!Initialize()) { @@ -110,23 +112,17 @@ namespace Nz return false; } - String path = pluginPath; - if (appendExtension && !path.EndsWith(NAZARA_DYNLIB_EXTENSION)) + std::filesystem::path path = pluginPath; + if (appendExtension && path.extension() == NAZARA_DYNLIB_EXTENSION) path += NAZARA_DYNLIB_EXTENSION; bool exists = false; - if (!File::IsAbsolute(path)) + if (!path.is_absolute()) { - for (const String& dir : s_directories) + for (const std::filesystem::path& dir : s_directories) { - String testPath; - testPath.Reserve(dir.GetSize() + path.GetSize() + 10); - - testPath = dir; - testPath += NAZARA_DIRECTORY_SEPARATOR; - testPath += path; - - if (File::Exists(testPath)) + std::filesystem::path testPath = dir / path; + if (std::filesystem::exists(testPath)) { path = testPath; exists = true; @@ -134,7 +130,7 @@ namespace Nz } } } - else if (File::Exists(path)) + else if (std::filesystem::exists(path)) exists = true; if (!exists) @@ -143,7 +139,7 @@ namespace Nz return false; } - std::unique_ptr library(new DynLib); + std::unique_ptr library = std::make_unique(); if (!library->Load(path)) { NazaraError("Failed to load plugin"); @@ -163,7 +159,8 @@ namespace Nz return false; } - s_plugins[pluginPath] = library.release(); + std::filesystem::path canonicalPath = std::filesystem::canonical(pluginPath); + s_plugins[canonicalPath] = std::move(library); return true; } @@ -176,7 +173,7 @@ namespace Nz * \remark Produces a NazaraError if not initialized */ - void PluginManager::RemoveDirectory(const String& directoryPath) + void PluginManager::RemoveDirectory(const std::filesystem::path& directoryPath) { if (!Initialize()) { @@ -184,7 +181,7 @@ namespace Nz return; } - s_directories.erase(File::AbsolutePath(directoryPath)); + s_directories.erase(std::filesystem::canonical(directoryPath)); } /*! @@ -210,7 +207,7 @@ namespace Nz * \remark Produces a NazaraError if plugin is not loaded */ - void PluginManager::Unmount(const String& pluginPath) + void PluginManager::Unmount(const std::filesystem::path& pluginPath) { if (!Initialize()) { @@ -218,7 +215,8 @@ namespace Nz return; } - auto it = s_plugins.find(pluginPath); + std::filesystem::path canonicalPath = std::filesystem::canonical(pluginPath); + auto it = s_plugins.find(canonicalPath); if (it == s_plugins.end()) { NazaraError("Plugin not loaded"); @@ -229,9 +227,6 @@ namespace Nz if (func) func(); - it->second->Unload(); - delete it->second; - s_plugins.erase(it); } @@ -253,15 +248,12 @@ namespace Nz PluginUnload func = reinterpret_cast(pair.second->GetSymbol("PluginUnload")); if (func) func(); - - pair.second->Unload(); - delete pair.second; } s_plugins.clear(); } - std::set PluginManager::s_directories; - std::unordered_map PluginManager::s_plugins; + std::set PluginManager::s_directories; + std::unordered_map, PluginManager::PathHash> PluginManager::s_plugins; bool PluginManager::s_initialized = false; } diff --git a/src/Nazara/Core/Posix/ConditionVariableImpl.cpp b/src/Nazara/Core/Posix/ConditionVariableImpl.cpp deleted file mode 100644 index 69eb691fa..000000000 --- a/src/Nazara/Core/Posix/ConditionVariableImpl.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - ConditionVariableImpl::ConditionVariableImpl() - { - pthread_cond_init(&m_cv, nullptr); - } - - ConditionVariableImpl::~ConditionVariableImpl() - { - pthread_cond_destroy(&m_cv); - } - - void ConditionVariableImpl::Signal() - { - pthread_cond_signal(&m_cv); - } - - void ConditionVariableImpl::SignalAll() - { - pthread_cond_broadcast(&m_cv); - } - - void ConditionVariableImpl::Wait(MutexImpl* mutex) - { - pthread_cond_wait(&m_cv, &mutex->m_handle); - } - - bool ConditionVariableImpl::Wait(MutexImpl* mutex, UInt32 timeout) - { - // get the current time - timeval tv; - gettimeofday(&tv, nullptr); - - // construct the time limit (current time + time to wait) - timespec ti; - ti.tv_nsec = (tv.tv_usec + (timeout % 1000)) * 1000000; - ti.tv_sec = tv.tv_sec + (timeout / 1000) + (ti.tv_nsec / 1000000000); - ti.tv_nsec %= 1000000000; - - return pthread_cond_timedwait(&m_cv,&mutex->m_handle, &ti) != 0; - } -} diff --git a/src/Nazara/Core/Posix/ConditionVariableImpl.hpp b/src/Nazara/Core/Posix/ConditionVariableImpl.hpp deleted file mode 100644 index e5da2d984..000000000 --- a/src/Nazara/Core/Posix/ConditionVariableImpl.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -#pragma once - -#ifndef NAZARA_CONDITIONVARIABLEIMPL_HPP -#define NAZARA_CONDITIONVARIABLEIMPL_HPP - -#include -#include - -namespace Nz -{ - class MutexImpl; - - class ConditionVariableImpl - { - public: - ConditionVariableImpl(); - ~ConditionVariableImpl(); - - void Signal(); - void SignalAll(); - - void Wait(MutexImpl* mutex); - bool Wait(MutexImpl* mutex, UInt32 timeout); - - private: - pthread_cond_t m_cv; - }; -} - -#endif // NAZARA_CONDITIONVARIABLEIMPL_HPP diff --git a/src/Nazara/Core/Posix/DirectoryImpl.cpp b/src/Nazara/Core/Posix/DirectoryImpl.cpp deleted file mode 100644 index e0a7968f0..000000000 --- a/src/Nazara/Core/Posix/DirectoryImpl.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - DirectoryImpl::DirectoryImpl(const Directory* parent) : - m_parent(parent) - { - } - - void DirectoryImpl::Close() - { - closedir(m_handle); - } - - String DirectoryImpl::GetResultName() const - { - return m_result->d_name; - } - - UInt64 DirectoryImpl::GetResultSize() const - { - String path = m_parent->GetPath(); - std::size_t pathSize = path.GetSize(); - - std::size_t resultNameSize = std::strlen(m_result->d_name); - - std::size_t fullNameSize = pathSize + 1 + resultNameSize; - StackArray fullName = NazaraStackArrayNoInit(char, fullNameSize + 1); - std::memcpy(&fullName[0], path.GetConstBuffer(), pathSize * sizeof(char)); - fullName[pathSize] = '/'; - std::memcpy(&fullName[pathSize + 1], m_result->d_name, resultNameSize * sizeof(char)); - fullName[fullNameSize] = '\0'; - - struct stat64 results; - stat64(fullName.data(), &results); - - return results.st_size; - } - - bool DirectoryImpl::IsResultDirectory() const - { - //TODO: Fix d_type handling (field can be missing or be a symbolic link, both cases which must be handled by calling stat) - - return m_result->d_type == DT_DIR; - } - - bool DirectoryImpl::NextResult() - { - if ((m_result = readdir64(m_handle))) - return true; - else - { - if (errno == EBADF || errno == EOVERFLOW) - NazaraError("Unable to get next result: " + Error::GetLastSystemError()); - - return false; - } - } - - bool DirectoryImpl::Open(const String& dirPath) - { - m_handle = opendir(dirPath.GetConstBuffer()); - if (!m_handle) - { - NazaraError("Unable to open directory: " + Error::GetLastSystemError()); - return false; - } - - return true; - } - - bool DirectoryImpl::Create(const String& dirPath) - { - mode_t permissions = S_IRWXU | S_IRWXG | S_IRWXO; // 777 - return mkdir(dirPath.GetConstBuffer(), permissions) != -1; - } - - bool DirectoryImpl::Exists(const String& dirPath) - { - struct stat64 filestats; - if (stat64(dirPath.GetConstBuffer(), &filestats) == -1) // error - return false; - - return S_ISDIR(filestats.st_mode) || S_ISREG(filestats.st_mode); - } - - String DirectoryImpl::GetCurrent() - { - String currentPath; - - char path[MAXPATHLEN]; - if (getcwd(path, MAXPATHLEN)) - currentPath = path; - else - NazaraError("Unable to get current directory: " + Error::GetLastSystemError()); // Bug: initialisation -> if no path for log ! - - return currentPath; - } - - bool DirectoryImpl::Remove(const String& dirPath) - { - bool success = rmdir(dirPath.GetConstBuffer()) != -1; - - return success; - } -} diff --git a/src/Nazara/Core/Posix/DirectoryImpl.hpp b/src/Nazara/Core/Posix/DirectoryImpl.hpp deleted file mode 100644 index 907947371..000000000 --- a/src/Nazara/Core/Posix/DirectoryImpl.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_DIRECTORYIMPL_HPP -#define NAZARA_DIRECTORYIMPL_HPP - -#include -#include - -namespace Nz -{ - class Directory; - class String; - - class DirectoryImpl - { - public: - DirectoryImpl(const Directory* parent); - DirectoryImpl(const DirectoryImpl&) = delete; - DirectoryImpl(DirectoryImpl&&) = delete; ///TODO - ~DirectoryImpl() = default; - - void Close(); - - String GetResultName() const; - UInt64 GetResultSize() const; - - bool IsResultDirectory() const; - - bool NextResult(); - - bool Open(const String& dirPath); - - DirectoryImpl& operator=(const DirectoryImpl&) = delete; - DirectoryImpl& operator=(DirectoryImpl&&) = delete; ///TODO - - static bool Create(const String& dirPath); - static bool Exists(const String& dirPath); - static String GetCurrent(); - static bool Remove(const String& dirPath); - - private: - const Directory* m_parent; - DIR* m_handle; - dirent64* m_result; - }; -} - -#endif // NAZARA_DIRECTORYIMPL_HPP diff --git a/src/Nazara/Core/Posix/FileImpl.cpp b/src/Nazara/Core/Posix/FileImpl.cpp index 5e2cbc200..c08a8c383 100644 --- a/src/Nazara/Core/Posix/FileImpl.cpp +++ b/src/Nazara/Core/Posix/FileImpl.cpp @@ -13,13 +13,14 @@ namespace Nz { FileImpl::FileImpl(const File* parent) : + m_fileDescriptor(-1), m_endOfFile(false), m_endOfFileUpdated(true) { NazaraUnused(parent); } - void FileImpl::Close() + FileImpl::~FileImpl() { if (m_fileDescriptor != -1) close(m_fileDescriptor); @@ -52,7 +53,7 @@ namespace Nz return static_cast(position); } - bool FileImpl::Open(const String& filePath, OpenModeFlags mode) + bool FileImpl::Open(const std::filesystem::path& filePath, OpenModeFlags mode) { int flags; mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; @@ -75,10 +76,10 @@ namespace Nz if (mode & OpenMode_Truncate) flags |= O_TRUNC; - m_fileDescriptor = open64(filePath.GetConstBuffer(), flags, permissions); + m_fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions); if (m_fileDescriptor == -1) { - NazaraError("Failed to open \"" + filePath + "\" : " + Error::GetLastSystemError()); + NazaraError("Failed to open \"" + filePath.generic_u8string() + "\" : " + Error::GetLastSystemError()); return false; } @@ -177,121 +178,4 @@ namespace Nz return written; } - - bool FileImpl::Copy(const String& sourcePath, const String& targetPath) - { - int fd1 = open64(sourcePath.GetConstBuffer(), O_RDONLY); - if (fd1 == -1) - { - NazaraError("Fail to open input file (" + sourcePath + "): " + Error::GetLastSystemError()); - return false; - } - - mode_t permissions; - struct stat sb; - if (fstat(fd1, &sb) == -1) // get permission from first file - { - NazaraWarning("Could not get permissions of source file"); - permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - } - else - { - permissions = sb.st_mode & ~S_IFMT; // S_IFMT: bit mask for the file type bit field -> ~S_IFMT: general permissions - } - - int fd2 = open64(targetPath.GetConstBuffer(), O_WRONLY | O_TRUNC, permissions); - if (fd2 == -1) - { - NazaraError("Fail to open output file (" + targetPath + "): " + Error::GetLastSystemError()); // TODO: more info ? - close(fd1); - return false; - } - - char buffer[512]; - ssize_t bytes; - do - { - bytes = read(fd1,buffer,512); - if (bytes == -1) - { - close(fd1); - close(fd2); - NazaraError("An error occured from copy : " + Error::GetLastSystemError()); - return false; - } - write(fd2,buffer,bytes); - } - while (bytes == 512); - - close(fd1); - close(fd2); - return true; - } - - bool FileImpl::Delete(const String& filePath) - { - bool success = unlink(filePath.GetConstBuffer()) != -1; - - if (success) - return true; - else - { - NazaraError("Failed to delete file (" + filePath + "): " + Error::GetLastSystemError()); - return false; - } - } - - bool FileImpl::Exists(const String& filePath) - { - const char* path = filePath.GetConstBuffer(); - if (access(path, F_OK) != -1) - return true; - - return false; - } - - time_t FileImpl::GetCreationTime(const String& filePath) - { - NazaraUnused(filePath); - - NazaraWarning("Posix has no creation time information"); - return 0; - } - - time_t FileImpl::GetLastAccessTime(const String& filePath) - { - struct stat64 stats; - stat64(filePath.GetConstBuffer(), &stats); - - return stats.st_atime; - } - - time_t FileImpl::GetLastWriteTime(const String& filePath) - { - struct stat64 stats; - stat64(filePath.GetConstBuffer(), &stats); - - return stats.st_mtime; - } - - UInt64 FileImpl::GetSize(const String& filePath) - { - struct stat64 stats; - stat64(filePath.GetConstBuffer(), &stats); - - return static_cast(stats.st_size); - } - - bool FileImpl::Rename(const String& sourcePath, const String& targetPath) - { - bool success = std::rename(sourcePath.GetConstBuffer(), targetPath.GetConstBuffer()) != -1; - - if (success) - return true; - else - { - NazaraError("Unable to rename file: " + Error::GetLastSystemError()); - return false; - } - } } diff --git a/src/Nazara/Core/Posix/FileImpl.hpp b/src/Nazara/Core/Posix/FileImpl.hpp index ef519eda0..d74ae4f3e 100644 --- a/src/Nazara/Core/Posix/FileImpl.hpp +++ b/src/Nazara/Core/Posix/FileImpl.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Nz { @@ -28,11 +29,10 @@ namespace Nz FileImpl(FileImpl&&) = delete; ///TODO ~FileImpl() = default; - void Close(); bool EndOfFile() const; void Flush(); UInt64 GetCursorPos() const; - bool Open(const String& filePath, OpenModeFlags mode); + bool Open(const std::filesystem::path& filePath, OpenModeFlags mode); std::size_t Read(void* buffer, std::size_t size); bool SetCursorPos(CursorPosition pos, Int64 offset); bool SetSize(UInt64 size); @@ -41,15 +41,6 @@ namespace Nz FileImpl& operator=(const FileImpl&) = delete; FileImpl& operator=(FileImpl&&) = delete; ///TODO - static bool Copy(const String& sourcePath, const String& targetPath); - static bool Delete(const String& filePath); - static bool Exists(const String& filePath); - static time_t GetCreationTime(const String& filePath); - static time_t GetLastAccessTime(const String& filePath); - static time_t GetLastWriteTime(const String& filePath); - static UInt64 GetSize(const String& filePath); - static bool Rename(const String& sourcePath, const String& targetPath); - private: int m_fileDescriptor; mutable bool m_endOfFile; diff --git a/src/Nazara/Core/Posix/MutexImpl.cpp b/src/Nazara/Core/Posix/MutexImpl.cpp deleted file mode 100644 index a19720000..000000000 --- a/src/Nazara/Core/Posix/MutexImpl.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - MutexImpl::MutexImpl() - { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - - pthread_mutex_init(&m_handle, &attr); - } - - MutexImpl::~MutexImpl() - { - pthread_mutex_destroy(&m_handle); - } - - void MutexImpl::Lock() - { - pthread_mutex_lock(&m_handle); - } - - bool MutexImpl::TryLock() - { - return pthread_mutex_trylock(&m_handle) == 0; - } - - void MutexImpl::Unlock() - { - pthread_mutex_unlock(&m_handle); - } -} diff --git a/src/Nazara/Core/Posix/MutexImpl.hpp b/src/Nazara/Core/Posix/MutexImpl.hpp deleted file mode 100644 index 5437ce043..000000000 --- a/src/Nazara/Core/Posix/MutexImpl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_MUTEXIMPL_HPP -#define NAZARA_MUTEXIMPL_HPP - -#include - -namespace Nz -{ - class MutexImpl - { - friend class ConditionVariableImpl; - - public: - MutexImpl(); - ~MutexImpl(); - - void Lock(); - bool TryLock(); - void Unlock(); - - private: - pthread_mutex_t m_handle; - }; -} - -#endif // NAZARA_MUTEXIMPL_HPP diff --git a/src/Nazara/Core/Posix/SemaphoreImpl.cpp b/src/Nazara/Core/Posix/SemaphoreImpl.cpp deleted file mode 100644 index c53928407..000000000 --- a/src/Nazara/Core/Posix/SemaphoreImpl.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - SemaphoreImpl::SemaphoreImpl(unsigned int count) - { - if (sem_init(&m_semaphore, 0, count) != 0) - NazaraError("Failed to create semaphore: " + Error::GetLastSystemError()); - } - - SemaphoreImpl::~SemaphoreImpl() - { - sem_destroy(&m_semaphore); - } - - unsigned int SemaphoreImpl::GetCount() const - { - int count=0; - sem_getvalue(const_cast(&m_semaphore), &count); - return static_cast(count); - } - - void SemaphoreImpl::Post() - { - #if NAZARA_CORE_SAFE - if (sem_post(&m_semaphore)==-1) - NazaraError("Failed to release semaphore: " + Error::GetLastSystemError()); - #else - sem_post(&m_semaphore); - #endif - } - - void SemaphoreImpl::Wait() - { - #if NAZARA_CORE_SAFE - if (sem_wait(&m_semaphore) == -1 ) - NazaraError("Failed to wait for semaphore: " + Error::GetLastSystemError()); - #else - sem_wait(&m_semaphore); - #endif - } - - bool SemaphoreImpl::Wait(UInt32 timeout) - { - timeval tv; - gettimeofday(&tv, nullptr); - - timespec ti; - ti.tv_nsec = (tv.tv_usec + (timeout % 1000)) * 1000000; - ti.tv_sec = tv.tv_sec + (timeout / 1000) + (ti.tv_nsec / 1000000000); - ti.tv_nsec %= 1000000000; - - #if NAZARA_CORE_SAFE - if (sem_timedwait(&m_semaphore, &ti) != 0) - { - NazaraError("Failed to wait for semaphore: " + Error::GetLastSystemError()); - return false; - } - - return true; - #else - return sem_timedwait(&m_semaphore, &ti) != 0; - #endif - } -} diff --git a/src/Nazara/Core/Posix/SemaphoreImpl.hpp b/src/Nazara/Core/Posix/SemaphoreImpl.hpp deleted file mode 100644 index 367d35811..000000000 --- a/src/Nazara/Core/Posix/SemaphoreImpl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SEMAPHOREIMPL_HPP -#define NAZARA_SEMAPHOREIMPL_HPP - -#include -#include - -namespace Nz -{ - class SemaphoreImpl - { - public: - SemaphoreImpl(unsigned int count); - ~SemaphoreImpl(); - - unsigned int GetCount() const; - void Post(); - void Wait(); - bool Wait(UInt32 timeout); - - private: - sem_t m_semaphore; - }; -} - -#endif // NAZARA_SEMAPHOREIMPL_HPP diff --git a/src/Nazara/Core/Posix/ThreadImpl.cpp b/src/Nazara/Core/Posix/ThreadImpl.cpp deleted file mode 100644 index 3793ddcf5..000000000 --- a/src/Nazara/Core/Posix/ThreadImpl.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - ThreadImpl::ThreadImpl(Functor* functor) - { - int error = pthread_create(&m_handle, nullptr, &ThreadImpl::ThreadProc, functor); - if (error != 0) - NazaraInternalError("Failed to create thread: " + Error::GetLastSystemError()); - } - - void ThreadImpl::Detach() - { - pthread_detach(m_handle); - } - - void ThreadImpl::Join() - { - pthread_join(m_handle, nullptr); - } - - void ThreadImpl::SetName(const Nz::String& name) - { -#ifdef __GNUC__ - pthread_setname_np(m_handle, name.GetConstBuffer()); -#else - NazaraWarning("Setting thread name is not supported on this platform"); -#endif - } - - void ThreadImpl::SetCurrentName(const Nz::String& name) - { -#ifdef __GNUC__ - pthread_setname_np(pthread_self(), name.GetConstBuffer()); -#else - NazaraWarning("Setting current thread name is not supported on this platform"); -#endif - } - - void ThreadImpl::Sleep(UInt32 time) - { - if (time == 0) - sched_yield(); - else - { - struct timespec ts; - ts.tv_sec = time / 1000; - ts.tv_nsec = (time - ts.tv_sec * 1000) * 1'000'000; - - int r; - do - { - r = nanosleep(&ts, &ts); - } - while (r == -1 && errno == EINTR); - } - } - - void* ThreadImpl::ThreadProc(void* userdata) - { - Functor* func = static_cast(userdata); - func->Run(); - delete func; - - return nullptr; - } -} diff --git a/src/Nazara/Core/Posix/ThreadImpl.hpp b/src/Nazara/Core/Posix/ThreadImpl.hpp deleted file mode 100644 index f8c024cb5..000000000 --- a/src/Nazara/Core/Posix/ThreadImpl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Alexandre Janniaux -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_THREADIMPL_HPP -#define NAZARA_THREADIMPL_HPP - -#include - -#if defined(__GNUC__) && !defined(_GNU_SOURCE) -#define _GNU_SOURCE -#endif - -#include - -namespace Nz -{ - struct Functor; - class String; - - class ThreadImpl - { - public: - ThreadImpl(Functor* threadFunc); - - void Detach(); - void Join(); - void SetName(const Nz::String& name); - - static void SetCurrentName(const Nz::String& name); - static void Sleep(UInt32 time); - - private: - static void* ThreadProc(void* userdata); - - pthread_t m_handle; - }; -} - -#endif // NAZARA_THREADIMPL_HPP diff --git a/src/Nazara/Core/Resource.cpp b/src/Nazara/Core/Resource.cpp index efd8a4eb6..d409d15cc 100644 --- a/src/Nazara/Core/Resource.cpp +++ b/src/Nazara/Core/Resource.cpp @@ -20,7 +20,7 @@ namespace Nz * \return A reference to the path */ - const String& Resource::GetFilePath() const + const std::filesystem::path& Resource::GetFilePath() const { return m_filePath; } @@ -31,7 +31,7 @@ namespace Nz * \param filePath Path to the resource */ - void Resource::SetFilePath(const String& filePath) + void Resource::SetFilePath(const std::filesystem::path& filePath) { m_filePath = filePath; } diff --git a/src/Nazara/Core/Semaphore.cpp b/src/Nazara/Core/Semaphore.cpp deleted file mode 100644 index e4a52b43f..000000000 --- a/src/Nazara/Core/Semaphore.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_POSIX) - #include -#else - #error Lack of implementation: Semaphore -#endif - -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::Semaphore - * \brief Core class that represents a counting semaphore - */ - - /*! - * \brief Constructs a semaphore object with a count - */ - - Semaphore::Semaphore(unsigned int count) - { - m_impl = new SemaphoreImpl(count); - } - - /*! - * \brief Destructs the object - */ - - Semaphore::~Semaphore() - { - delete m_impl; - } - - /*! - * \brief Gets the number of count that can handle the semaphore - * \return Number of count associated with the semaphore - */ - - unsigned int Semaphore::GetCount() const - { - return m_impl->GetCount(); - } - - /*! - * \brief Increments the count of the semaphore and wait if count equals zero - * - * Increments the value of semaphore variable by 1. After the increment, if the pre-increment value was negative (meaning there are processes waiting for a resource), it transfers a blocked process from the semaphore's waiting queue to the ready queue - */ - - void Semaphore::Post() - { - m_impl->Post(); - } - - /*! - * \brief Decrements the count of the semaphore and wait if count equals zero - * - * If the value of semaphore variable is not negative, decrements it by 1. If the semaphore variable is now negative, the process executing Wait is blocked (i.e., added to the semaphore's queue) until the value is greater or equal to 1. Otherwise, the process continues execution, having used a unit of the resource - */ - - void Semaphore::Wait() - { - m_impl->Wait(); - } - - /*! - * \brief Decrements the count of the semaphore and wait if count equals zero - * \return true if the semaphore successfully decrements before timeout - * - * If the value of semaphore variable is not negative, decrements it by 1. If the semaphore variable is now negative, the process executing Wait is blocked (i.e., added to the semaphore's queue) until the value is greater or equal to 1. Otherwise, the process continues execution, having used a unit of the resource - */ - - bool Semaphore::Wait(UInt32 timeout) - { - return m_impl->Wait(timeout); - } -} diff --git a/src/Nazara/Core/Stream.cpp b/src/Nazara/Core/Stream.cpp index 7ae91ed93..c607ff313 100644 --- a/src/Nazara/Core/Stream.cpp +++ b/src/Nazara/Core/Stream.cpp @@ -28,9 +28,9 @@ namespace Nz * \return Empty string (meant to be virtual) */ - String Stream::GetDirectory() const + std::filesystem::path Stream::GetDirectory() const { - return String(); + return std::filesystem::path(); } /*! @@ -38,9 +38,9 @@ namespace Nz * \return Empty string (meant to be virtual) */ - String Stream::GetPath() const + std::filesystem::path Stream::GetPath() const { - return String(); + return std::filesystem::path(); } /*! @@ -57,9 +57,9 @@ namespace Nz * \remark With the text stream option, "\r\n" is treated as "\n" * \remark The line separator character is not returned as part of the string */ - String Stream::ReadLine(unsigned int lineSize) + std::string Stream::ReadLine(unsigned int lineSize) { - String line; + std::string line; if (lineSize == 0) // Maximal size undefined { const unsigned int bufferSize = 64; @@ -79,9 +79,9 @@ namespace Nz if (ptr != buffer) { if (m_streamOptions & StreamOption_Text && buffer[pos - 1] == '\r') - line.Append(buffer, pos - 1); + line.append(buffer, pos - 1); else - line.Append(buffer, pos); + line.append(buffer, pos); } if (!SetCursorPos(GetCursorPos() - readSize + pos + 1)) @@ -100,28 +100,28 @@ namespace Nz length--; } - line.Append(buffer, length); + line.append(buffer, length); } } while (readSize == bufferSize); } else { - line.Set(lineSize, '\0'); + line.resize(lineSize, '\0'); std::size_t readSize = Read(&line[0], lineSize); - std::size_t pos = line.Find('\n'); + std::size_t pos = line.find('\n'); if (pos <= readSize) // False only if the character is not available (npos being the biggest integer) { if (m_streamOptions & StreamOption_Text && pos > 0 && line[pos - 1] == '\r') - line.Resize(pos); + line.resize(pos); else - line.Resize(pos + 1); + line.resize(pos + 1); if (!SetCursorPos(GetCursorPos() - readSize + pos + 1)) NazaraWarning("Failed to reset cursos pos"); } else - line.Resize(readSize); + line.resize(readSize); } return line; diff --git a/src/Nazara/Core/StringExt.cpp b/src/Nazara/Core/StringExt.cpp new file mode 100644 index 000000000..52f4e90cc --- /dev/null +++ b/src/Nazara/Core/StringExt.cpp @@ -0,0 +1,226 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + bool IsSpace(char32_t character) + { + return character == '\t' || Unicode::GetCategory(character) & Unicode::Category_Separator; + } + + char ToLower(char character) + { + if (character >= 'A' && character <= 'Z') + return character + ('a' - 'A'); + else + return character; + } + + char ToUpper(char character) + { + if (character >= 'a' && character <= 'z') + return character + ('A' - 'a'); + else + return character; + } + + template + struct WideConverter + { + static std::string From(const wchar_t* wstr, std::size_t size) + { + if constexpr (S == 2) + { + // UTF-16 (Windows) + return FromUtf16String(std::u16string_view(reinterpret_cast(wstr), size)); + } + else if constexpr (S == 4) + { + // UTF-32 (Linux) + return FromUtf32String(std::u32string_view(reinterpret_cast(wstr), size)); + } + else + { + static_assert(AlwaysFalse, "Unsupported platform"); + return std::string(""); + } + } + + static std::wstring To(const std::string_view& str) + { + if constexpr (S == 2) + { + std::wstring result; + utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result)); + + return result; + } + else if constexpr (S == 4) + { + std::wstring result; + utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result)); + + return result; + } + else + { + static_assert(AlwaysFalse, "Unsupported platform"); + return std::string(""); + } + } + }; + } + + std::string FromUtf16String(const char16_t* u16str) + { + std::size_t size = std::char_traits::length(u16str); + return FromUtf16String(std::u16string_view(u16str, size)); + } + + std::string FromUtf16String(const std::u16string_view& u16str) + { + std::string result; + utf8::utf16to8(u16str.begin(), u16str.end(), std::back_inserter(result)); + + return result; + } + + std::string FromUtf32String(const char32_t* u32str) + { + std::size_t size = std::char_traits::length(u32str); + return FromUtf32String(std::u32string_view(u32str, size)); + } + + std::string FromUtf32String(const std::u32string_view& u32str) + { + std::string result; + utf8::utf32to8(u32str.begin(), u32str.end(), std::back_inserter(result)); + + return result; + } + + std::string FromWideString(const wchar_t* wstr) + { + std::size_t size = std::char_traits::length(wstr); + return WideConverter::From(wstr, size); + } + + std::string FromWideString(const std::wstring_view& wstr) + { + return WideConverter::From(wstr.data(), wstr.size()); + } + + bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent) + { + if (s.size() > str.size()) + return false; + + return std::equal(str.begin(), str.begin() + s.size(), s.begin(), s.end(), [](char c1, char c2) + { + return ToLower(c1) == ToLower(c2); + }); + } + + bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent, UnicodeAware) + { + if (str.empty() || s.empty()) + return str == s; + + utf8::iterator it(str.data(), str.data(), str.data() + str.size()); + utf8::iterator it2(s.data(), s.data(), s.data() + s.size()); + do + { + if (it2.base() >= s.data() + s.size()) + return true; + + if (Unicode::GetLowercase(*it) != Unicode::GetLowercase(*it2)) + return false; + + ++it2; + } + while (*it++); + + return true; + } + + std::string ToLower(const std::string_view& str) + { + std::string result; + result.reserve(str.size()); + std::transform(str.begin(), str.end(), std::back_inserter(result), Overload(ToLower)); + + return result; + } + + std::string ToLower(const std::string_view& str, UnicodeAware) + { + if (str.empty()) + return std::string(); + + std::string result; + result.reserve(str.size()); + + utf8::unchecked::iterator it(str.data()); + do + utf8::append(Unicode::GetLowercase(*it), std::back_inserter(result)); + while (*++it); + + return result; + } + + std::string ToUpper(const std::string_view& str) + { + std::string result; + result.reserve(str.size()); + std::transform(str.begin(), str.end(), std::back_inserter(result), Overload(ToUpper)); + + return result; + } + + std::string ToUpper(const std::string_view& str, UnicodeAware) + { + if (str.empty()) + return std::string(); + + std::string result; + result.reserve(str.size()); + + utf8::iterator it(str.data(), str.data(), str.data() + str.size()); + do + utf8::append(Unicode::GetUppercase(*it), std::back_inserter(result)); + while (*++it); + + return result; + } + + std::u16string ToUtf16String(const std::string_view& str) + { + std::u16string result; + utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result)); + + return result; + } + + std::u32string ToUtf32String(const std::string_view& str) + { + std::u32string result; + utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result)); + + return result; + } + + std::wstring ToWideString(const std::string_view& str) + { + return WideConverter::To(str); + } +} + +#include diff --git a/src/Nazara/Core/Thread.cpp b/src/Nazara/Core/Thread.cpp deleted file mode 100644 index 5380188d1..000000000 --- a/src/Nazara/Core/Thread.cpp +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_POSIX) - #include -#else - #error Thread has no implementation -#endif - -#include - -namespace Nz -{ - /*! - * \ingroup core - * \class Nz::Thread - * \brief Core class that represents a thread - */ - - /*! - * \brief Constructs a Thread object by default - */ - - Thread::Thread() : - m_impl(nullptr) - { - } - - /*! - * \brief Waits that the thread ends and then destroys this - */ - - Thread::~Thread() - { - if (m_impl) - { - m_impl->Join(); - delete m_impl; - m_impl = nullptr; - } - } - - /*! - * \brief Detaches the thread - */ - - void Thread::Detach() - { - if (m_impl) - { - m_impl->Detach(); - delete m_impl; - m_impl = nullptr; - } - } - - /*! - * \brief Gets the id of the thread - * \return The identifiant of the thread (PID) - */ - - Thread::Id Thread::GetId() const - { - return Thread::Id(m_impl); - } - - /*! - * \brief Checks whether the thread can be joined - * \return true if well formed and not detached - */ - - bool Thread::IsJoinable() const - { - return m_impl != nullptr; - } - - /*! - * \brief Waits that the thread ends - * - * \remark Produce a NazaraError if no functor was assigned and NAZARA_CORE_SAFE is defined - */ - - void Thread::Join() - { - #if NAZARA_CORE_SAFE - if (!m_impl) - { - NazaraError("This thread is not joinable"); - return; - } - #endif - - m_impl->Join(); - delete m_impl; - m_impl = nullptr; - } - - /*! - * \brief Changes the debugging name associated to a thread - * - * Changes the debugging name associated with a particular thread, and may helps with debugging tools. - * - * \param name The new name of the thread - * - * \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator) - * - * \see SetCurrentThreadName - */ - void Thread::SetName(const String& name) - { - NazaraAssert(m_impl, "Invalid thread"); - NazaraAssert(name.GetSize() < 16, "Thread name is too long"); - - m_impl->SetName(name); - } - - /*! - * \brief Gets the number of simulatenous threads that can run on the same cpu - * \return The number of simulatenous threads - */ - unsigned int Thread::HardwareConcurrency() - { - return HardwareInfo::GetProcessorCount(); - } - - - /*! - * \brief Changes the debugging name associated to the calling thread - * - * Changes the debugging name associated with the calling thread, and may helps with debugging tools. - * - * \param name The new name associated with this thread - * - * \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator) - * - * \see SetName - */ - void Thread::SetCurrentThreadName(const String& name) - { - NazaraAssert(name.GetSize() < 16, "Thread name is too long"); - - ThreadImpl::SetCurrentName(name); - } - - /*! - * \brief Makes sleep this thread - * - * \param milliseconds The number of milliseconds to sleep - */ - void Thread::Sleep(UInt32 milliseconds) - { - ThreadImpl::Sleep(milliseconds); - } - - /*! - * \brief Creates the implementation of this thread - * - * \param functor The task the thread will represent - */ - - void Thread::CreateImpl(Functor* functor) - { - m_impl = new ThreadImpl(functor); - } - - /*********************************Thread::Id********************************/ - - /*! - * \brief Constructs a Thread object with a thread implementation - * - * \param thread Thread implementation assigned to the thread - */ - - Thread::Id::Id(ThreadImpl* thread) : - m_id(thread) - { - } - - /*! - * \brief Compares two Thread::Id - * \return true if the two thread ids are the same - * - * \param lhs First id - * \param rhs Second id - */ - - bool operator==(const Thread::Id& lhs, const Thread::Id& rhs) - { - return lhs.m_id == rhs.m_id; - } - - /*! - * \brief Compares two Thread::Id - * \return false if the two thread ids are the same - * - * \param lhs First id - * \param rhs Second id - */ - - bool operator!=(const Thread::Id& lhs, const Thread::Id& rhs) - { - return lhs.m_id != rhs.m_id; - } - - /*! - * \brief Compares two Thread::Id - * \return true if the first thread id is inferior to the second one - * - * \param lhs First id - * \param rhs Second id - */ - - bool operator<(const Thread::Id& lhs, const Thread::Id& rhs) - { - return lhs.m_id < rhs.m_id; - } - - /*! - * \brief Compares two Thread::Id - * \return true if the first thread id is inferior or equal to the second one - * - * \param lhs First id - * \param rhs Second id - */ - - bool operator<=(const Thread::Id& lhs, const Thread::Id& rhs) - { - return lhs.m_id <= rhs.m_id; - } - - /*! - * \brief Compares two Thread::Id - * \return true if the first thread id is superior to the second one - * - * \param lhs First id - * \param rhs Second id - */ - - bool operator>(const Thread::Id& lhs, const Thread::Id& rhs) - { - return lhs.m_id > rhs.m_id; - } - - /*! - * \brief Compares two Thread::Id - * \return true if the first thread id is superior or equal to the second one - * - * \param lhs First id - * \param rhs Second id - */ - - bool operator>=(const Thread::Id& lhs, const Thread::Id& rhs) - { - return lhs.m_id >= rhs.m_id; - } - - /*! - * \brief Output operator - * \return The stream - * - * \param out The stream - * \param id The thread id to output - */ - - std::ostream& operator<<(std::ostream& o, const Nz::Thread::Id& id) - { - o << id.m_id; - return o; - } -} diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp deleted file mode 100644 index 7cd5416a8..000000000 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Source: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -#include -#include -#include - -namespace Nz -{ - ConditionVariableImpl::ConditionVariableImpl() - { - #if NAZARA_CORE_WINDOWS_NT6 - InitializeConditionVariable(&m_cv); - #else - m_count = 0; - m_events[BROADCAST] = CreateEvent(nullptr, true, false, nullptr); // manual-reset event - m_events[SIGNAL] = CreateEvent(nullptr, false, false, nullptr); // auto-reset event - #endif - } - - #if !NAZARA_CORE_WINDOWS_NT6 - ConditionVariableImpl::~ConditionVariableImpl() - { - CloseHandle(m_events[BROADCAST]); - CloseHandle(m_events[SIGNAL]); - } - #endif - - void ConditionVariableImpl::Signal() - { - #if NAZARA_CORE_WINDOWS_NT6 - WakeConditionVariable(&m_cv); - #else - if (m_count > 0) - SetEvent(m_events[SIGNAL]); - #endif - } - - void ConditionVariableImpl::SignalAll() - { - #if NAZARA_CORE_WINDOWS_NT6 - WakeAllConditionVariable(&m_cv); - #else - if (m_count > 0) - SetEvent(m_events[BROADCAST]); - #endif - } - - void ConditionVariableImpl::Wait(MutexImpl* mutex) - { - Wait(mutex, INFINITE); - } - - bool ConditionVariableImpl::Wait(MutexImpl* mutex, UInt32 timeout) - { - #if NAZARA_CORE_WINDOWS_NT6 - return SleepConditionVariableCS(&m_cv, &mutex->m_criticalSection, timeout) == TRUE; - #else - m_count++; - - // It's ok to release the mutex here since Win32 - // manual-reset events maintain state when used with SetEvent. - // This avoids the "lost wakeup" bug... - LeaveCriticalSection(&mutex->m_criticalSection); - - // Wait for either event to become signaled due to Signal being called or SignalAll being called. - int result = WaitForMultipleObjects(2, m_events, false, timeout); - - // Some thread called SignalAll - if (--m_count == 0 && result == WAIT_OBJECT_0 + BROADCAST) - // We're the last waiter to be notified or to stop waiting, so reset the manual event. - ResetEvent(m_events[BROADCAST]); - - // Reacquire the mutex. - EnterCriticalSection(&mutex->m_criticalSection); - - return result != WAIT_TIMEOUT; - #endif - } - -} diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.hpp b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp deleted file mode 100644 index 852241ae3..000000000 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -#pragma once - -#ifndef NAZARA_CONDITIONVARIABLEIMPL_HPP -#define NAZARA_CONDITIONVARIABLEIMPL_HPP - -#include -#include -#include - -namespace Nz -{ - class MutexImpl; - - class ConditionVariableImpl - { - public: - ConditionVariableImpl(); - #if NAZARA_CORE_WINDOWS_NT6 - ~ConditionVariableImpl() = default; - #else - ~ConditionVariableImpl(); - #endif - - void Signal(); - void SignalAll(); - - void Wait(MutexImpl* mutex); - bool Wait(MutexImpl* mutex, UInt32 timeout); - - private: - #if NAZARA_CORE_WINDOWS_NT6 - CONDITION_VARIABLE m_cv; - #else - enum - { - SIGNAL, - BROADCAST, - MAX_EVENTS - }; - - std::atomic_uint m_count; - HANDLE m_events[MAX_EVENTS]; - #endif - }; -} - -#endif // NAZARA_CONDITIONVARIABLEIMPL_HPP diff --git a/src/Nazara/Core/Win32/DirectoryImpl.cpp b/src/Nazara/Core/Win32/DirectoryImpl.cpp deleted file mode 100644 index 824d81746..000000000 --- a/src/Nazara/Core/Win32/DirectoryImpl.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - DirectoryImpl::DirectoryImpl(const Directory* parent) - { - NazaraUnused(parent); - } - - void DirectoryImpl::Close() - { - FindClose(m_handle); - } - - String DirectoryImpl::GetResultName() const - { - return String::Unicode(m_result.cFileName); - } - - UInt64 DirectoryImpl::GetResultSize() const - { - LARGE_INTEGER size; - size.HighPart = m_result.nFileSizeHigh; - size.LowPart = m_result.nFileSizeLow; - - return size.QuadPart; - } - - bool DirectoryImpl::IsResultDirectory() const - { - if (m_result.dwFileAttributes != INVALID_FILE_ATTRIBUTES) - return (m_result.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; - else - return false; - } - - bool DirectoryImpl::NextResult() - { - if (m_firstCall) // Nous devons ignorer le premier appel car FindFirstFile nous a déjà renvoyé des résultats - { - m_firstCall = false; - return true; - } - - if (FindNextFileW(m_handle, &m_result)) - return true; - else - { - if (GetLastError() != ERROR_NO_MORE_FILES) - NazaraError("Unable to get next result: " + Error::GetLastSystemError()); - - return false; - } - } - - bool DirectoryImpl::Open(const String& dirPath) - { - String searchPath = dirPath + "\\*"; - - m_handle = FindFirstFileW(searchPath.GetWideString().data(), &m_result); - if (m_handle == INVALID_HANDLE_VALUE) - { - NazaraError("Unable to open directory: " + Error::GetLastSystemError()); - return false; - } - - m_firstCall = true; - - return true; - } - - bool DirectoryImpl::Create(const String& dirPath) - { - return (CreateDirectoryW(dirPath.GetWideString().data(), nullptr) != 0) || GetLastError() == ERROR_ALREADY_EXISTS; - } - - bool DirectoryImpl::Exists(const String& dirPath) - { - DWORD attributes = GetFileAttributesW(dirPath.GetWideString().data()); - if (attributes != INVALID_FILE_ATTRIBUTES) - return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; - else - return false; - } - - String DirectoryImpl::GetCurrent() - { - String currentPath; - std::unique_ptr path(new wchar_t[MAX_PATH]); - - unsigned int size = GetCurrentDirectoryW(MAX_PATH, path.get()); - if (size > MAX_PATH) // La taille prends en compte le caractère nul - { - path.reset(new wchar_t[size]); - if (GetCurrentDirectoryW(size, path.get()) != 0) - currentPath = String::Unicode(path.get()); - else - NazaraError("Unable to get current directory: " + Error::GetLastSystemError()); - } - else if (size == 0) - NazaraError("Unable to get current directory: " + Error::GetLastSystemError()); - else - currentPath = String::Unicode(path.get()); - - return currentPath; - } - - bool DirectoryImpl::Remove(const String& dirPath) - { - bool success = RemoveDirectoryW(dirPath.GetWideString().data()) != 0; - - DWORD error = GetLastError(); - return success || error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND; - } -} diff --git a/src/Nazara/Core/Win32/DirectoryImpl.hpp b/src/Nazara/Core/Win32/DirectoryImpl.hpp deleted file mode 100644 index 358910be4..000000000 --- a/src/Nazara/Core/Win32/DirectoryImpl.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_DIRECTORYIMPL_HPP -#define NAZARA_DIRECTORYIMPL_HPP - -#include -#include - -namespace Nz -{ - class Directory; - class String; - - class DirectoryImpl - { - public: - DirectoryImpl(const Directory* parent); - DirectoryImpl(const DirectoryImpl&) = delete; - DirectoryImpl(DirectoryImpl&&) = delete; ///TODO - ~DirectoryImpl() = default; - - void Close(); - - String GetResultName() const; - UInt64 GetResultSize() const; - - bool IsResultDirectory() const; - - bool NextResult(); - - bool Open(const String& dirPath); - - DirectoryImpl& operator=(const DirectoryImpl&) = delete; - DirectoryImpl& operator=(DirectoryImpl&&) = delete; ///TODO - - static bool Create(const String& dirPath); - static bool Exists(const String& dirPath); - static String GetCurrent(); - static bool Remove(const String& dirPath); - - private: - HANDLE m_handle; - WIN32_FIND_DATAW m_result; - bool m_firstCall; - }; -} - -#endif // NAZARA_DIRECTORYIMPL_HPP diff --git a/src/Nazara/Core/Win32/DynLibImpl.cpp b/src/Nazara/Core/Win32/DynLibImpl.cpp index aa42fda18..d2cbecb7d 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.cpp +++ b/src/Nazara/Core/Win32/DynLibImpl.cpp @@ -5,34 +5,39 @@ #include #include #include -#include -#include +#include #include #include namespace Nz { - DynLibImpl::DynLibImpl(DynLib* parent) + DynLibImpl::DynLibImpl(DynLib*) : + m_handle(nullptr) { - NazaraUnused(parent); } - DynLibFunc DynLibImpl::GetSymbol(const String& symbol, String* errorMessage) const + DynLibImpl::~DynLibImpl() { - DynLibFunc sym = reinterpret_cast(GetProcAddress(m_handle, symbol.GetConstBuffer())); + if (m_handle) + FreeLibrary(m_handle); + } + + DynLibFunc DynLibImpl::GetSymbol(const char* symbol, std::string* errorMessage) const + { + DynLibFunc sym = reinterpret_cast(GetProcAddress(m_handle, symbol)); if (!sym) *errorMessage = Error::GetLastSystemError(); return sym; } - bool DynLibImpl::Load(const String& libraryPath, String* errorMessage) + bool DynLibImpl::Load(const std::filesystem::path& libraryPath, std::string* errorMessage) { - String path = libraryPath; - if (!path.EndsWith(".dll")) + std::filesystem::path path = libraryPath; + if (path.extension() != ".dll") path += ".dll"; - m_handle = LoadLibraryExW(path.GetWideString().data(), nullptr, (File::IsAbsolute(path)) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0); + m_handle = LoadLibraryExW(ToWideString(path.generic_u8string()).data(), nullptr, (path.is_absolute()) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0); if (m_handle) return true; else @@ -41,10 +46,4 @@ namespace Nz return false; } } - - void DynLibImpl::Unload() - { - FreeLibrary(m_handle); - } - } diff --git a/src/Nazara/Core/Win32/DynLibImpl.hpp b/src/Nazara/Core/Win32/DynLibImpl.hpp index c9d88d57d..31a279103 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.hpp +++ b/src/Nazara/Core/Win32/DynLibImpl.hpp @@ -9,23 +9,21 @@ #include #include +#include #include namespace Nz { - class String; - class DynLibImpl { public: DynLibImpl(DynLib* m_parent); DynLibImpl(const DynLibImpl&) = delete; DynLibImpl(DynLibImpl&&) = delete; ///TODO? - ~DynLibImpl() = default; + ~DynLibImpl(); - DynLibFunc GetSymbol(const String& symbol, String* errorMessage) const; - bool Load(const String& libraryPath, String* errorMessage); - void Unload(); + DynLibFunc GetSymbol(const char* symbol, std::string* errorMessage) const; + bool Load(const std::filesystem::path& libraryPath, std::string* errorMessage); DynLibImpl& operator=(const DynLibImpl&) = delete; DynLibImpl& operator=(DynLibImpl&&) = delete; ///TODO? diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index 4e5d75c6c..5b1fe952b 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -18,9 +19,10 @@ namespace Nz NazaraUnused(parent); } - void FileImpl::Close() + FileImpl::~FileImpl() { - CloseHandle(m_handle); + if (m_handle) + CloseHandle(m_handle); } bool FileImpl::EndOfFile() const @@ -55,7 +57,7 @@ namespace Nz return position.QuadPart; } - bool FileImpl::Open(const String& filePath, OpenModeFlags mode) + bool FileImpl::Open(const std::filesystem::path& filePath, OpenModeFlags mode) { DWORD access = 0; DWORD shareMode = FILE_SHARE_READ; @@ -87,7 +89,7 @@ namespace Nz if ((mode & OpenMode_Lock) == 0) shareMode |= FILE_SHARE_WRITE; - m_handle = CreateFileW(filePath.GetWideString().data(), access, shareMode, nullptr, openMode, 0, nullptr); + m_handle = CreateFileW(ToWideString(filePath.generic_u8string()).data(), access, shareMode, nullptr, openMode, 0, nullptr); return m_handle != INVALID_HANDLE_VALUE; } @@ -197,118 +199,4 @@ namespace Nz return written; } - - bool FileImpl::Copy(const String& sourcePath, const String& targetPath) - { - if (CopyFileW(sourcePath.GetWideString().data(), targetPath.GetWideString().data(), false)) - return true; - else - { - NazaraError("Failed to copy file: " + Error::GetLastSystemError()); - return false; - } - } - - bool FileImpl::Delete(const String& filePath) - { - if (DeleteFileW(filePath.GetWideString().data())) - return true; - else - { - NazaraError("Failed to delete file (" + filePath + "): " + Error::GetLastSystemError()); - return false; - } - } - - bool FileImpl::Exists(const String& filePath) - { - HANDLE handle = CreateFileW(filePath.GetWideString().data(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); - if (handle == INVALID_HANDLE_VALUE) - return false; - - CloseHandle(handle); - return true; - } - - time_t FileImpl::GetCreationTime(const String& filePath) - { - HANDLE handle = CreateFileW(filePath.GetWideString().data(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); - if (handle == INVALID_HANDLE_VALUE) - return 0; - - FILETIME creationTime; - if (!GetFileTime(handle, &creationTime, nullptr, nullptr)) - { - CloseHandle(handle); - - NazaraError("Unable to get creation time: " + Error::GetLastSystemError()); - return 0; - } - - CloseHandle(handle); - return FileTimeToTime(&creationTime); - } - - time_t FileImpl::GetLastAccessTime(const String& filePath) - { - HANDLE handle = CreateFileW(filePath.GetWideString().data(), 0, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); - if (handle == INVALID_HANDLE_VALUE) - return 0; - - FILETIME accessTime; - if (!GetFileTime(handle, nullptr, &accessTime, nullptr)) - { - CloseHandle(handle); - - NazaraError("Unable to get last access time: " + Error::GetLastSystemError()); - return 0; - } - - CloseHandle(handle); - return FileTimeToTime(&accessTime); - } - - time_t FileImpl::GetLastWriteTime(const String& filePath) - { - HANDLE handle = CreateFileW(filePath.GetWideString().data(), 0, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); - if (handle == INVALID_HANDLE_VALUE) - return 0; - - FILETIME writeTime; - if (!GetFileTime(handle, nullptr, nullptr, &writeTime)) - { - CloseHandle(handle); - - NazaraError("Unable to get last write time: " + Error::GetLastSystemError()); - return 0; - } - - CloseHandle(handle); - return FileTimeToTime(&writeTime); - } - - UInt64 FileImpl::GetSize(const String& filePath) - { - HANDLE handle = CreateFileW(filePath.GetWideString().data(), 0, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); - if (handle == INVALID_HANDLE_VALUE) - return 0; - - LARGE_INTEGER fileSize; - if (!GetFileSizeEx(handle, &fileSize)) - fileSize.QuadPart = 0; - - CloseHandle(handle); - return fileSize.QuadPart; - } - - bool FileImpl::Rename(const String& sourcePath, const String& targetPath) - { - if (MoveFileExW(sourcePath.GetWideString().data(), targetPath.GetWideString().data(), MOVEFILE_COPY_ALLOWED)) - return true; - else - { - NazaraError("Unable to rename file: " + Error::GetLastSystemError()); - return false; - } - } } diff --git a/src/Nazara/Core/Win32/FileImpl.hpp b/src/Nazara/Core/Win32/FileImpl.hpp index 6595c58b2..3380a71e4 100644 --- a/src/Nazara/Core/Win32/FileImpl.hpp +++ b/src/Nazara/Core/Win32/FileImpl.hpp @@ -23,13 +23,12 @@ namespace Nz FileImpl(const File* parent); FileImpl(const FileImpl&) = delete; FileImpl(FileImpl&&) = delete; ///TODO - ~FileImpl() = default; + ~FileImpl(); - void Close(); bool EndOfFile() const; void Flush(); UInt64 GetCursorPos() const; - bool Open(const String& filePath, OpenModeFlags mode); + bool Open(const std::filesystem::path& filePath, OpenModeFlags mode); std::size_t Read(void* buffer, std::size_t size); bool SetCursorPos(CursorPosition pos, Int64 offset); bool SetSize(UInt64 size); @@ -38,15 +37,6 @@ namespace Nz FileImpl& operator=(const FileImpl&) = delete; FileImpl& operator=(FileImpl&&) = delete; ///TODO - static bool Copy(const String& sourcePath, const String& targetPath); - static bool Delete(const String& filePath); - static bool Exists(const String& filePath); - static time_t GetCreationTime(const String& filePath); - static time_t GetLastAccessTime(const String& filePath); - static time_t GetLastWriteTime(const String& filePath); - static UInt64 GetSize(const String& filePath); - static bool Rename(const String& sourcePath, const String& targetPath); - private: HANDLE m_handle; mutable bool m_endOfFile; diff --git a/src/Nazara/Core/Win32/MutexImpl.cpp b/src/Nazara/Core/Win32/MutexImpl.cpp deleted file mode 100644 index 7c4e18f34..000000000 --- a/src/Nazara/Core/Win32/MutexImpl.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - MutexImpl::MutexImpl() - { - #if NAZARA_CORE_WINDOWS_CS_SPINLOCKS > 0 - InitializeCriticalSectionAndSpinCount(&m_criticalSection, NAZARA_CORE_WINDOWS_CS_SPINLOCKS); - #else - InitializeCriticalSection(&m_criticalSection); - #endif - } - - MutexImpl::~MutexImpl() - { - DeleteCriticalSection(&m_criticalSection); - } - - void MutexImpl::Lock() - { - EnterCriticalSection(&m_criticalSection); - } - - bool MutexImpl::TryLock() - { - return TryEnterCriticalSection(&m_criticalSection) != 0; - } - - void MutexImpl::Unlock() - { - LeaveCriticalSection(&m_criticalSection); - } -} diff --git a/src/Nazara/Core/Win32/MutexImpl.hpp b/src/Nazara/Core/Win32/MutexImpl.hpp deleted file mode 100644 index e411d4fa2..000000000 --- a/src/Nazara/Core/Win32/MutexImpl.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_MUTEXIMPL_HPP -#define NAZARA_MUTEXIMPL_HPP - -#include -#include - -namespace Nz -{ - class MutexImpl - { - friend class ConditionVariableImpl; - - public: - MutexImpl(); - ~MutexImpl(); - - void Lock(); - bool TryLock(); - void Unlock(); - - private: - CRITICAL_SECTION m_criticalSection; - }; -} - -#endif // NAZARA_MUTEXIMPL_HPP diff --git a/src/Nazara/Core/Win32/SemaphoreImpl.cpp b/src/Nazara/Core/Win32/SemaphoreImpl.cpp deleted file mode 100644 index 19bc17c74..000000000 --- a/src/Nazara/Core/Win32/SemaphoreImpl.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - SemaphoreImpl::SemaphoreImpl(unsigned int count) - { - m_semaphore = CreateSemaphoreW(nullptr, count, std::numeric_limits::max(), nullptr); - if (!m_semaphore) - NazaraError("Failed to create semaphore: " + Error::GetLastSystemError()); - } - - SemaphoreImpl::~SemaphoreImpl() - { - CloseHandle(m_semaphore); - } - - unsigned int SemaphoreImpl::GetCount() const - { - LONG count; - ReleaseSemaphore(m_semaphore, 0, &count); - return count; - } - - void SemaphoreImpl::Post() - { - #if NAZARA_CORE_SAFE - if (!ReleaseSemaphore(m_semaphore, 1, nullptr)) - NazaraError("Failed to release semaphore: " + Error::GetLastSystemError()); - #else - ReleaseSemaphore(m_semaphore, 1, nullptr); - #endif - } - - void SemaphoreImpl::Wait() - { - #if NAZARA_CORE_SAFE - if (WaitForSingleObject(m_semaphore, INFINITE) == WAIT_FAILED) - NazaraError("Failed to wait for semaphore: " + Error::GetLastSystemError()); - #else - WaitForSingleObject(m_semaphore, INFINITE); - #endif - } - - bool SemaphoreImpl::Wait(UInt32 timeout) - { - #if NAZARA_CORE_SAFE - DWORD result = WaitForSingleObject(m_semaphore, timeout); - if (result == WAIT_FAILED) - { - NazaraError("Failed to wait for semaphore: " + Error::GetLastSystemError()); - return false; - } - else - return result == WAIT_OBJECT_0; - #else - return WaitForSingleObject(m_semaphore, timeout) == WAIT_OBJECT_0; - #endif - } -} diff --git a/src/Nazara/Core/Win32/SemaphoreImpl.hpp b/src/Nazara/Core/Win32/SemaphoreImpl.hpp deleted file mode 100644 index 3dad0d9a3..000000000 --- a/src/Nazara/Core/Win32/SemaphoreImpl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SEMAPHOREIMPL_HPP -#define NAZARA_SEMAPHOREIMPL_HPP - -#include -#include - -namespace Nz -{ - class SemaphoreImpl - { - public: - SemaphoreImpl(unsigned int count); - ~SemaphoreImpl(); - - unsigned int GetCount() const; - void Post(); - void Wait(); - bool Wait(UInt32 timeout); - - private: - HANDLE m_semaphore; - }; -} - -#endif // NAZARA_SEMAPHOREIMPL_HPP diff --git a/src/Nazara/Core/Win32/ThreadImpl.cpp b/src/Nazara/Core/Win32/ThreadImpl.cpp deleted file mode 100644 index 0ad2293cc..000000000 --- a/src/Nazara/Core/Win32/ThreadImpl.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - // Windows 10, version 1607 brought SetThreadDescription in order to name a thread - using SetThreadDescriptionFunc = HRESULT(WINAPI*)(HANDLE hThread, PCWSTR lpThreadDescription); - -#ifdef NAZARA_COMPILER_MSVC - namespace - { -#pragma pack(push,8) - struct THREADNAME_INFO - { - DWORD dwType; - LPCSTR szName; - DWORD dwThreadID; - DWORD dwFlags; - }; -#pragma pack(pop) - } -#endif - - ThreadImpl::ThreadImpl(Functor* functor) - { - unsigned int threadId; - m_handle = reinterpret_cast(_beginthreadex(nullptr, 0, &ThreadImpl::ThreadProc, functor, 0, &threadId)); - if (!m_handle) - NazaraInternalError("Failed to create thread: " + Error::GetLastSystemError()); - - m_threadId = threadId; - } - - void ThreadImpl::Detach() - { - // http://stackoverflow.com/questions/418742/is-it-reasonable-to-call-closehandle-on-a-thread-before-it-terminates - CloseHandle(m_handle); - } - - void ThreadImpl::Join() - { - WaitForSingleObject(m_handle, INFINITE); - CloseHandle(m_handle); - } - - void ThreadImpl::SetName(const Nz::String& name) - { - SetThreadName(m_handle, name); - } - - void ThreadImpl::SetCurrentName(const Nz::String& name) - { - SetThreadName(::GetCurrentThread(), name); - } - - void ThreadImpl::Sleep(UInt32 time) - { - ::Sleep(time); - } - - void ThreadImpl::RaiseThreadNameException(DWORD threadId, const char* threadName) - { -#ifdef NAZARA_COMPILER_MSVC - if (!::IsDebuggerPresent()) - return; - - // https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx - constexpr DWORD MS_VC_EXCEPTION = 0x406D1388; - - THREADNAME_INFO info; - info.dwType = 0x1000; - info.szName = threadName; - info.dwThreadID = threadId; - info.dwFlags = 0; - -#pragma warning(push) -#pragma warning(disable: 6320 6322) - __try - { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), reinterpret_cast(&info)); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - } -#pragma warning(pop) -#else - NazaraWarning("SetThreadDescription is not supported and threadname exception is only supported with MSVC"); -#endif - } - - void ThreadImpl::SetThreadName(HANDLE threadHandle, const Nz::String& name) - { - // Try to use SetThreadDescription if available - static SetThreadDescriptionFunc SetThreadDescription = reinterpret_cast(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"), "SetThreadDescription")); - if (SetThreadDescription) - SetThreadDescription(threadHandle, name.GetWideString().data()); - else - RaiseThreadNameException(::GetThreadId(threadHandle), name.GetConstBuffer()); - } - - unsigned int __stdcall ThreadImpl::ThreadProc(void* userdata) - { - Functor* func = static_cast(userdata); - func->Run(); - delete func; - - /* - En C++, il vaut mieux retourner depuis la fonction que de quitter le thread explicitement - Source : http://msdn.microsoft.com/en-us/library/windows/desktop/ms682659(v=vs.85).aspx - */ - - return 0; - } -} diff --git a/src/Nazara/Core/Win32/ThreadImpl.hpp b/src/Nazara/Core/Win32/ThreadImpl.hpp deleted file mode 100644 index c12697611..000000000 --- a/src/Nazara/Core/Win32/ThreadImpl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Core module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Inspiré du code de la SFML par Laurent Gomila - -#pragma once - -#ifndef NAZARA_THREADIMPL_HPP -#define NAZARA_THREADIMPL_HPP - -#include -#include -#include - -namespace Nz -{ - struct Functor; - - class ThreadImpl - { - public: - ThreadImpl(Functor* threadFunc); - - void Detach(); - void Join(); - void SetName(const Nz::String& name); - - static void SetCurrentName(const Nz::String& name); - static void Sleep(UInt32 time); - - private: - static void RaiseThreadNameException(DWORD threadId, const char* threadName); - static void SetThreadName(HANDLE threadHandle, const Nz::String& name); - static unsigned int __stdcall ThreadProc(void* userdata); - - DWORD m_threadId; - HANDLE m_handle; - }; -} - -#endif // NAZARA_THREADIMPL_HPP diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index d21ed58c1..5b8df3932 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -22,13 +22,14 @@ namespace Nz { const ParameterList& matData = model->GetMesh()->GetMaterialData(i); - String filePath; - if (matData.GetStringParameter(MaterialData::FilePath, &filePath)) + String path; + if (matData.GetStringParameter(MaterialData::FilePath, &path)) { - if (!File::Exists(filePath)) + std::filesystem::path filePath = path.ToStdString(); + if (!std::filesystem::exists(filePath)) { NazaraWarning("Shader name does not refer to an existing file, \".tga\" is used by default"); - filePath += ".tga"; + filePath.replace_extension(".tga"); } if (MaterialRef material = Material::LoadFromFile(filePath, parameters.material)) diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 81c50ab85..08b769c1a 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -115,7 +115,7 @@ namespace Nz bool isEnabled; double dValue; long long iValue; - String path; + Nz::String path; ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled, true); @@ -247,22 +247,22 @@ namespace Nz // Textures if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path)) - SetAlphaMap(path); + SetAlphaMap(path.ToStdString()); if (matParams.loadDiffuseMap && matData.GetStringParameter(MaterialData::DiffuseTexturePath, &path)) - SetDiffuseMap(path); + SetDiffuseMap(path.ToStdString()); if (matParams.loadEmissiveMap && matData.GetStringParameter(MaterialData::EmissiveTexturePath, &path)) - SetEmissiveMap(path); + SetEmissiveMap(path.ToStdString()); if (matParams.loadHeightMap && matData.GetStringParameter(MaterialData::HeightTexturePath, &path)) - SetHeightMap(path); + SetHeightMap(path.ToStdString()); if (matParams.loadNormalMap && matData.GetStringParameter(MaterialData::NormalTexturePath, &path)) - SetNormalMap(path); + SetNormalMap(path.ToStdString()); if (matParams.loadSpecularMap && matData.GetStringParameter(MaterialData::SpecularTexturePath, &path)) - SetSpecularMap(path); + SetSpecularMap(path.ToStdString()); SetShader(matParams.shaderName); } @@ -329,44 +329,44 @@ namespace Nz // Textures if (HasAlphaMap()) { - const String& path = GetAlphaMap()->GetFilePath(); - if (!path.IsEmpty()) - matData->SetParameter(MaterialData::AlphaTexturePath, path); + const std::filesystem::path& path = GetAlphaMap()->GetFilePath(); + if (!path.empty()) + matData->SetParameter(MaterialData::AlphaTexturePath, path.generic_u8string()); } if (HasDiffuseMap()) { - const String& path = GetDiffuseMap()->GetFilePath(); - if (!path.IsEmpty()) - matData->SetParameter(MaterialData::DiffuseTexturePath, path); + const std::filesystem::path& path = GetDiffuseMap()->GetFilePath(); + if (!path.empty()) + matData->SetParameter(MaterialData::DiffuseTexturePath, path.generic_u8string()); } if (HasEmissiveMap()) { - const String& path = GetEmissiveMap()->GetFilePath(); - if (!path.IsEmpty()) - matData->SetParameter(MaterialData::EmissiveTexturePath, path); + const std::filesystem::path& path = GetEmissiveMap()->GetFilePath(); + if (!path.empty()) + matData->SetParameter(MaterialData::EmissiveTexturePath, path.generic_u8string()); } if (HasHeightMap()) { - const String& path = GetHeightMap()->GetFilePath(); - if (!path.IsEmpty()) - matData->SetParameter(MaterialData::HeightTexturePath, path); + const std::filesystem::path& path = GetHeightMap()->GetFilePath(); + if (!path.empty()) + matData->SetParameter(MaterialData::HeightTexturePath, path.generic_u8string()); } if (HasNormalMap()) { - const String& path = GetNormalMap()->GetFilePath(); - if (!path.IsEmpty()) - matData->SetParameter(MaterialData::NormalTexturePath, path); + const std::filesystem::path& path = GetNormalMap()->GetFilePath(); + if (!path.empty()) + matData->SetParameter(MaterialData::NormalTexturePath, path.generic_u8string()); } if (HasSpecularMap()) { - const String& path = GetSpecularMap()->GetFilePath(); - if (!path.IsEmpty()) - matData->SetParameter(MaterialData::SpecularTexturePath, path); + const std::filesystem::path& path = GetSpecularMap()->GetFilePath(); + if (!path.empty()) + matData->SetParameter(MaterialData::SpecularTexturePath, path.generic_u8string()); } } diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 743984783..37e5f8ca0 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace Nz @@ -29,7 +30,7 @@ namespace Nz #include }; - void OverrideShader(const String& path, String* source) + void OverrideShader(const std::filesystem::path& path, String* source) { ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled); @@ -46,7 +47,7 @@ namespace Nz *source = shaderSource; - NazaraNotice(path + " will be used to override built-in shader"); + NazaraNotice(path.generic_u8string() + " will be used to override built-in shader"); } } } diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index 5a6b1cfca..31187023b 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -86,7 +86,7 @@ namespace Nz * \remark Produces a NazaraError if there is no subMesh with that name * \remark Produces a NazaraError if material is invalid */ - const MaterialRef& Model::GetMaterial(const String& subMeshName) const + const MaterialRef& Model::GetMaterial(const std::string& subMeshName) const { NazaraAssert(m_mesh, "Model has no mesh"); @@ -113,7 +113,7 @@ namespace Nz * \remark Produces a NazaraError if there is no subMesh with that name * \remark Produces a NazaraError if material index is invalid */ - const MaterialRef& Model::GetMaterial(std::size_t skinIndex, const String& subMeshName) const + const MaterialRef& Model::GetMaterial(std::size_t skinIndex, const std::string& subMeshName) const { NazaraAssert(m_mesh, "Model has no mesh"); @@ -160,7 +160,7 @@ namespace Nz * \remark Produces a NazaraError if material index is invalid */ - bool Model::SetMaterial(const String& subMeshName, MaterialRef material) + bool Model::SetMaterial(const std::string& subMeshName, MaterialRef material) { SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName); if (!subMesh) @@ -185,7 +185,7 @@ namespace Nz * \remark Produces a NazaraError if there is no subMesh with that name * \remark Produces a NazaraError if material index is invalid */ - bool Model::SetMaterial(std::size_t skinIndex, const String& subMeshName, MaterialRef material) + bool Model::SetMaterial(std::size_t skinIndex, const std::string& subMeshName, MaterialRef material) { SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName); if (!subMesh) @@ -239,7 +239,7 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the model */ - ModelRef Model::LoadFromFile(const String& filePath, const ModelParameters& params) + ModelRef Model::LoadFromFile(const std::filesystem::path& filePath, const ModelParameters& params) { return ModelLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 0c16de174..6a01fd5d2 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -56,7 +56,7 @@ namespace Nz * * \return True if the material was found or loaded from its name/path, false if it couldn't */ - bool Sprite::SetMaterial(String materialName, bool resizeSprite) + bool Sprite::SetMaterial(std::string materialName, bool resizeSprite) { MaterialRef material = MaterialLibrary::Query(materialName); if (!material) @@ -85,7 +85,7 @@ namespace Nz * * \return True if the material was found or loaded from its name/path, false if it couldn't */ - bool Sprite::SetMaterial(std::size_t skinIndex, String materialName, bool resizeSprite) + bool Sprite::SetMaterial(std::size_t skinIndex, std::string materialName, bool resizeSprite) { MaterialRef material = MaterialLibrary::Query(materialName); if (!material) @@ -114,7 +114,7 @@ namespace Nz * * \remark The sprite material gets copied to prevent accidentally changing other drawable materials */ - bool Sprite::SetTexture(String textureName, bool resizeSprite) + bool Sprite::SetTexture(std::string textureName, bool resizeSprite) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) @@ -144,7 +144,7 @@ namespace Nz * * \remark The sprite material gets copied to prevent accidentally changing other drawable materials */ - bool Sprite::SetTexture(std::size_t skinIndex, String textureName, bool resizeSprite) + bool Sprite::SetTexture(std::size_t skinIndex, std::string textureName, bool resizeSprite) { TextureRef texture = TextureLibrary::Query(textureName); if (!texture) diff --git a/src/Nazara/Lua/LuaState.cpp b/src/Nazara/Lua/LuaState.cpp index 6065087d6..c18367c30 100644 --- a/src/Nazara/Lua/LuaState.cpp +++ b/src/Nazara/Lua/LuaState.cpp @@ -371,7 +371,7 @@ namespace Nz return CallWithHandler(errorHandler, 0); } - bool LuaState::ExecuteFromFile(const String& filePath, int errorHandler) + bool LuaState::ExecuteFromFile(const std::filesystem::path& filePath, int errorHandler) { if (!LoadFromFile(filePath)) return false; @@ -539,7 +539,7 @@ namespace Nz return true; } - bool LuaState::LoadFromFile(const String& filePath) + bool LuaState::LoadFromFile(const std::filesystem::path& filePath) { File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 4df6e0cae..0887e7d3f 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include @@ -113,7 +112,7 @@ namespace Nz std::size_t size = m_buffer->GetSize(); - Nz::LockGuard lock(*s_availableBuffersMutex); + std::lock_guard lock(s_availableBuffersMutex); s_availableBuffers.emplace_back(std::make_pair(size, std::move(m_buffer))); } @@ -132,7 +131,7 @@ namespace Nz NazaraAssert(minCapacity >= cursorPos, "Cannot init stream with a smaller capacity than wanted cursor pos"); { - Nz::LockGuard lock(*s_availableBuffersMutex); + std::lock_guard lock(s_availableBuffersMutex); FreeStream(); //< In case it wasn't released yet @@ -160,7 +159,6 @@ namespace Nz bool NetPacket::Initialize() { - s_availableBuffersMutex = std::make_unique(); return true; } @@ -171,9 +169,8 @@ namespace Nz void NetPacket::Uninitialize() { s_availableBuffers.clear(); - s_availableBuffersMutex.reset(); } - std::unique_ptr NetPacket::s_availableBuffersMutex; + std::mutex NetPacket::s_availableBuffersMutex; std::vector>> NetPacket::s_availableBuffers; } diff --git a/src/Nazara/Platform/Win32/WindowImpl.cpp b/src/Nazara/Platform/Win32/WindowImpl.cpp index 6ee3365ac..edc5dd1d6 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.cpp +++ b/src/Nazara/Platform/Win32/WindowImpl.cpp @@ -5,10 +5,7 @@ // Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation #include -#include #include -#include -#include #include #include #include @@ -130,15 +127,15 @@ namespace Nz if (async) { - Mutex mutex; - ConditionVariable condition; + std::mutex mutex; + std::condition_variable condition; m_threadActive = true; // On attend que la fenêtre soit créée - mutex.Lock(); - m_thread = Thread(WindowThread, &m_handle, win32StyleEx, title, win32Style, fullscreen, Rectui(x, y, width, height), this, &mutex, &condition); - condition.Wait(&mutex); - mutex.Unlock(); + std::unique_lock lock(mutex); + m_thread = std::thread(WindowThread, std::ref(m_handle), win32StyleEx, title, win32Style, fullscreen, Rectui(x, y, width, height), this, std::ref(mutex), std::ref(condition)); + + condition.wait(lock); } else m_handle = CreateWindowExW(win32StyleEx, className, title.GetWideString().data(), win32Style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this); @@ -186,12 +183,12 @@ namespace Nz { if (m_style & WindowStyle_Threaded) { - if (m_thread.IsJoinable()) + if (m_thread.joinable()) { m_threadActive = false; PostMessageW(m_handle, WM_NULL, 0, 0); // Wake up our thread - m_thread.Join(); + m_thread.join(); } } else @@ -1151,24 +1148,24 @@ namespace Nz return style; } - void WindowImpl::WindowThread(HWND* handle, DWORD styleEx, const String& title, DWORD style, bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition) + void WindowImpl::WindowThread(HWND& handle, DWORD styleEx, const String& title, DWORD style, bool fullscreen, const Rectui& dimensions, WindowImpl* window, std::mutex& mutex, std::condition_variable& condition) { - HWND& winHandle = *handle; - winHandle = CreateWindowExW(styleEx, className, title.GetWideString().data(), style, dimensions.x, dimensions.y, dimensions.width, dimensions.height, nullptr, nullptr, GetModuleHandle(nullptr), window); + handle = CreateWindowExW(styleEx, className, title.GetWideString().data(), style, dimensions.x, dimensions.y, dimensions.width, dimensions.height, nullptr, nullptr, GetModuleHandle(nullptr), window); - if (winHandle) + if (handle) window->PrepareWindow(fullscreen); - mutex->Lock(); - condition->Signal(); - mutex->Unlock(); // mutex and condition may be destroyed after this line + { + std::lock_guard lock(mutex); + condition.notify_all(); + } - if (!winHandle) + if (!handle) return; while (window->m_threadActive) window->ProcessEvents(true); - DestroyWindow(winHandle); + DestroyWindow(handle); } } diff --git a/src/Nazara/Platform/Win32/WindowImpl.hpp b/src/Nazara/Platform/Win32/WindowImpl.hpp index e05a86fdf..8165ae8c5 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.hpp +++ b/src/Nazara/Platform/Win32/WindowImpl.hpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -19,12 +18,13 @@ #include #include #include +#include +#include +#include #include namespace Nz { - class ConditionVariable; - class Mutex; class Window; #undef IsMinimized // Conflits with windows.h redefinition @@ -87,7 +87,7 @@ namespace Nz static Keyboard::Key ConvertVirtualKey(WPARAM key, LPARAM flags); static LRESULT CALLBACK MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam); static UInt32 RetrieveStyle(HWND window); - static void WindowThread(HWND* handle, DWORD styleEx, const String& title, DWORD style, bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); + static void WindowThread(HWND& handle, DWORD styleEx, const String& title, DWORD style, bool fullscreen, const Rectui& dimensions, WindowImpl* window, std::mutex& mutex, std::condition_variable& condition); HCURSOR m_cursor; HWND m_handle; @@ -98,7 +98,7 @@ namespace Nz Vector2i m_mousePos; Vector2i m_position; Vector2ui m_size; - Thread m_thread; + std::thread m_thread; Window* m_parent; bool m_eventListener; bool m_keyRepeat; diff --git a/src/Nazara/Platform/Window.cpp b/src/Nazara/Platform/Window.cpp index 9ce743ad4..90b6556a2 100644 --- a/src/Nazara/Platform/Window.cpp +++ b/src/Nazara/Platform/Window.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -39,13 +38,10 @@ namespace Nz Window::Window(Window&& window) : m_events(std::move(window.m_events)), m_pendingEvents(std::move(window.m_pendingEvents)), - m_eventCondition(std::move(window.m_eventCondition)), m_cursorController(std::move(window.m_cursorController)), m_cursor(std::move(window.m_cursor)), m_eventHandler(std::move(window.m_eventHandler)), m_icon(std::move(window.m_icon)), - m_eventMutex(std::move(window.m_eventMutex)), - m_eventConditionMutex(std::move(window.m_eventConditionMutex)), m_asyncWindow(window.m_asyncWindow), m_closed(window.m_asyncWindow), m_closeOnQuit(window.m_closeOnQuit), @@ -344,7 +340,7 @@ namespace Nz m_impl->ProcessEvents(block); else { - LockGuard eventLock(m_eventMutex); + std::lock_guard eventLock(m_eventMutex); for (const WindowEvent& event : m_pendingEvents) HandleEvent(event); @@ -570,16 +566,19 @@ namespace Nz } else { - LockGuard lock(m_eventMutex); + std::lock_guard lock(m_eventMutex); if (m_events.empty()) { m_waitForEvent = true; - m_eventConditionMutex.Lock(); - m_eventMutex.Unlock(); - m_eventCondition.Wait(&m_eventConditionMutex); - m_eventMutex.Lock(); - m_eventConditionMutex.Unlock(); + { + m_eventMutex.unlock(); + + std::unique_lock eventConditionLock(m_eventConditionMutex); + m_eventCondition.wait(eventConditionLock); + + m_eventMutex.lock(); + } m_waitForEvent = false; } @@ -601,13 +600,10 @@ namespace Nz { m_events = std::move(window.m_events); m_pendingEvents = std::move(window.m_pendingEvents); - m_eventCondition = std::move(window.m_eventCondition); m_cursorController = std::move(window.m_cursorController); m_cursor = std::move(window.m_cursor); m_eventHandler = std::move(window.m_eventHandler); m_icon = std::move(window.m_icon); - m_eventMutex = std::move(window.m_eventMutex); - m_eventConditionMutex = std::move(window.m_eventConditionMutex); m_asyncWindow = window.m_asyncWindow; m_closed = window.m_asyncWindow; m_closeOnQuit = window.m_closeOnQuit; diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index b1ade1d95..b4d4f259b 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -5,10 +5,10 @@ #include #include #include -#include #include #include #include +#include #include namespace Nz @@ -137,7 +137,7 @@ namespace Nz { int remainingTime = 1000/static_cast(m_framerateLimit) - static_cast(m_clock.GetMilliseconds()); if (remainingTime > 0) - Thread::Sleep(remainingTime); + std::this_thread::sleep_for(std::chrono::milliseconds(remainingTime)); m_clock.Restart(); } diff --git a/src/Nazara/Renderer/Shader.cpp b/src/Nazara/Renderer/Shader.cpp index bfef4c12d..a3e5662ce 100644 --- a/src/Nazara/Renderer/Shader.cpp +++ b/src/Nazara/Renderer/Shader.cpp @@ -62,7 +62,7 @@ namespace Nz m_attachedShaders[stage].push_back(shader); } - bool Shader::AttachStageFromFile(ShaderStageType stage, const String& filePath) + bool Shader::AttachStageFromFile(ShaderStageType stage, const std::filesystem::path& filePath) { ShaderStage shaderStage(stage); if (!shaderStage.IsValid()) diff --git a/src/Nazara/Renderer/ShaderStage.cpp b/src/Nazara/Renderer/ShaderStage.cpp index 29f434091..bf88c4a06 100644 --- a/src/Nazara/Renderer/ShaderStage.cpp +++ b/src/Nazara/Renderer/ShaderStage.cpp @@ -165,7 +165,7 @@ namespace Nz glShaderSource(m_id, 1, &tmp, &length); } - bool ShaderStage::SetSourceFromFile(const String& filePath) + bool ShaderStage::SetSourceFromFile(const std::filesystem::path& filePath) { #if NAZARA_RENDERER_SAFE if (!m_id) @@ -178,7 +178,7 @@ namespace Nz File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) { - NazaraError("Failed to open \"" + filePath + '"'); + NazaraError("Failed to open \"" + filePath.generic_u8string() + '"'); return false; } diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index a03dc558a..7ade50291 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -483,7 +483,7 @@ namespace Nz return m_impl != nullptr; } - bool Texture::LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params) + bool Texture::LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -601,7 +601,7 @@ namespace Nz return Update(image, Rectui(0, 0, faceSize, faceSize), face); } - bool Texture::SaveToFile(const String& filePath, const ImageParams& params) + bool Texture::SaveToFile(const std::filesystem::path& filePath, const ImageParams& params) { Image image; if (!Download(&image)) @@ -613,7 +613,7 @@ namespace Nz return image.SaveToFile(filePath, params); } - bool Texture::SaveToStream(Stream& stream, const String& format, const ImageParams& params) + bool Texture::SaveToStream(Stream& stream, const std::string& format, const ImageParams& params) { Image image; if (!Download(&image)) @@ -935,7 +935,7 @@ namespace Nz return false; } - TextureRef Texture::LoadFromFile(const String& filePath, const ImageParams& params, bool generateMipmaps) + TextureRef Texture::LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params, bool generateMipmaps) { ImageRef image = Image::LoadFromFile(filePath, params); if (!image) @@ -1047,7 +1047,7 @@ namespace Nz return LoadFromImage(image, generateMipmaps); } - TextureRef Texture::LoadArrayFromFile(const String& filePath, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize) + TextureRef Texture::LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize) { ImageRef cubemap = Image::LoadArrayFromFile(filePath, imageParams, atlasSize); if (!cubemap) @@ -1095,7 +1095,7 @@ namespace Nz return LoadFromImage(cubemap, generateMipmaps); } - TextureRef Texture::LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams) + TextureRef Texture::LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams) { ImageRef cubemap = Image::LoadCubemapFromFile(filePath, imageParams, cubemapParams); if (!cubemap) diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp index 50eed66ac..aec846a09 100644 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderPreprocessor.cpp @@ -166,12 +166,12 @@ namespace Nz } } - bool UberShaderPreprocessor::SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags) + bool UberShaderPreprocessor::SetShaderFromFile(ShaderStageType stage, const std::filesystem::path& filePath, const String& shaderFlags, const String& requiredFlags) { File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) { - NazaraError("Failed to open \"" + filePath + '"'); + NazaraError("Failed to open \"" + filePath.generic_u8string() + '"'); return false; } diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp index fa975747d..d221e3d86 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.cpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.cpp @@ -7,11 +7,10 @@ #include #include #include -#include -#include #include #include #include +#include #include namespace Nz @@ -185,8 +184,8 @@ namespace Nz if (shareContext) { // wglShareLists n'est pas thread-safe (source: SFML) - static Mutex mutex; - LockGuard lock(mutex); + static std::mutex mutex; + std::lock_guard lock(mutex); if (!wglShareLists(shareContext, m_context)) NazaraWarning("Failed to share the context: " + Error::GetLastSystemError()); diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index d60e095ee..1a05ef423 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -16,13 +16,13 @@ namespace Nz { struct AnimationImpl { - std::unordered_map sequenceMap; + std::unordered_map sequenceMap; std::vector sequences; std::vector sequenceJoints; // Uniquement pour les animations squelettiques AnimationType type; bool loopPointInterpolation = false; - UInt32 frameCount; - UInt32 jointCount; // Uniquement pour les animations squelettiques + std::size_t frameCount; + std::size_t jointCount; // Uniquement pour les animations squelettiques }; bool AnimationParams::IsValid() const @@ -50,7 +50,7 @@ namespace Nz if (m_impl->type == AnimationType_Skeletal) { - UInt32 endFrame = sequence.firstFrame + sequence.frameCount - 1; + std::size_t endFrame = sequence.firstFrame + sequence.frameCount - 1; if (endFrame >= m_impl->frameCount) { m_impl->frameCount = endFrame+1; @@ -69,7 +69,7 @@ namespace Nz } #endif - m_impl->sequenceMap[sequence.name] = static_cast(m_impl->sequences.size()); + m_impl->sequenceMap[sequence.name] = static_cast(m_impl->sequences.size()); } m_impl->sequences.push_back(sequence); @@ -77,7 +77,7 @@ namespace Nz return true; } - void Animation::AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const + void Animation::AnimateSkeleton(Skeleton* targetSkeleton, std::size_t frameA, std::size_t frameB, float interpolation) const { NazaraAssert(m_impl, "Animation not created"); NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); @@ -86,7 +86,7 @@ namespace Nz NazaraAssert(frameA < m_impl->frameCount, "FrameA is out of range"); NazaraAssert(frameB < m_impl->frameCount, "FrameB is out of range"); - for (UInt32 i = 0; i < m_impl->jointCount; ++i) + for (std::size_t i = 0; i < m_impl->jointCount; ++i) { Joint* joint = targetSkeleton->GetJoint(i); @@ -99,7 +99,7 @@ namespace Nz } } - bool Animation::CreateSkeletal(UInt32 frameCount, UInt32 jointCount) + bool Animation::CreateSkeletal(std::size_t frameCount, std::size_t jointCount) { NazaraAssert(frameCount > 0, "Frame count must be over zero"); NazaraAssert(jointCount > 0, "Frame count must be over zero"); @@ -133,14 +133,14 @@ namespace Nz m_impl->loopPointInterpolation = loopPointInterpolation; } - UInt32 Animation::GetFrameCount() const + std::size_t Animation::GetFrameCount() const { NazaraAssert(m_impl, "Animation not created"); return m_impl->frameCount; } - UInt32 Animation::GetJointCount() const + std::size_t Animation::GetJointCount() const { NazaraAssert(m_impl, "Animation not created"); @@ -161,7 +161,7 @@ namespace Nz return &m_impl->sequences[it->second]; } - Sequence* Animation::GetSequence(UInt32 index) + Sequence* Animation::GetSequence(std::size_t index) { NazaraAssert(m_impl, "Animation not created"); NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); @@ -183,7 +183,7 @@ namespace Nz return &m_impl->sequences[it->second]; } - const Sequence* Animation::GetSequence(UInt32 index) const + const Sequence* Animation::GetSequence(std::size_t index) const { NazaraAssert(m_impl, "Animation not created"); NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); @@ -191,14 +191,14 @@ namespace Nz return &m_impl->sequences[index]; } - UInt32 Animation::GetSequenceCount() const + std::size_t Animation::GetSequenceCount() const { NazaraAssert(m_impl, "Animation not created"); - return static_cast(m_impl->sequences.size()); + return static_cast(m_impl->sequences.size()); } - UInt32 Animation::GetSequenceIndex(const String& sequenceName) const + std::size_t Animation::GetSequenceIndex(const String& sequenceName) const { NazaraAssert(m_impl, "Animation not created"); @@ -212,7 +212,7 @@ namespace Nz return it->second; } - SequenceJoint* Animation::GetSequenceJoints(UInt32 frameIndex) + SequenceJoint* Animation::GetSequenceJoints(std::size_t frameIndex) { NazaraAssert(m_impl, "Animation not created"); NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); @@ -220,7 +220,7 @@ namespace Nz return &m_impl->sequenceJoints[frameIndex*m_impl->jointCount]; } - const SequenceJoint* Animation::GetSequenceJoints(UInt32 frameIndex) const + const SequenceJoint* Animation::GetSequenceJoints(std::size_t frameIndex) const { NazaraAssert(m_impl, "Animation not created"); NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); @@ -242,7 +242,7 @@ namespace Nz return m_impl->sequenceMap.find(sequenceName) != m_impl->sequenceMap.end(); } - bool Animation::HasSequence(UInt32 index) const + bool Animation::HasSequence(std::size_t index) const { NazaraAssert(m_impl, "Animation not created"); @@ -278,7 +278,7 @@ namespace Nz m_impl->sequences.erase(sequenceIt); } - void Animation::RemoveSequence(UInt32 index) + void Animation::RemoveSequence(std::size_t index) { NazaraAssert(m_impl, "Animation not created"); NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); @@ -289,7 +289,7 @@ namespace Nz m_impl->sequences.erase(it); } - AnimationRef Animation::LoadFromFile(const String& filePath, const AnimationParams& params) + AnimationRef Animation::LoadFromFile(const std::filesystem::path& filePath, const AnimationParams& params) { return AnimationLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Utility/Font.cpp b/src/Nazara/Utility/Font.cpp index a61311fb0..7bbd80ad2 100644 --- a/src/Nazara/Utility/Font.cpp +++ b/src/Nazara/Utility/Font.cpp @@ -354,7 +354,7 @@ namespace Nz return s_defaultMinimumStepSize; } - FontRef Font::OpenFromFile(const String& filePath, const FontParams& params) + FontRef Font::OpenFromFile(const std::filesystem::path& filePath, const FontParams& params) { return FontLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index e4c6f2d57..9fb93cc6e 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -18,7 +18,7 @@ namespace Nz DDSLoader() = delete; ~DDSLoader() = delete; - static bool IsSupported(const String& extension) + static bool IsSupported(const std::string& extension) { return (extension == "dds"); } diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp index 05814a903..37ca659fe 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp @@ -320,9 +320,9 @@ namespace Nz return characterSize/15.f; // Joker ? } - bool SetFile(const String& filePath) + bool SetFile(const std::filesystem::path& filePath) { - std::unique_ptr file(new File); + std::unique_ptr file = std::make_unique(); if (!file->Open(filePath, OpenMode_ReadOnly)) { NazaraError("Failed to open stream from file: " + Error::GetLastError()); @@ -336,7 +336,7 @@ namespace Nz void SetMemory(const void* data, std::size_t size) { - m_ownedStream.reset(new MemoryView(data, size)); + m_ownedStream = std::make_unique(data, size); SetStream(*m_ownedStream); } @@ -349,14 +349,14 @@ namespace Nz m_stream.pos = 0; m_stream.size = static_cast(stream.GetSize()); - m_args.driver = 0; + m_args.driver = nullptr; m_args.flags = FT_OPEN_STREAM; m_args.stream = &m_stream; } bool SupportsOutline(float /*outlineThickness*/) const override { - return s_stroker != 0; + return s_stroker != nullptr; } bool SupportsStyle(TextStyleFlags style) const override @@ -383,10 +383,10 @@ namespace Nz mutable unsigned int m_characterSize; }; - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { ///FIXME: Je suppose qu'il en manque quelques unes.. - static std::set supportedExtensions = { + static std::set supportedExtensions = { "afm", "bdf", "cff", "cid", "dfont", "fnt", "fon", "otf", "pfa", "pfb", "pfm", "pfr", "sfnt", "ttc", "tte", "ttf" }; @@ -408,12 +408,11 @@ namespace Nz return Ternary_False; } - FontRef LoadFile(const String& filePath, const FontParams& parameters) + FontRef LoadFile(const std::filesystem::path& filePath, const FontParams& parameters) { NazaraUnused(parameters); - std::unique_ptr face(new FreeTypeStream); - + std::unique_ptr face = std::make_unique(); if (!face->SetFile(filePath)) { NazaraError("Failed to open file"); diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index b58799978..d5fb90270 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -20,7 +20,7 @@ namespace Nz { namespace { - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { return (extension == "md2"); } @@ -93,14 +93,14 @@ namespace Nz mesh->SetMaterialCount(header.num_skins); stream.SetCursorPos(header.offset_skins); { - String baseDir = stream.GetDirectory(); + std::filesystem::path baseDir = stream.GetDirectory(); char skin[68]; for (unsigned int i = 0; i < header.num_skins; ++i) { stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); + matData.SetParameter(MaterialData::DiffuseTexturePath, (baseDir / skin).generic_u8string()); mesh->SetMaterialData(i, std::move(matData)); } @@ -196,10 +196,8 @@ namespace Nz Vector2f invSkinSize(1.f / header.skinwidth, 1.f / header.skinheight); for (unsigned int i = 0; i < header.num_tris; ++i) { - for (unsigned int j = 0; j < 3; ++j) + for (unsigned int fixedIndex : indexFix) //< Reverse winding order { - const unsigned int fixedIndex = indexFix[j]; //< Reverse winding order - const MD2_TexCoord& texC = texCoords[triangles[i].texCoords[fixedIndex]]; Vector2f uv(texC.u, texC.v); uv *= invSkinSize; diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index 84f0baeaf..e93299d1a 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include @@ -13,7 +12,7 @@ namespace Nz { namespace { - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { return (extension == "md5anim"); } @@ -40,10 +39,10 @@ namespace Nz } const MD5AnimParser::Frame* frames = parser.GetFrames(); - UInt32 frameCount = parser.GetFrameCount(); - UInt32 frameRate = parser.GetFrameRate(); + std::size_t frameCount = parser.GetFrameCount(); + std::size_t frameRate = parser.GetFrameRate(); const MD5AnimParser::Joint* joints = parser.GetJoints(); - UInt32 jointCount = parser.GetJointCount(); + std::size_t jointCount = parser.GetJointCount(); // À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation AnimationRef animation = Animation::New(); @@ -53,7 +52,7 @@ namespace Nz sequence.firstFrame = 0; sequence.frameCount = frameCount; sequence.frameRate = frameRate; - sequence.name = stream.GetPath().SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true); + sequence.name = stream.GetPath().filename().generic_u8string(); animation->AddSequence(sequence); @@ -63,10 +62,10 @@ namespace Nz Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); - for (UInt32 i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { int parent = joints[i].parent; - for (UInt32 j = 0; j < frameCount; ++j) + for (std::size_t j = 0; j < frameCount; ++j) { SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i]; diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 31b3a64a7..69ffcad36 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -20,7 +20,7 @@ namespace Nz { namespace { - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { return (extension == "md5mesh"); } @@ -48,7 +48,7 @@ namespace Nz Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); - String baseDir = stream.GetDirectory(); + std::filesystem::path baseDir = stream.GetDirectory(); // Le hellknight de Doom 3 fait ~120 unités, et il est dit qu'il fait trois mètres // Nous réduisons donc la taille générale des fichiers MD5 de 1/40 @@ -198,7 +198,7 @@ namespace Nz // Material ParameterList matData; - matData.SetParameter(MaterialData::FilePath, baseDir + md5Mesh.shader); + matData.SetParameter(MaterialData::FilePath, (baseDir / md5Mesh.shader).generic_u8string()); mesh->SetMaterialData(i, std::move(matData)); @@ -211,11 +211,11 @@ namespace Nz // Animation // Il est peut-être éventuellement possible que la probabilité que l'animation ait le même nom soit non-nulle. - String path = stream.GetPath(); - if (!path.IsEmpty()) + std::filesystem::path path = stream.GetPath(); + if (!path.empty()) { - path.Replace(".md5mesh", ".md5anim", -8, String::CaseInsensitive); - if (File::Exists(path)) + path.replace_extension(".md5anim"); + if (std::filesystem::exists(path)) mesh->SetAnimation(path); } } @@ -306,7 +306,7 @@ namespace Nz // Material ParameterList matData; - matData.SetParameter(MaterialData::FilePath, baseDir + md5Mesh.shader); + matData.SetParameter(MaterialData::FilePath, (baseDir / md5Mesh.shader).generic_u8string()); mesh->SetMaterialData(i, std::move(matData)); } diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index c6af0ed96..fc5f30f6d 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -71,19 +72,19 @@ namespace Nz { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING case 'M': // MD5Version - if (m_currentLine.GetWord(0) != "MD5Version") + if (!StartsWith(m_currentLine, "MD5Version ")) UnrecognizedLine(); break; case 'c': // commandline - if (m_currentLine.GetWord(0) != "commandline") + if (!StartsWith(m_currentLine, "commandline ")) UnrecognizedLine(); break; #endif case 'j': // joints #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (!m_currentLine.StartsWith("joints {")) + if (!StartsWith(m_currentLine, "joints {")) { UnrecognizedLine(); break; @@ -100,7 +101,7 @@ namespace Nz case 'm': // mesh { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (m_currentLine != "mesh {") + if (!StartsWith(m_currentLine, "mesh {")) { UnrecognizedLine(); break; @@ -113,7 +114,7 @@ namespace Nz Warning("More meshes than registred"); #endif - m_meshes.push_back(Mesh()); + m_meshes.emplace_back(); } if (!ParseMesh()) @@ -182,14 +183,25 @@ namespace Nz m_lineCount++; m_currentLine = m_stream.ReadLine(); - if (m_currentLine.IsEmpty()) - continue; - m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires - m_currentLine.Simplify(); // Pour un traitement plus simple - m_currentLine.Trim(); + if (std::size_t p = m_currentLine.find("//"); p != m_currentLine.npos) + { + if (p > 0) + m_currentLine = m_currentLine.substr(0, p - 1); + else + m_currentLine.clear(); + } + + // Trim left + m_currentLine.erase(m_currentLine.begin(), std::find_if(m_currentLine.begin(), m_currentLine.end(), [](char c) + { + return !std::isspace(c); + })); + + if (m_currentLine.empty()) + continue; } - while (m_currentLine.IsEmpty()); + while (m_currentLine.empty()); } else m_keepLastLine = false; @@ -197,9 +209,9 @@ namespace Nz return true; } - void MD5MeshParser::Error(const String& message) + void MD5MeshParser::Error(const std::string& message) { - NazaraError(message + " at line #" + String::Number(m_lineCount)); + NazaraError(message + " at line #" + std::to_string(m_lineCount)); } bool MD5MeshParser::ParseJoints() @@ -216,7 +228,7 @@ namespace Nz if (!Advance()) return false; - std::size_t pos = m_currentLine.Find(' '); + std::size_t pos = m_currentLine.find(' '); if (pos == String::npos) { UnrecognizedLine(true); @@ -231,8 +243,8 @@ namespace Nz char name[64]; if (std::sscanf(&m_currentLine[0], "%63s %d ( %f %f %f ) ( %f %f %f )", &name[0], &m_joints[i].parent, - &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, - &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 8) + &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, + &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 8) { UnrecognizedLine(true); return false; @@ -246,7 +258,7 @@ namespace Nz { if (static_cast(parent) >= jointCount) { - Error("Joint's parent is out of bounds (" + String::Number(parent) + " >= " + String::Number(jointCount) + ')'); + Error("Joint's parent is out of bounds (" + std::to_string(parent) + " >= " + std::to_string(jointCount) + ')'); return false; } } @@ -257,7 +269,7 @@ namespace Nz if (!Advance()) return false; - if (m_currentLine != '}') + if (m_currentLine != "}") { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING Warning("Hierarchy braces closing not found"); @@ -282,17 +294,42 @@ namespace Nz break; case 's': // shader + { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (!m_currentLine.StartsWith("shader ")) + if (!StartsWith(m_currentLine, "shader ")) { UnrecognizedLine(); break; } #endif - m_meshes[m_meshIndex].shader = m_currentLine.SubString(7); - m_meshes[m_meshIndex].shader.Trim('"'); + std::string_view shader = m_currentLine; + shader = shader.substr(7); + if (shader.empty()) + { +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + UnrecognizedLine(); +#endif + break; + } + + if (shader.front() == '"') + shader.remove_prefix(1); + + if (shader.empty()) + { +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + UnrecognizedLine(); +#endif + break; + } + + if (shader.back() == '"') + shader.remove_prefix(1); + + m_meshes[m_meshIndex].shader = shader; break; + } case 'n': // num[tris/verts] { @@ -315,7 +352,7 @@ namespace Nz if (index != i) { - Error("Unexpected triangle index (expected " + String::Number(i) + ", got " + String::Number(index) + ')'); + Error("Unexpected triangle index (expected " + std::to_string(i) + ", got " + std::to_string(index) + ')'); return false; } } @@ -338,7 +375,7 @@ namespace Nz if (index != i) { - Error("Unexpected vertex index (expected " + String::Number(i) + ", got " + String::Number(index) + ')'); + Error("Unexpected vertex index (expected " + std::to_string(i) + ", got " + std::to_string(index) + ')'); return false; } } @@ -354,7 +391,7 @@ namespace Nz Weight& weight = m_meshes[m_meshIndex].weights[i]; unsigned int index; if (std::sscanf(&m_currentLine[0], "weight %u %u %f ( %f %f %f )", &index, &weight.joint, &weight.bias, - &weight.pos.x, &weight.pos.y, &weight.pos.z) != 6) + &weight.pos.x, &weight.pos.y, &weight.pos.z) != 6) { UnrecognizedLine(true); return false; @@ -362,7 +399,7 @@ namespace Nz if (index != i) { - Error("Unexpected weight index (expected " + String::Number(i) + ", got " + String::Number(index) + ')'); + Error("Unexpected weight index (expected " + std::to_string(i) + ", got " + std::to_string(index) + ')'); return false; } } @@ -408,14 +445,14 @@ namespace Nz return true; } - void MD5MeshParser::Warning(const String& message) + void MD5MeshParser::Warning(const std::string& message) { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + NazaraWarning(message + " at line #" + std::to_string(m_lineCount)); } void MD5MeshParser::UnrecognizedLine(bool error) { - String message = "Unrecognized \"" + m_currentLine + '"'; + std::string message = "Unrecognized \"" + m_currentLine + '"'; if (error) Error(message); diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 31a377e38..743622f0c 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -4,12 +4,31 @@ #include #include +#include #include #include #include namespace Nz { + namespace + { + template + bool TestKeyword(const std::string& currentLine, const char(&keyword)[N], std::size_t& offset) + { + if (currentLine.size() > N && StartsWith(currentLine, keyword, CaseIndependent{}) && std::isspace(currentLine[N - 1])) + { + offset = N; + while (offset < currentLine.size() && std::isspace(currentLine[offset])) + offset++; + + return offset < currentLine.size(); + } + else + return false; + } + } + bool MTLParser::Parse(Stream& stream) { m_currentStream = &stream; @@ -31,266 +50,434 @@ namespace Nz m_materials.clear(); Material* currentMaterial = nullptr; + std::size_t offset; while (Advance(false)) { - String keyword = m_currentLine.GetWord(0).ToLower(); - if (keyword == "ka") + switch (std::tolower(m_currentLine[0])) { - float r, g, b; - if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) + case 'b': { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); + if (TestKeyword(m_currentLine, "bump", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); - currentMaterial->ambient = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); + currentMaterial->bumpMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "kd") - { - float r, g, b; - if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) + + case 'd': { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); + if (TestKeyword(m_currentLine, "d", offset)) + { + float alpha; + if (std::sscanf(&m_currentLine[2], "%f", &alpha) == 1) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); - currentMaterial->diffuse = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); + currentMaterial->alpha = alpha; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "decal", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->decalMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "disp", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->displacementMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + break; } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "ks") - { - float r, g, b; - if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) + + case 'e': { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); + if (TestKeyword(m_currentLine, "emissive", offset)) + { + // This is a custom keyword + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); - currentMaterial->specular = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); + currentMaterial->emissiveMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + break; } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "ni") - { - float density; - if (std::sscanf(&m_currentLine[3], "%f", &density) == 1) + + case 'k': { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); + if (TestKeyword(m_currentLine, "ka", offset)) + { + float r, g, b; + if (std::sscanf(&m_currentLine[offset], "%f %f %f", &r, &g, &b) == 3) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); - currentMaterial->refractionIndex = density; + currentMaterial->ambient = Color(static_cast(r * 255.f), static_cast(g * 255.f), static_cast(b * 255.f)); + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "kd", offset)) + { + float r, g, b; + if (std::sscanf(&m_currentLine[offset], "%f %f %f", &r, &g, &b) == 3) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->diffuse = Color(static_cast(r * 255.f), static_cast(g * 255.f), static_cast(b * 255.f)); + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "ks", offset)) + { + float r, g, b; + if (std::sscanf(&m_currentLine[offset], "%f %f %f", &r, &g, &b) == 3) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->specular = Color(static_cast(r * 255.f), static_cast(g * 255.f), static_cast(b * 255.f)); + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + + break; } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "ns") - { - float coef; - if (std::sscanf(&m_currentLine[3], "%f", &coef) == 1) + + case 'i': { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); + if (TestKeyword(m_currentLine, "illum", offset)) + { + unsigned int model; + if (std::sscanf(&m_currentLine[offset], "%u", &model) == 1) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); - currentMaterial->shininess = coef; - } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == 'd') - { - float alpha; - if (std::sscanf(&m_currentLine[(keyword[0] == 'd') ? 2 : 3], "%f", &alpha) == 1) - { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->alpha = alpha; - } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "tr") - { - float alpha; - if (std::sscanf(&m_currentLine[(keyword[0] == 'd') ? 2 : 3], "%f", &alpha) == 1) - { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->alpha = 1.f - alpha; // tr vaut pour la "valeur de transparence", 0 = opaque - } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "illum") - { - unsigned int model; - if (std::sscanf(&m_currentLine[6], "%u", &model) == 1) - { - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->illumModel = model; - } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } - else if (keyword == "map_ka") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->ambientMap = map; - } - } - else if (keyword == "map_kd") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->diffuseMap = map; - } - } - else if (keyword == "map_ks") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->specularMap = map; - } - } - else if (keyword == "map_bump" || keyword == "bump") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->bumpMap = map; - } - } - else if (keyword == "map_d") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->alphaMap = map; - } - } - else if (keyword == "map_decal" || keyword == "decal") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->decalMap = map; - } - } - else if (keyword == "map_disp" || keyword == "disp") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->displacementMap = map; - } - } - else if (keyword == "map_refl" || keyword == "refl") - { - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->reflectionMap = map; - } - } - else if (keyword == "map_normal" || keyword == "normal") - { - // This is a custom keyword - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->normalMap = map; - } - } - else if (keyword == "map_emissive" || keyword == "emissive") - { - // This is a custom keyword - std::size_t mapPos = m_currentLine.GetWordPosition(1); - if (mapPos != String::npos) - { - String map = m_currentLine.SubString(mapPos); - if (!currentMaterial) - currentMaterial = AddMaterial("default"); - - currentMaterial->emissiveMap = map; - } - } - else if (keyword == "newmtl") - { - String materialName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); - if (!materialName.IsEmpty()) - currentMaterial = AddMaterial(materialName); - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); - #endif - } + currentMaterial->illumModel = model; + } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else + UnrecognizedLine(); #endif + } + break; + } + + case 'm': + { + if (TestKeyword(m_currentLine, "map_ka", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->ambientMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_kd", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->diffuseMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_ks", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->specularMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_bump", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->bumpMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_d", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->alphaMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_decal", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->decalMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_disp", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->displacementMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_refl", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->reflectionMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_normal", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->normalMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "map_emissive", offset)) + { + // This is a custom keyword + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->emissiveMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + break; + } + + case 'n': + { + if (TestKeyword(m_currentLine, "ni", offset)) + { + float density; + if (std::sscanf(&m_currentLine[offset], "%f", &density) == 1) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->refractionIndex = density; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "ns", offset)) + { + float coef; + if (std::sscanf(&m_currentLine[offset], "%f", &coef) == 1) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->shininess = coef; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "normal", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->normalMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + else if (TestKeyword(m_currentLine, "newmtl", offset)) + { + std::string materialName = m_currentLine.substr(offset); + if (!materialName.empty()) + currentMaterial = AddMaterial(materialName); +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + break; + } + + case 'r': + { + if (TestKeyword(m_currentLine, "refl", offset)) + { + std::string map = m_currentLine.substr(offset); + if (!map.empty()) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->reflectionMap = map; + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + break; + } + + case 't': + { + if (TestKeyword(m_currentLine, "tr", offset)) + { + float alpha; + if (std::sscanf(&m_currentLine[offset], "%f", &alpha) == 1) + { + if (!currentMaterial) + currentMaterial = AddMaterial("default"); + + currentMaterial->alpha = 1.f - alpha; // tr vaut pour la "valeur de transparence", 0 = opaque + } +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + else + UnrecognizedLine(); +#endif + } + } + + default: +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + UnrecognizedLine(); +#endif + break; + } } return true; @@ -378,49 +565,49 @@ namespace Nz EmitLine(mat.illumModel); } - if (!mat.ambientMap.IsEmpty()) + if (!mat.ambientMap.empty()) { Emit("map_Ka "); EmitLine(mat.ambientMap); } - if (!mat.diffuseMap.IsEmpty()) + if (!mat.diffuseMap.empty()) { Emit("map_Kd "); EmitLine(mat.diffuseMap); } - if (!mat.specularMap.IsEmpty()) + if (!mat.specularMap.empty()) { Emit("map_Ks "); EmitLine(mat.specularMap); } - if (!mat.bumpMap.IsEmpty()) + if (!mat.bumpMap.empty()) { Emit("map_bump "); EmitLine(mat.bumpMap); } - if (!mat.alphaMap.IsEmpty()) + if (!mat.alphaMap.empty()) { Emit("map_d "); EmitLine(mat.alphaMap); } - if (!mat.decalMap.IsEmpty()) + if (!mat.decalMap.empty()) { Emit("map_decal "); EmitLine(mat.decalMap); } - if (!mat.displacementMap.IsEmpty()) + if (!mat.displacementMap.empty()) { Emit("map_disp "); EmitLine(mat.displacementMap); } - if (!mat.reflectionMap.IsEmpty()) + if (!mat.reflectionMap.empty()) { Emit("map_refl "); EmitLine(mat.reflectionMap); @@ -450,13 +637,18 @@ namespace Nz m_lineCount++; m_currentLine = m_currentStream->ReadLine(); - if (m_currentLine.IsEmpty()) - continue; + if (std::size_t p = m_currentLine.find('#'); p != m_currentLine.npos) + { + if (p > 0) + m_currentLine = m_currentLine.substr(0, p - 1); + else + m_currentLine.clear(); + } - m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires - m_currentLine.Simplify(); // Pour un traitement plus simple + if (m_currentLine.empty()) + continue; } - while (m_currentLine.IsEmpty()); + while (m_currentLine.empty()); } else m_keepLastLine = false; diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 58b2d8e0a..819bbe256 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -22,7 +22,7 @@ namespace Nz { namespace { - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { return (extension == "obj"); } @@ -42,12 +42,12 @@ namespace Nz return Ternary_Unknown; } - bool ParseMTL(Mesh* mesh, const String& filePath, const String* materials, const OBJParser::Mesh* meshes, UInt32 meshCount) + bool ParseMTL(Mesh* mesh, const std::filesystem::path& filePath, const std::string* materials, const OBJParser::Mesh* meshes, std::size_t meshCount) { File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) { - NazaraError("Failed to open MTL file (" + file.GetPath() + ')'); + NazaraError("Failed to open MTL file (" + file.GetPath().generic_u8string() + ')'); return false; } @@ -59,10 +59,10 @@ namespace Nz } std::unordered_map materialCache; - String baseDir = file.GetDirectory(); - for (UInt32 i = 0; i < meshCount; ++i) + std::filesystem::path baseDir = file.GetDirectory(); + for (std::size_t i = 0; i < meshCount; ++i) { - const String& matName = materials[meshes[i].material]; + const std::string& matName = materials[meshes[i].material]; const MTLParser::Material* mtlMat = materialParser.GetMaterial(matName); if (!mtlMat) { @@ -89,53 +89,53 @@ namespace Nz data.SetParameter(MaterialData::Shininess, mtlMat->shininess); data.SetParameter(MaterialData::SpecularColor, specularColor); - if (!mtlMat->alphaMap.IsEmpty()) + if (!mtlMat->alphaMap.empty()) { - String fullPath = mtlMat->alphaMap; - if (!Nz::File::IsAbsolute(fullPath)) - fullPath.Prepend(baseDir); + std::filesystem::path fullPath = mtlMat->alphaMap; + if (!fullPath.is_absolute()) + fullPath = baseDir / fullPath; - data.SetParameter(MaterialData::AlphaTexturePath, fullPath); + data.SetParameter(MaterialData::AlphaTexturePath, fullPath.generic_u8string()); } - if (!mtlMat->diffuseMap.IsEmpty()) + if (!mtlMat->diffuseMap.empty()) { - String fullPath = mtlMat->diffuseMap; - if (!Nz::File::IsAbsolute(fullPath)) - fullPath.Prepend(baseDir); + std::filesystem::path fullPath = mtlMat->diffuseMap; + if (!fullPath.is_absolute()) + fullPath = baseDir / fullPath; - data.SetParameter(MaterialData::DiffuseTexturePath, fullPath); + data.SetParameter(MaterialData::DiffuseTexturePath, fullPath.generic_u8string()); } - if (!mtlMat->emissiveMap.IsEmpty()) + if (!mtlMat->emissiveMap.empty()) { - String fullPath = mtlMat->emissiveMap; - if (!Nz::File::IsAbsolute(fullPath)) - fullPath.Prepend(baseDir); + std::filesystem::path fullPath = mtlMat->emissiveMap; + if (!fullPath.is_absolute()) + fullPath = baseDir / fullPath; - data.SetParameter(MaterialData::EmissiveTexturePath, fullPath); + data.SetParameter(MaterialData::EmissiveTexturePath, fullPath.generic_u8string()); } - if (!mtlMat->normalMap.IsEmpty()) + if (!mtlMat->normalMap.empty()) { - String fullPath = mtlMat->normalMap; - if (!Nz::File::IsAbsolute(fullPath)) - fullPath.Prepend(baseDir); + std::filesystem::path fullPath = mtlMat->normalMap; + if (!fullPath.is_absolute()) + fullPath = baseDir / fullPath; - data.SetParameter(MaterialData::NormalTexturePath, fullPath); + data.SetParameter(MaterialData::NormalTexturePath, fullPath.generic_u8string()); } - if (!mtlMat->specularMap.IsEmpty()) + if (!mtlMat->specularMap.empty()) { - String fullPath = mtlMat->specularMap; - if (!Nz::File::IsAbsolute(fullPath)) - fullPath.Prepend(baseDir); + std::filesystem::path fullPath = mtlMat->specularMap; + if (!fullPath.is_absolute()) + fullPath = baseDir / fullPath; - data.SetParameter(MaterialData::SpecularTexturePath, fullPath); + data.SetParameter(MaterialData::SpecularTexturePath, fullPath.generic_u8string()); } // If we either have an alpha value or an alpha map, let's configure the material for transparency - if (alphaValue != 255 || !mtlMat->alphaMap.IsEmpty()) + if (alphaValue != 255 || !mtlMat->alphaMap.empty()) { // Some default settings data.SetParameter(MaterialData::Blending, true); @@ -169,27 +169,27 @@ namespace Nz MeshRef mesh = Mesh::New(); mesh->CreateStatic(); - const String* materials = parser.GetMaterials(); + const std::string* materials = parser.GetMaterials(); const Vector4f* positions = parser.GetPositions(); const Vector3f* normals = parser.GetNormals(); const Vector3f* texCoords = parser.GetTexCoords(); const OBJParser::Mesh* meshes = parser.GetMeshes(); - UInt32 meshCount = parser.GetMeshCount(); + std::size_t meshCount = parser.GetMeshCount(); NazaraAssert(materials != nullptr && positions != nullptr && normals != nullptr && texCoords != nullptr && meshes != nullptr && meshCount > 0, "Invalid OBJParser output"); // Un conteneur temporaire pour contenir les indices de face avant triangulation - std::vector faceIndices(3); // Comme il y aura au moins trois sommets - for (UInt32 i = 0; i < meshCount; ++i) + std::vector faceIndices(3); // Comme il y aura au moins trois sommets + for (std::size_t i = 0; i < meshCount; ++i) { std::size_t faceCount = meshes[i].faces.size(); if (faceCount == 0) continue; - std::vector indices; + std::vector indices; indices.reserve(faceCount*3); // Pire cas si les faces sont des triangles // Afin d'utiliser OBJParser::FaceVertex comme clé dans un unordered_map, @@ -226,10 +226,10 @@ namespace Nz unsigned int vertexCount = 0; for (unsigned int j = 0; j < faceCount; ++j) { - UInt32 faceVertexCount = meshes[i].faces[j].vertexCount; + std::size_t faceVertexCount = meshes[i].faces[j].vertexCount; faceIndices.resize(faceVertexCount); - for (UInt32 k = 0; k < faceVertexCount; ++k) + for (std::size_t k = 0; k < faceVertexCount; ++k) { const OBJParser::FaceVertex& vertex = meshes[i].vertices[meshes[i].faces[j].firstVertex + k]; @@ -241,7 +241,7 @@ namespace Nz } // Triangulation - for (UInt32 k = 1; k < faceVertexCount-1; ++k) + for (std::size_t k = 1; k < faceVertexCount-1; ++k) { indices.push_back(faceIndices[0]); indices.push_back(faceIndices[k]); @@ -250,13 +250,13 @@ namespace Nz } // Création des buffers - IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits::max(), UInt32(indices.size()), parameters.storage, parameters.indexBufferFlags); - VertexBufferRef vertexBuffer = VertexBuffer::New(parameters.vertexDeclaration, UInt32(vertexCount), parameters.storage, parameters.vertexBufferFlags); + IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits::max(), std::size_t(indices.size()), parameters.storage, parameters.indexBufferFlags); + VertexBufferRef vertexBuffer = VertexBuffer::New(parameters.vertexDeclaration, std::size_t(vertexCount), parameters.storage, parameters.vertexBufferFlags); // Remplissage des indices IndexMapper indexMapper(indexBuffer, BufferAccess_WriteOnly); for (std::size_t j = 0; j < indices.size(); ++j) - indexMapper.Set(j, indices[j]); + indexMapper.Set(j, UInt32(indices[j])); indexMapper.Unmap(); // Pour laisser les autres tâches affecter l'index buffer @@ -337,11 +337,11 @@ namespace Nz mesh->Recenter(); // On charge les matériaux si demandé - String mtlLib = parser.GetMtlLib(); - if (!mtlLib.IsEmpty()) + std::filesystem::path mtlLib = parser.GetMtlLib(); + if (!mtlLib.empty()) { ErrorFlags flags(ErrorFlag_ThrowExceptionDisabled); - ParseMTL(mesh, stream.GetDirectory() + mtlLib, materials, meshes, meshCount); + ParseMTL(mesh, stream.GetDirectory() / mtlLib, materials, meshes, meshCount); } return mesh; diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index b4766fc56..03cf494fa 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -45,32 +46,29 @@ namespace Nz case 'o': //< Object (defines a mesh) case 's': //< Smooth { - if (m_currentLine.GetSize() > 1 && m_currentLine[1] == ' ') + if (m_currentLine.size() > 1 && m_currentLine[1] == ' ') return true; break; } case 'm': //< MTLLib - if (m_currentLine.GetWord(0).ToLower() == "mtllib") + if (StartsWith(m_currentLine, "mtllib ")) return true; break; case 'u': //< Usemtl - if (m_currentLine.GetWord(0).ToLower() == "usemtl") + if (StartsWith(m_currentLine, "usemtl ")) return true; break; case 'v': //< Position/Normal/Texcoords { - String word = m_currentLine.GetWord(0).ToLower(); - if (word == 'v') - return true; - else if (word == "vn") - return true; - else if (word == "vt") + if (StartsWith(m_currentLine, "v ") || + StartsWith(m_currentLine, "vn ") || + StartsWith(m_currentLine, "vt ")) return true; break; @@ -87,7 +85,7 @@ namespace Nz return false; } - bool OBJParser::Parse(Nz::Stream& stream, UInt32 reservedVertexCount) + bool OBJParser::Parse(Nz::Stream& stream, std::size_t reservedVertexCount) { m_currentStream = &stream; m_errorCount = 0; @@ -106,10 +104,10 @@ namespace Nz }); } - String matName, meshName; + std::string matName, meshName; matName = meshName = "default"; m_meshes.clear(); - m_mtlLib.Clear(); + m_mtlLib.clear(); m_normals.clear(); m_positions.clear(); @@ -122,12 +120,12 @@ namespace Nz // Sort meshes by material and group using MatPair = std::pair; - std::unordered_map> meshesByName; + std::unordered_map> meshesByName; UInt32 faceReserve = 0; UInt32 vertexReserve = 0; unsigned int matCount = 0; - auto GetMaterial = [&] (const String& mesh, const String& mat) -> Mesh* + auto GetMaterial = [&] (const std::string& mesh, const std::string& mat) -> Mesh* { auto& map = meshesByName[mesh]; auto it = map.find(mat); @@ -154,22 +152,22 @@ namespace Nz case '#': //< Comment // Some softwares write comments to gives the number of vertex/faces an importer can expect unsigned int data; - if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %u", &data) == 1) + if (std::sscanf(m_currentLine.data(), "# position count: %u", &data) == 1) m_positions.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %u", &data) == 1) + else if (std::sscanf(m_currentLine.data(), "# normal count: %u", &data) == 1) m_normals.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %u", &data) == 1) + else if (std::sscanf(m_currentLine.data(), "# texcoords count: %u", &data) == 1) m_texCoords.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %u", &data) == 1) + else if (std::sscanf(m_currentLine.data(), "# face count: %u", &data) == 1) faceReserve = data; - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %u", &data) == 1) + else if (std::sscanf(m_currentLine.data(), "# vertex count: %u", &data) == 1) vertexReserve = data; break; case 'f': //< Face { - if (m_currentLine.GetSize() < 7) // Since we only treat triangles, this is the minimum length of a face line (f 1 2 3) + if (m_currentLine.size() < 7) // Since we only treat triangles, this is the minimum length of a face line (f 1 2 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (!UnrecognizedLine()) @@ -178,7 +176,7 @@ namespace Nz break; } - unsigned int vertexCount = m_currentLine.Count(' '); + std::size_t vertexCount = std::count(m_currentLine.begin(), m_currentLine.end(), ' '); if (vertexCount < 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING @@ -192,8 +190,8 @@ namespace Nz currentMesh = GetMaterial(meshName, matName); Face face; - face.firstVertex = static_cast(currentMesh->vertices.size()); - face.vertexCount = static_cast(vertexCount); + face.firstVertex = currentMesh->vertices.size(); + face.vertexCount = vertexCount; currentMesh->vertices.resize(face.firstVertex + vertexCount, FaceVertex{0, 0, 0}); @@ -230,7 +228,7 @@ namespace Nz p += static_cast(m_positions.size()); if (p < 0) { - Error("Vertex index out of range (" + String::Number(p) + " < 0"); + Error("Vertex index out of range (" + std::to_string(p) + " < 0"); error = true; break; } @@ -243,7 +241,7 @@ namespace Nz n += static_cast(m_normals.size()); if (n < 0) { - Error("Normal index out of range (" + String::Number(n) + " < 0"); + Error("Normal index out of range (" + std::to_string(n) + " < 0"); error = true; break; } @@ -256,7 +254,7 @@ namespace Nz t += static_cast(m_texCoords.size()); if (t < 0) { - Error("Texture coordinates index out of range (" + String::Number(t) + " < 0"); + Error("Texture coordinates index out of range (" + std::to_string(t) + " < 0"); error = true; break; } @@ -266,19 +264,19 @@ namespace Nz if (static_cast(p) > m_positions.size()) { - Error("Vertex index out of range (" + String::Number(p) + " >= " + String::Number(m_positions.size()) + ')'); + Error("Vertex index out of range (" + std::to_string(p) + " >= " + std::to_string(m_positions.size()) + ')'); error = true; break; } else if (n != 0 && static_cast(n) > m_normals.size()) { - Error("Normal index out of range (" + String::Number(n) + " >= " + String::Number(m_normals.size()) + ')'); + Error("Normal index out of range (" + std::to_string(n) + " >= " + std::to_string(m_normals.size()) + ')'); error = true; break; } else if (t != 0 && static_cast(t) > m_texCoords.size()) { - Error("TexCoord index out of range (" + String::Number(t) + " >= " + String::Number(m_texCoords.size()) + ')'); + Error("TexCoord index out of range (" + std::to_string(t) + " >= " + std::to_string(m_texCoords.size()) + ')'); error = true; break; } @@ -299,29 +297,36 @@ namespace Nz } case 'm': //< MTLLib - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (m_currentLine.GetWord(0).ToLower() != "mtllib") + { + const char prefix[] = "mtllib "; + if (!StartsWith(m_currentLine, prefix)) + { +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (!UnrecognizedLine()) return false; - #endif +#endif - m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); + break; + } + + m_mtlLib = m_currentLine.substr(sizeof(prefix) - 1); break; + } case 'g': //< Group (inside a mesh) case 'o': //< Object (defines a mesh) { - if (m_currentLine.GetSize() <= 2 || m_currentLine[1] != ' ') + if (m_currentLine.size() <= 2 || m_currentLine[1] != ' ') { - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (!UnrecognizedLine()) return false; - #endif +#endif break; } - String objectName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); - if (objectName.IsEmpty()) + std::string objectName = m_currentLine.substr(2); + if (objectName.empty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (!UnrecognizedLine()) @@ -335,12 +340,12 @@ namespace Nz break; } - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING case 's': //< Smooth - if (m_currentLine.GetSize() <= 2 || m_currentLine[1] == ' ') + if (m_currentLine.size() <= 2 || m_currentLine[1] == ' ') { - String param = m_currentLine.SubString(2); - if (param != "all" && param != "on" && param != "off" && !param.IsNumber()) + std::string param = m_currentLine.substr(2); + if (param != "all" && param != "on" && param != "off" && !IsNumber(param)) { if (!UnrecognizedLine()) return false; @@ -349,33 +354,51 @@ namespace Nz else if (!UnrecognizedLine()) return false; break; - #endif +#endif case 'u': //< Usemtl - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (m_currentLine.GetWord(0) != "usemtl" && !UnrecognizedLine()) - return false; - #endif - - matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); - currentMesh = nullptr; - if (matName.IsEmpty()) + { + const char prefix[] = "usemtl "; + if (!StartsWith(m_currentLine, prefix)) { - #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (!UnrecognizedLine()) return false; - #endif +#endif + break; } + + std::string newMatName = m_currentLine.substr(sizeof(prefix) - 1); + if (newMatName.empty()) + { +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + if (!UnrecognizedLine()) + return false; +#endif + break; + } + + matName = std::move(newMatName); + currentMesh = nullptr; break; + } case 'v': //< Position/Normal/Texcoords { - String word = m_currentLine.GetWord(0).ToLower(); - if (word == 'v') + if (m_currentLine.size() < 7) + { +#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING + if (!UnrecognizedLine()) + return false; +#endif + break; + } + + if (std::isspace(m_currentLine[1])) { Vector4f vertex(Vector3f::Zero(), 1.f); - unsigned int paramCount = std::sscanf(&m_currentLine[2], "%f %f %f %f", &vertex.x, &vertex.y, &vertex.z, &vertex.w); + unsigned int paramCount = std::sscanf(&m_currentLine[2], " %f %f %f %f", &vertex.x, &vertex.y, &vertex.z, &vertex.w); if (paramCount >= 1) m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING @@ -383,10 +406,10 @@ namespace Nz return false; #endif } - else if (word == "vn") + else if (m_currentLine[1] == 'n' && std::isspace(m_currentLine[2])) { Vector3f normal(Vector3f::Zero()); - unsigned int paramCount = std::sscanf(&m_currentLine[3], "%f %f %f", &normal.x, &normal.y, &normal.z); + unsigned int paramCount = std::sscanf(&m_currentLine[3], " %f %f %f", &normal.x, &normal.y, &normal.z); if (paramCount == 3) m_normals.push_back(normal); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING @@ -394,10 +417,10 @@ namespace Nz return false; #endif } - else if (word == "vt") + else if (m_currentLine[1] == 't' && std::isspace(m_currentLine[2])) { Vector3f uvw(Vector3f::Zero()); - unsigned int paramCount = std::sscanf(&m_currentLine[3], "%f %f %f", &uvw.x, &uvw.y, &uvw.z); + unsigned int paramCount = std::sscanf(&m_currentLine[3], " %f %f %f", &uvw.x, &uvw.y, &uvw.z); if (paramCount >= 2) m_texCoords.push_back(uvw); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING @@ -422,7 +445,7 @@ namespace Nz } } - std::unordered_map materials; + std::unordered_map materials; m_materials.resize(matCount); for (auto& meshPair : meshesByName) @@ -480,10 +503,10 @@ namespace Nz EmitLine("# Exported by Nazara Engine"); EmitLine(); - if (!m_mtlLib.IsEmpty()) + if (!m_mtlLib.empty()) { Emit("mtllib "); - EmitLine(m_mtlLib); + EmitLine(m_mtlLib.generic_u8string()); EmitLine(); } @@ -617,12 +640,18 @@ namespace Nz m_lineCount++; m_currentLine = m_currentStream->ReadLine(); - if (m_currentLine.IsEmpty()) - continue; + if (std::size_t p = m_currentLine.find('#'); p != m_currentLine.npos) + { + if (p > 0) + m_currentLine = m_currentLine.substr(0, p - 1); + else + m_currentLine.clear(); + } - m_currentLine.Simplify(); // Simplify lines (convert multiple blanks into a single space and trims) + if (m_currentLine.empty()) + continue; } - while (m_currentLine.IsEmpty()); + while (m_currentLine.empty()); } else m_keepLastLine = false; diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 74585971d..d363bbe67 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -2,7 +2,6 @@ // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include #include #include #include @@ -28,12 +27,12 @@ namespace Nz { } - UInt32 GetCount() const + std::size_t GetCount() const { return m_count; } - UInt32 Insert(const T& data) + std::size_t Insert(const T& data) { auto it = m_cache.find(data); if (it == m_cache.end()) @@ -47,17 +46,17 @@ namespace Nz } private: - UInt32 m_count; - std::map m_cache; + std::size_t m_count; + std::map m_cache; T* m_buffer; }; - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { return (extension == "obj"); } - bool SaveToStream(const Mesh& mesh, const String& format, Stream& stream, const MeshParams& parameters) + bool SaveToStream(const Mesh& mesh, const std::string& format, Stream& stream, const MeshParams& parameters) { NazaraUnused(parameters); @@ -73,18 +72,18 @@ namespace Nz return false; } - UInt32 worstCacheVertexCount = mesh.GetVertexCount(); + std::size_t worstCacheVertexCount = mesh.GetVertexCount(); OBJParser objFormat; objFormat.SetNormalCount(worstCacheVertexCount); objFormat.SetPositionCount(worstCacheVertexCount); objFormat.SetTexCoordCount(worstCacheVertexCount); - String mtlPath = stream.GetPath(); - if (!mtlPath.IsEmpty()) + std::filesystem::path mtlPath = stream.GetPath(); + if (!mtlPath.empty()) { - mtlPath.Replace(".obj", ".mtl"); - String fileName = mtlPath.SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true); - if (!fileName.IsEmpty()) + mtlPath.replace_extension(".mtl"); + std::filesystem::path fileName = mtlPath.filename(); + if (!fileName.empty()) objFormat.SetMtlLib(fileName); } @@ -94,17 +93,20 @@ namespace Nz // Materials MTLParser mtlFormat; - std::unordered_set registredMaterials; + std::unordered_set registredMaterials; - UInt32 matCount = mesh.GetMaterialCount(); - String* materialNames = objFormat.SetMaterialCount(matCount); - for (UInt32 i = 0; i < matCount; ++i) + std::size_t matCount = mesh.GetMaterialCount(); + std::string* materialNames = objFormat.SetMaterialCount(matCount); + for (std::size_t i = 0; i < matCount; ++i) { const ParameterList& matData = mesh.GetMaterialData(i); - String name; - if (!matData.GetStringParameter(MaterialData::Name, &name)) - name = "material_" + String::Number(i); + String nzname; + std::string name; + if (matData.GetStringParameter(MaterialData::Name, &nzname)) + name = nzname.ToStdString(); + else + name = "material_" + std::to_string(i); // Makes sure we only have one material of that name while (registredMaterials.find(name) != registredMaterials.end()) @@ -117,7 +119,7 @@ namespace Nz String strVal; if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) - material->diffuseMap = strVal; + material->diffuseMap = strVal.ToStdString(); else { Color colorVal; @@ -136,28 +138,28 @@ namespace Nz material->shininess = float(dValue); if (matData.GetStringParameter(MaterialData::AlphaTexturePath, &strVal)) - material->alphaMap = strVal; + material->alphaMap = strVal.ToStdString(); if (matData.GetStringParameter(MaterialData::DiffuseTexturePath, &strVal)) - material->diffuseMap = strVal; + material->diffuseMap = strVal.ToStdString(); if (matData.GetStringParameter(MaterialData::SpecularTexturePath, &strVal)) - material->specularMap = strVal; + material->specularMap = strVal.ToStdString(); } } // Meshes - UInt32 meshCount = mesh.GetSubMeshCount(); + std::size_t meshCount = mesh.GetSubMeshCount(); OBJParser::Mesh* meshes = objFormat.SetMeshCount(meshCount); - for (UInt32 i = 0; i < meshCount; ++i) + for (std::size_t i = 0; i < meshCount; ++i) { const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); - UInt32 triangleCount = staticMesh->GetTriangleCount(); + std::size_t triangleCount = staticMesh->GetTriangleCount(); meshes[i].faces.resize(triangleCount); meshes[i].material = staticMesh->GetMaterialIndex(); - meshes[i].name = "mesh_" + String::Number(i); + meshes[i].name = "mesh_" + std::to_string(i); meshes[i].vertices.resize(triangleCount * 3); { @@ -167,7 +169,7 @@ namespace Nz SparsePtr positionPtr = vertexMapper.GetComponentPtr(VertexComponent_Position); SparsePtr texCoordsPtr = vertexMapper.GetComponentPtr(VertexComponent_TexCoord); - UInt32 faceIndex = 0; + std::size_t faceIndex = 0; TriangleIterator triangle(staticMesh); do { @@ -179,7 +181,7 @@ namespace Nz { OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; - UInt32 index = triangle[j]; + std::size_t index = triangle[j]; vertexIndices.normal = normalCache.Insert(normalPtr[index]); vertexIndices.position = positionCache.Insert(positionPtr[index]); vertexIndices.texCoord = texCoordsCache.Insert(texCoordsPtr[index]); @@ -197,7 +199,7 @@ namespace Nz objFormat.Save(stream); - if (!mtlPath.IsEmpty()) + if (!mtlPath.empty()) { File mtlFile(mtlPath, OpenMode_WriteOnly | OpenMode_Truncate); if (mtlFile.IsOpen()) diff --git a/src/Nazara/Utility/Formats/PCXLoader.cpp b/src/Nazara/Utility/Formats/PCXLoader.cpp index 5de1aa29d..75016cd2c 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.cpp +++ b/src/Nazara/Utility/Formats/PCXLoader.cpp @@ -40,7 +40,7 @@ namespace Nz static_assert(sizeof(pcx_header) == (6+48+54)*sizeof(UInt8) + 10*sizeof(UInt16), "pcx_header struct must be packed"); - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { return (extension == "pcx"); } diff --git a/src/Nazara/Utility/Formats/STBLoader.cpp b/src/Nazara/Utility/Formats/STBLoader.cpp index 132886175..26836c057 100644 --- a/src/Nazara/Utility/Formats/STBLoader.cpp +++ b/src/Nazara/Utility/Formats/STBLoader.cpp @@ -36,7 +36,7 @@ namespace Nz static stbi_io_callbacks callbacks = {Read, Skip, Eof}; - bool IsSupported(const String& extension) + bool IsSupported(const std::string& extension) { static std::set supportedExtensions = {"bmp", "gif", "hdr", "jpg", "jpeg", "pic", "png", "ppm", "pgm", "psd", "tga"}; return supportedExtensions.find(extension) != supportedExtensions.end(); diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index bc8d7d7ac..effb8b921 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -15,7 +15,7 @@ namespace Nz { using FormatHandler = bool(*)(const Image& image, const ImageParams& parameters, Stream& stream); - std::map s_formatHandlers; + std::map s_formatHandlers; int ConvertToFloatFormat(Image& image) { @@ -102,12 +102,12 @@ namespace Nz throw std::runtime_error("Failed to write to stream"); } - bool FormatQuerier(const String& extension) + bool FormatQuerier(const std::string& extension) { return s_formatHandlers.find(extension) != s_formatHandlers.end(); } - bool SaveToStream(const Image& image, const String& format, Stream& stream, const ImageParams& parameters) + bool SaveToStream(const Image& image, const std::string& format, Stream& stream, const ImageParams& parameters) { NazaraUnused(parameters); diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index da5ec120c..51443667a 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -850,7 +850,7 @@ namespace Nz } // LoadArray - ImageRef Image::LoadArrayFromFile(const String& filePath, const ImageParams& imageParams, const Vector2ui& atlasSize) + ImageRef Image::LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams, const Vector2ui& atlasSize) { ImageRef image = Image::LoadFromFile(filePath, imageParams); if (!image) @@ -951,7 +951,7 @@ namespace Nz return LoadArrayFromImage(image, atlasSize); } - ImageRef Image::LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams, const CubemapParams& cubemapParams) + ImageRef Image::LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams, const CubemapParams& cubemapParams) { ImageRef image = Image::LoadFromFile(filePath, imageParams); if (!image) @@ -1074,7 +1074,7 @@ namespace Nz return LoadCubemapFromImage(image, cubemapParams); } - bool Image::LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params) + bool Image::LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params) { NazaraAssert(IsValid() && IsCubemap(), "Texture must be a valid cubemap"); @@ -1158,12 +1158,12 @@ namespace Nz return true; } - bool Image::SaveToFile(const String& filePath, const ImageParams& params) + bool Image::SaveToFile(const std::filesystem::path& filePath, const ImageParams& params) { return ImageSaver::SaveToFile(*this, filePath, params); } - bool Image::SaveToStream(Stream& stream, const String& format, const ImageParams& params) + bool Image::SaveToStream(Stream& stream, const std::string& format, const ImageParams& params) { return ImageSaver::SaveToStream(*this, stream, format, params); } @@ -1429,7 +1429,7 @@ namespace Nz return 0; } - ImageRef Image::LoadFromFile(const String& filePath, const ImageParams& params) + ImageRef Image::LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params) { return ImageLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index 4455a2f0c..21d1997f0 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -19,13 +19,13 @@ namespace Nz Reset(largeIndices, std::move(buffer)); } - IndexBuffer::IndexBuffer(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size) + IndexBuffer::IndexBuffer(bool largeIndices, BufferRef buffer, std::size_t offset, std::size_t size) { ErrorFlags(ErrorFlag_ThrowException, true); Reset(largeIndices, std::move(buffer), offset, size); } - IndexBuffer::IndexBuffer(bool largeIndices, UInt32 length, DataStorage storage, BufferUsageFlags usage) + IndexBuffer::IndexBuffer(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage) { ErrorFlags(ErrorFlag_ThrowException, true); Reset(largeIndices, length, storage, usage); @@ -53,14 +53,14 @@ namespace Nz return Nz::ComputeCacheMissCount(mapper.begin(), m_indexCount); } - bool IndexBuffer::Fill(const void* data, UInt32 startIndex, UInt32 length) + bool IndexBuffer::Fill(const void* data, std::size_t startIndex, std::size_t length) { - UInt32 stride = GetStride(); + std::size_t stride = GetStride(); return FillRaw(data, startIndex*stride, length*stride); } - bool IndexBuffer::FillRaw(const void* data, UInt32 offset, UInt32 size) + bool IndexBuffer::FillRaw(const void* data, std::size_t offset, std::size_t size) { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); @@ -68,7 +68,7 @@ namespace Nz return m_buffer->Fill(data, m_startOffset+offset, size); } - void* IndexBuffer::MapRaw(BufferAccess access, UInt32 offset, UInt32 size) + void* IndexBuffer::MapRaw(BufferAccess access, std::size_t offset, std::size_t size) { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); @@ -76,7 +76,7 @@ namespace Nz return m_buffer->Map(access, offset, size); } - void* IndexBuffer::MapRaw(BufferAccess access, UInt32 offset, UInt32 size) const + void* IndexBuffer::MapRaw(BufferAccess access, std::size_t offset, std::size_t size) const { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); @@ -103,13 +103,13 @@ namespace Nz Reset(largeIndices, buffer, 0, buffer->GetSize()); } - void IndexBuffer::Reset(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size) + void IndexBuffer::Reset(bool largeIndices, BufferRef buffer, std::size_t offset, std::size_t size) { NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); NazaraAssert(size > 0, "Invalid size"); NazaraAssert(offset + size > buffer->GetSize(), "Virtual buffer exceed buffer bounds"); - UInt32 stride = static_cast((largeIndices) ? sizeof(UInt32) : sizeof(UInt16)); + std::size_t stride = static_cast((largeIndices) ? sizeof(std::size_t) : sizeof(UInt16)); m_buffer = buffer; m_endOffset = offset + size; @@ -118,9 +118,9 @@ namespace Nz m_startOffset = offset; } - void IndexBuffer::Reset(bool largeIndices, UInt32 length, DataStorage storage, BufferUsageFlags usage) + void IndexBuffer::Reset(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage) { - UInt32 stride = static_cast((largeIndices) ? sizeof(UInt32) : sizeof(UInt16)); + std::size_t stride = static_cast((largeIndices) ? sizeof(std::size_t) : sizeof(UInt16)); m_endOffset = length * stride; m_indexCount = length; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 890577de4..d2ed17353 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -71,10 +71,10 @@ namespace Nz InvalidateAABB(); } - void Mesh::AddSubMesh(const String& identifier, SubMesh* subMesh) + void Mesh::AddSubMesh(const std::string& identifier, SubMesh* subMesh) { NazaraAssert(m_isValid, "Mesh should be created first"); - NazaraAssert(!identifier.IsEmpty(), "Identifier is empty"); + NazaraAssert(!identifier.empty(), "Identifier is empty"); NazaraAssert(m_subMeshMap.find(identifier) == m_subMeshMap.end(), "SubMesh identifier \"" + identifier + "\" is already in use"); NazaraAssert(subMesh, "Invalid submesh"); NazaraAssert(subMesh->GetAnimationType() == m_animationType, "Submesh animation type doesn't match mesh animation type"); @@ -83,7 +83,7 @@ namespace Nz AddSubMesh(subMesh); - m_subMeshMap[identifier] = static_cast(index); + m_subMeshMap[identifier] = static_cast(index); } SubMesh* Mesh::BuildSubMesh(const Primitive& primitive, const MeshParams& params) @@ -256,11 +256,11 @@ namespace Nz void Mesh::BuildSubMeshes(const PrimitiveList& list, const MeshParams& params) { - for (UInt32 i = 0; i < list.GetSize(); ++i) + for (std::size_t i = 0; i < list.GetSize(); ++i) BuildSubMesh(list.GetPrimitive(i), params); } - bool Mesh::CreateSkeletal(UInt32 jointCount) + bool Mesh::CreateSkeletal(std::size_t jointCount) { Destroy(); @@ -293,7 +293,7 @@ namespace Nz { OnMeshDestroy(this); - m_animationPath.Clear(); + m_animationPath.clear(); m_materialData.clear(); m_materialData.resize(1); m_skeleton.Destroy(); @@ -350,7 +350,7 @@ namespace Nz return m_aabb; } - String Mesh::GetAnimation() const + std::filesystem::path Mesh::GetAnimation() const { NazaraAssert(m_isValid, "Mesh should be created first"); @@ -364,7 +364,7 @@ namespace Nz return m_animationType; } - UInt32 Mesh::GetJointCount() const + std::size_t Mesh::GetJointCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(m_animationType == AnimationType_Skeletal, "Mesh is not skeletal"); @@ -372,7 +372,7 @@ namespace Nz return m_jointCount; } - ParameterList& Mesh::GetMaterialData(UInt32 index) + ParameterList& Mesh::GetMaterialData(std::size_t index) { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(index < m_materialData.size(), "Material index out of range"); @@ -380,7 +380,7 @@ namespace Nz return m_materialData[index]; } - const ParameterList& Mesh::GetMaterialData(UInt32 index) const + const ParameterList& Mesh::GetMaterialData(std::size_t index) const { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(index < m_materialData.size(), "Material index out of range"); @@ -388,11 +388,11 @@ namespace Nz return m_materialData[index]; } - UInt32 Mesh::GetMaterialCount() const + std::size_t Mesh::GetMaterialCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - return static_cast(m_materialData.size()); + return static_cast(m_materialData.size()); } Skeleton* Mesh::GetSkeleton() @@ -411,7 +411,7 @@ namespace Nz return &m_skeleton; } - SubMesh* Mesh::GetSubMesh(const String& identifier) + SubMesh* Mesh::GetSubMesh(const std::string& identifier) { NazaraAssert(m_isValid, "Mesh should be created first"); @@ -421,7 +421,7 @@ namespace Nz return m_subMeshes[it->second].subMesh; } - SubMesh* Mesh::GetSubMesh(UInt32 index) + SubMesh* Mesh::GetSubMesh(std::size_t index) { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(index < m_subMeshes.size(), "Submesh index out of range"); @@ -429,7 +429,7 @@ namespace Nz return m_subMeshes[index].subMesh; } - const SubMesh* Mesh::GetSubMesh(const String& identifier) const + const SubMesh* Mesh::GetSubMesh(const std::string& identifier) const { NazaraAssert(m_isValid, "Mesh should be created first"); @@ -439,7 +439,7 @@ namespace Nz return m_subMeshes[it->second].subMesh; } - const SubMesh* Mesh::GetSubMesh(UInt32 index) const + const SubMesh* Mesh::GetSubMesh(std::size_t index) const { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(index < m_subMeshes.size(), "Submesh index out of range"); @@ -447,14 +447,14 @@ namespace Nz return m_subMeshes[index].subMesh; } - UInt32 Mesh::GetSubMeshCount() const + std::size_t Mesh::GetSubMeshCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - return static_cast(m_subMeshes.size()); + return static_cast(m_subMeshes.size()); } - UInt32 Mesh::GetSubMeshIndex(const String& identifier) const + std::size_t Mesh::GetSubMeshIndex(const std::string& identifier) const { NazaraAssert(m_isValid, "Mesh should be created first"); @@ -464,22 +464,22 @@ namespace Nz return it->second; } - UInt32 Mesh::GetTriangleCount() const + std::size_t Mesh::GetTriangleCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - UInt32 triangleCount = 0; + std::size_t triangleCount = 0; for (const SubMeshData& data : m_subMeshes) triangleCount += data.subMesh->GetTriangleCount(); return triangleCount; } - UInt32 Mesh::GetVertexCount() const + std::size_t Mesh::GetVertexCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - UInt32 vertexCount = 0; + std::size_t vertexCount = 0; for (const SubMeshData& data : m_subMeshes) vertexCount += data.subMesh->GetVertexCount(); @@ -495,14 +495,14 @@ namespace Nz OnMeshInvalidateAABB(this); } - bool Mesh::HasSubMesh(const String& identifier) const + bool Mesh::HasSubMesh(const std::string& identifier) const { NazaraAssert(m_isValid, "Mesh should be created first"); return m_subMeshMap.find(identifier) != m_subMeshMap.end(); } - bool Mesh::HasSubMesh(UInt32 index) const + bool Mesh::HasSubMesh(std::size_t index) const { NazaraAssert(m_isValid, "Mesh should be created first"); @@ -536,8 +536,8 @@ namespace Nz BufferMapper mapper(staticMesh.GetVertexBuffer(), BufferAccess_ReadWrite); MeshVertex* vertices = static_cast(mapper.GetPointer()); - UInt32 vertexCount = staticMesh.GetVertexCount(); - for (UInt32 i = 0; i < vertexCount; ++i) + std::size_t vertexCount = staticMesh.GetVertexCount(); + for (std::size_t i = 0; i < vertexCount; ++i) { vertices->position -= center; vertices++; @@ -551,49 +551,47 @@ namespace Nz } } - void Mesh::RemoveSubMesh(const String& identifier) + void Mesh::RemoveSubMesh(const std::string& identifier) { - UInt32 index = GetSubMeshIndex(identifier); - - // On déplace l'itérateur du début d'une distance de x - auto it2 = m_subMeshes.begin(); - std::advance(it2, index); - m_subMeshes.erase(it2); - - InvalidateAABB(); + std::size_t index = GetSubMeshIndex(identifier); + RemoveSubMesh(index); } - void Mesh::RemoveSubMesh(UInt32 index) + void Mesh::RemoveSubMesh(std::size_t index) { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(index < m_subMeshes.size(), "Submesh index out of range"); - // On déplace l'itérateur du début de x - auto it = m_subMeshes.begin(); - std::advance(it, index); - m_subMeshes.erase(it); + m_subMeshes.erase(m_subMeshes.begin() + index); + + // Shift indices + for (auto& it : m_subMeshMap) + { + if (it.second > index) + it.second--; + } InvalidateAABB(); } - bool Mesh::SaveToFile(const String& filePath, const MeshParams& params) + bool Mesh::SaveToFile(const std::filesystem::path& filePath, const MeshParams& params) { return MeshSaver::SaveToFile(*this, filePath, params); } - bool Mesh::SaveToStream(Stream& stream, const String& format, const MeshParams& params) + bool Mesh::SaveToStream(Stream& stream, const std::string& format, const MeshParams& params) { return MeshSaver::SaveToStream(*this, stream, format, params); } - void Mesh::SetAnimation(const String& animationPath) + void Mesh::SetAnimation(const std::filesystem::path& animationPath) { NazaraAssert(m_isValid, "Mesh should be created first"); m_animationPath = animationPath; } - void Mesh::SetMaterialData(UInt32 matIndex, ParameterList data) + void Mesh::SetMaterialData(std::size_t matIndex, ParameterList data) { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(matIndex < m_materialData.size(), "Material index out of range"); @@ -601,7 +599,7 @@ namespace Nz m_materialData[matIndex] = std::move(data); } - void Mesh::SetMaterialCount(UInt32 matCount) + void Mesh::SetMaterialCount(std::size_t matCount) { NazaraAssert(m_isValid, "Mesh should be created first"); NazaraAssert(matCount > 0, "A mesh should have at least a material"); @@ -611,7 +609,7 @@ namespace Nz #ifdef NAZARA_DEBUG for (SubMeshData& data : m_subMeshes) { - UInt32 matIndex = data.subMesh->GetMaterialIndex(); + std::size_t matIndex = data.subMesh->GetMaterialIndex(); if (matIndex >= matCount) { data.subMesh->SetMaterialIndex(0); // To prevent a crash @@ -635,8 +633,8 @@ namespace Nz Boxf aabb(vertices->position.x, vertices->position.y, vertices->position.z, 0.f, 0.f, 0.f); - UInt32 vertexCount = staticMesh.GetVertexCount(); - for (UInt32 i = 0; i < vertexCount; ++i) + std::size_t vertexCount = staticMesh.GetVertexCount(); + for (std::size_t i = 0; i < vertexCount; ++i) { vertices->position = matrix.Transform(vertices->position); aabb.ExtendTo(vertices->position); @@ -648,7 +646,7 @@ namespace Nz } } - MeshRef Mesh::LoadFromFile(const String& filePath, const MeshParams& params) + MeshRef Mesh::LoadFromFile(const std::filesystem::path& filePath, const MeshParams& params) { return MeshLoader::LoadFromFile(filePath, params); } diff --git a/src/Nazara/Utility/SkeletalMesh.cpp b/src/Nazara/Utility/SkeletalMesh.cpp index e5a3a3268..7b8bc6a78 100644 --- a/src/Nazara/Utility/SkeletalMesh.cpp +++ b/src/Nazara/Utility/SkeletalMesh.cpp @@ -80,7 +80,7 @@ namespace Nz return m_vertexBuffer; } - unsigned int SkeletalMesh::GetVertexCount() const + std::size_t SkeletalMesh::GetVertexCount() const { return m_vertexBuffer->GetVertexCount(); } diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index 45958980f..21e0596b7 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -11,7 +11,7 @@ namespace Nz { struct SkeletonImpl { - std::unordered_map jointMap; + std::unordered_map jointMap; std::vector joints; Boxf aabb; bool aabbUpdated = false; @@ -32,7 +32,7 @@ namespace Nz Destroy(); } - bool Skeleton::Create(UInt32 jointCount) + bool Skeleton::Create(std::size_t jointCount) { #if NAZARA_UTILITY_SAFE if (jointCount == 0) @@ -118,7 +118,7 @@ namespace Nz return &m_impl->joints[it->second]; } - Joint* Skeleton::GetJoint(UInt32 index) + Joint* Skeleton::GetJoint(std::size_t index) { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -165,7 +165,7 @@ namespace Nz return &m_impl->joints[it->second]; } - const Joint* Skeleton::GetJoint(UInt32 index) const + const Joint* Skeleton::GetJoint(std::size_t index) const { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -210,7 +210,7 @@ namespace Nz return &m_impl->joints[0]; } - UInt32 Skeleton::GetJointCount() const + std::size_t Skeleton::GetJointCount() const { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -220,7 +220,7 @@ namespace Nz } #endif - return static_cast(m_impl->joints.size()); + return static_cast(m_impl->joints.size()); } int Skeleton::GetJointIndex(const String& jointName) const @@ -285,7 +285,7 @@ namespace Nz InvalidateJoints(); } - void Skeleton::Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount) + void Skeleton::Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, std::size_t* indices, std::size_t indiceCount) { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -315,9 +315,9 @@ namespace Nz const Joint* jointsA = &skeletonA.m_impl->joints[0]; const Joint* jointsB = &skeletonB.m_impl->joints[0]; - for (UInt32 i = 0; i < indiceCount; ++i) + for (std::size_t i = 0; i < indiceCount; ++i) { - UInt32 index = indices[i]; + std::size_t index = indices[i]; #if NAZARA_UTILITY_SAFE if (index >= m_impl->joints.size()) @@ -352,7 +352,7 @@ namespace Nz m_impl->jointMapUpdated = skeleton.m_impl->jointMapUpdated; m_impl->joints = skeleton.m_impl->joints; - // Code crade mais son optimisation demanderait de stocker jointCount*sizeof(UInt32) en plus + // Code crade mais son optimisation demanderait de stocker jointCount*sizeof(std::size_t) en plus // Ce qui, pour juste une copie qui ne se fera que rarement, ne vaut pas le coup // L'éternel trade-off mémoire/calculs .. std::size_t jointCount = skeleton.m_impl->joints.size(); @@ -414,7 +414,7 @@ namespace Nz { NazaraAssert(m_impl->jointMap.find(name) == m_impl->jointMap.end(), "Joint name \"" + name + "\" is already present in joint map"); - m_impl->jointMap[name] = static_cast(i); + m_impl->jointMap[name] = static_cast(i); } } diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index b363736f7..38de3c033 100644 --- a/src/Nazara/Utility/StaticMesh.cpp +++ b/src/Nazara/Utility/StaticMesh.cpp @@ -107,7 +107,7 @@ namespace Nz return m_vertexBuffer; } - unsigned int StaticMesh::GetVertexCount() const + std::size_t StaticMesh::GetVertexCount() const { return m_vertexBuffer->GetVertexCount(); } diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 0b7a95b31..b10c42992 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -32,14 +32,14 @@ namespace Nz void SubMesh::GenerateNormals() { VertexMapper mapper(this); - UInt32 vertexCount = mapper.GetVertexCount(); + std::size_t vertexCount = mapper.GetVertexCount(); SparsePtr normals = mapper.GetComponentPtr(VertexComponent_Normal); SparsePtr positions = mapper.GetComponentPtr(VertexComponent_Position); if (!normals || !positions) return; - for (UInt32 i = 0; i < vertexCount; ++i) + for (std::size_t i = 0; i < vertexCount; ++i) normals[i].MakeZero(); TriangleIterator iterator(this); @@ -58,14 +58,14 @@ namespace Nz } while (iterator.Advance()); - for (UInt32 i = 0; i < vertexCount; ++i) + for (std::size_t i = 0; i < vertexCount; ++i) normals[i].Normalize(); } void SubMesh::GenerateNormalsAndTangents() { VertexMapper mapper(this); - UInt32 vertexCount = mapper.GetVertexCount(); + std::size_t vertexCount = mapper.GetVertexCount(); SparsePtr normals = mapper.GetComponentPtr(VertexComponent_Normal); SparsePtr positions = mapper.GetComponentPtr(VertexComponent_Position); @@ -74,7 +74,7 @@ namespace Nz if (!normals || !positions || !tangents || !texCoords) return; - for (UInt32 i = 0; i < vertexCount; ++i) + for (std::size_t i = 0; i < vertexCount; ++i) { normals[i].MakeZero(); tangents[i].MakeZero(); @@ -169,10 +169,10 @@ namespace Nz return m_primitiveMode; } - unsigned int SubMesh::GetTriangleCount() const + std::size_t SubMesh::GetTriangleCount() const { const IndexBuffer* indexBuffer = GetIndexBuffer(); - unsigned int indexCount; + std::size_t indexCount; if (indexBuffer) indexCount = indexBuffer->GetIndexCount(); else @@ -199,7 +199,7 @@ namespace Nz return 0; } - UInt32 SubMesh::GetMaterialIndex() const + std::size_t SubMesh::GetMaterialIndex() const { return m_matIndex; } @@ -209,7 +209,7 @@ namespace Nz m_primitiveMode = mode; } - void SubMesh::SetMaterialIndex(UInt32 matIndex) + void SubMesh::SetMaterialIndex(std::size_t matIndex) { m_matIndex = matIndex; } diff --git a/src/Nazara/Utility/VertexBuffer.cpp b/src/Nazara/Utility/VertexBuffer.cpp index e072c4aa1..2e2e22e21 100644 --- a/src/Nazara/Utility/VertexBuffer.cpp +++ b/src/Nazara/Utility/VertexBuffer.cpp @@ -15,13 +15,13 @@ namespace Nz Reset(std::move(vertexDeclaration), std::move(buffer)); } - VertexBuffer::VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, UInt32 offset, UInt32 size) + VertexBuffer::VertexBuffer(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, std::size_t offset, std::size_t size) { ErrorFlags(ErrorFlag_ThrowException, true); Reset(std::move(vertexDeclaration), std::move(buffer), offset, size); } - VertexBuffer::VertexBuffer(VertexDeclarationConstRef vertexDeclaration, UInt32 length, DataStorage storage, BufferUsageFlags usage) + VertexBuffer::VertexBuffer(VertexDeclarationConstRef vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage) { ErrorFlags(ErrorFlag_ThrowException, true); Reset(std::move(vertexDeclaration), length, storage, usage); @@ -42,13 +42,13 @@ namespace Nz OnVertexBufferRelease(this); } - bool VertexBuffer::Fill(const void* data, UInt32 startVertex, UInt32 length) + bool VertexBuffer::Fill(const void* data, std::size_t startVertex, std::size_t length) { - UInt32 stride = static_cast(m_vertexDeclaration->GetStride()); + std::size_t stride = static_cast(m_vertexDeclaration->GetStride()); return FillRaw(data, startVertex*stride, length*stride); } - bool VertexBuffer::FillRaw(const void* data, UInt32 offset, UInt32 size) + bool VertexBuffer::FillRaw(const void* data, std::size_t offset, std::size_t size) { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); @@ -56,24 +56,24 @@ namespace Nz return m_buffer->Fill(data, m_startOffset + offset, size); } - void* VertexBuffer::Map(BufferAccess access, UInt32 startVertex, UInt32 length) + void* VertexBuffer::Map(BufferAccess access, std::size_t startVertex, std::size_t length) { - UInt32 stride = static_cast(m_vertexDeclaration->GetStride()); + std::size_t stride = static_cast(m_vertexDeclaration->GetStride()); return MapRaw(access, startVertex*stride, length*stride); } - void* VertexBuffer::Map(BufferAccess access, UInt32 startVertex, UInt32 length) const + void* VertexBuffer::Map(BufferAccess access, std::size_t startVertex, std::size_t length) const { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_vertexDeclaration, "Invalid vertex declaration"); - UInt32 stride = static_cast(m_vertexDeclaration->GetStride()); + std::size_t stride = static_cast(m_vertexDeclaration->GetStride()); return MapRaw(access, startVertex*stride, length*stride); } - void* VertexBuffer::MapRaw(BufferAccess access, UInt32 offset, UInt32 size) + void* VertexBuffer::MapRaw(BufferAccess access, std::size_t offset, std::size_t size) { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); @@ -81,7 +81,7 @@ namespace Nz return m_buffer->Map(access, offset, size); } - void* VertexBuffer::MapRaw(BufferAccess access, UInt32 offset, UInt32 size) const + void* VertexBuffer::MapRaw(BufferAccess access, std::size_t offset, std::size_t size) const { NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); @@ -99,11 +99,11 @@ namespace Nz { NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); - UInt32 size = buffer->GetSize(); + std::size_t size = buffer->GetSize(); Reset(std::move(vertexDeclaration), std::move(buffer), 0, size); } - void VertexBuffer::Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, UInt32 offset, UInt32 size) + void VertexBuffer::Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer, std::size_t offset, std::size_t size) { NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); NazaraAssert(size > 0, "Invalid size"); @@ -112,13 +112,13 @@ namespace Nz m_buffer = buffer; m_endOffset = offset + size; m_startOffset = offset; - m_vertexCount = (vertexDeclaration) ? (size / static_cast(vertexDeclaration->GetStride())) : 0; + m_vertexCount = (vertexDeclaration) ? (size / static_cast(vertexDeclaration->GetStride())) : 0; m_vertexDeclaration = vertexDeclaration; } - void VertexBuffer::Reset(VertexDeclarationConstRef vertexDeclaration, UInt32 length, DataStorage storage, BufferUsageFlags usage) + void VertexBuffer::Reset(VertexDeclarationConstRef vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage) { - m_endOffset = length * ((vertexDeclaration) ? static_cast(vertexDeclaration->GetStride()) : 1); + m_endOffset = length * ((vertexDeclaration) ? static_cast(vertexDeclaration->GetStride()) : 1); m_startOffset = 0; m_vertexCount = length; m_vertexDeclaration = std::move(vertexDeclaration); @@ -139,7 +139,7 @@ namespace Nz { NazaraAssert(vertexDeclaration, "Invalid vertex declaration"); - m_vertexCount = (m_endOffset - m_startOffset) / static_cast(vertexDeclaration->GetStride()); + m_vertexCount = (m_endOffset - m_startOffset) / static_cast(vertexDeclaration->GetStride()); m_vertexDeclaration = std::move(vertexDeclaration); } diff --git a/tests/Engine/Audio/Music.cpp b/tests/Engine/Audio/Music.cpp index 2e0edd8c3..262e87bc6 100644 --- a/tests/Engine/Audio/Music.cpp +++ b/tests/Engine/Audio/Music.cpp @@ -1,8 +1,8 @@ +#include #include #include - -#include -#include +#include +#include SCENARIO("Music", "[AUDIO][MUSIC]") { @@ -32,9 +32,9 @@ SCENARIO("Music", "[AUDIO][MUSIC]") Nz::Audio::SetGlobalVolume(0.f); music.Play(); - Nz::Thread::Sleep(1000); + std::this_thread::sleep_for(std::chrono::seconds(1)); REQUIRE(music.GetPlayingOffset() >= 950); - Nz::Thread::Sleep(200); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); REQUIRE(music.GetPlayingOffset() <= 1300); music.Pause(); REQUIRE(music.GetStatus() == Nz::SoundStatus_Paused); diff --git a/tests/Engine/Audio/Sound.cpp b/tests/Engine/Audio/Sound.cpp index 684138ccd..aa58bd537 100644 --- a/tests/Engine/Audio/Sound.cpp +++ b/tests/Engine/Audio/Sound.cpp @@ -1,8 +1,8 @@ +#include #include #include - -#include -#include +#include +#include SCENARIO("Sound", "[AUDIO][SOUND]") { @@ -26,10 +26,10 @@ SCENARIO("Sound", "[AUDIO][SOUND]") { Nz::Audio::SetGlobalVolume(0.f); - sound.Play(); - Nz::Thread::Sleep(1000); + sound.Play(); + std::this_thread::sleep_for(std::chrono::seconds(1)); REQUIRE(sound.GetPlayingOffset() >= 950); - Nz::Thread::Sleep(200); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); REQUIRE(sound.GetPlayingOffset() <= 1300); sound.Pause(); REQUIRE(sound.GetStatus() == Nz::SoundStatus_Paused); diff --git a/tests/Engine/Audio/SoundEmitter.cpp b/tests/Engine/Audio/SoundEmitter.cpp index baac41eb3..c2cf4f318 100644 --- a/tests/Engine/Audio/SoundEmitter.cpp +++ b/tests/Engine/Audio/SoundEmitter.cpp @@ -1,8 +1,6 @@ #include #include -#include - SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]") { GIVEN("A sound emitter") diff --git a/tests/Engine/Core/Clock.cpp b/tests/Engine/Core/Clock.cpp index 0bd579163..4e62996f1 100644 --- a/tests/Engine/Core/Clock.cpp +++ b/tests/Engine/Core/Clock.cpp @@ -1,6 +1,7 @@ #include -#include #include +#include +#include SCENARIO("Clock", "[CORE][CLOCK]") { @@ -25,7 +26,7 @@ SCENARIO("Clock", "[CORE][CLOCK]") THEN("Time must not be the initialTime") { - Nz::Thread::Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); Nz::UInt64 microSeconds = clock.GetMicroseconds(); CHECK(microSeconds != initialTime); CHECK(microSeconds / 1000 <= clock.GetMilliseconds()); diff --git a/tests/Engine/Core/Directory.cpp b/tests/Engine/Core/Directory.cpp deleted file mode 100644 index 5e60ed0ca..000000000 --- a/tests/Engine/Core/Directory.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -SCENARIO("Directory", "[CORE][DIRECTORY]") -{ - GIVEN("The current directory") - { - Nz::Directory currentDirectory(Nz::Directory::GetCurrent()); - CHECK(currentDirectory.Exists()); - currentDirectory.Open(); - - WHEN("We create a new directory Test Directory") - { - Nz::Directory::Create("Test Directory"); - - THEN("A new directory has been created") - { - CHECK(Nz::Directory::Exists(currentDirectory.GetCurrent() + "/Test Directory")); - CHECK(currentDirectory.IsOpen()); - } - } - - AND_WHEN("We delete it") - { - Nz::Directory::Remove(currentDirectory.GetCurrent() + "/Test Directory", true); - - THEN("It doesn't exist anymore") - { - CHECK(!Nz::Directory::Exists(currentDirectory.GetCurrent() + "/Test Directory")); - } - } - } -} - diff --git a/tests/Engine/Core/File.cpp b/tests/Engine/Core/File.cpp index 60b5bcc40..e78a812d1 100644 --- a/tests/Engine/Core/File.cpp +++ b/tests/Engine/Core/File.cpp @@ -1,5 +1,4 @@ #include -#include #include SCENARIO("File", "[CORE][FILE]") @@ -9,7 +8,7 @@ SCENARIO("File", "[CORE][FILE]") WHEN("We create a new file") { Nz::File file("Test File.txt", Nz::OpenMode_ReadWrite); - REQUIRE(file.GetDirectory() == Nz::Directory::GetCurrent() + NAZARA_DIRECTORY_SEPARATOR); + REQUIRE(file.GetDirectory() == std::filesystem::current_path()); REQUIRE(file.IsOpen()); THEN("We are allowed to write 3 times 'Test String'") @@ -53,18 +52,18 @@ SCENARIO("File", "[CORE][FILE]") WHEN("We delete this file") { - Nz::File::Delete("Test File.txt"); + std::filesystem::remove("Test File.txt"); THEN("It doesn't exist anymore") { - CHECK(!Nz::File::Exists("Test File.txt")); + CHECK(!std::filesystem::exists("Test File.txt")); } } } GIVEN("The test file") { - REQUIRE(Nz::File::Exists("resources/Engine/Core/FileTest.txt")); + REQUIRE(std::filesystem::exists("resources/Engine/Core/FileTest.txt")); Nz::File fileTest("resources/Engine/Core/FileTest.txt", Nz::OpenMode_ReadOnly | Nz::OpenMode_Text); @@ -79,20 +78,4 @@ SCENARIO("File", "[CORE][FILE]") } } } - - GIVEN("Nothing") - { - WHEN("We get the absolute path of something containing relative path") - { - Nz::String containingDot = "/resources/Spaceship/./spaceship.mtl"; - Nz::String containingDoubleDot = "/resources/Spaceship/../Spaceship/spaceship.mtl"; - - THEN("The relative positioning should disappear") - { - Nz::String containingNoMoreDot = Nz::File::NormalizePath("/resources/Spaceship/spaceship.mtl"); - REQUIRE(Nz::File::AbsolutePath(containingDot).EndsWith(containingNoMoreDot)); - REQUIRE(Nz::File::AbsolutePath(containingDoubleDot).EndsWith(containingNoMoreDot)); - } - } - } } diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index 2c34e0b0b..0bc90483c 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -1,10 +1,11 @@ -#include #include #include #include #include #include +#include #include +#include SCENARIO("TCP", "[NETWORK][TCP]") { @@ -29,7 +30,7 @@ SCENARIO("TCP", "[NETWORK][TCP]") Nz::IpAddress clientIP = client.GetRemoteAddress(); CHECK(clientIP.IsValid()); - Nz::Thread::Sleep(100); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); Nz::TcpClient serverToClient; REQUIRE(server.AcceptClient(&serverToClient)); diff --git a/thirdparty/include/Utfcpp/utf8.h b/thirdparty/include/Utfcpp/utf8.h index 82b13f59f..c2c85d6d0 100644 --- a/thirdparty/include/Utfcpp/utf8.h +++ b/thirdparty/include/Utfcpp/utf8.h @@ -31,4 +31,8 @@ DEALINGS IN THE SOFTWARE. #include "utf8/checked.h" #include "utf8/unchecked.h" +#if __cplusplus >= 201103L // C++ 11 or later +#include "utf8/cpp11.h" +#endif // C++ 11 or later + #endif // header guard diff --git a/thirdparty/include/Utfcpp/utf8/checked.h b/thirdparty/include/Utfcpp/utf8/checked.h index 23a5e473d..c31861e0a 100644 --- a/thirdparty/include/Utfcpp/utf8/checked.h +++ b/thirdparty/include/Utfcpp/utf8/checked.h @@ -1,4 +1,4 @@ -// Copyright 2006 Nemanja Trifunovic +// Copyright 2006-2016 Nemanja Trifunovic /* Permission is hereby granted, free of charge, to any person or organization @@ -41,7 +41,7 @@ namespace utf8 class invalid_code_point : public exception { uint32_t cp; public: - invalid_code_point(uint32_t Cp) : cp(Cp) {} // @Lynix: -Wshadow + invalid_code_point(uint32_t codepoint) : cp(codepoint) {} virtual const char* what() const throw() { return "Invalid code point"; } uint32_t code_point() const {return cp;} }; @@ -107,7 +107,9 @@ namespace utf8 *out++ = *it; break; case internal::NOT_ENOUGH_ROOM: - throw not_enough_room(); + out = utf8::append (replacement, out); + start = end; + break; case internal::INVALID_LEAD: out = utf8::append (replacement, out); ++start; @@ -174,23 +176,19 @@ namespace utf8 return utf8::peek_next(it, end); } - /// Deprecated in versions that include "prior" - template - uint32_t previous(octet_iterator& it, octet_iterator pass_start) - { - octet_iterator end = it; - while (utf8::internal::is_trail(*(--it))) - if (it == pass_start) - throw invalid_utf8(*it); // error - no lead byte in the sequence - octet_iterator temp = it; - return utf8::next(temp, end); - } - template void advance (octet_iterator& it, distance_type n, octet_iterator end) { - for (distance_type i = 0; i < n; ++i) - utf8::next(it, end); + const distance_type zero(0); + if (n < zero) { + // backward + for (distance_type i = n; i < zero; ++i) + utf8::prior(it, end); + } else { + // forward + for (distance_type i = zero; i < n; ++i) + utf8::next(it, end); + } } template @@ -233,7 +231,7 @@ namespace utf8 template u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result) { - while (start != end) { + while (start < end) { uint32_t cp = utf8::next(start, end); if (cp > 0xffff) { //make a surrogate pair *result++ = static_cast((cp >> 10) + internal::LEAD_OFFSET); @@ -257,7 +255,7 @@ namespace utf8 template u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result) { - while (start != end) + while (start < end) (*result++) = utf8::next(start, end); return result; @@ -272,9 +270,9 @@ namespace utf8 public: iterator () {} explicit iterator (const octet_iterator& octet_it, - const octet_iterator& Range_start, // @Lynix: -Wshadow - const octet_iterator& Range_end) : // @Lynix: -Wshadow - it(octet_it), range_start(Range_start), range_end(Range_end) // @Lynix: -Wshadow + const octet_iterator& rangestart, + const octet_iterator& rangeend) : + it(octet_it), range_start(rangestart), range_end(rangeend) { if (it < range_start || it > range_end) throw std::out_of_range("Invalid utf-8 iterator position"); @@ -324,4 +322,3 @@ namespace utf8 #endif //header guard - diff --git a/thirdparty/include/Utfcpp/utf8/core.h b/thirdparty/include/Utfcpp/utf8/core.h index 636795143..01e061b0a 100644 --- a/thirdparty/include/Utfcpp/utf8/core.h +++ b/thirdparty/include/Utfcpp/utf8/core.h @@ -50,8 +50,8 @@ namespace internal const uint16_t LEAD_SURROGATE_MAX = 0xdbffu; const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u; const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu; - const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10); - const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN; + const uint16_t LEAD_OFFSET = 0xd7c0u; // LEAD_SURROGATE_MIN - (0x10000 >> 10) + const uint32_t SURROGATE_OFFSET = 0xfca02400u; // 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN // Maximum valid value for a Unicode code point const uint32_t CODE_POINT_MAX = 0x0010ffffu; @@ -143,7 +143,7 @@ namespace internal if (!utf8::internal::is_trail(*it)) return INCOMPLETE_SEQUENCE; - + return UTF8_OK; } @@ -166,7 +166,7 @@ namespace internal { if (it == end) return NOT_ENOUGH_ROOM; - + code_point = utf8::internal::mask8(*it); UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) @@ -223,6 +223,9 @@ namespace internal template utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point) { + if (it == end) + return NOT_ENOUGH_ROOM; + // Save the original value of it so we can go back in case of failure // Of course, it does not make much sense with i.e. stream iterators octet_iterator original_it = it; @@ -235,7 +238,7 @@ namespace internal // Get trail octets and calculate the code point utf_error err = UTF8_OK; switch (length) { - case 0: + case 0: return INVALID_LEAD; case 1: err = utf8::internal::get_sequence_1(it, end, cp); @@ -311,18 +314,7 @@ namespace internal ((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) && ((it != end) && (utf8::internal::mask8(*it)) == bom[2]) ); - } - - //Deprecated in release 2.3 - template - inline bool is_bom (octet_iterator it) - { - return ( - (utf8::internal::mask8(*it++)) == bom[0] && - (utf8::internal::mask8(*it++)) == bom[1] && - (utf8::internal::mask8(*it)) == bom[2] - ); - } + } } // namespace utf8 #endif // header guard diff --git a/thirdparty/include/Utfcpp/utf8/cpp11.h b/thirdparty/include/Utfcpp/utf8/cpp11.h new file mode 100644 index 000000000..d93961b04 --- /dev/null +++ b/thirdparty/include/Utfcpp/utf8/cpp11.h @@ -0,0 +1,103 @@ +// Copyright 2018 Nemanja Trifunovic + +/* +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + + +#ifndef UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1 +#define UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1 + +#include "checked.h" +#include + +namespace utf8 +{ + + inline void append(char32_t cp, std::string& s) + { + append(uint32_t(cp), std::back_inserter(s)); + } + + inline std::string utf16to8(const std::u16string& s) + { + std::string result; + utf16to8(s.begin(), s.end(), std::back_inserter(result)); + return result; + } + + inline std::u16string utf8to16(const std::string& s) + { + std::u16string result; + utf8to16(s.begin(), s.end(), std::back_inserter(result)); + return result; + } + + inline std::string utf32to8(const std::u32string& s) + { + std::string result; + utf32to8(s.begin(), s.end(), std::back_inserter(result)); + return result; + } + + inline std::u32string utf8to32(const std::string& s) + { + std::u32string result; + utf8to32(s.begin(), s.end(), std::back_inserter(result)); + return result; + } + + inline std::size_t find_invalid(const std::string& s) + { + std::string::const_iterator invalid = find_invalid(s.begin(), s.end()); + return (invalid == s.end()) ? std::string::npos : (invalid - s.begin()); + } + + inline bool is_valid(const std::string& s) + { + return is_valid(s.begin(), s.end()); + } + + inline std::string replace_invalid(const std::string& s, char32_t replacement) + { + std::string result; + replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement); + return result; + } + + inline std::string replace_invalid(const std::string& s) + { + std::string result; + replace_invalid(s.begin(), s.end(), std::back_inserter(result)); + return result; + } + + inline bool starts_with_bom(const std::string& s) + { + return starts_with_bom(s.begin(), s.end()); + } + +} // namespace utf8 + +#endif // header guard + diff --git a/thirdparty/include/Utfcpp/utf8/unchecked.h b/thirdparty/include/Utfcpp/utf8/unchecked.h index cb2427166..def000997 100644 --- a/thirdparty/include/Utfcpp/utf8/unchecked.h +++ b/thirdparty/include/Utfcpp/utf8/unchecked.h @@ -32,13 +32,13 @@ DEALINGS IN THE SOFTWARE. namespace utf8 { - namespace unchecked + namespace unchecked { template octet_iterator append(uint32_t cp, octet_iterator result) { if (cp < 0x80) // one octet - *(result++) = static_cast(cp); + *(result++) = static_cast(cp); else if (cp < 0x800) { // two octets *(result++) = static_cast((cp >> 6) | 0xc0); *(result++) = static_cast((cp & 0x3f) | 0x80); @@ -57,6 +57,46 @@ namespace utf8 return result; } + template + output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement) + { + while (start != end) { + octet_iterator sequence_start = start; + internal::utf_error err_code = utf8::internal::validate_next(start, end); + switch (err_code) { + case internal::UTF8_OK : + for (octet_iterator it = sequence_start; it != start; ++it) + *out++ = *it; + break; + case internal::NOT_ENOUGH_ROOM: + out = utf8::unchecked::append (replacement, out); + start = end; + break; + case internal::INVALID_LEAD: + out = utf8::unchecked::append (replacement, out); + ++start; + break; + case internal::INCOMPLETE_SEQUENCE: + case internal::OVERLONG_SEQUENCE: + case internal::INVALID_CODE_POINT: + out = utf8::unchecked::append (replacement, out); + ++start; + // just one replacement mark for the sequence + while (start != end && utf8::internal::is_trail(*start)) + ++start; + break; + } + } + return out; + } + + template + inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out) + { + static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd); + return utf8::unchecked::replace_invalid(start, end, out, replacement_marker); + } + template uint32_t next(octet_iterator& it) { @@ -85,13 +125,13 @@ namespace utf8 break; } ++it; - return cp; + return cp; } template uint32_t peek_next(octet_iterator it) { - return utf8::unchecked::next(it); + return utf8::unchecked::next(it); } template @@ -102,18 +142,19 @@ namespace utf8 return utf8::unchecked::next(temp); } - // Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous) - template - inline uint32_t previous(octet_iterator& it) - { - return utf8::unchecked::prior(it); - } - template void advance (octet_iterator& it, distance_type n) { - for (distance_type i = 0; i < n; ++i) - utf8::unchecked::next(it); + const distance_type zero(0); + if (n < zero) { + // backward + for (distance_type i = n; i < zero; ++i) + utf8::unchecked::prior(it); + } else { + // forward + for (distance_type i = zero; i < n; ++i) + utf8::unchecked::next(it); + } } template @@ -128,7 +169,7 @@ namespace utf8 template octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result) - { + { while (start != end) { uint32_t cp = utf8::internal::mask16(*start++); // Take care of surrogate pairs first @@ -138,7 +179,7 @@ namespace utf8 } result = utf8::unchecked::append(cp, result); } - return result; + return result; } template From 8b5f9d68c3c8664e144b62da535830356dbb6225 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 00:49:38 +0100 Subject: [PATCH 03/25] Fix missing includes --- include/Nazara/Core/StringExt.inl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl index 064ca8be6..5203358f3 100644 --- a/include/Nazara/Core/StringExt.inl +++ b/include/Nazara/Core/StringExt.inl @@ -3,6 +3,9 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include +#include #include namespace Nz From 2cc95b4f7559e2f517128fdfe4e91df3d23a1277 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:06:34 +0100 Subject: [PATCH 04/25] Update travis docker (to support C++17) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e697ccb25..852e52ae1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:stretch +FROM debian:buster RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libxcb-cursor-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev libassimp-dev From 364122f582a6f904ebc7e836cb285df46a1be2e1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:06:48 +0100 Subject: [PATCH 05/25] SparsePtr: Make pointer conversion explicit --- include/Nazara/Core/SparsePtr.hpp | 2 +- src/Nazara/Physics3D/Collider3D.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index aad0e453e..c26602697 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -43,7 +43,7 @@ namespace Nz void SetStride(int stride); explicit operator bool() const; - operator T*() const; + explicit operator T*() const; T& operator*() const; T* operator->() const; T& operator[](std::size_t index) const; diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index be7ceb6be..be4436a61 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -347,7 +347,7 @@ namespace Nz m_vertices[i] = *vertices++; } else // Fast path - std::memcpy(m_vertices.data(), vertices, vertexCount*sizeof(Vector3f)); + std::memcpy(m_vertices.data(), vertices.GetPtr(), vertexCount*sizeof(Vector3f)); } ConvexCollider3D::ConvexCollider3D(SparsePtr vertices, unsigned int vertexCount, float tolerance, const Vector3f& translation, const Quaternionf& rotation) : From 8ace61ce7ddaaf2d756f405669ac004046683e64 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:17:27 +0100 Subject: [PATCH 06/25] DynLib: Posix fixes --- src/Nazara/Core/Posix/DynLibImpl.cpp | 27 +++++++++++++-------------- src/Nazara/Core/Posix/DynLibImpl.hpp | 7 ++++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Nazara/Core/Posix/DynLibImpl.cpp b/src/Nazara/Core/Posix/DynLibImpl.cpp index f519c916f..6311b44e6 100644 --- a/src/Nazara/Core/Posix/DynLibImpl.cpp +++ b/src/Nazara/Core/Posix/DynLibImpl.cpp @@ -10,12 +10,18 @@ namespace Nz { - DynLibImpl::DynLibImpl(DynLib* parent) + DynLibImpl::DynLibImpl(DynLib*) : + m_handle(nullptr) { - NazaraUnused(parent); } - DynLibFunc DynLibImpl::GetSymbol(const String& symbol, String* errorMessage) const + DynLibImpl::~DynLibImpl() + { + if (m_handle) + dlclose(m_handle); + } + + DynLibFunc DynLibImpl::GetSymbol(const char* symbol, std::string* errorMessage) const { /* Il n'est pas standard de cast un pointeur d'objet vers un pointeur de fonction. @@ -31,19 +37,17 @@ namespace Nz dlerror(); // Clear error flag - converter.pointer = dlsym(m_handle, symbol.GetConstBuffer()); + converter.pointer = dlsym(m_handle, symbol); if (!converter.pointer) *errorMessage = dlerror(); return converter.func; } - bool DynLibImpl::Load(const String& libraryPath, String* errorMessage) + bool DynLibImpl::Load(const std::filesystem::path& libraryPath, std::string* errorMessage) { - String path = libraryPath; - - size_t pos = path.FindLast(".so"); - if (pos == String::npos || (path.GetLength() > pos+3 && path[pos+3] != '.')) + std::filesystem::path path = libraryPath; + if (path.extension() != ".so") path += ".so"; dlerror(); // Clear error flag @@ -57,9 +61,4 @@ namespace Nz return false; } } - - void DynLibImpl::Unload() - { - dlclose(m_handle); - } } diff --git a/src/Nazara/Core/Posix/DynLibImpl.hpp b/src/Nazara/Core/Posix/DynLibImpl.hpp index e101abc84..10b38addf 100644 --- a/src/Nazara/Core/Posix/DynLibImpl.hpp +++ b/src/Nazara/Core/Posix/DynLibImpl.hpp @@ -8,6 +8,8 @@ #define NAZARA_DYNLIBIMPL_HPP #include +#include +#include namespace Nz { @@ -19,9 +21,8 @@ namespace Nz DynLibImpl(DynLib* m_parent); ~DynLibImpl() = default; - DynLibFunc GetSymbol(const String& symbol, String* errorMessage) const; - bool Load(const String& libraryPath, String* errorMessage); - void Unload(); + DynLibFunc GetSymbol(const char* symbol, std::string* errorMessage) const; + bool Load(const std::filesystem::path& libraryPath, std::string* errorMessage); private: void* m_handle; From 3fc67b35981ee92e1ee500a32573720587648d2a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:20:48 +0100 Subject: [PATCH 07/25] Core/FileLogger: Drop noexcept specifier for movement Since fstream doesn't have it --- include/Nazara/Core/FileLogger.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/FileLogger.hpp b/include/Nazara/Core/FileLogger.hpp index f61ba8046..6ca049453 100644 --- a/include/Nazara/Core/FileLogger.hpp +++ b/include/Nazara/Core/FileLogger.hpp @@ -20,7 +20,7 @@ namespace Nz public: FileLogger(const String& logPath = "NazaraLog.log"); FileLogger(const FileLogger&) = default; - FileLogger(FileLogger&&) noexcept = default; + FileLogger(FileLogger&&) = default; ~FileLogger(); void EnableTimeLogging(bool enable); @@ -33,7 +33,7 @@ namespace Nz void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override; FileLogger& operator=(const FileLogger&) = default; - FileLogger& operator=(FileLogger&&) noexcept = default; + FileLogger& operator=(FileLogger&&) = default; private: std::fstream m_outputFile; From f084c30d703d08da79c86e4e7a2717d8e6c654eb Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:26:36 +0100 Subject: [PATCH 08/25] Posix fixes --- src/Nazara/Core/Posix/DynLibImpl.cpp | 2 +- src/Nazara/Core/Posix/DynLibImpl.hpp | 2 +- src/Nazara/Core/Posix/FileImpl.cpp | 16 +++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Nazara/Core/Posix/DynLibImpl.cpp b/src/Nazara/Core/Posix/DynLibImpl.cpp index 6311b44e6..4e14fbf17 100644 --- a/src/Nazara/Core/Posix/DynLibImpl.cpp +++ b/src/Nazara/Core/Posix/DynLibImpl.cpp @@ -51,7 +51,7 @@ namespace Nz path += ".so"; dlerror(); // Clear error flag - m_handle = dlopen(path.GetConstBuffer(), RTLD_LAZY | RTLD_GLOBAL); + m_handle = dlopen(path.generic_u8string().data(), RTLD_LAZY | RTLD_GLOBAL); if (m_handle) return true; diff --git a/src/Nazara/Core/Posix/DynLibImpl.hpp b/src/Nazara/Core/Posix/DynLibImpl.hpp index 10b38addf..1ce00e423 100644 --- a/src/Nazara/Core/Posix/DynLibImpl.hpp +++ b/src/Nazara/Core/Posix/DynLibImpl.hpp @@ -19,7 +19,7 @@ namespace Nz { public: DynLibImpl(DynLib* m_parent); - ~DynLibImpl() = default; + ~DynLibImpl(); DynLibFunc GetSymbol(const char* symbol, std::string* errorMessage) const; bool Load(const std::filesystem::path& libraryPath, std::string* errorMessage); diff --git a/src/Nazara/Core/Posix/FileImpl.cpp b/src/Nazara/Core/Posix/FileImpl.cpp index c08a8c383..b340abde1 100644 --- a/src/Nazara/Core/Posix/FileImpl.cpp +++ b/src/Nazara/Core/Posix/FileImpl.cpp @@ -76,8 +76,8 @@ namespace Nz if (mode & OpenMode_Truncate) flags |= O_TRUNC; - m_fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions); - if (m_fileDescriptor == -1) + int fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions); + if (fileDescriptor == -1) { NazaraError("Failed to open \"" + filePath.generic_u8string() + "\" : " + Error::GetLastSystemError()); return false; @@ -96,16 +96,16 @@ namespace Nz initialize_flock(lock); - if (fcntl(m_fileDescriptor, F_GETLK, &lock) == -1) + if (fcntl(fileDescriptor, F_GETLK, &lock) == -1) { - Close(); + close(fileDescriptor); NazaraError("Unable to detect presence of lock on the file"); return false; } if (lock.l_type != F_UNLCK) { - Close(); + close(fileDescriptor); NazaraError("A lock is present on the file"); return false; } @@ -114,14 +114,16 @@ namespace Nz { initialize_flock(lock); - if (fcntl(m_fileDescriptor, F_SETLK, &lock) == -1) + if (fcntl(fileDescriptor, F_SETLK, &lock) == -1) { - Close(); + close(fileDescriptor); NazaraError("Unable to place a lock on the file"); return false; } } + m_fileDescriptor = fileDescriptor; + return true; } From 9ac5aadc9dc568cf4df971e4ad825782de5c45ef Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:29:47 +0100 Subject: [PATCH 09/25] I swear I fixed that --- src/Nazara/Core/Posix/FileImpl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/Posix/FileImpl.hpp b/src/Nazara/Core/Posix/FileImpl.hpp index d74ae4f3e..ae35375ce 100644 --- a/src/Nazara/Core/Posix/FileImpl.hpp +++ b/src/Nazara/Core/Posix/FileImpl.hpp @@ -27,7 +27,7 @@ namespace Nz FileImpl(const File* parent); FileImpl(const FileImpl&) = delete; FileImpl(FileImpl&&) = delete; ///TODO - ~FileImpl() = default; + ~FileImpl(); bool EndOfFile() const; void Flush(); From 97a62a48176430071b40376804b74e2ca9b5a89b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:35:09 +0100 Subject: [PATCH 10/25] StringExt: Fix some template mistakes --- src/Nazara/Core/StringExt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Core/StringExt.cpp b/src/Nazara/Core/StringExt.cpp index 52f4e90cc..a56447b98 100644 --- a/src/Nazara/Core/StringExt.cpp +++ b/src/Nazara/Core/StringExt.cpp @@ -49,7 +49,7 @@ namespace Nz } else { - static_assert(AlwaysFalse, "Unsupported platform"); + static_assert(AlwaysFalse>::value, "Unsupported platform"); return std::string(""); } } @@ -72,8 +72,8 @@ namespace Nz } else { - static_assert(AlwaysFalse, "Unsupported platform"); - return std::string(""); + static_assert(AlwaysFalse>, "Unsupported platform"); + return std::wstring(L""); } } }; From 385702525312bc1110e66da1ddb357d151e36d93 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:38:06 +0100 Subject: [PATCH 11/25] *darth vader yelling noooooo gif* --- src/Nazara/Core/StringExt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/StringExt.cpp b/src/Nazara/Core/StringExt.cpp index a56447b98..2238a3810 100644 --- a/src/Nazara/Core/StringExt.cpp +++ b/src/Nazara/Core/StringExt.cpp @@ -72,7 +72,7 @@ namespace Nz } else { - static_assert(AlwaysFalse>, "Unsupported platform"); + static_assert(AlwaysFalse>::value, "Unsupported platform"); return std::wstring(L""); } } From 6ec2f3e56e5e7a5b8b86fea9e945d0e358779b12 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 02:49:32 +0100 Subject: [PATCH 12/25] More Linux fixes --- src/Nazara/Platform/X11/WindowImpl.cpp | 20 ++++++++++---------- src/Nazara/Platform/X11/WindowImpl.hpp | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Nazara/Platform/X11/WindowImpl.cpp b/src/Nazara/Platform/X11/WindowImpl.cpp index abf2db675..caf9ebd60 100644 --- a/src/Nazara/Platform/X11/WindowImpl.cpp +++ b/src/Nazara/Platform/X11/WindowImpl.cpp @@ -165,15 +165,14 @@ namespace Nz if (m_style & WindowStyle_Threaded) { - Mutex mutex; - ConditionVariable condition; + std::mutex mutex; + std::condition_variable condition; m_threadActive = true; // Wait until the thread is ready - mutex.Lock(); - m_thread = Thread(WindowThread, this, &mutex, &condition); - condition.Wait(&mutex); - mutex.Unlock(); + std::unique_lock lock(mutex); + m_thread = std::string(WindowThread, this, std::ref(mutex), std::ref(condition)); + condition.wait(lock); } // Set fullscreen video mode and switch to fullscreen if necessary @@ -1577,11 +1576,12 @@ namespace Nz )); } - void WindowImpl::WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition) + void WindowImpl::WindowThread(WindowImpl* window, std::mutex& mutex, std::condition_variable& condition) { - mutex->Lock(); - condition->Signal(); - mutex->Unlock(); // mutex and condition may be destroyed after this line + { + std::lock_guard lock(mutex); + condition.notify_all(); + } if (!window->m_window) return; diff --git a/src/Nazara/Platform/X11/WindowImpl.hpp b/src/Nazara/Platform/X11/WindowImpl.hpp index ecf5e0233..16509b9e5 100644 --- a/src/Nazara/Platform/X11/WindowImpl.hpp +++ b/src/Nazara/Platform/X11/WindowImpl.hpp @@ -10,18 +10,18 @@ #define NAZARA_WINDOWIMPL_HPP #include -#include #include #include #include #include +#include +#include +#include #include #include namespace Nz { - class ConditionVariable; - class Mutex; class Cursor; class Icon; class VideoMode; @@ -100,13 +100,13 @@ namespace Nz bool UpdateNormalHints(); void UpdateEventQueue(xcb_generic_event_t* event); - static void WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition); + static void WindowThread(WindowImpl* window, std::mutex& mutex, std::condition_variable& condition); xcb_window_t m_window; xcb_screen_t* m_screen; xcb_randr_get_screen_info_reply_t m_oldVideoMode; xcb_size_hints_t m_size_hints; - Thread m_thread; + std::thread m_thread; WindowStyleFlags m_style; Window* m_parent; bool m_eventListener; From a51e77fe833c76c9b2bb91e5f3912837e521d6bd Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 11:14:41 +0100 Subject: [PATCH 13/25] [Posix] Fix compilation --- appveyor.yml | 2 ++ src/Nazara/Platform/X11/WindowImpl.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index dcdf221ad..544370634 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,7 @@ shallow_clone: true skip_commits: files: - .travis.yml + - Dockerfile - Doxyfile - LICENSE - License-Cabin.txt @@ -15,6 +16,7 @@ skip_commits: - 'writing style.md' - doc/* - NazaraModuleTemplate/* + message: /\[Posix\]/ os: - Visual Studio 2017 diff --git a/src/Nazara/Platform/X11/WindowImpl.cpp b/src/Nazara/Platform/X11/WindowImpl.cpp index caf9ebd60..0d81a9c05 100644 --- a/src/Nazara/Platform/X11/WindowImpl.cpp +++ b/src/Nazara/Platform/X11/WindowImpl.cpp @@ -171,7 +171,7 @@ namespace Nz // Wait until the thread is ready std::unique_lock lock(mutex); - m_thread = std::string(WindowThread, this, std::ref(mutex), std::ref(condition)); + m_thread = std::thread(WindowThread, this, std::ref(mutex), std::ref(condition)); condition.wait(lock); } From 6fd31d1c71356cfcb313a731cd4a59970adba461 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 11:29:54 +0100 Subject: [PATCH 14/25] [Posix] Moar fixes --- src/Nazara/Platform/X11/WindowImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Platform/X11/WindowImpl.cpp b/src/Nazara/Platform/X11/WindowImpl.cpp index 0d81a9c05..787fa5e40 100644 --- a/src/Nazara/Platform/X11/WindowImpl.cpp +++ b/src/Nazara/Platform/X11/WindowImpl.cpp @@ -237,10 +237,10 @@ namespace Nz { if (m_style & WindowStyle_Threaded) { - if (m_thread.IsJoinable()) + if (m_thread.joinable()) { m_threadActive = false; - m_thread.Join(); + m_thread.join(); } } From 7c1857ba1eb0f2531afa7f6aee8a823cfcbd3189 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 11:36:50 +0100 Subject: [PATCH 15/25] Fix missing include --- src/Nazara/Renderer/RenderWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index b4d4f259b..3bbfdf09e 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace Nz From eb8800f8124d3d2701e154c37a669cecc80198d6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 17:52:06 +0100 Subject: [PATCH 16/25] Remove Lua and Noise modules --- SDK/include/NDK/Application.hpp | 2 - SDK/include/NDK/Lua/LuaBinding.hpp | 68 -- SDK/include/NDK/Lua/LuaBinding.inl | 70 -- SDK/include/NDK/Lua/LuaBinding_Audio.hpp | 33 - SDK/include/NDK/Lua/LuaBinding_Base.hpp | 55 -- SDK/include/NDK/Lua/LuaBinding_Core.hpp | 31 - SDK/include/NDK/Lua/LuaBinding_Graphics.hpp | 36 - SDK/include/NDK/Lua/LuaBinding_Math.hpp | 37 - SDK/include/NDK/Lua/LuaBinding_Network.hpp | 31 - SDK/include/NDK/Lua/LuaBinding_Platform.hpp | 28 - SDK/include/NDK/Lua/LuaBinding_Renderer.hpp | 29 - SDK/include/NDK/Lua/LuaBinding_SDK.hpp | 43 - SDK/include/NDK/Lua/LuaBinding_Utility.hpp | 32 - SDK/include/NDK/LuaAPI.hpp | 42 - SDK/include/NDK/LuaAPI.inl | 687 -------------- SDK/src/NDK/Application.cpp | 42 - SDK/src/NDK/Lua/LuaBinding.cpp | 68 -- SDK/src/NDK/Lua/LuaBinding_Audio.cpp | 198 ---- SDK/src/NDK/Lua/LuaBinding_Base.cpp | 13 - SDK/src/NDK/Lua/LuaBinding_Core.cpp | 279 ------ SDK/src/NDK/Lua/LuaBinding_Graphics.cpp | 498 ---------- SDK/src/NDK/Lua/LuaBinding_Math.cpp | 986 -------------------- SDK/src/NDK/Lua/LuaBinding_Network.cpp | 314 ------- SDK/src/NDK/Lua/LuaBinding_Platform.cpp | 133 --- SDK/src/NDK/Lua/LuaBinding_Renderer.cpp | 110 --- SDK/src/NDK/Lua/LuaBinding_SDK.cpp | 354 ------- SDK/src/NDK/Lua/LuaBinding_Utility.cpp | 338 ------- SDK/src/NDK/LuaAPI.cpp | 63 -- SDK/src/NDK/Sdk.cpp | 6 - build/scripts/modules/lua.lua | 7 - build/scripts/modules/noise.lua | 5 - examples/FirstScene/main.cpp | 6 - examples/Particles/LogoDemo.cpp | 2 +- examples/Particles/main.cpp | 4 +- examples/Tut00/main.cpp | 4 +- include/Nazara/Lua.hpp | 40 - include/Nazara/Lua/Config.hpp | 51 - include/Nazara/Lua/ConfigCheck.hpp | 18 - include/Nazara/Lua/Debug.hpp | 8 - include/Nazara/Lua/DebugOff.hpp | 9 - include/Nazara/Lua/Enums.hpp | 93 -- include/Nazara/Lua/Lua.hpp | 32 - include/Nazara/Lua/LuaClass.hpp | 121 --- include/Nazara/Lua/LuaClass.inl | 603 ------------ include/Nazara/Lua/LuaCoroutine.hpp | 42 - include/Nazara/Lua/LuaCoroutine.inl | 22 - include/Nazara/Lua/LuaInstance.hpp | 57 -- include/Nazara/Lua/LuaInstance.inl | 40 - include/Nazara/Lua/LuaState.hpp | 210 ----- include/Nazara/Lua/LuaState.inl | 843 ----------------- include/Nazara/Noise.hpp | 44 - include/Nazara/Noise/Config.hpp | 51 - include/Nazara/Noise/ConfigCheck.hpp | 18 - include/Nazara/Noise/Debug.hpp | 8 - include/Nazara/Noise/DebugOff.hpp | 9 - include/Nazara/Noise/Enums.hpp | 18 - include/Nazara/Noise/FBM.hpp | 31 - include/Nazara/Noise/HybridMultiFractal.hpp | 31 - include/Nazara/Noise/MixerBase.hpp | 41 - include/Nazara/Noise/Noise.hpp | 32 - include/Nazara/Noise/NoiseBase.hpp | 47 - include/Nazara/Noise/NoiseTools.hpp | 14 - include/Nazara/Noise/Perlin.hpp | 27 - include/Nazara/Noise/Simplex.hpp | 27 - include/Nazara/Noise/Worley.hpp | 37 - src/Nazara/Lua/Debug/NewOverload.cpp | 31 - src/Nazara/Lua/Lua.cpp | 63 -- src/Nazara/Lua/LuaCoroutine.cpp | 54 -- src/Nazara/Lua/LuaInstance.cpp | 167 ---- src/Nazara/Lua/LuaState.cpp | 875 ----------------- src/Nazara/Noise/Debug/NewOverload.cpp | 31 - src/Nazara/Noise/FBM.cpp | 62 -- src/Nazara/Noise/HybridMultiFractal.cpp | 98 -- src/Nazara/Noise/MixerBase.cpp | 56 -- src/Nazara/Noise/Noise.cpp | 65 -- src/Nazara/Noise/NoiseBase.cpp | 74 -- src/Nazara/Noise/NoiseTools.cpp | 28 - src/Nazara/Noise/Perlin.cpp | 274 ------ src/Nazara/Noise/Simplex.cpp | 374 -------- src/Nazara/Noise/Worley.cpp | 155 --- tests/Engine/Lua/LuaClass.cpp | 249 ----- tests/Engine/Lua/LuaCoroutine.cpp | 31 - tests/Engine/Lua/LuaInstance.cpp | 84 -- tests/Engine/Lua/LuaState.cpp | 216 ----- 84 files changed, 4 insertions(+), 10261 deletions(-) delete mode 100644 SDK/include/NDK/Lua/LuaBinding.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding.inl delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Audio.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Base.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Core.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Graphics.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Math.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Network.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Platform.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Renderer.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_SDK.hpp delete mode 100644 SDK/include/NDK/Lua/LuaBinding_Utility.hpp delete mode 100644 SDK/include/NDK/LuaAPI.hpp delete mode 100644 SDK/include/NDK/LuaAPI.inl delete mode 100644 SDK/src/NDK/Lua/LuaBinding.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Audio.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Base.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Core.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Graphics.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Math.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Network.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Platform.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Renderer.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_SDK.cpp delete mode 100644 SDK/src/NDK/Lua/LuaBinding_Utility.cpp delete mode 100644 SDK/src/NDK/LuaAPI.cpp delete mode 100644 build/scripts/modules/lua.lua delete mode 100644 build/scripts/modules/noise.lua delete mode 100644 include/Nazara/Lua.hpp delete mode 100644 include/Nazara/Lua/Config.hpp delete mode 100644 include/Nazara/Lua/ConfigCheck.hpp delete mode 100644 include/Nazara/Lua/Debug.hpp delete mode 100644 include/Nazara/Lua/DebugOff.hpp delete mode 100644 include/Nazara/Lua/Enums.hpp delete mode 100644 include/Nazara/Lua/Lua.hpp delete mode 100644 include/Nazara/Lua/LuaClass.hpp delete mode 100644 include/Nazara/Lua/LuaClass.inl delete mode 100644 include/Nazara/Lua/LuaCoroutine.hpp delete mode 100644 include/Nazara/Lua/LuaCoroutine.inl delete mode 100644 include/Nazara/Lua/LuaInstance.hpp delete mode 100644 include/Nazara/Lua/LuaInstance.inl delete mode 100644 include/Nazara/Lua/LuaState.hpp delete mode 100644 include/Nazara/Lua/LuaState.inl delete mode 100644 include/Nazara/Noise.hpp delete mode 100644 include/Nazara/Noise/Config.hpp delete mode 100644 include/Nazara/Noise/ConfigCheck.hpp delete mode 100644 include/Nazara/Noise/Debug.hpp delete mode 100644 include/Nazara/Noise/DebugOff.hpp delete mode 100644 include/Nazara/Noise/Enums.hpp delete mode 100644 include/Nazara/Noise/FBM.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal.hpp delete mode 100644 include/Nazara/Noise/MixerBase.hpp delete mode 100644 include/Nazara/Noise/Noise.hpp delete mode 100644 include/Nazara/Noise/NoiseBase.hpp delete mode 100644 include/Nazara/Noise/NoiseTools.hpp delete mode 100644 include/Nazara/Noise/Perlin.hpp delete mode 100644 include/Nazara/Noise/Simplex.hpp delete mode 100644 include/Nazara/Noise/Worley.hpp delete mode 100644 src/Nazara/Lua/Debug/NewOverload.cpp delete mode 100644 src/Nazara/Lua/Lua.cpp delete mode 100644 src/Nazara/Lua/LuaCoroutine.cpp delete mode 100644 src/Nazara/Lua/LuaInstance.cpp delete mode 100644 src/Nazara/Lua/LuaState.cpp delete mode 100644 src/Nazara/Noise/Debug/NewOverload.cpp delete mode 100644 src/Nazara/Noise/FBM.cpp delete mode 100644 src/Nazara/Noise/HybridMultiFractal.cpp delete mode 100644 src/Nazara/Noise/MixerBase.cpp delete mode 100644 src/Nazara/Noise/Noise.cpp delete mode 100644 src/Nazara/Noise/NoiseBase.cpp delete mode 100644 src/Nazara/Noise/NoiseTools.cpp delete mode 100644 src/Nazara/Noise/Perlin.cpp delete mode 100644 src/Nazara/Noise/Simplex.cpp delete mode 100644 src/Nazara/Noise/Worley.cpp delete mode 100644 tests/Engine/Lua/LuaClass.cpp delete mode 100644 tests/Engine/Lua/LuaCoroutine.cpp delete mode 100644 tests/Engine/Lua/LuaInstance.cpp delete mode 100644 tests/Engine/Lua/LuaState.cpp diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 69e97bdce..23417bcd8 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -83,7 +82,6 @@ namespace Ndk struct ConsoleOverlay { Console* console; - Nz::LuaInstance lua; NazaraSlot(Nz::EventHandler, OnEvent, eventSlot); NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot); diff --git a/SDK/include/NDK/Lua/LuaBinding.hpp b/SDK/include/NDK/Lua/LuaBinding.hpp deleted file mode 100644 index 2a14cb5a5..000000000 --- a/SDK/include/NDK/Lua/LuaBinding.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_HPP -#define NDK_LUABINDING_HPP - -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding - { - friend class LuaBinding_SDK; - - public: - LuaBinding(); - ~LuaBinding() = default; - - template void BindComponent(const Nz::String& name); - - void RegisterClasses(Nz::LuaState& state); - - std::unique_ptr core; - std::unique_ptr math; - std::unique_ptr network; - std::unique_ptr sdk; - std::unique_ptr utility; - - #ifndef NDK_SERVER - std::unique_ptr audio; - std::unique_ptr graphics; - std::unique_ptr renderer; - std::unique_ptr platform; - #endif - - private: - template - static int AddComponentOfType(Nz::LuaState& lua, EntityHandle& handle); - - template - static int PushComponentOfType(Nz::LuaState& lua, BaseComponent& component); - - using AddComponentFunc = int(*)(Nz::LuaState&, EntityHandle&); - using GetComponentFunc = int(*)(Nz::LuaState&, BaseComponent&); - - struct ComponentBinding - { - AddComponentFunc adder; - ComponentIndex index; - GetComponentFunc getter; - Nz::String name; - }; - - ComponentBinding* QueryComponentIndex(Nz::LuaState& lua, int argIndex = 2); - - std::vector m_componentBinding; - std::unordered_map m_componentBindingByName; - }; -} - -#include - -#endif // NDK_LUABINDING_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding.inl b/SDK/include/NDK/Lua/LuaBinding.inl deleted file mode 100644 index 95ea207ab..000000000 --- a/SDK/include/NDK/Lua/LuaBinding.inl +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -namespace Ndk -{ - namespace Detail - { - template - struct AddComponentIf; - - template<> - struct AddComponentIf - { - template - static int AddComponent(Nz::LuaState& lua, EntityHandle& handle) - { - T& component = handle->AddComponent(); - lua.Push(component.CreateHandle()); - return 1; - } - }; - - template<> - struct AddComponentIf - { - template - static int AddComponent(Nz::LuaState& lua, EntityHandle& /*handle*/) - { - lua.Error("Component has no default constructor and cannot be created from Lua yet"); - return 0; - } - }; - } - - /*! - * \brief Binds a component to a name - * - * \param name Name used to retrieve the component - * - * \remark Produces a NazaraAssert if name is empty - */ - template - void LuaBinding::BindComponent(const Nz::String& name) - { - NazaraAssert(!name.IsEmpty(), "Component name cannot be empty"); - - static_assert(std::is_base_of::value, "ComponentType must inherit BaseComponent"); - - ComponentBinding binding; - binding.adder = &Detail::AddComponentIf::value>::template AddComponent; - binding.getter = &PushComponentOfType; - binding.index = T::componentIndex; - binding.name = name; - - if (m_componentBinding.size() <= T::componentIndex) - m_componentBinding.resize(T::componentIndex + 1); - - m_componentBinding[T::componentIndex] = std::move(binding); - m_componentBindingByName[name] = T::componentIndex; - } - - template - int LuaBinding::PushComponentOfType(Nz::LuaState& lua, BaseComponent& component) - { - T& rightComponent = static_cast(component); - lua.Push(rightComponent.CreateHandle()); - return 1; - } -} diff --git a/SDK/include/NDK/Lua/LuaBinding_Audio.hpp b/SDK/include/NDK/Lua/LuaBinding_Audio.hpp deleted file mode 100644 index f2ee8c1ac..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Audio.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_AUDIO_HPP -#define NDK_LUABINDING_AUDIO_HPP - -#include -#include -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Audio : public LuaBinding_Base - { - public: - LuaBinding_Audio(LuaBinding& binding); - ~LuaBinding_Audio() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass music; - Nz::LuaClass sound; - Nz::LuaClass soundBuffer; - Nz::LuaClass soundEmitter; - }; -} - -#endif // NDK_LUABINDING_CORE_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Base.hpp b/SDK/include/NDK/Lua/LuaBinding_Base.hpp deleted file mode 100644 index 5a52e0bc2..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Base.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_BASE_HPP -#define NDK_LUABINDING_BASE_HPP - -#include -#include -#include - -namespace Ndk -{ - class LuaBinding; - - class LuaBinding_Audio; - class LuaBinding_Core; - class LuaBinding_Graphics; - class LuaBinding_Math; - class LuaBinding_Network; - class LuaBinding_Renderer; - class LuaBinding_SDK; - class LuaBinding_Utility; - class LuaBinding_Platform; - - class NDK_API LuaBinding_Base - { - public: - LuaBinding_Base(LuaBinding& binding); - virtual ~LuaBinding_Base(); - - virtual void Register(Nz::LuaState& state) = 0; - - // Implementation lies in the respective .cpp files (still searching for a cleaner way..) - static std::unique_ptr BindCore(LuaBinding& binding); - static std::unique_ptr BindMath(LuaBinding& binding); - static std::unique_ptr BindNetwork(LuaBinding& binding); - static std::unique_ptr BindSDK(LuaBinding& binding); - static std::unique_ptr BindUtility(LuaBinding& binding); - - #ifndef NDK_SERVER - static std::unique_ptr BindAudio(LuaBinding& binding); - static std::unique_ptr BindGraphics(LuaBinding& binding); - static std::unique_ptr BindRenderer(LuaBinding& binding); - static std::unique_ptr BindPlatform(LuaBinding& binding); - #endif - - protected: - LuaBinding& m_binding; - }; -} - -#endif // NDK_LUABINDING_BASE_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Core.hpp b/SDK/include/NDK/Lua/LuaBinding_Core.hpp deleted file mode 100644 index 4277936e0..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Core.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_CORE_HPP -#define NDK_LUABINDING_CORE_HPP - -#include -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Core : public LuaBinding_Base - { - public: - LuaBinding_Core(LuaBinding& binding); - ~LuaBinding_Core() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass clock; - Nz::LuaClass file; - Nz::LuaClass stream; - }; -} - -#endif // NDK_LUABINDING_CORE_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp b/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp deleted file mode 100644 index 7a804dd0f..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Graphics.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_GRAPHICS_HPP -#define NDK_LUABINDING_GRAPHICS_HPP - -#include -#include -#include -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Graphics : public LuaBinding_Base - { - public: - LuaBinding_Graphics(LuaBinding& binding); - ~LuaBinding_Graphics() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass abstractViewer; - Nz::LuaClass instancedRenderable; - Nz::LuaClass material; - Nz::LuaClass model; - Nz::LuaClass sprite; - Nz::LuaClass spriteLibrary; - }; -} - -#endif // NDK_LUABINDING_GRAPHICS_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Math.hpp b/SDK/include/NDK/Lua/LuaBinding_Math.hpp deleted file mode 100644 index 5849a7c33..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Math.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_MATH_HPP -#define NDK_LUABINDING_MATH_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Math : public LuaBinding_Base - { - public: - LuaBinding_Math(LuaBinding& binding); - ~LuaBinding_Math() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass eulerAngles; - Nz::LuaClass matrix4d; - Nz::LuaClass quaternion; - Nz::LuaClass rect; - Nz::LuaClass vector2d; - Nz::LuaClass vector3d; - }; -} - -#endif // NDK_LUABINDING_MATH_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Network.hpp b/SDK/include/NDK/Lua/LuaBinding_Network.hpp deleted file mode 100644 index 1b7f32f27..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Network.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_NETWORK_HPP -#define NDK_LUABINDING_NETWORK_HPP - -#include -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Network : public LuaBinding_Base - { - public: - LuaBinding_Network(LuaBinding& binding); - ~LuaBinding_Network() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass abstractSocket; - Nz::LuaClass ipAddress; - Nz::LuaClass udpSocket; - }; -} - -#endif // NDK_LUABINDING_NETWORK_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Platform.hpp b/SDK/include/NDK/Lua/LuaBinding_Platform.hpp deleted file mode 100644 index 2d28841e7..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Platform.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_SYSTEM_HPP -#define NDK_LUABINDING_SYSTEM_HPP - -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Platform : public LuaBinding_Base - { - public: - LuaBinding_Platform(LuaBinding& binding); - ~LuaBinding_Platform() = default; - - void Register(Nz::LuaState& state) override; - - // Platform - Nz::LuaClass keyboard; - }; -} - -#endif // NDK_LUABINDING_SYSTEM_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp b/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp deleted file mode 100644 index daa75e4af..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Renderer.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_RENDERER_HPP -#define NDK_LUABINDING_RENDERER_HPP - -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Renderer : public LuaBinding_Base - { - public: - LuaBinding_Renderer(LuaBinding& binding); - ~LuaBinding_Renderer() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass texture; - Nz::LuaClass textureLibrary; - Nz::LuaClass textureManager; - }; -} - -#endif // NDK_LUABINDING_RENDERER_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_SDK.hpp b/SDK/include/NDK/Lua/LuaBinding_SDK.hpp deleted file mode 100644 index a663edce4..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_SDK.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_SDK_HPP -#define NDK_LUABINDING_SDK_HPP - -#include -#include -#include -#include -#include - -namespace Ndk -{ - class Application; - - class NDK_API LuaBinding_SDK : public LuaBinding_Base - { - public: - LuaBinding_SDK(LuaBinding& binding); - ~LuaBinding_SDK() = default; - - void Register(Nz::LuaState& state) override; - - Nz::LuaClass application; - Nz::LuaClass entity; - Nz::LuaClass nodeComponent; - Nz::LuaClass velocityComponent; - Nz::LuaClass world; - - #ifndef NDK_SERVER - Nz::LuaClass cameraComponent; - Nz::LuaClass console; - Nz::LuaClass graphicsComponent; - #endif - - }; -} - -#endif // NDK_LUABINDING_SDK_HPP diff --git a/SDK/include/NDK/Lua/LuaBinding_Utility.hpp b/SDK/include/NDK/Lua/LuaBinding_Utility.hpp deleted file mode 100644 index 6f7fde64b..000000000 --- a/SDK/include/NDK/Lua/LuaBinding_Utility.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUABINDING_UTILITY_HPP -#define NDK_LUABINDING_UTILITY_HPP - -#include -#include -#include -#include - -namespace Ndk -{ - class NDK_API LuaBinding_Utility : public LuaBinding_Base - { - public: - LuaBinding_Utility(LuaBinding& binding); - ~LuaBinding_Utility() = default; - - void Register(Nz::LuaState& state) override; - - // Utility - Nz::LuaClass abstractImage; - Nz::LuaClass font; - Nz::LuaClass node; - }; -} - -#endif // NDK_LUABINDING_UTILITY_HPP diff --git a/SDK/include/NDK/LuaAPI.hpp b/SDK/include/NDK/LuaAPI.hpp deleted file mode 100644 index 457ffb980..000000000 --- a/SDK/include/NDK/LuaAPI.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#pragma once - -#ifndef NDK_LUAINTERFACE_HPP -#define NDK_LUAINTERFACE_HPP - -#include - -namespace Nz -{ - class LuaState; -} - -namespace Ndk -{ - class LuaBinding; - - class NDK_API LuaAPI - { - public: - LuaAPI() = delete; - ~LuaAPI() = delete; - - static LuaBinding* GetBinding(); - - static bool Initialize(); - - static void RegisterClasses(Nz::LuaState& state); - - static void Uninitialize(); - - private: - static LuaBinding* s_binding; - }; -} - -#include - -#endif // NDK_LUAINTERFACE_HPP diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl deleted file mode 100644 index b867e90fe..000000000 --- a/SDK/include/NDK/LuaAPI.inl +++ /dev/null @@ -1,687 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef NDK_SERVER -#include -#include -#include -#include -#include -#endif - -namespace Nz -{ - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Color* color, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - color->r = state.CheckField("r", index); - color->g = state.CheckField("g", index); - color->b = state.CheckField("b", index); - color->a = state.CheckField("a", 255, index); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, EulerAnglesd* angles, TypeTag) - { - switch (state.GetType(index)) - { - case Nz::LuaType_Table: - angles->Set(state.CheckField("pitch", index), state.CheckField("yaw", index), state.CheckField("roll", index)); - return 1; - - default: - { - if (state.IsOfType(index, "EulerAngles")) - angles->Set(*static_cast(state.ToUserdata(index))); - else - angles->Set(*static_cast(state.CheckUserdata(index, "Quaternion"))); - - return 1; - } - } - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, EulerAnglesf* angles, TypeTag) - { - EulerAnglesd anglesDouble; - unsigned int ret = LuaImplQueryArg(state, index, &anglesDouble, TypeTag()); - - angles->Set(anglesDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, FontRef* fontRef, TypeTag) - { - *fontRef = *static_cast(state.CheckUserdata(index, "Font")); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, FontParams* params, TypeTag) - { - NazaraUnused(params); - - state.CheckType(index, Nz::LuaType_Table); - - // Structure is empty for now - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, ImageParams* params, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - params->levelCount = state.CheckField("LevelCount"); - params->loadFormat = state.CheckField("LoadFormat"); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, IpAddress* address, TypeTag) - { - switch (state.GetType(index)) - { - case Nz::LuaType_String: - address->BuildFromAddress(state.CheckString(index)); - return 1; - - default: - *address = *static_cast(state.CheckUserdata(index, "IpAddress")); - return 1; - } - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Matrix4d* mat, TypeTag) - { - switch (state.GetType(index)) - { - case Nz::LuaType_Table: - { - double values[16]; - for (std::size_t i = 0; i < 16; ++i) - { - state.PushInteger(i + 1); - state.GetTable(); - - values[i] = state.CheckNumber(-1); - state.Pop(); - } - - *mat = Matrix4d(values); - return 1; - } - - default: - { - if (state.IsOfType(index, "Matrix4")) - *mat = *static_cast(state.ToUserdata(index)); - - return 1; - } - } - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Matrix4f* mat, TypeTag) - { - Matrix4d matDouble = Matrix4d::Identity(); - unsigned int ret = LuaImplQueryArg(state, index, &matDouble, TypeTag()); - - mat->Set(matDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MeshParams* params, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - params->animated = state.CheckField("Animated", params->animated); - params->center = state.CheckField("Center", params->center); - params->matrix = state.CheckField("Matrix", params->matrix); - params->optimizeIndexBuffers = state.CheckField("OptimizeIndexBuffers", params->optimizeIndexBuffers); - params->texCoordOffset = state.CheckField("TexCoordOffset", params->texCoordOffset); - params->texCoordScale = state.CheckField("TexCoordScale", params->texCoordScale); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Quaterniond* quat, TypeTag) - { - switch (state.GetType(index)) - { - case Nz::LuaType_Table: - quat->Set(state.CheckField("w", index), state.CheckField("x", index), state.CheckField("y", index), state.CheckField("z", index)); - return 1; - - default: - { - if (state.IsOfType(index, "EulerAngles")) - quat->Set(*static_cast(state.ToUserdata(index))); - else - quat->Set(*static_cast(state.CheckUserdata(index, "Quaternion"))); - - return 1; - } - } - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Quaternionf* quat, TypeTag) - { - Quaterniond quatDouble; - unsigned int ret = LuaImplQueryArg(state, index, &quatDouble, TypeTag()); - - quat->Set(quatDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectd* rect, TypeTag) - { - state.CheckType(index, LuaType_Table); - - rect->x = state.CheckField("x", index); - rect->y = state.CheckField("y", index); - rect->width = state.CheckField("width", index); - rect->height = state.CheckField("height", index); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectf* rect, TypeTag) - { - Rectd rectDouble; - unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag()); - - rect->Set(rectDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Recti* rect, TypeTag) - { - Rectd rectDouble; - unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag()); - - rect->Set(rectDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Rectui* rect, TypeTag) - { - Rectd rectDouble; - unsigned int ret = LuaImplQueryArg(state, index, &rectDouble, TypeTag()); - - rect->Set(rectDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2d* vec, TypeTag) - { - switch (state.GetType(index)) - { - case Nz::LuaType_Number: - if (index < 0 && index > -2) - state.Error("Vector2 expected, two numbers are required to convert it"); - - vec->Set(state.CheckNumber(index), state.CheckNumber(index + 1)); - return 2; - - case Nz::LuaType_Table: - vec->Set(state.CheckField("x", index), state.CheckField("y", index)); - return 1; - - default: - vec->Set(*static_cast(state.CheckUserdata(index, "Vector2"))); - return 1; - } - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2f* vec, TypeTag) - { - Vector2d vecDouble; - unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); - - vec->Set(vecDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2ui* vec, TypeTag) - { - Vector2d vecDouble; - unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); - - vec->Set(vecDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector2i* vec, TypeTag) - { - Vector2d vecDouble; - unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); - - vec->Set(vecDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3d* vec, TypeTag) - { - switch (state.GetType(index)) - { - case Nz::LuaType_Number: - if (index < 0 && index > -3) - state.Error("Vector3 expected, three numbers are required to convert it"); - - vec->Set(state.CheckNumber(index), state.CheckNumber(index + 1), state.CheckNumber(index + 2, 0.0)); - return 3; - - case Nz::LuaType_Table: - vec->Set(state.CheckField("x", index), state.CheckField("y", index), state.CheckField("z", 0.0, index)); - return 1; - - default: - vec->Set(*static_cast(state.CheckUserdata(index, "Vector3"))); - return 1; - } - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3f* vec, TypeTag) - { - Vector3d vecDouble; - unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); - - vec->Set(vecDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3ui* vec, TypeTag) - { - Vector3d vecDouble; - unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); - - vec->Set(vecDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Vector3i* vec, TypeTag) - { - Vector3d vecDouble; - unsigned int ret = LuaImplQueryArg(state, index, &vecDouble, TypeTag()); - - vec->Set(vecDouble); - return ret; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::Entity** handle, TypeTag) - { - if (!state.IsOfType(index, LuaType_Nil)) - *handle = *static_cast(state.CheckUserdata(index, "Entity")); - else - *handle = nullptr; - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::EntityHandle* handle, TypeTag) - { - if (!state.IsOfType(index, LuaType_Nil)) - *handle = *static_cast(state.CheckUserdata(index, "Entity")); - else - handle->Reset(); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::WorldHandle* handle, TypeTag) - { - *handle = *static_cast(state.CheckUserdata(index, "World")); - - return 1; - } - -#ifndef NDK_SERVER - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, InstancedRenderableRef* renderable, TypeTag) - { - if (state.IsOfType(index, "InstancedRenderable") || - state.IsOfType(index, "Model") || - state.IsOfType(index, "Sprite")) - { - *renderable = *static_cast(state.ToUserdata(index)); - } - else - state.ArgError(index, "is not a InstancedRenderable instance"); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MaterialRef* materialRef, TypeTag) - { - *materialRef = *static_cast(state.CheckUserdata(index, "Material")); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, MaterialParams* params, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - params->loadAlphaMap = state.CheckField("LoadAlphaMap", params->loadAlphaMap); - params->loadDiffuseMap = state.CheckField("LoadDiffuseMap", params->loadDiffuseMap); - params->loadEmissiveMap = state.CheckField("LoadEmissiveMap", params->loadEmissiveMap); - params->loadHeightMap = state.CheckField("LoadHeightMap", params->loadHeightMap); - params->loadNormalMap = state.CheckField("LoadNormalMap", params->loadNormalMap); - params->loadSpecularMap = state.CheckField("LoadSpecularMap", params->loadSpecularMap); - params->shaderName = state.CheckField("ShaderName", params->shaderName); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, ModelParameters* params, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - params->loadMaterials = state.CheckField("LoadMaterials", params->loadMaterials); - - LuaImplQueryArg(state, -1, ¶ms->material, TypeTag()); - LuaImplQueryArg(state, -1, ¶ms->mesh, TypeTag()); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SoundBufferParams* params, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - params->forceMono = state.CheckField("ForceMono", params->forceMono); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SoundStreamParams* params, TypeTag) - { - state.CheckType(index, Nz::LuaType_Table); - - params->forceMono = state.CheckField("ForceMono", params->forceMono); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, SpriteRef* spriteRef, TypeTag) - { - *spriteRef = *static_cast(state.CheckUserdata(index, "Sprite")); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& state, int index, TextureRef* textureRef, TypeTag) - { - *textureRef = *static_cast(state.CheckUserdata(index, "Texture")); - - return 1; - } -#endif - - inline int LuaImplReplyVal(const LuaState& state, Color&& val, TypeTag) - { - state.PushTable(); - state.PushField("r", val.r); - state.PushField("g", val.g); - state.PushField("b", val.b); - state.PushField("a", val.a); - - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, EulerAnglesd&& val, TypeTag) - { - state.PushInstance("EulerAngles", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, EulerAnglesf&& val, TypeTag) - { - state.PushInstance("EulerAngles", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, FontRef&& val, TypeTag) - { - state.PushInstance("Font", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Font::SizeInfo&& val, TypeTag) - { - state.PushTable(); - state.PushField("LineHeight", val.lineHeight); - state.PushField("SpaceAdvance", val.spaceAdvance); - state.PushField("UnderlinePosition", val.underlinePosition); - state.PushField("UnderlineThickness", val.underlineThickness); - - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, ImageParams&& val, TypeTag) - { - state.PushTable(0, 2); - state.PushField("LevelCount", val.levelCount); - state.PushField("LoadFormat", val.loadFormat); - - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, IpAddress&& val, TypeTag) - { - state.PushInstance("IpAddress", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Matrix4d&& val, TypeTag) - { - state.PushInstance("Matrix4", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Matrix4f&& val, TypeTag) - { - state.PushInstance("Matrix4", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Quaterniond&& val, TypeTag) - { - state.PushInstance("Quaternion", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Quaternionf&& val, TypeTag) - { - state.PushInstance("Quaternion", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Rectd&& val, TypeTag) - { - state.PushInstance("Rect", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Rectf&& val, TypeTag) - { - state.PushInstance("Rect", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Recti&& val, TypeTag) - { - state.PushInstance("Rect", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Rectui&& val, TypeTag) - { - state.PushInstance("Rect", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector2d&& val, TypeTag) - { - state.PushInstance("Vector2", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector2f&& val, TypeTag) - { - state.PushInstance("Vector2", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector2ui&& val, TypeTag) - { - state.PushInstance("Vector2", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector2i&& val, TypeTag) - { - state.PushInstance("Vector2", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector3d&& val, TypeTag) - { - state.PushInstance("Vector3", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector3f&& val, TypeTag) - { - state.PushInstance("Vector3", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector3ui&& val, TypeTag) - { - state.PushInstance("Vector3", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Vector3i&& val, TypeTag) - { - state.PushInstance("Vector3", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::Entity* ptr, TypeTag) - { - state.PushInstance("Entity", ptr); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::Application* ptr, TypeTag) - { - state.PushInstance("Application", ptr); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::EntityHandle&& handle, TypeTag) - { - state.PushInstance("Entity", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::NodeComponentHandle&& handle, TypeTag) - { - state.PushInstance("NodeComponent", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::VelocityComponentHandle&& handle, TypeTag) - { - state.PushInstance("VelocityComponent", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::World* ptr, TypeTag) - { - state.PushInstance("World", ptr); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::WorldHandle&& handle, TypeTag) - { - state.PushInstance("World", handle); - return 1; - } - -#ifndef NDK_SERVER - inline int LuaImplReplyVal(const LuaState& state, MaterialRef&& handle, TypeTag) - { - state.PushInstance("Material", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, ModelRef&& handle, TypeTag) - { - state.PushInstance("Model", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, const SoundBuffer* val, TypeTag) - { - state.PushInstance("SoundBuffer", val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, SoundBufferRef&& handle, TypeTag) - { - state.PushInstance("SoundBuffer", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, SpriteRef&& handle, TypeTag) - { - state.PushInstance("Sprite", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, TextureRef&& handle, TypeTag) - { - state.PushInstance("Texture", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::CameraComponentHandle&& handle, TypeTag) - { - state.PushInstance("CameraComponent", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::ConsoleHandle&& handle, TypeTag) - { - state.PushInstance("Console", handle); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& state, Ndk::GraphicsComponentHandle&& handle, TypeTag) - { - state.PushInstance("GraphicsComponent", handle); - return 1; - } -#endif - -} diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index cf6fcdbb5..b9a7047b4 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #endif @@ -151,14 +150,7 @@ namespace Ndk else windowDimensions.MakeZero(); - Nz::LuaInstance& lua = overlay->lua; - overlay->console = info.canvas->Add(); - overlay->console->OnCommand.Connect([&lua](Ndk::Console* console, const Nz::String& command) - { - if (!lua.Execute(command)) - console->AddLine(lua.GetLastError(), Nz::Color::Red); - }); Console& consoleRef = *overlay->console; consoleRef.Resize({float(windowDimensions.x), windowDimensions.y / 4.f}); @@ -170,40 +162,6 @@ namespace Ndk consoleRef.AddLine(str); }); - lua.LoadLibraries(); - LuaAPI::RegisterClasses(lua); - - // Override "print" function to add a line in the console - lua.PushFunction([&consoleRef] (Nz::LuaState& state) - { - Nz::StringStream stream; - - unsigned int argCount = state.GetStackTop(); - state.GetGlobal("tostring"); - for (unsigned int i = 1; i <= argCount; ++i) - { - state.PushValue(-1); // tostring function - state.PushValue(i); // argument - state.Call(1, 1); - - std::size_t length; - const char* str = state.CheckString(-1, &length); - if (i > 1) - stream << '\t'; - - stream << Nz::String(str, length); - state.Pop(1); - } - - consoleRef.AddLine(stream); - return 0; - }); - lua.SetGlobal("print"); - - // Define a few base variables to allow our interface to interact with the application - lua.PushGlobal("Application", Ndk::Application::Instance()); - lua.PushGlobal("Console", consoleRef.CreateHandle()); - // Setup a few event callback to handle the console Nz::EventHandler& eventHandler = info.window->GetEventHandler(); diff --git a/SDK/src/NDK/Lua/LuaBinding.cpp b/SDK/src/NDK/Lua/LuaBinding.cpp deleted file mode 100644 index 4bca51e19..000000000 --- a/SDK/src/NDK/Lua/LuaBinding.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include - -namespace Ndk -{ - /*! - * \ingroup NDK - * \class Ndk::LuaBinding - * \brief NDK class that represents the binding between the engine & the SDK with the Lua scripting - */ - - /*! - * \brief Binds modules to Lua - */ - - LuaBinding::LuaBinding() - { - core = LuaBinding_Base::BindCore(*this); - math = LuaBinding_Base::BindMath(*this); - network = LuaBinding_Base::BindNetwork(*this); - utility = LuaBinding_Base::BindUtility(*this); - - #ifndef NDK_SERVER - audio = LuaBinding_Base::BindAudio(*this); - renderer = LuaBinding_Base::BindRenderer(*this); - graphics = LuaBinding_Base::BindGraphics(*this); - platform = LuaBinding_Base::BindPlatform(*this); - #endif - - sdk = LuaBinding_Base::BindSDK(*this); - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the engine & SDK - */ - - void LuaBinding::RegisterClasses(Nz::LuaState& state) - { - core->Register(state); - math->Register(state); - network->Register(state); - sdk->Register(state); - utility->Register(state); - - #ifndef NDK_SERVER - audio->Register(state); - graphics->Register(state); - renderer->Register(state); - platform->Register(state); - #endif - - // ComponentType (fake enumeration to expose component indexes) - state.PushTable(0, m_componentBinding.size()); - { - for (const ComponentBinding& entry : m_componentBinding) - { - if (entry.name.IsEmpty()) - continue; - - state.PushField(entry.name, entry.index); - } - } - state.SetGlobal("ComponentType"); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Audio.cpp b/SDK/src/NDK/Lua/LuaBinding_Audio.cpp deleted file mode 100644 index df97a7d38..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Audio.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindAudio(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Audio::LuaBinding_Audio(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::SoundEmitter **********************************/ - soundEmitter.Reset("SoundEmitter"); - { - soundEmitter.BindMethod("EnableLooping", &Nz::SoundEmitter::EnableLooping); - soundEmitter.BindMethod("EnableSpatialization", &Nz::SoundEmitter::EnableSpatialization); - - soundEmitter.BindMethod("GetAttenuation", &Nz::SoundEmitter::GetAttenuation); - soundEmitter.BindMethod("GetDuration", &Nz::SoundEmitter::GetDuration); - soundEmitter.BindMethod("GetMinDistance", &Nz::SoundEmitter::GetMinDistance); - soundEmitter.BindMethod("GetPitch", &Nz::SoundEmitter::GetPitch); - soundEmitter.BindMethod("GetPlayingOffset", &Nz::SoundEmitter::GetPlayingOffset); - soundEmitter.BindMethod("GetPosition", &Nz::Sound::GetPosition); - soundEmitter.BindMethod("GetStatus", &Nz::SoundEmitter::GetStatus); - soundEmitter.BindMethod("GetVelocity", &Nz::Sound::GetVelocity); - soundEmitter.BindMethod("GetVolume", &Nz::SoundEmitter::GetVolume); - - soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping); - soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized); - - soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause); - soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play); - - soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation); - soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance); - soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch); - soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition); - soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity); - soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume); - - soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop); - } - - /*********************************** Nz::Music **********************************/ - music.Reset("Music"); - { - music.Inherit(soundEmitter); - - music.BindDefaultConstructor(); - - //musicClass.SetMethod("Create", &Nz::Music::Create); - //musicClass.SetMethod("Destroy", &Nz::Music::Destroy); - - music.BindMethod("EnableLooping", &Nz::Music::EnableLooping); - - music.BindMethod("GetDuration", &Nz::Music::GetDuration); - music.BindMethod("GetFormat", &Nz::Music::GetFormat); - music.BindMethod("GetPlayingOffset", &Nz::Music::GetPlayingOffset); - music.BindMethod("GetSampleCount", &Nz::Music::GetSampleCount); - music.BindMethod("GetSampleRate", &Nz::Music::GetSampleRate); - music.BindMethod("GetStatus", &Nz::Music::GetStatus); - - music.BindMethod("IsLooping", &Nz::Music::IsLooping); - - music.BindMethod("OpenFromFile", &Nz::Music::OpenFromFile, Nz::SoundStreamParams()); - - music.BindMethod("Pause", &Nz::Music::Pause); - music.BindMethod("Play", &Nz::Music::Play); - - music.BindMethod("SetPlayingOffset", &Nz::Music::SetPlayingOffset); - - music.BindMethod("Stop", &Nz::Music::Stop); - - // Manual - music.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int - { - Nz::StringStream ss("Music("); - ss << instance.GetFilePath().generic_u8string() << ')'; - - lua.PushString(ss); - return 1; - }); - } - - /*********************************** Nz::Sound **********************************/ - sound.Reset("Sound"); - { - sound.Inherit(soundEmitter); - - sound.BindDefaultConstructor(); - - sound.BindMethod("GetBuffer", &Nz::Sound::GetBuffer); - - sound.BindMethod("IsPlayable", &Nz::Sound::IsPlayable); - sound.BindMethod("IsPlaying", &Nz::Sound::IsPlaying); - - sound.BindMethod("LoadFromFile", &Nz::Sound::LoadFromFile, Nz::SoundBufferParams()); - - sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset); - - // Manual - sound.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int - { - Nz::StringStream ss("Sound("); - if (const Nz::SoundBuffer* buffer = instance.GetBuffer()) - ss << buffer; - - ss << ')'; - - lua.PushString(ss); - return 1; - }); - } - - /*********************************** Nz::SoundBuffer **********************************/ - soundBuffer.Reset("SoundBuffer"); - { - soundBuffer.SetConstructor([] (Nz::LuaState& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount) - { - NazaraUnused(lua); - NazaraUnused(argumentCount); - - Nz::PlacementNew(instance, Nz::SoundBuffer::New()); - return true; - }); - - soundBuffer.BindMethod("Destroy", &Nz::SoundBuffer::Destroy); - - soundBuffer.BindMethod("GetDuration", &Nz::SoundBuffer::GetDuration); - soundBuffer.BindMethod("GetFormat", &Nz::SoundBuffer::GetFormat); - soundBuffer.BindMethod("GetSampleCount", &Nz::SoundBuffer::GetSampleCount); - soundBuffer.BindMethod("GetSampleRate", &Nz::SoundBuffer::GetSampleRate); - - soundBuffer.BindMethod("IsValid", &Nz::SoundBuffer::IsValid); - - soundBuffer.BindStaticMethod("LoadFromFile", &Nz::SoundBuffer::LoadFromFile, Nz::SoundBufferParams()); - - soundBuffer.BindStaticMethod("IsFormatSupported", &Nz::SoundBuffer::IsFormatSupported); - - // Manual - soundBuffer.BindMethod("Create", [] (Nz::LuaState& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int - { - int index = 2; - Nz::AudioFormat format = lua.Check(&index); - unsigned int sampleCount = lua.Check(&index); - unsigned int sampleRate = lua.Check(&index); - - std::size_t bufferSize = 0; - const char* buffer = lua.CheckString(index, &bufferSize); - lua.ArgCheck(buffer && bufferSize >= sampleCount * sizeof(Nz::Int16), index, "Invalid buffer"); - - lua.PushBoolean(instance->Create(format, sampleCount, sampleRate, reinterpret_cast(buffer))); - return 1; - }); - - soundBuffer.BindMethod("GetSamples", [] (Nz::LuaState& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int - { - lua.PushString(reinterpret_cast(instance->GetSamples()), instance->GetSampleCount() * sizeof(Nz::Int16)); - return 1; - }); - - soundBuffer.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int - { - Nz::StringStream ss("SoundBuffer("); - if (instance->IsValid()) - { - std::filesystem::path filePath = instance->GetFilePath(); - if (!filePath.empty()) - ss << "File: " << filePath.generic_u8string() << ", "; - - ss << "Duration: " << instance->GetDuration() / 1000.f << "s"; - } - ss << ')'; - - lua.PushString(ss); - return 1; - }); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Audio classes - */ - void LuaBinding_Audio::Register(Nz::LuaState& state) - { - music.Register(state); - sound.Register(state); - soundBuffer.Register(state); - soundEmitter.Register(state); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Base.cpp b/SDK/src/NDK/Lua/LuaBinding_Base.cpp deleted file mode 100644 index b9bd44c57..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Base.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include - -namespace Ndk -{ - LuaBinding_Base::LuaBinding_Base(LuaBinding& binding) : - m_binding(binding) - { - } - - LuaBinding_Base::~LuaBinding_Base() = default; -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Core.cpp b/SDK/src/NDK/Lua/LuaBinding_Core.cpp deleted file mode 100644 index 49a7642f4..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Core.cpp +++ /dev/null @@ -1,279 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindCore(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Core::LuaBinding_Core(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::Stream ***********************************/ - stream.Reset("Stream"); - { - stream.BindMethod("EnableTextMode", &Nz::Stream::EnableTextMode); - stream.BindMethod("Flush", &Nz::Stream::Flush); - stream.BindMethod("GetCursorPos", &Nz::Stream::GetCursorPos); - stream.BindMethod("GetDirectory", &Nz::Stream::GetDirectory); - stream.BindMethod("GetPath", &Nz::Stream::GetPath); - stream.BindMethod("GetOpenMode", &Nz::Stream::GetOpenMode); - stream.BindMethod("GetStreamOptions", &Nz::Stream::GetStreamOptions); - stream.BindMethod("GetSize", &Nz::Stream::GetSize); - stream.BindMethod("ReadLine", &Nz::Stream::ReadLine, 0U); - stream.BindMethod("IsReadable", &Nz::Stream::IsReadable); - stream.BindMethod("IsSequential", &Nz::Stream::IsSequential); - stream.BindMethod("IsTextModeEnabled", &Nz::Stream::IsTextModeEnabled); - stream.BindMethod("IsWritable", &Nz::Stream::IsWritable); - stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos); - - stream.BindMethod("Read", [] (Nz::LuaState& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int { - int argIndex = 2; - - std::size_t length = lua.Check(&argIndex); - - std::unique_ptr buffer(new char[length]); - std::size_t readLength = instance.Read(buffer.get(), length); - - lua.PushString(Nz::String(buffer.get(), readLength)); - return 1; - }); - - stream.BindMethod("Write", [] (Nz::LuaState& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int { - int argIndex = 2; - - std::size_t bufferSize = 0; - const char* buffer = lua.CheckString(argIndex, &bufferSize); - - if (instance.IsTextModeEnabled()) - lua.Push(instance.Write(Nz::String(buffer, bufferSize))); - else - lua.Push(instance.Write(buffer, bufferSize)); - return 1; - }); - } - - /*********************************** Nz::Clock **********************************/ - clock.Reset("Clock"); - { - clock.SetConstructor([] (Nz::LuaState& lua, Nz::Clock* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 2U); - - int argIndex = 2; - switch (argCount) - { - case 0: - Nz::PlacementNew(instance); - return true; - - case 1: - { - Nz::Int64 startingValue = lua.Check(&argIndex, 0); - - Nz::PlacementNew(instance, startingValue); - return true; - } - - case 2: - { - Nz::Int64 startingValue = lua.Check(&argIndex, 0); - bool paused = lua.Check(&argIndex, false); - - Nz::PlacementNew(instance, startingValue, paused); - return true; - } - } - - lua.Error("No matching overload for Clock constructor"); - return false; - }); - - clock.BindMethod("GetMicroseconds", &Nz::Clock::GetMicroseconds); - clock.BindMethod("GetMilliseconds", &Nz::Clock::GetMilliseconds); - clock.BindMethod("GetSeconds", &Nz::Clock::GetSeconds); - clock.BindMethod("IsPaused", &Nz::Clock::IsPaused); - clock.BindMethod("Pause", &Nz::Clock::Pause); - clock.BindMethod("Restart", &Nz::Clock::Restart); - clock.BindMethod("Unpause", &Nz::Clock::Unpause); - - // Manual - clock.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream ss("Clock(Elapsed: "); - ss << instance.GetSeconds(); - ss << "s, Paused: "; - ss << instance.IsPaused(); - ss << ')'; - - lua.PushString(ss); - return 1; - }); - } - - /*********************************** Nz::File ***********************************/ - file.Reset("File"); - { - file.Inherit(stream); - - file.SetConstructor([] (Nz::LuaState& lua, Nz::File* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 1U); - - int argIndex = 2; - switch (argCount) - { - case 0: - Nz::PlacementNew(instance); - return true; - - case 1: - { - std::string filePath = lua.Check(&argIndex); - - Nz::PlacementNew(instance, filePath); - return true; - } - - case 2: - { - std::string filePath = lua.Check(&argIndex); - Nz::UInt32 openMode = lua.Check(&argIndex); - - Nz::PlacementNew(instance, filePath, openMode); - return true; - } - } - - lua.Error("No matching overload for File constructor"); - return false; - }); - - file.BindMethod("Close", &Nz::File::Close); - file.BindMethod("Copy", &Nz::File::Copy); - file.BindMethod("Delete", &Nz::File::Delete); - file.BindMethod("EndOfFile", &Nz::File::EndOfFile); - file.BindMethod("Exists", &Nz::File::Exists); - file.BindMethod("GetFileName", &Nz::File::GetFileName); - file.BindMethod("IsOpen", &Nz::File::IsOpen); - - // Manual - file.BindMethod("Open", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 2U); - - int argIndex = 2; - switch (argCount) - { - case 0: - case 1: - return lua.Push(instance.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); - - case 2: - { - std::string filePath = lua.Check(&argIndex); - Nz::UInt32 openMode = lua.Check(&argIndex, Nz::OpenMode_NotOpen); - return lua.Push(instance.Open(filePath, openMode)); - } - } - - lua.Error("No matching overload for method Open"); - return 0; - }); - - file.BindMethod("SetCursorPos", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 2U); - - int argIndex = 2; - switch (argCount) - { - case 1: - return lua.Push(instance.SetCursorPos(lua.Check(&argIndex))); - - case 2: - { - Nz::CursorPosition curPos = lua.Check(&argIndex); - Nz::Int64 offset = lua.Check(&argIndex); - return lua.Push(instance.SetCursorPos(curPos, offset)); - } - } - - lua.Error("No matching overload for method SetCursorPos"); - return 0; - }); - - file.BindMethod("__tostring", [] (Nz::LuaState& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream ss("File("); - if (instance.IsOpen()) - ss << "Path: " << instance.GetPath().generic_u8string(); - - ss << ')'; - - lua.PushString(ss); - return 1; - }); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Core classes - */ - void LuaBinding_Core::Register(Nz::LuaState& state) - { - // Classes - clock.Register(state); - file.Register(state); - stream.Register(state); - - // Enums - - // Nz::CursorPosition - static_assert(Nz::CursorPosition_Max + 1 == 3, "Nz::CursorPosition has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 3); - { - state.PushField("AtBegin", Nz::CursorPosition_AtBegin); - state.PushField("AtCurrent", Nz::CursorPosition_AtCurrent); - state.PushField("AtEnd", Nz::CursorPosition_AtEnd); - } - state.SetGlobal("CursorPosition"); - - // Nz::HashType - static_assert(Nz::HashType_Max + 1 == 10, "Nz::HashType has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 10); - { - state.PushField("CRC32", Nz::HashType_CRC32); - state.PushField("CRC64", Nz::HashType_CRC64); - state.PushField("Fletcher16", Nz::HashType_Fletcher16); - state.PushField("MD5", Nz::HashType_MD5); - state.PushField("SHA1", Nz::HashType_SHA1); - state.PushField("SHA224", Nz::HashType_SHA224); - state.PushField("SHA256", Nz::HashType_SHA256); - state.PushField("SHA384", Nz::HashType_SHA384); - state.PushField("SHA512", Nz::HashType_SHA512); - state.PushField("Whirlpool", Nz::HashType_Whirlpool); - } - state.SetGlobal("HashType"); - - // Nz::OpenMode - static_assert(Nz::OpenMode_Max + 1 == 8, "Nz::OpenModeFlags has been updated but change was not reflected to Lua binding"); - state.PushTable(0, Nz::OpenMode_Max + 1); - { - state.PushField("Append", Nz::OpenMode_Append); - state.PushField("NotOpen", Nz::OpenMode_NotOpen); - state.PushField("Lock", Nz::OpenMode_Lock); - state.PushField("ReadOnly", Nz::OpenMode_ReadOnly); - state.PushField("ReadWrite", Nz::OpenMode_ReadWrite); - state.PushField("Text", Nz::OpenMode_Text); - state.PushField("Truncate", Nz::OpenMode_Truncate); - state.PushField("WriteOnly", Nz::OpenMode_WriteOnly); - } - state.SetGlobal("OpenMode"); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp b/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp deleted file mode 100644 index 5ed660089..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Graphics.cpp +++ /dev/null @@ -1,498 +0,0 @@ -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindGraphics(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Graphics::LuaBinding_Graphics(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::AbstractViewer ***********************************/ - abstractViewer.Reset("AbstractViewer"); - { - abstractViewer.BindMethod("GetAspectRatio", &Nz::AbstractViewer::GetAspectRatio); - abstractViewer.BindMethod("GetEyePosition", &Nz::AbstractViewer::GetEyePosition); - abstractViewer.BindMethod("GetForward", &Nz::AbstractViewer::GetForward); - //abstractViewer.BindMethod("GetFrustum", &Nz::AbstractViewer::GetFrustum); - abstractViewer.BindMethod("GetProjectionMatrix", &Nz::AbstractViewer::GetProjectionMatrix); - //abstractViewer.BindMethod("GetTarget", &Nz::AbstractViewer::GetTarget); - abstractViewer.BindMethod("GetViewMatrix", &Nz::AbstractViewer::GetViewMatrix); - abstractViewer.BindMethod("GetViewport", &Nz::AbstractViewer::GetViewport); - abstractViewer.BindMethod("GetZFar", &Nz::AbstractViewer::GetZFar); - abstractViewer.BindMethod("GetZNear", &Nz::AbstractViewer::GetZNear); - } - - /*********************************** Nz::InstancedRenderable ***********************************/ - instancedRenderable.Reset("InstancedRenderable"); - { - instancedRenderable.BindMethod("GetMaterial", [] (Nz::LuaState& lua, Nz::InstancedRenderable* instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 2U); - switch (argCount) - { - case 0: - case 1: - { - int argIndex = 2; - std::size_t matIndex(lua.Check(&argIndex, 0)); - - return lua.Push(instance->GetMaterial(matIndex)); - } - - case 2: - { - int argIndex = 2; - std::size_t skinIndex(lua.Check(&argIndex)); - std::size_t matIndex(lua.Check(&argIndex)); - - return lua.Push(instance->GetMaterial(skinIndex, matIndex)); - } - } - - lua.Error("No matching overload for method GetMaterial"); - return 0; - }); - - instancedRenderable.BindMethod("GetMaterialCount", &Nz::InstancedRenderable::GetMaterialCount); - instancedRenderable.BindMethod("GetSkin", &Nz::InstancedRenderable::GetSkin); - instancedRenderable.BindMethod("GetSkinCount", &Nz::InstancedRenderable::GetSkinCount); - - instancedRenderable.BindMethod("SetSkin", &Nz::InstancedRenderable::SetSkin); - instancedRenderable.BindMethod("SetSkinCount", &Nz::InstancedRenderable::SetSkinCount); - } - - /*********************************** Nz::Material ***********************************/ - material.Reset("Material"); - { - material.SetConstructor([] (Nz::LuaState& lua, Nz::MaterialRef* instance, std::size_t argumentCount) - { - switch (argumentCount) - { - case 0: - Nz::PlacementNew(instance, Nz::Material::New()); - return true; - - case 1: - { - int argIndex = 1; - if (lua.IsOfType(argIndex, "MaterialPipeline")) - { - Nz::PlacementNew(instance, Nz::Material::New(*static_cast(lua.ToUserdata(argIndex)))); - return true; - } - else if (lua.IsOfType(argIndex, "Material")) - { - Nz::PlacementNew(instance, Nz::Material::New(**static_cast(lua.ToUserdata(argIndex)))); - return true; - } - else - { - Nz::PlacementNew(instance, Nz::Material::New(lua.Check(&argIndex))); - return true; - } - } - } - - lua.Error("No matching overload for constructor"); - return false; - }); - - material.BindMethod("Configure", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "MaterialPipeline")) - { - instance->Configure(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - { - lua.Push(instance->Configure(lua.Check(&argIndex))); - return 1; - } - }); - - material.BindMethod("EnableAlphaTest", &Nz::Material::EnableAlphaTest); - material.BindMethod("EnableBlending", &Nz::Material::EnableBlending); - material.BindMethod("EnableColorWrite", &Nz::Material::EnableColorWrite); - material.BindMethod("EnableDepthBuffer", &Nz::Material::EnableDepthBuffer); - material.BindMethod("EnableDepthSorting", &Nz::Material::EnableDepthSorting); - material.BindMethod("EnableDepthWrite", &Nz::Material::EnableDepthWrite); - material.BindMethod("EnableFaceCulling", &Nz::Material::EnableFaceCulling); - material.BindMethod("EnableReflectionMapping", &Nz::Material::EnableReflectionMapping); - material.BindMethod("EnableScissorTest", &Nz::Material::EnableScissorTest); - material.BindMethod("EnableShadowCasting", &Nz::Material::EnableShadowCasting); - material.BindMethod("EnableShadowReceive", &Nz::Material::EnableShadowReceive); - material.BindMethod("EnableStencilTest", &Nz::Material::EnableStencilTest); - - material.BindMethod("EnsurePipelineUpdate", &Nz::Material::EnsurePipelineUpdate); - - material.BindMethod("GetAlphaMap", &Nz::Material::GetAlphaMap); - material.BindMethod("GetAlphaThreshold", &Nz::Material::GetAlphaThreshold); - material.BindMethod("GetAmbientColor", &Nz::Material::GetAmbientColor); - material.BindMethod("GetDepthFunc", &Nz::Material::GetDepthFunc); - material.BindMethod("GetDepthMaterial", &Nz::Material::GetDepthMaterial); - material.BindMethod("GetDiffuseColor", &Nz::Material::GetDiffuseColor); - material.BindMethod("GetDiffuseMap", &Nz::Material::GetDiffuseMap); - //material.BindMethod("GetDiffuseSampler", &Nz::Material::GetDiffuseSampler); - material.BindMethod("GetDstBlend", &Nz::Material::GetDstBlend); - material.BindMethod("GetEmissiveMap", &Nz::Material::GetEmissiveMap); - material.BindMethod("GetFaceCulling", &Nz::Material::GetFaceCulling); - material.BindMethod("GetFaceFilling", &Nz::Material::GetFaceFilling); - material.BindMethod("GetHeightMap", &Nz::Material::GetHeightMap); - material.BindMethod("GetLineWidth", &Nz::Material::GetLineWidth); - material.BindMethod("GetNormalMap", &Nz::Material::GetNormalMap); - //material.BindMethod("GetPipeline", &Nz::Material::GetPipeline); - //material.BindMethod("GetPipelineInfo", &Nz::Material::GetPipelineInfo); - material.BindMethod("GetPointSize", &Nz::Material::GetPointSize); - material.BindMethod("GetReflectionMode", &Nz::Material::GetReflectionMode); - //material.BindMethod("GetShader", &Nz::Material::GetShader); - material.BindMethod("GetShininess", &Nz::Material::GetShininess); - material.BindMethod("GetSpecularColor", &Nz::Material::GetSpecularColor); - material.BindMethod("GetSpecularMap", &Nz::Material::GetSpecularMap); - //material.BindMethod("GetSpecularSampler", &Nz::Material::GetSpecularSampler); - material.BindMethod("GetSrcBlend", &Nz::Material::GetSrcBlend); - - material.BindMethod("HasAlphaMap", &Nz::Material::HasAlphaMap); - material.BindMethod("HasDepthMaterial", &Nz::Material::HasDepthMaterial); - material.BindMethod("HasDiffuseMap", &Nz::Material::HasDiffuseMap); - material.BindMethod("HasEmissiveMap", &Nz::Material::HasEmissiveMap); - material.BindMethod("HasHeightMap", &Nz::Material::HasHeightMap); - material.BindMethod("HasNormalMap", &Nz::Material::HasNormalMap); - material.BindMethod("HasSpecularMap", &Nz::Material::HasSpecularMap); - - material.BindMethod("IsAlphaTestEnabled", &Nz::Material::IsAlphaTestEnabled); - material.BindMethod("IsBlendingEnabled", &Nz::Material::IsBlendingEnabled); - material.BindMethod("IsColorWriteEnabled", &Nz::Material::IsColorWriteEnabled); - material.BindMethod("IsDepthBufferEnabled", &Nz::Material::IsDepthBufferEnabled); - material.BindMethod("IsDepthSortingEnabled", &Nz::Material::IsDepthSortingEnabled); - material.BindMethod("IsDepthWriteEnabled", &Nz::Material::IsDepthWriteEnabled); - material.BindMethod("IsFaceCullingEnabled", &Nz::Material::IsFaceCullingEnabled); - material.BindMethod("IsReflectionMappingEnabled", &Nz::Material::IsReflectionMappingEnabled); - material.BindMethod("IsScissorTestEnabled", &Nz::Material::IsScissorTestEnabled); - material.BindMethod("IsStencilTestEnabled", &Nz::Material::IsStencilTestEnabled); - material.BindMethod("IsShadowCastingEnabled", &Nz::Material::IsShadowCastingEnabled); - material.BindMethod("IsShadowReceiveEnabled", &Nz::Material::IsShadowReceiveEnabled); - - material.BindMethod("Reset", &Nz::Material::Reset); - - material.BindMethod("SetAlphaThreshold", &Nz::Material::SetAlphaThreshold); - material.BindMethod("SetAmbientColor", &Nz::Material::SetAmbientColor); - material.BindMethod("SetDepthFunc", &Nz::Material::SetDepthFunc); - material.BindMethod("SetDepthFunc", &Nz::Material::SetDepthFunc); - material.BindMethod("SetDepthMaterial", &Nz::Material::SetDepthMaterial); - material.BindMethod("SetDiffuseColor", &Nz::Material::SetDiffuseColor); - //material.BindMethod("SetDiffuseSampler", &Nz::Material::SetDiffuseSampler); - material.BindMethod("SetDstBlend", &Nz::Material::SetDstBlend); - material.BindMethod("SetFaceCulling", &Nz::Material::SetFaceCulling); - material.BindMethod("SetFaceFilling", &Nz::Material::SetFaceFilling); - material.BindMethod("SetLineWidth", &Nz::Material::SetLineWidth); - material.BindMethod("SetPointSize", &Nz::Material::SetPointSize); - material.BindMethod("SetReflectionMode", &Nz::Material::SetReflectionMode); - material.BindMethod("SetShininess", &Nz::Material::SetShininess); - material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor); - material.BindMethod("SetSpecularColor", &Nz::Material::SetSpecularColor); - //material.BindMethod("SetSpecularSampler", &Nz::Material::SetSpecularSampler); - material.BindMethod("SetSrcBlend", &Nz::Material::SetSrcBlend); - - material.BindStaticMethod("GetDefault", &Nz::Material::GetDefault); - material.BindStaticMethod("LoadFromFile", &Nz::Material::LoadFromFile, Nz::MaterialParams()); - - material.BindMethod("SetAlphaMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - instance->SetAlphaMap(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetAlphaMap(lua.Check(&argIndex))); - }); - - material.BindMethod("SetDiffuseMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - instance->SetDiffuseMap(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetDiffuseMap(lua.Check(&argIndex))); - }); - - material.BindMethod("SetEmissiveMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - instance->SetEmissiveMap(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetEmissiveMap(lua.Check(&argIndex))); - }); - - material.BindMethod("SetHeightMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - instance->SetHeightMap(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetHeightMap(lua.Check(&argIndex))); - }); - - material.BindMethod("SetNormalMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - instance->SetNormalMap(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetNormalMap(lua.Check(&argIndex))); - }); - - material.BindMethod("SetShader", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "UberShader")) - { - instance->SetShader(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetShader(lua.Check(&argIndex))); - }); - - material.BindMethod("SetSpecularMap", [] (Nz::LuaState& lua, Nz::MaterialRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - instance->SetSpecularMap(*static_cast(lua.ToUserdata(argIndex))); - return 0; - } - else - return lua.Push(instance->SetSpecularMap(lua.Check(&argIndex))); - }); - } - - /*********************************** Nz::Model ***********************************/ - model.Reset("Model"); - { - model.Inherit(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef* - { - return reinterpret_cast(modelRef); //TODO: Make a ObjectRefCast - }); - - model.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/) - { - Nz::PlacementNew(instance, Nz::Model::New()); - return true; - }); - - //modelClass.SetMethod("GetMesh", &Nz::Model::GetMesh); - - model.BindMethod("IsAnimated", &Nz::Model::IsAnimated); - - model.BindMethod("SetMaterial", [] (Nz::LuaState& lua, Nz::Model* instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 3U); - switch (argCount) - { - case 2: - { - int argIndex = 2; - if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - { - std::size_t matIndex(lua.Check(&argIndex)); - Nz::MaterialRef mat(lua.Check(&argIndex)); - - instance->SetMaterial(matIndex, std::move(mat)); - return 0; - } - else if (lua.IsOfType(argIndex, Nz::LuaType_String)) - { - std::string subMesh(lua.Check(&argIndex)); - Nz::MaterialRef mat(lua.Check(&argIndex)); - - instance->SetMaterial(subMesh, std::move(mat)); - return 0; - } - - break; - } - - case 3: - { - int argIndex = 2; - if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - { - std::size_t skinIndex(lua.Check(&argIndex)); - std::size_t matIndex(lua.Check(&argIndex)); - Nz::MaterialRef mat(lua.Check(&argIndex)); - - instance->SetMaterial(skinIndex, matIndex, std::move(mat)); - return 0; - } - else if (lua.IsOfType(argIndex, Nz::LuaType_String)) - { - std::size_t skinIndex(lua.Check(&argIndex)); - std::string subMesh(lua.Check(&argIndex)); - Nz::MaterialRef materialRef(lua.Check(&argIndex)); - - instance->SetMaterial(skinIndex, subMesh, std::move(materialRef)); - return 0; - } - - break; - } - } - - lua.Error("No matching overload for method SetMaterial"); - return 0; - }); - - //modelClass.SetMethod("SetMesh", &Nz::Model::SetMesh); - //modelClass.SetMethod("SetSequence", &Nz::Model::SetSequence); - - model.BindStaticMethod("LoadFromFile", &Nz::Model::LoadFromFile, Nz::ModelParameters()); - } - - /*********************************** Nz::Sprite ***********************************/ - sprite.Reset("Sprite"); - { - sprite.Inherit(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef* - { - return reinterpret_cast(spriteRef); //TODO: Make a ObjectRefCast - }); - - sprite.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/) - { - Nz::PlacementNew(instance, Nz::Sprite::New()); - return true; - }); - - sprite.BindMethod("GetColor", &Nz::Sprite::GetColor); - sprite.BindMethod("GetCornerColor", &Nz::Sprite::GetCornerColor); - sprite.BindMethod("GetOrigin", &Nz::Sprite::GetOrigin); - sprite.BindMethod("GetSize", &Nz::Sprite::GetSize); - sprite.BindMethod("GetTextureCoords", &Nz::Sprite::GetTextureCoords); - - sprite.BindMethod("SetColor", &Nz::Sprite::SetColor); - sprite.BindMethod("SetCornerColor", &Nz::Sprite::SetCornerColor); - sprite.BindMethod("SetDefaultMaterial", &Nz::Sprite::SetDefaultMaterial); - sprite.BindMethod("SetOrigin", &Nz::Sprite::SetOrigin); - sprite.BindMethod("SetSize", (void(Nz::Sprite::*)(const Nz::Vector2f&)) &Nz::Sprite::SetSize); - sprite.BindMethod("SetTextureCoords", &Nz::Sprite::SetTextureCoords); - sprite.BindMethod("SetTextureRect", &Nz::Sprite::SetTextureRect); - - sprite.BindMethod("SetMaterial", [] (Nz::LuaState& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Material")) - { - bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); - - instance->SetMaterial(*static_cast(lua.ToUserdata(argIndex)), resizeSprite); - } - else if (lua.IsOfType(argIndex, Nz::LuaType_String)) - { - bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); - - instance->SetMaterial(lua.ToString(argIndex), resizeSprite); - } - else if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - { - std::size_t skinIndex(lua.Check(&argIndex)); - bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); - - if (lua.IsOfType(argIndex, "Material")) - instance->SetMaterial(skinIndex, *static_cast(lua.ToUserdata(argIndex)), resizeSprite); - else - instance->SetMaterial(skinIndex, lua.Check(&argIndex), resizeSprite); - } - - return 0; - }); - - sprite.BindMethod("SetTexture", [] (Nz::LuaState& lua, Nz::SpriteRef& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Texture")) - { - bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); - - instance->SetTexture(*static_cast(lua.ToUserdata(argIndex)), resizeSprite); - } - else if (lua.IsOfType(argIndex, Nz::LuaType_String)) - { - bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); - - instance->SetTexture(lua.ToString(argIndex), resizeSprite); - } - else if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - { - std::size_t skinIndex(lua.Check(&argIndex)); - bool resizeSprite = lua.CheckBoolean(argIndex + 1, true); - - if (lua.IsOfType(argIndex, "Texture")) - instance->SetTexture(skinIndex, *static_cast(lua.ToUserdata(argIndex)), resizeSprite); - else - instance->SetTexture(skinIndex, lua.Check(&argIndex), resizeSprite); - } - - return 0; - }); - } - - /*********************************** Nz::SpriteLibrary ***********************************/ - spriteLibrary.Reset("SpriteLibrary"); - { - spriteLibrary.BindStaticMethod("Get", &Nz::SpriteLibrary::Get); - spriteLibrary.BindStaticMethod("Has", &Nz::SpriteLibrary::Has); - spriteLibrary.BindStaticMethod("Register", &Nz::SpriteLibrary::Register); - spriteLibrary.BindStaticMethod("Query", &Nz::SpriteLibrary::Query); - spriteLibrary.BindStaticMethod("Unregister", &Nz::SpriteLibrary::Unregister); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Graphics classes - */ - - void LuaBinding_Graphics::Register(Nz::LuaState& state) - { - abstractViewer.Register(state); - instancedRenderable.Register(state); - material.Register(state); - model.Register(state); - sprite.Register(state); - spriteLibrary.Register(state); - - // Nz::ReflectionMode - static_assert(Nz::ReflectionMode_Max + 1 == 3, "Nz::ReflectionMode has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 3); - { - state.PushField("Probe", Nz::ReflectionMode_Probe); - state.PushField("RealTime", Nz::ReflectionMode_RealTime); - state.PushField("Skybox", Nz::ReflectionMode_Skybox); - } - state.SetGlobal("ReflectionMode"); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Math.cpp b/SDK/src/NDK/Lua/LuaBinding_Math.cpp deleted file mode 100644 index 15deebfab..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Math.cpp +++ /dev/null @@ -1,986 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include -#include -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindMath(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Math::LuaBinding_Math(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::EulerAngles **********************************/ - eulerAngles.Reset("EulerAngles"); - { - eulerAngles.SetConstructor([] (Nz::LuaState& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 3U); - - switch (argCount) - { - case 0: - Nz::PlacementNew(instance, Nz::EulerAnglesd::Zero()); - return true; - - case 1: - Nz::PlacementNew(instance, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); - return true; - - case 3: - Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); - return true; - } - - lua.Error("No matching overload for EulerAngles constructor"); - return false; - }); - - eulerAngles.BindMethod("Normalize", &Nz::EulerAnglesd::Normalize); - eulerAngles.BindMethod("ToQuaternion", &Nz::EulerAnglesd::ToQuaternion); - - eulerAngles.BindMethod("__tostring", &Nz::EulerAnglesd::ToString); - - eulerAngles.SetGetter([] (Nz::LuaState& lua, Nz::EulerAnglesd& instance) - { - std::size_t length; - const char* ypr = lua.CheckString(2, &length); - - switch (length) - { - case 1: - { - switch (ypr[0]) - { - case 'p': - lua.Push(instance.pitch); - return true; - - case 'y': - lua.Push(instance.yaw); - return true; - - case 'r': - lua.Push(instance.roll); - return true; - } - break; - } - - case 3: - { - if (std::memcmp(ypr, "yaw", 3) != 0) - break; - - lua.Push(instance.yaw); - return true; - } - - case 4: - { - if (std::memcmp(ypr, "roll", 4) != 0) - break; - - lua.Push(instance.roll); - return true; - } - - case 5: - { - if (std::memcmp(ypr, "pitch", 5) != 0) - break; - - lua.Push(instance.pitch); - return true; - } - } - - return false; - }); - - eulerAngles.SetSetter([] (Nz::LuaState& lua, Nz::EulerAnglesd& instance) - { - std::size_t length; - const char* ypr = lua.CheckString(2, &length); - double value = lua.CheckNumber(3); - - switch (length) - { - case 1: - { - switch (ypr[0]) - { - case 'p': - instance.pitch = value; - return true; - - case 'y': - instance.yaw = value; - return true; - - case 'r': - instance.roll = value; - return true; - } - break; - } - - case 3: - { - if (std::memcmp(ypr, "yaw", 3) != 0) - break; - - instance.yaw = value; - return true; - } - - case 4: - { - if (std::memcmp(ypr, "roll", 4) != 0) - break; - - instance.roll = value; - return true; - } - - case 5: - { - if (std::memcmp(ypr, "pitch", 5) != 0) - break; - - instance.pitch = value; - return true; - } - } - - return false; - }); - } - - /*********************************** Nz::Matrix4 **********************************/ - matrix4d.Reset("Matrix4"); - { - matrix4d.SetConstructor([] (Nz::LuaState& lua, Nz::Matrix4d* matrix, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 3U); - - switch (argCount) - { - case 0: - Nz::PlacementNew(matrix, Nz::Matrix4d::Zero()); - return true; - - case 1: - if (lua.IsOfType(1, "Matrix4")) - Nz::PlacementNew(matrix, *static_cast(lua.ToUserdata(1))); - break; - - case 16: - { - double values[16]; - for (int i = 0; i < 16; ++i) - values[i] = lua.CheckNumber(i); - - Nz::PlacementNew(matrix, values); - - return true; - } - } - - lua.Error("No matching overload for constructor"); - return false; - }); - - matrix4d.BindMethod("ApplyRotation", &Nz::Matrix4d::ApplyRotation); - matrix4d.BindMethod("ApplyScale", &Nz::Matrix4d::ApplyScale); - matrix4d.BindMethod("ApplyTranslation", &Nz::Matrix4d::ApplyTranslation); - - matrix4d.BindMethod("Concatenate", &Nz::Matrix4d::Concatenate); - matrix4d.BindMethod("ConcatenateAffine", &Nz::Matrix4d::ConcatenateAffine); - - //matrix4d.BindMethod("GetColumn", &Nz::Matrix4d::GetColumn); - matrix4d.BindMethod("GetDeterminant", &Nz::Matrix4d::GetDeterminant); - matrix4d.BindMethod("GetDeterminantAffine", &Nz::Matrix4d::GetDeterminantAffine); - - matrix4d.BindMethod("GetInverse", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - Nz::Matrix4d result; - if (instance.GetInverse(&result)) - return lua.Push(true, result); - else - return lua.Push(false); - }); - - matrix4d.BindMethod("GetInverseAffine", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - Nz::Matrix4d result; - if (instance.GetInverseAffine(&result)) - return lua.Push(true, result); - else - return lua.Push(false); - }); - - matrix4d.BindMethod("GetRotation", &Nz::Matrix4d::GetRotation); - - //matrix4d.BindMethod("GetRow", &Nz::Matrix4d::GetRow); - matrix4d.BindMethod("GetScale", &Nz::Matrix4d::GetScale); - matrix4d.BindMethod("GetSquaredScale", &Nz::Matrix4d::GetSquaredScale); - matrix4d.BindMethod("GetTranslation", &Nz::Matrix4d::GetTranslation); - - matrix4d.BindMethod("GetTransposed", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - Nz::Matrix4d result; - instance.GetTransposed(&result); - - return lua.Push(result); - }); - - matrix4d.BindMethod("HasNegativeScale", &Nz::Matrix4d::HasNegativeScale); - matrix4d.BindMethod("HasScale", &Nz::Matrix4d::HasScale); - - matrix4d.BindMethod("Inverse", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - bool succeeded; - instance.Inverse(&succeeded); - - return lua.Push(succeeded); - }); - - matrix4d.BindMethod("InverseAffine", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - bool succeeded; - instance.InverseAffine(&succeeded); - - return lua.Push(succeeded); - }); - - matrix4d.BindMethod("IsAffine", &Nz::Matrix4d::IsAffine); - matrix4d.BindMethod("IsIdentity", &Nz::Matrix4d::IsIdentity); - - matrix4d.BindMethod("MakeIdentity", &Nz::Matrix4d::MakeIdentity); - matrix4d.BindMethod("MakeLookAt", &Nz::Matrix4d::MakeLookAt, Nz::Vector3d::Up()); - matrix4d.BindMethod("MakeOrtho", &Nz::Matrix4d::MakeOrtho, -1.0, 1.0); - matrix4d.BindMethod("MakePerspective", &Nz::Matrix4d::MakePerspective); - matrix4d.BindMethod("MakeRotation", &Nz::Matrix4d::MakeRotation); - matrix4d.BindMethod("MakeScale", &Nz::Matrix4d::MakeScale); - matrix4d.BindMethod("MakeTranslation", &Nz::Matrix4d::MakeTranslation); - matrix4d.BindMethod("MakeTransform", (Nz::Matrix4d&(Nz::Matrix4d::*)(const Nz::Vector3d&, const Nz::Quaterniond&, const Nz::Vector3d&)) &Nz::Matrix4d::MakeTransform, Nz::Vector3d::Unit()); - matrix4d.BindMethod("MakeViewMatrix", &Nz::Matrix4d::MakeViewMatrix); - matrix4d.BindMethod("MakeZero", &Nz::Matrix4d::MakeZero); - - matrix4d.BindMethod("Set", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 3U); - - int argIndex = 2; - switch (argCount) - { - case 1: - if (lua.IsOfType(argIndex, "Matrix4")) - instance = *static_cast(lua.ToUserdata(argIndex)); - break; - - case 16: - { - double values[16]; - for (std::size_t i = 0; i < 16; ++i) - values[i] = lua.CheckNumber(argIndex++); - - instance = Nz::Matrix4d(values); - - return 0; - } - } - - lua.Error("No matching overload for method Set"); - return 0; - }); - - matrix4d.BindMethod("SetRotation", &Nz::Matrix4d::SetRotation); - matrix4d.BindMethod("SetScale", &Nz::Matrix4d::SetScale); - matrix4d.BindMethod("SetTranslation", &Nz::Matrix4d::SetTranslation); - - matrix4d.BindMethod("Transform", [] (Nz::LuaState& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "Vector2")) - { - double z(lua.CheckNumber(argIndex + 1, 0.0)); - double w(lua.CheckNumber(argIndex + 2, 1.0)); - - return lua.Push(instance.Transform(*static_cast(lua.ToUserdata(argIndex)), z, w)); - } - else if (lua.IsOfType(argIndex, "Vector3")) - { - double w(lua.CheckNumber(argIndex + 1, 1.0)); - - return lua.Push(instance.Transform(*static_cast(lua.ToUserdata(argIndex)), w)); - } - //else if (lua.IsOfType(2, "Vector4")) - // return lua.Push(instance.Transform(*static_cast(lua.ToUserdata(1)))); - - lua.Error("No matching overload for method Transform"); - return 0; - }); - - matrix4d.BindMethod("Transpose", &Nz::Matrix4d::Transpose); - - matrix4d.BindMethod("__tostring", &Nz::Matrix4d::ToString); - - matrix4d.BindStaticMethod("Concatenate", &Nz::Matrix4d::Concatenate); - matrix4d.BindStaticMethod("ConcatenateAffine", &Nz::Matrix4d::ConcatenateAffine); - matrix4d.BindStaticMethod("Identity", &Nz::Matrix4d::Identity); - matrix4d.BindStaticMethod("LookAt", &Nz::Matrix4d::LookAt, Nz::Vector3d::Up()); - matrix4d.BindStaticMethod("Ortho", &Nz::Matrix4d::Ortho, -1.0, 1.0); - matrix4d.BindStaticMethod("Perspective", &Nz::Matrix4d::Perspective); - matrix4d.BindStaticMethod("Rotate", &Nz::Matrix4d::Rotate); - matrix4d.BindStaticMethod("Scale", &Nz::Matrix4d::Scale); - matrix4d.BindStaticMethod("Translate", &Nz::Matrix4d::Translate); - matrix4d.BindStaticMethod("Transform", (Nz::Matrix4d(*)(const Nz::Vector3d&, const Nz::Quaterniond&, const Nz::Vector3d&)) &Nz::Matrix4d::Transform, Nz::Vector3d::Unit()); - matrix4d.BindStaticMethod("ViewMatrix", &Nz::Matrix4d::ViewMatrix); - matrix4d.BindStaticMethod("Zero", &Nz::Matrix4d::Zero); - - matrix4d.SetGetter([] (Nz::LuaState& lua, Nz::Matrix4d& instance) - { - bool succeeded = false; - std::size_t index = static_cast(lua.ToInteger(2, &succeeded)); - if (!succeeded || index < 1 || index > 16) - return false; - - lua.Push(instance[index - 1]); - return true; - }); - - matrix4d.SetSetter([] (Nz::LuaState& lua, Nz::Matrix4d& instance) - { - bool succeeded = false; - std::size_t index = static_cast(lua.ToInteger(2, &succeeded)); - if (!succeeded || index < 1 || index > 16) - return false; - - instance[index - 1] = lua.CheckNumber(3); - - return true; - }); - } - - /*********************************** Nz::Rect **********************************/ - rect.Reset("Rect"); - { - rect.SetConstructor([] (Nz::LuaState& lua, Nz::Rectd* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 4U); - - switch (argCount) - { - case 0: - case 4: - PlacementNew(instance, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0), lua.CheckNumber(4, 0.0)); - return true; - - case 1: - { - if (lua.IsOfType(1, "Rect")) - PlacementNew(instance, *static_cast(lua.ToUserdata(1))); - else if (lua.IsOfType(1, Nz::LuaType_Table)) - { - // TODO => Faire sans avoir à mettre de nom dans la table et prendre les éléments un à un pour créer le Rectd - PlacementNew(instance, lua.CheckField("x", 1), - lua.CheckField("y", 1), - lua.CheckField("width", 1), - lua.CheckField("height", 1)); - } - else if (lua.IsOfType(1, "Vector2")) - PlacementNew(instance, *static_cast(lua.ToUserdata(1))); - else - break; - - return true; - } - - case 2: - { - if (lua.IsOfType(1, Nz::LuaType_Number) && lua.IsOfType(2, Nz::LuaType_Number)) - PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2)); - else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2")) - PlacementNew(instance, *static_cast(lua.ToUserdata(1)), *static_cast(lua.ToUserdata(2))); - else - break; - - return true; - } - } - - lua.Error("No matching overload for Rect constructor"); - return false; - }); - - rect.BindMethod("__tostring", &Nz::Rectd::ToString); - - rect.SetGetter([] (Nz::LuaState& lua, Nz::Rectd& instance) - { - switch (lua.GetType(2)) - { - case Nz::LuaType_Number: - { - auto index = lua.CheckBoundInteger(2); - if (index < 1 || index > 4) - return false; - - lua.Push(instance[index - 1]); - return true; - } - - case Nz::LuaType_String: - { - std::size_t length; - const char* xywh = lua.CheckString(2, &length); - - if (length != 1) - break; - - switch (xywh[0]) - { - case 'x': - lua.Push(instance.x); - return true; - - case 'y': - lua.Push(instance.y); - return true; - - case 'w': - lua.Push(instance.width); - return true; - - case 'h': - lua.Push(instance.height); - return true; - - default: - break; - } - break; - } - - default: - break; - } - - return false; - }); - - rect.SetSetter([] (Nz::LuaState& lua, Nz::Rectd& instance) - { - switch (lua.GetType(2)) - { - case Nz::LuaType_Number: - { - auto index = lua.CheckBoundInteger(2); - if (index < 1 || index > 4) - return false; - - instance[index - 1] = lua.CheckNumber(2); - return true; - } - - case Nz::LuaType_String: - { - std::size_t length; - const char* xywh = lua.CheckString(2, &length); - - if (length != 1) - break; - - double value = lua.CheckNumber(3); - - switch (xywh[0]) - { - case 'x': - instance.x = value; - return true; - - case 'y': - instance.y = value; - return true; - - case 'w': - instance.width = value; - return true; - - case 'h': - instance.height = value; - return true; - } - break; - } - - default: - break; - } - - return false; - }); - } - - /*********************************** Nz::Quaternion **********************************/ - quaternion.Reset("Quaternion"); - { - quaternion.SetConstructor([] (Nz::LuaState& lua, Nz::Quaterniond* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 4U); - - switch (argCount) - { - case 0: - Nz::PlacementNew(instance, Nz::Quaterniond::Zero()); - return true; - - case 1: - { - if (lua.IsOfType(1, "EulerAngles")) - Nz::PlacementNew(instance, *static_cast(lua.ToUserdata(1))); - else if (lua.IsOfType(1, "Quaternion")) - Nz::PlacementNew(instance, *static_cast(lua.ToUserdata(1))); - else - break; - - return true; - } - - case 2: - Nz::PlacementNew(instance, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); - return true; - - case 4: - Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); - return true; - - default: - break; - } - - lua.Error("No matching overload for Quaternion constructor"); - return false; - }); - - quaternion.BindMethod("ComputeW", &Nz::Quaterniond::ComputeW); - quaternion.BindMethod("Conjugate", &Nz::Quaterniond::Conjugate); - quaternion.BindMethod("DotProduct", &Nz::Quaterniond::DotProduct); - quaternion.BindMethod("GetConjugate", &Nz::Quaterniond::GetConjugate); - quaternion.BindMethod("GetInverse", &Nz::Quaterniond::GetInverse); - - quaternion.BindMethod("Inverse", &Nz::Quaterniond::Inverse); - quaternion.BindMethod("Magnitude", &Nz::Quaterniond::Magnitude); - - quaternion.BindMethod("SquaredMagnitude", &Nz::Quaterniond::SquaredMagnitude); - quaternion.BindMethod("ToEulerAngles", &Nz::Quaterniond::ToEulerAngles); - - quaternion.BindMethod("__tostring", &Nz::Quaterniond::ToString); - - quaternion.BindStaticMethod("Lerp", &Nz::Quaterniond::Lerp); - quaternion.BindStaticMethod("RotationBetween", &Nz::Quaterniond::RotationBetween); - quaternion.BindStaticMethod("Slerp", &Nz::Quaterniond::Slerp); - - quaternion.BindMethod("GetNormal", [] (Nz::LuaState& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int - { - double length; - - lua.Push(instance.GetNormal(&length)); - lua.Push(length); - - return 2; - }); - - quaternion.BindMethod("Normalize", [] (Nz::LuaState& lua, Nz::Quaterniond& instance, std::size_t /*argumentCount*/) -> int - { - double length; - - instance.Normalize(&length); - lua.Push(1); //< instance - lua.Push(length); - - return 2; - }); - - quaternion.BindStaticMethod("Normalize", [] (Nz::LuaState& state) -> int - { - int argIndex = 1; - Nz::Quaterniond quat = state.Check(&argIndex); - - double length; - - state.Push(Nz::Quaterniond::Normalize(quat, &length)); - state.Push(length); - - return 2; - }); - - quaternion.SetGetter([] (Nz::LuaState& lua, Nz::Quaterniond& instance) - { - std::size_t length; - const char* wxyz = lua.CheckString(2, &length); - - if (length != 1) - return false; - - switch (wxyz[0]) - { - case 'w': - lua.Push(instance.w); - return true; - - case 'x': - lua.Push(instance.x); - return true; - - case 'y': - lua.Push(instance.y); - return true; - - case 'z': - lua.Push(instance.z); - return true; - } - - return false; - }); - - quaternion.SetSetter([] (Nz::LuaState& lua, Nz::Quaterniond& instance) - { - std::size_t length; - const char* wxyz = lua.CheckString(2, &length); - - if (length != 1) - return false; - - double value = lua.CheckNumber(3); - - switch (wxyz[0]) - { - case 'w': - instance.w = value; - return true; - - case 'x': - instance.x = value; - return true; - - case 'y': - instance.y = value; - return true; - - case 'z': - instance.z = value; - return true; - - default: - break; - } - - return false; - }); - } - - /*********************************** Nz::Vector2 **********************************/ - vector2d.Reset("Vector2"); - { - vector2d.SetConstructor([] (Nz::LuaState& lua, Nz::Vector2d* vector, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 2U); - - switch (argCount) - { - case 0: - case 2: - Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0)); - return true; - - case 1: - { - if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1)); - else if (lua.IsOfType(1, "Vector2")) - Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); - else - break; - - return true; - } - } - - lua.Error("No matching overload for Vector2 constructor"); - return false; - }); - - vector2d.BindMethod("__tostring", &Nz::Vector2d::ToString); - - vector2d.SetGetter([] (Nz::LuaState& lua, Nz::Vector2d& instance) - { - switch (lua.GetType(2)) - { - case Nz::LuaType_Number: - { - long long index = lua.CheckInteger(2); - if (index < 1 || index > 2) - return false; - - lua.Push(instance[index - 1]); - return true; - } - - case Nz::LuaType_String: - { - std::size_t length; - const char* xy = lua.CheckString(2, &length); - - if (length != 1) - break; - - switch (xy[0]) - { - case 'x': - lua.Push(instance.x); - return true; - - case 'y': - lua.Push(instance.y); - return true; - - default: - break; - } - break; - } - - default: - break; - } - - return false; - }); - - vector2d.SetSetter([] (Nz::LuaState& lua, Nz::Vector2d& instance) - { - switch (lua.GetType(2)) - { - case Nz::LuaType_Number: - { - long long index = lua.CheckInteger(2); - if (index < 1 || index > 2) - return false; - - instance[index - 1] = lua.CheckNumber(3); - return true; - } - - case Nz::LuaType_String: - { - std::size_t length; - const char* xy = lua.CheckString(2, &length); - - if (length != 1) - break; - - double value = lua.CheckNumber(3); - - switch (xy[0]) - { - case 'x': - instance.x = value; - return true; - - case 'y': - instance.y = value; - return true; - - default: - break; - } - break; - } - - default: - break; - } - - return false; - }); - } - - /*********************************** Nz::Vector3 **********************************/ - vector3d.Reset("Vector3"); - { - vector3d.SetConstructor([] (Nz::LuaState& lua, Nz::Vector3d* vector, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 3U); - - switch (argCount) - { - case 0: - case 3: - Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0)); - return true; - - case 1: - { - if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1)); - else if (lua.IsOfType(1, "Vector2")) - Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); - else if (lua.IsOfType(1, "Vector3")) - Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); - else - break; - - return true; - } - - case 2: - { - if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector2"))); - else if (lua.IsOfType(1, "Vector2")) - Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1)), lua.CheckNumber(2)); - else - break; - - return true; - } - } - - lua.Error("No matching overload for constructor"); - return false; - }); - - vector3d.BindMethod("__tostring", &Nz::Vector3d::ToString); - - vector3d.SetGetter([] (Nz::LuaState& lua, Nz::Vector3d& instance) - { - switch (lua.GetType(2)) - { - case Nz::LuaType_Number: - { - long long index = lua.CheckInteger(2); - if (index < 1 || index > 3) - return false; - - lua.Push(instance[index - 1]); - return true; - } - - case Nz::LuaType_String: - { - std::size_t length; - const char* xyz = lua.CheckString(2, &length); - - if (length != 1) - break; - - switch (xyz[0]) - { - case 'x': - lua.Push(instance.x); - return true; - - case 'y': - lua.Push(instance.y); - return true; - - case 'z': - lua.Push(instance.z); - return true; - - default: - break; - } - break; - } - - default: - break; - } - - return false; - }); - - vector3d.SetSetter([] (Nz::LuaState& lua, Nz::Vector3d& instance) - { - switch (lua.GetType(2)) - { - case Nz::LuaType_Number: - { - long long index = lua.CheckInteger(2); - if (index < 1 || index > 3) - return false; - - instance[index - 1] = lua.CheckNumber(3); - return true; - } - - case Nz::LuaType_String: - { - std::size_t length; - const char* xyz = lua.CheckString(2, &length); - - if (length != 1) - break; - - double value = lua.CheckNumber(3); - - switch (xyz[0]) - { - case 'x': - instance.x = value; - return true; - - case 'y': - instance.y = value; - return true; - - case 'z': - instance.z = value; - return true; - - default: - break; - } - break; - } - - default: - break; - } - - return false; - }); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Math classes - */ - void LuaBinding_Math::Register(Nz::LuaState& state) - { - eulerAngles.Register(state); - matrix4d.Register(state); - quaternion.Register(state); - rect.Register(state); - vector2d.Register(state); - vector3d.Register(state); - - quaternion.PushGlobalTable(state); - { - state.PushField("Identity", Nz::Quaterniond::Identity()); - state.PushField("Zero", Nz::Quaterniond::Zero()); - } - state.Pop(); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Network.cpp b/SDK/src/NDK/Lua/LuaBinding_Network.cpp deleted file mode 100644 index f3f82264a..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Network.cpp +++ /dev/null @@ -1,314 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindNetwork(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Network::LuaBinding_Network(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::AbstractSocket **********************************/ - abstractSocket.Reset("AbstractSocket"); - { - abstractSocket.BindMethod("Close", &Nz::AbstractSocket::Close); - abstractSocket.BindMethod("EnableBlocking", &Nz::AbstractSocket::EnableBlocking); - abstractSocket.BindMethod("GetLastError", &Nz::AbstractSocket::GetLastError); - abstractSocket.BindMethod("GetState", &Nz::AbstractSocket::GetState); - abstractSocket.BindMethod("GetType", &Nz::AbstractSocket::GetType); - abstractSocket.BindMethod("IsBlockingEnabled", &Nz::AbstractSocket::IsBlockingEnabled); - abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes); - } - - /*********************************** Nz::IpAddress **********************************/ - ipAddress.Reset("IpAddress"); - { - ipAddress.SetConstructor([] (Nz::LuaState& lua, Nz::IpAddress* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 9U); - - int argIndex = 1; - switch (argCount) - { - case 0: - Nz::PlacementNew(instance); - return true; - - case 1: - Nz::PlacementNew(instance, lua.CheckString(argIndex)); - return true; - - case 4: - case 5: - { - Nz::UInt8 a = lua.Check(&argIndex); - Nz::UInt8 b = lua.Check(&argIndex); - Nz::UInt8 c = lua.Check(&argIndex); - Nz::UInt8 d = lua.Check(&argIndex); - Nz::UInt16 port = lua.Check(&argIndex, 0); - - Nz::PlacementNew(instance, a, b, c, d, port); - return true; - } - - case 8: - case 9: - { - Nz::UInt16 a = lua.Check(&argIndex); - Nz::UInt16 b = lua.Check(&argIndex); - Nz::UInt16 c = lua.Check(&argIndex); - Nz::UInt16 d = lua.Check(&argIndex); - Nz::UInt16 e = lua.Check(&argIndex); - Nz::UInt16 f = lua.Check(&argIndex); - Nz::UInt16 g = lua.Check(&argIndex); - Nz::UInt16 h = lua.Check(&argIndex); - Nz::UInt16 port = lua.Check(&argIndex, 0); - - Nz::PlacementNew(instance, a, b, c, d, e, f, g, h, port); - return true; - } - } - - lua.Error("No matching overload for constructor"); - return false; - }); - - ipAddress.BindMethod("GetPort", &Nz::IpAddress::GetPort); - ipAddress.BindMethod("GetProtocol", &Nz::IpAddress::GetProtocol); - ipAddress.BindMethod("IsLoopback", &Nz::IpAddress::IsLoopback); - ipAddress.BindMethod("IsValid", &Nz::IpAddress::IsValid); - ipAddress.BindMethod("ToUInt32", &Nz::IpAddress::ToUInt32); - ipAddress.BindMethod("__tostring", &Nz::IpAddress::ToString); - - ipAddress.BindStaticMethod("ResolveAddress", [] (Nz::LuaState& state) -> int - { - Nz::String service; - Nz::ResolveError error = Nz::ResolveError_Unknown; - - int argIndex = 2; - Nz::String hostName = Nz::IpAddress::ResolveAddress(state.Check(&argIndex), &service, &error); - - if (error == Nz::ResolveError_NoError) - { - state.Push(hostName); - state.Push(service); - return 2; - } - else - { - state.PushBoolean(false); - state.Push(error); - return 2; - } - }); - - ipAddress.BindStaticMethod("ResolveHostname", [] (Nz::LuaState& state) -> int - { - Nz::ResolveError error = Nz::ResolveError_Unknown; - - int argIndex = 2; - Nz::NetProtocol protocol = state.Check(&argIndex); - Nz::String hostname = state.Check(&argIndex); - Nz::String service = state.Check(&argIndex, "http"); - - std::vector addresses = Nz::IpAddress::ResolveHostname(protocol, hostname, service, &error); - if (error == Nz::ResolveError_NoError) - { - int index = 1; - state.PushTable(addresses.size()); - for (Nz::HostnameInfo& info : addresses) - { - state.PushInteger(index++); - state.PushTable(0, 4); - state.PushField("Address", std::move(info.address)); - state.PushField("CanonicalName", std::move(info.canonicalName)); - state.PushField("Protocol", std::move(info.protocol)); - state.PushField("SocketType", std::move(info.socketType)); - state.SetTable(); - } - - return 1; - } - else - { - state.PushBoolean(false); - state.Push(error); - return 2; - } - }); - } - - udpSocket.Reset("UdpSocket"); - { - udpSocket.Inherit(abstractSocket); - - udpSocket.BindDefaultConstructor(); - - udpSocket.BindMethod("Create", &Nz::UdpSocket::Create); - udpSocket.BindMethod("EnableBroadcasting", &Nz::UdpSocket::EnableBroadcasting); - udpSocket.BindMethod("GetBoundAddress", &Nz::UdpSocket::GetBoundAddress); - udpSocket.BindMethod("GetBoundPort", &Nz::UdpSocket::GetBoundPort); - udpSocket.BindMethod("IsBroadcastingEnabled", &Nz::UdpSocket::IsBroadcastingEnabled); - udpSocket.BindMethod("QueryMaxDatagramSize", &Nz::UdpSocket::QueryMaxDatagramSize); - - udpSocket.BindMethod("Bind", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - if (lua.IsOfType(argIndex, "IpAddress")) - return lua.Push(socket.Bind(*static_cast(lua.ToUserdata(argIndex)))); - else - return lua.Push(socket.Bind(lua.Check(&argIndex))); - }); - - udpSocket.BindMethod("Receive", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int - { - Nz::IpAddress from; - - std::array buffer; - std::size_t received; - if (socket.Receive(buffer.data(), buffer.size(), &from, &received)) - { - lua.PushBoolean(true); - lua.PushString(from.ToString()); - lua.PushString(buffer.data(), received); - return 3; - } - - lua.PushBoolean(false); - return 1; - }); - - udpSocket.BindMethod("Send", [](Nz::LuaState& lua, Nz::UdpSocket& socket, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - Nz::String to = lua.Check(&argIndex); - - std::size_t bufferLength; - const char* buffer = lua.CheckString(argIndex, &bufferLength); - - std::size_t sent; - bool ret; - if ((ret = socket.Send(Nz::IpAddress(to), buffer, bufferLength, &sent)) != true) - sent = 0; - - return lua.Push(std::make_pair(ret, sent)); - }); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Network classes - */ - void LuaBinding_Network::Register(Nz::LuaState& state) - { - // Classes - abstractSocket.Register(state); - ipAddress.Register(state); - udpSocket.Register(state); - - // Enums - - // Nz::NetProtocol - static_assert(Nz::NetProtocol_Max + 1 == 4, "Nz::NetProtocol has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 4); - { - state.PushField("Any", Nz::NetProtocol_Any); - state.PushField("IPv4", Nz::NetProtocol_IPv4); - state.PushField("IPv6", Nz::NetProtocol_IPv6); - state.PushField("Unknown", Nz::NetProtocol_Unknown); - } - state.SetGlobal("NetProtocol"); - - // Nz::PacketPriority - static_assert(Nz::PacketPriority_Max + 1 == 4, "Nz::PacketPriority has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 6); - { - state.PushField("High", Nz::PacketPriority_High); - state.PushField("Highest", Nz::PacketPriority_Highest); - state.PushField("Immediate", Nz::PacketPriority_Immediate); - state.PushField("Medium", Nz::PacketPriority_Medium); - state.PushField("Low", Nz::PacketPriority_Low); - state.PushField("Lowest", Nz::PacketPriority_Lowest); - } - state.SetGlobal("PacketPriority"); - - // Nz::PacketReliability - static_assert(Nz::PacketReliability_Max + 1 == 3, "Nz::PacketReliability has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 3); - { - state.PushField("Reliable", Nz::PacketReliability_Reliable); - state.PushField("ReliableOrdered", Nz::PacketReliability_ReliableOrdered); - state.PushField("Unreliable", Nz::PacketReliability_Unreliable); - } - state.SetGlobal("PacketReliability"); - - // Nz::ResolveError - static_assert(Nz::ResolveError_Max + 1 == 9, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 9); - { - state.PushField("Internal", Nz::ResolveError_Internal); - state.PushField("ResourceError", Nz::ResolveError_ResourceError); - state.PushField("NoError", Nz::ResolveError_NoError); - state.PushField("NonRecoverable", Nz::ResolveError_NonRecoverable); - state.PushField("NotFound", Nz::ResolveError_NotFound); - state.PushField("NotInitialized", Nz::ResolveError_NotInitialized); - state.PushField("ProtocolNotSupported", Nz::ResolveError_ProtocolNotSupported); - state.PushField("TemporaryFailure", Nz::ResolveError_TemporaryFailure); - state.PushField("Unknown", Nz::ResolveError_Unknown); - } - state.SetGlobal("ResolveError"); - - // Nz::SocketError - static_assert(Nz::SocketError_Max + 1 == 16, "Nz::SocketError has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 16); - { - state.PushField("AddressNotAvailable", Nz::SocketError_AddressNotAvailable); - state.PushField("ConnectionClosed", Nz::SocketError_ConnectionClosed); - state.PushField("ConnectionRefused", Nz::SocketError_ConnectionRefused); - state.PushField("DatagramSize", Nz::SocketError_DatagramSize); - state.PushField("Internal", Nz::SocketError_Internal); - state.PushField("Interrupted", Nz::SocketError_Interrupted); - state.PushField("Packet", Nz::SocketError_Packet); - state.PushField("NetworkError", Nz::SocketError_NetworkError); - state.PushField("NoError", Nz::SocketError_NoError); - state.PushField("NotInitialized", Nz::SocketError_NotInitialized); - state.PushField("NotSupported", Nz::SocketError_NotSupported); - state.PushField("ResolveError", Nz::SocketError_ResolveError); - state.PushField("ResourceError", Nz::SocketError_ResourceError); - state.PushField("TimedOut", Nz::SocketError_TimedOut); - state.PushField("Unknown", Nz::SocketError_Unknown); - state.PushField("UnreachableHost", Nz::SocketError_UnreachableHost); - } - state.SetGlobal("SocketError"); - - // Nz::SocketState - static_assert(Nz::SocketState_Max + 1 == 5, "Nz::SocketState has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 5); - { - state.PushField("Bound", Nz::SocketState_Bound); - state.PushField("Connecting", Nz::SocketState_Connecting); - state.PushField("Connected", Nz::SocketState_Connected); - state.PushField("NotConnected", Nz::SocketState_NotConnected); - state.PushField("Resolving", Nz::SocketState_Resolving); - } - state.SetGlobal("SocketState"); - - // Nz::SocketType - static_assert(Nz::SocketType_Max + 1 == 4, "Nz::SocketState has been updated but change was not reflected to Lua binding"); - state.PushTable(0, 4); - { - state.PushField("Raw", Nz::SocketType_Raw); - state.PushField("TCP", Nz::SocketType_TCP); - state.PushField("UDP", Nz::SocketType_UDP); - state.PushField("Unknown", Nz::SocketType_Unknown); - } - state.SetGlobal("SocketType"); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Platform.cpp b/SDK/src/NDK/Lua/LuaBinding_Platform.cpp deleted file mode 100644 index 2a2b02e7e..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Platform.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindPlatform(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Platform::LuaBinding_Platform(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::Keyboard **********************************/ - keyboard.Reset("Keyboard"); - { - keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName); - keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Utility classes - */ - void LuaBinding_Platform::Register(Nz::LuaState& state) - { - keyboard.Register(state); - - keyboard.PushGlobalTable(state); - { - static_assert(Nz::Keyboard::Count == 121, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding"); - - state.PushField("Undefined", Nz::Keyboard::Undefined); - - // A-Z - for (std::size_t i = 0; i < 26; ++i) - state.PushField(Nz::String('A' + char(i)), Nz::Keyboard::A + i); - - // Numerical - for (std::size_t i = 0; i < 10; ++i) - { - state.PushField("Num" + Nz::String::Number(i), Nz::Keyboard::Num0 + i); - state.PushField("Numpad" + Nz::String::Number(i), Nz::Keyboard::Numpad0 + i); - } - - // F1-F15 - for (std::size_t i = 0; i < 15; ++i) - state.PushField('F' + Nz::String::Number(i+1), Nz::Keyboard::F1 + i); - - // And all the others... - state.PushField("Down", Nz::Keyboard::Down); - state.PushField("Left", Nz::Keyboard::Left); - state.PushField("Right", Nz::Keyboard::Right); - state.PushField("Up", Nz::Keyboard::Up); - - state.PushField("Add", Nz::Keyboard::Add); - state.PushField("Decimal", Nz::Keyboard::Decimal); - state.PushField("Divide", Nz::Keyboard::Divide); - state.PushField("Multiply", Nz::Keyboard::Multiply); - state.PushField("Subtract", Nz::Keyboard::Subtract); - - state.PushField("Backslash", Nz::Keyboard::Backslash); - state.PushField("Backspace", Nz::Keyboard::Backspace); - state.PushField("Clear", Nz::Keyboard::Clear); - state.PushField("Comma", Nz::Keyboard::Comma); - state.PushField("Dash", Nz::Keyboard::Dash); - state.PushField("Delete", Nz::Keyboard::Delete); - state.PushField("End", Nz::Keyboard::End); - state.PushField("Equal", Nz::Keyboard::Equal); - state.PushField("Escape", Nz::Keyboard::Escape); - state.PushField("Home", Nz::Keyboard::Home); - state.PushField("Insert", Nz::Keyboard::Insert); - state.PushField("LAlt", Nz::Keyboard::LAlt); - state.PushField("LBracket", Nz::Keyboard::LBracket); - state.PushField("LControl", Nz::Keyboard::LControl); - state.PushField("LShift", Nz::Keyboard::LShift); - state.PushField("LSystem", Nz::Keyboard::LSystem); - state.PushField("PageDown", Nz::Keyboard::PageDown); - state.PushField("PageUp", Nz::Keyboard::PageUp); - state.PushField("Pause", Nz::Keyboard::Pause); - state.PushField("Period", Nz::Keyboard::Period); - state.PushField("Print", Nz::Keyboard::Print); - state.PushField("PrintScreen", Nz::Keyboard::PrintScreen); - state.PushField("Quote", Nz::Keyboard::Quote); - state.PushField("RAlt", Nz::Keyboard::RAlt); - state.PushField("RBracket", Nz::Keyboard::RBracket); - state.PushField("RControl", Nz::Keyboard::RControl); - state.PushField("Return", Nz::Keyboard::Return); - state.PushField("RShift", Nz::Keyboard::RShift); - state.PushField("RSystem", Nz::Keyboard::RSystem); - state.PushField("Semicolon", Nz::Keyboard::Semicolon); - state.PushField("Slash", Nz::Keyboard::Slash); - state.PushField("Space", Nz::Keyboard::Space); - state.PushField("Tab", Nz::Keyboard::Tab); - state.PushField("Tilde", Nz::Keyboard::Tilde); - state.PushField("Browser_Back", Nz::Keyboard::Browser_Back); - state.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites); - state.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward); - state.PushField("Browser_Home", Nz::Keyboard::Browser_Home); - state.PushField("Browser_Refresh", Nz::Keyboard::Browser_Refresh); - state.PushField("Browser_Search", Nz::Keyboard::Browser_Search); - state.PushField("Browser_Stop", Nz::Keyboard::Browser_Stop); - state.PushField("Media_Next", Nz::Keyboard::Media_Next); - state.PushField("Media_Play", Nz::Keyboard::Media_Play); - state.PushField("Media_Previous", Nz::Keyboard::Media_Previous); - state.PushField("Media_Stop", Nz::Keyboard::Media_Stop); - state.PushField("Volume_Down", Nz::Keyboard::Volume_Down); - state.PushField("Volume_Mute", Nz::Keyboard::Volume_Mute); - state.PushField("Volume_Up", Nz::Keyboard::Volume_Up); - state.PushField("CapsLock", Nz::Keyboard::CapsLock); - state.PushField("NumLock", Nz::Keyboard::NumLock); - state.PushField("ScrollLock", Nz::Keyboard::ScrollLock); - } - state.Pop(); - - static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding"); - state.PushTable(0, Nz::WindowStyle_Max + 1); - { - state.PushField("None", Nz::WindowStyle_None); - state.PushField("Fullscreen", Nz::WindowStyle_Fullscreen); - state.PushField("Closable", Nz::WindowStyle_Closable); - state.PushField("Resizable", Nz::WindowStyle_Resizable); - state.PushField("Titlebar", Nz::WindowStyle_Titlebar); - state.PushField("Threaded", Nz::WindowStyle_Threaded); - } - state.SetGlobal("WindowStyle"); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp b/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp deleted file mode 100644 index 8aacf2a1f..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Renderer.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#include -#include -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindRenderer(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Renderer::LuaBinding_Renderer(LuaBinding& binding) : - LuaBinding_Base(binding) - { - LuaBinding_Utility& utility = static_cast(*m_binding.utility); - - /*********************************** Nz::Texture ***********************************/ - texture.Reset("Texture"); - { - texture.Inherit(utility.abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef* - { - return reinterpret_cast(textureRef); //TODO: Make a ObjectRefCast - }); - - texture.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/) - { - Nz::PlacementNew(instance, Nz::Texture::New()); - return true; - }); - - texture.BindMethod("Create", &Nz::Texture::Create, static_cast(1), 1U); - texture.BindMethod("Destroy", &Nz::Texture::Destroy); - - //texture.BindMethod("Download", &Nz::Texture::Download); - - texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping); - texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate); - texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps); - texture.BindMethod("InvalidateMipmaps", &Nz::Texture::InvalidateMipmaps); - texture.BindMethod("IsValid", &Nz::Texture::IsValid); - - texture.BindMethod("LoadFaceFromFile", &Nz::Texture::LoadFaceFromFile, Nz::ImageParams()); - //bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams()); - //bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams()); - - texture.BindMethod("SaveToFile", &Nz::Texture::SaveToFile, Nz::ImageParams()); - //bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams()); - - texture.BindMethod("SetMipmapRange", &Nz::Texture::SetMipmapRange); - - texture.BindStaticMethod("IsFormatSupported", &Nz::Texture::IsFormatSupported); - texture.BindStaticMethod("IsMipmappingSupported", &Nz::Texture::IsMipmappingSupported); - texture.BindStaticMethod("IsTypeSupported", &Nz::Texture::IsTypeSupported); - - texture.BindStaticMethod("LoadFromFile", &Nz::Texture::LoadFromFile, true, Nz::ImageParams()); - //TextureRef LoadFromImage(const Image& image, bool generateMipmaps = true); - //TextureRef LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - //TextureRef LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - - texture.BindStaticMethod("LoadArrayFromFile", &Nz::Texture::LoadArrayFromFile, Nz::Vector2ui(2, 2), true, Nz::ImageParams()); - //TextureRef LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - //TextureRef LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - //TextureRef LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - - //TextureRef LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - //TextureRef LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams()); - //TextureRef LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - //TextureRef LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - } - - /*********************************** Nz::TextureLibrary ***********************************/ - textureLibrary.Reset("TextureLibrary"); - { - textureLibrary.BindStaticMethod("Get", &Nz::TextureLibrary::Get); - textureLibrary.BindStaticMethod("Has", &Nz::TextureLibrary::Has); - textureLibrary.BindStaticMethod("Register", &Nz::TextureLibrary::Register); - textureLibrary.BindStaticMethod("Query", &Nz::TextureLibrary::Query); - textureLibrary.BindStaticMethod("Unregister", &Nz::TextureLibrary::Unregister); - } - - /*********************************** Nz::TextureManager ***********************************/ - textureManager.Reset("TextureManager"); - { - textureManager.BindStaticMethod("Clear", &Nz::TextureManager::Clear); - textureManager.BindStaticMethod("Get", &Nz::TextureManager::Get); - textureManager.BindStaticMethod("GetDefaultParameters", &Nz::TextureManager::GetDefaultParameters); - textureManager.BindStaticMethod("Purge", &Nz::TextureManager::Purge); - textureManager.BindStaticMethod("Register", &Nz::TextureManager::Register); - textureManager.BindStaticMethod("SetDefaultParameters", &Nz::TextureManager::SetDefaultParameters); - textureManager.BindStaticMethod("Unregister", &Nz::TextureManager::Unregister); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Renderer classes - */ - void LuaBinding_Renderer::Register(Nz::LuaState& state) - { - texture.Register(state); - textureLibrary.Register(state); - textureManager.Register(state); - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp b/SDK/src/NDK/Lua/LuaBinding_SDK.cpp deleted file mode 100644 index 805f7742d..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_SDK.cpp +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq, Arnaud Cadot -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#include -#include -#include -#include - -#ifndef NDK_SERVER -#include -#endif - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindSDK(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_SDK::LuaBinding_SDK(LuaBinding& binding) : - LuaBinding_Base(binding) - { - #ifndef NDK_SERVER - LuaBinding_Graphics& graphics = static_cast(*m_binding.graphics); - #endif - - LuaBinding_Utility& utility = static_cast(*m_binding.utility); - - /*********************************** Ndk::Application **********************************/ - application.Reset("Application"); - { - #ifndef NDK_SERVER - //application.SetMethod("AddWindow", &Application::AddWindow); - - application.BindMethod("EnableConsole", &Application::EnableConsole); - application.BindMethod("EnableFPSCounter", &Application::EnableFPSCounter); - - application.BindMethod("IsConsoleEnabled", &Application::IsConsoleEnabled); - application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled); - #endif - - application.BindMethod("AddWorld", [] (Nz::LuaState& lua, Application* instance, std::size_t /*argumentCount*/) -> int - { - lua.Push(instance->AddWorld().CreateHandle()); - return 1; - }); - - application.BindMethod("GetUpdateTime", &Application::GetUpdateTime); - application.BindMethod("Quit", &Application::Quit); - } - - /*********************************** Ndk::Console **********************************/ - #ifndef NDK_SERVER - console.Reset("Console"); - { - console.Inherit(utility.node, [] (ConsoleHandle* handle) -> Nz::Node* - { - return handle->GetObject(); - }); - - console.BindMethod("AddLine", &Console::AddLine, Nz::Color::White); - console.BindMethod("Clear", &Console::Clear); - console.BindMethod("GetCharacterSize", &Console::GetCharacterSize); - //console.BindMethod("GetHistory", &Console::GetHistory); - //console.BindMethod("GetInput", &Console::GetInput); - console.BindMethod("GetTextFont", &Console::GetTextFont); - - console.BindMethod("IsValidHandle", &ConsoleHandle::IsValid); - - console.BindMethod("SetCharacterSize", &Console::SetCharacterSize); - console.BindMethod("SetTextFont", &Console::SetTextFont); - } - #endif - - /*********************************** Ndk::Entity **********************************/ - entity.Reset("Entity"); - { - entity.BindMethod("Enable", &Entity::Enable, true); - entity.BindMethod("GetId", &Entity::GetId); - entity.BindMethod("GetWorld", &Entity::GetWorld); - entity.BindMethod("Kill", &Entity::Kill); - entity.BindMethod("IsEnabled", &Entity::IsEnabled); - entity.BindMethod("IsValid", &Entity::IsValid); - entity.BindMethod("IsValidHandle", &EntityHandle::IsValid); - entity.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents); - entity.BindMethod("__tostring", &EntityHandle::ToString); - - entity.BindMethod("AddComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int - { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); - - return bindingComponent->adder(state, handle); - }); - - entity.BindMethod("HasComponent", [this](Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int - { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); - - state.PushBoolean(handle->HasComponent(bindingComponent->index)); - return 1; - }); - - entity.BindMethod("GetComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int - { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); - - return bindingComponent->getter(state, handle->GetComponent(bindingComponent->index)); - }); - - entity.BindMethod("RemoveComponent", [this] (Nz::LuaState& state, EntityHandle& handle, std::size_t /*argumentCount*/) -> int - { - LuaBinding::ComponentBinding* bindingComponent = m_binding.QueryComponentIndex(state); - - handle->RemoveComponent(bindingComponent->index); - return 0; - }); - } - - /*********************************** Ndk::NodeComponent **********************************/ - nodeComponent.Reset("NodeComponent"); - { - nodeComponent.BindMethod("IsValidHandle", &NodeComponentHandle::IsValid); - - nodeComponent.Inherit(utility.node, [] (NodeComponentHandle* handle) -> Nz::Node* - { - return handle->GetObject(); - }); - } - - /*********************************** Ndk::VelocityComponent **********************************/ - velocityComponent.Reset("VelocityComponent"); - { - velocityComponent.BindMethod("IsValidHandle", &VelocityComponentHandle::IsValid); - - velocityComponent.SetGetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance) - { - std::size_t length; - const char* member = lua.CheckString(2, &length); - - if (std::strcmp(member, "Linear") == 0) - { - lua.Push(instance->linearVelocity); - return true; - } - - return false; - }); - - velocityComponent.SetSetter([] (Nz::LuaState& lua, VelocityComponentHandle& instance) - { - std::size_t length; - const char* member = lua.CheckString(2, &length); - - int argIndex = 3; - if (std::strcmp(member, "Linear") == 0) - { - instance->linearVelocity = lua.Check(&argIndex); - return true; - } - - return false; - }); - } - - /*********************************** Ndk::World **********************************/ - world.Reset("World"); - { - world.BindMethod("CreateEntity", &World::CreateEntity); - world.BindMethod("CreateEntities", &World::CreateEntities); - world.BindMethod("Clear", &World::Clear); - world.BindMethod("DisableProfiler", &World::DisableProfiler); - world.BindMethod("EnableProfiler", &World::EnableProfiler); - world.BindMethod("IsProfilerEnabled", &World::IsProfilerEnabled); - world.BindMethod("Refresh", &World::Refresh); - world.BindMethod("ResetProfiler", &World::ResetProfiler); - world.BindMethod("Update", &World::Update); - - world.BindMethod("IsValidHandle", &WorldHandle::IsValid); - } - - #ifndef NDK_SERVER - /*********************************** Ndk::CameraComponent **********************************/ - cameraComponent.Reset("CameraComponent"); - { - cameraComponent.Inherit(graphics.abstractViewer, [] (CameraComponentHandle* handle) -> Nz::AbstractViewer* - { - return handle->GetObject(); - }); - - cameraComponent.BindMethod("GetFOV", &CameraComponent::GetFOV); - cameraComponent.BindMethod("GetLayer", &CameraComponent::GetLayer); - - cameraComponent.BindMethod("IsValidHandle", &CameraComponentHandle::IsValid); - - cameraComponent.BindMethod("SetFOV", &CameraComponent::SetFOV); - cameraComponent.BindMethod("SetLayer", &CameraComponent::SetLayer); - cameraComponent.BindMethod("SetProjectionType", &CameraComponent::SetProjectionType); - cameraComponent.BindMethod("SetSize", (void(CameraComponent::*)(const Nz::Vector2f&)) &CameraComponent::SetSize); - //cameraComponent.BindMethod("SetTarget", &CameraComponent::SetTarget); - cameraComponent.BindMethod("SetTargetRegion", &CameraComponent::SetTargetRegion); - cameraComponent.BindMethod("SetViewport", &CameraComponent::SetViewport); - cameraComponent.BindMethod("SetZFar", &CameraComponent::SetZFar); - cameraComponent.BindMethod("SetZNear", &CameraComponent::SetZNear); - } - - /*********************************** Ndk::GraphicsComponent **********************************/ - graphicsComponent.Reset("GraphicsComponent"); - { - graphicsComponent.BindMethod("Attach", [] (Nz::LuaState& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int - { - /* - void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); - void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0); - */ - - std::size_t argCount = std::min(argumentCount, 3U); - - switch (argCount) - { - case 1: - { - int argIndex = 2; - instance->Attach(lua.Check(&argIndex)); - return 0; - } - - case 2: - { - int argIndex = 2; - Nz::InstancedRenderableRef renderable = lua.Check(&argIndex); - - if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - { - int renderOrder = lua.Check(&argIndex); - - instance->Attach(renderable, renderOrder); - } - else if (lua.IsOfType(argIndex, "Matrix4")) - { - Nz::Matrix4f localMatrix = lua.Check(&argIndex); - - instance->Attach(renderable, localMatrix); - } - else - break; - - return 0; - } - - case 3: - { - int argIndex = 2; - Nz::InstancedRenderableRef renderable = lua.Check(&argIndex); - Nz::Matrix4f localMatrix = lua.Check(&argIndex); - int renderOrder = lua.Check(&argIndex); - - instance->Attach(renderable, localMatrix, renderOrder); - return 0; - } - } - - lua.Error("No matching overload for method GetMemoryUsage"); - return 0; - }); - - graphicsComponent.BindMethod("IsValidHandle", &GraphicsComponentHandle::IsValid); - } - #endif - - // Components functions - m_binding.BindComponent("Node"); - m_binding.BindComponent("Velocity"); - - #ifndef NDK_SERVER - m_binding.BindComponent("Camera"); - m_binding.BindComponent("Graphics"); - #endif - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the SDK classes - */ - void LuaBinding_SDK::Register(Nz::LuaState& state) - { - // Classes - application.Register(state); - entity.Register(state); - nodeComponent.Register(state); - velocityComponent.Register(state); - world.Register(state); - - #ifndef NDK_SERVER - cameraComponent.Register(state); - console.Register(state); - graphicsComponent.Register(state); - #endif - - // Enums - } - - /*! - * \brief Gets the index of the component - * \return A pointer to the binding linked to a component - * - * \param instance Lua instance that will interact with the component - * \param argIndex Index of the component - */ - LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaState& state, int argIndex) - { - switch (state.GetType(argIndex)) - { - case Nz::LuaType_Number: - { - ComponentIndex componentIndex = state.Check(&argIndex); - if (componentIndex > m_componentBinding.size()) - { - state.Error("Invalid component index"); - return nullptr; - } - - ComponentBinding& binding = m_componentBinding[componentIndex]; - if (binding.name.IsEmpty()) - { - state.Error("Invalid component index"); - return nullptr; - } - - return &binding; - } - - case Nz::LuaType_String: - { - const char* key = state.CheckString(argIndex); - auto it = m_componentBindingByName.find(key); - if (it == m_componentBindingByName.end()) - { - state.Error("Invalid component name"); - return nullptr; - } - - return &m_componentBinding[it->second]; - } - - default: - break; - } - - state.Error("Invalid component index at #" + Nz::String::Number(argIndex)); - return nullptr; - } -} diff --git a/SDK/src/NDK/Lua/LuaBinding_Utility.cpp b/SDK/src/NDK/Lua/LuaBinding_Utility.cpp deleted file mode 100644 index 262620b12..000000000 --- a/SDK/src/NDK/Lua/LuaBinding_Utility.cpp +++ /dev/null @@ -1,338 +0,0 @@ -// This file is part of the "Nazara Development Kit" -// For conditions of distribution and use, see copyright notice in Prerequisites.hpp - -#include -#include - -namespace Ndk -{ - std::unique_ptr LuaBinding_Base::BindUtility(LuaBinding& binding) - { - return std::make_unique(binding); - } - - LuaBinding_Utility::LuaBinding_Utility(LuaBinding& binding) : - LuaBinding_Base(binding) - { - /*********************************** Nz::AbstractImage **********************************/ - abstractImage.Reset("AbstractImage"); - { - abstractImage.BindMethod("GetBytesPerPixel", &Nz::AbstractImage::GetBytesPerPixel); - abstractImage.BindMethod("GetDepth", &Nz::AbstractImage::GetDepth, static_cast(0)); - abstractImage.BindMethod("GetFormat", &Nz::AbstractImage::GetFormat); - abstractImage.BindMethod("GetHeight", &Nz::AbstractImage::GetHeight, static_cast(0)); - abstractImage.BindMethod("GetLevelCount", &Nz::AbstractImage::GetLevelCount); - abstractImage.BindMethod("GetMaxLevel", &Nz::AbstractImage::GetMaxLevel); - abstractImage.BindMethod("GetSize", &Nz::AbstractImage::GetSize, static_cast(0)); - abstractImage.BindMethod("GetType", &Nz::AbstractImage::GetType); - abstractImage.BindMethod("GetWidth", &Nz::AbstractImage::GetWidth, static_cast(0)); - abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed); - abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap); - - abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaState& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 1U); - switch (argCount) - { - case 0: - return lua.Push(instance->GetMemoryUsage()); - - case 1: - { - int argIndex = 2; - Nz::UInt8 level(lua.Check(&argIndex)); - - return lua.Push(instance->GetMemoryUsage(level)); - } - } - - lua.Error("No matching overload for method GetMemoryUsage"); - return 0; - }); - - abstractImage.BindMethod("Update", [] (Nz::LuaState& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 6U); - int argIndex = 2; - - std::size_t bufferSize = 0; - const Nz::UInt8* pixels = reinterpret_cast(lua.CheckString(argIndex++, &bufferSize)); - - if (argCount < 2 || lua.IsOfType(2, Nz::LuaType_Number)) - { - // bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) - unsigned int srcWidth = lua.Check(&argIndex, 0); - unsigned int srcHeight = lua.Check(&argIndex, 0); - Nz::UInt8 level = lua.Check(&argIndex, 0); - - ///TODO: Buffer checks (Nz::ByteBufferView ?) - return lua.Push(instance->Update(pixels, srcWidth, srcHeight, level)); - } - /* Disabled until Box and Rect have been ported - else if (lua.IsOfType(2, "Box")) - { - // bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) - Nz::Boxui box = lua.Check(&argIndex); - unsigned int srcWidth = lua.Check(&argIndex, 0); - unsigned int srcHeight = lua.Check(&argIndex, 0); - Nz::UInt8 level = lua.Check(&argIndex, 0); - - ///TODO: Buffer checks (Nz::ByteBufferView ?) - return lua.Push(abstractImage->Update(pixels, srcWidth, srcHeight, level)); - } - else if (lua.IsOfType(2, "Rect")) - { - // bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) - Nz::Rectui box = lua.Check(&argIndex); - unsigned int srcWidth = lua.Check(&argIndex, 0); - unsigned int srcHeight = lua.Check(&argIndex, 0); - Nz::UInt8 level = lua.Check(&argIndex, 0); - - ///TODO: Buffer checks (Nz::ByteBufferView ?) - return lua.Push(abstractImage->Update(pixels, srcWidth, srcHeight, level)); - }*/ - - lua.Error("No matching overload for method Update"); - return 0; - }); - } - - /*********************************** Nz::Font **********************************/ - font.Reset("Font"); - { - font.SetConstructor([] (Nz::LuaState& /*lua*/, Nz::FontRef* instance, std::size_t /*argumentCount*/) - { - Nz::PlacementNew(instance, Nz::Font::New()); - return true; - }); - - font.BindMethod("ClearGlyphCache", &Nz::Font::ClearGlyphCache); - font.BindMethod("ClearKerningCache", &Nz::Font::ClearKerningCache); - font.BindMethod("ClearSizeInfoCache", &Nz::Font::ClearSizeInfoCache); - - font.BindMethod("Destroy", &Nz::Font::Destroy); - - font.BindMethod("GetCachedGlyphCount", [] (Nz::LuaState& lua, Nz::FontRef& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 2U); - - int argIndex = 2; - switch (argCount) - { - case 0: - lua.Push(instance->GetCachedGlyphCount()); - return 1; - - case 3: - { - unsigned int characterSize = lua.Check(&argIndex); - Nz::TextStyleFlags style = lua.Check(&argIndex); - float outlineThickness = lua.Check(&argIndex); - - lua.Push(instance->GetCachedGlyphCount(characterSize, style, outlineThickness)); - return 1; - } - } - - lua.Error("No matching overload for method GetCachedGlyphCount"); - return 0; - }); - - font.BindMethod("GetFamilyName", &Nz::Font::GetFamilyName); - font.BindMethod("GetKerning", &Nz::Font::GetKerning); - font.BindMethod("GetGlyphBorder", &Nz::Font::GetGlyphBorder); - font.BindMethod("GetMinimumStepSize", &Nz::Font::GetMinimumStepSize); - font.BindMethod("GetSizeInfo", &Nz::Font::GetSizeInfo); - font.BindMethod("GetStyleName", &Nz::Font::GetStyleName); - - font.BindMethod("IsValid", &Nz::Font::IsValid); - - font.BindMethod("Precache", (bool(Nz::Font::*)(unsigned int, Nz::TextStyleFlags, float, const Nz::String&) const) &Nz::Font::Precache); - - font.BindMethod("SetGlyphBorder", &Nz::Font::SetGlyphBorder); - font.BindMethod("SetMinimumStepSize", &Nz::Font::SetMinimumStepSize); - - font.BindStaticMethod("GetDefault", &Nz::Font::GetDefault); - font.BindStaticMethod("GetDefaultGlyphBorder", &Nz::Font::GetDefaultGlyphBorder); - font.BindStaticMethod("GetDefaultMinimumStepSize", &Nz::Font::GetDefaultMinimumStepSize); - - font.BindStaticMethod("OpenFromFile", &Nz::Font::OpenFromFile, Nz::FontParams()); - - font.BindStaticMethod("SetDefaultGlyphBorder", &Nz::Font::SetDefaultGlyphBorder); - font.BindStaticMethod("SetDefaultMinimumStepSize", &Nz::Font::SetDefaultMinimumStepSize); - } - - /*********************************** Nz::Node **********************************/ - node.Reset("Node"); - { - node.BindMethod("GetBackward", &Nz::Node::GetBackward); - //nodeClass.SetMethod("GetChilds", &Nz::Node::GetChilds); - node.BindMethod("GetDown", &Nz::Node::GetDown); - node.BindMethod("GetForward", &Nz::Node::GetForward); - node.BindMethod("GetInheritPosition", &Nz::Node::GetInheritPosition); - node.BindMethod("GetInheritRotation", &Nz::Node::GetInheritRotation); - node.BindMethod("GetInheritScale", &Nz::Node::GetInheritScale); - node.BindMethod("GetInitialPosition", &Nz::Node::GetInitialPosition); - //nodeClass.SetMethod("GetInitialRotation", &Nz::Node::GetInitialRotation); - node.BindMethod("GetInitialScale", &Nz::Node::GetInitialScale); - node.BindMethod("GetLeft", &Nz::Node::GetLeft); - node.BindMethod("GetNodeType", &Nz::Node::GetNodeType); - //nodeClass.SetMethod("GetParent", &Nz::Node::GetParent); - node.BindMethod("GetPosition", &Nz::Node::GetPosition, Nz::CoordSys_Global); - node.BindMethod("GetRight", &Nz::Node::GetRight); - //nodeClass.SetMethod("GetRotation", &Nz::Node::GetRotation, Nz::CoordSys_Global); - node.BindMethod("GetScale", &Nz::Node::GetScale, Nz::CoordSys_Global); - //nodeClass.SetMethod("GetTransformMatrix", &Nz::Node::GetTransformMatrix); - node.BindMethod("GetUp", &Nz::Node::GetUp); - - node.BindMethod("HasChilds", &Nz::Node::HasChilds); - - node.BindMethod("GetBackward", &Nz::Node::GetBackward); - node.BindMethod("GetDown", &Nz::Node::GetDown); - node.BindMethod("GetForward", &Nz::Node::GetForward); - node.BindMethod("GetInheritPosition", &Nz::Node::GetInheritPosition); - node.BindMethod("GetInheritRotation", &Nz::Node::GetInheritRotation); - node.BindMethod("GetInheritScale", &Nz::Node::GetInheritScale); - node.BindMethod("GetInitialPosition", &Nz::Node::GetInitialPosition); - node.BindMethod("GetInitialRotation", &Nz::Node::GetInitialRotation); - node.BindMethod("GetInitialScale", &Nz::Node::GetInitialScale); - node.BindMethod("GetLeft", &Nz::Node::GetLeft); - node.BindMethod("GetNodeType", &Nz::Node::GetNodeType); - node.BindMethod("GetPosition", &Nz::Node::GetPosition, Nz::CoordSys_Global); - node.BindMethod("GetRight", &Nz::Node::GetRight); - node.BindMethod("GetRotation", &Nz::Node::GetRotation, Nz::CoordSys_Global); - node.BindMethod("GetScale", &Nz::Node::GetScale, Nz::CoordSys_Global); - node.BindMethod("GetUp", &Nz::Node::GetUp); - - node.BindMethod("SetInitialPosition", (void(Nz::Node::*)(const Nz::Vector3f&)) &Nz::Node::SetInitialPosition); - node.BindMethod("SetInitialRotation", (void(Nz::Node::*)(const Nz::Quaternionf&)) &Nz::Node::SetInitialRotation); - - node.BindMethod("SetPosition", (void(Nz::Node::*)(const Nz::Vector3f&, Nz::CoordSys)) &Nz::Node::SetPosition, Nz::CoordSys_Local); - node.BindMethod("SetRotation", (void(Nz::Node::*)(const Nz::Quaternionf&, Nz::CoordSys)) &Nz::Node::SetRotation, Nz::CoordSys_Local); - - node.BindMethod("Move", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - - Nz::Vector3f offset = lua.Check(&argIndex); - Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.Move(offset, coordSys); - - return 0; - }); - - node.BindMethod("Rotate", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int - { - int argIndex = 2; - - Nz::Quaternionf rotation = lua.Check(&argIndex); - Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.Rotate(rotation, coordSys); - - return 0; - }); - - node.BindMethod("Scale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 4U); - - int argIndex = 2; - switch (argCount) - { - case 1: - { - if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - instance.Scale(lua.Check(&argIndex)); - else - instance.Scale(lua.Check(&argIndex)); - - return 0; - } - - case 3: - instance.Scale(lua.Check(&argIndex)); - return 0; - } - - lua.Error("No matching overload for method Scale"); - return 0; - }); - - node.BindMethod("SetScale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 4U); - - int argIndex = 2; - switch (argCount) - { - case 1: - case 2: - { - if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - { - float scale = lua.Check(&argIndex); - Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - instance.SetScale(scale, coordSys); - } - else - instance.SetScale(lua.Check(&argIndex)); - - return 0; - } - - case 3: - case 4: - { - Nz::Vector3f scale = lua.Check(&argIndex); - Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - - instance.SetScale(scale, coordSys); - return 0; - } - } - - lua.Error("No matching overload for method SetScale"); - return 0; - }); - - node.BindMethod("SetInitialScale", [] (Nz::LuaState& lua, Nz::Node& instance, std::size_t argumentCount) -> int - { - std::size_t argCount = std::min(argumentCount, 4U); - - int argIndex = 2; - switch (argCount) - { - case 1: - { - if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - instance.SetInitialScale(lua.Check(&argIndex)); - else - instance.SetInitialScale(lua.Check(&argIndex)); - - return 0; - } - - case 2: - case 3: - instance.SetInitialScale(lua.Check(&argIndex)); - return 0; - } - - lua.Error("No matching overload for method SetInitialScale"); - return 0; - }); - } - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the Utility classes - */ - void LuaBinding_Utility::Register(Nz::LuaState& state) - { - abstractImage.Register(state); - font.Register(state); - node.Register(state); - } -} diff --git a/SDK/src/NDK/LuaAPI.cpp b/SDK/src/NDK/LuaAPI.cpp deleted file mode 100644 index 3a82d2130..000000000 --- a/SDK/src/NDK/LuaAPI.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include -#include -#include - -namespace Ndk -{ - /*! - * \ingroup NDK - * \class Ndk::LuaAPI - * \brief NDK class that represents the api used for Lua - */ - - /*! - * \brief Gets the internal binding for Lua - * \return A pointer to the binding - */ - LuaBinding* LuaAPI::GetBinding() - { - if (!s_binding && !Initialize()) - { - NazaraError("Failed to initialize binding"); - return nullptr; - } - - return s_binding; - } - - /*! - * \brief Initializes the LuaAPI module - * \return true if initialization is successful - */ - - bool LuaAPI::Initialize() - { - s_binding = new LuaBinding; - return true; - } - - /*! - * \brief Registers the classes that will be used by the Lua instance - * - * \param instance Lua instance that will interact with the engine & SDK - */ - - void LuaAPI::RegisterClasses(Nz::LuaState& state) - { - Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true); - GetBinding()->RegisterClasses(state); - } - - /*! - * \brief Uninitializes the LuaAPI module - */ - - void LuaAPI::Uninitialize() - { - delete s_binding; - } - - LuaBinding* LuaAPI::s_binding = nullptr; -} diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 341e6f0d5..c6a6de027 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include #include @@ -70,8 +68,6 @@ namespace Ndk // Initialize the engine first // Shared modules - Nz::Lua::Initialize(); - Nz::Noise::Initialize(); Nz::Physics2D::Initialize(); Nz::Physics3D::Initialize(); Nz::Utility::Initialize(); @@ -178,8 +174,6 @@ namespace Ndk #endif // Shared modules - Nz::Lua::Uninitialize(); - Nz::Noise::Uninitialize(); Nz::Physics2D::Uninitialize(); Nz::Physics3D::Uninitialize(); Nz::Utility::Uninitialize(); diff --git a/build/scripts/modules/lua.lua b/build/scripts/modules/lua.lua deleted file mode 100644 index 96fe0cbc1..000000000 --- a/build/scripts/modules/lua.lua +++ /dev/null @@ -1,7 +0,0 @@ --- Quelle ironie -MODULE.Name = "Lua" - -MODULE.Libraries = { - "lua", - "NazaraCore" -} diff --git a/build/scripts/modules/noise.lua b/build/scripts/modules/noise.lua deleted file mode 100644 index 155cd83be..000000000 --- a/build/scripts/modules/noise.lua +++ /dev/null @@ -1,5 +0,0 @@ -MODULE.Name = "Noise" - -MODULE.Libraries = { - "NazaraCore" -} diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 06e9fd97c..4952106a8 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -13,7 +13,6 @@ */ #include // Horloges -#include // Module de scripting #include // Module graphique #include // Module de rendu #include // Module utilitaire @@ -22,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -264,10 +262,6 @@ int main() application.EnableConsole(true); application.EnableFPSCounter(true); - Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); - consoleOverlay.lua.PushGlobal("Spaceship", spaceship->CreateHandle()); - consoleOverlay.lua.PushGlobal("World", world->CreateHandle()); - //Gestion des Evenements Nz::EventHandler& eventHandler = window.GetEventHandler(); diff --git a/examples/Particles/LogoDemo.cpp b/examples/Particles/LogoDemo.cpp index f04ce43ad..a4d31ef8d 100644 --- a/examples/Particles/LogoDemo.cpp +++ b/examples/Particles/LogoDemo.cpp @@ -126,7 +126,7 @@ ParticleDemo("Logo", sharedData) Nz::ImageParams params; params.loadFormat = Nz::PixelFormatType_RGBA8; - m_logo = Nz::Image::LoadFromFile("resources/Logo.png", params); + m_logo = Nz::Image::LoadFromFile("E:/Twitch/avatar_interested.png", params); if (!m_logo) NazaraError("Failed to load logo!"); diff --git a/examples/Particles/main.cpp b/examples/Particles/main.cpp index 7f1571989..2d77811a4 100644 --- a/examples/Particles/main.cpp +++ b/examples/Particles/main.cpp @@ -1,9 +1,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -38,6 +36,8 @@ int main() Nz::RenderWindow& window = app.AddWindow(mode, "Nazara demo - Particles", Nz::WindowStyle_Closable, targetParams); //Nz::RenderWindow& window = app.AddWindow(Nz::VideoMode(1920, 1080), "Nazara demo - Particles", Nz::WindowStyle_Fullscreen, targetParams); + app.EnableFPSCounter(true); + Ndk::World& world3D = app.AddWorld(); Ndk::World& world2D = app.AddWorld(); diff --git a/examples/Tut00/main.cpp b/examples/Tut00/main.cpp index a1029eb99..d3018f5e8 100644 --- a/examples/Tut00/main.cpp +++ b/examples/Tut00/main.cpp @@ -1,9 +1,7 @@ -#include +#include #include #include -#include #include -#include #include #include #include diff --git a/include/Nazara/Lua.hpp b/include/Nazara/Lua.hpp deleted file mode 100644 index bd7ddb24c..000000000 --- a/include/Nazara/Lua.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// This file was automatically generated - -/* - Nazara Engine - Lua scripting module - - Copyright (C) 2015 Jérôme Leclercq (lynix680@gmail.com) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_GLOBAL_LUA_HPP -#define NAZARA_GLOBAL_LUA_HPP - -#include -#include -#include -#include -#include -#include -#include - -#endif // NAZARA_GLOBAL_LUA_HPP diff --git a/include/Nazara/Lua/Config.hpp b/include/Nazara/Lua/Config.hpp deleted file mode 100644 index 6536233f6..000000000 --- a/include/Nazara/Lua/Config.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - Nazara Engine - Lua scripting module - - Copyright (C) 2015 Jérôme Leclercq (lynix680@gmail.com) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_CONFIG_LUA_HPP -#define NAZARA_CONFIG_LUA_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) -#define NAZARA_LUA_MANAGE_MEMORY 0 - -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_LUA_SAFE 1 - -/// Vérification des valeurs et types de certaines constantes -#include - -#if defined(NAZARA_STATIC) - #define NAZARA_LUA_API -#else - #ifdef NAZARA_LUA_BUILD - #define NAZARA_LUA_API NAZARA_EXPORT - #else - #define NAZARA_LUA_API NAZARA_IMPORT - #endif -#endif - -#endif // NAZARA_CONFIG_LUA_HPP diff --git a/include/Nazara/Lua/ConfigCheck.hpp b/include/Nazara/Lua/ConfigCheck.hpp deleted file mode 100644 index ee3010113..000000000 --- a/include/Nazara/Lua/ConfigCheck.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONFIG_CHECK_LUA_HPP -#define NAZARA_CONFIG_CHECK_LUA_HPP - -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp - -// On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_LUA_MANAGE_MEMORY - #undef NAZARA_LUA_MANAGE_MEMORY - #define NAZARA_LUA_MANAGE_MEMORY 0 -#endif - -#endif // NAZARA_CONFIG_CHECK_LUA_HPP diff --git a/include/Nazara/Lua/Debug.hpp b/include/Nazara/Lua/Debug.hpp deleted file mode 100644 index 991f620a2..000000000 --- a/include/Nazara/Lua/Debug.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_LUA_MANAGE_MEMORY - #include -#endif diff --git a/include/Nazara/Lua/DebugOff.hpp b/include/Nazara/Lua/DebugOff.hpp deleted file mode 100644 index 59c38fd94..000000000 --- a/include/Nazara/Lua/DebugOff.hpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_LUA_MANAGE_MEMORY - #undef delete - #undef new -#endif diff --git a/include/Nazara/Lua/Enums.hpp b/include/Nazara/Lua/Enums.hpp deleted file mode 100644 index e92f058d5..000000000 --- a/include/Nazara/Lua/Enums.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ENUMS_LUA_HPP -#define NAZARA_ENUMS_LUA_HPP - -#include - -namespace Nz -{ - enum LuaBindMode - { - LuaBindMode_Table, - LuaBindMode_Userdata, - - LuaBindMode_Max = LuaBindMode_Userdata - }; - - enum LuaComparison - { - LuaComparison_Equality, - LuaComparison_Less, - LuaComparison_LessOrEqual, - - LuaComparison_Max = LuaComparison_LessOrEqual - }; - - enum LuaLib - { - LuaLib_Coroutine, - LuaLib_Debug, - LuaLib_Math, - LuaLib_Io, - LuaLib_Package, - LuaLib_Os, - LuaLib_String, - LuaLib_Table, - LuaLib_Utf8, - - LuaLib_Max = LuaLib_Utf8 - }; - - enum LuaOperation - { - LuaOperation_Addition, - LuaOperation_BitwiseAnd, - LuaOperation_BitwiseLeftShift, - LuaOperation_BitwiseNot, - LuaOperation_BitwiseOr, - LuaOperation_BitwideRightShift, - LuaOperation_BitwiseXOr, - LuaOperation_Division, - LuaOperation_Exponentiation, - LuaOperation_FloorDivision, - LuaOperation_Modulo, - LuaOperation_Multiplication, - LuaOperation_Negation, - LuaOperation_Substraction, - - LuaOperation_Max = LuaOperation_Substraction - }; - - enum LuaType - { - LuaType_Boolean, - LuaType_Function, - LuaType_LightUserdata, - LuaType_Nil, - LuaType_Number, - LuaType_None, - LuaType_String, - LuaType_Table, - LuaType_Thread, - LuaType_Userdata, - - LuaType_Max = LuaType_Userdata - }; - - template<> - struct EnumAsFlags - { - static constexpr LuaLib max = LuaLib_Max; - }; - - using LuaLibFlags = Flags; - - constexpr LuaLibFlags LuaLib_All = LuaLibFlags(LuaLibFlags::ValueMask); -} - -#endif // NAZARA_ENUMS_LUA_HPP diff --git a/include/Nazara/Lua/Lua.hpp b/include/Nazara/Lua/Lua.hpp deleted file mode 100644 index d884a22b9..000000000 --- a/include/Nazara/Lua/Lua.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_LUA_HPP -#define NAZARA_LUA_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_LUA_API Lua - { - public: - Lua() = delete; - ~Lua() = delete; - - static bool Initialize(); - - static bool IsInitialized(); - - static void Uninitialize(); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_LUA_HPP diff --git a/include/Nazara/Lua/LuaClass.hpp b/include/Nazara/Lua/LuaClass.hpp deleted file mode 100644 index 79558a3b6..000000000 --- a/include/Nazara/Lua/LuaClass.hpp +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_LUACLASS_HPP -#define NAZARA_LUACLASS_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - template - class LuaClass - { - template - friend class LuaClass; - - public: - using ClassFunc = std::function; - using ClassIndexFunc = std::function; - using ConstructorFunc = std::function; - template using ConvertToParent = std::function; - using FinalizerFunc = std::function; - using StaticIndexFunc = std::function; - using StaticFunc = std::function; - - LuaClass() = default; - LuaClass(const String& name); - - void BindDefaultConstructor(); - - void BindMethod(const String& name, ClassFunc method); - template std::enable_if_t::value> BindMethod(const String& name, R(P::*func)(Args...), DefArgs&&... defArgs); - template std::enable_if_t::value> BindMethod(const String& name, R(P::*func)(Args...) const, DefArgs&&... defArgs); - template std::enable_if_t::type>::value> BindMethod(const String& name, R(P::*func)(Args...), DefArgs&&... defArgs); - template std::enable_if_t::type>::value> BindMethod(const String& name, R(P::*func)(Args...) const, DefArgs&&... defArgs); - - void BindStaticMethod(const String& name, StaticFunc func); - template void BindStaticMethod(const String& name, R(*func)(Args...), DefArgs&&... defArgs); - - template void Inherit(LuaClass

& parent); - template void Inherit(LuaClass

& parent, ConvertToParent

convertFunc); - - void Reset(); - void Reset(const String& name); - - void Register(LuaState& state); - - void PushGlobalTable(LuaState& state); - - void SetConstructor(ConstructorFunc constructor); - void SetFinalizer(FinalizerFunc finalizer); - void SetGetter(ClassIndexFunc getter); - void SetSetter(ClassIndexFunc setter); - void SetStaticGetter(StaticIndexFunc getter); - void SetStaticSetter(StaticIndexFunc getter); - - private: - template - friend struct LuaClassImplFinalizerSetupProxy; - - int PushClassInfo(LuaState& state); - void SetupConstructor(LuaState& state, int classInfoRef); - void SetupDefaultToString(LuaState& state, int classInfoRef); - void SetupFinalizer(LuaState& state, int classInfoRef); - void SetupGetter(LuaState& state, LuaCFunction proxy, int classInfoRef); - void SetupGlobalTable(LuaState& state, int classInfoRef); - void SetupMetatable(LuaState& state, int classInfoRef); - void SetupMethod(LuaState& state, LuaCFunction proxy, const String& name, std::size_t methodIndex, int classInfoRef); - void SetupSetter(LuaState& state, LuaCFunction proxy, int classInfoRef); - - using ParentFunc = std::function; - using InstanceGetter = std::function; - - struct ClassInfo - { - std::vector methods; - std::vector parentGetters; - std::vector staticMethods; - std::unordered_map instanceGetters; - ClassIndexFunc getter; - ClassIndexFunc setter; - ConstructorFunc constructor; - FinalizerFunc finalizer; - StaticIndexFunc staticGetter; - StaticIndexFunc staticSetter; - String name; - int globalTableRef = -1; - }; - - static int ConstructorProxy(lua_State* internalState); - static int FinalizerProxy(lua_State* internalState); - static int InfoDestructor(lua_State* internalState); - static void Get(const std::shared_ptr& info, LuaState& state, T* instance); - static int GetterProxy(lua_State* internalState); - static int MethodProxy(lua_State* internalState); - static int SetterProxy(lua_State* internalState); - static int StaticGetterProxy(lua_State* internalState); - static int StaticMethodProxy(lua_State* internalState); - static int StaticSetterProxy(lua_State* internalState); - static int ToStringProxy(lua_State* internalState); - - std::map m_methods; - std::map m_staticMethods; - std::shared_ptr m_info; - }; -} - -#include - -#endif // NAZARA_LUACLASS_HPP diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl deleted file mode 100644 index 86ab9b311..000000000 --- a/include/Nazara/Lua/LuaClass.inl +++ /dev/null @@ -1,603 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - template - LuaClass::LuaClass(const String& name) - { - Reset(name); - } - - template - inline void LuaClass::BindDefaultConstructor() - { - SetConstructor([] (Nz::LuaState& state, T* instance, std::size_t argumentCount) - { - NazaraUnused(state); - NazaraUnused(argumentCount); - - PlacementNew(instance); - return true; - }); - } - - template - template - inline void LuaClass::Inherit(LuaClass

& parent) - { - Inherit

(parent, [] (T* instance) -> P* - { - return static_cast(instance); - }); - } - - template - template - inline void LuaClass::Inherit(LuaClass

& parent, ConvertToParent

convertFunc) - { - static_assert(!std::is_same::value || std::is_base_of::value, "P must be a base of T"); - - std::shared_ptr::ClassInfo>& parentInfo = parent.m_info; - - parentInfo->instanceGetters[m_info->name] = [info = m_info, convertFunc] (LuaState& state) -> P* - { - return convertFunc(static_cast(state.CheckUserdata(1, info->name))); - }; - - m_info->parentGetters.emplace_back([parentInfo, convertFunc] (LuaState& state, T* instance) - { - LuaClass

::Get(parentInfo, state, convertFunc(instance)); - }); - } - - - template - void LuaClass::Reset() - { - m_info.reset(); - } - - template - void LuaClass::Reset(const String& name) - { - m_info = std::make_shared(); - m_info->name = name; - - m_info->instanceGetters[m_info->name] = [info = m_info] (LuaState& state) - { - return static_cast(state.CheckUserdata(1, info->name)); - }; - } - - template - void LuaClass::Register(LuaState& state) - { - int classInfoRef = PushClassInfo(state); - - // Let's create the metatable which will be associated with every state. - SetupMetatable(state, classInfoRef); - - if (m_info->constructor || m_info->staticGetter || m_info->staticSetter || !m_staticMethods.empty()) - SetupGlobalTable(state, classInfoRef); - - state.DestroyReference(classInfoRef); - } - - template - void LuaClass::PushGlobalTable(LuaState& state) - { - state.PushReference(m_info->globalTableRef); - } - - template - void LuaClass::SetConstructor(ConstructorFunc constructor) - { - m_info->constructor = constructor; - } - - template - void LuaClass::SetFinalizer(FinalizerFunc finalizer) - { - m_info->finalizer = finalizer; - } - - template - void LuaClass::SetGetter(ClassIndexFunc getter) - { - m_info->getter = getter; - } - - template - void LuaClass::BindMethod(const String& name, ClassFunc method) - { - m_methods[name] = method; - } - - template - template - std::enable_if_t::value> LuaClass::BindMethod(const String& name, R(P::*func)(Args...), DefArgs&&... defArgs) - { - typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - - BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int - { - handler.ProcessArguments(state); - - return handler.Invoke(state, object, func); - }); - } - - template - template - std::enable_if_t::value> LuaClass::BindMethod(const String& name, R(P::*func)(Args...) const, DefArgs&&... defArgs) - { - typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - - BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int - { - handler.ProcessArguments(state); - - return handler.Invoke(state, object, func); - }); - } - - template - template - std::enable_if_t::type>::value> LuaClass::BindMethod(const String& name, R(P::*func)(Args...), DefArgs&&... defArgs) - { - typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - - BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int - { - handler.ProcessArguments(state); - - return handler.Invoke(state, object, func); - }); - } - - template - template - std::enable_if_t::type>::value> LuaClass::BindMethod(const String& name, R(P::*func)(Args...) const, DefArgs&&... defArgs) - { - typename LuaImplMethodProxy::template Impl handler(std::forward(defArgs)...); - - BindMethod(name, [func, handler] (LuaState& state, T& object, std::size_t /*argumentCount*/) -> int - { - handler.ProcessArguments(state); - - return handler.Invoke(state, object, func); - }); - } - - template - void LuaClass::SetSetter(ClassIndexFunc setter) - { - m_info->setter = setter; - } - - template - void LuaClass::SetStaticGetter(StaticIndexFunc getter) - { - m_info->staticGetter = getter; - } - - template - void LuaClass::BindStaticMethod(const String& name, StaticFunc method) - { - m_staticMethods[name] = method; - } - - template - template - void LuaClass::BindStaticMethod(const String& name, R(*func)(Args...), DefArgs&&... defArgs) - { - typename LuaImplFunctionProxy::template Impl handler(std::forward(defArgs)...); - - BindStaticMethod(name, [func, handler] (LuaState& state) -> int - { - handler.ProcessArguments(state); - - return handler.Invoke(state, func); - }); - } - - template - void LuaClass::SetStaticSetter(StaticIndexFunc setter) - { - m_info->staticSetter = setter; - } - - template - int LuaClass::PushClassInfo(LuaState& state) - { - // Our ClassInfo has to outlive the LuaClass, because we don't want to force the user to keep the LuaClass alive - // To do that, each Registration creates a tiny shared_ptr wrapper whose life is directly managed by Lua. - // This shared_ptr object gets pushed as a up-value for every proxy function set in the metatable. - // This way, there is no way our ClassInfo gets freed before any instance and the global class gets destroyed. - std::shared_ptr* info = static_cast*>(state.PushUserdata(sizeof(std::shared_ptr))); - PlacementNew(info, m_info); - - // Setup a tiny metatable to let Lua know how to destroy our ClassInfo - state.PushTable(0, 1); - state.PushLightUserdata(info); - state.PushCFunction(InfoDestructor, 1); - state.SetField("__gc"); - state.SetMetatable(-2); - - return state.CreateReference(); - } - - template - void LuaClass::SetupConstructor(LuaState& state, int classInfoRef) - { - state.PushReference(classInfoRef); - state.PushCFunction(ConstructorProxy, 1); - state.SetField("__call"); // ClassMeta.__call = ConstructorProxy - } - - template - void LuaClass::SetupDefaultToString(LuaState& state, int classInfoRef) - { - state.PushReference(classInfoRef); - state.PushCFunction(ToStringProxy, 1); - state.SetField("__tostring"); - } - - template - struct LuaClassImplFinalizerSetupProxy; - - template - struct LuaClassImplFinalizerSetupProxy - { - static void Setup(LuaState& state, int classInfoRef) - { - state.PushReference(classInfoRef); - state.PushCFunction(LuaClass::FinalizerProxy, 1); - state.SetField("__gc"); - } - }; - - template - struct LuaClassImplFinalizerSetupProxy - { - static void Setup(LuaState&, int) - { - } - }; - - template - void LuaClass::SetupFinalizer(LuaState& state, int classInfoRef) - { - LuaClassImplFinalizerSetupProxy::value>::Setup(state, classInfoRef); - } - - template - void LuaClass::SetupGetter(LuaState& state, LuaCFunction proxy, int classInfoRef) - { - state.PushReference(classInfoRef); - state.PushValue(-2); // Metatable - state.PushCFunction(proxy, 2); - - state.SetField("__index"); // Getter - } - - template - void LuaClass::SetupGlobalTable(LuaState& state, int classInfoRef) - { - // Create the global table - state.PushTable(); // Class = {} - - // Create a metatable which will be used for our global table - state.PushTable(); // ClassMeta = {} - - if (m_info->constructor) - SetupConstructor(state, classInfoRef); - - if (m_info->staticGetter) - SetupGetter(state, StaticGetterProxy, classInfoRef); - else - { - // Optimize by assigning the metatable instead of a search function - state.PushValue(-1); // Metatable - state.SetField("__index"); - } - - if (m_info->staticSetter) - SetupSetter(state, StaticSetterProxy, classInfoRef); - - m_info->staticMethods.reserve(m_staticMethods.size()); - for (auto& pair : m_staticMethods) - { - std::size_t methodIndex = m_info->staticMethods.size(); - m_info->staticMethods.push_back(pair.second); - - SetupMethod(state, StaticMethodProxy, pair.first, methodIndex, classInfoRef); - } - - state.SetMetatable(-2); // setmetatable(Class, ClassMeta), pops ClassMeta - - state.PushValue(-1); // As CreateReference() pops the table, push a copy - m_info->globalTableRef = state.CreateReference(); - - state.SetGlobal(m_info->name); // _G["Class"] = Class - } - - template - void LuaClass::SetupMetatable(LuaState& state, int classInfoRef) - { - if (!state.NewMetatable(m_info->name)) - NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance"); - { - SetupFinalizer(state, classInfoRef); - - if (m_info->getter || !m_info->parentGetters.empty()) - SetupGetter(state, GetterProxy, classInfoRef); - else - { - // Optimize by assigning the metatable instead of a search function - // This is only possible if we have no custom getter nor parent - state.PushValue(-1); // Metatable - state.SetField("__index"); - } - - if (m_info->setter) - SetupSetter(state, SetterProxy, classInfoRef); - - // In case a __tostring method is missing, add a default implementation returning the class name - if (m_methods.find("__tostring") == m_methods.end()) - SetupDefaultToString(state, classInfoRef); - - m_info->methods.reserve(m_methods.size()); - for (auto& pair : m_methods) - { - std::size_t methodIndex = m_info->methods.size(); - m_info->methods.push_back(pair.second); - - SetupMethod(state, MethodProxy, pair.first, methodIndex, classInfoRef); - } - } - state.Pop(); //< Pops the metatable, it won't be collected before it's referenced by the Lua registry. - } - - template - void LuaClass::SetupMethod(LuaState& state, LuaCFunction proxy, const String& name, std::size_t methodIndex, int classInfoRef) - { - state.PushReference(classInfoRef); - state.PushInteger(methodIndex); - state.PushCFunction(proxy, 2); - - state.SetField(name); // Method name - } - - template - void LuaClass::SetupSetter(LuaState& state, LuaCFunction proxy, int classInfoRef) - { - state.PushReference(classInfoRef); - state.PushCFunction(proxy, 1); - - state.SetField("__newindex"); // Setter - } - - - template - int LuaClass::ConstructorProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - const ConstructorFunc& constructor = info->constructor; - - state.Remove(1); // On enlève l'argument "table" du stack - - std::size_t argCount = state.GetStackTop(); - - T* instance = static_cast(state.PushUserdata(sizeof(T))); - - if (!constructor(state, instance, argCount)) - { - state.Error("Constructor failed"); - return 0; // Normalement jamais exécuté (l'erreur provoquant une exception) - } - - state.SetMetatable(info->name); - return 1; - } - - template - int LuaClass::FinalizerProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - const FinalizerFunc& finalizer = info->finalizer; - - T* instance = static_cast(state.CheckUserdata(1, info->name)); - state.Remove(1); //< Remove the instance from the Lua stack - - if (!finalizer || finalizer(state, *instance)) - instance->~T(); - - return 0; - } - - template - int LuaClass::InfoDestructor(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - state.DestroyReference(info->globalTableRef); - - using namespace std; // Obligatoire pour le destructeur - info.~shared_ptr(); // Si vous voyez une autre façon de faire, je suis preneur - - return 0; - } - - template - void LuaClass::Get(const std::shared_ptr& info, LuaState& state, T* instance) - { - const ClassIndexFunc& getter = info->getter; - - if (!getter || !getter(state, *instance)) - { - // Query from the metatable - state.GetMetatable(info->name); //< Metatable - state.PushValue(2); //< Field - state.GetTable(); // Metatable[Field] - - state.Remove(-2); // Remove Metatable - - if (!state.IsValid(-1)) - { - for (const ParentFunc& parentGetter : info->parentGetters) - { - state.Pop(); //< Pop the last nil value - - parentGetter(state, instance); - if (state.IsValid(-1)) - return; - } - } - } - } - - template - int LuaClass::GetterProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - - T* instance = static_cast(state.CheckUserdata(1, info->name)); - - Get(info, state, instance); - return 1; - } - - template - int LuaClass::MethodProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - - T* instance = nullptr; - if (state.GetMetatable(1)) - { - LuaType type = state.GetField("__name"); - if (type == LuaType_String) - { - String name = state.ToString(-1); - auto it = info->instanceGetters.find(name); - if (it != info->instanceGetters.end()) - instance = it->second(state); - } - state.Pop(2); - } - - if (!instance) - { - state.Error("Method cannot be called without an object"); - return 0; - } - - std::size_t argCount = state.GetStackTop() - 1U; - - unsigned int index = static_cast(state.ToInteger(state.GetIndexOfUpValue(2))); - const ClassFunc& method = info->methods[index]; - return method(state, *instance, argCount); - } - - template - int LuaClass::SetterProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - const ClassIndexFunc& setter = info->setter; - - T& instance = *static_cast(state.CheckUserdata(1, info->name)); - - if (!setter(state, instance)) - { - std::size_t length; - const char* str = state.ToString(2, &length); - - state.Error("Class \"" + info->name + "\" has no field \"" + String(str, length) + "\")"); - } - - return 1; - } - - template - int LuaClass::StaticGetterProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - const StaticIndexFunc& getter = info->staticGetter; - - if (!getter(state)) - { - // On accède alors à la table - state.PushValue(state.GetIndexOfUpValue(2)); - state.PushValue(-2); - state.GetTable(); - } - - return 1; - } - - template - int LuaClass::StaticMethodProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - unsigned int index = static_cast(state.ToInteger(state.GetIndexOfUpValue(2))); - const StaticFunc& method = info->staticMethods[index]; - - return method(state); - } - - template - int LuaClass::StaticSetterProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - const StaticIndexFunc& setter = info->staticSetter; - - if (!setter(state)) - { - std::size_t length; - const char* str = state.ToString(2, &length); - - state.Error("Class \"" + info->name + "\" has no static field \"" + String(str, length) + ')'); - } - - return 1; - } - - template - int LuaClass::ToStringProxy(lua_State* internalState) - { - LuaState state = LuaInstance::GetState(internalState); - - std::shared_ptr& info = *static_cast*>(state.ToUserdata(state.GetIndexOfUpValue(1))); - - state.PushString(info->name); - return 1; - } -} - -#include diff --git a/include/Nazara/Lua/LuaCoroutine.hpp b/include/Nazara/Lua/LuaCoroutine.hpp deleted file mode 100644 index 753aa8a4f..000000000 --- a/include/Nazara/Lua/LuaCoroutine.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_LUACOROUTINE_HPP -#define NAZARA_LUACOROUTINE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_LUA_API LuaCoroutine : public LuaState - { - friend class LuaState; - - public: - LuaCoroutine(const LuaCoroutine&) = delete; - inline LuaCoroutine(LuaCoroutine&& instance); - ~LuaCoroutine(); - - bool CanResume() const; - - Ternary Resume(unsigned int argCount = 0); - - LuaCoroutine& operator=(const LuaCoroutine&) = delete; - inline LuaCoroutine& operator=(LuaCoroutine&& instance); - - private: - LuaCoroutine(lua_State* internalState, int refIndex); - - bool Run(int argCount, int resultCount, int errHandler) override; - - int m_ref; - }; -} - -#include - -#endif // NAZARA_LUACOROUTINE_HPP diff --git a/include/Nazara/Lua/LuaCoroutine.inl b/include/Nazara/Lua/LuaCoroutine.inl deleted file mode 100644 index 43a3f87cb..000000000 --- a/include/Nazara/Lua/LuaCoroutine.inl +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -namespace Nz -{ - inline LuaCoroutine::LuaCoroutine(LuaCoroutine&& instance) : - LuaState(std::move(instance)), - m_ref(instance.m_ref) - { - instance.m_ref = -1; - } - - inline LuaCoroutine& LuaCoroutine::operator=(LuaCoroutine&& instance) - { - LuaState::operator=(std::move(instance)); - - std::swap(m_ref, instance.m_ref); - - return *this; - } -} diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp deleted file mode 100644 index c45a77a94..000000000 --- a/include/Nazara/Lua/LuaInstance.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_LUAINSTANCE_HPP -#define NAZARA_LUAINSTANCE_HPP - -#include -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_LUA_API LuaInstance : public LuaState - { - friend class LuaCoroutine; - friend class LuaState; - - public: - LuaInstance(); - LuaInstance(const LuaInstance&) = delete; - LuaInstance(LuaInstance&& instance); - ~LuaInstance(); - - inline std::size_t GetMemoryLimit() const; - inline std::size_t GetMemoryUsage() const; - inline UInt32 GetTimeLimit() const; - - void LoadLibraries(LuaLibFlags libFlags = LuaLib_All); - - inline void SetMemoryLimit(std::size_t memoryLimit); - inline void SetTimeLimit(UInt32 limit); - - LuaInstance& operator=(const LuaInstance&) = delete; - LuaInstance& operator=(LuaInstance&& instance); - - private: - inline void SetMemoryUsage(std::size_t memoryUsage); - - static void* MemoryAllocator(void *ud, void *ptr, std::size_t osize, std::size_t nsize); - static void TimeLimiter(lua_State* internalState, lua_Debug* debug); - - std::size_t m_memoryLimit; - std::size_t m_memoryUsage; - UInt32 m_timeLimit; - Clock m_clock; - unsigned int m_level; - }; -} - -#include - -#endif // NAZARA_LUAINSTANCE_HPP diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl deleted file mode 100644 index 21d9b061e..000000000 --- a/include/Nazara/Lua/LuaInstance.inl +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include - -namespace Nz -{ - inline std::size_t LuaInstance::GetMemoryLimit() const - { - return m_memoryLimit; - } - - inline std::size_t LuaInstance::GetMemoryUsage() const - { - return m_memoryUsage; - } - - inline UInt32 LuaInstance::GetTimeLimit() const - { - return m_timeLimit; - } - - inline void LuaInstance::SetMemoryLimit(std::size_t memoryLimit) - { - m_memoryLimit = memoryLimit; - } - - inline void LuaInstance::SetTimeLimit(UInt32 limit) - { - m_timeLimit = limit; - } - - inline void LuaInstance::SetMemoryUsage(std::size_t memoryUsage) - { - m_memoryUsage = memoryUsage; - } -} - -#include diff --git a/include/Nazara/Lua/LuaState.hpp b/include/Nazara/Lua/LuaState.hpp deleted file mode 100644 index 8f401a6c3..000000000 --- a/include/Nazara/Lua/LuaState.hpp +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_LUASTATE_HPP -#define NAZARA_LUASTATE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct lua_Debug; -struct lua_State; - -namespace Nz -{ - class LuaCoroutine; - class LuaInstance; - class LuaState; - class Stream; - - using LuaCFunction = int (*)(lua_State* internalState); - using LuaFunction = std::function; - - class NAZARA_LUA_API LuaState - { - public: - LuaState(const LuaState&) = default; - LuaState(LuaState&& instance) = default; - ~LuaState() = default; - - void ArgCheck(bool condition, unsigned int argNum, const char* error) const; - void ArgCheck(bool condition, unsigned int argNum, const String& error) const; - int ArgError(unsigned int argNum, const char* error) const; - int ArgError(unsigned int argNum, const String& error) const; - - bool Call(unsigned int argCount); - bool Call(unsigned int argCount, unsigned int resultCount); - bool CallWithHandler(unsigned int argCount, int errorHandler); - bool CallWithHandler(unsigned int argCount, unsigned int resultCount, int errorHandler); - - template T Check(int* index) const; - template T Check(int* index, T defValue) const; - void CheckAny(int index) const; - bool CheckBoolean(int index) const; - bool CheckBoolean(int index, bool defValue) const; - template T CheckBoundInteger(int index) const; - template T CheckBoundInteger(int index, T defValue) const; - template T CheckField(const char* fieldName, int tableIndex = -1) const; - template T CheckField(const String& fieldName, int tableIndex = -1) const; - template T CheckField(const char* fieldName, T defValue, int tableIndex = -1) const; - template T CheckField(const String& fieldName, T defValue, int tableIndex = -1) const; - long long CheckInteger(int index) const; - long long CheckInteger(int index, long long defValue) const; - template T CheckGlobal(const char* fieldName) const; - template T CheckGlobal(const String& fieldName) const; - template T CheckGlobal(const char* fieldName, T defValue) const; - template T CheckGlobal(const String& fieldName, T defValue) const; - double CheckNumber(int index) const; - double CheckNumber(int index, double defValue) const; - void CheckStack(int space, const char* error = nullptr) const; - void CheckStack(int space, const String& error) const; - const char* CheckString(int index, std::size_t* length = nullptr) const; - const char* CheckString(int index, const char* defValue, std::size_t* length = nullptr) const; - void CheckType(int index, LuaType type) const; - void* CheckUserdata(int index, const char* tname) const; - void* CheckUserdata(int index, const String& tname) const; - - bool Compare(int index1, int index2, LuaComparison comparison) const; - void Compute(LuaOperation operation) const; - - void Concatenate(int count) const; - - int CreateReference(); - void DestroyReference(int ref); - - String DumpStack() const; - - void Error(const char* message) const; - void Error(const String& message) const; - - bool Execute(const String& code, int errorHandler = 0); - bool ExecuteFromFile(const std::filesystem::path& filePath, int errorHandler = 0); - bool ExecuteFromMemory(const void* data, std::size_t size, int errorHandler = 0); - bool ExecuteFromStream(Stream& stream, int errorHandler = 0); - - int GetAbsIndex(int index) const; - LuaType GetField(const char* fieldName, int tableIndex = -1) const; - LuaType GetField(const String& fieldName, int tableIndex = -1) const; - LuaType GetGlobal(const char* name) const; - LuaType GetGlobal(const String& name) const; - inline lua_State* GetInternalState() const; - inline String GetLastError() const; - LuaType GetMetatable(const char* tname) const; - LuaType GetMetatable(const String& tname) const; - bool GetMetatable(int index) const; - unsigned int GetStackTop() const; - LuaType GetTable(int index = -2) const; - LuaType GetTableRaw(int index = -2) const; - LuaType GetType(int index) const; - const char* GetTypeName(LuaType type) const; - - void Insert(int index) const; - - bool IsOfType(int index, LuaType type) const; - bool IsOfType(int index, const char* tname) const; - bool IsOfType(int index, const String& tname) const; - bool IsValid(int index) const; - - bool Load(const String& code); - bool LoadFromFile(const std::filesystem::path& filePath); - bool LoadFromMemory(const void* data, std::size_t size); - bool LoadFromStream(Stream& stream); - - long long Length(int index) const; - std::size_t LengthRaw(int index) const; - - void MoveTo(LuaState* instance, int n) const; - - LuaCoroutine NewCoroutine(); - bool NewMetatable(const char* str); - bool NewMetatable(const String& str); - bool Next(int index = -2) const; - - void Pop(unsigned int n = 1U) const; - - template int Push(T arg) const; - template int Push(T firstArg, T2 secondArg, Args... args) const; - void PushBoolean(bool value) const; - void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const; - template void PushField(const char* name, T&& arg, int tableIndex = -2) const; - template void PushField(const String& name, T&& arg, int tableIndex = -2) const; - void PushFunction(LuaFunction func) const; - template void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const; - template void PushGlobal(const char* name, T&& arg); - template void PushGlobal(const String& name, T&& arg); - template void PushInstance(const char* tname, T&& instance) const; - template void PushInstance(const char* tname, Args&&... args) const; - void PushInteger(long long value) const; - void PushLightUserdata(void* value) const; - void PushMetatable(const char* str) const; - void PushMetatable(const String& str) const; - void PushNil() const; - void PushNumber(double value) const; - void PushReference(int ref) const; - void PushString(const char* str) const; - void PushString(const char* str, std::size_t size) const; - void PushString(const String& str) const; - void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const; - void* PushUserdata(std::size_t size) const; - void PushValue(int index) const; - - bool RawEqual(int index1, int index2) const; - - void Remove(int index) const; - void Replace(int index) const; - - void SetField(const char* name, int tableIndex = -2) const; - void SetField(const String& name, int tableIndex = -2) const; - void SetGlobal(const char* name); - void SetGlobal(const String& name); - void SetMetatable(const char* tname) const; - void SetMetatable(const String& tname) const; - void SetMetatable(int index) const; - void SetTable(int index = -3) const; - void SetTableRaw(int index = -3) const; - - bool ToBoolean(int index) const; - long long ToInteger(int index, bool* succeeded = nullptr) const; - double ToNumber(int index, bool* succeeded = nullptr) const; - const void* ToPointer(int index) const; - const char* ToString(int index, std::size_t* length = nullptr) const; - void* ToUserdata(int index) const; - void* ToUserdata(int index, const char* tname) const; - void* ToUserdata(int index, const String& tname) const; - - void Traceback(const char* message = nullptr, int level = 0); - - LuaState& operator=(const LuaState&) = default; - LuaState& operator=(LuaState&& instance) = default; - - static int GetIndexOfUpValue(int upValue); - static LuaInstance& GetInstance(lua_State* internalState); - static inline LuaState GetState(lua_State* internalState); - - protected: - LuaState(lua_State* internalState); - - template std::enable_if_t::value, T> CheckBounds(int index, long long value) const; - template std::enable_if_t::value, T> CheckBounds(int index, long long value) const; - virtual bool Run(int argCount, int resultCount, int errHandler); - - static int ProxyFunc(lua_State* internalState); - - MovablePtr m_state; - String m_lastError; - }; -} - -#include - -#endif // NAZARA_LUASTATE_HPP diff --git a/include/Nazara/Lua/LuaState.inl b/include/Nazara/Lua/LuaState.inl deleted file mode 100644 index a3a71ef65..000000000 --- a/include/Nazara/Lua/LuaState.inl +++ /dev/null @@ -1,843 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - inline LuaState::LuaState(lua_State* internalState) : - m_state(internalState) - { - } - - inline lua_State* LuaState::GetInternalState() const - { - return m_state; - } - - inline String LuaState::GetLastError() const - { - return m_lastError; - } - - // Functions args - inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, bool* arg, TypeTag) - { - *arg = instance.CheckBoolean(index); - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, bool* arg, bool defValue, TypeTag) - { - *arg = instance.CheckBoolean(index, defValue); - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, std::filesystem::path* arg, TypeTag) - { - std::size_t strLength = 0; - const char* str = instance.CheckString(index, &strLength); - - arg->assign(std::string_view(str, strLength)); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, std::string* arg, TypeTag) - { - std::size_t strLength = 0; - const char* str = instance.CheckString(index, &strLength); - - arg->assign(str, strLength); - - return 1; - } - - inline unsigned int LuaImplQueryArg(const LuaState& instance, int index, String* arg, TypeTag) - { - std::size_t strLength = 0; - const char* str = instance.CheckString(index, &strLength); - - arg->Set(str, strLength); - - return 1; - } - - template - std::enable_if_t::value && !IsEnumFlag::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - return LuaImplQueryArg(instance, index, reinterpret_cast(arg), TypeTag()); - } - - template - std::enable_if_t::value && !IsEnumFlag::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - return LuaImplQueryArg(instance, index, reinterpret_cast(arg), static_cast(defValue), TypeTag()); - } - - template - std::enable_if_t::value && IsEnumFlag::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - - UnderlyingT pot2Val; - unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, TypeTag()); - - *arg = static_cast(IntegralLog2Pot(pot2Val)); - return ret; - } - - template - std::enable_if_t::value && IsEnumFlag::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) - { - using UnderlyingT = std::underlying_type_t; - - UnderlyingT pot2Val; - unsigned int ret = LuaImplQueryArg(instance, index, &pot2Val, 1U << static_cast(defValue), TypeTag()); - - *arg = static_cast(IntegralLog2Pot(pot2Val)); - return ret; - } - - template - unsigned int LuaImplQueryArg(const LuaState& instance, int index, Flags* arg, TypeTag>) - { - *arg = Flags(instance.CheckBoundInteger(index)); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) - { - *arg = static_cast(instance.CheckNumber(index)); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) - { - *arg = static_cast(instance.CheckNumber(index, static_cast(defValue))); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) - { - *arg = instance.CheckBoundInteger(index); - return 1; - } - - template - std::enable_if_t::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, T defValue, TypeTag) - { - *arg = instance.CheckBoundInteger(index, defValue); - return 1; - } - - template - std::enable_if_t::value && !std::is_enum::value && !std::is_floating_point::value, unsigned int> LuaImplQueryArg(const LuaState& instance, int index, T* arg, const T& defValue, TypeTag tag) - { - if (instance.IsValid(index)) - return LuaImplQueryArg(instance, index, arg, tag); - else - { - *arg = defValue; - return 1; - } - } - - template - unsigned int LuaImplQueryArg(const LuaState& instance, int index, T* arg, TypeTag) - { - return LuaImplQueryArg(instance, index, arg, TypeTag()); - } - - template - unsigned int LuaImplQueryArg(const LuaState& instance, int index, T* arg, const T& defValue, TypeTag) - { - return LuaImplQueryArg(instance, index, arg, defValue, TypeTag()); - } - - template - unsigned int LuaImplQueryArg(const LuaState& instance, int index, std::vector* container, TypeTag>) - { - instance.CheckType(index, Nz::LuaType_Table); - std::size_t pos = 1; - - container->clear(); - for (;;) - { - Nz::CallOnExit popStack { [&instance]() { instance.Pop(); } }; - instance.PushInteger(pos++); - - int tableIndex = (index < 0) ? index - 1 : index; - if (instance.GetTable(tableIndex) == Nz::LuaType_Nil) - break; - - T arg; - if (LuaImplQueryArg(instance, -1, &arg, TypeTag()) != 1) - { - instance.Error("Type needs more than one place to be initialized"); - return 0; - } - - container->push_back(arg); - } - - return 1; - } - - // Function returns - inline int LuaImplReplyVal(const LuaState& instance, bool val, TypeTag) - { - instance.PushBoolean(val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& instance, double val, TypeTag) - { - instance.PushNumber(val); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& instance, float val, TypeTag) - { - instance.PushNumber(val); - return 1; - } - - template - std::enable_if_t::value && !IsEnumFlag::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - using EnumT = typename std::underlying_type::type; - return LuaImplReplyVal(instance, static_cast(val), TypeTag()); - } - - template - std::enable_if_t::value && IsEnumFlag::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - Flags flags(val); - return LuaImplReplyVal(instance, flags, TypeTag()); - } - - template - int LuaImplReplyVal(const LuaState& instance, Flags val, TypeTag>) - { - instance.PushInteger(typename Flags::BitField(val)); - return 1; - } - - template - std::enable_if_t::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - instance.PushInteger(val); - return 1; - } - - template - std::enable_if_t::value || std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, val, TypeTag()); - } - - template - std::enable_if_t::value || std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, val, TypeTag()); - } - - template - std::enable_if_t::value && !std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, std::move(val), TypeTag()); - } - - template - std::enable_if_t::value && !std::is_enum::value, int> LuaImplReplyVal(const LuaState& instance, T val, TypeTag) - { - return LuaImplReplyVal(instance, std::move(val), TypeTag()); - } - - template - int LuaImplReplyVal(const LuaState& instance, T&& val, TypeTag) - { - return LuaImplReplyVal(instance, std::forward(val), TypeTag()); - } - - inline int LuaImplReplyVal(const LuaState& instance, std::string&& val, TypeTag) - { - instance.PushString(val.c_str(), val.size()); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& instance, std::filesystem::path&& val, TypeTag) - { - return LuaImplReplyVal(instance, val.generic_u8string(), TypeTag()); - } - - template - inline int LuaImplReplyVal(const LuaState& instance, std::vector&& valContainer, TypeTag>) - { - std::size_t index = 1; - instance.PushTable(valContainer.size()); - for (T& val : valContainer) - { - instance.PushInteger(index++); - if (LuaImplReplyVal(instance, std::move(val), TypeTag()) != 1) - { - instance.Error("Couldn't create table: type need more than one place to store"); - return 0; - } - instance.SetTable(); - } - - return 1; - } - - inline int LuaImplReplyVal(const LuaState& instance, ByteArray&& val, TypeTag) - { - instance.PushString(reinterpret_cast(val.GetConstBuffer()), val.GetSize()); - return 1; - } - - inline int LuaImplReplyVal(const LuaState& instance, String&& val, TypeTag) - { - instance.PushString(std::move(val)); - return 1; - } - - template - int LuaImplReplyVal(const LuaState& instance, std::pair&& val, TypeTag>) - { - int retVal = 0; - - retVal += LuaImplReplyVal(instance, std::move(val.first), TypeTag()); - retVal += LuaImplReplyVal(instance, std::move(val.second), TypeTag()); - - return retVal; - } - - template - struct LuaImplArgProcesser; - - template<> - struct LuaImplArgProcesser - { - template - static unsigned int Process(const LuaState& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs) - { - return LuaImplQueryArg(instance, argIndex, &std::get(args), std::get() - N - 1>(defArgs), TypeTag()); - } - }; - - template<> - struct LuaImplArgProcesser - { - template - static unsigned int Process(const LuaState& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs) - { - NazaraUnused(defArgs); - - return LuaImplQueryArg(instance, argIndex, &std::get(args), TypeTag()); - } - }; - - template - class LuaImplFunctionProxy - { - public: - template - class Impl - { - static constexpr std::size_t ArgCount = sizeof...(Args); - static constexpr std::size_t DefArgCount = sizeof...(DefArgs); - - static_assert(ArgCount >= DefArgCount, "There cannot be more default arguments than argument"); - - static constexpr std::size_t FirstDefArg = ArgCount - DefArgCount; - - public: - Impl(DefArgs... defArgs) : - m_defaultArgs(std::forward(defArgs)...) - { - } - - void ProcessArguments(const LuaState& instance) const - { - m_index = 1; - ProcessArgs<0, Args...>(instance); - } - - int Invoke(const LuaState& instance, void(*func)(Args...)) const - { - NazaraUnused(instance); - - Apply(func, m_args); - return 0; - } - - template - int Invoke(const LuaState& instance, Ret(*func)(Args...)) const - { - return LuaImplReplyVal(instance, std::move(Apply(func, m_args)), TypeTag()); - } - - private: - using ArgContainer = std::tuple>...>; - using DefArgContainer = std::tuple>...>; - - template - void ProcessArgs(const LuaState& instance) const - { - NazaraUnused(instance); - - // No argument to process - } - - template - void ProcessArgs(const LuaState& instance) const - { - LuaImplArgProcesser<(N >= FirstDefArg)>::template Process(instance, m_index, m_args, m_defaultArgs); - } - - template - void ProcessArgs(const LuaState& instance) const - { - ProcessArgs(instance); - ProcessArgs(instance); - } - - mutable ArgContainer m_args; - DefArgContainer m_defaultArgs; - mutable unsigned int m_index; - }; - }; - - template - class LuaImplMethodProxy - { - public: - template - class Impl - { - static constexpr std::size_t ArgCount = sizeof...(Args); - static constexpr std::size_t DefArgCount = sizeof...(DefArgs); - - static_assert(ArgCount >= DefArgCount, "There cannot be more default arguments than argument"); - - static constexpr std::size_t FirstDefArg = ArgCount - DefArgCount; - - public: - Impl(DefArgs... defArgs) : - m_defaultArgs(std::forward(defArgs)...) - { - } - - void ProcessArguments(const LuaState& instance) const - { - m_index = 2; //< 1 being the instance - ProcessArgs<0, Args...>(instance); - } - - template - std::enable_if_t::value, int> Invoke(const LuaState& instance, T& object, void(P::*func)(Args...)) const - { - NazaraUnused(instance); - - Apply(object, func, m_args); - return 0; - } - - template - std::enable_if_t::value, int> Invoke(const LuaState& instance, T& object, Ret(P::*func)(Args...)) const - { - return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::value, int> Invoke(const LuaState& instance, T& object, T&(P::*func)(Args...)) const - { - T& r = Apply(object, func, m_args); - if (&r == &object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - template - std::enable_if_t::value, int> Invoke(const LuaState& instance, const T& object, void(P::*func)(Args...) const) const - { - NazaraUnused(instance); - - Apply(object, func, m_args); - return 0; - } - - template - std::enable_if_t::value, int> Invoke(const LuaState& instance, const T& object, Ret(P::*func)(Args...) const) const - { - return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::value, int> Invoke(const LuaState& instance, const T& object, const T&(P::*func)(Args...) const) const - { - const T& r = Apply(object, func, m_args); - if (&r == &object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, T& object, void(P::*func)(Args...)) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - Apply(*object, func, m_args); - return 0; - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, T& object, Ret(P::*func)(Args...)) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, T& object, typename PointedType::type&(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - const typename PointedType::type& r = Apply(*object, func, m_args); - if (&r == &*object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, const T& object, void(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - Apply(*object, func, m_args); - return 0; - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, const T& object, Ret(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag()); - } - - template - std::enable_if_t::type>::value, int> Invoke(const LuaState& instance, const T& object, const typename PointedType::type&(P::*func)(Args...) const) const - { - if (!object) - { - instance.Error("Invalid object"); - return 0; - } - - const typename PointedType::type& r = Apply(*object, func, m_args); - if (&r == &*object) - { - instance.PushValue(1); //< Userdata - return 1; - } - else - return LuaImplReplyVal(instance, r, TypeTag()); - } - - private: - using ArgContainer = std::tuple>...>; - using DefArgContainer = std::tuple>...>; - - template - void ProcessArgs(const LuaState& instance) const - { - NazaraUnused(instance); - - // No argument to process - } - - template - void ProcessArgs(const LuaState& instance) const - { - m_index += LuaImplArgProcesser<(N >= FirstDefArg)>::template Process(instance, m_index, m_args, m_defaultArgs); - } - - template - void ProcessArgs(const LuaState& instance) const - { - ProcessArgs(instance); - ProcessArgs(instance); - } - - mutable ArgContainer m_args; - DefArgContainer m_defaultArgs; - mutable unsigned int m_index; - }; - }; - - template - T LuaState::Check(int* index) const - { - NazaraAssert(index, "Invalid index pointer"); - - T object; - *index += LuaImplQueryArg(*this, *index, &object, TypeTag()); - - return object; - } - - template - T LuaState::Check(int* index, T defValue) const - { - NazaraAssert(index, "Invalid index pointer"); - - T object; - *index += LuaImplQueryArg(*this, *index, &object, defValue, TypeTag()); - - return object; - } - - template - inline T LuaState::CheckBoundInteger(int index) const - { - return CheckBounds(index, CheckInteger(index)); - } - - template - inline T LuaState::CheckBoundInteger(int index, T defValue) const - { - return CheckBounds(index, CheckInteger(index, defValue)); - } - - template - T LuaState::CheckField(const char* fieldName, int tableIndex) const - { - T object; - - GetField(fieldName, tableIndex); - tableIndex += LuaImplQueryArg(*this, -1, &object, TypeTag()); - Pop(); - - return object; - } - - template - T LuaState::CheckField(const String& fieldName, int tableIndex) const - { - return CheckField(fieldName.GetConstBuffer(), tableIndex); - } - - template - T LuaState::CheckField(const char* fieldName, T defValue, int tableIndex) const - { - T object; - - GetField(fieldName, tableIndex); - tableIndex += LuaImplQueryArg(*this, -1, &object, defValue, TypeTag()); - Pop(); - - return object; - } - - template - T LuaState::CheckField(const String& fieldName, T defValue, int tableIndex) const - { - return CheckField(fieldName.GetConstBuffer(), defValue, tableIndex); - } - - template - T LuaState::CheckGlobal(const char* fieldName) const - { - T object; - - GetGlobal(fieldName); - LuaImplQueryArg(*this, -1, &object, TypeTag()); - Pop(); - - return object; - } - - template - T LuaState::CheckGlobal(const String& fieldName) const - { - return CheckGlobal(fieldName.GetConstBuffer()); - } - - template - T LuaState::CheckGlobal(const char* fieldName, T defValue) const - { - T object; - - GetGlobal(fieldName); - LuaImplQueryArg(*this, -1, &object, defValue, TypeTag()); - Pop(); - - return object; - } - - template - T LuaState::CheckGlobal(const String& fieldName, T defValue) const - { - return CheckGlobal(fieldName.GetConstBuffer(), defValue); - } - - template - int LuaState::Push(T arg) const - { - return LuaImplReplyVal(*this, std::move(arg), TypeTag()); - } - - template - int LuaState::Push(T firstArg, T2 secondArg, Args... args) const - { - int valCount = 0; - valCount += Push(std::move(firstArg)); - valCount += Push(secondArg, std::forward(args)...); - - return valCount; - } - - template - void LuaState::PushField(const char* name, T&& arg, int tableIndex) const - { - Push(std::forward(arg)); - SetField(name, tableIndex); - } - - template - void LuaState::PushField(const String& name, T&& arg, int tableIndex) const - { - PushField(name.GetConstBuffer(), std::forward(arg), tableIndex); - } - - template - void LuaState::PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const - { - typename LuaImplFunctionProxy::template Impl handler(std::forward(defArgs)...); - - PushFunction([func, handler] (LuaState& lua) -> int - { - handler.ProcessArguments(lua); - - return handler.Invoke(lua, func); - }); - } - - template - void LuaState::PushGlobal(const char* name, T&& arg) - { - Push(std::forward(arg)); - SetGlobal(name); - } - - template - void LuaState::PushGlobal(const String& name, T&& arg) - { - PushGlobal(name.GetConstBuffer(), std::forward(arg)); - } - - template - void LuaState::PushInstance(const char* tname, T&& instance) const - { - T* userdata = static_cast(PushUserdata(sizeof(T))); - PlacementNew(userdata, std::move(instance)); - - SetMetatable(tname); - } - - template - void LuaState::PushInstance(const char* tname, Args&&... args) const - { - T* userdata = static_cast(PushUserdata(sizeof(T))); - PlacementNew(userdata, std::forward(args)...); - - SetMetatable(tname); - } - - template - std::enable_if_t::value, T> LuaState::CheckBounds(int index, long long value) const - { - constexpr long long minBounds = std::numeric_limits::min(); - constexpr long long maxBounds = std::numeric_limits::max(); - if (value < minBounds || value > maxBounds) - { - Nz::StringStream stream; - stream << "Argument #" << index << " is outside value range [" << minBounds << ", " << maxBounds << "] (" << value << ')'; - Error(stream); - } - - return static_cast(value); - } - - template - std::enable_if_t::value, T> LuaState::CheckBounds(int index, long long value) const - { - unsigned long long uValue = static_cast(value); - constexpr unsigned long long minBounds = 0; - constexpr unsigned long long maxBounds = std::numeric_limits::max(); - if (uValue < minBounds || uValue > maxBounds) - { - Nz::StringStream stream; - stream << "Argument #" << index << " is outside value range [" << minBounds << ", " << maxBounds << "] (" << value << ')'; - Error(stream); - } - - return static_cast(uValue); - } - - inline LuaState LuaState::GetState(lua_State* internalState) - { - return LuaState(internalState); - } -} diff --git a/include/Nazara/Noise.hpp b/include/Nazara/Noise.hpp deleted file mode 100644 index f8ecfb82e..000000000 --- a/include/Nazara/Noise.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// This file was automatically generated - -/* - Nazara Engine - Noise module - - Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_GLOBAL_NOISE_HPP -#define NAZARA_GLOBAL_NOISE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // NAZARA_GLOBAL_NOISE_HPP diff --git a/include/Nazara/Noise/Config.hpp b/include/Nazara/Noise/Config.hpp deleted file mode 100644 index afe6d577e..000000000 --- a/include/Nazara/Noise/Config.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - Nazara Engine - Noise module - - Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_CONFIG_NOISE_HPP -#define NAZARA_CONFIG_NOISE_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) -#define NAZARA_NOISE_MANAGE_MEMORY 0 - -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_NOISE_SAFE 1 - -/// Vérification des valeurs et types de certaines constantes -#include - -#if defined(NAZARA_STATIC) - #define NAZARA_NOISE_API -#else - #ifdef NAZARA_NOISE_BUILD - #define NAZARA_NOISE_API NAZARA_EXPORT - #else - #define NAZARA_NOISE_API NAZARA_IMPORT - #endif -#endif - -#endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/Noise/ConfigCheck.hpp b/include/Nazara/Noise/ConfigCheck.hpp deleted file mode 100644 index 93a90e13f..000000000 --- a/include/Nazara/Noise/ConfigCheck.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONFIG_CHECK_NOISE_HPP -#define NAZARA_CONFIG_CHECK_NOISE_HPP - -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp - -// On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_NOISE_MANAGE_MEMORY - #undef NAZARA_NOISE_MANAGE_MEMORY - #define NAZARA_NOISE_MANAGE_MEMORY 0 -#endif - -#endif // NAZARA_CONFIG_CHECK_NOISE_HPP diff --git a/include/Nazara/Noise/Debug.hpp b/include/Nazara/Noise/Debug.hpp deleted file mode 100644 index 4068c5a95..000000000 --- a/include/Nazara/Noise/Debug.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_NOISE_MANAGE_MEMORY - #include -#endif diff --git a/include/Nazara/Noise/DebugOff.hpp b/include/Nazara/Noise/DebugOff.hpp deleted file mode 100644 index a0ca07927..000000000 --- a/include/Nazara/Noise/DebugOff.hpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_NOISE_MANAGE_MEMORY - #undef delete - #undef new -#endif diff --git a/include/Nazara/Noise/Enums.hpp b/include/Nazara/Noise/Enums.hpp deleted file mode 100644 index fdc2b7ec3..000000000 --- a/include/Nazara/Noise/Enums.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_ENUMS_NOISE_HPP -#define NAZARA_ENUMS_NOISE_HPP - -namespace Nz -{ - enum WorleyFunction - { - WorleyFunction_F1 = 0, - WorleyFunction_F2 = 1, - WorleyFunction_F3 = 2, - WorleyFunction_F4 = 3 - }; -} -#endif // NAZARA_ENUMS_NOISE_HPP diff --git a/include/Nazara/Noise/FBM.hpp b/include/Nazara/Noise/FBM.hpp deleted file mode 100644 index 743ab41fc..000000000 --- a/include/Nazara/Noise/FBM.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_FBM_HPP -#define NAZARA_FBM_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM : public MixerBase - { - public: - FBM(const NoiseBase& source); - FBM(const FBM&) = delete; - ~FBM() = default; - - float Get(float x, float y, float scale) const override; - float Get(float x, float y, float z, float scale) const override; - float Get(float x, float y, float z, float w, float scale) const override; - - FBM& operator=(const FBM&) = delete; - - private: - const NoiseBase& m_source; - }; -} - -#endif // NAZARA_FBM_HPP diff --git a/include/Nazara/Noise/HybridMultiFractal.hpp b/include/Nazara/Noise/HybridMultiFractal.hpp deleted file mode 100644 index da2456e40..000000000 --- a/include/Nazara/Noise/HybridMultiFractal.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_HYBRIDMULTIFRACTAL_HPP -#define NAZARA_HYBRIDMULTIFRACTAL_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal : public MixerBase - { - public: - HybridMultiFractal(const NoiseBase & source); - HybridMultiFractal(const HybridMultiFractal&) = delete; - ~HybridMultiFractal() = default; - - float Get(float x, float y, float scale) const override; - float Get(float x, float y, float z, float scale) const override; - float Get(float x, float y, float z, float w, float scale) const override; - - HybridMultiFractal& operator=(const HybridMultiFractal&) = delete; - - private: - const NoiseBase& m_source; - }; -} - -#endif // NAZARA_HYBRIDMULTIFRACTAL_HPP diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp deleted file mode 100644 index f509c0493..000000000 --- a/include/Nazara/Noise/MixerBase.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_MIXERBASE_HPP -#define NAZARA_MIXERBASE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API MixerBase - { - public: - MixerBase(); - virtual ~MixerBase() = default; - - virtual float Get(float x, float y, float scale) const = 0; - virtual float Get(float x, float y, float z, float scale) const = 0; - virtual float Get(float x, float y, float z, float w, float scale) const = 0; - - float GetHurstParameter() const; - float GetLacunarity() const; - float GetOctaveNumber() const; - - void SetParameters(float hurst, float lacunarity, float octaves); - - protected: - float m_hurst; - float m_lacunarity; - float m_octaves; - std::vector m_exponent_array; - float m_sum; - - private: - void Recompute(); - }; -} - -#endif // NAZARA_MIXERBASE_HPP diff --git a/include/Nazara/Noise/Noise.hpp b/include/Nazara/Noise/Noise.hpp deleted file mode 100644 index eb27d1a26..000000000 --- a/include/Nazara/Noise/Noise.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_NOISE_HPP -#define NAZARA_NOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Noise - { - public: - Noise() = delete; - ~Noise() = delete; - - static bool Initialize(); - - static bool IsInitialized(); - - static void Uninitialize(); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_NOISE_HPP diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp deleted file mode 100644 index e19339316..000000000 --- a/include/Nazara/Noise/NoiseBase.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_NOISEBASE_HPP -#define NAZARA_NOISEBASE_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API NoiseBase - { - public: - NoiseBase(unsigned int seed = 0); - virtual ~NoiseBase() = default; - - virtual float Get(float x, float y, float scale) const = 0; - virtual float Get(float x, float y, float z, float scale) const = 0; - virtual float Get(float x, float y, float z, float w, float scale) const = 0; - float GetScale(); - - void SetScale(float scale); - void SetSeed(unsigned int seed); - - void Shuffle(); - - protected: - std::array m_permutations; - float m_scale; - - static std::array s_gradients2; - static std::array s_gradients3; - static std::array s_gradients4; - - private: - std::mt19937 m_randomEngine; - }; -} - -#endif // NAZARA_NOISEBASE_HPP diff --git a/include/Nazara/Noise/NoiseTools.hpp b/include/Nazara/Noise/NoiseTools.hpp deleted file mode 100644 index b3fd1bada..000000000 --- a/include/Nazara/Noise/NoiseTools.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_NOISETOOLS_HPP -#define NAZARA_NOISETOOLS_HPP - -namespace Nz -{ - int fastfloor(float n); - int JenkinsHash(int a, int b, int c); -} - -#endif // NAZARA_NOISETOOLS_HPP diff --git a/include/Nazara/Noise/Perlin.hpp b/include/Nazara/Noise/Perlin.hpp deleted file mode 100644 index 480af41bd..000000000 --- a/include/Nazara/Noise/Perlin.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_PERLIN_HPP -#define NAZARA_PERLIN_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin : public NoiseBase - { - public: - Perlin() = default; - Perlin(unsigned int seed); - ~Perlin() = default; - - float Get(float x, float y, float scale) const override; - float Get(float x, float y, float z, float scale) const override; - float Get(float x, float y, float z, float w, float scale) const override; - }; -} - -#endif // NAZARA_PERLIN_HPP diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp deleted file mode 100644 index cbe037821..000000000 --- a/include/Nazara/Noise/Simplex.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_SIMPLEX_HPP -#define NAZARA_SIMPLEX_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex : public NoiseBase - { - public: - Simplex() = default; - Simplex(unsigned int seed); - ~Simplex() = default; - - float Get(float x, float y, float scale) const override; - float Get(float x, float y, float z, float scale) const override; - float Get(float x, float y, float z, float w, float scale) const override; - }; -} - -#endif // NAZARA_SIMPLEX_HPP diff --git a/include/Nazara/Noise/Worley.hpp b/include/Nazara/Noise/Worley.hpp deleted file mode 100644 index 22e6b86e5..000000000 --- a/include/Nazara/Noise/Worley.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#ifndef NAZARA_WORLEY_HPP -#define NAZARA_WORLEY_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Worley : public NoiseBase - { - public: - Worley(); - Worley(unsigned int seed); - ~Worley() = default; - - float Get(float x, float y, float scale) const override; - float Get(float x, float y, float z, float scale) const override; - float Get(float x, float y, float z, float w, float scale) const override; - - void Set(WorleyFunction func); - - private: - void SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; - - WorleyFunction m_function; - }; -} - -#endif // NAZARA_WORLEY_HPP diff --git a/src/Nazara/Lua/Debug/NewOverload.cpp b/src/Nazara/Lua/Debug/NewOverload.cpp deleted file mode 100644 index 8c83e037e..000000000 --- a/src/Nazara/Lua/Debug/NewOverload.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_LUA_MANAGE_MEMORY - -#include -#include // Nécessaire ? - -void* operator new(std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, true); -} - -#endif // NAZARA_LUA_MANAGE_MEMORY diff --git a/src/Nazara/Lua/Lua.cpp b/src/Nazara/Lua/Lua.cpp deleted file mode 100644 index 83ec20a86..000000000 --- a/src/Nazara/Lua/Lua.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - bool Lua::Initialize() - { - if (s_moduleReferenceCounter > 0) - { - s_moduleReferenceCounter++; - return true; // Déjà initialisé - } - - // Initialisation des dépendances - if (!Core::Initialize()) - { - NazaraError("Failed to initialize core module"); - return false; - } - - s_moduleReferenceCounter++; - - // Initialisation du module - - NazaraNotice("Initialized: Lua module"); - return true; - } - - bool Lua::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - void Lua::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Le module est soit encore utilisé, soit pas initialisé - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - // Libération du module - s_moduleReferenceCounter = 0; - - NazaraNotice("Uninitialized: Lua module"); - - // Libération des dépendances - Core::Uninitialize(); - } - - unsigned int Lua::s_moduleReferenceCounter = 0; -} diff --git a/src/Nazara/Lua/LuaCoroutine.cpp b/src/Nazara/Lua/LuaCoroutine.cpp deleted file mode 100644 index ad3f40736..000000000 --- a/src/Nazara/Lua/LuaCoroutine.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - LuaCoroutine::LuaCoroutine(lua_State* internalState, int refIndex) : - LuaState(internalState), - m_ref(refIndex) - { - } - - LuaCoroutine::~LuaCoroutine() - { - if (m_ref >= 0) - DestroyReference(m_ref); - } - - bool LuaCoroutine::CanResume() const - { - return lua_status(m_state) == LUA_YIELD; - } - - Ternary LuaCoroutine::Resume(unsigned int argCount) - { - LuaInstance& instance = GetInstance(m_state); - if (instance.m_level++ == 0) - instance.m_clock.Restart(); - - int status = lua_resume(m_state, nullptr, argCount); - instance.m_level--; - - if (status == LUA_OK) - return Ternary_True; - else if (status == LUA_YIELD) - return Ternary_Unknown; - else - { - m_lastError = ToString(-1); - Pop(); - return Ternary_False; - } - } - - bool LuaCoroutine::Run(int argCount, int /*resultCount*/, int /*errHandler*/) - { - return Resume(argCount) != Ternary_False; - } -} diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp deleted file mode 100644 index eb9e4e48f..000000000 --- a/src/Nazara/Lua/LuaInstance.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - int AtPanic(lua_State* internalState) - { - String lastError(lua_tostring(internalState, -1)); - - throw std::runtime_error("Lua panic: " + lastError.ToStdString()); - } - } - - LuaInstance::LuaInstance() : - LuaState(nullptr), - m_memoryLimit(0), - m_memoryUsage(0), - m_timeLimit(1000), - m_level(0) - { - m_state = lua_newstate(MemoryAllocator, this); - lua_atpanic(m_state, AtPanic); - lua_sethook(m_state, TimeLimiter, LUA_MASKCOUNT, 1000); - } - - LuaInstance::LuaInstance(LuaInstance&& instance) : - LuaState(std::move(instance)) - { - std::swap(m_memoryLimit, instance.m_memoryLimit); - std::swap(m_memoryUsage, instance.m_memoryUsage); - std::swap(m_timeLimit, instance.m_timeLimit); - std::swap(m_clock, instance.m_clock); - std::swap(m_level, instance.m_level); - - if (m_state) - lua_setallocf(m_state, MemoryAllocator, this); - - if (instance.m_state) - lua_setallocf(instance.m_state, MemoryAllocator, &instance); - } - - LuaInstance::~LuaInstance() - { - if (m_state) - lua_close(m_state); - } - - void LuaInstance::LoadLibraries(LuaLibFlags libFlags) - { - // From luaL_openlibs - std::array libs; - std::size_t libCount = 0; - - libs[libCount++] = { "_G", luaopen_base }; - - if (libFlags & LuaLib_Coroutine) - libs[libCount++] = { LUA_COLIBNAME, luaopen_coroutine }; - - if (libFlags & LuaLib_Debug) - libs[libCount++] = { LUA_DBLIBNAME, luaopen_debug }; - - if (libFlags & LuaLib_Io) - libs[libCount++] = { LUA_IOLIBNAME, luaopen_io }; - - if (libFlags & LuaLib_Math) - libs[libCount++] = { LUA_MATHLIBNAME, luaopen_math }; - - if (libFlags & LuaLib_Os) - libs[libCount++] = { LUA_OSLIBNAME, luaopen_os }; - - if (libFlags & LuaLib_Package) - libs[libCount++] = { LUA_LOADLIBNAME, luaopen_package }; - - if (libFlags & LuaLib_String) - libs[libCount++] = { LUA_STRLIBNAME, luaopen_string }; - - if (libFlags & LuaLib_Table) - libs[libCount++] = { LUA_TABLIBNAME, luaopen_table }; - - if (libFlags & LuaLib_Utf8) - libs[libCount++] = { LUA_UTF8LIBNAME, luaopen_utf8 }; - - for (std::size_t i = 0; i < libCount; ++i) - { - luaL_requiref(m_state, libs[i].name, libs[i].func, 1); - lua_pop(m_state, 1); /* remove lib */ - } - } - - LuaInstance& LuaInstance::operator=(LuaInstance&& instance) - { - LuaState::operator=(std::move(instance)); - - std::swap(m_memoryLimit, instance.m_memoryLimit); - std::swap(m_memoryUsage, instance.m_memoryUsage); - std::swap(m_timeLimit, instance.m_timeLimit); - std::swap(m_clock, instance.m_clock); - std::swap(m_level, instance.m_level); - - if (m_state) - lua_setallocf(m_state, MemoryAllocator, this); - - if (instance.m_state) - lua_setallocf(instance.m_state, MemoryAllocator, &instance); - - return *this; - } - - void* LuaInstance::MemoryAllocator(void* ud, void* ptr, std::size_t osize, std::size_t nsize) - { - LuaInstance* instance = static_cast(ud); - std::size_t memoryLimit = instance->GetMemoryLimit(); - std::size_t memoryUsage = instance->GetMemoryUsage(); - - if (nsize == 0) - { - assert(memoryUsage >= osize); - - instance->SetMemoryUsage(memoryUsage - osize); - std::free(ptr); - - return nullptr; - } - else - { - std::size_t usage = memoryUsage + nsize; - if (ptr) - usage -= osize; - - if (memoryLimit != 0 && usage > memoryLimit) - { - NazaraError("Lua memory usage is over memory limit (" + String::Number(usage) + " > " + String::Number(memoryLimit) + ')'); - return nullptr; - } - - instance->SetMemoryUsage(usage); - - return std::realloc(ptr, nsize); - } - } - - void LuaInstance::TimeLimiter(lua_State* internalState, lua_Debug* debug) - { - NazaraUnused(debug); - - LuaInstance* instance; - lua_getallocf(internalState, reinterpret_cast(&instance)); - - if (instance->m_clock.GetMilliseconds() > instance->GetTimeLimit()) - luaL_error(internalState, "maximum execution time exceeded"); - } -} diff --git a/src/Nazara/Lua/LuaState.cpp b/src/Nazara/Lua/LuaState.cpp deleted file mode 100644 index c18367c30..000000000 --- a/src/Nazara/Lua/LuaState.cpp +++ /dev/null @@ -1,875 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Lua scripting module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - LuaType FromLuaType(int type) - { - switch (type) - { - case LUA_TBOOLEAN: - return LuaType_Boolean; - - case LUA_TFUNCTION: - return LuaType_Function; - - case LUA_TLIGHTUSERDATA: - return LuaType_LightUserdata; - - case LUA_TNIL: - return LuaType_Nil; - - case LUA_TNONE: - return LuaType_None; - - case LUA_TNUMBER: - return LuaType_Number; - - case LUA_TSTRING: - return LuaType_String; - - case LUA_TTABLE: - return LuaType_Table; - - case LUA_TTHREAD: - return LuaType_Thread; - - case LUA_TUSERDATA: - return LuaType_Userdata; - - default: - return LuaType_None; - } - } - - struct StreamData - { - Stream* stream; - char buffer[NAZARA_CORE_FILE_BUFFERSIZE]; - }; - - const char* StreamReader(lua_State* internalState, void* data, std::size_t* size) - { - NazaraUnused(internalState); - - StreamData* streamData = static_cast(data); - - if (streamData->stream->EndOfStream()) - return nullptr; - else - { - *size = streamData->stream->Read(streamData->buffer, NAZARA_CORE_FILE_BUFFERSIZE); - return streamData->buffer; - } - } - - int s_comparisons[] = { - LUA_OPEQ, // LuaComparison_Equality - LUA_OPLT, // LuaComparison_Less - LUA_OPLE // LuaComparison_LessOrEqual - }; - - static_assert(sizeof(s_comparisons)/sizeof(int) == LuaComparison_Max+1, "Lua comparison array is incomplete"); - - int s_operations[] = { - LUA_OPADD, // LuaOperation_Addition - LUA_OPBAND, // LuaOperation_BitwiseAnd - LUA_OPSHL, // LuaOperation_BitwiseLeftShift - LUA_OPBNOT, // LuaOperation_BitwiseNot - LUA_OPBOR, // LuaOperation_BitwiseOr - LUA_OPSHR, // LuaOperation_BitwiseRightShift - LUA_OPBXOR, // LuaOperation_BitwiseXOr - LUA_OPDIV, // LuaOperation_Division - LUA_OPPOW, // LuaOperation_Exponentiation - LUA_OPIDIV, // LuaOperation_FloorDivision - LUA_OPMUL, // LuaOperation_Multiplication - LUA_OPMOD, // LuaOperation_Modulo - LUA_OPUNM, // LuaOperation_Negation - LUA_OPSUB // LuaOperation_Substraction - }; - - static_assert(sizeof(s_operations)/sizeof(int) == LuaOperation_Max+1, "Lua operation array is incomplete"); - - int s_types[] = { - LUA_TBOOLEAN, // LuaType_Boolean - LUA_TFUNCTION, // LuaType_Function - LUA_TLIGHTUSERDATA, // LuaType_LightUserdata - LUA_TNIL, // LuaType_Nil - LUA_TNUMBER, // LuaType_Number - LUA_TNONE, // LuaType_None - LUA_TSTRING, // LuaType_String - LUA_TTABLE, // LuaType_Table - LUA_TTHREAD, // LuaType_Thread - LUA_TUSERDATA // LuaType_Userdata - }; - - static_assert(sizeof(s_types)/sizeof(int) == LuaType_Max+1, "Lua type array is incomplete"); - } - - void LuaState::ArgCheck(bool condition, unsigned int argNum, const char* error) const - { - luaL_argcheck(m_state, condition, argNum, error); - } - - void LuaState::ArgCheck(bool condition, unsigned int argNum, const String& error) const - { - luaL_argcheck(m_state, condition, argNum, error.GetConstBuffer()); - } - - int LuaState::ArgError(unsigned int argNum, const char* error) const - { - return luaL_argerror(m_state, argNum, error); - } - - int LuaState::ArgError(unsigned int argNum, const String& error) const - { - return luaL_argerror(m_state, argNum, error.GetConstBuffer()); - } - - bool LuaState::Call(unsigned int argCount) - { - return Run(argCount, LUA_MULTRET, 0); - } - - bool LuaState::Call(unsigned int argCount, unsigned int resultCount) - { - return Run(argCount, resultCount, 0); - } - - bool LuaState::CallWithHandler(unsigned int argCount, int errorHandler) - { - return Run(argCount, LUA_MULTRET, errorHandler); - } - - bool LuaState::CallWithHandler(unsigned int argCount, unsigned int resultCount, int errorHandler) - { - return Run(argCount, resultCount, errorHandler); - } - - void LuaState::CheckAny(int index) const - { - luaL_checkany(m_state, index); - } - - bool LuaState::CheckBoolean(int index) const - { - if (lua_isnoneornil(m_state, index)) - { - const char* msg = lua_pushfstring(m_state, "%s expected, got %s", lua_typename(m_state, LUA_TBOOLEAN), luaL_typename(m_state, index)); - luaL_argerror(m_state, index, msg); // Lance une exception - return false; - } - - return lua_toboolean(m_state, index) != 0; - } - - bool LuaState::CheckBoolean(int index, bool defValue) const - { - if (lua_isnoneornil(m_state, index)) - return defValue; - - return lua_toboolean(m_state, index) != 0; - } - - long long LuaState::CheckInteger(int index) const - { - return luaL_checkinteger(m_state, index); - } - - long long LuaState::CheckInteger(int index, long long defValue) const - { - return luaL_optinteger(m_state, index, defValue); - } - - double LuaState::CheckNumber(int index) const - { - return luaL_checknumber(m_state, index); - } - - double LuaState::CheckNumber(int index, double defValue) const - { - return luaL_optnumber(m_state, index, defValue); - } - - void LuaState::CheckStack(int space, const char* error) const - { - luaL_checkstack(m_state, space, error); - } - - void LuaState::CheckStack(int space, const String& error) const - { - CheckStack(space, error.GetConstBuffer()); - } - - const char* LuaState::CheckString(int index, std::size_t* length) const - { - return luaL_checklstring(m_state, index, length); - } - - const char* LuaState::CheckString(int index, const char* defValue, std::size_t* length) const - { - return luaL_optlstring(m_state, index, defValue, length); - } - - void LuaState::CheckType(int index, LuaType type) const - { - #ifdef NAZARA_DEBUG - if (type > LuaType_Max) - { - NazaraError("Lua type out of enum"); - return; - } - #endif - - luaL_checktype(m_state, index, s_types[type]); - } - - void* LuaState::CheckUserdata(int index, const char* tname) const - { - return luaL_checkudata(m_state, index, tname); - } - - void* LuaState::CheckUserdata(int index, const String& tname) const - { - return luaL_checkudata(m_state, index, tname.GetConstBuffer()); - } - - bool LuaState::Compare(int index1, int index2, LuaComparison comparison) const - { - #ifdef NAZARA_DEBUG - if (comparison > LuaComparison_Max) - { - NazaraError("Lua comparison out of enum"); - return false; - } - #endif - - return (lua_compare(m_state, index1, index2, s_comparisons[comparison]) != 0); - } - - void LuaState::Compute(LuaOperation operation) const - { - #ifdef NAZARA_DEBUG - if (operation > LuaOperation_Max) - { - NazaraError("Lua operation out of enum"); - return; - } - #endif - - lua_arith(m_state, s_operations[operation]); - } - - void LuaState::Concatenate(int count) const - { - lua_concat(m_state, count); - } - - int LuaState::CreateReference() - { - return luaL_ref(m_state, LUA_REGISTRYINDEX); - } - - void LuaState::DestroyReference(int ref) - { - luaL_unref(m_state, LUA_REGISTRYINDEX, ref); - } - - String LuaState::DumpStack() const - { - StringStream stream; - unsigned int stackTop = GetStackTop(); - stream << stackTop << " entries\n"; - - for (unsigned int i = 1; i <= stackTop; ++i) - { - stream << i << ": "; - switch (GetType(i)) - { - case LuaType_Boolean: - stream << "Boolean(" << ToBoolean(i) << ')'; - break; - - case LuaType_Function: - stream << "Function(" << ToPointer(i) << ')'; - break; - - case LuaType_LightUserdata: - case LuaType_Userdata: - stream << "Userdata(" << ToUserdata(i) << ')'; - break; - - case LuaType_Nil: - stream << "Nil"; - break; - - case LuaType_None: - stream << "None"; - break; - - case LuaType_Number: - stream << "Number(" << ToNumber(i) << ')'; - break; - - case LuaType_String: - stream << "String(" << ToString(i) << ')'; - break; - - case LuaType_Table: - stream << "Table(" << ToPointer(i) << ')'; - break; - - case LuaType_Thread: - stream << "Thread(" << ToPointer(i) << ')'; - break; - - default: - stream << "Unknown(" << ToPointer(i) << ')'; - break; - } - - stream << '\n'; - } - - return stream.ToString(); - } - - void LuaState::Error(const char* message) const - { - luaL_error(m_state, message); - } - - void LuaState::Error(const String& message) const - { - luaL_error(m_state, message.GetConstBuffer()); - } - - bool LuaState::Execute(const String& code, int errorHandler) - { - if (code.IsEmpty()) - return true; - - if (!Load(code)) - return false; - - return CallWithHandler(errorHandler, 0); - } - - bool LuaState::ExecuteFromFile(const std::filesystem::path& filePath, int errorHandler) - { - if (!LoadFromFile(filePath)) - return false; - - return CallWithHandler(errorHandler, 0); - } - - bool LuaState::ExecuteFromMemory(const void* data, std::size_t size, int errorHandler) - { - MemoryView stream(data, size); - return ExecuteFromStream(stream, errorHandler); - } - - bool LuaState::ExecuteFromStream(Stream& stream, int errorHandler) - { - if (!LoadFromStream(stream)) - return false; - - return CallWithHandler(errorHandler, 0); - } - - int LuaState::GetAbsIndex(int index) const - { - return lua_absindex(m_state, index); - } - - LuaType LuaState::GetField(const char* fieldName, int tableIndex) const - { - return FromLuaType(lua_getfield(m_state, tableIndex, fieldName)); - } - - LuaType LuaState::GetField(const String& fieldName, int tableIndex) const - { - return FromLuaType(lua_getfield(m_state, tableIndex, fieldName.GetConstBuffer())); - } - - LuaType LuaState::GetGlobal(const char* name) const - { - return FromLuaType(lua_getglobal(m_state, name)); - } - - LuaType LuaState::GetGlobal(const String& name) const - { - return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer())); - } - - LuaType LuaState::GetMetatable(const char* tname) const - { - return FromLuaType(luaL_getmetatable(m_state, tname)); - } - - LuaType LuaState::GetMetatable(const String& tname) const - { - return FromLuaType(luaL_getmetatable(m_state, tname.GetConstBuffer())); - } - - bool LuaState::GetMetatable(int index) const - { - return lua_getmetatable(m_state, index) != 0; - } - - unsigned int LuaState::GetStackTop() const - { - return static_cast(lua_gettop(m_state)); - } - - LuaType LuaState::GetTable(int index) const - { - return FromLuaType(lua_gettable(m_state, index)); - } - - LuaType LuaState::GetTableRaw(int index) const - { - return FromLuaType(lua_rawget(m_state, index)); - } - - LuaType LuaState::GetType(int index) const - { - return FromLuaType(lua_type(m_state, index)); - } - - const char* LuaState::GetTypeName(LuaType type) const - { - #ifdef NAZARA_DEBUG - if (type > LuaType_Max) - { - NazaraError("Lua type out of enum"); - return nullptr; - } - #endif - - return lua_typename(m_state, s_types[type]); - } - - void LuaState::Insert(int index) const - { - lua_insert(m_state, index); - } - - bool LuaState::IsOfType(int index, LuaType type) const - { - switch (type) - { - case LuaType_Boolean: - return lua_isboolean(m_state, index) != 0; - - case LuaType_Function: - return lua_isfunction(m_state, index) != 0; - - case LuaType_LightUserdata: - return lua_islightuserdata(m_state, index) != 0; - - case LuaType_Nil: - return lua_isnil(m_state, index) != 0; - - case LuaType_None: - return lua_isnone(m_state, index) != 0; - - case LuaType_Number: - return lua_isnumber(m_state, index) != 0; - - case LuaType_String: - return lua_isstring(m_state, index) != 0; - - case LuaType_Table: - return lua_istable(m_state, index) != 0; - - case LuaType_Thread: - return lua_isthread(m_state, index) != 0; - - case LuaType_Userdata: - return lua_isuserdata(m_state, index) != 0; - } - - NazaraError("Lua type not handled (0x" + String::Number(type, 16) + ')'); - return false; - } - - bool LuaState::IsOfType(int index, const char* tname) const - { - void* ud = luaL_testudata(m_state, index, tname); - return ud != nullptr; - } - - bool LuaState::IsOfType(int index, const String& tname) const - { - return IsOfType(index, tname.GetConstBuffer()); - } - - bool LuaState::IsValid(int index) const - { - return lua_isnoneornil(m_state, index) == 0; - } - - bool LuaState::Load(const String& code) - { - if (luaL_loadstring(m_state, code.GetConstBuffer()) != 0) - { - m_lastError = lua_tostring(m_state, -1); - lua_pop(m_state, 1); - - return false; - } - - return true; - } - - bool LuaState::LoadFromFile(const std::filesystem::path& filePath) - { - File file(filePath); - if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) - { - NazaraError("Failed to open file"); - return false; - } - - std::size_t length = static_cast(file.GetSize()); - - String source(length, '\0'); - - if (file.Read(&source[0], length) != length) - { - NazaraError("Failed to read file"); - return false; - } - - file.Close(); - - return Load(source); - } - - bool LuaState::LoadFromMemory(const void* data, std::size_t size) - { - MemoryView stream(data, size); - return LoadFromStream(stream); - } - - bool LuaState::LoadFromStream(Stream& stream) - { - StreamData data; - data.stream = &stream; - - if (lua_load(m_state, StreamReader, &data, "C++", nullptr) != 0) - { - m_lastError = lua_tostring(m_state, -1); - lua_pop(m_state, 1); - - return false; - } - - return true; - } - - long long LuaState::Length(int index) const - { - return luaL_len(m_state, index); - } - - std::size_t LuaState::LengthRaw(int index) const - { - return lua_rawlen(m_state, index); - } - - void LuaState::MoveTo(LuaState* instance, int n) const - { - lua_xmove(m_state, instance->m_state, n); - } - - LuaCoroutine LuaState::NewCoroutine() - { - lua_State* thread = lua_newthread(m_state); - int ref = luaL_ref(m_state, LUA_REGISTRYINDEX); - - return LuaCoroutine(thread, ref); - } - - bool LuaState::NewMetatable(const char* str) - { - return luaL_newmetatable(m_state, str) != 0; - } - - bool LuaState::NewMetatable(const String& str) - { - return luaL_newmetatable(m_state, str.GetConstBuffer()) != 0; - } - - bool LuaState::Next(int index) const - { - return lua_next(m_state, index) != 0; - } - - void LuaState::Pop(unsigned int n) const - { - lua_pop(m_state, static_cast(n)); - } - - void LuaState::PushBoolean(bool value) const - { - lua_pushboolean(m_state, (value) ? 1 : 0); - } - - void LuaState::PushCFunction(LuaCFunction func, unsigned int upvalueCount) const - { - lua_pushcclosure(m_state, func, upvalueCount); - } - - void LuaState::PushFunction(LuaFunction func) const - { - LuaFunction* luaFunc = static_cast(lua_newuserdata(m_state, sizeof(LuaFunction))); - PlacementNew(luaFunc, std::move(func)); - - lua_pushcclosure(m_state, ProxyFunc, 1); - } - - void LuaState::PushInteger(long long value) const - { - lua_pushinteger(m_state, value); - } - - void LuaState::PushLightUserdata(void* value) const - { - lua_pushlightuserdata(m_state, value); - } - - void LuaState::PushMetatable(const char* str) const - { - luaL_getmetatable(m_state, str); - } - - void LuaState::PushMetatable(const String& str) const - { - luaL_getmetatable(m_state, str.GetConstBuffer()); - } - - void LuaState::PushNil() const - { - lua_pushnil(m_state); - } - - void LuaState::PushNumber(double value) const - { - lua_pushnumber(m_state, value); - } - - void LuaState::PushReference(int ref) const - { - lua_rawgeti(m_state, LUA_REGISTRYINDEX, ref); - } - - void LuaState::PushString(const char* str) const - { - lua_pushstring(m_state, str); - } - - void LuaState::PushString(const char* str, std::size_t size) const - { - lua_pushlstring(m_state, str, size); - } - - void LuaState::PushString(const String& str) const - { - lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize()); - } - - void LuaState::PushTable(std::size_t sequenceElementCount, std::size_t arrayElementCount) const - { - constexpr std::size_t maxInt = std::numeric_limits::max(); - lua_createtable(m_state, static_cast(std::min(sequenceElementCount, maxInt)), static_cast(std::min(arrayElementCount, maxInt))); - } - - void* LuaState::PushUserdata(std::size_t size) const - { - return lua_newuserdata(m_state, size); - } - - void LuaState::PushValue(int index) const - { - lua_pushvalue(m_state, index); - } - - bool LuaState::RawEqual(int index1, int index2) const - { - return lua_rawequal(m_state, index1, index2); - } - - void LuaState::Remove(int index) const - { - lua_remove(m_state, index); - } - - void LuaState::Replace(int index) const - { - lua_replace(m_state, index); - } - - void LuaState::SetField(const char* name, int tableIndex) const - { - lua_setfield(m_state, tableIndex, name); - } - - void LuaState::SetField(const String& name, int tableIndex) const - { - lua_setfield(m_state, tableIndex, name.GetConstBuffer()); - } - - void LuaState::SetGlobal(const char* name) - { - lua_setglobal(m_state, name); - } - - void LuaState::SetGlobal(const String& name) - { - lua_setglobal(m_state, name.GetConstBuffer()); - } - - void LuaState::SetMetatable(const char* tname) const - { - luaL_setmetatable(m_state, tname); - } - - void LuaState::SetMetatable(const String& tname) const - { - luaL_setmetatable(m_state, tname.GetConstBuffer()); - } - - void LuaState::SetMetatable(int index) const - { - lua_setmetatable(m_state, index); - } - - void LuaState::SetTable(int index) const - { - lua_settable(m_state, index); - } - - void LuaState::SetTableRaw(int index) const - { - lua_rawset(m_state, index); - } - - bool LuaState::ToBoolean(int index) const - { - return lua_toboolean(m_state, index) != 0; - } - - long long LuaState::ToInteger(int index, bool* succeeded) const - { - int success; - long long result = lua_tointegerx(m_state, index, &success); - - if (succeeded) - *succeeded = (success != 0); - - return result; - } - - double LuaState::ToNumber(int index, bool* succeeded) const - { - int success; - double result = lua_tonumberx(m_state, index, &success); - - if (succeeded) - *succeeded = (success != 0); - - return result; - } - - const void* LuaState::ToPointer(int index) const - { - return lua_topointer(m_state, index); - } - - const char* LuaState::ToString(int index, std::size_t* length) const - { - return lua_tolstring(m_state, index, length); - } - - void* LuaState::ToUserdata(int index) const - { - return lua_touserdata(m_state, index); - } - - void* LuaState::ToUserdata(int index, const char* tname) const - { - return luaL_testudata(m_state, index, tname); - } - - void* LuaState::ToUserdata(int index, const String& tname) const - { - return luaL_testudata(m_state, index, tname.GetConstBuffer()); - } - - void LuaState::Traceback(const char* message, int level) - { - luaL_traceback(m_state, m_state, message, level); - } - - bool LuaState::Run(int argCount, int resultCount, int errHandler) - { - LuaInstance& instance = GetInstance(m_state); - - if (instance.m_level++ == 0) - instance.m_clock.Restart(); - - int status = lua_pcall(m_state, argCount, resultCount, errHandler); - - instance.m_level--; - - if (status != 0) - { - m_lastError = lua_tostring(m_state, -1); - lua_pop(m_state, 1); - - return false; - } - - return true; - } - - int LuaState::GetIndexOfUpValue(int upValue) - { - return lua_upvalueindex(upValue); - } - - LuaInstance& LuaState::GetInstance(lua_State* internalState) - { - LuaInstance* instance; - lua_getallocf(internalState, reinterpret_cast(&instance)); - - return *instance; - } - - int LuaState::ProxyFunc(lua_State* internalState) - { - LuaFunction& func = *static_cast(lua_touserdata(internalState, lua_upvalueindex(1))); - LuaState state = GetState(internalState); - - return func(state); - } - -} diff --git a/src/Nazara/Noise/Debug/NewOverload.cpp b/src/Nazara/Noise/Debug/NewOverload.cpp deleted file mode 100644 index d761e94b8..000000000 --- a/src/Nazara/Noise/Debug/NewOverload.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_NOISE_MANAGE_MEMORY - -#include -#include // Nécessaire ? - -void* operator new(std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, true); -} - -#endif // NAZARA_NOISE_MANAGE_MEMORY diff --git a/src/Nazara/Noise/FBM.cpp b/src/Nazara/Noise/FBM.cpp deleted file mode 100644 index 95d79c2cd..000000000 --- a/src/Nazara/Noise/FBM.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - FBM::FBM(const NoiseBase & source): m_source(source) - { - } - - ///TODO: Handle with variadic templates - float FBM::Get(float x, float y, float scale) const - { - float value = 0.f; - for(int i = 0; i < m_octaves; ++i) - { - value += m_source.Get(x, y, scale) * m_exponent_array.at(i); - scale *= m_lacunarity; - } - - float remainder = m_octaves - static_cast(m_octaves); - if(std::fabs(remainder) > 0.01f) - value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast(m_octaves-1)); - - return value / m_sum; - } - - float FBM::Get(float x, float y, float z, float scale) const - { - float value = 0.f; - for(int i = 0; i < m_octaves; ++i) - { - value += m_source.Get(x, y, z, scale) * m_exponent_array.at(i); - scale *= m_lacunarity; - } - - float remainder = m_octaves - static_cast(m_octaves); - if(std::fabs(remainder) > 0.01f) - value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast(m_octaves-1)); - - return value / m_sum; - } - - float FBM::Get(float x, float y, float z, float w, float scale) const - { - float value = 0.f; - for(int i = 0; i < m_octaves; ++i) - { - value += m_source.Get(x, y, z, w, scale) * m_exponent_array.at(i); - scale *= m_lacunarity; - } - - float remainder = m_octaves - static_cast(m_octaves); - if(std::fabs(remainder) > 0.01f) - value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast(m_octaves-1)); - - return value / m_sum; - } -} diff --git a/src/Nazara/Noise/HybridMultiFractal.cpp b/src/Nazara/Noise/HybridMultiFractal.cpp deleted file mode 100644 index 86ae2e9cd..000000000 --- a/src/Nazara/Noise/HybridMultiFractal.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - HybridMultiFractal::HybridMultiFractal(const NoiseBase & source) : - m_source(source) - { - } - - float HybridMultiFractal::Get(float x, float y, float scale) const - { - float offset = 1.0f; - float value = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(0); - float weight = value; - float signal = 0.f; - - scale *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (weight > 1.f) - weight = 1.f; - - signal = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(i); - value += weight * signal; - weight *= signal; - scale *= m_lacunarity; - } - - float remainder = m_octaves - static_cast(m_octaves); - - if (remainder > 0.f) - value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast(m_octaves-1)); - - return value / m_sum - offset; - } - - float HybridMultiFractal::Get(float x, float y, float z, float scale) const - { - float offset = 1.0f; - float value = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(0); - float weight = value; - float signal = 0.f; - - scale *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (weight > 1.f) - weight = 1.f; - - signal = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(i); - value += weight * signal; - weight *= signal; - scale *= m_lacunarity; - } - - float remainder = m_octaves - static_cast(m_octaves); - - if (remainder > 0.f) - value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast(m_octaves-1)); - - return value / m_sum - offset; - } - - float HybridMultiFractal::Get(float x, float y, float z, float w, float scale) const - { - float offset = 1.0f; - float value = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(0); - float weight = value; - float signal = 0.f; - - scale *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (weight > 1.f) - weight = 1.f; - - signal = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(i); - value += weight * signal; - weight *= signal; - scale *= m_lacunarity; - } - - float remainder = m_octaves - static_cast(m_octaves); - - if (remainder > 0.f) - value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast(m_octaves-1)); - - return value / m_sum - offset; - } -} diff --git a/src/Nazara/Noise/MixerBase.cpp b/src/Nazara/Noise/MixerBase.cpp deleted file mode 100644 index f3fbc0f8a..000000000 --- a/src/Nazara/Noise/MixerBase.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - MixerBase::MixerBase() : - m_hurst(1.2f), - m_lacunarity(5.f), - m_octaves(3.f) - { - Recompute(); - } - - float MixerBase::GetHurstParameter() const - { - return m_hurst; - } - - float MixerBase::GetLacunarity() const - { - return m_lacunarity; - } - - float MixerBase::GetOctaveNumber() const - { - return m_octaves; - } - - void MixerBase::SetParameters(float hurst, float lacunarity, float octaves) - { - m_hurst = hurst; - m_lacunarity = lacunarity; - m_octaves = octaves; - - Recompute(); - } - - void MixerBase::Recompute() - { - float frequency = 1.0; - m_sum = 0.f; - m_exponent_array.clear(); - - for (int i(0) ; i < static_cast(m_octaves) ; ++i) - { - m_exponent_array.push_back(std::pow( frequency, -m_hurst )); - frequency *= m_lacunarity; - m_sum += m_exponent_array.at(i); - } - } -} diff --git a/src/Nazara/Noise/Noise.cpp b/src/Nazara/Noise/Noise.cpp deleted file mode 100644 index 880527834..000000000 --- a/src/Nazara/Noise/Noise.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - bool Noise::Initialize() - { - if (s_moduleReferenceCounter > 0) - { - s_moduleReferenceCounter++; - return true; // Déjà initialisé - } - - // Initialisation des dépendances - if (!Core::Initialize()) - { - NazaraError("Failed to initialize core module"); - Uninitialize(); - - return false; - } - - s_moduleReferenceCounter++; - - // Initialisation du module - - NazaraNotice("Initialized: Noise module"); - return true; - } - - bool Noise::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - void Noise::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Le module est soit encore utilisé, soit pas initialisé - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - // Libération du module - s_moduleReferenceCounter = 0; - - NazaraNotice("Uninitialized: Noise module"); - - // Libération des dépendances - Core::Uninitialize(); - } - - unsigned int Noise::s_moduleReferenceCounter = 0; -} diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp deleted file mode 100644 index 0a4f09505..000000000 --- a/src/Nazara/Noise/NoiseBase.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - NoiseBase::NoiseBase(unsigned int seed) : - m_scale(0.05f) - { - SetSeed(seed); - - // Fill permutations with initial values - std::iota(m_permutations.begin(), m_permutations.begin() + 256, 0); - } - - float NoiseBase::GetScale() - { - return m_scale; - } - - void NoiseBase::SetScale(float scale) - { - m_scale = scale; - } - - void NoiseBase::SetSeed(unsigned int seed) - { - m_randomEngine.seed(seed); - } - - void NoiseBase::Shuffle() - { - std::shuffle(m_permutations.begin(), m_permutations.begin() + 256, m_randomEngine); - - for(std::size_t i = 1; i < (m_permutations.size() / 256); ++i) - std::copy(m_permutations.begin(), m_permutations.begin() + 256, m_permutations.begin() + 256 * i); - } - - std::array NoiseBase::s_gradients2 = - { - { - {1.f, 1.f}, {-1.f, 1.f}, {1.f, -1.f}, {-1.f, -1.f}, - {1.f, 0.f}, {-1.f, 0.f}, {0.f, 1.f}, { 0.f, -1.f} - } - }; - - std::array NoiseBase::s_gradients3 = - { - { - {1.f,1.f,0.f}, {-1.f, 1.f, 0.f}, {1.f, -1.f, 0.f}, {-1.f, -1.f, 0.f}, - {1.f,0.f,1.f}, {-1.f, 0.f, 1.f}, {1.f, 0.f, -1.f}, {-1.f, 0.f, -1.f}, - {0.f,1.f,1.f}, { 0.f, -1.f, 1.f}, {0.f, 1.f, -1.f}, {0.f, -1.f, -1.f}, - {1.f,1.f,0.f}, {-1.f, 1.f, 0.f}, {0.f, -1.f, 1.f}, {0.f, -1.f, -1.f} - } - }; - - std::array NoiseBase::s_gradients4 = - { - { - {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, - {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, - {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, - {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, - {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, - {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, - {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, - {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} - } - }; -} diff --git a/src/Nazara/Noise/NoiseTools.cpp b/src/Nazara/Noise/NoiseTools.cpp deleted file mode 100644 index 5f6274357..000000000 --- a/src/Nazara/Noise/NoiseTools.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - int fastfloor(float n) - { - return (n >= 0) ? static_cast(n) : static_cast(n-1); - } - - int JenkinsHash(int a, int b, int c) - { - a = a-b; a = a - c; a = a^(static_cast(c) >> 13); - b = b-c; b = b - a; b = b^(a << 8); - c = c-a; c = c - b; c = c^(static_cast(b) >> 13); - a = a-b; a = a - c; a = a^(static_cast(c) >> 12); - b = b-c; b = b - a; b = b^(a << 16); - c = c-a; c = c - b; c = c^(static_cast(b) >> 5); - a = a-b; a = a - c; a = a^(static_cast(c) >> 3); - b = b-c; b = b - a; b = b^(a << 10); - c = c-a; c = c - b; c = c^(static_cast(b) >> 15); - return c; - } -} diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp deleted file mode 100644 index d80bf7c84..000000000 --- a/src/Nazara/Noise/Perlin.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - Perlin::Perlin(unsigned int seed) : - Perlin() - { - SetSeed(seed); - Shuffle(); - } - - float Perlin::Get(float x, float y, float scale) const - { - float xc, yc; - int x0, y0; - int gi0,gi1,gi2,gi3; - int ii, jj; - - float s,t,u,v; - float Cx,Cy; - float Li1, Li2; - float tempx,tempy; - - xc = x * scale; - yc = y * scale; - - x0 = fastfloor(xc); - y0 = fastfloor(yc); - - ii = x0 & 255; - jj = y0 & 255; - - gi0 = m_permutations[ii + m_permutations[jj]] & 7; - gi1 = m_permutations[ii + 1 + m_permutations[jj]] & 7; - gi2 = m_permutations[ii + m_permutations[jj + 1]] & 7; - gi3 = m_permutations[ii + 1 + m_permutations[jj + 1]] & 7; - - tempx = xc - x0; - tempy = yc - y0; - - Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); - Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); - - s = s_gradients2[gi0][0]*tempx + s_gradients2[gi0][1]*tempy; - - tempx = xc - (x0 + 1); - t = s_gradients2[gi1][0]*tempx + s_gradients2[gi1][1]*tempy; - - tempy = yc - (y0 + 1); - v = s_gradients2[gi3][0]*tempx + s_gradients2[gi3][1]*tempy; - - tempx = xc - x0; - u = s_gradients2[gi2][0]*tempx + s_gradients2[gi2][1]*tempy; - - Li1 = s + Cx*(t-s); - Li2 = u + Cx*(v-u); - - return Li1 + Cy*(Li2-Li1); - } - - float Perlin::Get(float x, float y, float z, float scale) const - { - float xc, yc, zc; - int x0, y0, z0; - int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; - int ii, jj, kk; - - float Li1,Li2,Li3,Li4,Li5,Li6; - float s[2],t[2],u[2],v[2]; - float Cx,Cy,Cz; - float tempx,tempy,tempz; - - xc = x * scale; - yc = y * scale; - zc = z * scale; - - x0 = fastfloor(xc); - y0 = fastfloor(yc); - z0 = fastfloor(zc); - - ii = x0 & 255; - jj = y0 & 255; - kk = z0 & 255; - - gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk]]] & 15; - gi1 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk]]] & 15; - gi2 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk]]] & 15; - gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk]]] & 15; - - gi4 = m_permutations[ii + m_permutations[jj + m_permutations[kk + 1]]] & 15; - gi5 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + 1]]] & 15; - gi6 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1]]] & 15; - gi7 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1]]] & 15; - - tempx = xc - x0; - tempy = yc - y0; - tempz = zc - z0; - - Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); - Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); - Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); - - s[0] = s_gradients3[gi0][0]*tempx + s_gradients3[gi0][1]*tempy + s_gradients3[gi0][2]*tempz; - - tempx = xc - (x0 + 1); - t[0] = s_gradients3[gi1][0]*tempx + s_gradients3[gi1][1]*tempy + s_gradients3[gi1][2]*tempz; - - tempy = yc - (y0 + 1); - v[0] = s_gradients3[gi3][0]*tempx + s_gradients3[gi3][1]*tempy + s_gradients3[gi3][2]*tempz; - - tempx = xc - x0; - u[0] = s_gradients3[gi2][0]*tempx + s_gradients3[gi2][1]*tempy + s_gradients3[gi2][2]*tempz; - - tempy = yc - y0; - tempz = zc - (z0 + 1); - s[1] = s_gradients3[gi4][0]*tempx + s_gradients3[gi4][1]*tempy + s_gradients3[gi4][2]*tempz; - - tempx = xc - (x0 + 1); - t[1] = s_gradients3[gi5][0]*tempx + s_gradients3[gi5][1]*tempy + s_gradients3[gi5][2]*tempz; - - tempy = yc - (y0 + 1); - v[1] = s_gradients3[gi7][0]*tempx + s_gradients3[gi7][1]*tempy + s_gradients3[gi7][2]*tempz; - - tempx = xc - x0; - u[1] = s_gradients3[gi6][0]*tempx + s_gradients3[gi6][1]*tempy + s_gradients3[gi6][2]*tempz; - - Li1 = s[0] + Cx*(t[0]-s[0]); - Li2 = u[0] + Cx*(v[0]-u[0]); - Li3 = s[1] + Cx*(t[1]-s[1]); - Li4 = u[1] + Cx*(v[1]-u[1]); - - Li5 = Li1 + Cy * (Li2-Li1); - Li6 = Li3 + Cy * (Li4-Li3); - - return Li5 + Cz * (Li6-Li5); - } - - float Perlin::Get(float x, float y, float z, float w, float scale) const - { - float xc,yc,zc,wc; - int x0,y0,z0,w0; - int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; - int ii,jj,kk,ll; - - float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; - float s[4],t[4],u[4],v[4]; - float Cx,Cy,Cz,Cw; - - float tempx,tempy,tempz,tempw; - - xc = x * scale; - yc = y * scale; - zc = z * scale; - wc = w * scale; - - x0 = fastfloor(xc); - y0 = fastfloor(yc); - z0 = fastfloor(zc); - w0 = fastfloor(wc); - - ii = x0 & 255; - jj = y0 & 255; - kk = z0 & 255; - ll = w0 & 255; - - gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll]]]] & 31; - gi1 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + m_permutations[ll]]]] & 31; - gi2 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll]]]] & 31; - gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll]]]] & 31; - - gi4 = m_permutations[ii + m_permutations[jj + + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; - gi5 = m_permutations[ii + 1 + m_permutations[jj + + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; - gi6 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; - gi7 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; - - gi8 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll + 1]]]] & 31; - gi9 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + m_permutations[ll + 1]]]] & 31; - gi10 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll + 1]]]] & 31; - gi11 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll + 1]]]] & 31; - - gi12 = m_permutations[ii + m_permutations[jj + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; - gi13 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; - gi14 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; - gi15 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; - - tempx = xc - x0; - tempy = yc - y0; - tempz = zc - z0; - tempw = wc - w0; - - Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); - Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); - Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); - Cw = tempw * tempw * tempw * (tempw * (tempw * 6 - 15) + 10); - - s[0] = s_gradients4[gi0][0]*tempx + s_gradients4[gi0][1]*tempy + s_gradients4[gi0][2]*tempz + s_gradients4[gi0][3]*tempw; - - tempx = xc - (x0+1); - t[0] = s_gradients4[gi1][0]*tempx + s_gradients4[gi1][1]*tempy + s_gradients4[gi1][2]*tempz + s_gradients4[gi1][3]*tempw; - - tempy = yc - (y0+1); - v[0] = s_gradients4[gi3][0]*tempx + s_gradients4[gi3][1]*tempy + s_gradients4[gi3][2]*tempz + s_gradients4[gi3][3]*tempw; - - tempx = xc - x0; - u[0] = s_gradients4[gi2][0]*tempx + s_gradients4[gi2][1]*tempy + s_gradients4[gi2][2]*tempz + s_gradients4[gi2][3]*tempw; - - tempy = yc - y0; - tempz = zc - (z0+1); - s[1] = s_gradients4[gi4][0]*tempx + s_gradients4[gi4][1]*tempy + s_gradients4[gi4][2]*tempz + s_gradients4[gi4][3]*tempw; - - tempx = xc - (x0+1); - t[1] = s_gradients4[gi5][0]*tempx + s_gradients4[gi5][1]*tempy + s_gradients4[gi5][2]*tempz + s_gradients4[gi5][3]*tempw; - - tempy = yc - (y0+1); - v[1] = s_gradients4[gi7][0]*tempx + s_gradients4[gi7][1]*tempy + s_gradients4[gi7][2]*tempz + s_gradients4[gi7][3]*tempw; - - tempx = xc - x0; - u[1] = s_gradients4[gi6][0]*tempx + s_gradients4[gi6][1]*tempy + s_gradients4[gi6][2]*tempz + s_gradients4[gi6][3]*tempw; - - - tempy = yc - y0; - tempz = zc - z0; - tempw = wc - (w0+1); - s[2] = s_gradients4[gi8][0]*tempx + s_gradients4[gi8][1]*tempy + s_gradients4[gi8][2]*tempz + s_gradients4[gi8][3]*tempw; - - tempx = xc - (x0+1); - t[2] = s_gradients4[gi9][0]*tempx + s_gradients4[gi9][1]*tempy + s_gradients4[gi9][2]*tempz + s_gradients4[gi9][3]*tempw; - - tempy = yc - (y0+1); - v[2] = s_gradients4[gi11][0]*tempx + s_gradients4[gi11][1]*tempy + s_gradients4[gi11][2]*tempz + s_gradients4[gi11][3]*tempw; - - tempx = xc - x0; - u[2] = s_gradients4[gi10][0]*tempx + s_gradients4[gi10][1]*tempy + s_gradients4[gi10][2]*tempz + s_gradients4[gi10][3]*tempw; - - - tempy = yc - y0; - tempz = zc - (z0+1); - s[3] = s_gradients4[gi12][0]*tempx + s_gradients4[gi12][1]*tempy + s_gradients4[gi12][2]*tempz + s_gradients4[gi12][3]*tempw; - - tempx = xc - (x0+1); - t[3] = s_gradients4[gi13][0]*tempx + s_gradients4[gi13][1]*tempy + s_gradients4[gi13][2]*tempz + s_gradients4[gi13][3]*tempw; - - tempy = yc - (y0+1); - v[3] = s_gradients4[gi15][0]*tempx + s_gradients4[gi15][1]*tempy + s_gradients4[gi15][2]*tempz + s_gradients4[gi15][3]*tempw; - - tempx = xc - x0; - u[3] = s_gradients4[gi14][0]*tempx + s_gradients4[gi14][1]*tempy + s_gradients4[gi14][2]*tempz + s_gradients4[gi14][3]*tempw; - - Li1 = s[0] + Cx*(t[0]-s[0]); - Li2 = u[0] + Cx*(v[0]-u[0]); - Li3 = s[1] + Cx*(t[1]-s[1]); - Li4 = u[1] + Cx*(v[1]-u[1]); - Li5 = s[2] + Cx*(t[2]-s[2]); - Li6 = u[2] + Cx*(v[2]-u[2]); - Li7 = s[3] + Cx*(t[3]-s[3]); - Li8 = u[3] + Cx*(v[3]-u[3]); - - Li9 = Li1 + Cy*(Li2-Li1); - Li10 = Li3 + Cy*(Li4-Li3); - Li11 = Li5 + Cy*(Li6-Li5); - Li12 = Li7 + Cy*(Li8-Li7); - - Li13 = Li9 + Cz*(Li10-Li9); - Li14 = Li11 + Cz*(Li12-Li11); - - return Li13 + Cw*(Li14-Li13); - } -} diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp deleted file mode 100644 index b9e6ba957..000000000 --- a/src/Nazara/Noise/Simplex.cpp +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - namespace - { - constexpr float s_SkewCoeff2D = 0.5f * (float(M_SQRT3) - 1.f); - constexpr float s_UnskewCoeff2D = (3.f - float(M_SQRT3))/6.f; - constexpr float s_SkewCoeff3D = 1.f / 3.f; - constexpr float s_UnskewCoeff3D = 1.f / 6.f; - constexpr float s_SkewCoeff4D = (float(M_SQRT5) - 1.f)/4.f; - constexpr float s_UnskewCoeff4D = (5.f - float(M_SQRT5))/20.f; - } - - Simplex::Simplex(unsigned int seed) - { - SetSeed(seed); - Shuffle(); - } - - float Simplex::Get(float x, float y, float scale) const - { - float xc = x * scale; - float yc = y * scale; - - float sum = (xc + yc) * s_SkewCoeff2D; - Vector2i skewedCubeOrigin(fastfloor(xc + sum), fastfloor(yc + sum)); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y) * s_UnskewCoeff2D; - Vector2f unskewedCubeOrigin(skewedCubeOrigin.x - sum, skewedCubeOrigin.y - sum); - - Vector2f unskewedDistToOrigin(xc - unskewedCubeOrigin.x, yc - unskewedCubeOrigin.y); - - Vector2ui off1; - if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) - off1.Set(1, 0); - else - off1.Set(0, 1); - - std::array d; - d[0] = -unskewedDistToOrigin; - d[1] = d[0] + Vector2f(off1) - Vector2f(s_UnskewCoeff2D); - d[2] = d[0] + Vector2f(1.f - 2.f * s_UnskewCoeff2D); - - Vector2i offset(skewedCubeOrigin.x & 255, skewedCubeOrigin.y & 255); - std::array gi = { - { - m_permutations[offset.x + m_permutations[offset.y]] & 7, - m_permutations[offset.x + off1.x + m_permutations[offset.y + off1.y]] & 7, - m_permutations[offset.x + 1 + m_permutations[offset.y + 1]] & 7 - } - }; - - float n = 0.f; - for (unsigned int i = 0; i < 3; ++i) - { - float c = 0.5f - d[i].x * d[i].x - d[i].y *d[i].y; - if (c > 0.f) - n += c * c * c * c * (s_gradients2[gi[i]].x * d[i].x + s_gradients2[gi[i]].y * d[i].y); - } - - return n*70.f; - } - - float Simplex::Get(float x, float y, float z, float scale) const - { - float xc, yc, zc; - int ii,jj,kk; - int gi0,gi1,gi2,gi3; - int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; - - int off1x,off1y,off1z; - int off2x,off2y,off2z; - float n1,n2,n3,n4; - float c1,c2,c3,c4; - - float sum; - float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; - float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; - float d1x,d1y,d1z; - float d2x,d2y,d2z; - float d3x,d3y,d3z; - float d4x,d4y,d4z; - - xc = x * scale; - yc = y * scale; - zc = z * scale; - - sum = (xc + yc + zc) * s_SkewCoeff3D; - skewedCubeOriginx = fastfloor(xc + sum); - skewedCubeOriginy = fastfloor(yc + sum); - skewedCubeOriginz = fastfloor(zc + sum); - - sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * s_UnskewCoeff3D; - unskewedCubeOriginx = skewedCubeOriginx - sum; - unskewedCubeOriginy = skewedCubeOriginy - sum; - unskewedCubeOriginz = skewedCubeOriginz - sum; - - unskewedDistToOriginx = xc - unskewedCubeOriginx; - unskewedDistToOriginy = yc - unskewedCubeOriginy; - unskewedDistToOriginz = zc - unskewedCubeOriginz; - - if(unskewedDistToOriginx >= unskewedDistToOriginy) - { - if(unskewedDistToOriginy >= unskewedDistToOriginz) - { - off1x = 1; - off1y = 0; - off1z = 0; - off2x = 1; - off2y = 1; - off2z = 0; - } - else if(unskewedDistToOriginx >= unskewedDistToOriginz) - { - off1x = 1; - off1y = 0; - off1z = 0; - off2x = 1; - off2y = 0; - off2z = 1; - } - else - { - off1x = 0; - off1y = 0; - off1z = 1; - off2x = 1; - off2y = 0; - off2z = 1; - } - } - else - { - if(unskewedDistToOriginy < unskewedDistToOriginz) - { - off1x = 0; - off1y = 0; - off1z = 1; - off2x = 0; - off2y = 1; - off2z = 1; - } - else if(unskewedDistToOriginx < unskewedDistToOriginz) - { - off1x = 0; - off1y = 1; - off1z = 0; - off2x = 0; - off2y = 1; - off2z = 1; - } - else - { - off1x = 0; - off1y = 1; - off1z = 0; - off2x = 1; - off2y = 1; - off2z = 0; - } - } - - d1x = unskewedDistToOriginx; - d1y = unskewedDistToOriginy; - d1z = unskewedDistToOriginz; - - d2x = d1x - off1x + s_UnskewCoeff3D; - d2y = d1y - off1y + s_UnskewCoeff3D; - d2z = d1z - off1z + s_UnskewCoeff3D; - - d3x = d1x - off2x + 2.f*s_UnskewCoeff3D; - d3y = d1y - off2y + 2.f*s_UnskewCoeff3D; - d3z = d1z - off2z + 2.f*s_UnskewCoeff3D; - - d4x = d1x - 1.f + 3.f*s_UnskewCoeff3D; - d4y = d1y - 1.f + 3.f*s_UnskewCoeff3D; - d4z = d1z - 1.f + 3.f*s_UnskewCoeff3D; - - ii = skewedCubeOriginx & 255; - jj = skewedCubeOriginy & 255; - kk = skewedCubeOriginz & 255; - - gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk ]]] % 12; - gi1 = m_permutations[ii + off1x + m_permutations[jj + off1y + m_permutations[kk + off1z ]]] % 12; - gi2 = m_permutations[ii + off2x + m_permutations[jj + off2y + m_permutations[kk + off2z ]]] % 12; - gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 ]]] % 12; - - c1 = 0.6f - d1x * d1x - d1y * d1y - d1z * d1z; - c2 = 0.6f - d2x * d2x - d2y * d2y - d2z * d2z; - c3 = 0.6f - d3x * d3x - d3y * d3y - d3z * d3z; - c4 = 0.6f - d4x * d4x - d4y * d4y - d4z * d4z; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(s_gradients3[gi0][0] * d1x + s_gradients3[gi0][1] * d1y + s_gradients3[gi0][2] * d1z); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(s_gradients3[gi1][0] * d2x + s_gradients3[gi1][1] * d2y + s_gradients3[gi1][2] * d2z); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(s_gradients3[gi2][0] * d3x + s_gradients3[gi2][1] * d3y + s_gradients3[gi2][2] * d3z); - - if(c4 < 0) - n4 = 0; - else - n4 = c4*c4*c4*c4*(s_gradients3[gi3][0] * d4x + s_gradients3[gi3][1] * d4y + s_gradients3[gi3][2] * d4z); - - return (n1+n2+n3+n4)*32; - } - - float Simplex::Get(float x, float y, float z, float w, float scale) const - { - static std::array lookupTable = - { - { - {0,1,2,3}, {0,1,3,2}, {0,0,0,0}, {0,2,3,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,2,3,0}, - {0,2,1,3}, {0,0,0,0}, {0,3,1,2}, {0,3,2,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,3,2,0}, - {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, - {1,2,0,3}, {0,0,0,0}, {1,3,0,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,3,0,1}, {2,3,1,0}, - {1,0,2,3}, {1,0,3,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,0,3,1}, {0,0,0,0}, {2,1,3,0}, - {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, - {2,0,1,3}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {3,0,1,2}, {3,0,2,1}, {0,0,0,0}, {3,1,2,0}, - {2,1,0,3}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {3,1,0,2}, {0,0,0,0}, {3,2,0,1}, {3,2,1,0} - } - }; - - float xc,yc,zc,wc; - int ii,jj,kk,ll; - int gi0,gi1,gi2,gi3,gi4; - int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; - - int off1x,off1y,off1z,off1w; - int off2x,off2y,off2z,off2w; - int off3x,off3y,off3z,off3w; - - int c; - float n1,n2,n3,n4,n5; - float c1,c2,c3,c4,c5; - - float sum; - float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; - float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; - float d1x,d2x,d3x,d4x,d5x; - float d1y,d2y,d3y,d4y,d5y; - float d1z,d2z,d3z,d4z,d5z; - float d1w,d2w,d3w,d4w,d5w; - - xc = x * scale; - yc = y * scale; - zc = z * scale; - wc = w * scale; - - sum = (xc + yc + zc + wc) * s_SkewCoeff4D; - skewedCubeOriginx = fastfloor(xc + sum); - skewedCubeOriginy = fastfloor(yc + sum); - skewedCubeOriginz = fastfloor(zc + sum); - skewedCubeOriginw = fastfloor(wc + sum); - - sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * s_UnskewCoeff4D; - unskewedCubeOriginx = skewedCubeOriginx - sum; - unskewedCubeOriginy = skewedCubeOriginy - sum; - unskewedCubeOriginz = skewedCubeOriginz - sum; - unskewedCubeOriginw = skewedCubeOriginw - sum; - - unskewedDistToOriginx = xc - unskewedCubeOriginx; - unskewedDistToOriginy = yc - unskewedCubeOriginy; - unskewedDistToOriginz = zc - unskewedCubeOriginz; - unskewedDistToOriginw = wc - unskewedCubeOriginw; - - c = 0; - c += (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; - c += (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; - c += (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; - c += (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; - c += (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; - c += (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; - - off1x = lookupTable[c][0] >= 3 ? 1 : 0; - off1y = lookupTable[c][1] >= 3 ? 1 : 0; - off1z = lookupTable[c][2] >= 3 ? 1 : 0; - off1w = lookupTable[c][3] >= 3 ? 1 : 0; - - off2x = lookupTable[c][0] >= 2 ? 1 : 0; - off2y = lookupTable[c][1] >= 2 ? 1 : 0; - off2z = lookupTable[c][2] >= 2 ? 1 : 0; - off2w = lookupTable[c][3] >= 2 ? 1 : 0; - - off3x = lookupTable[c][0] >= 1 ? 1 : 0; - off3y = lookupTable[c][1] >= 1 ? 1 : 0; - off3z = lookupTable[c][2] >= 1 ? 1 : 0; - off3w = lookupTable[c][3] >= 1 ? 1 : 0; - - d1x = unskewedDistToOriginx; - d1y = unskewedDistToOriginy; - d1z = unskewedDistToOriginz; - d1w = unskewedDistToOriginw; - - d2x = d1x - off1x + s_UnskewCoeff4D; - d2y = d1y - off1y + s_UnskewCoeff4D; - d2z = d1z - off1z + s_UnskewCoeff4D; - d2w = d1w - off1w + s_UnskewCoeff4D; - - d3x = d1x - off2x + 2.f*s_UnskewCoeff4D; - d3y = d1y - off2y + 2.f*s_UnskewCoeff4D; - d3z = d1z - off2z + 2.f*s_UnskewCoeff4D; - d3w = d1w - off2w + 2.f*s_UnskewCoeff4D; - - d4x = d1x - off3x + 3.f*s_UnskewCoeff4D; - d4y = d1y - off3y + 3.f*s_UnskewCoeff4D; - d4z = d1z - off3z + 3.f*s_UnskewCoeff4D; - d4w = d1w - off3w + 3.f*s_UnskewCoeff4D; - - d5x = d1x - 1.f + 4*s_UnskewCoeff4D; - d5y = d1y - 1.f + 4*s_UnskewCoeff4D; - d5z = d1z - 1.f + 4*s_UnskewCoeff4D; - d5w = d1w - 1.f + 4*s_UnskewCoeff4D; - - ii = skewedCubeOriginx & 255; - jj = skewedCubeOriginy & 255; - kk = skewedCubeOriginz & 255; - ll = skewedCubeOriginw & 255; - - gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll ]]]] & 31; - gi1 = m_permutations[ii + off1x + m_permutations[jj + off1y + m_permutations[kk + off1z + m_permutations[ll + off1w]]]] & 31; - gi2 = m_permutations[ii + off2x + m_permutations[jj + off2y + m_permutations[kk + off2z + m_permutations[ll + off2w]]]] & 31; - gi3 = m_permutations[ii + off3x + m_permutations[jj + off3y + m_permutations[kk + off3z + m_permutations[ll + off3w]]]] & 31; - gi4 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1 ]]]] % 32; - - c1 = 0.6f - d1x*d1x - d1y*d1y - d1z*d1z - d1w*d1w; - c2 = 0.6f - d2x*d2x - d2y*d2y - d2z*d2z - d2w*d2w; - c3 = 0.6f - d3x*d3x - d3y*d3y - d3z*d3z - d3w*d3w; - c4 = 0.6f - d4x*d4x - d4y*d4y - d4z*d4z - d4w*d4w; - c5 = 0.6f - d5x*d5x - d5y*d5y - d5z*d5z - d5w*d5w; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(s_gradients4[gi0][0]*d1x + s_gradients4[gi0][1]*d1y + s_gradients4[gi0][2]*d1z + s_gradients4[gi0][3]*d1w); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(s_gradients4[gi1][0]*d2x + s_gradients4[gi1][1]*d2y + s_gradients4[gi1][2]*d2z + s_gradients4[gi1][3]*d2w); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(s_gradients4[gi2][0]*d3x + s_gradients4[gi2][1]*d3y + s_gradients4[gi2][2]*d3z + s_gradients4[gi2][3]*d3w); - - if(c4 < 0) - n4 = 0; - else - n4 = c4*c4*c4*c4*(s_gradients4[gi3][0]*d4x + s_gradients4[gi3][1]*d4y + s_gradients4[gi3][2]*d4z + s_gradients4[gi3][3]*d4w); - - if(c5 < 0) - n5 = 0; - else - n5 = c5*c5*c5*c5*(s_gradients4[gi4][0]*d5x + s_gradients4[gi4][1]*d5y + s_gradients4[gi4][2]*d5z + s_gradients4[gi4][3]*d5w); - - return (n1+n2+n3+n4+n5)*27.f; - } -} diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp deleted file mode 100644 index 82366234b..000000000 --- a/src/Nazara/Noise/Worley.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2017 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - static constexpr std::array m_functionScales = { - { - 1.f / float(M_SQRT2), - 0.5f / float(M_SQRT2), - 0.5f / float(M_SQRT2), - 0.5f / float(M_SQRT2) - } - }; - } - Worley::Worley() : - m_function(WorleyFunction_F1) - { - } - - Worley::Worley(unsigned int seed) : - Worley() - { - SetSeed(seed); - Shuffle(); - } - - float Worley::Get(float x, float y, float scale) const - { - std::map featurePoints; - - float xc, yc; - int x0, y0; - float fractx, fracty; - - xc = x * scale; - yc = y * scale; - - x0 = fastfloor(xc); - y0 = fastfloor(yc); - - fractx = xc - static_cast(x0); - fracty = yc - static_cast(y0); - - featurePoints.clear(); - - SquareTest(x0,y0,xc,yc,featurePoints); - - std::size_t functionIndex = static_cast(m_function); - - auto it = featurePoints.begin(); - std::advance(it, functionIndex); - - if(fractx < it->first) - SquareTest(x0 - 1,y0,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if(1.f - fractx < it->first) - SquareTest(x0 + 1,y0,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if(fracty < it->first) - SquareTest(x0,y0 - 1,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if (1.f - fracty < it->first) - SquareTest(x0,y0 + 1,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if (fractx < it->first && fracty < it->first) - SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if (1.f - fractx < it->first && fracty < it->first) - SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if (fractx < it->first && 1.f - fracty < it->first) - SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - if(1.f - fractx < it->first && 1.f - fracty < it->first) - SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); - - it = featurePoints.begin(); - std::advance(it, functionIndex); - - return it->first * m_functionScales[functionIndex]; - } - - float Worley::Get(float /*x*/, float /*y*/, float /*z*/, float /*scale*/) const - { - throw std::runtime_error("Worley 3D not available yet."); - } - - float Worley::Get(float /*x*/, float /*y*/, float /*z*/, float /*w*/, float /*scale*/) const - { - throw std::runtime_error("Worley 4D not available yet."); - } - - void Worley::Set(WorleyFunction func) - { - m_function = func; - } - - void Worley::SquareTest(int xi, int yi, float x, float y, std::map& featurePoints) const - { - int ii = xi & 255; - int jj = yi & 255; - - std::size_t seed = m_permutations[ii + m_permutations[jj]]; - - //On initialise notre rng avec seed - std::minstd_rand0 randomNumberGenerator(static_cast(seed)); - - //On prend un nombre de points à déterminer dans le cube, compris entre 1 et 8 - std::size_t m = (seed & 7) + 1; - - //On calcule les emplacements des différents points - for(std::size_t i(0) ; i < m; ++i) - { - Nz::Vector2f featurePoint; - featurePoint.x = (randomNumberGenerator() & 1023) / 1023.f + static_cast(xi); - featurePoint.y = (randomNumberGenerator() & 1023) / 1023.f + static_cast(yi); - - // TODO : Check order is correct - float distance = std::sqrt((featurePoint.x - x) * (featurePoint.x - x) + - (featurePoint.y - y) * (featurePoint.y - y)); - - //Insertion dans la liste triée - featurePoints[distance] = featurePoint; - } - } -} diff --git a/tests/Engine/Lua/LuaClass.cpp b/tests/Engine/Lua/LuaClass.cpp deleted file mode 100644 index 5cddb3cb1..000000000 --- a/tests/Engine/Lua/LuaClass.cpp +++ /dev/null @@ -1,249 +0,0 @@ -#include -#include -#include -#include - -class LuaClass_Test -{ - public: - LuaClass_Test() = default; - LuaClass_Test(const LuaClass_Test& other) = default; - LuaClass_Test& operator=(const LuaClass_Test& other) = default; - virtual ~LuaClass_Test() = default; - - LuaClass_Test(int i, bool j = false) : - m_i(i), - m_j(j) - { - } - - virtual int GetI() const - { - return m_i; - } - - bool GetJ() const - { - return m_j; - } - - int GetDefault(int defaultValue = 0) - { - return defaultValue; - } - - static int StaticMethodWithArguments(int a, int b) - { - return a + b; - } - - private: - int m_i; - bool m_j; -}; - -class LuaClass_InheritTest : public LuaClass_Test -{ - public: - LuaClass_InheritTest() : - LuaClass_Test(5, true) - { - } - - int GetI() const override - { - return LuaClass_Test::GetI() + 3; - } -}; - -class LuaClass_TestWithHandle : public Nz::HandledObject -{ - public: - int GetI() const - { - return m_i; - } - - int GetDefault(int defaultValue = 0) - { - return defaultValue; - } - - private: - int m_i = 8; -}; - -inline unsigned int LuaImplQueryArg(const Nz::LuaState& instance, int index, LuaClass_Test* arg, Nz::TypeTag) -{ - REQUIRE(instance.IsOfType(index, "Test")); - *arg = *static_cast(instance.ToUserdata(index)); - return 1; -} - -inline unsigned int LuaImplQueryArg(const Nz::LuaState& instance, int index, Nz::ObjectHandle* arg, Nz::TypeTag>) -{ - REQUIRE(instance.IsOfType(index, "TestWithHandle")); - *arg = *static_cast*>(instance.ToUserdata(index)); - return 1; -} - -inline unsigned int LuaImplQueryArg(const Nz::LuaState& instance, int index, LuaClass_InheritTest* arg, Nz::TypeTag) -{ - REQUIRE(instance.IsOfType(index, "InheritTest")); - *arg = *static_cast(instance.ToUserdata(index)); - return 1; -} - -SCENARIO("LuaClass", "[LUA][LUACLASS]") -{ - GIVEN("One lua class for our Test class") - { - Nz::LuaInstance luaInstance; - Nz::LuaClass test; - Nz::LuaClass inheritTest; - using TestHandle = Nz::ObjectHandle; - Nz::LuaClass testHandle; - - WHEN("We bind the methods") - { - test.Reset("Test"); - - test.BindDefaultConstructor(); - - test.SetConstructor([] (Nz::LuaState& lua, LuaClass_Test* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 2U); - - int argIndex = 1; - switch (argCount) - { - case 1: - { - int iValue = lua.Check(&argIndex, 0); - - Nz::PlacementNew(instance, iValue); - return true; - } - - case 2: - { - int iValue = lua.Check(&argIndex, 0); - bool j = lua.Check(&argIndex, false); - - Nz::PlacementNew(instance, iValue, j); - return true; - } - } - - lua.Error("No matching overload for Test constructor"); - return false; - }); - - test.BindMethod("GetI", &LuaClass_Test::GetI); - test.BindMethod("GetJ", &LuaClass_Test::GetJ); - test.BindMethod("GetDefault", &LuaClass_Test::GetDefault, 0); - - test.BindStaticMethod("StaticMethodWithArguments", [] (Nz::LuaState& state) -> int - { - int argIndex = 1; - int result = LuaClass_Test::StaticMethodWithArguments(state.Check(&argIndex), state.Check(&argIndex)); - - state.Push(result); - return 1; - }); - - test.Register(luaInstance); - - THEN("We should be able to call them") - { - int value = 1; - int staticResult = value + value; - - luaInstance.PushFunction([=](Nz::LuaState& state) -> int - { - int argIndex = 1; - LuaClass_Test result = state.Check(&argIndex); - CHECK(result.GetI() == value); - CHECK_FALSE(result.GetJ()); - return 1; - }); - luaInstance.SetGlobal("CheckTest"); - - luaInstance.PushFunction([=](Nz::LuaState& state) -> int - { - int argIndex = 1; - int result = state.Check(&argIndex); - CHECK(result == staticResult); - return 1; - }); - luaInstance.SetGlobal("CheckStatic"); - - luaInstance.PushFunction([=](Nz::LuaState& state) -> int - { - int argIndex = 1; - LuaClass_Test result = state.Check(&argIndex); - CHECK(result.GetI() == staticResult); - CHECK(result.GetJ()); - return 1; - }); - luaInstance.SetGlobal("CheckFinalTest"); - - REQUIRE(luaInstance.ExecuteFromFile("resources/Engine/Lua/LuaClass.lua")); - REQUIRE(luaInstance.GetGlobal("test_Test") == Nz::LuaType_Function); - luaInstance.Call(0); - } - - AND_THEN("With a subclass") - { - inheritTest.Reset("InheritTest"); - - inheritTest.Inherit(test); - inheritTest.BindDefaultConstructor(); - - inheritTest.Register(luaInstance); - - luaInstance.PushFunction([=](Nz::LuaState& state) -> int - { - int argIndex = 1; - LuaClass_InheritTest result = state.Check(&argIndex); - CHECK(result.GetI() == 8); - CHECK(result.GetJ()); - return 1; - }); - luaInstance.SetGlobal("CheckInheritTest"); - - REQUIRE(luaInstance.ExecuteFromFile("resources/Engine/Lua/LuaClass.lua")); - REQUIRE(luaInstance.GetGlobal("test_InheritTest") == Nz::LuaType_Function); - luaInstance.Call(0); - } - } - - WHEN("We bind the object with Handle") - { - int defaultValue = 5; - - testHandle.Reset("TestHandle"); - testHandle.BindMethod("IsValid", &TestHandle::IsValid); - testHandle.BindMethod("GetI", &LuaClass_TestWithHandle::GetI); - testHandle.BindMethod("GetDefault", &LuaClass_TestWithHandle::GetDefault, defaultValue); - testHandle.Register(luaInstance); - - THEN("We can ensure the following properties") - { - luaInstance.PushFunction([=](Nz::LuaState& state) -> int - { - int argIndex = 1; - TestHandle result = state.Check(&argIndex); - CHECK(result->GetI() == 8); - CHECK(result->GetDefault() == defaultValue); - return 1; - }); - luaInstance.SetGlobal("CheckTestHandle"); - - REQUIRE(luaInstance.ExecuteFromFile("resources/Engine/Lua/LuaClass.lua")); - REQUIRE(luaInstance.GetGlobal("test_TestHandle") == Nz::LuaType_Function); - luaInstance.Call(0); - } - } - } -} diff --git a/tests/Engine/Lua/LuaCoroutine.cpp b/tests/Engine/Lua/LuaCoroutine.cpp deleted file mode 100644 index 3ab42d6b9..000000000 --- a/tests/Engine/Lua/LuaCoroutine.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -SCENARIO("LuaCoroutine", "[LUA][LUACOROUTINE]") -{ - GIVEN("One lua with coroutine") - { - Nz::LuaInstance luaInstance; - luaInstance.LoadLibraries(Nz::LuaLib_Coroutine); - - REQUIRE(luaInstance.ExecuteFromFile("resources/Engine/Lua/LuaCoroutine.lua")); - - Nz::LuaCoroutine coroutine = luaInstance.NewCoroutine(); - REQUIRE(coroutine.GetGlobal("infinite") == Nz::LuaType_Function); - coroutine.PushInteger(4); - CHECK(coroutine.Call(1)); - - coroutine.Resume(); - CHECK(coroutine.CheckInteger(1) == 1); - coroutine.Resume(); - CHECK(coroutine.CheckInteger(1) == -1); - coroutine.Resume(); - CHECK(coroutine.CheckInteger(1) == 0); - coroutine.Resume(); - CHECK(coroutine.CheckInteger(1) == 1); - - coroutine.Resume(); - CHECK_FALSE(coroutine.CanResume()); - } -} diff --git a/tests/Engine/Lua/LuaInstance.cpp b/tests/Engine/Lua/LuaInstance.cpp deleted file mode 100644 index 6042704bf..000000000 --- a/tests/Engine/Lua/LuaInstance.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include -#include -#include - -SCENARIO("LuaInstance", "[LUA][LUAINSTANCE]") -{ - GIVEN("One lua instance") - { - Nz::LuaInstance luaInstance; - - WHEN("We set memory constraint") - { - luaInstance.SetMemoryLimit(1'000); - - THEN("If we excess memory, it should crash") - { - REQUIRE_THROWS_WITH(luaInstance.Execute(R"( - global t = {} - for 1,10000000 do - t[i] = i - end - )"), Catch::Matchers::Contains("memory")); - } - } - - WHEN("We set time constraint") - { - luaInstance.SetTimeLimit(10); - - THEN("If we excess time, it should produce an error") - { - CHECK(!luaInstance.Execute(R"( - function ack(M,N) - if M == 0 then return N + 1 end - if N == 0 then return ack(M-1,1) end - return ack(M-1,ack(M, N-1)) - end - ack(100, 100) - )")); - - REQUIRE_THAT(luaInstance.GetLastError().ToStdString(), Catch::Matchers::Contains("time")); - } - } - } - - GIVEN("Two instances") - { - Nz::LuaInstance luaInstance; - - int memoryLimit = 10'000; - int timeLimit = 1'000; - luaInstance.SetMemoryLimit(memoryLimit); - luaInstance.SetTimeLimit(timeLimit); - - int value = 5; - luaInstance.PushInteger(value); - - WHEN("We use move constructor") - { - Nz::LuaInstance movedInstance(std::move(luaInstance)); - - THEN("We should be able to retrieve the value") - { - CHECK(movedInstance.CheckInteger(1) == value); - CHECK(movedInstance.GetMemoryLimit() == memoryLimit); - CHECK(movedInstance.GetTimeLimit() == timeLimit); - } - } - - WHEN("We use move assignment") - { - Nz::LuaInstance movedInstance; - movedInstance.PushInteger(value + 1); - movedInstance = std::move(luaInstance); - - THEN("We should be able to retrieve the value") - { - CHECK(movedInstance.CheckInteger(1) == value); - CHECK(movedInstance.GetMemoryLimit() == memoryLimit); - CHECK(movedInstance.GetTimeLimit() == timeLimit); - } - } - } -} diff --git a/tests/Engine/Lua/LuaState.cpp b/tests/Engine/Lua/LuaState.cpp deleted file mode 100644 index 430927d98..000000000 --- a/tests/Engine/Lua/LuaState.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include -#include - -static int counter(lua_State* L) -{ - Nz::LuaInstance& luaInstance = Nz::LuaInstance::GetInstance(L); - double val = luaInstance.ToNumber(luaInstance.GetIndexOfUpValue(1)); - luaInstance.PushNumber(++val); - luaInstance.PushValue(-1); - luaInstance.Replace(luaInstance.GetIndexOfUpValue(1)); - return 1; -} - -struct TestLuaState -{ - int a = 3; - float b = 5.f; -}; - -struct TestMetaTable -{ - float x = 1.f; - float y = 2.f; -}; - -inline int LuaImplReplyVal(const Nz::LuaState& state, TestLuaState&& val, Nz::TypeTag) -{ - state.PushTable(); - state.PushField("a", val.a); - state.PushField("b", val.b); - - return 1; -} - -inline unsigned int LuaImplQueryArg(const Nz::LuaState& state, int index, TestLuaState* arg, Nz::TypeTag) -{ - state.CheckType(index, Nz::LuaType_Table); - - arg->a = state.CheckField("a", index); - arg->b = state.CheckField("b", index); - - return 1; -} - -SCENARIO("LuaState", "[LUA][LUASTATE]") -{ - GIVEN("One lua instance") - { - Nz::LuaInstance luaInstance; - luaInstance.LoadLibraries(Nz::LuaLib_Math); - - WHEN("We push different primitive types") - { - bool booleanValue = true; - long long integerValue = 5LL; - double doubleValue = -55.0; - const char* stringValue = "test"; - Nz::String nazaraValue = "Nazara"; - luaInstance.PushBoolean(booleanValue); - luaInstance.PushInteger(integerValue); - luaInstance.PushNil(); - luaInstance.PushNumber(doubleValue); - luaInstance.PushString(stringValue); - luaInstance.PushString(nazaraValue); - - THEN("We should be able to retrieve them") - { - CHECK(luaInstance.CheckBoolean(1) == booleanValue); - CHECK(luaInstance.CheckInteger(2) == integerValue); - bool succeeded = false; - CHECK(luaInstance.ToInteger(2, &succeeded) == integerValue); - CHECK(succeeded); - CHECK(luaInstance.ToPointer(3) == nullptr); - CHECK(luaInstance.CheckNumber(4) == Approx(doubleValue)); - succeeded = false; - CHECK(luaInstance.ToNumber(4, &succeeded) == Approx(doubleValue)); - CHECK(succeeded); - CHECK(luaInstance.CheckString(5) == std::string(stringValue)); - CHECK(luaInstance.CheckString(6) == nazaraValue); - std::size_t length = 0; - CHECK(luaInstance.ToString(6, &length) == nazaraValue); - CHECK(length == nazaraValue.GetSize()); - } - } - - WHEN("We use basic operations") - { - luaInstance.PushInteger(1); - luaInstance.PushInteger(2); - - THEN("We should behave normally") - { - CHECK(luaInstance.Compare(1, 2, Nz::LuaComparison_Less)); - luaInstance.Compute(Nz::LuaOperation_Substraction); - CHECK(luaInstance.ToInteger(1) == -1); - } - } - - WHEN("We manipulate the stack") - { - Nz::String stringValue = "hello"; - luaInstance.PushBoolean(true); - luaInstance.PushNumber(10.0); - luaInstance.PushNil(); - luaInstance.PushString(stringValue); - /* true 10.0 nil hello */ - - THEN("These effects are expected") - { - luaInstance.PushValue(-4); - /* true 10.0 nil hello true */ - CHECK(luaInstance.CheckBoolean(5)); - - luaInstance.Replace(3); - /* true 10.0 true hello */ - CHECK(luaInstance.CheckBoolean(3)); - - luaInstance.Remove(-2); - /* true 10.0 hello */ - CHECK(luaInstance.CheckString(3) == stringValue); - - luaInstance.Pop(2); - /* true */ - CHECK_FALSE(luaInstance.IsValid(2)); - } - } - - WHEN("We try the CFunction") - { - double counterValue = 55.0; - luaInstance.PushFunction([=](Nz::LuaState& s) -> int { - s.PushNumber(counterValue); - s.PushCFunction(&counter, 1); - return 1; - }); - - THEN("We can call them") - { - luaInstance.Call(0); // We call our counter creator - luaInstance.Call(0); // We call our counter, which increments the value - CHECK(luaInstance.ToNumber(0) == Approx(counterValue + 1.0)); - } - } - - WHEN("We push our user type locally") - { - luaInstance.Push(TestLuaState()); - - THEN("We can retrieve it") - { - int index = 1; - TestLuaState popped = luaInstance.Check(&index); - CHECK(popped.a == 3); - CHECK(popped.b == Approx(5.0)); - } - } - - WHEN("We push our user type globally") - { - luaInstance.PushGlobal("TestLuaState", TestLuaState()); - - THEN("We can retrieve it") - { - TestLuaState popped = luaInstance.CheckGlobal("TestLuaState"); - CHECK(popped.a == 3); - CHECK(popped.b == Approx(5.0)); - } - } - - WHEN("We define a lua function") - { - luaInstance.Execute(R"( - function f (x, y) - return (x^2 * math.sin(y))/(1 - x) - end - )"); - - THEN("We can call it from the code") - { - REQUIRE(luaInstance.GetGlobal("f") == Nz::LuaType_Function); - luaInstance.Push(3.0, 2.0); - luaInstance.Call(2, 1); - CHECK(luaInstance.ToNumber(1) == Approx(-4.09).margin(0.1)); - } - } - - WHEN("We push a std::vector locally") - { - std::vector vec { 1, 5, -8, 6, -4 }; - luaInstance.Push(std::vector { vec }); - - THEN("We can retrieve it with correct values") - { - int index = 1; - std::vector otherVec = luaInstance.Check>(&index); - - for (std::size_t i {}; i < otherVec.size(); ++i) - CHECK(otherVec[i] == vec[i]); - } - } - - WHEN("We push a std::vector globally") - { - std::vector vec { 1, 5, -8, 6, -4 }; - luaInstance.PushGlobal("vector", std::vector { vec }); - - THEN("We can retrieve it with correct values") - { - std::vector otherVec = luaInstance.CheckGlobal>("vector"); - - for (std::size_t i {}; i < otherVec.size(); ++i) - CHECK(otherVec[i] == vec[i]); - } - } - } -} From 43ee75b75f13decc26e1fd05944556ed38dbfa1e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 17:57:46 +0100 Subject: [PATCH 17/25] Replace #include NazaraSDK}/Algorithm.hpp | 4 +- SDK/include/{NDK => NazaraSDK}/Algorithm.inl | 0 .../{NDK => NazaraSDK}/Application.hpp | 10 ++-- .../{NDK => NazaraSDK}/Application.inl | 2 +- .../{NDK => NazaraSDK}/BaseComponent.hpp | 4 +- .../{NDK => NazaraSDK}/BaseComponent.inl | 0 SDK/include/{NDK => NazaraSDK}/BaseSystem.hpp | 4 +- SDK/include/{NDK => NazaraSDK}/BaseSystem.inl | 0 SDK/include/{NDK => NazaraSDK}/BaseWidget.hpp | 10 ++-- SDK/include/{NDK => NazaraSDK}/BaseWidget.inl | 2 +- SDK/include/{NDK => NazaraSDK}/Canvas.hpp | 6 +-- SDK/include/{NDK => NazaraSDK}/Canvas.inl | 2 +- SDK/include/{NDK => NazaraSDK}/Component.hpp | 4 +- SDK/include/{NDK => NazaraSDK}/Component.inl | 2 +- SDK/include/NazaraSDK/Components.hpp | 24 +++++++++ .../Components/CameraComponent.hpp | 4 +- .../Components/CameraComponent.inl | 0 .../Components/CollisionComponent2D.hpp | 4 +- .../Components/CollisionComponent2D.inl | 0 .../Components/CollisionComponent3D.hpp | 4 +- .../Components/CollisionComponent3D.inl | 0 .../Components/ConstraintComponent2D.hpp | 6 +-- .../Components/ConstraintComponent2D.inl | 6 +-- .../Components/DebugComponent.hpp | 4 +- .../Components/DebugComponent.inl | 2 +- .../Components/GraphicsComponent.hpp | 4 +- .../Components/GraphicsComponent.inl | 6 +-- .../Components/LifetimeComponent.hpp | 4 +- .../Components/LifetimeComponent.inl | 2 +- .../Components/LightComponent.hpp | 4 +- .../Components/LightComponent.inl | 0 .../Components/ListenerComponent.hpp | 4 +- .../Components/ListenerComponent.inl | 0 .../Components/NodeComponent.hpp | 4 +- .../Components/NodeComponent.inl | 2 +- .../Components/ParticleEmitterComponent.hpp | 4 +- .../Components/ParticleEmitterComponent.inl | 0 .../Components/ParticleGroupComponent.hpp | 4 +- .../Components/ParticleGroupComponent.inl | 2 +- .../Components/PhysicsComponent2D.hpp | 4 +- .../Components/PhysicsComponent2D.inl | 2 +- .../Components/PhysicsComponent3D.hpp | 4 +- .../Components/PhysicsComponent3D.inl | 0 .../Components/VelocityComponent.hpp | 4 +- .../Components/VelocityComponent.inl | 0 SDK/include/{NDK => NazaraSDK}/Console.hpp | 6 +-- SDK/include/{NDK => NazaraSDK}/Console.inl | 0 SDK/include/{NDK => NazaraSDK}/Entity.hpp | 6 +-- SDK/include/{NDK => NazaraSDK}/Entity.inl | 2 +- SDK/include/{NDK => NazaraSDK}/EntityList.hpp | 6 +-- SDK/include/{NDK => NazaraSDK}/EntityList.inl | 0 .../{NDK => NazaraSDK}/EntityOwner.hpp | 4 +- .../{NDK => NazaraSDK}/EntityOwner.inl | 2 +- .../{NDK => NazaraSDK}/Prerequisites.hpp | 0 SDK/include/{NDK => NazaraSDK}/Sdk.hpp | 4 +- SDK/include/{NDK => NazaraSDK}/Sdk.inl | 0 SDK/include/{NDK => NazaraSDK}/State.hpp | 2 +- .../{NDK => NazaraSDK}/StateMachine.hpp | 6 +-- .../{NDK => NazaraSDK}/StateMachine.inl | 2 +- SDK/include/{NDK => NazaraSDK}/System.hpp | 4 +- SDK/include/{NDK => NazaraSDK}/System.inl | 2 +- SDK/include/NazaraSDK/Systems.hpp | 17 ++++++ .../Systems/DebugSystem.hpp | 4 +- .../Systems/DebugSystem.inl | 2 +- .../Systems/LifetimeSystem.hpp | 4 +- .../Systems/LifetimeSystem.inl | 0 .../Systems/ListenerSystem.hpp | 4 +- .../Systems/ListenerSystem.inl | 0 .../Systems/ParticleSystem.hpp | 4 +- .../Systems/ParticleSystem.inl | 0 .../Systems/PhysicsSystem2D.hpp | 6 +-- .../Systems/PhysicsSystem2D.inl | 2 +- .../Systems/PhysicsSystem3D.hpp | 6 +-- .../Systems/PhysicsSystem3D.inl | 0 .../Systems/RenderSystem.hpp | 8 +-- .../Systems/RenderSystem.inl | 2 +- .../Systems/VelocitySystem.hpp | 4 +- .../Systems/VelocitySystem.inl | 0 SDK/include/NazaraSDK/Widgets.hpp | 20 +++++++ .../Widgets/AbstractTextAreaWidget.hpp | 6 +-- .../Widgets/AbstractTextAreaWidget.inl | 2 +- .../{NDK => NazaraSDK}/Widgets/BoxLayout.hpp | 8 +-- .../{NDK => NazaraSDK}/Widgets/BoxLayout.inl | 2 +- .../Widgets/ButtonWidget.hpp | 6 +-- .../Widgets/ButtonWidget.inl | 2 +- .../Widgets/CheckboxWidget.hpp | 10 ++-- .../Widgets/CheckboxWidget.inl | 0 .../{NDK => NazaraSDK}/Widgets/Enums.hpp | 0 .../Widgets/ImageWidget.hpp | 8 +-- .../Widgets/ImageWidget.inl | 2 +- .../Widgets/LabelWidget.hpp | 6 +-- .../Widgets/LabelWidget.inl | 2 +- .../Widgets/ProgressBarWidget.hpp | 6 +-- .../Widgets/ProgressBarWidget.inl | 0 .../Widgets/RichTextAreaWidget.hpp | 4 +- .../Widgets/RichTextAreaWidget.inl | 2 +- .../Widgets/ScrollAreaWidget.hpp | 6 +-- .../Widgets/ScrollAreaWidget.inl | 2 +- .../Widgets/TextAreaWidget.hpp | 4 +- .../Widgets/TextAreaWidget.inl | 2 +- SDK/include/{NDK => NazaraSDK}/World.hpp | 8 +-- SDK/include/{NDK => NazaraSDK}/World.inl | 2 +- SDK/src/{NDK => NazaraSDK}/Application.cpp | 0 SDK/src/{NDK => NazaraSDK}/BaseComponent.cpp | 2 +- SDK/src/{NDK => NazaraSDK}/BaseSystem.cpp | 4 +- SDK/src/{NDK => NazaraSDK}/BaseWidget.cpp | 10 ++-- SDK/src/{NDK => NazaraSDK}/Canvas.cpp | 2 +- .../Components/CameraComponent.cpp | 6 +-- .../Components/CollisionComponent2D.cpp | 10 ++-- .../Components/CollisionComponent3D.cpp | 8 +-- .../Components/ConstraintComponent2D.cpp | 2 +- .../Components/DebugComponent.cpp | 4 +- .../Components/GraphicsComponent.cpp | 8 +-- .../Components/LifetimeComponent.cpp | 2 +- .../Components/LightComponent.cpp | 2 +- .../Components/ListenerComponent.cpp | 2 +- .../Components/NodeComponent.cpp | 2 +- .../Components/ParticleEmitterComponent.cpp | 2 +- .../Components/ParticleGroupComponent.cpp | 2 +- .../Components/PhysicsComponent2D.cpp | 10 ++-- .../Components/PhysicsComponent3D.cpp | 10 ++-- .../Components/VelocityComponent.cpp | 2 +- SDK/src/{NDK => NazaraSDK}/Console.cpp | 10 ++-- SDK/src/{NDK => NazaraSDK}/Entity.cpp | 6 +-- SDK/src/{NDK => NazaraSDK}/EntityList.cpp | 4 +- .../Resources/checkmark.png.h | 0 SDK/src/{NDK => NazaraSDK}/Sdk.cpp | 54 +++++++++---------- SDK/src/{NDK => NazaraSDK}/State.cpp | 2 +- .../Systems/DebugSystem.cpp | 14 ++--- .../Systems/LifetimeSystem.cpp | 4 +- .../Systems/ListenerSystem.cpp | 6 +-- .../Systems/ParticleSystem.cpp | 4 +- .../Systems/PhysicsSystem2D.cpp | 12 ++--- .../Systems/PhysicsSystem3D.cpp | 10 ++-- .../Systems/RenderSystem.cpp | 12 ++--- .../Systems/VelocitySystem.cpp | 10 ++-- .../Widgets/AbstractTextAreaWidget.cpp | 6 +-- .../{NDK => NazaraSDK}/Widgets/BoxLayout.cpp | 2 +- .../Widgets/ButtonWidget.cpp | 6 +-- .../Widgets/CheckboxWidget.cpp | 6 +-- .../Widgets/ImageWidget.cpp | 6 +-- .../Widgets/LabelWidget.cpp | 6 +-- .../Widgets/ProgressBarWidget.cpp | 6 +-- .../Widgets/RichTextAreaWidget.cpp | 2 +- .../Widgets/ScrollAreaWidget.cpp | 6 +-- .../Widgets/TextAreaWidget.cpp | 6 +-- SDK/src/{NDK => NazaraSDK}/World.cpp | 20 +++---- examples/FirstScene/main.cpp | 12 ++--- examples/Particles/Common.cpp | 4 +- examples/Particles/Common.hpp | 8 +-- examples/Particles/LogoDemo.cpp | 4 +- examples/Particles/LogoDemo.hpp | 2 +- examples/Particles/SpacebattleDemo.cpp | 4 +- examples/Particles/SpacebattleDemo.hpp | 4 +- examples/Particles/main.cpp | 8 +-- examples/Tut00/main.cpp | 2 +- examples/Tut01/main.cpp | 8 +-- examples/Tut02/main.cpp | 8 +-- tests/Engine/Platform/EventHandler.cpp | 12 ++--- .../Platform/EventHandler/BaseState.cpp | 2 +- .../Platform/EventHandler/BaseState.hpp | 2 +- .../Platform/EventHandler/EventState.cpp | 2 +- .../Platform/EventHandler/FocusState.cpp | 2 +- .../Engine/Platform/EventHandler/KeyState.cpp | 2 +- .../Platform/EventHandler/MenuState.cpp | 2 +- .../Platform/EventHandler/MouseClickState.cpp | 2 +- .../Platform/EventHandler/MouseEnterState.cpp | 2 +- .../Platform/EventHandler/MouseMoveState.cpp | 2 +- .../Platform/EventHandler/StateFactory.hpp | 2 +- tests/Engine/Platform/EventHandler/Text.cpp | 8 +-- tests/Engine/Platform/EventHandler/Text.hpp | 2 +- .../Platform/EventHandler/TextEnterState.cpp | 2 +- .../EventHandler/WindowModificationState.cpp | 2 +- tests/SDK/NDK/Application.cpp | 2 +- tests/SDK/NDK/BaseSystem.cpp | 8 +-- tests/SDK/NDK/Component.cpp | 2 +- tests/SDK/NDK/Entity.cpp | 4 +- tests/SDK/NDK/EntityList.cpp | 4 +- tests/SDK/NDK/EntityOwner.cpp | 4 +- tests/SDK/NDK/StateMachine.cpp | 2 +- tests/SDK/NDK/System.cpp | 2 +- tests/SDK/NDK/Systems/ListenerSystem.cpp | 10 ++-- tests/SDK/NDK/Systems/PhysicsSystem2D.cpp | 10 ++-- tests/SDK/NDK/Systems/PhysicsSystem3D.cpp | 10 ++-- tests/SDK/NDK/Systems/RenderSystem.cpp | 8 +-- tests/SDK/NDK/Systems/VelocitySystem.cpp | 8 +-- tests/SDK/NDK/World.cpp | 4 +- tests/main.cpp | 2 +- 191 files changed, 469 insertions(+), 469 deletions(-) delete mode 100644 SDK/include/NDK/Components.hpp delete mode 100644 SDK/include/NDK/Systems.hpp delete mode 100644 SDK/include/NDK/Widgets.hpp rename SDK/include/{NDK => NazaraSDK}/Algorithm.hpp (91%) rename SDK/include/{NDK => NazaraSDK}/Algorithm.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Application.hpp (95%) rename SDK/include/{NDK => NazaraSDK}/Application.inl (99%) rename SDK/include/{NDK => NazaraSDK}/BaseComponent.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/BaseComponent.inl (100%) rename SDK/include/{NDK => NazaraSDK}/BaseSystem.hpp (97%) rename SDK/include/{NDK => NazaraSDK}/BaseSystem.inl (100%) rename SDK/include/{NDK => NazaraSDK}/BaseWidget.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/BaseWidget.inl (99%) rename SDK/include/{NDK => NazaraSDK}/Canvas.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/Canvas.inl (98%) rename SDK/include/{NDK => NazaraSDK}/Component.hpp (90%) rename SDK/include/{NDK => NazaraSDK}/Component.inl (98%) create mode 100644 SDK/include/NazaraSDK/Components.hpp rename SDK/include/{NDK => NazaraSDK}/Components/CameraComponent.hpp (97%) rename SDK/include/{NDK => NazaraSDK}/Components/CameraComponent.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/CollisionComponent2D.hpp (95%) rename SDK/include/{NDK => NazaraSDK}/Components/CollisionComponent2D.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/CollisionComponent3D.hpp (94%) rename SDK/include/{NDK => NazaraSDK}/Components/CollisionComponent3D.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/ConstraintComponent2D.hpp (91%) rename SDK/include/{NDK => NazaraSDK}/Components/ConstraintComponent2D.inl (90%) rename SDK/include/{NDK => NazaraSDK}/Components/DebugComponent.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/Components/DebugComponent.inl (96%) rename SDK/include/{NDK => NazaraSDK}/Components/GraphicsComponent.hpp (98%) rename SDK/include/{NDK => NazaraSDK}/Components/GraphicsComponent.inl (98%) rename SDK/include/{NDK => NazaraSDK}/Components/LifetimeComponent.hpp (90%) rename SDK/include/{NDK => NazaraSDK}/Components/LifetimeComponent.inl (90%) rename SDK/include/{NDK => NazaraSDK}/Components/LightComponent.hpp (91%) rename SDK/include/{NDK => NazaraSDK}/Components/LightComponent.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/ListenerComponent.hpp (87%) rename SDK/include/{NDK => NazaraSDK}/Components/ListenerComponent.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/NodeComponent.hpp (90%) rename SDK/include/{NDK => NazaraSDK}/Components/NodeComponent.inl (96%) rename SDK/include/{NDK => NazaraSDK}/Components/ParticleEmitterComponent.hpp (92%) rename SDK/include/{NDK => NazaraSDK}/Components/ParticleEmitterComponent.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/ParticleGroupComponent.hpp (92%) rename SDK/include/{NDK => NazaraSDK}/Components/ParticleGroupComponent.inl (97%) rename SDK/include/{NDK => NazaraSDK}/Components/PhysicsComponent2D.hpp (98%) rename SDK/include/{NDK => NazaraSDK}/Components/PhysicsComponent2D.inl (99%) rename SDK/include/{NDK => NazaraSDK}/Components/PhysicsComponent3D.hpp (97%) rename SDK/include/{NDK => NazaraSDK}/Components/PhysicsComponent3D.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Components/VelocityComponent.hpp (90%) rename SDK/include/{NDK => NazaraSDK}/Components/VelocityComponent.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Console.hpp (95%) rename SDK/include/{NDK => NazaraSDK}/Console.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Entity.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/Entity.inl (99%) rename SDK/include/{NDK => NazaraSDK}/EntityList.hpp (95%) rename SDK/include/{NDK => NazaraSDK}/EntityList.inl (100%) rename SDK/include/{NDK => NazaraSDK}/EntityOwner.hpp (92%) rename SDK/include/{NDK => NazaraSDK}/EntityOwner.inl (98%) rename SDK/include/{NDK => NazaraSDK}/Prerequisites.hpp (100%) rename SDK/include/{NDK => NazaraSDK}/Sdk.hpp (88%) rename SDK/include/{NDK => NazaraSDK}/Sdk.inl (100%) rename SDK/include/{NDK => NazaraSDK}/State.hpp (89%) rename SDK/include/{NDK => NazaraSDK}/StateMachine.hpp (90%) rename SDK/include/{NDK => NazaraSDK}/StateMachine.inl (99%) rename SDK/include/{NDK => NazaraSDK}/System.hpp (90%) rename SDK/include/{NDK => NazaraSDK}/System.inl (96%) create mode 100644 SDK/include/NazaraSDK/Systems.hpp rename SDK/include/{NDK => NazaraSDK}/Systems/DebugSystem.hpp (95%) rename SDK/include/{NDK => NazaraSDK}/Systems/DebugSystem.inl (86%) rename SDK/include/{NDK => NazaraSDK}/Systems/LifetimeSystem.hpp (87%) rename SDK/include/{NDK => NazaraSDK}/Systems/LifetimeSystem.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Systems/ListenerSystem.hpp (88%) rename SDK/include/{NDK => NazaraSDK}/Systems/ListenerSystem.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Systems/ParticleSystem.hpp (88%) rename SDK/include/{NDK => NazaraSDK}/Systems/ParticleSystem.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Systems/PhysicsSystem2D.hpp (98%) rename SDK/include/{NDK => NazaraSDK}/Systems/PhysicsSystem2D.inl (97%) rename SDK/include/{NDK => NazaraSDK}/Systems/PhysicsSystem3D.hpp (89%) rename SDK/include/{NDK => NazaraSDK}/Systems/PhysicsSystem3D.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Systems/RenderSystem.hpp (94%) rename SDK/include/{NDK => NazaraSDK}/Systems/RenderSystem.inl (99%) rename SDK/include/{NDK => NazaraSDK}/Systems/VelocitySystem.hpp (87%) rename SDK/include/{NDK => NazaraSDK}/Systems/VelocitySystem.inl (100%) create mode 100644 SDK/include/NazaraSDK/Widgets.hpp rename SDK/include/{NDK => NazaraSDK}/Widgets/AbstractTextAreaWidget.hpp (97%) rename SDK/include/{NDK => NazaraSDK}/Widgets/AbstractTextAreaWidget.inl (99%) rename SDK/include/{NDK => NazaraSDK}/Widgets/BoxLayout.hpp (85%) rename SDK/include/{NDK => NazaraSDK}/Widgets/BoxLayout.inl (89%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ButtonWidget.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ButtonWidget.inl (98%) rename SDK/include/{NDK => NazaraSDK}/Widgets/CheckboxWidget.hpp (92%) rename SDK/include/{NDK => NazaraSDK}/Widgets/CheckboxWidget.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Widgets/Enums.hpp (100%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ImageWidget.hpp (89%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ImageWidget.inl (96%) rename SDK/include/{NDK => NazaraSDK}/Widgets/LabelWidget.hpp (87%) rename SDK/include/{NDK => NazaraSDK}/Widgets/LabelWidget.inl (91%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ProgressBarWidget.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ProgressBarWidget.inl (100%) rename SDK/include/{NDK => NazaraSDK}/Widgets/RichTextAreaWidget.hpp (95%) rename SDK/include/{NDK => NazaraSDK}/Widgets/RichTextAreaWidget.inl (97%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ScrollAreaWidget.hpp (94%) rename SDK/include/{NDK => NazaraSDK}/Widgets/ScrollAreaWidget.inl (94%) rename SDK/include/{NDK => NazaraSDK}/Widgets/TextAreaWidget.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/Widgets/TextAreaWidget.inl (98%) rename SDK/include/{NDK => NazaraSDK}/World.hpp (96%) rename SDK/include/{NDK => NazaraSDK}/World.inl (99%) rename SDK/src/{NDK => NazaraSDK}/Application.cpp (100%) rename SDK/src/{NDK => NazaraSDK}/BaseComponent.cpp (98%) rename SDK/src/{NDK => NazaraSDK}/BaseSystem.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/BaseWidget.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/Canvas.cpp (99%) rename SDK/src/{NDK => NazaraSDK}/Components/CameraComponent.cpp (98%) rename SDK/src/{NDK => NazaraSDK}/Components/CollisionComponent2D.cpp (94%) rename SDK/src/{NDK => NazaraSDK}/Components/CollisionComponent3D.cpp (94%) rename SDK/src/{NDK => NazaraSDK}/Components/ConstraintComponent2D.cpp (92%) rename SDK/src/{NDK => NazaraSDK}/Components/DebugComponent.cpp (88%) rename SDK/src/{NDK => NazaraSDK}/Components/GraphicsComponent.cpp (98%) rename SDK/src/{NDK => NazaraSDK}/Components/LifetimeComponent.cpp (82%) rename SDK/src/{NDK => NazaraSDK}/Components/LightComponent.cpp (82%) rename SDK/src/{NDK => NazaraSDK}/Components/ListenerComponent.cpp (82%) rename SDK/src/{NDK => NazaraSDK}/Components/NodeComponent.cpp (83%) rename SDK/src/{NDK => NazaraSDK}/Components/ParticleEmitterComponent.cpp (92%) rename SDK/src/{NDK => NazaraSDK}/Components/ParticleGroupComponent.cpp (81%) rename SDK/src/{NDK => NazaraSDK}/Components/PhysicsComponent2D.cpp (92%) rename SDK/src/{NDK => NazaraSDK}/Components/PhysicsComponent3D.cpp (92%) rename SDK/src/{NDK => NazaraSDK}/Components/VelocityComponent.cpp (82%) rename SDK/src/{NDK => NazaraSDK}/Console.cpp (96%) rename SDK/src/{NDK => NazaraSDK}/Entity.cpp (98%) rename SDK/src/{NDK => NazaraSDK}/EntityList.cpp (83%) rename SDK/src/{NDK => NazaraSDK}/Resources/checkmark.png.h (100%) rename SDK/src/{NDK => NazaraSDK}/Sdk.cpp (74%) rename SDK/src/{NDK => NazaraSDK}/State.cpp (91%) rename SDK/src/{NDK => NazaraSDK}/Systems/DebugSystem.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/Systems/LifetimeSystem.cpp (84%) rename SDK/src/{NDK => NazaraSDK}/Systems/ListenerSystem.cpp (92%) rename SDK/src/{NDK => NazaraSDK}/Systems/ParticleSystem.cpp (90%) rename SDK/src/{NDK => NazaraSDK}/Systems/PhysicsSystem2D.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/Systems/PhysicsSystem3D.cpp (94%) rename SDK/src/{NDK => NazaraSDK}/Systems/RenderSystem.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/Systems/VelocitySystem.cpp (82%) rename SDK/src/{NDK => NazaraSDK}/Widgets/AbstractTextAreaWidget.cpp (98%) rename SDK/src/{NDK => NazaraSDK}/Widgets/BoxLayout.cpp (98%) rename SDK/src/{NDK => NazaraSDK}/Widgets/ButtonWidget.cpp (96%) rename SDK/src/{NDK => NazaraSDK}/Widgets/CheckboxWidget.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/Widgets/ImageWidget.cpp (79%) rename SDK/src/{NDK => NazaraSDK}/Widgets/LabelWidget.cpp (76%) rename SDK/src/{NDK => NazaraSDK}/Widgets/ProgressBarWidget.cpp (95%) rename SDK/src/{NDK => NazaraSDK}/Widgets/RichTextAreaWidget.cpp (99%) rename SDK/src/{NDK => NazaraSDK}/Widgets/ScrollAreaWidget.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/Widgets/TextAreaWidget.cpp (97%) rename SDK/src/{NDK => NazaraSDK}/World.cpp (95%) diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp deleted file mode 100644 index cc8c37d93..000000000 --- a/SDK/include/NDK/Components.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// This file was automatically generated - -#pragma once - -#ifndef NDK_COMPONENTS_GLOBAL_HPP -#define NDK_COMPONENTS_GLOBAL_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp deleted file mode 100644 index e9a60f0c3..000000000 --- a/SDK/include/NDK/Systems.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated - -#pragma once - -#ifndef NDK_SYSTEMS_GLOBAL_HPP -#define NDK_SYSTEMS_GLOBAL_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // NDK_SYSTEMS_GLOBAL_HPP diff --git a/SDK/include/NDK/Widgets.hpp b/SDK/include/NDK/Widgets.hpp deleted file mode 100644 index 9a36e37a2..000000000 --- a/SDK/include/NDK/Widgets.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// This file was automatically generated - -#pragma once - -#ifndef NDK_WIDGETS_GLOBAL_HPP -#define NDK_WIDGETS_GLOBAL_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // NDK_WIDGETS_GLOBAL_HPP diff --git a/SDK/include/NDK/Algorithm.hpp b/SDK/include/NazaraSDK/Algorithm.hpp similarity index 91% rename from SDK/include/NDK/Algorithm.hpp rename to SDK/include/NazaraSDK/Algorithm.hpp index 21eefd68a..9496c4d21 100644 --- a/SDK/include/NDK/Algorithm.hpp +++ b/SDK/include/NazaraSDK/Algorithm.hpp @@ -7,7 +7,7 @@ #ifndef NDK_ALGORITHM_HPP #define NDK_ALGORITHM_HPP -#include +#include namespace Ndk { @@ -20,6 +20,6 @@ namespace Ndk template bool IsSystem(S& system); } -#include +#include #endif // NDK_ALGORITHM_HPP diff --git a/SDK/include/NDK/Algorithm.inl b/SDK/include/NazaraSDK/Algorithm.inl similarity index 100% rename from SDK/include/NDK/Algorithm.inl rename to SDK/include/NazaraSDK/Algorithm.inl diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NazaraSDK/Application.hpp similarity index 95% rename from SDK/include/NDK/Application.hpp rename to SDK/include/NazaraSDK/Application.hpp index 23417bcd8..5302d68a0 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NazaraSDK/Application.hpp @@ -7,16 +7,16 @@ #ifndef NDK_APPLICATION_HPP #define NDK_APPLICATION_HPP -#include -#include +#include +#include #include #include #include #include #ifndef NDK_SERVER -#include -#include +#include +#include #include #include #include @@ -144,6 +144,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_APPLICATION_HPP diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NazaraSDK/Application.inl similarity index 99% rename from SDK/include/NDK/Application.inl rename to SDK/include/NazaraSDK/Application.inl index 42139db0c..df690d038 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NazaraSDK/Application.inl @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequisites.hpp #include -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NazaraSDK/BaseComponent.hpp similarity index 96% rename from SDK/include/NDK/BaseComponent.hpp rename to SDK/include/NazaraSDK/BaseComponent.hpp index 3dd90bb75..c00260b09 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NazaraSDK/BaseComponent.hpp @@ -7,7 +7,7 @@ #ifndef NDK_BASECOMPONENT_HPP #define NDK_BASECOMPONENT_HPP -#include +#include #include #include #include @@ -69,6 +69,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_BASECOMPONENT_HPP diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NazaraSDK/BaseComponent.inl similarity index 100% rename from SDK/include/NDK/BaseComponent.inl rename to SDK/include/NazaraSDK/BaseComponent.inl diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NazaraSDK/BaseSystem.hpp similarity index 97% rename from SDK/include/NDK/BaseSystem.hpp rename to SDK/include/NazaraSDK/BaseSystem.hpp index a3d967a9c..87967764d 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NazaraSDK/BaseSystem.hpp @@ -8,7 +8,7 @@ #define NDK_BASESYSTEM_HPP #include -#include +#include namespace Ndk { @@ -100,6 +100,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_BASESYSTEM_HPP diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NazaraSDK/BaseSystem.inl similarity index 100% rename from SDK/include/NDK/BaseSystem.inl rename to SDK/include/NazaraSDK/BaseSystem.inl diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NazaraSDK/BaseWidget.hpp similarity index 96% rename from SDK/include/NDK/BaseWidget.hpp rename to SDK/include/NazaraSDK/BaseWidget.hpp index 8bdd15584..62ace6eba 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NazaraSDK/BaseWidget.hpp @@ -7,10 +7,10 @@ #ifndef NDK_BASEWIDGET_HPP #define NDK_BASEWIDGET_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -170,6 +170,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_BASEWIDGET_HPP diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NazaraSDK/BaseWidget.inl similarity index 99% rename from SDK/include/NDK/BaseWidget.inl rename to SDK/include/NazaraSDK/BaseWidget.inl index edff81436..7115b5ad5 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NazaraSDK/BaseWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NazaraSDK/Canvas.hpp similarity index 96% rename from SDK/include/NDK/Canvas.hpp rename to SDK/include/NazaraSDK/Canvas.hpp index 26cc36cbd..1cff05828 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NazaraSDK/Canvas.hpp @@ -7,8 +7,8 @@ #ifndef NDK_CANVAS_HPP #define NDK_CANVAS_HPP -#include -#include +#include +#include #include #include @@ -82,6 +82,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_CANVAS_HPP diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NazaraSDK/Canvas.inl similarity index 98% rename from SDK/include/NDK/Canvas.inl rename to SDK/include/NazaraSDK/Canvas.inl index 0e1cb38f5..4e308631e 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NazaraSDK/Canvas.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/include/NDK/Component.hpp b/SDK/include/NazaraSDK/Component.hpp similarity index 90% rename from SDK/include/NDK/Component.hpp rename to SDK/include/NazaraSDK/Component.hpp index 6b32c5fd2..d2ccaaf5d 100644 --- a/SDK/include/NDK/Component.hpp +++ b/SDK/include/NazaraSDK/Component.hpp @@ -7,7 +7,7 @@ #ifndef NDK_COMPONENT_HPP #define NDK_COMPONENT_HPP -#include +#include namespace Ndk { @@ -27,6 +27,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENT_HPP diff --git a/SDK/include/NDK/Component.inl b/SDK/include/NazaraSDK/Component.inl similarity index 98% rename from SDK/include/NDK/Component.inl rename to SDK/include/NazaraSDK/Component.inl index e90cada8a..459cd4789 100644 --- a/SDK/include/NDK/Component.inl +++ b/SDK/include/NazaraSDK/Component.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/include/NazaraSDK/Components.hpp b/SDK/include/NazaraSDK/Components.hpp new file mode 100644 index 000000000..a937e07e9 --- /dev/null +++ b/SDK/include/NazaraSDK/Components.hpp @@ -0,0 +1,24 @@ +// This file was automatically generated + +#pragma once + +#ifndef NDK_COMPONENTS_GLOBAL_HPP +#define NDK_COMPONENTS_GLOBAL_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NazaraSDK/Components/CameraComponent.hpp similarity index 97% rename from SDK/include/NDK/Components/CameraComponent.hpp rename to SDK/include/NazaraSDK/Components/CameraComponent.hpp index cf835704a..a4faaf7fa 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NazaraSDK/Components/CameraComponent.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace Ndk { @@ -114,7 +114,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_CAMERACOMPONENT_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NazaraSDK/Components/CameraComponent.inl similarity index 100% rename from SDK/include/NDK/Components/CameraComponent.inl rename to SDK/include/NazaraSDK/Components/CameraComponent.inl diff --git a/SDK/include/NDK/Components/CollisionComponent2D.hpp b/SDK/include/NazaraSDK/Components/CollisionComponent2D.hpp similarity index 95% rename from SDK/include/NDK/Components/CollisionComponent2D.hpp rename to SDK/include/NazaraSDK/Components/CollisionComponent2D.hpp index a5da3b8c2..4bd47e6ae 100644 --- a/SDK/include/NDK/Components/CollisionComponent2D.hpp +++ b/SDK/include/NazaraSDK/Components/CollisionComponent2D.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace Ndk @@ -61,6 +61,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_COLLISIONCOMPONENT2D_HPP diff --git a/SDK/include/NDK/Components/CollisionComponent2D.inl b/SDK/include/NazaraSDK/Components/CollisionComponent2D.inl similarity index 100% rename from SDK/include/NDK/Components/CollisionComponent2D.inl rename to SDK/include/NazaraSDK/Components/CollisionComponent2D.inl diff --git a/SDK/include/NDK/Components/CollisionComponent3D.hpp b/SDK/include/NazaraSDK/Components/CollisionComponent3D.hpp similarity index 94% rename from SDK/include/NDK/Components/CollisionComponent3D.hpp rename to SDK/include/NazaraSDK/Components/CollisionComponent3D.hpp index 65e48576b..846985cf4 100644 --- a/SDK/include/NDK/Components/CollisionComponent3D.hpp +++ b/SDK/include/NazaraSDK/Components/CollisionComponent3D.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace Ndk @@ -53,6 +53,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP diff --git a/SDK/include/NDK/Components/CollisionComponent3D.inl b/SDK/include/NazaraSDK/Components/CollisionComponent3D.inl similarity index 100% rename from SDK/include/NDK/Components/CollisionComponent3D.inl rename to SDK/include/NazaraSDK/Components/CollisionComponent3D.inl diff --git a/SDK/include/NDK/Components/ConstraintComponent2D.hpp b/SDK/include/NazaraSDK/Components/ConstraintComponent2D.hpp similarity index 91% rename from SDK/include/NDK/Components/ConstraintComponent2D.hpp rename to SDK/include/NazaraSDK/Components/ConstraintComponent2D.hpp index 652559481..97c201570 100644 --- a/SDK/include/NDK/Components/ConstraintComponent2D.hpp +++ b/SDK/include/NazaraSDK/Components/ConstraintComponent2D.hpp @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -46,6 +46,6 @@ namespace Ndk } -#include +#include #endif// NDK_COMPONENTS_CONSTRAINTCOMPONENT2D_HPP diff --git a/SDK/include/NDK/Components/ConstraintComponent2D.inl b/SDK/include/NazaraSDK/Components/ConstraintComponent2D.inl similarity index 90% rename from SDK/include/NDK/Components/ConstraintComponent2D.inl rename to SDK/include/NazaraSDK/Components/ConstraintComponent2D.inl index 5db943439..4d4d2e81a 100644 --- a/SDK/include/NDK/Components/ConstraintComponent2D.inl +++ b/SDK/include/NazaraSDK/Components/ConstraintComponent2D.inl @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Components/DebugComponent.hpp b/SDK/include/NazaraSDK/Components/DebugComponent.hpp similarity index 96% rename from SDK/include/NDK/Components/DebugComponent.hpp rename to SDK/include/NazaraSDK/Components/DebugComponent.hpp index e0993d26d..9dcf762d5 100644 --- a/SDK/include/NDK/Components/DebugComponent.hpp +++ b/SDK/include/NazaraSDK/Components/DebugComponent.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include namespace Ndk { @@ -85,7 +85,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_DEBUGCOMPONENT_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/DebugComponent.inl b/SDK/include/NazaraSDK/Components/DebugComponent.inl similarity index 96% rename from SDK/include/NDK/Components/DebugComponent.inl rename to SDK/include/NazaraSDK/Components/DebugComponent.inl index e0f42a560..0aff21089 100644 --- a/SDK/include/NDK/Components/DebugComponent.inl +++ b/SDK/include/NazaraSDK/Components/DebugComponent.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NazaraSDK/Components/GraphicsComponent.hpp similarity index 98% rename from SDK/include/NDK/Components/GraphicsComponent.hpp rename to SDK/include/NazaraSDK/Components/GraphicsComponent.hpp index e7780f3e0..fca142554 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NazaraSDK/Components/GraphicsComponent.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include namespace Ndk @@ -164,7 +164,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NazaraSDK/Components/GraphicsComponent.inl similarity index 98% rename from SDK/include/NDK/Components/GraphicsComponent.inl rename to SDK/include/NazaraSDK/Components/GraphicsComponent.inl index 37bbd1049..05c878df7 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NazaraSDK/Components/GraphicsComponent.inl @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include #include namespace Ndk diff --git a/SDK/include/NDK/Components/LifetimeComponent.hpp b/SDK/include/NazaraSDK/Components/LifetimeComponent.hpp similarity index 90% rename from SDK/include/NDK/Components/LifetimeComponent.hpp rename to SDK/include/NazaraSDK/Components/LifetimeComponent.hpp index 72004a90d..cb2044605 100644 --- a/SDK/include/NDK/Components/LifetimeComponent.hpp +++ b/SDK/include/NazaraSDK/Components/LifetimeComponent.hpp @@ -7,7 +7,7 @@ #ifndef NDK_COMPONENTS_LIFETIMECOMPONENT_HPP #define NDK_COMPONENTS_LIFETIMECOMPONENT_HPP -#include +#include namespace Ndk { @@ -35,6 +35,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_LIFETIMECOMPONENT_HPP diff --git a/SDK/include/NDK/Components/LifetimeComponent.inl b/SDK/include/NazaraSDK/Components/LifetimeComponent.inl similarity index 90% rename from SDK/include/NDK/Components/LifetimeComponent.inl rename to SDK/include/NazaraSDK/Components/LifetimeComponent.inl index 145e160ba..6635bc0d8 100644 --- a/SDK/include/NDK/Components/LifetimeComponent.inl +++ b/SDK/include/NazaraSDK/Components/LifetimeComponent.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Components/LightComponent.hpp b/SDK/include/NazaraSDK/Components/LightComponent.hpp similarity index 91% rename from SDK/include/NDK/Components/LightComponent.hpp rename to SDK/include/NazaraSDK/Components/LightComponent.hpp index a7f72d0eb..33eec59a1 100644 --- a/SDK/include/NDK/Components/LightComponent.hpp +++ b/SDK/include/NazaraSDK/Components/LightComponent.hpp @@ -9,7 +9,7 @@ #define NDK_COMPONENTS_LIGHTCOMPONENT_HPP #include -#include +#include namespace Ndk { @@ -30,7 +30,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_LIGHTCOMPONENT_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/LightComponent.inl b/SDK/include/NazaraSDK/Components/LightComponent.inl similarity index 100% rename from SDK/include/NDK/Components/LightComponent.inl rename to SDK/include/NazaraSDK/Components/LightComponent.inl diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NazaraSDK/Components/ListenerComponent.hpp similarity index 87% rename from SDK/include/NDK/Components/ListenerComponent.hpp rename to SDK/include/NazaraSDK/Components/ListenerComponent.hpp index d5debdd36..4a8490d6a 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NazaraSDK/Components/ListenerComponent.hpp @@ -8,7 +8,7 @@ #ifndef NDK_COMPONENTS_LISTENERCOMPONENT_HPP #define NDK_COMPONENTS_LISTENERCOMPONENT_HPP -#include +#include namespace Ndk { @@ -32,7 +32,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_LISTENERCOMPONENT_HPP #endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/ListenerComponent.inl b/SDK/include/NazaraSDK/Components/ListenerComponent.inl similarity index 100% rename from SDK/include/NDK/Components/ListenerComponent.inl rename to SDK/include/NazaraSDK/Components/ListenerComponent.inl diff --git a/SDK/include/NDK/Components/NodeComponent.hpp b/SDK/include/NazaraSDK/Components/NodeComponent.hpp similarity index 90% rename from SDK/include/NDK/Components/NodeComponent.hpp rename to SDK/include/NazaraSDK/Components/NodeComponent.hpp index bccba1233..2a5dd2289 100644 --- a/SDK/include/NDK/Components/NodeComponent.hpp +++ b/SDK/include/NazaraSDK/Components/NodeComponent.hpp @@ -8,7 +8,7 @@ #define NDK_COMPONENTS_NODECOMPONENT_HPP #include -#include +#include namespace Ndk { @@ -30,6 +30,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_NODECOMPONENT_HPP diff --git a/SDK/include/NDK/Components/NodeComponent.inl b/SDK/include/NazaraSDK/Components/NodeComponent.inl similarity index 96% rename from SDK/include/NDK/Components/NodeComponent.inl rename to SDK/include/NazaraSDK/Components/NodeComponent.inl index a7eb1f9bc..6a6770d66 100644 --- a/SDK/include/NDK/Components/NodeComponent.inl +++ b/SDK/include/NazaraSDK/Components/NodeComponent.inl @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequisites.hpp #include -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NazaraSDK/Components/ParticleEmitterComponent.hpp similarity index 92% rename from SDK/include/NDK/Components/ParticleEmitterComponent.hpp rename to SDK/include/NazaraSDK/Components/ParticleEmitterComponent.hpp index 0c7497a3b..65833003f 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NazaraSDK/Components/ParticleEmitterComponent.hpp @@ -9,7 +9,7 @@ #define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP #include -#include +#include namespace Ndk { @@ -43,7 +43,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP #endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NazaraSDK/Components/ParticleEmitterComponent.inl similarity index 100% rename from SDK/include/NDK/Components/ParticleEmitterComponent.inl rename to SDK/include/NazaraSDK/Components/ParticleEmitterComponent.inl diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NazaraSDK/Components/ParticleGroupComponent.hpp similarity index 92% rename from SDK/include/NDK/Components/ParticleGroupComponent.hpp rename to SDK/include/NazaraSDK/Components/ParticleGroupComponent.hpp index 9415b8547..8471ecc03 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.hpp +++ b/SDK/include/NazaraSDK/Components/ParticleGroupComponent.hpp @@ -9,7 +9,7 @@ #define NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP #include -#include +#include namespace Ndk { @@ -35,7 +35,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NazaraSDK/Components/ParticleGroupComponent.inl similarity index 97% rename from SDK/include/NDK/Components/ParticleGroupComponent.inl rename to SDK/include/NazaraSDK/Components/ParticleGroupComponent.inl index d6225df3b..1e0d75cac 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.inl +++ b/SDK/include/NazaraSDK/Components/ParticleGroupComponent.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.hpp b/SDK/include/NazaraSDK/Components/PhysicsComponent2D.hpp similarity index 98% rename from SDK/include/NDK/Components/PhysicsComponent2D.hpp rename to SDK/include/NazaraSDK/Components/PhysicsComponent2D.hpp index 3983c26a5..15159709d 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.hpp +++ b/SDK/include/NazaraSDK/Components/PhysicsComponent2D.hpp @@ -8,7 +8,7 @@ #define NDK_COMPONENTS_PHYSICSCOMPONENT2D_HPP #include -#include +#include #include namespace Ndk @@ -125,6 +125,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_PHYSICSCOMPONENT2D_HPP diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.inl b/SDK/include/NazaraSDK/Components/PhysicsComponent2D.inl similarity index 99% rename from SDK/include/NDK/Components/PhysicsComponent2D.inl rename to SDK/include/NazaraSDK/Components/PhysicsComponent2D.inl index 6e0b0b10f..f42b95c85 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.inl +++ b/SDK/include/NazaraSDK/Components/PhysicsComponent2D.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/include/NDK/Components/PhysicsComponent3D.hpp b/SDK/include/NazaraSDK/Components/PhysicsComponent3D.hpp similarity index 97% rename from SDK/include/NDK/Components/PhysicsComponent3D.hpp rename to SDK/include/NazaraSDK/Components/PhysicsComponent3D.hpp index 08cc64081..538860cde 100644 --- a/SDK/include/NDK/Components/PhysicsComponent3D.hpp +++ b/SDK/include/NazaraSDK/Components/PhysicsComponent3D.hpp @@ -8,7 +8,7 @@ #define NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP #include -#include +#include #include namespace Ndk @@ -96,6 +96,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP diff --git a/SDK/include/NDK/Components/PhysicsComponent3D.inl b/SDK/include/NazaraSDK/Components/PhysicsComponent3D.inl similarity index 100% rename from SDK/include/NDK/Components/PhysicsComponent3D.inl rename to SDK/include/NazaraSDK/Components/PhysicsComponent3D.inl diff --git a/SDK/include/NDK/Components/VelocityComponent.hpp b/SDK/include/NazaraSDK/Components/VelocityComponent.hpp similarity index 90% rename from SDK/include/NDK/Components/VelocityComponent.hpp rename to SDK/include/NazaraSDK/Components/VelocityComponent.hpp index 2c619da76..b2f82a556 100644 --- a/SDK/include/NDK/Components/VelocityComponent.hpp +++ b/SDK/include/NazaraSDK/Components/VelocityComponent.hpp @@ -8,7 +8,7 @@ #define NDK_COMPONENTS_VELOCITYCOMPONENT_HPP #include -#include +#include namespace Ndk { @@ -31,6 +31,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_VELOCITYCOMPONENT_HPP diff --git a/SDK/include/NDK/Components/VelocityComponent.inl b/SDK/include/NazaraSDK/Components/VelocityComponent.inl similarity index 100% rename from SDK/include/NDK/Components/VelocityComponent.inl rename to SDK/include/NazaraSDK/Components/VelocityComponent.inl diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NazaraSDK/Console.hpp similarity index 95% rename from SDK/include/NDK/Console.hpp rename to SDK/include/NazaraSDK/Console.hpp index 3b4dbbe39..67aece140 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NazaraSDK/Console.hpp @@ -14,8 +14,8 @@ #include #include #include -#include -#include +#include +#include namespace Nz { @@ -82,7 +82,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_CONSOLE_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Console.inl b/SDK/include/NazaraSDK/Console.inl similarity index 100% rename from SDK/include/NDK/Console.inl rename to SDK/include/NazaraSDK/Console.inl diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NazaraSDK/Entity.hpp similarity index 96% rename from SDK/include/NDK/Entity.hpp rename to SDK/include/NazaraSDK/Entity.hpp index 85e43da19..f05a5c432 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NazaraSDK/Entity.hpp @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -109,6 +109,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_ENTITY_HPP diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NazaraSDK/Entity.inl similarity index 99% rename from SDK/include/NDK/Entity.inl rename to SDK/include/NazaraSDK/Entity.inl index 799384182..f17ff92fa 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NazaraSDK/Entity.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NazaraSDK/EntityList.hpp similarity index 95% rename from SDK/include/NDK/EntityList.hpp rename to SDK/include/NazaraSDK/EntityList.hpp index 0f89d0cad..0950cae2f 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NazaraSDK/EntityList.hpp @@ -8,8 +8,8 @@ #define NDK_ENTITYLIST_HPP #include -#include -#include +#include +#include namespace Ndk { @@ -81,6 +81,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_ENTITYLIST_HPP diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NazaraSDK/EntityList.inl similarity index 100% rename from SDK/include/NDK/EntityList.inl rename to SDK/include/NazaraSDK/EntityList.inl diff --git a/SDK/include/NDK/EntityOwner.hpp b/SDK/include/NazaraSDK/EntityOwner.hpp similarity index 92% rename from SDK/include/NDK/EntityOwner.hpp rename to SDK/include/NazaraSDK/EntityOwner.hpp index 84eb95feb..2fec8f6dc 100644 --- a/SDK/include/NDK/EntityOwner.hpp +++ b/SDK/include/NazaraSDK/EntityOwner.hpp @@ -7,7 +7,7 @@ #ifndef NDK_ENTITYOWNER_HPP #define NDK_ENTITYOWNER_HPP -#include +#include namespace Ndk { @@ -30,6 +30,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_ENTITYOWNER_HPP diff --git a/SDK/include/NDK/EntityOwner.inl b/SDK/include/NazaraSDK/EntityOwner.inl similarity index 98% rename from SDK/include/NDK/EntityOwner.inl rename to SDK/include/NazaraSDK/EntityOwner.inl index 4ee9530f7..13f1e8cad 100644 --- a/SDK/include/NDK/EntityOwner.inl +++ b/SDK/include/NazaraSDK/EntityOwner.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include diff --git a/SDK/include/NDK/Prerequisites.hpp b/SDK/include/NazaraSDK/Prerequisites.hpp similarity index 100% rename from SDK/include/NDK/Prerequisites.hpp rename to SDK/include/NazaraSDK/Prerequisites.hpp diff --git a/SDK/include/NDK/Sdk.hpp b/SDK/include/NazaraSDK/Sdk.hpp similarity index 88% rename from SDK/include/NDK/Sdk.hpp rename to SDK/include/NazaraSDK/Sdk.hpp index 7b096c583..9e42e3ac6 100644 --- a/SDK/include/NDK/Sdk.hpp +++ b/SDK/include/NazaraSDK/Sdk.hpp @@ -7,7 +7,7 @@ #ifndef NDK_SDK_HPP #define NDK_SDK_HPP -#include +#include namespace Ndk { @@ -26,6 +26,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_SDK_HPP diff --git a/SDK/include/NDK/Sdk.inl b/SDK/include/NazaraSDK/Sdk.inl similarity index 100% rename from SDK/include/NDK/Sdk.inl rename to SDK/include/NazaraSDK/Sdk.inl diff --git a/SDK/include/NDK/State.hpp b/SDK/include/NazaraSDK/State.hpp similarity index 89% rename from SDK/include/NDK/State.hpp rename to SDK/include/NazaraSDK/State.hpp index 3b3664218..506cd6476 100644 --- a/SDK/include/NDK/State.hpp +++ b/SDK/include/NazaraSDK/State.hpp @@ -7,7 +7,7 @@ #ifndef NDK_STATE_HPP #define NDK_STATE_HPP -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/StateMachine.hpp b/SDK/include/NazaraSDK/StateMachine.hpp similarity index 90% rename from SDK/include/NDK/StateMachine.hpp rename to SDK/include/NazaraSDK/StateMachine.hpp index 57398a619..54db4877b 100644 --- a/SDK/include/NDK/StateMachine.hpp +++ b/SDK/include/NazaraSDK/StateMachine.hpp @@ -7,8 +7,8 @@ #ifndef NDK_STATEMACHINE_HPP #define NDK_STATEMACHINE_HPP -#include -#include +#include +#include #include #include @@ -56,6 +56,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_STATEMACHINE_HPP \ No newline at end of file diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NazaraSDK/StateMachine.inl similarity index 99% rename from SDK/include/NDK/StateMachine.inl rename to SDK/include/NazaraSDK/StateMachine.inl index ba2a74928..95df4e82b 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NazaraSDK/StateMachine.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include diff --git a/SDK/include/NDK/System.hpp b/SDK/include/NazaraSDK/System.hpp similarity index 90% rename from SDK/include/NDK/System.hpp rename to SDK/include/NazaraSDK/System.hpp index 538fe097c..5276a2251 100644 --- a/SDK/include/NDK/System.hpp +++ b/SDK/include/NazaraSDK/System.hpp @@ -7,7 +7,7 @@ #ifndef NDK_SYSTEM_HPP #define NDK_SYSTEM_HPP -#include +#include namespace Ndk { @@ -27,6 +27,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEM_HPP diff --git a/SDK/include/NDK/System.inl b/SDK/include/NazaraSDK/System.inl similarity index 96% rename from SDK/include/NDK/System.inl rename to SDK/include/NazaraSDK/System.inl index 3902205c0..0110da45a 100644 --- a/SDK/include/NDK/System.inl +++ b/SDK/include/NazaraSDK/System.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/include/NazaraSDK/Systems.hpp b/SDK/include/NazaraSDK/Systems.hpp new file mode 100644 index 000000000..b2b1a123e --- /dev/null +++ b/SDK/include/NazaraSDK/Systems.hpp @@ -0,0 +1,17 @@ +// This file was automatically generated + +#pragma once + +#ifndef NDK_SYSTEMS_GLOBAL_HPP +#define NDK_SYSTEMS_GLOBAL_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NDK_SYSTEMS_GLOBAL_HPP diff --git a/SDK/include/NDK/Systems/DebugSystem.hpp b/SDK/include/NazaraSDK/Systems/DebugSystem.hpp similarity index 95% rename from SDK/include/NDK/Systems/DebugSystem.hpp rename to SDK/include/NazaraSDK/Systems/DebugSystem.hpp index 1d468ea41..d8c7ccfd7 100644 --- a/SDK/include/NDK/Systems/DebugSystem.hpp +++ b/SDK/include/NazaraSDK/Systems/DebugSystem.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace Ndk { @@ -52,7 +52,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_DEBUGSYSTEM_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/DebugSystem.inl b/SDK/include/NazaraSDK/Systems/DebugSystem.inl similarity index 86% rename from SDK/include/NDK/Systems/DebugSystem.inl rename to SDK/include/NazaraSDK/Systems/DebugSystem.inl index b72b87f3f..46d425afa 100644 --- a/SDK/include/NDK/Systems/DebugSystem.inl +++ b/SDK/include/NazaraSDK/Systems/DebugSystem.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Systems/LifetimeSystem.hpp b/SDK/include/NazaraSDK/Systems/LifetimeSystem.hpp similarity index 87% rename from SDK/include/NDK/Systems/LifetimeSystem.hpp rename to SDK/include/NazaraSDK/Systems/LifetimeSystem.hpp index 9957c1b53..ff095580d 100644 --- a/SDK/include/NDK/Systems/LifetimeSystem.hpp +++ b/SDK/include/NazaraSDK/Systems/LifetimeSystem.hpp @@ -7,7 +7,7 @@ #ifndef NDK_SYSTEMS_LIFETIMESYSTEM_HPP #define NDK_SYSTEMS_LIFETIMESYSTEM_HPP -#include +#include namespace Ndk { @@ -24,6 +24,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_LIFETIMESYSTEM_HPP diff --git a/SDK/include/NDK/Systems/LifetimeSystem.inl b/SDK/include/NazaraSDK/Systems/LifetimeSystem.inl similarity index 100% rename from SDK/include/NDK/Systems/LifetimeSystem.inl rename to SDK/include/NazaraSDK/Systems/LifetimeSystem.inl diff --git a/SDK/include/NDK/Systems/ListenerSystem.hpp b/SDK/include/NazaraSDK/Systems/ListenerSystem.hpp similarity index 88% rename from SDK/include/NDK/Systems/ListenerSystem.hpp rename to SDK/include/NazaraSDK/Systems/ListenerSystem.hpp index fce5e8cae..7f203c35a 100644 --- a/SDK/include/NDK/Systems/ListenerSystem.hpp +++ b/SDK/include/NazaraSDK/Systems/ListenerSystem.hpp @@ -8,7 +8,7 @@ #ifndef NDK_SYSTEMS_LISTENERSYSTEM_HPP #define NDK_SYSTEMS_LISTENERSYSTEM_HPP -#include +#include namespace Ndk { @@ -25,7 +25,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_LISTENERSYSTEM_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/ListenerSystem.inl b/SDK/include/NazaraSDK/Systems/ListenerSystem.inl similarity index 100% rename from SDK/include/NDK/Systems/ListenerSystem.inl rename to SDK/include/NazaraSDK/Systems/ListenerSystem.inl diff --git a/SDK/include/NDK/Systems/ParticleSystem.hpp b/SDK/include/NazaraSDK/Systems/ParticleSystem.hpp similarity index 88% rename from SDK/include/NDK/Systems/ParticleSystem.hpp rename to SDK/include/NazaraSDK/Systems/ParticleSystem.hpp index adbfc7e39..cb57a41d7 100644 --- a/SDK/include/NDK/Systems/ParticleSystem.hpp +++ b/SDK/include/NazaraSDK/Systems/ParticleSystem.hpp @@ -8,7 +8,7 @@ #ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP #define NDK_SYSTEMS_PARTICLESYSTEM_HPP -#include +#include namespace Ndk { @@ -25,7 +25,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/ParticleSystem.inl b/SDK/include/NazaraSDK/Systems/ParticleSystem.inl similarity index 100% rename from SDK/include/NDK/Systems/ParticleSystem.inl rename to SDK/include/NazaraSDK/Systems/ParticleSystem.inl diff --git a/SDK/include/NDK/Systems/PhysicsSystem2D.hpp b/SDK/include/NazaraSDK/Systems/PhysicsSystem2D.hpp similarity index 98% rename from SDK/include/NDK/Systems/PhysicsSystem2D.hpp rename to SDK/include/NazaraSDK/Systems/PhysicsSystem2D.hpp index dd10fcd57..faff327a2 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem2D.hpp +++ b/SDK/include/NazaraSDK/Systems/PhysicsSystem2D.hpp @@ -8,8 +8,8 @@ #define NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP #include -#include -#include +#include +#include #include namespace Ndk @@ -127,6 +127,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP diff --git a/SDK/include/NDK/Systems/PhysicsSystem2D.inl b/SDK/include/NazaraSDK/Systems/PhysicsSystem2D.inl similarity index 97% rename from SDK/include/NDK/Systems/PhysicsSystem2D.inl rename to SDK/include/NazaraSDK/Systems/PhysicsSystem2D.inl index 64870c092..1a490b4dd 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem2D.inl +++ b/SDK/include/NazaraSDK/Systems/PhysicsSystem2D.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Systems/PhysicsSystem3D.hpp b/SDK/include/NazaraSDK/Systems/PhysicsSystem3D.hpp similarity index 89% rename from SDK/include/NDK/Systems/PhysicsSystem3D.hpp rename to SDK/include/NazaraSDK/Systems/PhysicsSystem3D.hpp index 07e4c7220..0e70e21f6 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem3D.hpp +++ b/SDK/include/NazaraSDK/Systems/PhysicsSystem3D.hpp @@ -8,8 +8,8 @@ #define NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP #include -#include -#include +#include +#include #include namespace Ndk @@ -36,6 +36,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP diff --git a/SDK/include/NDK/Systems/PhysicsSystem3D.inl b/SDK/include/NazaraSDK/Systems/PhysicsSystem3D.inl similarity index 100% rename from SDK/include/NDK/Systems/PhysicsSystem3D.inl rename to SDK/include/NazaraSDK/Systems/PhysicsSystem3D.inl diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NazaraSDK/Systems/RenderSystem.hpp similarity index 94% rename from SDK/include/NDK/Systems/RenderSystem.hpp rename to SDK/include/NazaraSDK/Systems/RenderSystem.hpp index 3b9d3f239..52758bc6d 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NazaraSDK/Systems/RenderSystem.hpp @@ -12,9 +12,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include namespace Ndk @@ -79,7 +79,7 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_RENDERSYSTEM_HPP #endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NazaraSDK/Systems/RenderSystem.inl similarity index 99% rename from SDK/include/NDK/Systems/RenderSystem.inl rename to SDK/include/NazaraSDK/Systems/RenderSystem.inl index 335026f17..ab9d03839 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NazaraSDK/Systems/RenderSystem.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Systems/VelocitySystem.hpp b/SDK/include/NazaraSDK/Systems/VelocitySystem.hpp similarity index 87% rename from SDK/include/NDK/Systems/VelocitySystem.hpp rename to SDK/include/NazaraSDK/Systems/VelocitySystem.hpp index 7bc836d90..46ef02862 100644 --- a/SDK/include/NDK/Systems/VelocitySystem.hpp +++ b/SDK/include/NazaraSDK/Systems/VelocitySystem.hpp @@ -7,7 +7,7 @@ #ifndef NDK_SYSTEMS_VELOCITYSYSTEM_HPP #define NDK_SYSTEMS_VELOCITYSYSTEM_HPP -#include +#include namespace Ndk { @@ -24,6 +24,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_SYSTEMS_VELOCITYSYSTEM_HPP diff --git a/SDK/include/NDK/Systems/VelocitySystem.inl b/SDK/include/NazaraSDK/Systems/VelocitySystem.inl similarity index 100% rename from SDK/include/NDK/Systems/VelocitySystem.inl rename to SDK/include/NazaraSDK/Systems/VelocitySystem.inl diff --git a/SDK/include/NazaraSDK/Widgets.hpp b/SDK/include/NazaraSDK/Widgets.hpp new file mode 100644 index 000000000..e2225bf68 --- /dev/null +++ b/SDK/include/NazaraSDK/Widgets.hpp @@ -0,0 +1,20 @@ +// This file was automatically generated + +#pragma once + +#ifndef NDK_WIDGETS_GLOBAL_HPP +#define NDK_WIDGETS_GLOBAL_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NDK_WIDGETS_GLOBAL_HPP diff --git a/SDK/include/NDK/Widgets/AbstractTextAreaWidget.hpp b/SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp similarity index 97% rename from SDK/include/NDK/Widgets/AbstractTextAreaWidget.hpp rename to SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp index b05f65bce..1a23bfa8e 100644 --- a/SDK/include/NDK/Widgets/AbstractTextAreaWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -130,6 +130,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_ABSTRACTTEXTAREAWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/AbstractTextAreaWidget.inl b/SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl similarity index 99% rename from SDK/include/NDK/Widgets/AbstractTextAreaWidget.inl rename to SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl index ca40d278b..0af05d76e 100644 --- a/SDK/include/NDK/Widgets/AbstractTextAreaWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/BoxLayout.hpp b/SDK/include/NazaraSDK/Widgets/BoxLayout.hpp similarity index 85% rename from SDK/include/NDK/Widgets/BoxLayout.hpp rename to SDK/include/NazaraSDK/Widgets/BoxLayout.hpp index d27616814..5c2ad0a9f 100644 --- a/SDK/include/NDK/Widgets/BoxLayout.hpp +++ b/SDK/include/NazaraSDK/Widgets/BoxLayout.hpp @@ -7,9 +7,9 @@ #ifndef NDK_WIDGETS_BOXLAYOUT_HPP #define NDK_WIDGETS_BOXLAYOUT_HPP -#include -#include -#include +#include +#include +#include #include namespace Ndk @@ -43,6 +43,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_BOXLAYOUT_HPP diff --git a/SDK/include/NDK/Widgets/BoxLayout.inl b/SDK/include/NazaraSDK/Widgets/BoxLayout.inl similarity index 89% rename from SDK/include/NDK/Widgets/BoxLayout.inl rename to SDK/include/NazaraSDK/Widgets/BoxLayout.inl index 72dfaaf5f..aceb4cc9d 100644 --- a/SDK/include/NDK/Widgets/BoxLayout.inl +++ b/SDK/include/NazaraSDK/Widgets/BoxLayout.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NazaraSDK/Widgets/ButtonWidget.hpp similarity index 96% rename from SDK/include/NDK/Widgets/ButtonWidget.hpp rename to SDK/include/NazaraSDK/Widgets/ButtonWidget.hpp index a65429290..3e3b6f16f 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/ButtonWidget.hpp @@ -7,8 +7,8 @@ #ifndef NDK_WIDGETS_BUTTONWIDGET_HPP #define NDK_WIDGETS_BUTTONWIDGET_HPP -#include -#include +#include +#include #include #include #include @@ -94,6 +94,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_BUTTONWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/ButtonWidget.inl b/SDK/include/NazaraSDK/Widgets/ButtonWidget.inl similarity index 98% rename from SDK/include/NDK/Widgets/ButtonWidget.inl rename to SDK/include/NazaraSDK/Widgets/ButtonWidget.inl index 11cf202cf..0924ab882 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/ButtonWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/CheckboxWidget.hpp b/SDK/include/NazaraSDK/Widgets/CheckboxWidget.hpp similarity index 92% rename from SDK/include/NDK/Widgets/CheckboxWidget.hpp rename to SDK/include/NazaraSDK/Widgets/CheckboxWidget.hpp index a9723c20b..d9057a248 100644 --- a/SDK/include/NDK/Widgets/CheckboxWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/CheckboxWidget.hpp @@ -7,10 +7,10 @@ #ifndef NDK_WIDGETS_CHECKBOXWIDGET_HPP #define NDK_WIDGETS_CHECKBOXWIDGET_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -100,6 +100,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_CHECKBOXWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/CheckboxWidget.inl b/SDK/include/NazaraSDK/Widgets/CheckboxWidget.inl similarity index 100% rename from SDK/include/NDK/Widgets/CheckboxWidget.inl rename to SDK/include/NazaraSDK/Widgets/CheckboxWidget.inl diff --git a/SDK/include/NDK/Widgets/Enums.hpp b/SDK/include/NazaraSDK/Widgets/Enums.hpp similarity index 100% rename from SDK/include/NDK/Widgets/Enums.hpp rename to SDK/include/NazaraSDK/Widgets/Enums.hpp diff --git a/SDK/include/NDK/Widgets/ImageWidget.hpp b/SDK/include/NazaraSDK/Widgets/ImageWidget.hpp similarity index 89% rename from SDK/include/NDK/Widgets/ImageWidget.hpp rename to SDK/include/NazaraSDK/Widgets/ImageWidget.hpp index d95af8623..4435a7058 100644 --- a/SDK/include/NDK/Widgets/ImageWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/ImageWidget.hpp @@ -7,9 +7,9 @@ #ifndef NDK_WIDGETS_IMAGEWIDGET_HPP #define NDK_WIDGETS_IMAGEWIDGET_HPP -#include -#include -#include +#include +#include +#include #include #include #include @@ -46,6 +46,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_IMAGEWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/ImageWidget.inl b/SDK/include/NazaraSDK/Widgets/ImageWidget.inl similarity index 96% rename from SDK/include/NDK/Widgets/ImageWidget.inl rename to SDK/include/NazaraSDK/Widgets/ImageWidget.inl index b1835941b..666adf12e 100644 --- a/SDK/include/NDK/Widgets/ImageWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/ImageWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/LabelWidget.hpp b/SDK/include/NazaraSDK/Widgets/LabelWidget.hpp similarity index 87% rename from SDK/include/NDK/Widgets/LabelWidget.hpp rename to SDK/include/NazaraSDK/Widgets/LabelWidget.hpp index 6e3b89ee8..a446262fb 100644 --- a/SDK/include/NDK/Widgets/LabelWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/LabelWidget.hpp @@ -7,8 +7,8 @@ #ifndef NDK_WIDGETS_LABELWIDGET_HPP #define NDK_WIDGETS_LABELWIDGET_HPP -#include -#include +#include +#include #include namespace Nz @@ -37,6 +37,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_LABELWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/LabelWidget.inl b/SDK/include/NazaraSDK/Widgets/LabelWidget.inl similarity index 91% rename from SDK/include/NDK/Widgets/LabelWidget.inl rename to SDK/include/NazaraSDK/Widgets/LabelWidget.inl index cf14ea7d0..de1b6d19e 100644 --- a/SDK/include/NDK/Widgets/LabelWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/LabelWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/ProgressBarWidget.hpp b/SDK/include/NazaraSDK/Widgets/ProgressBarWidget.hpp similarity index 96% rename from SDK/include/NDK/Widgets/ProgressBarWidget.hpp rename to SDK/include/NazaraSDK/Widgets/ProgressBarWidget.hpp index 2ae334b8c..7d2d5d7d4 100644 --- a/SDK/include/NDK/Widgets/ProgressBarWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/ProgressBarWidget.hpp @@ -7,8 +7,8 @@ #ifndef NDK_WIDGETS_PROGRESSBARWIDGET_HPP #define NDK_WIDGETS_PROGRESSBARWIDGET_HPP -#include -#include +#include +#include #include #include #include @@ -96,6 +96,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_PROGRESSBARWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/ProgressBarWidget.inl b/SDK/include/NazaraSDK/Widgets/ProgressBarWidget.inl similarity index 100% rename from SDK/include/NDK/Widgets/ProgressBarWidget.inl rename to SDK/include/NazaraSDK/Widgets/ProgressBarWidget.inl diff --git a/SDK/include/NDK/Widgets/RichTextAreaWidget.hpp b/SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp similarity index 95% rename from SDK/include/NDK/Widgets/RichTextAreaWidget.hpp rename to SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp index a21a233d2..24cf26f7c 100644 --- a/SDK/include/NDK/Widgets/RichTextAreaWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp @@ -8,7 +8,7 @@ #define NDK_WIDGETS_RICHTEXTAREAWIDGET_HPP #include -#include +#include namespace Ndk { @@ -63,6 +63,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_TEXTAREAWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/RichTextAreaWidget.inl b/SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.inl similarity index 97% rename from SDK/include/NDK/Widgets/RichTextAreaWidget.inl rename to SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.inl index 4fd7faa10..82d84c3be 100644 --- a/SDK/include/NDK/Widgets/RichTextAreaWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/ScrollAreaWidget.hpp b/SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp similarity index 94% rename from SDK/include/NDK/Widgets/ScrollAreaWidget.hpp rename to SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp index 17ada16ef..bc4e01a93 100644 --- a/SDK/include/NDK/Widgets/ScrollAreaWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp @@ -7,8 +7,8 @@ #ifndef NDK_WIDGETS_SCROLLAREAWIDGET_HPP #define NDK_WIDGETS_SCROLLAREAWIDGET_HPP -#include -#include +#include +#include #include namespace Ndk @@ -69,6 +69,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_SCROLLAREAWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/ScrollAreaWidget.inl b/SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.inl similarity index 94% rename from SDK/include/NDK/Widgets/ScrollAreaWidget.inl rename to SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.inl index 89bea6d47..64ee3b1df 100644 --- a/SDK/include/NDK/Widgets/ScrollAreaWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NazaraSDK/Widgets/TextAreaWidget.hpp similarity index 96% rename from SDK/include/NDK/Widgets/TextAreaWidget.hpp rename to SDK/include/NazaraSDK/Widgets/TextAreaWidget.hpp index 8b06e7579..c2fe9822c 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NazaraSDK/Widgets/TextAreaWidget.hpp @@ -8,7 +8,7 @@ #define NDK_WIDGETS_TEXTAREAWIDGET_HPP #include -#include +#include namespace Ndk { @@ -72,6 +72,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WIDGETS_TEXTAREAWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NazaraSDK/Widgets/TextAreaWidget.inl similarity index 98% rename from SDK/include/NDK/Widgets/TextAreaWidget.inl rename to SDK/include/NazaraSDK/Widgets/TextAreaWidget.inl index f63897420..776841979 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NazaraSDK/Widgets/TextAreaWidget.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NazaraSDK/World.hpp similarity index 96% rename from SDK/include/NDK/World.hpp rename to SDK/include/NazaraSDK/World.hpp index ca6e917b7..b0d2f3c92 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NazaraSDK/World.hpp @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -134,6 +134,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_WORLD_HPP diff --git a/SDK/include/NDK/World.inl b/SDK/include/NazaraSDK/World.inl similarity index 99% rename from SDK/include/NDK/World.inl rename to SDK/include/NazaraSDK/World.inl index 1c3e446e1..00451153b 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NazaraSDK/World.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NazaraSDK/Application.cpp similarity index 100% rename from SDK/src/NDK/Application.cpp rename to SDK/src/NazaraSDK/Application.cpp diff --git a/SDK/src/NDK/BaseComponent.cpp b/SDK/src/NazaraSDK/BaseComponent.cpp similarity index 98% rename from SDK/src/NDK/BaseComponent.cpp rename to SDK/src/NazaraSDK/BaseComponent.cpp index 5092b9b65..9ed65f3be 100644 --- a/SDK/src/NDK/BaseComponent.cpp +++ b/SDK/src/NazaraSDK/BaseComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/BaseSystem.cpp b/SDK/src/NazaraSDK/BaseSystem.cpp similarity index 97% rename from SDK/src/NDK/BaseSystem.cpp rename to SDK/src/NazaraSDK/BaseSystem.cpp index 11a8e1926..708a6a9db 100644 --- a/SDK/src/NDK/BaseSystem.cpp +++ b/SDK/src/NazaraSDK/BaseSystem.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NazaraSDK/BaseWidget.cpp similarity index 97% rename from SDK/src/NDK/BaseWidget.cpp rename to SDK/src/NazaraSDK/BaseWidget.cpp index cb643dc0c..463ac0f45 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NazaraSDK/BaseWidget.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace Ndk diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NazaraSDK/Canvas.cpp similarity index 99% rename from SDK/src/NDK/Canvas.cpp rename to SDK/src/NazaraSDK/Canvas.cpp index f6d27ad15..2eb09ecac 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NazaraSDK/Canvas.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/src/NDK/Components/CameraComponent.cpp b/SDK/src/NazaraSDK/Components/CameraComponent.cpp similarity index 98% rename from SDK/src/NDK/Components/CameraComponent.cpp rename to SDK/src/NazaraSDK/Components/CameraComponent.cpp index 4a599ab9e..3a7ddda15 100644 --- a/SDK/src/NDK/Components/CameraComponent.cpp +++ b/SDK/src/NazaraSDK/Components/CameraComponent.cpp @@ -2,10 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/CollisionComponent2D.cpp b/SDK/src/NazaraSDK/Components/CollisionComponent2D.cpp similarity index 94% rename from SDK/src/NDK/Components/CollisionComponent2D.cpp rename to SDK/src/NazaraSDK/Components/CollisionComponent2D.cpp index fddbe8842..5d6d21eaa 100644 --- a/SDK/src/NDK/Components/CollisionComponent2D.cpp +++ b/SDK/src/NazaraSDK/Components/CollisionComponent2D.cpp @@ -2,12 +2,12 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/CollisionComponent3D.cpp b/SDK/src/NazaraSDK/Components/CollisionComponent3D.cpp similarity index 94% rename from SDK/src/NDK/Components/CollisionComponent3D.cpp rename to SDK/src/NazaraSDK/Components/CollisionComponent3D.cpp index a147043d7..dc37cb163 100644 --- a/SDK/src/NDK/Components/CollisionComponent3D.cpp +++ b/SDK/src/NazaraSDK/Components/CollisionComponent3D.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/ConstraintComponent2D.cpp b/SDK/src/NazaraSDK/Components/ConstraintComponent2D.cpp similarity index 92% rename from SDK/src/NDK/Components/ConstraintComponent2D.cpp rename to SDK/src/NazaraSDK/Components/ConstraintComponent2D.cpp index 6c75f39ee..5c6e6e091 100644 --- a/SDK/src/NDK/Components/ConstraintComponent2D.cpp +++ b/SDK/src/NazaraSDK/Components/ConstraintComponent2D.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/DebugComponent.cpp b/SDK/src/NazaraSDK/Components/DebugComponent.cpp similarity index 88% rename from SDK/src/NDK/Components/DebugComponent.cpp rename to SDK/src/NazaraSDK/Components/DebugComponent.cpp index 604e1d143..f0cccc684 100644 --- a/SDK/src/NDK/Components/DebugComponent.cpp +++ b/SDK/src/NazaraSDK/Components/DebugComponent.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NazaraSDK/Components/GraphicsComponent.cpp similarity index 98% rename from SDK/src/NDK/Components/GraphicsComponent.cpp rename to SDK/src/NazaraSDK/Components/GraphicsComponent.cpp index 43bfa3b54..8fa933a73 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NazaraSDK/Components/GraphicsComponent.cpp @@ -2,10 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include -#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/LifetimeComponent.cpp b/SDK/src/NazaraSDK/Components/LifetimeComponent.cpp similarity index 82% rename from SDK/src/NDK/Components/LifetimeComponent.cpp rename to SDK/src/NazaraSDK/Components/LifetimeComponent.cpp index 5ffa6da82..18099c3e7 100644 --- a/SDK/src/NDK/Components/LifetimeComponent.cpp +++ b/SDK/src/NazaraSDK/Components/LifetimeComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/LightComponent.cpp b/SDK/src/NazaraSDK/Components/LightComponent.cpp similarity index 82% rename from SDK/src/NDK/Components/LightComponent.cpp rename to SDK/src/NazaraSDK/Components/LightComponent.cpp index 8aeb3f8a9..59ee5cfe7 100644 --- a/SDK/src/NDK/Components/LightComponent.cpp +++ b/SDK/src/NazaraSDK/Components/LightComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/ListenerComponent.cpp b/SDK/src/NazaraSDK/Components/ListenerComponent.cpp similarity index 82% rename from SDK/src/NDK/Components/ListenerComponent.cpp rename to SDK/src/NazaraSDK/Components/ListenerComponent.cpp index 420e685cb..8948ba703 100644 --- a/SDK/src/NDK/Components/ListenerComponent.cpp +++ b/SDK/src/NazaraSDK/Components/ListenerComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/NodeComponent.cpp b/SDK/src/NazaraSDK/Components/NodeComponent.cpp similarity index 83% rename from SDK/src/NDK/Components/NodeComponent.cpp rename to SDK/src/NazaraSDK/Components/NodeComponent.cpp index 5a78ae093..d87a6f76e 100644 --- a/SDK/src/NDK/Components/NodeComponent.cpp +++ b/SDK/src/NazaraSDK/Components/NodeComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NazaraSDK/Components/ParticleEmitterComponent.cpp similarity index 92% rename from SDK/src/NDK/Components/ParticleEmitterComponent.cpp rename to SDK/src/NazaraSDK/Components/ParticleEmitterComponent.cpp index d128f4c16..8268d2b99 100644 --- a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp +++ b/SDK/src/NazaraSDK/Components/ParticleEmitterComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include namespace Ndk diff --git a/SDK/src/NDK/Components/ParticleGroupComponent.cpp b/SDK/src/NazaraSDK/Components/ParticleGroupComponent.cpp similarity index 81% rename from SDK/src/NDK/Components/ParticleGroupComponent.cpp rename to SDK/src/NazaraSDK/Components/ParticleGroupComponent.cpp index 7042eb298..6aef06598 100644 --- a/SDK/src/NDK/Components/ParticleGroupComponent.cpp +++ b/SDK/src/NazaraSDK/Components/ParticleGroupComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/PhysicsComponent2D.cpp b/SDK/src/NazaraSDK/Components/PhysicsComponent2D.cpp similarity index 92% rename from SDK/src/NDK/Components/PhysicsComponent2D.cpp rename to SDK/src/NazaraSDK/Components/PhysicsComponent2D.cpp index 871fa762e..579fad093 100644 --- a/SDK/src/NDK/Components/PhysicsComponent2D.cpp +++ b/SDK/src/NazaraSDK/Components/PhysicsComponent2D.cpp @@ -2,12 +2,12 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include namespace Ndk diff --git a/SDK/src/NDK/Components/PhysicsComponent3D.cpp b/SDK/src/NazaraSDK/Components/PhysicsComponent3D.cpp similarity index 92% rename from SDK/src/NDK/Components/PhysicsComponent3D.cpp rename to SDK/src/NazaraSDK/Components/PhysicsComponent3D.cpp index 4615d3c43..c02a6a7f7 100644 --- a/SDK/src/NDK/Components/PhysicsComponent3D.cpp +++ b/SDK/src/NazaraSDK/Components/PhysicsComponent3D.cpp @@ -2,12 +2,12 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Components/VelocityComponent.cpp b/SDK/src/NazaraSDK/Components/VelocityComponent.cpp similarity index 82% rename from SDK/src/NDK/Components/VelocityComponent.cpp rename to SDK/src/NazaraSDK/Components/VelocityComponent.cpp index a457c4483..a41da1baf 100644 --- a/SDK/src/NDK/Components/VelocityComponent.cpp +++ b/SDK/src/NazaraSDK/Components/VelocityComponent.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NazaraSDK/Console.cpp similarity index 96% rename from SDK/src/NDK/Console.cpp rename to SDK/src/NazaraSDK/Console.cpp index e98ad90ec..2450b8996 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NazaraSDK/Console.cpp @@ -2,13 +2,13 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NazaraSDK/Entity.cpp similarity index 98% rename from SDK/src/NDK/Entity.cpp rename to SDK/src/NazaraSDK/Entity.cpp index 8086e5905..0cfb1125d 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NazaraSDK/Entity.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/EntityList.cpp b/SDK/src/NazaraSDK/EntityList.cpp similarity index 83% rename from SDK/src/NDK/EntityList.cpp rename to SDK/src/NazaraSDK/EntityList.cpp index 49841843d..fe906f84a 100644 --- a/SDK/src/NDK/EntityList.cpp +++ b/SDK/src/NazaraSDK/EntityList.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Resources/checkmark.png.h b/SDK/src/NazaraSDK/Resources/checkmark.png.h similarity index 100% rename from SDK/src/NDK/Resources/checkmark.png.h rename to SDK/src/NazaraSDK/Resources/checkmark.png.h diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NazaraSDK/Sdk.cpp similarity index 74% rename from SDK/src/NDK/Sdk.cpp rename to SDK/src/NazaraSDK/Sdk.cpp index c6a6de027..0a7e08ee3 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NazaraSDK/Sdk.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include @@ -11,34 +11,34 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef NDK_SERVER -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif namespace Ndk diff --git a/SDK/src/NDK/State.cpp b/SDK/src/NazaraSDK/State.cpp similarity index 91% rename from SDK/src/NDK/State.cpp rename to SDK/src/NazaraSDK/State.cpp index dc569c1ac..edc284034 100644 --- a/SDK/src/NDK/State.cpp +++ b/SDK/src/NazaraSDK/State.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/DebugSystem.cpp b/SDK/src/NazaraSDK/Systems/DebugSystem.cpp similarity index 97% rename from SDK/src/NDK/Systems/DebugSystem.cpp rename to SDK/src/NazaraSDK/Systems/DebugSystem.cpp index 5b8bb7aa6..377d8f936 100644 --- a/SDK/src/NDK/Systems/DebugSystem.cpp +++ b/SDK/src/NazaraSDK/Systems/DebugSystem.cpp @@ -2,18 +2,18 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/LifetimeSystem.cpp b/SDK/src/NazaraSDK/Systems/LifetimeSystem.cpp similarity index 84% rename from SDK/src/NDK/Systems/LifetimeSystem.cpp rename to SDK/src/NazaraSDK/Systems/LifetimeSystem.cpp index d575ebdc4..76fd24721 100644 --- a/SDK/src/NDK/Systems/LifetimeSystem.cpp +++ b/SDK/src/NazaraSDK/Systems/LifetimeSystem.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/ListenerSystem.cpp b/SDK/src/NazaraSDK/Systems/ListenerSystem.cpp similarity index 92% rename from SDK/src/NDK/Systems/ListenerSystem.cpp rename to SDK/src/NazaraSDK/Systems/ListenerSystem.cpp index c725bc368..0139b536b 100644 --- a/SDK/src/NDK/Systems/ListenerSystem.cpp +++ b/SDK/src/NazaraSDK/Systems/ListenerSystem.cpp @@ -2,10 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/ParticleSystem.cpp b/SDK/src/NazaraSDK/Systems/ParticleSystem.cpp similarity index 90% rename from SDK/src/NDK/Systems/ParticleSystem.cpp rename to SDK/src/NazaraSDK/Systems/ParticleSystem.cpp index b374bf1e7..0a9ecc3b6 100644 --- a/SDK/src/NDK/Systems/ParticleSystem.cpp +++ b/SDK/src/NazaraSDK/Systems/ParticleSystem.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp b/SDK/src/NazaraSDK/Systems/PhysicsSystem2D.cpp similarity index 97% rename from SDK/src/NDK/Systems/PhysicsSystem2D.cpp rename to SDK/src/NazaraSDK/Systems/PhysicsSystem2D.cpp index 4b6386c74..23559f4fe 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp +++ b/SDK/src/NazaraSDK/Systems/PhysicsSystem2D.cpp @@ -2,13 +2,13 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/PhysicsSystem3D.cpp b/SDK/src/NazaraSDK/Systems/PhysicsSystem3D.cpp similarity index 94% rename from SDK/src/NDK/Systems/PhysicsSystem3D.cpp rename to SDK/src/NazaraSDK/Systems/PhysicsSystem3D.cpp index 4e905a64c..39218e13f 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem3D.cpp +++ b/SDK/src/NazaraSDK/Systems/PhysicsSystem3D.cpp @@ -2,12 +2,12 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NazaraSDK/Systems/RenderSystem.cpp similarity index 97% rename from SDK/src/NDK/Systems/RenderSystem.cpp rename to SDK/src/NazaraSDK/Systems/RenderSystem.cpp index 8b4bfe03f..b2693a041 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NazaraSDK/Systems/RenderSystem.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include @@ -10,11 +10,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NazaraSDK/Systems/VelocitySystem.cpp similarity index 82% rename from SDK/src/NDK/Systems/VelocitySystem.cpp rename to SDK/src/NazaraSDK/Systems/VelocitySystem.cpp index b633d7b68..3ff4b52c1 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NazaraSDK/Systems/VelocitySystem.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp b/SDK/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp similarity index 98% rename from SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp rename to SDK/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp index ddb3467f5..773df6b68 100644 --- a/SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/BoxLayout.cpp b/SDK/src/NazaraSDK/Widgets/BoxLayout.cpp similarity index 98% rename from SDK/src/NDK/Widgets/BoxLayout.cpp rename to SDK/src/NazaraSDK/Widgets/BoxLayout.cpp index 89564ed08..2e59bf559 100644 --- a/SDK/src/NDK/Widgets/BoxLayout.cpp +++ b/SDK/src/NazaraSDK/Widgets/BoxLayout.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #include diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NazaraSDK/Widgets/ButtonWidget.cpp similarity index 96% rename from SDK/src/NDK/Widgets/ButtonWidget.cpp rename to SDK/src/NazaraSDK/Widgets/ButtonWidget.cpp index c88645e44..84818e45b 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/ButtonWidget.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/CheckboxWidget.cpp b/SDK/src/NazaraSDK/Widgets/CheckboxWidget.cpp similarity index 97% rename from SDK/src/NDK/Widgets/CheckboxWidget.cpp rename to SDK/src/NazaraSDK/Widgets/CheckboxWidget.cpp index 7d906d8d1..3c16b1219 100644 --- a/SDK/src/NDK/Widgets/CheckboxWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/CheckboxWidget.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include +#include +#include #include #include @@ -54,7 +54,7 @@ namespace Ndk { const Nz::UInt8 r_checkmark[] = { - #include + #include }; Nz::TextureRef checkmarkTexture = Nz::Texture::LoadFromMemory(r_checkmark, sizeof(r_checkmark) / sizeof(r_checkmark[0])); diff --git a/SDK/src/NDK/Widgets/ImageWidget.cpp b/SDK/src/NazaraSDK/Widgets/ImageWidget.cpp similarity index 79% rename from SDK/src/NDK/Widgets/ImageWidget.cpp rename to SDK/src/NazaraSDK/Widgets/ImageWidget.cpp index 0a1cfdc81..bb8398806 100644 --- a/SDK/src/NDK/Widgets/ImageWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/ImageWidget.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/LabelWidget.cpp b/SDK/src/NazaraSDK/Widgets/LabelWidget.cpp similarity index 76% rename from SDK/src/NDK/Widgets/LabelWidget.cpp rename to SDK/src/NazaraSDK/Widgets/LabelWidget.cpp index 813295622..6c3c2825b 100644 --- a/SDK/src/NDK/Widgets/LabelWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/LabelWidget.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/ProgressBarWidget.cpp b/SDK/src/NazaraSDK/Widgets/ProgressBarWidget.cpp similarity index 95% rename from SDK/src/NDK/Widgets/ProgressBarWidget.cpp rename to SDK/src/NazaraSDK/Widgets/ProgressBarWidget.cpp index cc3f4f2d9..0c566b423 100644 --- a/SDK/src/NDK/Widgets/ProgressBarWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/ProgressBarWidget.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include -#include -#include +#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/RichTextAreaWidget.cpp b/SDK/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp similarity index 99% rename from SDK/src/NDK/Widgets/RichTextAreaWidget.cpp rename to SDK/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp index 35abb6e06..dfb32bd98 100644 --- a/SDK/src/NDK/Widgets/RichTextAreaWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/ScrollAreaWidget.cpp b/SDK/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp similarity index 97% rename from SDK/src/NDK/Widgets/ScrollAreaWidget.cpp rename to SDK/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp index 0d7c1f934..09c33c2a5 100644 --- a/SDK/src/NDK/Widgets/ScrollAreaWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp @@ -2,10 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NazaraSDK/Widgets/TextAreaWidget.cpp similarity index 97% rename from SDK/src/NDK/Widgets/TextAreaWidget.cpp rename to SDK/src/NazaraSDK/Widgets/TextAreaWidget.cpp index 4271f43a1..b6110d781 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NazaraSDK/Widgets/TextAreaWidget.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include -#include -#include +#include +#include namespace Ndk { diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NazaraSDK/World.cpp similarity index 95% rename from SDK/src/NDK/World.cpp rename to SDK/src/NazaraSDK/World.cpp index ef59463bc..f06f1338f 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NazaraSDK/World.cpp @@ -2,20 +2,20 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifndef NDK_SERVER -#include -#include -#include -#include +#include +#include +#include +#include #endif namespace Ndk diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 4952106a8..e3852541e 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -17,12 +17,12 @@ #include // Module de rendu #include // Module utilitaire #include // Module utilitaire -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include // Petite fonction permettant de rendre le déplacement de la caméra moins ridige diff --git a/examples/Particles/Common.cpp b/examples/Particles/Common.cpp index 0ed9096ef..690537d0f 100644 --- a/examples/Particles/Common.cpp +++ b/examples/Particles/Common.cpp @@ -1,8 +1,8 @@ #include "Common.hpp" #include #include -#include -#include +#include +#include ParticleDemo::ParticleDemo(const Nz::String& name, const ExampleShared& exampleShared) : m_shared(exampleShared), diff --git a/examples/Particles/Common.hpp b/examples/Particles/Common.hpp index 658b97419..3d672c5b3 100644 --- a/examples/Particles/Common.hpp +++ b/examples/Particles/Common.hpp @@ -7,10 +7,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/examples/Particles/LogoDemo.cpp b/examples/Particles/LogoDemo.cpp index a4d31ef8d..cb2509500 100644 --- a/examples/Particles/LogoDemo.cpp +++ b/examples/Particles/LogoDemo.cpp @@ -2,8 +2,8 @@ #include #include #include -#include -#include +#include +#include #include namespace diff --git a/examples/Particles/LogoDemo.hpp b/examples/Particles/LogoDemo.hpp index bd0536edf..bbf14e789 100644 --- a/examples/Particles/LogoDemo.hpp +++ b/examples/Particles/LogoDemo.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "Common.hpp" diff --git a/examples/Particles/SpacebattleDemo.cpp b/examples/Particles/SpacebattleDemo.cpp index 6f3205b87..d0c9e2749 100644 --- a/examples/Particles/SpacebattleDemo.cpp +++ b/examples/Particles/SpacebattleDemo.cpp @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include namespace { diff --git a/examples/Particles/SpacebattleDemo.hpp b/examples/Particles/SpacebattleDemo.hpp index e0b928e19..b2aaa5c33 100644 --- a/examples/Particles/SpacebattleDemo.hpp +++ b/examples/Particles/SpacebattleDemo.hpp @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include #include "Common.hpp" diff --git a/examples/Particles/main.cpp b/examples/Particles/main.cpp index 2d77811a4..e31bfeb88 100644 --- a/examples/Particles/main.cpp +++ b/examples/Particles/main.cpp @@ -5,10 +5,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "LogoDemo.hpp" #include "SpacebattleDemo.hpp" #include diff --git a/examples/Tut00/main.cpp b/examples/Tut00/main.cpp index d3018f5e8..5fc95a9c4 100644 --- a/examples/Tut00/main.cpp +++ b/examples/Tut00/main.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include int main(int argc, char* argv[]) diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index 4570cec08..94834829c 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -3,10 +3,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include int main(int argc, char* argv[]) diff --git a/examples/Tut02/main.cpp b/examples/Tut02/main.cpp index 83de624c6..b86ddcef3 100644 --- a/examples/Tut02/main.cpp +++ b/examples/Tut02/main.cpp @@ -3,10 +3,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include int main(int argc, char* argv[]) diff --git a/tests/Engine/Platform/EventHandler.cpp b/tests/Engine/Platform/EventHandler.cpp index a2f64e9f4..c131386af 100644 --- a/tests/Engine/Platform/EventHandler.cpp +++ b/tests/Engine/Platform/EventHandler.cpp @@ -1,12 +1,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "EventHandler/StateContext.hpp" #include "EventHandler/StateFactory.hpp" diff --git a/tests/Engine/Platform/EventHandler/BaseState.cpp b/tests/Engine/Platform/EventHandler/BaseState.cpp index 8cb229445..eacd7c221 100644 --- a/tests/Engine/Platform/EventHandler/BaseState.cpp +++ b/tests/Engine/Platform/EventHandler/BaseState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include BaseState::BaseState(StateContext& context) : State(), diff --git a/tests/Engine/Platform/EventHandler/BaseState.hpp b/tests/Engine/Platform/EventHandler/BaseState.hpp index 2356e39cd..2fc721b9c 100644 --- a/tests/Engine/Platform/EventHandler/BaseState.hpp +++ b/tests/Engine/Platform/EventHandler/BaseState.hpp @@ -5,7 +5,7 @@ #include -#include +#include class StateContext; diff --git a/tests/Engine/Platform/EventHandler/EventState.cpp b/tests/Engine/Platform/EventHandler/EventState.cpp index 1d6a6784a..d45104d23 100644 --- a/tests/Engine/Platform/EventHandler/EventState.cpp +++ b/tests/Engine/Platform/EventHandler/EventState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include EventState::EventState(StateContext& context) : BaseState(context), diff --git a/tests/Engine/Platform/EventHandler/FocusState.cpp b/tests/Engine/Platform/EventHandler/FocusState.cpp index ee5fd5f7e..a90f79608 100644 --- a/tests/Engine/Platform/EventHandler/FocusState.cpp +++ b/tests/Engine/Platform/EventHandler/FocusState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include FocusState::FocusState(StateContext& context) : BaseState(context) diff --git a/tests/Engine/Platform/EventHandler/KeyState.cpp b/tests/Engine/Platform/EventHandler/KeyState.cpp index 40bd785f1..82d1d0160 100644 --- a/tests/Engine/Platform/EventHandler/KeyState.cpp +++ b/tests/Engine/Platform/EventHandler/KeyState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include KeyState::KeyState(StateContext& context) : BaseState(context), diff --git a/tests/Engine/Platform/EventHandler/MenuState.cpp b/tests/Engine/Platform/EventHandler/MenuState.cpp index d1a244369..c967744b4 100644 --- a/tests/Engine/Platform/EventHandler/MenuState.cpp +++ b/tests/Engine/Platform/EventHandler/MenuState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include MenuState::MenuState(StateContext& context) : BaseState(context), diff --git a/tests/Engine/Platform/EventHandler/MouseClickState.cpp b/tests/Engine/Platform/EventHandler/MouseClickState.cpp index 74cb8ef79..53ae46496 100644 --- a/tests/Engine/Platform/EventHandler/MouseClickState.cpp +++ b/tests/Engine/Platform/EventHandler/MouseClickState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include MouseClickState::MouseClickState(StateContext& context) : BaseState(context) diff --git a/tests/Engine/Platform/EventHandler/MouseEnterState.cpp b/tests/Engine/Platform/EventHandler/MouseEnterState.cpp index 1eb2ca9e2..fa3ddf51b 100644 --- a/tests/Engine/Platform/EventHandler/MouseEnterState.cpp +++ b/tests/Engine/Platform/EventHandler/MouseEnterState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include MouseEnterState::MouseEnterState(StateContext& context) : BaseState(context) diff --git a/tests/Engine/Platform/EventHandler/MouseMoveState.cpp b/tests/Engine/Platform/EventHandler/MouseMoveState.cpp index f0fcb3659..9ff4e2ac4 100644 --- a/tests/Engine/Platform/EventHandler/MouseMoveState.cpp +++ b/tests/Engine/Platform/EventHandler/MouseMoveState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include MouseMoveState::MouseMoveState(StateContext& context) : BaseState(context) diff --git a/tests/Engine/Platform/EventHandler/StateFactory.hpp b/tests/Engine/Platform/EventHandler/StateFactory.hpp index a17965d9d..596934fbb 100644 --- a/tests/Engine/Platform/EventHandler/StateFactory.hpp +++ b/tests/Engine/Platform/EventHandler/StateFactory.hpp @@ -1,7 +1,7 @@ #ifndef __STATEFACTORY_HPP__ #define __STATEFACTORY_HPP__ -#include +#include #include #include diff --git a/tests/Engine/Platform/EventHandler/Text.cpp b/tests/Engine/Platform/EventHandler/Text.cpp index 98637b276..5aef2ceac 100644 --- a/tests/Engine/Platform/EventHandler/Text.cpp +++ b/tests/Engine/Platform/EventHandler/Text.cpp @@ -2,10 +2,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include Text::Text(StateContext& stateContext) : m_context(stateContext) diff --git a/tests/Engine/Platform/EventHandler/Text.hpp b/tests/Engine/Platform/EventHandler/Text.hpp index a804b4baa..7997759aa 100644 --- a/tests/Engine/Platform/EventHandler/Text.hpp +++ b/tests/Engine/Platform/EventHandler/Text.hpp @@ -2,7 +2,7 @@ #define __TEXT_HPP__ #include -#include +#include #include "StateContext.hpp" class Text diff --git a/tests/Engine/Platform/EventHandler/TextEnterState.cpp b/tests/Engine/Platform/EventHandler/TextEnterState.cpp index 2aa58da69..22a1b34b9 100644 --- a/tests/Engine/Platform/EventHandler/TextEnterState.cpp +++ b/tests/Engine/Platform/EventHandler/TextEnterState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include TextEnterState::TextEnterState(StateContext& context) : BaseState(context) diff --git a/tests/Engine/Platform/EventHandler/WindowModificationState.cpp b/tests/Engine/Platform/EventHandler/WindowModificationState.cpp index 027185fe6..0ea87c4af 100644 --- a/tests/Engine/Platform/EventHandler/WindowModificationState.cpp +++ b/tests/Engine/Platform/EventHandler/WindowModificationState.cpp @@ -4,7 +4,7 @@ #include "StateFactory.hpp" #include -#include +#include WindowModificationState::WindowModificationState(StateContext& context) : BaseState(context) diff --git a/tests/SDK/NDK/Application.cpp b/tests/SDK/NDK/Application.cpp index 3eab5645e..a7f471255 100644 --- a/tests/SDK/NDK/Application.cpp +++ b/tests/SDK/NDK/Application.cpp @@ -1,4 +1,4 @@ -#include +#include #include SCENARIO("Application", "[NDK][APPLICATION]") diff --git a/tests/SDK/NDK/BaseSystem.cpp b/tests/SDK/NDK/BaseSystem.cpp index 84649df22..bf86a9011 100644 --- a/tests/SDK/NDK/BaseSystem.cpp +++ b/tests/SDK/NDK/BaseSystem.cpp @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include namespace diff --git a/tests/SDK/NDK/Component.cpp b/tests/SDK/NDK/Component.cpp index c41f541be..74244fda5 100644 --- a/tests/SDK/NDK/Component.cpp +++ b/tests/SDK/NDK/Component.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace diff --git a/tests/SDK/NDK/Entity.cpp b/tests/SDK/NDK/Entity.cpp index 7d59cfc20..e17b9114d 100644 --- a/tests/SDK/NDK/Entity.cpp +++ b/tests/SDK/NDK/Entity.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include namespace diff --git a/tests/SDK/NDK/EntityList.cpp b/tests/SDK/NDK/EntityList.cpp index 0642b50b7..6b9c85ddf 100644 --- a/tests/SDK/NDK/EntityList.cpp +++ b/tests/SDK/NDK/EntityList.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include SCENARIO("EntityList", "[NDK][ENTITYLIST]") diff --git a/tests/SDK/NDK/EntityOwner.cpp b/tests/SDK/NDK/EntityOwner.cpp index b7ce87e15..1cb6f768c 100644 --- a/tests/SDK/NDK/EntityOwner.cpp +++ b/tests/SDK/NDK/EntityOwner.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]") diff --git a/tests/SDK/NDK/StateMachine.cpp b/tests/SDK/NDK/StateMachine.cpp index 15502c5cf..29a781e2c 100644 --- a/tests/SDK/NDK/StateMachine.cpp +++ b/tests/SDK/NDK/StateMachine.cpp @@ -1,4 +1,4 @@ -#include +#include #include class TestState : public Ndk::State diff --git a/tests/SDK/NDK/System.cpp b/tests/SDK/NDK/System.cpp index 5f6d74284..a6ef4e590 100644 --- a/tests/SDK/NDK/System.cpp +++ b/tests/SDK/NDK/System.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace diff --git a/tests/SDK/NDK/Systems/ListenerSystem.cpp b/tests/SDK/NDK/Systems/ListenerSystem.cpp index b83b24cd1..85a8f8fb1 100644 --- a/tests/SDK/NDK/Systems/ListenerSystem.cpp +++ b/tests/SDK/NDK/Systems/ListenerSystem.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp b/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp index 770f1e190..2081da617 100644 --- a/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp +++ b/tests/SDK/NDK/Systems/PhysicsSystem2D.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp b/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp index b66aa89b7..7dc66673c 100644 --- a/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp +++ b/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include SCENARIO("PhysicsSystem3D", "[NDK][PHYSICSSYSTEM3D]") diff --git a/tests/SDK/NDK/Systems/RenderSystem.cpp b/tests/SDK/NDK/Systems/RenderSystem.cpp index e30fa3a03..110b98299 100644 --- a/tests/SDK/NDK/Systems/RenderSystem.cpp +++ b/tests/SDK/NDK/Systems/RenderSystem.cpp @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/tests/SDK/NDK/Systems/VelocitySystem.cpp b/tests/SDK/NDK/Systems/VelocitySystem.cpp index aff645106..de77de28d 100644 --- a/tests/SDK/NDK/Systems/VelocitySystem.cpp +++ b/tests/SDK/NDK/Systems/VelocitySystem.cpp @@ -1,7 +1,7 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]") diff --git a/tests/SDK/NDK/World.cpp b/tests/SDK/NDK/World.cpp index f98a7e2e1..56cb49d92 100644 --- a/tests/SDK/NDK/World.cpp +++ b/tests/SDK/NDK/World.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include namespace diff --git a/tests/main.cpp b/tests/main.cpp index 34bb79e5f..0e4581f17 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,7 +1,7 @@ #define CATCH_CONFIG_RUNNER #include -#include +#include #include #include #include From c69ee0b896f0a508a4707be1b0ee62f34e51115b Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 18:04:33 +0100 Subject: [PATCH 18/25] Fix premake issues --- build/scripts/tools/ndk.lua | 10 +++++----- build/scripts/tools/ndk_server.lua | 9 +-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 7cb1f24a5..1f7000351 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -14,11 +14,11 @@ TOOL.Includes = { } TOOL.Files = { - "../SDK/include/NDK/**.hpp", - "../SDK/include/NDK/**.inl", - "../SDK/src/NDK/**.hpp", - "../SDK/src/NDK/**.inl", - "../SDK/src/NDK/**.cpp" + "../SDK/include/NazaraSDK/**.hpp", + "../SDK/include/NazaraSDK/**.inl", + "../SDK/src/NazaraSDK/**.hpp", + "../SDK/src/NazaraSDK/**.inl", + "../SDK/src/NazaraSDK/**.cpp" } TOOL.Libraries = function() diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 2fd17e7f1..8a74510fd 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -36,20 +36,13 @@ TOOL.FilesExcluded = { "../SDK/**/Particle*Component.*", "../SDK/**/ParticleSystem.*", "../SDK/**/RenderSystem.*", - "../SDK/**/*Layout*.*", - "../SDK/**/*Widget*.*", - "../SDK/**/LuaBinding_Audio.*", - "../SDK/**/LuaBinding_Graphics.*", - "../SDK/**/LuaBinding_Renderer.*", - "../SDK/**/LuaBinding_Platform.*" + "../SDK/**/*Layout*.*" } TOOL.Libraries = { "NazaraCore", - "NazaraLua", "NazaraNetwork", - "NazaraNoise", "NazaraPhysics2D", "NazaraPhysics3D", "NazaraUtility" From f0d11aea7289bb0c6f689bc5fe9275ebfd8e80f0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 18:05:12 +0100 Subject: [PATCH 19/25] Fix missing include --- examples/DopplerEffect/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/DopplerEffect/main.cpp b/examples/DopplerEffect/main.cpp index b0c7a8f62..464e4ef59 100644 --- a/examples/DopplerEffect/main.cpp +++ b/examples/DopplerEffect/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include int main() { From b6b3ac9f312b5d3dc7146cfbae77bd3842fc6787 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 18:23:30 +0100 Subject: [PATCH 20/25] Move SDK include and source to base --- build/scripts/tools/ndk.lua | 14 +++--- build/scripts/tools/ndk_server.lua | 43 ++++++++++--------- .../NazaraSDK/Algorithm.hpp | 0 .../NazaraSDK/Algorithm.inl | 0 .../NazaraSDK/Application.hpp | 0 .../NazaraSDK/Application.inl | 0 .../NazaraSDK/BaseComponent.hpp | 0 .../NazaraSDK/BaseComponent.inl | 0 .../NazaraSDK/BaseSystem.hpp | 0 .../NazaraSDK/BaseSystem.inl | 0 .../NazaraSDK/BaseWidget.hpp | 0 .../NazaraSDK/BaseWidget.inl | 0 {SDK/include => include}/NazaraSDK/Canvas.hpp | 0 {SDK/include => include}/NazaraSDK/Canvas.inl | 0 .../NazaraSDK/Component.hpp | 0 .../NazaraSDK/Component.inl | 0 .../NazaraSDK/Components.hpp | 0 .../NazaraSDK/Components/CameraComponent.hpp | 0 .../NazaraSDK/Components/CameraComponent.inl | 0 .../Components/CollisionComponent2D.hpp | 0 .../Components/CollisionComponent2D.inl | 0 .../Components/CollisionComponent3D.hpp | 0 .../Components/CollisionComponent3D.inl | 0 .../Components/ConstraintComponent2D.hpp | 0 .../Components/ConstraintComponent2D.inl | 0 .../NazaraSDK/Components/DebugComponent.hpp | 0 .../NazaraSDK/Components/DebugComponent.inl | 0 .../Components/GraphicsComponent.hpp | 0 .../Components/GraphicsComponent.inl | 0 .../Components/LifetimeComponent.hpp | 0 .../Components/LifetimeComponent.inl | 0 .../NazaraSDK/Components/LightComponent.hpp | 0 .../NazaraSDK/Components/LightComponent.inl | 0 .../Components/ListenerComponent.hpp | 0 .../Components/ListenerComponent.inl | 0 .../NazaraSDK/Components/NodeComponent.hpp | 0 .../NazaraSDK/Components/NodeComponent.inl | 0 .../Components/ParticleEmitterComponent.hpp | 0 .../Components/ParticleEmitterComponent.inl | 0 .../Components/ParticleGroupComponent.hpp | 0 .../Components/ParticleGroupComponent.inl | 0 .../Components/PhysicsComponent2D.hpp | 0 .../Components/PhysicsComponent2D.inl | 0 .../Components/PhysicsComponent3D.hpp | 0 .../Components/PhysicsComponent3D.inl | 0 .../Components/VelocityComponent.hpp | 0 .../Components/VelocityComponent.inl | 0 .../include => include}/NazaraSDK/Console.hpp | 0 .../include => include}/NazaraSDK/Console.inl | 0 {SDK/include => include}/NazaraSDK/Entity.hpp | 0 {SDK/include => include}/NazaraSDK/Entity.inl | 0 .../NazaraSDK/EntityList.hpp | 0 .../NazaraSDK/EntityList.inl | 0 .../NazaraSDK/EntityOwner.hpp | 0 .../NazaraSDK/EntityOwner.inl | 0 .../NazaraSDK/Prerequisites.hpp | 0 {SDK/include => include}/NazaraSDK/Sdk.hpp | 0 {SDK/include => include}/NazaraSDK/Sdk.inl | 0 {SDK/include => include}/NazaraSDK/State.hpp | 0 .../NazaraSDK/StateMachine.hpp | 0 .../NazaraSDK/StateMachine.inl | 0 {SDK/include => include}/NazaraSDK/System.hpp | 0 {SDK/include => include}/NazaraSDK/System.inl | 0 .../include => include}/NazaraSDK/Systems.hpp | 0 .../NazaraSDK/Systems/DebugSystem.hpp | 0 .../NazaraSDK/Systems/DebugSystem.inl | 0 .../NazaraSDK/Systems/LifetimeSystem.hpp | 0 .../NazaraSDK/Systems/LifetimeSystem.inl | 0 .../NazaraSDK/Systems/ListenerSystem.hpp | 0 .../NazaraSDK/Systems/ListenerSystem.inl | 0 .../NazaraSDK/Systems/ParticleSystem.hpp | 0 .../NazaraSDK/Systems/ParticleSystem.inl | 0 .../NazaraSDK/Systems/PhysicsSystem2D.hpp | 0 .../NazaraSDK/Systems/PhysicsSystem2D.inl | 0 .../NazaraSDK/Systems/PhysicsSystem3D.hpp | 0 .../NazaraSDK/Systems/PhysicsSystem3D.inl | 0 .../NazaraSDK/Systems/RenderSystem.hpp | 0 .../NazaraSDK/Systems/RenderSystem.inl | 0 .../NazaraSDK/Systems/VelocitySystem.hpp | 0 .../NazaraSDK/Systems/VelocitySystem.inl | 0 .../include => include}/NazaraSDK/Widgets.hpp | 0 .../Widgets/AbstractTextAreaWidget.hpp | 0 .../Widgets/AbstractTextAreaWidget.inl | 0 .../NazaraSDK/Widgets/BoxLayout.hpp | 0 .../NazaraSDK/Widgets/BoxLayout.inl | 0 .../NazaraSDK/Widgets/ButtonWidget.hpp | 0 .../NazaraSDK/Widgets/ButtonWidget.inl | 0 .../NazaraSDK/Widgets/CheckboxWidget.hpp | 0 .../NazaraSDK/Widgets/CheckboxWidget.inl | 0 .../NazaraSDK/Widgets/Enums.hpp | 0 .../NazaraSDK/Widgets/ImageWidget.hpp | 0 .../NazaraSDK/Widgets/ImageWidget.inl | 0 .../NazaraSDK/Widgets/LabelWidget.hpp | 0 .../NazaraSDK/Widgets/LabelWidget.inl | 0 .../NazaraSDK/Widgets/ProgressBarWidget.hpp | 0 .../NazaraSDK/Widgets/ProgressBarWidget.inl | 0 .../NazaraSDK/Widgets/RichTextAreaWidget.hpp | 0 .../NazaraSDK/Widgets/RichTextAreaWidget.inl | 0 .../NazaraSDK/Widgets/ScrollAreaWidget.hpp | 0 .../NazaraSDK/Widgets/ScrollAreaWidget.inl | 0 .../NazaraSDK/Widgets/TextAreaWidget.hpp | 0 .../NazaraSDK/Widgets/TextAreaWidget.inl | 0 {SDK/include => include}/NazaraSDK/World.hpp | 0 {SDK/include => include}/NazaraSDK/World.inl | 0 {SDK/src => src}/NazaraSDK/Application.cpp | 10 ++--- {SDK/src => src}/NazaraSDK/BaseComponent.cpp | 0 {SDK/src => src}/NazaraSDK/BaseSystem.cpp | 0 {SDK/src => src}/NazaraSDK/BaseWidget.cpp | 0 {SDK/src => src}/NazaraSDK/Canvas.cpp | 0 .../NazaraSDK/Components/CameraComponent.cpp | 0 .../Components/CollisionComponent2D.cpp | 0 .../Components/CollisionComponent3D.cpp | 0 .../Components/ConstraintComponent2D.cpp | 0 .../NazaraSDK/Components/DebugComponent.cpp | 0 .../Components/GraphicsComponent.cpp | 0 .../Components/LifetimeComponent.cpp | 0 .../NazaraSDK/Components/LightComponent.cpp | 0 .../Components/ListenerComponent.cpp | 0 .../NazaraSDK/Components/NodeComponent.cpp | 0 .../Components/ParticleEmitterComponent.cpp | 0 .../Components/ParticleGroupComponent.cpp | 0 .../Components/PhysicsComponent2D.cpp | 0 .../Components/PhysicsComponent3D.cpp | 0 .../Components/VelocityComponent.cpp | 0 {SDK/src => src}/NazaraSDK/Console.cpp | 0 {SDK/src => src}/NazaraSDK/Entity.cpp | 0 {SDK/src => src}/NazaraSDK/EntityList.cpp | 0 .../NazaraSDK/Resources/checkmark.png.h | 0 {SDK/src => src}/NazaraSDK/Sdk.cpp | 0 {SDK/src => src}/NazaraSDK/State.cpp | 0 .../NazaraSDK/Systems/DebugSystem.cpp | 0 .../NazaraSDK/Systems/LifetimeSystem.cpp | 0 .../NazaraSDK/Systems/ListenerSystem.cpp | 0 .../NazaraSDK/Systems/ParticleSystem.cpp | 0 .../NazaraSDK/Systems/PhysicsSystem2D.cpp | 0 .../NazaraSDK/Systems/PhysicsSystem3D.cpp | 0 .../NazaraSDK/Systems/RenderSystem.cpp | 0 .../NazaraSDK/Systems/VelocitySystem.cpp | 0 .../Widgets/AbstractTextAreaWidget.cpp | 0 .../NazaraSDK/Widgets/BoxLayout.cpp | 0 .../NazaraSDK/Widgets/ButtonWidget.cpp | 0 .../NazaraSDK/Widgets/CheckboxWidget.cpp | 0 .../NazaraSDK/Widgets/ImageWidget.cpp | 0 .../NazaraSDK/Widgets/LabelWidget.cpp | 0 .../NazaraSDK/Widgets/ProgressBarWidget.cpp | 0 .../NazaraSDK/Widgets/RichTextAreaWidget.cpp | 0 .../NazaraSDK/Widgets/ScrollAreaWidget.cpp | 0 .../NazaraSDK/Widgets/TextAreaWidget.cpp | 0 {SDK/src => src}/NazaraSDK/World.cpp | 0 149 files changed, 34 insertions(+), 33 deletions(-) rename {SDK/include => include}/NazaraSDK/Algorithm.hpp (100%) rename {SDK/include => include}/NazaraSDK/Algorithm.inl (100%) rename {SDK/include => include}/NazaraSDK/Application.hpp (100%) rename {SDK/include => include}/NazaraSDK/Application.inl (100%) rename {SDK/include => include}/NazaraSDK/BaseComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/BaseComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/BaseSystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/BaseSystem.inl (100%) rename {SDK/include => include}/NazaraSDK/BaseWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/BaseWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Canvas.hpp (100%) rename {SDK/include => include}/NazaraSDK/Canvas.inl (100%) rename {SDK/include => include}/NazaraSDK/Component.hpp (100%) rename {SDK/include => include}/NazaraSDK/Component.inl (100%) rename {SDK/include => include}/NazaraSDK/Components.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/CameraComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/CameraComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/CollisionComponent2D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/CollisionComponent2D.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/CollisionComponent3D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/CollisionComponent3D.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/ConstraintComponent2D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/ConstraintComponent2D.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/DebugComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/DebugComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/GraphicsComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/GraphicsComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/LifetimeComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/LifetimeComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/LightComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/LightComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/ListenerComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/ListenerComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/NodeComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/NodeComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/ParticleEmitterComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/ParticleEmitterComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/ParticleGroupComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/ParticleGroupComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/PhysicsComponent2D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/PhysicsComponent2D.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/PhysicsComponent3D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/PhysicsComponent3D.inl (100%) rename {SDK/include => include}/NazaraSDK/Components/VelocityComponent.hpp (100%) rename {SDK/include => include}/NazaraSDK/Components/VelocityComponent.inl (100%) rename {SDK/include => include}/NazaraSDK/Console.hpp (100%) rename {SDK/include => include}/NazaraSDK/Console.inl (100%) rename {SDK/include => include}/NazaraSDK/Entity.hpp (100%) rename {SDK/include => include}/NazaraSDK/Entity.inl (100%) rename {SDK/include => include}/NazaraSDK/EntityList.hpp (100%) rename {SDK/include => include}/NazaraSDK/EntityList.inl (100%) rename {SDK/include => include}/NazaraSDK/EntityOwner.hpp (100%) rename {SDK/include => include}/NazaraSDK/EntityOwner.inl (100%) rename {SDK/include => include}/NazaraSDK/Prerequisites.hpp (100%) rename {SDK/include => include}/NazaraSDK/Sdk.hpp (100%) rename {SDK/include => include}/NazaraSDK/Sdk.inl (100%) rename {SDK/include => include}/NazaraSDK/State.hpp (100%) rename {SDK/include => include}/NazaraSDK/StateMachine.hpp (100%) rename {SDK/include => include}/NazaraSDK/StateMachine.inl (100%) rename {SDK/include => include}/NazaraSDK/System.hpp (100%) rename {SDK/include => include}/NazaraSDK/System.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/DebugSystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/DebugSystem.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/LifetimeSystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/LifetimeSystem.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/ListenerSystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/ListenerSystem.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/ParticleSystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/ParticleSystem.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/PhysicsSystem2D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/PhysicsSystem2D.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/PhysicsSystem3D.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/PhysicsSystem3D.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/RenderSystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/RenderSystem.inl (100%) rename {SDK/include => include}/NazaraSDK/Systems/VelocitySystem.hpp (100%) rename {SDK/include => include}/NazaraSDK/Systems/VelocitySystem.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/AbstractTextAreaWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/BoxLayout.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/BoxLayout.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ButtonWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ButtonWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/CheckboxWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/CheckboxWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/Enums.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ImageWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ImageWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/LabelWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/LabelWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ProgressBarWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ProgressBarWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/RichTextAreaWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/RichTextAreaWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ScrollAreaWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/ScrollAreaWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/Widgets/TextAreaWidget.hpp (100%) rename {SDK/include => include}/NazaraSDK/Widgets/TextAreaWidget.inl (100%) rename {SDK/include => include}/NazaraSDK/World.hpp (100%) rename {SDK/include => include}/NazaraSDK/World.inl (100%) rename {SDK/src => src}/NazaraSDK/Application.cpp (96%) rename {SDK/src => src}/NazaraSDK/BaseComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/BaseSystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/BaseWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Canvas.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/CameraComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/CollisionComponent2D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/CollisionComponent3D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/ConstraintComponent2D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/DebugComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/GraphicsComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/LifetimeComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/LightComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/ListenerComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/NodeComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/ParticleEmitterComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/ParticleGroupComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/PhysicsComponent2D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/PhysicsComponent3D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Components/VelocityComponent.cpp (100%) rename {SDK/src => src}/NazaraSDK/Console.cpp (100%) rename {SDK/src => src}/NazaraSDK/Entity.cpp (100%) rename {SDK/src => src}/NazaraSDK/EntityList.cpp (100%) rename {SDK/src => src}/NazaraSDK/Resources/checkmark.png.h (100%) rename {SDK/src => src}/NazaraSDK/Sdk.cpp (100%) rename {SDK/src => src}/NazaraSDK/State.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/DebugSystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/LifetimeSystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/ListenerSystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/ParticleSystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/PhysicsSystem2D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/PhysicsSystem3D.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/RenderSystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/Systems/VelocitySystem.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/BoxLayout.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/ButtonWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/CheckboxWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/ImageWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/LabelWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/ProgressBarWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/RichTextAreaWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/ScrollAreaWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/Widgets/TextAreaWidget.cpp (100%) rename {SDK/src => src}/NazaraSDK/World.cpp (100%) diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 1f7000351..49d7ee94d 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -9,16 +9,16 @@ TOOL.Defines = { } TOOL.Includes = { - "../SDK/include", - "../SDK/src" + "../include", + "../src" } TOOL.Files = { - "../SDK/include/NazaraSDK/**.hpp", - "../SDK/include/NazaraSDK/**.inl", - "../SDK/src/NazaraSDK/**.hpp", - "../SDK/src/NazaraSDK/**.inl", - "../SDK/src/NazaraSDK/**.cpp" + "../include/NazaraSDK/**.hpp", + "../include/NazaraSDK/**.inl", + "../src/NazaraSDK/**.hpp", + "../src/NazaraSDK/**.inl", + "../src/NazaraSDK/**.cpp" } TOOL.Libraries = function() diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 8a74510fd..96ef7a0ab 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -10,36 +10,37 @@ TOOL.Defines = { } TOOL.Includes = { - "../SDK/include", - "../SDK/src" + "../include", + "../src" } TOOL.Files = { - "../SDK/include/NDK/**.hpp", - "../SDK/include/NDK/**.inl", - "../SDK/src/NDK/**.hpp", - "../SDK/src/NDK/**.inl", - "../SDK/src/NDK/**.cpp" + "../include/NazaraSDK/**.hpp", + "../include/NazaraSDK/**.inl", + "../src/NazaraSDK/**.hpp", + "../src/NazaraSDK/**.inl", + "../src/NazaraSDK/**.cpp" } -- Excludes client-only files TOOL.FilesExcluded = { - "../SDK/**/CameraComponent.*", - "../SDK/**/Canvas.*", - "../SDK/**/Console.*", - "../SDK/**/DebugComponent.*", - "../SDK/**/DebugSystem.*", - "../SDK/**/GraphicsComponent.*", - "../SDK/**/LightComponent.*", - "../SDK/**/ListenerComponent.*", - "../SDK/**/ListenerSystem.*", - "../SDK/**/Particle*Component.*", - "../SDK/**/ParticleSystem.*", - "../SDK/**/RenderSystem.*", - "../SDK/**/*Layout*.*" + "../*/NazaraSDK/BaseWidget.*", + "../*/NazaraSDK/Canvas.*", + "../*/NazaraSDK/Console.*", + "../*/NazaraSDK/**/CameraComponent.*", + "../*/NazaraSDK/**/DebugComponent.*", + "../*/NazaraSDK/**/DebugSystem.*", + "../*/NazaraSDK/**/GraphicsComponent.*", + "../*/NazaraSDK/**/LightComponent.*", + "../*/NazaraSDK/**/ListenerComponent.*", + "../*/NazaraSDK/**/ListenerSystem.*", + "../*/NazaraSDK/**/Particle*Component.*", + "../*/NazaraSDK/**/ParticleSystem.*", + "../*/NazaraSDK/**/RenderSystem.*", + "../*/NazaraSDK/**/*Layout*.*", + "../*/NazaraSDK/**/*Widget*.*" } - TOOL.Libraries = { "NazaraCore", "NazaraNetwork", diff --git a/SDK/include/NazaraSDK/Algorithm.hpp b/include/NazaraSDK/Algorithm.hpp similarity index 100% rename from SDK/include/NazaraSDK/Algorithm.hpp rename to include/NazaraSDK/Algorithm.hpp diff --git a/SDK/include/NazaraSDK/Algorithm.inl b/include/NazaraSDK/Algorithm.inl similarity index 100% rename from SDK/include/NazaraSDK/Algorithm.inl rename to include/NazaraSDK/Algorithm.inl diff --git a/SDK/include/NazaraSDK/Application.hpp b/include/NazaraSDK/Application.hpp similarity index 100% rename from SDK/include/NazaraSDK/Application.hpp rename to include/NazaraSDK/Application.hpp diff --git a/SDK/include/NazaraSDK/Application.inl b/include/NazaraSDK/Application.inl similarity index 100% rename from SDK/include/NazaraSDK/Application.inl rename to include/NazaraSDK/Application.inl diff --git a/SDK/include/NazaraSDK/BaseComponent.hpp b/include/NazaraSDK/BaseComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/BaseComponent.hpp rename to include/NazaraSDK/BaseComponent.hpp diff --git a/SDK/include/NazaraSDK/BaseComponent.inl b/include/NazaraSDK/BaseComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/BaseComponent.inl rename to include/NazaraSDK/BaseComponent.inl diff --git a/SDK/include/NazaraSDK/BaseSystem.hpp b/include/NazaraSDK/BaseSystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/BaseSystem.hpp rename to include/NazaraSDK/BaseSystem.hpp diff --git a/SDK/include/NazaraSDK/BaseSystem.inl b/include/NazaraSDK/BaseSystem.inl similarity index 100% rename from SDK/include/NazaraSDK/BaseSystem.inl rename to include/NazaraSDK/BaseSystem.inl diff --git a/SDK/include/NazaraSDK/BaseWidget.hpp b/include/NazaraSDK/BaseWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/BaseWidget.hpp rename to include/NazaraSDK/BaseWidget.hpp diff --git a/SDK/include/NazaraSDK/BaseWidget.inl b/include/NazaraSDK/BaseWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/BaseWidget.inl rename to include/NazaraSDK/BaseWidget.inl diff --git a/SDK/include/NazaraSDK/Canvas.hpp b/include/NazaraSDK/Canvas.hpp similarity index 100% rename from SDK/include/NazaraSDK/Canvas.hpp rename to include/NazaraSDK/Canvas.hpp diff --git a/SDK/include/NazaraSDK/Canvas.inl b/include/NazaraSDK/Canvas.inl similarity index 100% rename from SDK/include/NazaraSDK/Canvas.inl rename to include/NazaraSDK/Canvas.inl diff --git a/SDK/include/NazaraSDK/Component.hpp b/include/NazaraSDK/Component.hpp similarity index 100% rename from SDK/include/NazaraSDK/Component.hpp rename to include/NazaraSDK/Component.hpp diff --git a/SDK/include/NazaraSDK/Component.inl b/include/NazaraSDK/Component.inl similarity index 100% rename from SDK/include/NazaraSDK/Component.inl rename to include/NazaraSDK/Component.inl diff --git a/SDK/include/NazaraSDK/Components.hpp b/include/NazaraSDK/Components.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components.hpp rename to include/NazaraSDK/Components.hpp diff --git a/SDK/include/NazaraSDK/Components/CameraComponent.hpp b/include/NazaraSDK/Components/CameraComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/CameraComponent.hpp rename to include/NazaraSDK/Components/CameraComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/CameraComponent.inl b/include/NazaraSDK/Components/CameraComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/CameraComponent.inl rename to include/NazaraSDK/Components/CameraComponent.inl diff --git a/SDK/include/NazaraSDK/Components/CollisionComponent2D.hpp b/include/NazaraSDK/Components/CollisionComponent2D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/CollisionComponent2D.hpp rename to include/NazaraSDK/Components/CollisionComponent2D.hpp diff --git a/SDK/include/NazaraSDK/Components/CollisionComponent2D.inl b/include/NazaraSDK/Components/CollisionComponent2D.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/CollisionComponent2D.inl rename to include/NazaraSDK/Components/CollisionComponent2D.inl diff --git a/SDK/include/NazaraSDK/Components/CollisionComponent3D.hpp b/include/NazaraSDK/Components/CollisionComponent3D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/CollisionComponent3D.hpp rename to include/NazaraSDK/Components/CollisionComponent3D.hpp diff --git a/SDK/include/NazaraSDK/Components/CollisionComponent3D.inl b/include/NazaraSDK/Components/CollisionComponent3D.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/CollisionComponent3D.inl rename to include/NazaraSDK/Components/CollisionComponent3D.inl diff --git a/SDK/include/NazaraSDK/Components/ConstraintComponent2D.hpp b/include/NazaraSDK/Components/ConstraintComponent2D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/ConstraintComponent2D.hpp rename to include/NazaraSDK/Components/ConstraintComponent2D.hpp diff --git a/SDK/include/NazaraSDK/Components/ConstraintComponent2D.inl b/include/NazaraSDK/Components/ConstraintComponent2D.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/ConstraintComponent2D.inl rename to include/NazaraSDK/Components/ConstraintComponent2D.inl diff --git a/SDK/include/NazaraSDK/Components/DebugComponent.hpp b/include/NazaraSDK/Components/DebugComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/DebugComponent.hpp rename to include/NazaraSDK/Components/DebugComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/DebugComponent.inl b/include/NazaraSDK/Components/DebugComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/DebugComponent.inl rename to include/NazaraSDK/Components/DebugComponent.inl diff --git a/SDK/include/NazaraSDK/Components/GraphicsComponent.hpp b/include/NazaraSDK/Components/GraphicsComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/GraphicsComponent.hpp rename to include/NazaraSDK/Components/GraphicsComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/GraphicsComponent.inl b/include/NazaraSDK/Components/GraphicsComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/GraphicsComponent.inl rename to include/NazaraSDK/Components/GraphicsComponent.inl diff --git a/SDK/include/NazaraSDK/Components/LifetimeComponent.hpp b/include/NazaraSDK/Components/LifetimeComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/LifetimeComponent.hpp rename to include/NazaraSDK/Components/LifetimeComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/LifetimeComponent.inl b/include/NazaraSDK/Components/LifetimeComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/LifetimeComponent.inl rename to include/NazaraSDK/Components/LifetimeComponent.inl diff --git a/SDK/include/NazaraSDK/Components/LightComponent.hpp b/include/NazaraSDK/Components/LightComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/LightComponent.hpp rename to include/NazaraSDK/Components/LightComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/LightComponent.inl b/include/NazaraSDK/Components/LightComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/LightComponent.inl rename to include/NazaraSDK/Components/LightComponent.inl diff --git a/SDK/include/NazaraSDK/Components/ListenerComponent.hpp b/include/NazaraSDK/Components/ListenerComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/ListenerComponent.hpp rename to include/NazaraSDK/Components/ListenerComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/ListenerComponent.inl b/include/NazaraSDK/Components/ListenerComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/ListenerComponent.inl rename to include/NazaraSDK/Components/ListenerComponent.inl diff --git a/SDK/include/NazaraSDK/Components/NodeComponent.hpp b/include/NazaraSDK/Components/NodeComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/NodeComponent.hpp rename to include/NazaraSDK/Components/NodeComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/NodeComponent.inl b/include/NazaraSDK/Components/NodeComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/NodeComponent.inl rename to include/NazaraSDK/Components/NodeComponent.inl diff --git a/SDK/include/NazaraSDK/Components/ParticleEmitterComponent.hpp b/include/NazaraSDK/Components/ParticleEmitterComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/ParticleEmitterComponent.hpp rename to include/NazaraSDK/Components/ParticleEmitterComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/ParticleEmitterComponent.inl b/include/NazaraSDK/Components/ParticleEmitterComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/ParticleEmitterComponent.inl rename to include/NazaraSDK/Components/ParticleEmitterComponent.inl diff --git a/SDK/include/NazaraSDK/Components/ParticleGroupComponent.hpp b/include/NazaraSDK/Components/ParticleGroupComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/ParticleGroupComponent.hpp rename to include/NazaraSDK/Components/ParticleGroupComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/ParticleGroupComponent.inl b/include/NazaraSDK/Components/ParticleGroupComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/ParticleGroupComponent.inl rename to include/NazaraSDK/Components/ParticleGroupComponent.inl diff --git a/SDK/include/NazaraSDK/Components/PhysicsComponent2D.hpp b/include/NazaraSDK/Components/PhysicsComponent2D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/PhysicsComponent2D.hpp rename to include/NazaraSDK/Components/PhysicsComponent2D.hpp diff --git a/SDK/include/NazaraSDK/Components/PhysicsComponent2D.inl b/include/NazaraSDK/Components/PhysicsComponent2D.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/PhysicsComponent2D.inl rename to include/NazaraSDK/Components/PhysicsComponent2D.inl diff --git a/SDK/include/NazaraSDK/Components/PhysicsComponent3D.hpp b/include/NazaraSDK/Components/PhysicsComponent3D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/PhysicsComponent3D.hpp rename to include/NazaraSDK/Components/PhysicsComponent3D.hpp diff --git a/SDK/include/NazaraSDK/Components/PhysicsComponent3D.inl b/include/NazaraSDK/Components/PhysicsComponent3D.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/PhysicsComponent3D.inl rename to include/NazaraSDK/Components/PhysicsComponent3D.inl diff --git a/SDK/include/NazaraSDK/Components/VelocityComponent.hpp b/include/NazaraSDK/Components/VelocityComponent.hpp similarity index 100% rename from SDK/include/NazaraSDK/Components/VelocityComponent.hpp rename to include/NazaraSDK/Components/VelocityComponent.hpp diff --git a/SDK/include/NazaraSDK/Components/VelocityComponent.inl b/include/NazaraSDK/Components/VelocityComponent.inl similarity index 100% rename from SDK/include/NazaraSDK/Components/VelocityComponent.inl rename to include/NazaraSDK/Components/VelocityComponent.inl diff --git a/SDK/include/NazaraSDK/Console.hpp b/include/NazaraSDK/Console.hpp similarity index 100% rename from SDK/include/NazaraSDK/Console.hpp rename to include/NazaraSDK/Console.hpp diff --git a/SDK/include/NazaraSDK/Console.inl b/include/NazaraSDK/Console.inl similarity index 100% rename from SDK/include/NazaraSDK/Console.inl rename to include/NazaraSDK/Console.inl diff --git a/SDK/include/NazaraSDK/Entity.hpp b/include/NazaraSDK/Entity.hpp similarity index 100% rename from SDK/include/NazaraSDK/Entity.hpp rename to include/NazaraSDK/Entity.hpp diff --git a/SDK/include/NazaraSDK/Entity.inl b/include/NazaraSDK/Entity.inl similarity index 100% rename from SDK/include/NazaraSDK/Entity.inl rename to include/NazaraSDK/Entity.inl diff --git a/SDK/include/NazaraSDK/EntityList.hpp b/include/NazaraSDK/EntityList.hpp similarity index 100% rename from SDK/include/NazaraSDK/EntityList.hpp rename to include/NazaraSDK/EntityList.hpp diff --git a/SDK/include/NazaraSDK/EntityList.inl b/include/NazaraSDK/EntityList.inl similarity index 100% rename from SDK/include/NazaraSDK/EntityList.inl rename to include/NazaraSDK/EntityList.inl diff --git a/SDK/include/NazaraSDK/EntityOwner.hpp b/include/NazaraSDK/EntityOwner.hpp similarity index 100% rename from SDK/include/NazaraSDK/EntityOwner.hpp rename to include/NazaraSDK/EntityOwner.hpp diff --git a/SDK/include/NazaraSDK/EntityOwner.inl b/include/NazaraSDK/EntityOwner.inl similarity index 100% rename from SDK/include/NazaraSDK/EntityOwner.inl rename to include/NazaraSDK/EntityOwner.inl diff --git a/SDK/include/NazaraSDK/Prerequisites.hpp b/include/NazaraSDK/Prerequisites.hpp similarity index 100% rename from SDK/include/NazaraSDK/Prerequisites.hpp rename to include/NazaraSDK/Prerequisites.hpp diff --git a/SDK/include/NazaraSDK/Sdk.hpp b/include/NazaraSDK/Sdk.hpp similarity index 100% rename from SDK/include/NazaraSDK/Sdk.hpp rename to include/NazaraSDK/Sdk.hpp diff --git a/SDK/include/NazaraSDK/Sdk.inl b/include/NazaraSDK/Sdk.inl similarity index 100% rename from SDK/include/NazaraSDK/Sdk.inl rename to include/NazaraSDK/Sdk.inl diff --git a/SDK/include/NazaraSDK/State.hpp b/include/NazaraSDK/State.hpp similarity index 100% rename from SDK/include/NazaraSDK/State.hpp rename to include/NazaraSDK/State.hpp diff --git a/SDK/include/NazaraSDK/StateMachine.hpp b/include/NazaraSDK/StateMachine.hpp similarity index 100% rename from SDK/include/NazaraSDK/StateMachine.hpp rename to include/NazaraSDK/StateMachine.hpp diff --git a/SDK/include/NazaraSDK/StateMachine.inl b/include/NazaraSDK/StateMachine.inl similarity index 100% rename from SDK/include/NazaraSDK/StateMachine.inl rename to include/NazaraSDK/StateMachine.inl diff --git a/SDK/include/NazaraSDK/System.hpp b/include/NazaraSDK/System.hpp similarity index 100% rename from SDK/include/NazaraSDK/System.hpp rename to include/NazaraSDK/System.hpp diff --git a/SDK/include/NazaraSDK/System.inl b/include/NazaraSDK/System.inl similarity index 100% rename from SDK/include/NazaraSDK/System.inl rename to include/NazaraSDK/System.inl diff --git a/SDK/include/NazaraSDK/Systems.hpp b/include/NazaraSDK/Systems.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems.hpp rename to include/NazaraSDK/Systems.hpp diff --git a/SDK/include/NazaraSDK/Systems/DebugSystem.hpp b/include/NazaraSDK/Systems/DebugSystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/DebugSystem.hpp rename to include/NazaraSDK/Systems/DebugSystem.hpp diff --git a/SDK/include/NazaraSDK/Systems/DebugSystem.inl b/include/NazaraSDK/Systems/DebugSystem.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/DebugSystem.inl rename to include/NazaraSDK/Systems/DebugSystem.inl diff --git a/SDK/include/NazaraSDK/Systems/LifetimeSystem.hpp b/include/NazaraSDK/Systems/LifetimeSystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/LifetimeSystem.hpp rename to include/NazaraSDK/Systems/LifetimeSystem.hpp diff --git a/SDK/include/NazaraSDK/Systems/LifetimeSystem.inl b/include/NazaraSDK/Systems/LifetimeSystem.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/LifetimeSystem.inl rename to include/NazaraSDK/Systems/LifetimeSystem.inl diff --git a/SDK/include/NazaraSDK/Systems/ListenerSystem.hpp b/include/NazaraSDK/Systems/ListenerSystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/ListenerSystem.hpp rename to include/NazaraSDK/Systems/ListenerSystem.hpp diff --git a/SDK/include/NazaraSDK/Systems/ListenerSystem.inl b/include/NazaraSDK/Systems/ListenerSystem.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/ListenerSystem.inl rename to include/NazaraSDK/Systems/ListenerSystem.inl diff --git a/SDK/include/NazaraSDK/Systems/ParticleSystem.hpp b/include/NazaraSDK/Systems/ParticleSystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/ParticleSystem.hpp rename to include/NazaraSDK/Systems/ParticleSystem.hpp diff --git a/SDK/include/NazaraSDK/Systems/ParticleSystem.inl b/include/NazaraSDK/Systems/ParticleSystem.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/ParticleSystem.inl rename to include/NazaraSDK/Systems/ParticleSystem.inl diff --git a/SDK/include/NazaraSDK/Systems/PhysicsSystem2D.hpp b/include/NazaraSDK/Systems/PhysicsSystem2D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/PhysicsSystem2D.hpp rename to include/NazaraSDK/Systems/PhysicsSystem2D.hpp diff --git a/SDK/include/NazaraSDK/Systems/PhysicsSystem2D.inl b/include/NazaraSDK/Systems/PhysicsSystem2D.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/PhysicsSystem2D.inl rename to include/NazaraSDK/Systems/PhysicsSystem2D.inl diff --git a/SDK/include/NazaraSDK/Systems/PhysicsSystem3D.hpp b/include/NazaraSDK/Systems/PhysicsSystem3D.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/PhysicsSystem3D.hpp rename to include/NazaraSDK/Systems/PhysicsSystem3D.hpp diff --git a/SDK/include/NazaraSDK/Systems/PhysicsSystem3D.inl b/include/NazaraSDK/Systems/PhysicsSystem3D.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/PhysicsSystem3D.inl rename to include/NazaraSDK/Systems/PhysicsSystem3D.inl diff --git a/SDK/include/NazaraSDK/Systems/RenderSystem.hpp b/include/NazaraSDK/Systems/RenderSystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/RenderSystem.hpp rename to include/NazaraSDK/Systems/RenderSystem.hpp diff --git a/SDK/include/NazaraSDK/Systems/RenderSystem.inl b/include/NazaraSDK/Systems/RenderSystem.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/RenderSystem.inl rename to include/NazaraSDK/Systems/RenderSystem.inl diff --git a/SDK/include/NazaraSDK/Systems/VelocitySystem.hpp b/include/NazaraSDK/Systems/VelocitySystem.hpp similarity index 100% rename from SDK/include/NazaraSDK/Systems/VelocitySystem.hpp rename to include/NazaraSDK/Systems/VelocitySystem.hpp diff --git a/SDK/include/NazaraSDK/Systems/VelocitySystem.inl b/include/NazaraSDK/Systems/VelocitySystem.inl similarity index 100% rename from SDK/include/NazaraSDK/Systems/VelocitySystem.inl rename to include/NazaraSDK/Systems/VelocitySystem.inl diff --git a/SDK/include/NazaraSDK/Widgets.hpp b/include/NazaraSDK/Widgets.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets.hpp rename to include/NazaraSDK/Widgets.hpp diff --git a/SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp b/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp rename to include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl b/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl rename to include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/BoxLayout.hpp b/include/NazaraSDK/Widgets/BoxLayout.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/BoxLayout.hpp rename to include/NazaraSDK/Widgets/BoxLayout.hpp diff --git a/SDK/include/NazaraSDK/Widgets/BoxLayout.inl b/include/NazaraSDK/Widgets/BoxLayout.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/BoxLayout.inl rename to include/NazaraSDK/Widgets/BoxLayout.inl diff --git a/SDK/include/NazaraSDK/Widgets/ButtonWidget.hpp b/include/NazaraSDK/Widgets/ButtonWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ButtonWidget.hpp rename to include/NazaraSDK/Widgets/ButtonWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/ButtonWidget.inl b/include/NazaraSDK/Widgets/ButtonWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ButtonWidget.inl rename to include/NazaraSDK/Widgets/ButtonWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/CheckboxWidget.hpp b/include/NazaraSDK/Widgets/CheckboxWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/CheckboxWidget.hpp rename to include/NazaraSDK/Widgets/CheckboxWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/CheckboxWidget.inl b/include/NazaraSDK/Widgets/CheckboxWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/CheckboxWidget.inl rename to include/NazaraSDK/Widgets/CheckboxWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/Enums.hpp b/include/NazaraSDK/Widgets/Enums.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/Enums.hpp rename to include/NazaraSDK/Widgets/Enums.hpp diff --git a/SDK/include/NazaraSDK/Widgets/ImageWidget.hpp b/include/NazaraSDK/Widgets/ImageWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ImageWidget.hpp rename to include/NazaraSDK/Widgets/ImageWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/ImageWidget.inl b/include/NazaraSDK/Widgets/ImageWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ImageWidget.inl rename to include/NazaraSDK/Widgets/ImageWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/LabelWidget.hpp b/include/NazaraSDK/Widgets/LabelWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/LabelWidget.hpp rename to include/NazaraSDK/Widgets/LabelWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/LabelWidget.inl b/include/NazaraSDK/Widgets/LabelWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/LabelWidget.inl rename to include/NazaraSDK/Widgets/LabelWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/ProgressBarWidget.hpp b/include/NazaraSDK/Widgets/ProgressBarWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ProgressBarWidget.hpp rename to include/NazaraSDK/Widgets/ProgressBarWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/ProgressBarWidget.inl b/include/NazaraSDK/Widgets/ProgressBarWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ProgressBarWidget.inl rename to include/NazaraSDK/Widgets/ProgressBarWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp b/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp rename to include/NazaraSDK/Widgets/RichTextAreaWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.inl b/include/NazaraSDK/Widgets/RichTextAreaWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/RichTextAreaWidget.inl rename to include/NazaraSDK/Widgets/RichTextAreaWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp b/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp rename to include/NazaraSDK/Widgets/ScrollAreaWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.inl b/include/NazaraSDK/Widgets/ScrollAreaWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/ScrollAreaWidget.inl rename to include/NazaraSDK/Widgets/ScrollAreaWidget.inl diff --git a/SDK/include/NazaraSDK/Widgets/TextAreaWidget.hpp b/include/NazaraSDK/Widgets/TextAreaWidget.hpp similarity index 100% rename from SDK/include/NazaraSDK/Widgets/TextAreaWidget.hpp rename to include/NazaraSDK/Widgets/TextAreaWidget.hpp diff --git a/SDK/include/NazaraSDK/Widgets/TextAreaWidget.inl b/include/NazaraSDK/Widgets/TextAreaWidget.inl similarity index 100% rename from SDK/include/NazaraSDK/Widgets/TextAreaWidget.inl rename to include/NazaraSDK/Widgets/TextAreaWidget.inl diff --git a/SDK/include/NazaraSDK/World.hpp b/include/NazaraSDK/World.hpp similarity index 100% rename from SDK/include/NazaraSDK/World.hpp rename to include/NazaraSDK/World.hpp diff --git a/SDK/include/NazaraSDK/World.inl b/include/NazaraSDK/World.inl similarity index 100% rename from SDK/include/NazaraSDK/World.inl rename to include/NazaraSDK/World.inl diff --git a/SDK/src/NazaraSDK/Application.cpp b/src/NazaraSDK/Application.cpp similarity index 96% rename from SDK/src/NazaraSDK/Application.cpp rename to src/NazaraSDK/Application.cpp index b9a7047b4..d96fa23d8 100644 --- a/SDK/src/NazaraSDK/Application.cpp +++ b/src/NazaraSDK/Application.cpp @@ -2,17 +2,17 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp -#include +#include #include #include #ifndef NDK_SERVER -#include -#include -#include -#include #include #include +#include +#include +#include +#include #endif namespace Ndk diff --git a/SDK/src/NazaraSDK/BaseComponent.cpp b/src/NazaraSDK/BaseComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/BaseComponent.cpp rename to src/NazaraSDK/BaseComponent.cpp diff --git a/SDK/src/NazaraSDK/BaseSystem.cpp b/src/NazaraSDK/BaseSystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/BaseSystem.cpp rename to src/NazaraSDK/BaseSystem.cpp diff --git a/SDK/src/NazaraSDK/BaseWidget.cpp b/src/NazaraSDK/BaseWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/BaseWidget.cpp rename to src/NazaraSDK/BaseWidget.cpp diff --git a/SDK/src/NazaraSDK/Canvas.cpp b/src/NazaraSDK/Canvas.cpp similarity index 100% rename from SDK/src/NazaraSDK/Canvas.cpp rename to src/NazaraSDK/Canvas.cpp diff --git a/SDK/src/NazaraSDK/Components/CameraComponent.cpp b/src/NazaraSDK/Components/CameraComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/CameraComponent.cpp rename to src/NazaraSDK/Components/CameraComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/CollisionComponent2D.cpp b/src/NazaraSDK/Components/CollisionComponent2D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/CollisionComponent2D.cpp rename to src/NazaraSDK/Components/CollisionComponent2D.cpp diff --git a/SDK/src/NazaraSDK/Components/CollisionComponent3D.cpp b/src/NazaraSDK/Components/CollisionComponent3D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/CollisionComponent3D.cpp rename to src/NazaraSDK/Components/CollisionComponent3D.cpp diff --git a/SDK/src/NazaraSDK/Components/ConstraintComponent2D.cpp b/src/NazaraSDK/Components/ConstraintComponent2D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/ConstraintComponent2D.cpp rename to src/NazaraSDK/Components/ConstraintComponent2D.cpp diff --git a/SDK/src/NazaraSDK/Components/DebugComponent.cpp b/src/NazaraSDK/Components/DebugComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/DebugComponent.cpp rename to src/NazaraSDK/Components/DebugComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/GraphicsComponent.cpp b/src/NazaraSDK/Components/GraphicsComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/GraphicsComponent.cpp rename to src/NazaraSDK/Components/GraphicsComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/LifetimeComponent.cpp b/src/NazaraSDK/Components/LifetimeComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/LifetimeComponent.cpp rename to src/NazaraSDK/Components/LifetimeComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/LightComponent.cpp b/src/NazaraSDK/Components/LightComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/LightComponent.cpp rename to src/NazaraSDK/Components/LightComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/ListenerComponent.cpp b/src/NazaraSDK/Components/ListenerComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/ListenerComponent.cpp rename to src/NazaraSDK/Components/ListenerComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/NodeComponent.cpp b/src/NazaraSDK/Components/NodeComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/NodeComponent.cpp rename to src/NazaraSDK/Components/NodeComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/ParticleEmitterComponent.cpp b/src/NazaraSDK/Components/ParticleEmitterComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/ParticleEmitterComponent.cpp rename to src/NazaraSDK/Components/ParticleEmitterComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/ParticleGroupComponent.cpp b/src/NazaraSDK/Components/ParticleGroupComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/ParticleGroupComponent.cpp rename to src/NazaraSDK/Components/ParticleGroupComponent.cpp diff --git a/SDK/src/NazaraSDK/Components/PhysicsComponent2D.cpp b/src/NazaraSDK/Components/PhysicsComponent2D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/PhysicsComponent2D.cpp rename to src/NazaraSDK/Components/PhysicsComponent2D.cpp diff --git a/SDK/src/NazaraSDK/Components/PhysicsComponent3D.cpp b/src/NazaraSDK/Components/PhysicsComponent3D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/PhysicsComponent3D.cpp rename to src/NazaraSDK/Components/PhysicsComponent3D.cpp diff --git a/SDK/src/NazaraSDK/Components/VelocityComponent.cpp b/src/NazaraSDK/Components/VelocityComponent.cpp similarity index 100% rename from SDK/src/NazaraSDK/Components/VelocityComponent.cpp rename to src/NazaraSDK/Components/VelocityComponent.cpp diff --git a/SDK/src/NazaraSDK/Console.cpp b/src/NazaraSDK/Console.cpp similarity index 100% rename from SDK/src/NazaraSDK/Console.cpp rename to src/NazaraSDK/Console.cpp diff --git a/SDK/src/NazaraSDK/Entity.cpp b/src/NazaraSDK/Entity.cpp similarity index 100% rename from SDK/src/NazaraSDK/Entity.cpp rename to src/NazaraSDK/Entity.cpp diff --git a/SDK/src/NazaraSDK/EntityList.cpp b/src/NazaraSDK/EntityList.cpp similarity index 100% rename from SDK/src/NazaraSDK/EntityList.cpp rename to src/NazaraSDK/EntityList.cpp diff --git a/SDK/src/NazaraSDK/Resources/checkmark.png.h b/src/NazaraSDK/Resources/checkmark.png.h similarity index 100% rename from SDK/src/NazaraSDK/Resources/checkmark.png.h rename to src/NazaraSDK/Resources/checkmark.png.h diff --git a/SDK/src/NazaraSDK/Sdk.cpp b/src/NazaraSDK/Sdk.cpp similarity index 100% rename from SDK/src/NazaraSDK/Sdk.cpp rename to src/NazaraSDK/Sdk.cpp diff --git a/SDK/src/NazaraSDK/State.cpp b/src/NazaraSDK/State.cpp similarity index 100% rename from SDK/src/NazaraSDK/State.cpp rename to src/NazaraSDK/State.cpp diff --git a/SDK/src/NazaraSDK/Systems/DebugSystem.cpp b/src/NazaraSDK/Systems/DebugSystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/DebugSystem.cpp rename to src/NazaraSDK/Systems/DebugSystem.cpp diff --git a/SDK/src/NazaraSDK/Systems/LifetimeSystem.cpp b/src/NazaraSDK/Systems/LifetimeSystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/LifetimeSystem.cpp rename to src/NazaraSDK/Systems/LifetimeSystem.cpp diff --git a/SDK/src/NazaraSDK/Systems/ListenerSystem.cpp b/src/NazaraSDK/Systems/ListenerSystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/ListenerSystem.cpp rename to src/NazaraSDK/Systems/ListenerSystem.cpp diff --git a/SDK/src/NazaraSDK/Systems/ParticleSystem.cpp b/src/NazaraSDK/Systems/ParticleSystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/ParticleSystem.cpp rename to src/NazaraSDK/Systems/ParticleSystem.cpp diff --git a/SDK/src/NazaraSDK/Systems/PhysicsSystem2D.cpp b/src/NazaraSDK/Systems/PhysicsSystem2D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/PhysicsSystem2D.cpp rename to src/NazaraSDK/Systems/PhysicsSystem2D.cpp diff --git a/SDK/src/NazaraSDK/Systems/PhysicsSystem3D.cpp b/src/NazaraSDK/Systems/PhysicsSystem3D.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/PhysicsSystem3D.cpp rename to src/NazaraSDK/Systems/PhysicsSystem3D.cpp diff --git a/SDK/src/NazaraSDK/Systems/RenderSystem.cpp b/src/NazaraSDK/Systems/RenderSystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/RenderSystem.cpp rename to src/NazaraSDK/Systems/RenderSystem.cpp diff --git a/SDK/src/NazaraSDK/Systems/VelocitySystem.cpp b/src/NazaraSDK/Systems/VelocitySystem.cpp similarity index 100% rename from SDK/src/NazaraSDK/Systems/VelocitySystem.cpp rename to src/NazaraSDK/Systems/VelocitySystem.cpp diff --git a/SDK/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp b/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp rename to src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/BoxLayout.cpp b/src/NazaraSDK/Widgets/BoxLayout.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/BoxLayout.cpp rename to src/NazaraSDK/Widgets/BoxLayout.cpp diff --git a/SDK/src/NazaraSDK/Widgets/ButtonWidget.cpp b/src/NazaraSDK/Widgets/ButtonWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/ButtonWidget.cpp rename to src/NazaraSDK/Widgets/ButtonWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/CheckboxWidget.cpp b/src/NazaraSDK/Widgets/CheckboxWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/CheckboxWidget.cpp rename to src/NazaraSDK/Widgets/CheckboxWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/ImageWidget.cpp b/src/NazaraSDK/Widgets/ImageWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/ImageWidget.cpp rename to src/NazaraSDK/Widgets/ImageWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/LabelWidget.cpp b/src/NazaraSDK/Widgets/LabelWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/LabelWidget.cpp rename to src/NazaraSDK/Widgets/LabelWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/ProgressBarWidget.cpp b/src/NazaraSDK/Widgets/ProgressBarWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/ProgressBarWidget.cpp rename to src/NazaraSDK/Widgets/ProgressBarWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp b/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp rename to src/NazaraSDK/Widgets/RichTextAreaWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp b/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp rename to src/NazaraSDK/Widgets/ScrollAreaWidget.cpp diff --git a/SDK/src/NazaraSDK/Widgets/TextAreaWidget.cpp b/src/NazaraSDK/Widgets/TextAreaWidget.cpp similarity index 100% rename from SDK/src/NazaraSDK/Widgets/TextAreaWidget.cpp rename to src/NazaraSDK/Widgets/TextAreaWidget.cpp diff --git a/SDK/src/NazaraSDK/World.cpp b/src/NazaraSDK/World.cpp similarity index 100% rename from SDK/src/NazaraSDK/World.cpp rename to src/NazaraSDK/World.cpp From c9635ed766aee8db17fb23d223f4397960aa7b51 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 18:48:29 +0100 Subject: [PATCH 21/25] Fix linking issues on Linux --- build/scripts/common.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index f7aabaaad..9fb3bcf07 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -866,6 +866,11 @@ function NazaraBuild:PrepareGeneric() buildoptions("-mfpmath=sse") buildoptions("-ftree-vectorize") + -- Add options required for C++17 thread and filesystem + filter("action:gmake*") + links("stdc++fs") + links("pthread") + filter({}) buildoptions(self.Config["AdditionalCompilationOptions"]) From 2f102ac2422ed45c94b7da84b3c7b0abd8253ac1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 18:48:42 +0100 Subject: [PATCH 22/25] Enable more warnings (except for chipmunk) --- build/scripts/common.lua | 5 +++++ thirdparty/build/chipmunk.lua | 2 ++ 2 files changed, 7 insertions(+) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 9fb3bcf07..1ec784848 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -97,6 +97,10 @@ function NazaraBuild:Execute() files(libTable.Files) excludes(libTable.FilesExcluded) + if (libTable.DisableWarnings) then + warnings("Off") + end + defines(libTable.Defines) flags(libTable.Flags) kind("StaticLib") -- Force them as static libs @@ -812,6 +816,7 @@ function NazaraBuild:PrepareGeneric() }) cppdialect("C++17") + warnings("Extra") self:FilterLibDirectory("../thirdparty/genlib/", libdirs) self:FilterLibDirectory("../thirdparty/lib/", libdirs) diff --git a/thirdparty/build/chipmunk.lua b/thirdparty/build/chipmunk.lua index cb3b27ba0..7331be7ca 100644 --- a/thirdparty/build/chipmunk.lua +++ b/thirdparty/build/chipmunk.lua @@ -11,9 +11,11 @@ LIBRARY.Defines = { } LIBRARY.Language = "C++" +LIBRARY.DisableWarnings = true -- chipmunk has many warnings we can't really fix LIBRARY.Files = { "../thirdparty/include/chipmunk/*.h", "../thirdparty/src/chipmunk/*.h", "../thirdparty/src/chipmunk/*.c", } + From 269190bb75a150fedd428efa4fb502fa1335ee57 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 18:49:43 +0100 Subject: [PATCH 23/25] Core/Bitset: Make use of if constexpr --- include/Nazara/Core/Bitset.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 1feda0b59..e4fd9b69c 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -119,7 +119,7 @@ namespace Nz Bitset::Bitset(T value) : Bitset() { - if (sizeof(T) <= sizeof(Block)) + if constexpr (sizeof(T) <= sizeof(Block)) { m_bitCount = BitCount(); m_blocks.push_back(static_cast(value)); From 215478284097a7e538cde6f3035a591fffea185e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 19:43:52 +0100 Subject: [PATCH 24/25] Fix Tut00 linking --- examples/Tut00/build.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/Tut00/build.lua b/examples/Tut00/build.lua index baf738d1d..438b1f0ca 100644 --- a/examples/Tut00/build.lua +++ b/examples/Tut00/build.lua @@ -10,9 +10,7 @@ EXAMPLE.Libraries = { "NazaraAudio", "NazaraCore", "NazaraGraphics", - "NazaraLua", "NazaraNetwork", - "NazaraNoise", "NazaraPhysics2D", "NazaraPhysics3D", "NazaraPlatform", From d298e93c136561f6bac346ef0bcaf6a171b41003 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 24 Feb 2020 20:57:06 +0100 Subject: [PATCH 25/25] Fix Linux linking issues --- build/scripts/common.lua | 48 +++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 1ec784848..aca8527eb 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -89,7 +89,7 @@ function NazaraBuild:Execute() for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) - self:PrepareGeneric() + self:PreconfigGenericProject() language(libTable.Language) location(_ACTION .. "/thirdparty") @@ -126,6 +126,8 @@ function NazaraBuild:Execute() end filter({}) + + self:PostconfigGenericProject() end end @@ -135,14 +137,14 @@ function NazaraBuild:Execute() if (_OPTIONS["united"]) then project("NazaraEngine") - self:PrepareMainWorkspace() + self:PreconfigNazaraProject() end for k, moduleTable in ipairs(self.OrderedModules) do if (not _OPTIONS["united"]) then project("Nazara" .. moduleTable.Name) - self:PrepareMainWorkspace() + self:PreconfigNazaraProject() end location(_ACTION .. "/modules") @@ -184,6 +186,14 @@ function NazaraBuild:Execute() end filter({}) + + if (not _OPTIONS["united"]) then + self:PostconfigNazaraProject() + end + end + + if (_OPTIONS["united"]) then + self:PostconfigNazaraProject() end -- Tools @@ -197,7 +207,7 @@ function NazaraBuild:Execute() project(prefix .. toolTable.Name) - self:PrepareMainWorkspace() + self:PreconfigNazaraProject() location(_ACTION .. "/tools") @@ -255,6 +265,8 @@ function NazaraBuild:Execute() end filter({}) + + self:PostconfigNazaraProject() end group("Examples") @@ -264,7 +276,7 @@ function NazaraBuild:Execute() project("Demo" .. exampleTable.Name) - self:PrepareMainWorkspace() + self:PreconfigNazaraProject() location(_ACTION .. "/examples") @@ -305,6 +317,8 @@ function NazaraBuild:Execute() end filter({}) + + self:PostconfigNazaraProject() end end end @@ -806,7 +820,7 @@ function NazaraBuild:Process(infoTable) return true end -function NazaraBuild:PrepareGeneric() +function NazaraBuild:PreconfigGenericProject() flags({ "MultiProcessorCompile", "NoMinimalRebuild", @@ -871,18 +885,22 @@ function NazaraBuild:PrepareGeneric() buildoptions("-mfpmath=sse") buildoptions("-ftree-vectorize") - -- Add options required for C++17 thread and filesystem - filter("action:gmake*") - links("stdc++fs") - links("pthread") - filter({}) buildoptions(self.Config["AdditionalCompilationOptions"]) end -function NazaraBuild:PrepareMainWorkspace() - self:PrepareGeneric() +function NazaraBuild:PostconfigGenericProject() + -- Add options required for C++17 thread and filesystem (have to be linked last) + filter("action:gmake*") + links("stdc++fs") + links("pthread") + + filter({}) +end + +function NazaraBuild:PreconfigNazaraProject() + self:PreconfigGenericProject() language("C++") @@ -916,6 +934,10 @@ function NazaraBuild:PrepareMainWorkspace() filter({}) end +function NazaraBuild:PostconfigNazaraProject() + self:PostconfigGenericProject() +end + function NazaraBuild:RegisterAction(actionTable) if (not actionTable.Manual) then if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then