From c7d011cd0063d8ab313c29304e3c29a5da7c9406 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Oct 2016 02:07:48 +0200 Subject: [PATCH 01/81] Readme: Display Travis CI status for branch master only --- readme.md | 2 +- readme_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index edb58080e..ea054e608 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ Platform | Build Status ------------ | ------------- Windows | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/dj5qx7axym4uakmy/branch/master?svg=true)](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master) -Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) +Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg?branch=master)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) # Nazara Engine diff --git a/readme_fr.md b/readme_fr.md index d7aff37b9..422be6a0e 100644 --- a/readme_fr.md +++ b/readme_fr.md @@ -1,7 +1,7 @@ Platforme | Build Status ------------ | ------------- Windows | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/dj5qx7axym4uakmy/branch/master?svg=true)](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master) -Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) +Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg?branch=master)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) # Nazara Engine From e087129d4a996eaaacf4d8fcb256b5d5d8af4c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 4 Nov 2016 18:14:52 +0100 Subject: [PATCH 02/81] Fix many errors and warnings found out by MinGW --- SDK/include/NDK/Application.inl | 8 +- .../NDK/Components/GraphicsComponent.hpp | 16 +- SDK/include/NDK/LuaAPI.inl | 2 +- SDK/src/NDK/LuaBinding_Audio.cpp | 30 +- SDK/src/NDK/LuaBinding_Core.cpp | 78 +- SDK/src/NDK/LuaBinding_Graphics.cpp | 16 +- SDK/src/NDK/LuaBinding_Math.cpp | 44 +- SDK/src/NDK/LuaBinding_Math.cpp.save-failed | 908 ++++++++++++++++++ SDK/src/NDK/LuaBinding_Network.cpp | 12 +- SDK/src/NDK/LuaBinding_Renderer.cpp | 12 +- SDK/src/NDK/LuaBinding_SDK.cpp | 16 +- SDK/src/NDK/LuaBinding_Utility.cpp | 48 +- include/Nazara/Graphics/TileMap.inl | 18 +- include/Nazara/Lua/LuaClass.inl | 12 +- include/Nazara/Lua/LuaInstance.inl | 8 +- include/Nazara/Math/Matrix4.inl | 2 +- include/Nazara/Math/Vector3.inl | 12 +- include/Nazara/Math/Vector4.inl | 16 +- include/Nazara/Network/IpAddress.inl | 8 +- include/Nazara/Physics2D/ConfigCheck.hpp | 6 +- include/Nazara/Physics2D/Debug.hpp | 4 +- include/Nazara/Physics2D/DebugOff.hpp | 2 +- include/Nazara/Physics3D/ConfigCheck.hpp | 4 +- include/Nazara/Physics3D/Debug.hpp | 2 +- include/Nazara/Physics3D/DebugOff.hpp | 2 +- include/Nazara/Physics3D/Enums.hpp | 2 +- src/Nazara/Core/File.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 1 + src/Nazara/Network/NetPacket.cpp | 2 +- src/Nazara/Network/TcpClient.cpp | 2 +- src/Nazara/Network/Win32/SocketImpl.cpp | 4 + src/Nazara/Physics2D/Debug/NewOverload.cpp | 4 +- src/Nazara/Physics3D/Debug/NewOverload.cpp | 2 +- src/Nazara/Renderer/RenderTexture.cpp | 1 + src/Nazara/Utility/Formats/MTLParser.cpp | 6 +- src/Nazara/Utility/Formats/OBJParser.cpp | 22 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 1 + src/Nazara/Utility/SoftwareBuffer.cpp | 2 +- 38 files changed, 1126 insertions(+), 211 deletions(-) create mode 100644 SDK/src/NDK/LuaBinding_Math.cpp.save-failed diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index d26a2daa8..0b4f2ce10 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -59,7 +59,7 @@ namespace Ndk * \param args Arguments used to create the window */ #ifndef NDK_SERVER - template + template T& Application::AddWindow(Args&&... args) { static_assert(std::is_base_of::value, "Type must inherit Window"); @@ -82,7 +82,7 @@ namespace Ndk * \param args Arguments used to create the world */ - template + template World& Application::AddWorld(Args&&... args) { m_worlds.emplace_back(std::forward(args)...); @@ -373,9 +373,9 @@ namespace Ndk { } - inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : + inline Application::WindowInfo::WindowInfo(std::unique_ptr&& windowPtr) : renderTarget(nullptr), - window(std::move(window)) + window(std::move(windowPtr)) { } #endif diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index b536fc154..f8cd6d957 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -73,19 +73,19 @@ namespace Ndk { } - Renderable(Renderable&& renderable) noexcept : - renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)), - renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)), - data(std::move(renderable.data)), - renderable(std::move(renderable.renderable)), - dataUpdated(renderable.dataUpdated) + Renderable(Renderable&& rhs) noexcept : + renderableInvalidationSlot(std::move(rhs.renderableInvalidationSlot)), + renderableReleaseSlot(std::move(rhs.renderableReleaseSlot)), + data(std::move(rhs.data)), + renderable(std::move(rhs.renderable)), + dataUpdated(rhs.dataUpdated) { } ~Renderable() { // Disconnect release slot before releasing instanced renderable reference - renderableReleaseSlot.Disconnect(); + renderableReleaseSlot.Disconnect(); } Renderable& operator=(Renderable&& r) noexcept @@ -118,4 +118,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP -#endif // NDK_SERVER \ No newline at end of file +#endif // NDK_SERVER diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 1ae2ddd43..e50699528 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -223,7 +223,7 @@ namespace Nz inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4f* mat, TypeTag) { - Matrix4d matDouble; + Matrix4d matDouble = Matrix4d::Identity(); unsigned int ret = LuaImplQueryArg(instance, index, &matDouble, TypeTag()); mat->Set(matDouble); diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index 46791b6c7..60f504939 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -41,12 +41,12 @@ namespace Ndk music.BindMethod("Stop", &Nz::Music::Stop); // Manual - music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& music, std::size_t /*argumentCount*/) -> int + music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Music("); - stream << music.GetFilePath() << ')'; + Nz::StringStream ss("Music("); + ss << instance.GetFilePath() << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); @@ -65,15 +65,15 @@ namespace Ndk sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset); // Manual - sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound, std::size_t /*argumentCount*/) -> int + sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Sound("); - if (const Nz::SoundBuffer* buffer = sound.GetBuffer()) - stream << buffer; + Nz::StringStream ss("Sound("); + if (const Nz::SoundBuffer* buffer = instance.GetBuffer()) + ss << buffer; - stream << ')'; + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); @@ -124,18 +124,18 @@ namespace Ndk soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("SoundBuffer("); + Nz::StringStream ss("SoundBuffer("); if (instance->IsValid()) { Nz::String filePath = instance->GetFilePath(); if (!filePath.IsEmpty()) - stream << "File: " << filePath << ", "; + ss << "File: " << filePath << ", "; - stream << "Duration: " << instance->GetDuration() / 1000.f << "s"; + ss << "Duration: " << instance->GetDuration() / 1000.f << "s"; } - stream << ')'; + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); diff --git a/SDK/src/NDK/LuaBinding_Core.cpp b/SDK/src/NDK/LuaBinding_Core.cpp index dc149e3d0..4a1e343f4 100644 --- a/SDK/src/NDK/LuaBinding_Core.cpp +++ b/SDK/src/NDK/LuaBinding_Core.cpp @@ -13,13 +13,13 @@ namespace Ndk void LuaBinding::BindCore() { /*********************************** Nz::Clock **********************************/ - clock.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t /*argumentCount*/) + clock.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* instance, std::size_t /*argumentCount*/) { int argIndex = 2; Nz::Int64 startingValue = lua.Check(&argIndex, 0); bool paused = lua.Check(&argIndex, false); - Nz::PlacementNew(clock, startingValue, paused); + Nz::PlacementNew(instance, startingValue, paused); return true; }); @@ -32,19 +32,19 @@ namespace Ndk clock.BindMethod("Unpause", &Nz::Clock::Unpause); // Manual - clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Clock(Elapsed: "); - stream << clock.GetSeconds(); - stream << "s, Paused: "; - stream << clock.IsPaused(); - stream << ')'; + clock.BindMethod("__tostring", [] (Nz::LuaInstance& 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(stream); + lua.PushString(ss); return 1; }); /********************************* Nz::Directory ********************************/ - directory.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory, std::size_t argumentCount) + directory.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); @@ -52,11 +52,11 @@ namespace Ndk switch (argCount) { case 0: - Nz::PlacementNew(directory); + Nz::PlacementNew(instance); return true; case 1: - Nz::PlacementNew(directory, lua.Check(&argIndex)); + Nz::PlacementNew(instance, lua.Check(&argIndex)); return true; } @@ -85,12 +85,12 @@ namespace Ndk directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent); // Manual - directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& directory, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Directory("); - stream << directory.GetPath(); - stream << ')'; + directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int { + Nz::StringStream ss("Directory("); + ss << instance.GetPath(); + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); @@ -110,35 +110,35 @@ namespace Ndk stream.BindMethod("IsWritable", &Nz::Stream::IsWritable); stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos); - stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int { + stream.BindMethod("Read", [] (Nz::LuaInstance& 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 = stream.Read(buffer.get(), length); + std::size_t readLength = instance.Read(buffer.get(), length); lua.PushString(Nz::String(buffer.get(), readLength)); return 1; }); - stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int { + stream.BindMethod("Write", [] (Nz::LuaInstance& 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 (stream.IsTextModeEnabled()) - lua.Push(stream.Write(Nz::String(buffer, bufferSize))); + if (instance.IsTextModeEnabled()) + lua.Push(instance.Write(Nz::String(buffer, bufferSize))); else - lua.Push(stream.Write(buffer, bufferSize)); + lua.Push(instance.Write(buffer, bufferSize)); return 1; }); /*********************************** Nz::File ***********************************/ file.Inherit(stream); - file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* file, std::size_t argumentCount) + file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); @@ -146,14 +146,14 @@ namespace Ndk switch (argCount) { case 0: - Nz::PlacementNew(file); + Nz::PlacementNew(instance); return true; case 1: { Nz::String filePath = lua.Check(&argIndex); - Nz::PlacementNew(file, filePath); + Nz::PlacementNew(instance, filePath); return true; } @@ -162,7 +162,7 @@ namespace Ndk Nz::String filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex); - Nz::PlacementNew(file, filePath, openMode); + Nz::PlacementNew(instance, filePath, openMode); return true; } } @@ -201,7 +201,7 @@ namespace Ndk file.BindStaticMethod("Rename", &Nz::File::Rename); // Manual - file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t argumentCount) -> int + file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -210,13 +210,13 @@ namespace Ndk { case 0: case 1: - return lua.Push(file.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); + return lua.Push(instance.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); case 2: { Nz::String filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex, Nz::OpenMode_NotOpen); - return lua.Push(file.Open(filePath, openMode)); + return lua.Push(instance.Open(filePath, openMode)); } } @@ -224,7 +224,7 @@ namespace Ndk return 0; }); - file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t argumentCount) -> int + file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -232,13 +232,13 @@ namespace Ndk switch (argCount) { case 1: - return lua.Push(file.SetCursorPos(lua.Check(&argIndex))); + 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(file.SetCursorPos(curPos, offset)); + return lua.Push(instance.SetCursorPos(curPos, offset)); } } @@ -246,14 +246,14 @@ namespace Ndk return 0; }); - file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("File("); - if (file.IsOpen()) - stream << "Path: " << file.GetPath(); + file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int { + Nz::StringStream ss("File("); + if (instance.IsOpen()) + ss << "Path: " << instance.GetPath(); - stream << ')'; + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); } diff --git a/SDK/src/NDK/LuaBinding_Graphics.cpp b/SDK/src/NDK/LuaBinding_Graphics.cpp index 4a2b53422..d1cff2ef5 100644 --- a/SDK/src/NDK/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/LuaBinding_Graphics.cpp @@ -231,14 +231,14 @@ namespace Ndk }); /*********************************** Nz::Model ***********************************/ - model.Inherit(instancedRenderable, [] (Nz::ModelRef* model) -> Nz::InstancedRenderableRef* + model.Inherit(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef* { - return reinterpret_cast(model); //TODO: Make a ObjectRefCast + return reinterpret_cast(modelRef); //TODO: Make a ObjectRefCast }); - model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* model, std::size_t /*argumentCount*/) + model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(model, Nz::Model::New()); + Nz::PlacementNew(instance, Nz::Model::New()); return true; }); @@ -260,14 +260,14 @@ namespace Ndk model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount); /*********************************** Nz::Sprite ***********************************/ - sprite.Inherit(instancedRenderable, [] (Nz::SpriteRef* sprite) -> Nz::InstancedRenderableRef* + sprite.Inherit(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef* { - return reinterpret_cast(sprite); //TODO: Make a ObjectRefCast + return reinterpret_cast(spriteRef); //TODO: Make a ObjectRefCast }); - sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* sprite, std::size_t /*argumentCount*/) + sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(sprite, Nz::Sprite::New()); + Nz::PlacementNew(instance, Nz::Sprite::New()); return true; }); diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index 51a510238..35ad13a2e 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -14,22 +14,22 @@ namespace Ndk void LuaBinding::BindMath() { /*********************************** Nz::EulerAngles **********************************/ - eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles, std::size_t argumentCount) + eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); switch (argCount) { case 0: - Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero()); + Nz::PlacementNew(instance, Nz::EulerAnglesd::Zero()); return true; case 1: - Nz::PlacementNew(angles, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); + Nz::PlacementNew(instance, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); return true; case 3: - Nz::PlacementNew(angles, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); + Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); return true; } @@ -154,7 +154,7 @@ namespace Ndk return false; }); - + /*********************************** Nz::Matrix4 **********************************/ matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount) { @@ -227,7 +227,7 @@ namespace Ndk { Nz::Matrix4d result; instance.GetTransposed(&result); - + return lua.Push(result); }); @@ -360,7 +360,7 @@ namespace Ndk }); /*********************************** Nz::Rect **********************************/ - rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount) + rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 4U); @@ -368,23 +368,23 @@ namespace Ndk { case 0: case 4: - PlacementNew(rect, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0), lua.CheckNumber(4, 0.0)); + 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(rect, *static_cast(lua.ToUserdata(1))); + 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(rect, lua.CheckField("x", 1), - lua.CheckField("y", 1), - lua.CheckField("width", 1), - lua.CheckField("height", 1)); + 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(rect, *static_cast(lua.ToUserdata(1))); + PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else break; @@ -394,9 +394,9 @@ namespace Ndk case 2: { if (lua.IsOfType(1, Nz::LuaType_Number) && lua.IsOfType(2, Nz::LuaType_Number)) - PlacementNew(rect, lua.CheckNumber(1), lua.CheckNumber(2)); + PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2)); else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2")) - PlacementNew(rect, *static_cast(lua.ToUserdata(1)), *static_cast(lua.ToUserdata(2))); + PlacementNew(instance, *static_cast(lua.ToUserdata(1)), *static_cast(lua.ToUserdata(2))); else break; @@ -516,22 +516,22 @@ namespace Ndk }); /*********************************** Nz::Quaternion **********************************/ - quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount) + quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 4U); switch (argCount) { case 0: - Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero()); + Nz::PlacementNew(instance, Nz::Quaterniond::Zero()); return true; case 1: { if (lua.IsOfType(1, "EulerAngles")) - Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + Nz::PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else if (lua.IsOfType(1, "Quaternion")) - Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + Nz::PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else break; @@ -539,11 +539,11 @@ namespace Ndk } case 2: - Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); + Nz::PlacementNew(instance, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); return true; case 4: - Nz::PlacementNew(quaternion, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); + Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); return true; default: diff --git a/SDK/src/NDK/LuaBinding_Math.cpp.save-failed b/SDK/src/NDK/LuaBinding_Math.cpp.save-failed new file mode 100644 index 000000000..6abec5c7b --- /dev/null +++ b/SDK/src/NDK/LuaBinding_Math.cpp.save-failed @@ -0,0 +1,908 @@ +// This file was automatically generated on 26 May 2014 at 01:05:31 + +#include +#include +#include +#include + +namespace Ndk +{ + /*! + * \brief Binds Math module to Lua + */ + + void LuaBinding::BindMath() + { + /*********************************** Nz::EulerAngles **********************************/ + eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 1U); + + switch (argCount) + { + case 0: + Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero()); + return true; + + case 1: + Nz::PlacementNew(angles, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); + return true; + + case 3: + Nz::PlacementNew(angles, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); + return true; + } + + lua.Error("No matching overload for EulerAngles constructor"); + return false; + }); + + eulerAngles.BindMethod("__tostring", &Nz::EulerAnglesd::ToString); + + eulerAngles.SetGetter([] (Nz::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& 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 (std::size_t 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::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + bool succeeded; + instance.Inverse(&succeeded); + + return lua.Push(succeeded); + }); + + matrix4d.BindMethod("InverseAffine", [] (Nz::LuaInstance& 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::LuaInstance& 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.Set(*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.Set(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::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 4U); + + switch (argCount) + { + case 0: + case 4: + PlacementNew(rect, 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(rect, *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(rect, lua.CheckField("x", 1), + lua.CheckField("y", 1), + lua.CheckField("width", 1), + lua.CheckField("height", 1)); + } + else if (lua.IsOfType(1, "Vector2")) + PlacementNew(rect, *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(rect, lua.CheckNumber(1), lua.CheckNumber(2)); + else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2")) + PlacementNew(rect, *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::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 4U); + + switch (argCount) + { + case 0: + Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero()); + return true; + + case 1: + { + if (lua.IsOfType(1, "EulerAngles")) + Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + else if (lua.IsOfType(1, "Quaternion")) + Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + else + break; + + return true; + } + + case 2: + Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); + return true; + + case 4: + Nz::PlacementNew(quaternion, 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("__tostring", &Nz::Quaterniond::ToString); + + quaternion.SetGetter([] (Nz::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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::RegisterMath(Nz::LuaInstance& instance) + { + eulerAngles.Register(instance); + matrix4d.Register(instance); + quaternion.Register(instance); + rect.Register(instance); + vector2d.Register(instance); + vector3d.Register(instance); + } +} diff --git a/SDK/src/NDK/LuaBinding_Network.cpp b/SDK/src/NDK/LuaBinding_Network.cpp index bd1105962..b51906481 100644 --- a/SDK/src/NDK/LuaBinding_Network.cpp +++ b/SDK/src/NDK/LuaBinding_Network.cpp @@ -21,7 +21,7 @@ namespace Ndk abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes); /*********************************** Nz::IpAddress **********************************/ - ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address, std::size_t argumentCount) + ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 9U); @@ -29,11 +29,11 @@ namespace Ndk switch (argCount) { case 0: - Nz::PlacementNew(address); + Nz::PlacementNew(instance); return true; case 1: - Nz::PlacementNew(address, lua.CheckString(argIndex)); + Nz::PlacementNew(instance, lua.CheckString(argIndex)); return true; case 4: @@ -45,7 +45,7 @@ namespace Ndk Nz::UInt8 d = lua.Check(&argIndex); Nz::UInt16 port = lua.Check(&argIndex, 0); - Nz::PlacementNew(address, a, b, c, d, port); + Nz::PlacementNew(instance, a, b, c, d, port); return true; } @@ -62,7 +62,7 @@ namespace Ndk Nz::UInt16 h = lua.Check(&argIndex); Nz::UInt16 port = lua.Check(&argIndex, 0); - Nz::PlacementNew(address, a, b, c, d, e, f, g, h, port); + Nz::PlacementNew(instance, a, b, c, d, e, f, g, h, port); return true; } } @@ -199,7 +199,7 @@ namespace Ndk instance.PushField("Unknown", Nz::ResolveError_Unknown); } instance.SetGlobal("ResolveError"); - + // Nz::SocketError static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); instance.PushTable(0, 15); diff --git a/SDK/src/NDK/LuaBinding_Renderer.cpp b/SDK/src/NDK/LuaBinding_Renderer.cpp index 8ffe76c69..1f1f9479f 100644 --- a/SDK/src/NDK/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/LuaBinding_Renderer.cpp @@ -13,14 +13,14 @@ namespace Ndk void LuaBinding::BindRenderer() { /*********************************** Nz::Texture ***********************************/ - texture.Inherit(abstractImage, [] (Nz::TextureRef* texture) -> Nz::AbstractImageRef* + texture.Inherit(abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef* { - return reinterpret_cast(texture); //TODO: Make a ObjectRefCast + return reinterpret_cast(textureRef); //TODO: Make a ObjectRefCast }); - texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* texture, std::size_t /*argumentCount*/) + texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(texture, Nz::Texture::New()); + Nz::PlacementNew(instance, Nz::Texture::New()); return true; }); @@ -28,7 +28,7 @@ namespace Ndk 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); @@ -73,4 +73,4 @@ namespace Ndk { texture.Register(instance); } -} \ No newline at end of file +} diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 3046f2483..880e49064 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -25,9 +25,9 @@ namespace Ndk application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled); #endif - application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application, std::size_t /*argumentCount*/) -> int + application.BindMethod("AddWorld", [] (Nz::LuaInstance& lua, Application* instance, std::size_t /*argumentCount*/) -> int { - instance.Push(application->AddWorld().CreateHandle()); + lua.Push(instance->AddWorld().CreateHandle()); return 1; }); @@ -59,7 +59,7 @@ namespace Ndk console.BindMethod("SetCharacterSize", &Console::SetCharacterSize); console.BindMethod("SetSize", &Console::SetSize); console.BindMethod("SetTextFont", &Console::SetTextFont); - + console.BindMethod("Show", &Console::Show, true); #endif @@ -139,7 +139,7 @@ namespace Ndk #ifndef NDK_SERVER /*********************************** Ndk::GraphicsComponent **********************************/ - graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent *gfxComponent, std::size_t argumentCount) -> int + graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int { /* void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); @@ -153,7 +153,7 @@ namespace Ndk case 1: { int argIndex = 2; - gfxComponent->Attach(lua.Check(&argIndex)); + instance->Attach(lua.Check(&argIndex)); return 0; } @@ -166,13 +166,13 @@ namespace Ndk { int renderOrder = lua.Check(&argIndex); - gfxComponent->Attach(renderable, renderOrder); + instance->Attach(renderable, renderOrder); } else if (lua.IsOfType(argIndex, "Matrix4")) { Nz::Matrix4f localMatrix = lua.Check(&argIndex); - gfxComponent->Attach(renderable, localMatrix); + instance->Attach(renderable, localMatrix); } else break; @@ -187,7 +187,7 @@ namespace Ndk Nz::Matrix4f localMatrix = lua.Check(&argIndex); int renderOrder = lua.Check(&argIndex); - gfxComponent->Attach(renderable, localMatrix, renderOrder); + instance->Attach(renderable, localMatrix, renderOrder); return 0; } } diff --git a/SDK/src/NDK/LuaBinding_Utility.cpp b/SDK/src/NDK/LuaBinding_Utility.cpp index 5ae37f669..e693ce35c 100644 --- a/SDK/src/NDK/LuaBinding_Utility.cpp +++ b/SDK/src/NDK/LuaBinding_Utility.cpp @@ -25,20 +25,20 @@ namespace Ndk abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed); abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap); - abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage, std::size_t argumentCount) -> int + abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 1U); switch (argCount) { case 0: - return lua.Push(abstractImage->GetMemoryUsage()); + return lua.Push(instance->GetMemoryUsage()); case 1: { int argIndex = 2; Nz::UInt8 level(lua.Check(&argIndex)); - return lua.Push(abstractImage->GetMemoryUsage(level)); + return lua.Push(instance->GetMemoryUsage(level)); } } @@ -46,7 +46,7 @@ namespace Ndk return 0; }); - abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage, std::size_t argumentCount) -> int + abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 6U); int argIndex = 2; @@ -62,7 +62,7 @@ namespace Ndk Nz::UInt8 level = lua.Check(&argIndex, 0); ///TODO: Buffer checks (Nz::ByteBufferView ?) - return lua.Push(abstractImage->Update(pixels, srcWidth, srcHeight, level)); + return lua.Push(instance->Update(pixels, srcWidth, srcHeight, level)); } /* Disabled until Box and Rect have been ported else if (lua.IsOfType(2, "Box")) @@ -93,9 +93,9 @@ namespace Ndk }); /*********************************** Nz::Font **********************************/ - font.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::FontRef* font, std::size_t /*argumentCount*/) + font.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::FontRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(font, Nz::Font::New()); + Nz::PlacementNew(instance, Nz::Font::New()); return true; }); @@ -199,29 +199,29 @@ namespace Ndk 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::LuaInstance& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int + node.BindMethod("Move", [] (Nz::LuaInstance& 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); - node.Move(offset, coordSys); + instance.Move(offset, coordSys); return 0; }); - node.BindMethod("Rotate", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int + node.BindMethod("Rotate", [] (Nz::LuaInstance& 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); - node.Rotate(rotation, coordSys); + instance.Rotate(rotation, coordSys); return 0; }); - node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int + node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -231,15 +231,15 @@ namespace Ndk case 1: { if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - node.Scale(lua.Check(&argIndex)); + instance.Scale(lua.Check(&argIndex)); else - node.Scale(lua.Check(&argIndex)); + instance.Scale(lua.Check(&argIndex)); return 0; } case 3: - node.Scale(lua.Check(&argIndex)); + instance.Scale(lua.Check(&argIndex)); return 0; } @@ -247,7 +247,7 @@ namespace Ndk return 0; }); - node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int + node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -261,10 +261,10 @@ namespace Ndk { float scale = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - node.SetScale(scale, coordSys); + instance.SetScale(scale, coordSys); } else - node.SetScale(lua.Check(&argIndex)); + instance.SetScale(lua.Check(&argIndex)); return 0; } @@ -275,7 +275,7 @@ namespace Ndk Nz::Vector3f scale = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - node.SetScale(scale, coordSys); + instance.SetScale(scale, coordSys); return 0; } } @@ -284,7 +284,7 @@ namespace Ndk return 0; }); - node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int + node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -294,16 +294,16 @@ namespace Ndk case 1: { if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - node.SetInitialScale(lua.Check(&argIndex)); + instance.SetInitialScale(lua.Check(&argIndex)); else - node.SetInitialScale(lua.Check(&argIndex)); + instance.SetInitialScale(lua.Check(&argIndex)); return 0; } case 2: case 3: - node.SetInitialScale(lua.Check(&argIndex)); + instance.SetInitialScale(lua.Check(&argIndex)); return 0; } @@ -324,4 +324,4 @@ namespace Ndk font.Register(instance); node.Register(instance); } -} \ No newline at end of file +} diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 4473a8600..f8faa7b54 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -29,7 +29,7 @@ namespace Nz m_isometricModeEnabled(false) { NazaraAssert(m_tiles.size() != 0U, "Invalid map size"); - NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size"); + NazaraAssert(m_tileSize.x > 0 && m_tileSize.y > 0, "Invalid tile size"); NazaraAssert(m_layers.size() != 0U, "Invalid material count"); for (Layer& layer : m_layers) @@ -175,7 +175,7 @@ namespace Nz * \param color The multiplicative color applied to the tile * \param materialIndex The material which will be used for rendering this tile * - * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * * \see EnableTiles @@ -253,7 +253,7 @@ namespace Nz Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); EnableTiles(unnormalizedCoords, color, materialIndex); } - + /*! * \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations * @@ -434,14 +434,14 @@ namespace Nz * * \param TileMap The other TileMap */ - inline TileMap& TileMap::operator=(const TileMap& TileMap) + inline TileMap& TileMap::operator=(const TileMap& tileMap) { - InstancedRenderable::operator=(TileMap); + InstancedRenderable::operator=(tileMap); - m_layers = TileMap.m_layers; - m_mapSize = TileMap.m_mapSize; - m_tiles = TileMap.m_tiles; - m_tileSize = TileMap.m_tileSize; + m_layers = tileMap.m_layers; + m_mapSize = tileMap.m_mapSize; + m_tiles = tileMap.m_tiles; + m_tileSize = tileMap.m_tileSize; // We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated InvalidateBoundingVolume(); diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index daf7a632a..3168ba43d 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -129,7 +129,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -143,7 +143,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -157,7 +157,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -171,7 +171,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -203,7 +203,7 @@ namespace Nz BindStaticMethod(name, [func, handler] (LuaInstance& lua) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, func); }); @@ -335,7 +335,7 @@ namespace Nz NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance"); { SetupFinalizer(lua); - + if (m_info->getter || !m_info->parentGetters.empty()) SetupGetter(lua, GetterProxy); else diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 25f193675..9bc20c73a 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -59,7 +59,7 @@ namespace Nz m_memoryUsage = instance.m_memoryUsage; m_state = instance.m_state; m_timeLimit = instance.m_timeLimit; - + instance.m_state = nullptr; return *this; @@ -320,7 +320,7 @@ namespace Nz { } - void ProcessArgs(const LuaInstance& instance) const + void ProcessArguments(const LuaInstance& instance) const { m_index = 1; ProcessArgs<0, Args...>(instance); @@ -391,7 +391,7 @@ namespace Nz { } - void ProcessArgs(const LuaInstance& instance) const + void ProcessArguments(const LuaInstance& instance) const { m_index = 2; //< 1 being the instance ProcessArgs<0, Args...>(instance); @@ -714,7 +714,7 @@ namespace Nz PushFunction([func, handler] (LuaInstance& lua) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, func); }); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 021cb6378..f045ac28a 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -792,7 +792,7 @@ namespace Nz template bool Matrix4::IsAffine() const { - return m14 == F(0.0) && m24 == F(0.0) && m34 == F(0.0) && m44 == F(1.0); + return NumberEquals(m14, F(0.0)) && NumberEquals(m24, F(0.0)) && NumberEquals(m34, F(0.0)) && NumberEquals(m44, F(1.0)); } /*! diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 555286024..604cbfb86 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -911,9 +911,9 @@ namespace Nz template bool Vector3::operator<(const Vector3& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) + if (NumberEquals(y, vec.y)) return z < vec.z; else return y < vec.y; @@ -931,10 +931,10 @@ namespace Nz template bool Vector3::operator<=(const Vector3& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) - return z <= vec.z; + if (NumberEquals(y, vec.y)) + return NumberEquals(z, vec.z) || z < vec.z; else return y < vec.y; } @@ -1371,7 +1371,7 @@ namespace std } }; } - + #undef F #include diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 190d31b99..f3cad0a31 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -843,11 +843,11 @@ namespace Nz template bool Vector4::operator<(const Vector4& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) + if (NumberEquals(y, vec.y)) { - if (z == vec.z) + if (NumberEquals(z, vec.z)) return w < vec.w; else return z < vec.z; @@ -869,12 +869,12 @@ namespace Nz template bool Vector4::operator<=(const Vector4& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) + if (NumberEquals(y, vec.y)) { - if (z == vec.z) - return w <= vec.w; + if (NumberEquals(z, vec.z)) + return NumberEquals(w, vec.w) || w < vec.w; else return z < vec.z; } @@ -1144,7 +1144,7 @@ namespace std } }; } - + #undef F #include diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index 1eaef4341..ed06b1af7 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -380,7 +380,7 @@ namespace std // This is SDBM adapted for IP addresses, tested to generate the least collisions possible // (It doesn't mean it cannot be improved though) - std::size_t hash = 0; + std::size_t h = 0; switch (ip.GetProtocol()) { case Nz::NetProtocol_Any: @@ -389,20 +389,20 @@ namespace std case Nz::NetProtocol_IPv4: { - hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; + h = ip.ToUInt32() + (h << 6) + (h << 16) - h; break; } case Nz::NetProtocol_IPv6: { Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); for (std::size_t i = 0; i < v6.size(); i++) - hash = v6[i] + (hash << 6) + (hash << 16) - hash; + h = v6[i] + (h << 6) + (h << 16) - h; break; } } - return ip.GetPort() + (hash << 6) + (hash << 16) - hash; + return ip.GetPort() + (h << 6) + (h << 16) - h; } }; } diff --git a/include/Nazara/Physics2D/ConfigCheck.hpp b/include/Nazara/Physics2D/ConfigCheck.hpp index 4689d6e68..3b3b90afc 100644 --- a/include/Nazara/Physics2D/ConfigCheck.hpp +++ b/include/Nazara/Physics2D/ConfigCheck.hpp @@ -10,9 +10,9 @@ /// 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_PHYSICS_MANAGE_MEMORY - #undef NAZARA_PHYSICS_MANAGE_MEMORY - #define NAZARA_PHYSICS3D_MANAGE_MEMORY 0 +#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS2D_MANAGE_MEMORY + #undef NAZARA_PHYSICS2D_MANAGE_MEMORY + #define NAZARA_PHYSICS2D_MANAGE_MEMORY 0 #endif #endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP diff --git a/include/Nazara/Physics2D/Debug.hpp b/include/Nazara/Physics2D/Debug.hpp index f9cebc624..729491e7c 100644 --- a/include/Nazara/Physics2D/Debug.hpp +++ b/include/Nazara/Physics2D/Debug.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#include +#if NAZARA_PHYSICS2D_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/Physics2D/DebugOff.hpp b/include/Nazara/Physics2D/DebugOff.hpp index dd95ffe34..ffbd0a25a 100644 --- a/include/Nazara/Physics2D/DebugOff.hpp +++ b/include/Nazara/Physics2D/DebugOff.hpp @@ -3,7 +3,7 @@ // 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_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS2D_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Physics3D/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp index 6b1c82073..012cc426c 100644 --- a/include/Nazara/Physics3D/ConfigCheck.hpp +++ b/include/Nazara/Physics3D/ConfigCheck.hpp @@ -10,8 +10,8 @@ /// 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_PHYSICS_MANAGE_MEMORY - #undef NAZARA_PHYSICS_MANAGE_MEMORY +#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS3D_MANAGE_MEMORY + #undef NAZARA_PHYSICS3D_MANAGE_MEMORY #define NAZARA_PHYSICS3D_MANAGE_MEMORY 0 #endif diff --git a/include/Nazara/Physics3D/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp index f70a8b570..ef111fb96 100644 --- a/include/Nazara/Physics3D/Debug.hpp +++ b/include/Nazara/Physics3D/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS3D_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/Physics3D/DebugOff.hpp b/include/Nazara/Physics3D/DebugOff.hpp index 595f0ad94..b8b84c240 100644 --- a/include/Nazara/Physics3D/DebugOff.hpp +++ b/include/Nazara/Physics3D/DebugOff.hpp @@ -3,7 +3,7 @@ // 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_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS3D_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Physics3D/Enums.hpp b/include/Nazara/Physics3D/Enums.hpp index 1b8920cbc..b01c9bb83 100644 --- a/include/Nazara/Physics3D/Enums.hpp +++ b/include/Nazara/Physics3D/Enums.hpp @@ -25,6 +25,6 @@ namespace Nz ColliderType3D_Max = ColliderType3D_Tree }; -}; +} #endif // NAZARA_ENUMS_PHYSICS3D_HPP diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 131ceb7f3..1fd77546f 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -906,5 +906,5 @@ namespace Nz } return true; - }; + } } diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index ef5f62b96..e927e2d22 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -94,6 +94,7 @@ namespace Nz void InstancedRenderable::UpdateData(InstanceData* instanceData) const { NazaraAssert(instanceData, "Invalid instance data"); + NazaraUnused(instanceData); } InstancedRenderableLibrary::LibraryMap InstancedRenderable::s_library; diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 0823f5258..dcac9e178 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -146,7 +146,7 @@ namespace Nz if (!m_buffer) m_buffer = std::make_unique(); - m_buffer->Resize(static_cast(cursorPos)); + m_buffer->Resize(minCapacity); m_memoryStream.SetBuffer(m_buffer.get(), openMode); m_memoryStream.SetCursorPos(cursorPos); diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index 1c84dc498..2be3d44cf 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -385,7 +385,7 @@ namespace Nz * \remark Produces a NazaraError because it is a special stream */ - bool TcpClient::SetCursorPos(UInt64 offset) + bool TcpClient::SetCursorPos(UInt64 /*offset*/) { NazaraError("SetCursorPos() cannot be used on sequential streams"); return false; diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 628d29807..5a02b4bae 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -437,6 +437,10 @@ namespace Nz return result; #else + NazaraUnused(fdarray); + NazaraUnused(nfds); + NazaraUnused(timeout); + if (error) *error = SocketError_NotSupported; diff --git a/src/Nazara/Physics2D/Debug/NewOverload.cpp b/src/Nazara/Physics2D/Debug/NewOverload.cpp index bd3153d1d..0c82acc94 100644 --- a/src/Nazara/Physics2D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics2D/Debug/NewOverload.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#include +#if NAZARA_PHYSICS2D_MANAGE_MEMORY #include #include // Nécessaire ? diff --git a/src/Nazara/Physics3D/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp index 18092514c..b87984066 100644 --- a/src/Nazara/Physics3D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics3D/Debug/NewOverload.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS3D_MANAGE_MEMORY #include #include // Nécessaire ? diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 647b8ff91..d90ba5f1a 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -795,6 +795,7 @@ namespace Nz NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index"); NazaraAssert(!m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state"); NazaraUnused(texture); + NazaraUnused(attachmentIndex); InvalidateTargets(); } diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 1bbed892f..c3b60a6e5 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -331,19 +331,19 @@ namespace Nz Emit(mat.specular.b / 255.f); EmitLine(); - if (mat.alpha != 1.f) + if (!NumberEquals(mat.alpha, 1.f)) { Emit("d "); EmitLine(mat.alpha); } - if (mat.refractionIndex != 1.f) + if (!NumberEquals(mat.refractionIndex, 1.f)) { Emit("ni "); EmitLine(mat.refractionIndex); } - if (mat.shininess != 1.f) + if (!NumberEquals(mat.shininess, 1.f)) { Emit("ns "); EmitLine(mat.shininess); diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 3b03b7f78..eed0ee2b1 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -128,17 +128,17 @@ namespace Nz UInt32 faceReserve = 0; UInt32 vertexReserve = 0; unsigned int matCount = 0; - auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh* + auto GetMaterial = [&] (const String& mesh, const String& mat) -> Mesh* { - auto& map = meshesByName[meshName]; - auto it = map.find(matName); + auto& map = meshesByName[mesh]; + auto it = map.find(mat); if (it == map.end()) - it = map.insert(std::make_pair(matName, MatPair(Mesh(), matCount++))).first; + it = map.insert(std::make_pair(mat, MatPair(Mesh(), matCount++))).first; - Mesh& mesh = it->second.first; + Mesh& meshData = it->second.first; - mesh.faces.reserve(faceReserve); - mesh.vertices.reserve(vertexReserve); + meshData.faces.reserve(faceReserve); + meshData.vertices.reserve(vertexReserve); faceReserve = 0; vertexReserve = 0; @@ -550,19 +550,19 @@ namespace Nz EmitLine(pair.second.size()); EmitLine(); - for (std::size_t meshIndex : pair.second) + for (std::size_t index : pair.second) { - const Mesh& mesh = m_meshes[meshIndex]; + const Mesh& mesh = m_meshes[index]; Emit("g "); EmitLine(mesh.name); EmitLine(); - + Emit("# face count: "); EmitLine(mesh.faces.size()); Emit("# vertex count: "); EmitLine(mesh.vertices.size()); - + for (const Face& face : mesh.faces) { Emit('f'); diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 03a95f35a..0d06fa0ba 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -75,6 +75,7 @@ namespace Nz Font* SimpleTextDrawer::GetFont(std::size_t index) const { NazaraAssert(index == 0, "Font index out of range"); + NazaraUnused(index); return m_font; } diff --git a/src/Nazara/Utility/SoftwareBuffer.cpp b/src/Nazara/Utility/SoftwareBuffer.cpp index 081f0fda3..040017c1e 100644 --- a/src/Nazara/Utility/SoftwareBuffer.cpp +++ b/src/Nazara/Utility/SoftwareBuffer.cpp @@ -11,7 +11,7 @@ namespace Nz { - SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType type) + SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType /*type*/) { } From 482eeafdb7a1470cd350e42c392ad8b74b84fda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 4 Nov 2016 18:31:15 +0100 Subject: [PATCH 04/81] Remove save-failed file --- .gitignore | 1 + SDK/src/NDK/LuaBinding_Math.cpp.save-failed | 908 -------------------- 2 files changed, 1 insertion(+), 908 deletions(-) delete mode 100644 SDK/src/NDK/LuaBinding_Math.cpp.save-failed diff --git a/.gitignore b/.gitignore index 0801d2577..897acbca3 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ build/scripts/features/index.html doc # Codeblocks +*.save-failed build/**/*.cbp build/**/*.cbp build/**/*.cbTemp diff --git a/SDK/src/NDK/LuaBinding_Math.cpp.save-failed b/SDK/src/NDK/LuaBinding_Math.cpp.save-failed deleted file mode 100644 index 6abec5c7b..000000000 --- a/SDK/src/NDK/LuaBinding_Math.cpp.save-failed +++ /dev/null @@ -1,908 +0,0 @@ -// This file was automatically generated on 26 May 2014 at 01:05:31 - -#include -#include -#include -#include - -namespace Ndk -{ - /*! - * \brief Binds Math module to Lua - */ - - void LuaBinding::BindMath() - { - /*********************************** Nz::EulerAngles **********************************/ - eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 1U); - - switch (argCount) - { - case 0: - Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero()); - return true; - - case 1: - Nz::PlacementNew(angles, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); - return true; - - case 3: - Nz::PlacementNew(angles, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); - return true; - } - - lua.Error("No matching overload for EulerAngles constructor"); - return false; - }); - - eulerAngles.BindMethod("__tostring", &Nz::EulerAnglesd::ToString); - - eulerAngles.SetGetter([] (Nz::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& 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 (std::size_t 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::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int - { - bool succeeded; - instance.Inverse(&succeeded); - - return lua.Push(succeeded); - }); - - matrix4d.BindMethod("InverseAffine", [] (Nz::LuaInstance& 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::LuaInstance& 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.Set(*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.Set(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::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 4U); - - switch (argCount) - { - case 0: - case 4: - PlacementNew(rect, 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(rect, *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(rect, lua.CheckField("x", 1), - lua.CheckField("y", 1), - lua.CheckField("width", 1), - lua.CheckField("height", 1)); - } - else if (lua.IsOfType(1, "Vector2")) - PlacementNew(rect, *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(rect, lua.CheckNumber(1), lua.CheckNumber(2)); - else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2")) - PlacementNew(rect, *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::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount) - { - std::size_t argCount = std::min(argumentCount, 4U); - - switch (argCount) - { - case 0: - Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero()); - return true; - - case 1: - { - if (lua.IsOfType(1, "EulerAngles")) - Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); - else if (lua.IsOfType(1, "Quaternion")) - Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); - else - break; - - return true; - } - - case 2: - Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); - return true; - - case 4: - Nz::PlacementNew(quaternion, 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("__tostring", &Nz::Quaterniond::ToString); - - quaternion.SetGetter([] (Nz::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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.SetConstructor([] (Nz::LuaInstance& 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::LuaInstance& 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::LuaInstance& 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::RegisterMath(Nz::LuaInstance& instance) - { - eulerAngles.Register(instance); - matrix4d.Register(instance); - quaternion.Register(instance); - rect.Register(instance); - vector2d.Register(instance); - vector3d.Register(instance); - } -} From c4ad52235ffa1582424f67510c20310f9230a43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 4 Nov 2016 22:24:56 +0100 Subject: [PATCH 05/81] Utility/Win32: Fix Window title when using NAZARA_UTILITY_THREADED_WINDOW --- src/Nazara/Utility/Win32/WindowImpl.cpp | 6 +++--- src/Nazara/Utility/Win32/WindowImpl.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index b494a7789..8a4ce99f4 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -154,7 +154,7 @@ namespace Nz // On attend que la fenêtre soit créée mutex.Lock(); - m_thread = Thread(WindowThread, &m_handle, win32StyleEx, title.GetWideString().data(), win32Style, x, y, width, height, this, &mutex, &condition); + m_thread = Thread(WindowThread, &m_handle, win32StyleEx, title, win32Style, x, y, width, height, this, &mutex, &condition); condition.Wait(&mutex); mutex.Unlock(); #else @@ -1178,10 +1178,10 @@ namespace Nz } #if NAZARA_UTILITY_THREADED_WINDOW - void WindowImpl::WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, WindowImpl* window, Mutex* mutex, ConditionVariable* condition) + void WindowImpl::WindowThread(HWND* handle, DWORD styleEx, const String& title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, WindowImpl* window, Mutex* mutex, ConditionVariable* condition) { HWND& winHandle = *handle; - winHandle = CreateWindowExW(styleEx, className, title, style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), window); + winHandle = CreateWindowExW(styleEx, className, title.GetWideString().data(), style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), window); mutex->Lock(); condition->Signal(); diff --git a/src/Nazara/Utility/Win32/WindowImpl.hpp b/src/Nazara/Utility/Win32/WindowImpl.hpp index b0fcf8ae0..2e7078b32 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.hpp +++ b/src/Nazara/Utility/Win32/WindowImpl.hpp @@ -89,7 +89,7 @@ namespace Nz static LRESULT CALLBACK MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam); static UInt32 RetrieveStyle(HWND window); #if NAZARA_UTILITY_THREADED_WINDOW - static void WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); + static void WindowThread(HWND* handle, DWORD styleEx, const String& title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); #endif HCURSOR m_cursor; From 12f68779631ce29918e004ac3708532a3783dabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 4 Nov 2016 22:25:16 +0100 Subject: [PATCH 06/81] Fix some warnings --- include/Nazara/Core/ConditionVariable.hpp | 2 +- src/Nazara/Utility/Window.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/ConditionVariable.hpp b/include/Nazara/Core/ConditionVariable.hpp index f6aeafe9b..19ab9e863 100644 --- a/include/Nazara/Core/ConditionVariable.hpp +++ b/include/Nazara/Core/ConditionVariable.hpp @@ -29,7 +29,7 @@ namespace Nz bool Wait(Mutex* mutex, UInt32 timeout); ConditionVariable& operator=(const ConditionVariable&) = delete; - inline ConditionVariable& operator=(ConditionVariable&& condition) noexcept; + ConditionVariable& operator=(ConditionVariable&& condition) noexcept; private: ConditionVariableImpl* m_impl; diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 078ff2bc5..203ad7c71 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -335,6 +335,7 @@ namespace Nz void Window::ProcessEvents(bool block) { NazaraAssert(m_impl, "Window not created"); + NazaraUnused(block); #if !NAZARA_UTILITY_THREADED_WINDOW m_impl->ProcessEvents(block); From 581cc989de3b1332d51589e7cb4502903772e072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 4 Nov 2016 22:57:07 +0100 Subject: [PATCH 07/81] Utility/Win32: Fix cached position never getting updated with threaded windows Closes #104 --- src/Nazara/Utility/Win32/WindowImpl.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 8a4ce99f4..0c1d23050 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -792,12 +792,17 @@ namespace Nz RECT windowRect; GetWindowRect(m_handle, &windowRect); - WindowEvent event; - event.type = WindowEventType_Moved; - event.position.x = windowRect.left; - event.position.y = windowRect.top; - m_parent->PushEvent(event); + Vector2i position(windowRect.left, windowRect.top); + if (m_position != position) + { + m_position = position; + WindowEvent event; + event.type = WindowEventType_Moved; + event.position.x = position.x; + event.position.y = position.y; + m_parent->PushEvent(event); + } break; } From 6ebe29ceb453dceaa9739f3a2c47b200a9839b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 4 Nov 2016 23:18:36 +0100 Subject: [PATCH 08/81] Utility/Win32: Generate only one WindowEvent_Moved per movement When not using threaded windows. Fixed #105 --- src/Nazara/Utility/Win32/WindowImpl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 0c1d23050..0c193cfaa 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -789,6 +789,11 @@ namespace Nz case WM_MOVE: { + #if !NAZARA_UTILITY_THREADED_WINDOW + if (m_sizemove) + break; + #endif + RECT windowRect; GetWindowRect(m_handle, &windowRect); From 5aeb9f8d592162a9ace3a692af56b81fa733e540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 11:17:19 +0100 Subject: [PATCH 09/81] Build: Add CodeBlocks target to premake5 --- build/scripts/actions/codeblocks.lua | 6 + .../actions/codeblocks/_codeblocks.lua | 44 ++++ .../scripts/actions/codeblocks/codeblocks.lua | 67 +++++ .../actions/codeblocks/codeblocks_project.lua | 243 ++++++++++++++++++ .../codeblocks/codeblocks_workspace.lua | 44 ++++ build/scripts/common.lua | 70 ++--- 6 files changed, 441 insertions(+), 33 deletions(-) create mode 100644 build/scripts/actions/codeblocks.lua create mode 100644 build/scripts/actions/codeblocks/_codeblocks.lua create mode 100644 build/scripts/actions/codeblocks/codeblocks.lua create mode 100644 build/scripts/actions/codeblocks/codeblocks_project.lua create mode 100644 build/scripts/actions/codeblocks/codeblocks_workspace.lua diff --git a/build/scripts/actions/codeblocks.lua b/build/scripts/actions/codeblocks.lua new file mode 100644 index 000000000..2a1f8b249 --- /dev/null +++ b/build/scripts/actions/codeblocks.lua @@ -0,0 +1,6 @@ +if (PremakeVersion >= 50) then + dofile("codeblocks/_codeblocks.lua") + dofile("codeblocks/codeblocks.lua") +end + +ACTION.Manual = true diff --git a/build/scripts/actions/codeblocks/_codeblocks.lua b/build/scripts/actions/codeblocks/_codeblocks.lua new file mode 100644 index 000000000..6a52bc404 --- /dev/null +++ b/build/scripts/actions/codeblocks/_codeblocks.lua @@ -0,0 +1,44 @@ +-- +-- _codeblocks.lua +-- Define the Code::Blocks action(s). +-- Copyright (c) 2002-2011 Jason Perkins and the Premake project +-- + local p = premake + + p.modules.codeblocks = {} + p.modules.codeblocks._VERSION = p._VERSION + + local codeblocks = p.modules.codeblocks + + newaction { + trigger = "codeblocks", + shortname = "Code::Blocks", + description = "Generate Code::Blocks project files", + + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, + + valid_languages = { "C", "C++" }, + + valid_tools = { + cc = { "clang", "gcc", "ow" }, + }, + + onWorkspace = function(wks) + p.modules.codeblocks.generateWorkspace(wks) + end, + + onProject = function(prj) + p.modules.codeblocks.generateProject(prj) + end, + + onCleanWorkspace = function(wks) + p.clean.file(wks, wks.name .. ".workspace") + p.clean.file(wks, wks.name .. ".workspace.layout") + end, + + onCleanProject = function(prj) + p.clean.file(prj, prj.name .. ".workspace") + p.clean.file(prj, prj.name .. ".depend") + p.clean.file(prj, prj.name .. ".layout") + end + } diff --git a/build/scripts/actions/codeblocks/codeblocks.lua b/build/scripts/actions/codeblocks/codeblocks.lua new file mode 100644 index 000000000..ebd8d11fa --- /dev/null +++ b/build/scripts/actions/codeblocks/codeblocks.lua @@ -0,0 +1,67 @@ +-- +-- codeblocks_workspace.lua +-- Generate a Code::Blocks workspace. +-- Copyright (c) 2009 Jason Perkins and the Premake project +-- + + local p = premake + + p.modules.codeblocks = {} + p.modules.codeblocks._VERSION = p._VERSION + + local codeblocks = p.modules.codeblocks + local project = p.project + + + function codeblocks.cfgname(cfg) + local cfgname = cfg.buildcfg + if codeblocks.workspace.multiplePlatforms then + cfgname = string.format("%s|%s", cfg.platform, cfg.buildcfg) + end + return cfgname + end + + function codeblocks.esc(value) + local result = value:gsub('"', '"') + result = result:gsub('<', '<') + result = result:gsub('>', '>') + return result + end + + function codeblocks.generateWorkspace(wks) + p.eol("\r\n") + p.indent("\t") + p.escaper(codeblocks.esc) + + p.generate(wks, ".workspace", codeblocks.workspace.generate) + end + + function codeblocks.generateProject(prj) + p.eol("\r\n") + p.indent("\t") + p.escaper(codeblocks.esc) + + if project.iscpp(prj) then + p.generate(prj, ".cbp", codeblocks.project.generate) + end + end + + function codeblocks.cleanWorkspace(wks) + p.clean.file(wks, wks.name .. ".workspace") + p.clean.file(wks, wks.name .. ".workspace.layout") + end + + function codeblocks.cleanProject(prj) + p.clean.file(prj, prj.name .. ".workspace") + p.clean.file(prj, prj.name .. ".depend") + p.clean.file(prj, prj.name .. ".layout") + end + + function codeblocks.cleanTarget(prj) + -- TODO.. + end + + include("codeblocks_workspace.lua") + include("codeblocks_project.lua") + + diff --git a/build/scripts/actions/codeblocks/codeblocks_project.lua b/build/scripts/actions/codeblocks/codeblocks_project.lua new file mode 100644 index 000000000..9882d5fbe --- /dev/null +++ b/build/scripts/actions/codeblocks/codeblocks_project.lua @@ -0,0 +1,243 @@ +-- +-- codeblocks_cbp.lua +-- Generate a Code::Blocks C/C++ project. +-- Copyright (c) 2009, 2011 Jason Perkins and the Premake project +-- + + local p = premake + local project = p.project + local config = p.config + local tree = p.tree + local codeblocks = p.modules.codeblocks + + codeblocks.project = {} + local m = codeblocks.project + m.elements = {} + + m.ctools = { + gcc = "gcc", + msc = "Visual C++", + } + + function m.getcompilername(cfg) + local tool = _OPTIONS.cc or cfg.toolset or p.GCC + + local toolset = p.tools[tool] + if not toolset then + error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'") + end + + return m.ctools[tool] + end + + function m.getcompiler(cfg) + local toolset = p.tools[_OPTIONS.cc or cfg.toolset or p.GCC] + if not toolset then + error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'") + end + return toolset + end + + function m.header(prj) + _p('') + _p('') + _p(1,'') + + -- write project block header + _p(1,'') + _p(2,'') + _p('') + end + + m.elements.project = function(prj) + return { + m.header, + m.configurations, + m.files, + m.extensions, + m.footer + } + end + +-- +-- Project: Generate the CodeBlocks project file. +-- + function m.generate(prj) + p.utf8() + + p.callArray(m.elements.project, prj) + end + + function m.configurations(prj) + -- write configuration blocks + _p(2,'') + local platforms = {} + for cfg in project.eachconfig(prj) do + local found = false + for k,v in pairs(platforms) do + if (v.platform == cfg.platform) then + table.insert(v.configs, cfg) + found = true + break + end + end + + if (not found) then + table.insert(platforms, {platform = cfg.platform, configs = {cfg}}) + end + end + + for k,platform in pairs(platforms) do + for k,cfg in pairs(platform.configs) do + local compiler = m.getcompiler(cfg) + + _p(3,'', cfg.longname) + + _p(4,'') + end + end + _p(2,'') + end + +-- +-- Write out a list of the source code files in the project. +-- + + function m.files(prj) + local pchheader + if (prj.pchheader) then + pchheader = path.getrelative(prj.location, prj.pchheader) + end + + local tr = project.getsourcetree(prj) + tree.traverse(tr, { + -- source files are handled at the leaves + onleaf = function(node, depth) + if node.relpath == node.vpath then + _p(2,'', node.relpath) + else + _p(2,'', node.name) + _p(3,'') + + end, + }, false, 1) + end + + function m.extensions(prj) + for cfg in project.eachconfig(prj) do + if cfg.debugenvs and #cfg.debugenvs > 0 then + --Assumption: if gcc is being used then so is gdb although this section will be ignored by + --other debuggers. If using gcc and not gdb it will silently not pass the + --environment arguments to the debugger + if m.getcompilername(cfg) == "gcc" then + _p(3,'') + _p(4,'', p.esc(cfg.longname)) + local args = '' + local sz = #cfg.debugenvs + for idx, v in ipairs(cfg.debugenvs) do + args = args .. 'set env ' .. v + if sz ~= idx then args = args .. ' ' end + end + _p(5,'',args) + _p(4,'') + _p(3,'') + else + error('Sorry at this moment there is no support for debug environment variables with this debugger and codeblocks') + end + end + end + end diff --git a/build/scripts/actions/codeblocks/codeblocks_workspace.lua b/build/scripts/actions/codeblocks/codeblocks_workspace.lua new file mode 100644 index 000000000..3de935877 --- /dev/null +++ b/build/scripts/actions/codeblocks/codeblocks_workspace.lua @@ -0,0 +1,44 @@ +-- +-- Name: codelite/codelite_workspace.lua +-- Purpose: Generate a CodeLite workspace. +-- Author: Ryan Pusztai +-- Modified by: Andrea Zanellato +-- Manu Evans +-- Created: 2013/05/06 +-- Copyright: (c) 2008-2015 Jason Perkins and the Premake project +-- + + local p = premake + local project = p.project + local workspace = p.workspace + local tree = p.tree + local codeblocks = p.modules.codeblocks + + codeblocks.workspace = {} + local m = codeblocks.workspace + +-- +-- Generate a CodeBlocks workspace +-- + function m.generate(wks) + p.utf8() + + _p('') + _p('') + _p(1,'', wks.name) + + for prj in workspace.eachproject(wks) do + local fname = path.join(path.getrelative(wks.location, prj.location), prj.name) + local active = iif(prj.project == wks.projects[1], ' active="1"', '') + + _p(2,'', fname, active) + for _,dep in ipairs(project.getdependencies(prj)) do + _p(3,'', path.join(path.getrelative(wks.location, dep.location), dep.name)) + end + + _p(2,'') + end + + _p(1,'') + _p('') + end \ No newline at end of file diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 423ebad0d..42a565fd6 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -14,6 +14,12 @@ function NazaraBuild:Execute() return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end + if (PremakeVersion >= 50) then + filter { "kind:SharedLib", "action:codeblocks or codelite or gmake or xcode3 or xcode4" } + implibprefix "lib" + implibextension ".a" + end + local platformData if (os.is64bit()) then platformData = {"x64", "x32"} @@ -721,7 +727,7 @@ function NazaraBuild:MakeInstallCommands(infoTable) for k,v in pairs(self.InstallDir) do local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) + postbuildcommands({[[xcopy "%{path.translate(cfg.buildtarget.relpath)}" "]] .. destPath .. [[\" /E /Y]]}) end for k,fileName in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do @@ -877,40 +883,38 @@ function NazaraBuild:Process(infoTable) end function NazaraBuild:RegisterAction(actionTable) - if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then - return false, "Invalid action name" + if (not actionTable.Manual) then + if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then + return false, "Invalid action name" + end + + local lowerCaseName = string.lower(actionTable.Name) + if (self.Actions[lowerCaseName] ~= nil) then + return false, "This action name is already in use" + end + + if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then + return false, "Action description is invalid" + end + + if (string.len(actionTable.Description) == 0) then + return false, "Action description is empty" + end + + if (actionTable.Function == nil or type(actionTable.Function) ~= "function") then + return false, "Action function is invalid" + end + + self.Actions[lowerCaseName] = actionTable + + newaction + { + trigger = lowerCaseName, + description = actionTable.Description, + execute = function () actionTable:Function() end + } end - local lowerCaseName = string.lower(actionTable.Name) - if (self.Actions[lowerCaseName] ~= nil) then - return false, "This action name is already in use" - end - - if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then - return false, "Action description is invalid" - end - - if (string.len(actionTable.Description) == 0) then - return false, "Action description is empty" - end - - if (self.Actions[actionTable.name] ~= nil) then - return false, "Action name \"" .. actionTable.name .. " is already registred" - end - - if (actionTable.Function == nil or type(actionTable.Function) ~= "function") then - return false, "Action function is invalid" - end - - self.Actions[lowerCaseName] = actionTable - - newaction - { - trigger = lowerCaseName, - description = actionTable.Description, - execute = function () actionTable:Function() end - } - return true end From 88000ab2e4dd6a2cc565cf4023ea7ddf03c4d62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 21:30:37 +0100 Subject: [PATCH 10/81] Build: Upgrade to Premake5-alpha10, get rid of Premake4 --- build/Build_CodeBlocks.bat | 2 +- build/scripts/actions/codeblocks.lua | 6 +- build/scripts/common.lua | 443 ++++++++++----------------- 3 files changed, 162 insertions(+), 289 deletions(-) diff --git a/build/Build_CodeBlocks.bat b/build/Build_CodeBlocks.bat index 439c5efac..5e6c23c44 100644 --- a/build/Build_CodeBlocks.bat +++ b/build/Build_CodeBlocks.bat @@ -1 +1 @@ -premake4 codeblocks \ No newline at end of file +premake5 codeblocks \ No newline at end of file diff --git a/build/scripts/actions/codeblocks.lua b/build/scripts/actions/codeblocks.lua index 2a1f8b249..f96a6d591 100644 --- a/build/scripts/actions/codeblocks.lua +++ b/build/scripts/actions/codeblocks.lua @@ -1,6 +1,4 @@ -if (PremakeVersion >= 50) then - dofile("codeblocks/_codeblocks.lua") - dofile("codeblocks/codeblocks.lua") -end +dofile("codeblocks/_codeblocks.lua") +dofile("codeblocks/codeblocks.lua") ACTION.Manual = true diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 42a565fd6..402484e06 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -9,27 +9,103 @@ function NazaraBuild:AddInstallPath(path) self.InstallDir[path] = true end +function NazaraBuild:FilterLibDirectory(prefix, func) + filter({"action:codeblocks or codelite or gmake", "architecture:x86", "system:Windows"}) + func(prefix .. "mingw/x86") + + filter({"action:codeblocks or codelite or gmake", "architecture:x86_64", "system:Windows"}) + func(prefix .. "mingw/x64") + + filter({"action:codeblocks or codelite or gmake", "architecture:x86", "system:not Windows"}) + func(prefix .. "gmake/x86") + + filter({"action:codeblocks or codelite or gmake", "architecture:x86_64", "system:not Windows"}) + func(prefix .. "gmake/x64") + + filter({"action:vs*", "architecture:x86"}) + func(prefix .. "msvc/x86") + + filter({"action:vs*", "architecture:x86_64"}) + func(prefix .. "msvc/x64") + + filter({"action:xcode3 or xcode4", "architecture:x86"}) + func(prefix .. "xcode/x86") + + filter({"action:xcode3 or xcode4", "architecture:x86_64"}) + func(prefix .. "xcode/x64") + + filter({}) +end + function NazaraBuild:Execute() - if (_ACTION == nil) then -- Si aucune action n'est spécifiée + if (_ACTION == nil) then -- If no action is specified, the user probably only wants to know how all of this works return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end - if (PremakeVersion >= 50) then - filter { "kind:SharedLib", "action:codeblocks or codelite or gmake or xcode3 or xcode4" } - implibprefix "lib" - implibextension ".a" - end + + local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake", "xcode3", "xcode4"}, " or ") local platformData if (os.is64bit()) then - platformData = {"x64", "x32"} + platformData = {"x64", "x86"} else - platformData = {"x32", "x64"} + platformData = {"x86", "x64"} end - if (self.Actions[_ACTION] == nil) then - local makeLibDir = os.is("windows") and "mingw" or "gmake" + flags({ + "C++14", + "MultiProcessorCompile", + "NoMinimalRebuild" + }) + self:FilterLibDirectory("../extlibs/lib/", libdirs) + + -- Fixes Premake stuff + filter({"kind:SharedLib", clangGccActions}) + implibprefix("lib") + filter({"kind:*Lib", clangGccActions, "system:Windows"}) + implibextension(".a") + filter({"kind:StaticLib", clangGccActions}) + targetextension(".a") + targetprefix("lib") + + -- General configuration + filter("kind:*Lib") + pic("On") + + filter({"kind:*Lib", "configurations:DebugStatic"}) + targetsuffix("-s-d") + + filter({"kind:*Lib", "configurations:ReleaseStatic"}) + targetsuffix("-s") + + filter({"kind:*Lib", "configurations:DebugDynamic"}) + targetsuffix("-d") + + filter("configurations:Debug*") + symbols("On") + + -- Setup some optimizations for release + filter("configurations:Release*") + flags("NoFramePointer") + optimize("Speed") + rtti("Off") + vectorextensions("SSE2") + + filter("configurations:*Static") + kind("StaticLib") + + filter("configurations:*Dynamic") + kind("SharedLib") + + -- Enable SSE math and vectorization optimizations + filter({"configurations:Release*", clangGccActions}) + buildoptions("-mfpmath=sse") + buildoptions("-ftree-vectorize") + + filter({}) + + if (self.Actions[_ACTION] == nil) then if (self.Config["BuildDependencies"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -40,63 +116,18 @@ function NazaraBuild:Execute() "ReleaseStatic" }) + self:FilterLibDirectory("../extlibs/lib/", targetdir) + + filter(clangGccActions) + buildoptions("-U__STRICT_ANSI__") + + filter({}) + includedirs("../extlibs/include") libdirs("../extlibs/lib/common") location(_ACTION) kind("StaticLib") - configuration({"codeblocks or codelite or gmake", "x32"}) - libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") - - configuration({"codeblocks or codelite or gmake", "x64"}) - libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - targetdir("../extlibs/lib/" .. makeLibDir .. "/x64") - - configuration("vs*") - buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj - - configuration({"vs*", "x32"}) - libdirs("../extlibs/lib/msvc/x86") - targetdir("../extlibs/lib/msvc/x86") - - configuration({"vs*", "x64"}) - libdirs("../extlibs/lib/msvc/x64") - targetdir("../extlibs/lib/msvc/x64") - - configuration({"xcode3 or xcode4", "x32"}) - libdirs("../extlibs/lib/xcode/x86") - targetdir("../extlibs/lib/xcode/x86") - - configuration({"xcode3 or xcode4", "x64"}) - libdirs("../extlibs/lib/xcode/x64") - targetdir("../extlibs/lib/xcode/x64") - - configuration("Debug*") - flags("Symbols") - - configuration("Release*") - flags("NoFramePointer") - optimize("Speed") - rtti("Off") - vectorextensions("SSE2") - - configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) - buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants - buildoptions("-ftree-vectorize") -- Activation de la vectorisation du code - - configuration("DebugStatic") - targetsuffix("-s-d") - - configuration("ReleaseStatic") - targetsuffix("-s") - - configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) - buildoptions("-fPIC") - - configuration("codeblocks or codelite or gmake or xcode3 or xcode4") - buildoptions({"-std=c++14", "-U__STRICT_ANSI__"}) - for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) @@ -111,25 +142,44 @@ function NazaraBuild:Execute() includedirs(libTable.Includes) links(libTable.Libraries) - configuration("x32") + filter("architecture:x86") libdirs(libTable.LibraryPaths.x86) - configuration("x64") + filter("architecture:x86_64") libdirs(libTable.LibraryPaths.x64) for k,v in pairs(libTable.ConfigurationLibraries) do - configuration(k) - links(v) + filter(k) + links(v) end - configuration({}) + filter({}) end end + -- General settings + filter("architecture:x86_64") + defines("NAZARA_PLATFORM_x64") + + filter("configurations:Debug*") + defines("NAZARA_DEBUG") + + filter("configurations:*Static") + defines("NAZARA_STATIC") + + filter("kind:*Lib") + defines("NAZARA_BUILD") + + filter({"system:not Windows", clangGccActions}) + buildoptions("-fvisibility=hidden") + + -- Add lib/conf/arch to library search path + self:FilterLibDirectory("../lib/", libdirs) + + -- Start defining projects workspace("NazaraEngine") platforms(platformData) - -- Configuration générale configurations({ -- "DebugStatic", -- "ReleaseStatic", @@ -140,36 +190,13 @@ function NazaraBuild:Execute() language("C++") location(_ACTION) - configuration("Debug*") - defines("NAZARA_DEBUG") - flags("Symbols") - - configuration("Release*") - flags("NoFramePointer") - optimize("Speed") - vectorextensions("SSE2") - - configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) - buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants - buildoptions("-ftree-vectorize") -- Activation de la vectorisation du code - - configuration("*Static") - defines("NAZARA_STATIC") - - configuration("codeblocks or codelite or gmake or xcode3 or xcode4") - buildoptions("-std=c++14") - - configuration({"linux or bsd or macosx", "gmake"}) - buildoptions("-fvisibility=hidden") - configuration("vs*") buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj flags("NoMinimalRebuild") defines("_CRT_SECURE_NO_WARNINGS") defines("_SCL_SECURE_NO_WARNINGS") - - -- Spécification des modules + -- Modules if (_OPTIONS["united"]) then project("NazaraEngine") end @@ -181,78 +208,12 @@ function NazaraBuild:Execute() location(_ACTION .. "/modules") - defines("NAZARA_BUILD") - includedirs({ "../include", "../src/", "../extlibs/include" }) - libdirs("../lib") - libdirs("../extlibs/lib/common") - - configuration("x32") - libdirs(moduleTable.LibraryPaths.x86) - - configuration("x64") - defines("NAZARA_PLATFORM_x64") - libdirs(moduleTable.LibraryPaths.x64) - - configuration({"codeblocks or codelite or gmake", "x32"}) - libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - libdirs("../lib/" .. makeLibDir .. "/x86") - targetdir("../lib/" .. makeLibDir .. "/x86") - - configuration({"codeblocks or codelite or gmake", "x64"}) - libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - libdirs("../lib/" .. makeLibDir .. "/x64") - targetdir("../lib/" .. makeLibDir .. "/x64") - - -- Copy the module binaries to the example folder - self:MakeInstallCommands(moduleTable) - - configuration({"vs*", "x32"}) - libdirs("../extlibs/lib/msvc/x86") - libdirs("../lib/msvc/x86") - targetdir("../lib/msvc/x86") - - configuration({"vs*", "x64"}) - libdirs("../extlibs/lib/msvc/x64") - libdirs("../lib/msvc/x64") - targetdir("../lib/msvc/x64") - - configuration({"xcode3 or xcode4", "x32"}) - libdirs("../extlibs/lib/xcode/x86") - libdirs("../lib/xcode/x86") - targetdir("../lib/xcode/x86") - - configuration({"xcode3 or xcode4", "x64"}) - libdirs("../extlibs/lib/xcode/x64") - libdirs("../lib/xcode/x64") - targetdir("../lib/xcode/x64") - - configuration("*Static") - defines("NAZARA_STATIC") - kind("StaticLib") - - configuration("*Dynamic") - kind("SharedLib") - - configuration("DebugStatic") - targetsuffix("-s-d") - - configuration("ReleaseStatic") - targetsuffix("-s") - - configuration("DebugDynamic") - targetsuffix("-d") - - configuration("Release*") - rtti(moduleTable.EnableRTTI and "On" or "Off") - - configuration({}) - files(moduleTable.Files) excludes(moduleTable.FilesExcluded) @@ -261,6 +222,23 @@ function NazaraBuild:Execute() includedirs(moduleTable.Includes) links(moduleTable.Libraries) + libdirs({ + "../extlibs/lib/common", + "../lib" + }) + + -- Output to lib/conf/arch + self:FilterLibDirectory("../lib/", targetdir) + + -- Copy the module binaries to the example folder + self:MakeInstallCommands(moduleTable) + + filter("architecture:x86") + libdirs(moduleTable.LibraryPaths.x86) + + filter("architecture:x86_64") + libdirs(moduleTable.LibraryPaths.x64) + for k,v in pairs(moduleTable.ConfigurationLibraries) do configuration(k) links(v) @@ -294,7 +272,7 @@ function NazaraBuild:Execute() kind("WindowedApp") end else - assert(false, "Invalid tool Kind") + assert(false, "Invalid tool kind") end includedirs({ @@ -302,94 +280,10 @@ function NazaraBuild:Execute() "../extlibs/include" }) - libdirs("../lib") - libdirs("../extlibs/lib/common") - - configuration("x32") - libdirs(toolTable.LibraryPaths.x86) - - configuration("x64") - defines("NAZARA_PLATFORM_x64") - libdirs(toolTable.LibraryPaths.x64) - - configuration({"codeblocks or codelite or gmake", "x32"}) - libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - libdirs("../lib/" .. makeLibDir .. "/x86") - if (toolTable.Kind == "library") then - targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") - elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/lib/" .. makeLibDir .. "/x86") - end - - configuration({"codeblocks or codelite or gmake", "x64"}) - libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - libdirs("../lib/" .. makeLibDir .. "/x64") - if (toolTable.Kind == "library") then - targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") - elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/lib/" .. makeLibDir .. "/x64") - end - - configuration({"vs*", "x32"}) - libdirs("../extlibs/lib/msvc/x86") - libdirs("../lib/msvc/x86") - if (toolTable.Kind == "library") then - targetdir(toolTable.TargetDirectory .. "/msvc/x86") - elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/lib/msvc/x86") - end - - configuration({"vs*", "x64"}) - libdirs("../extlibs/lib/msvc/x64") - libdirs("../lib/msvc/x64") - if (toolTable.Kind == "library") then - targetdir(toolTable.TargetDirectory .. "/msvc/x64") - elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/lib/msvc/x64") - end - - configuration({"xcode3 or xcode4", "x32"}) - libdirs("../extlibs/lib/xcode/x86") - libdirs("../lib/xcode/x86") - if (toolTable.Kind == "library") then - targetdir(toolTable.TargetDirectory .. "/xcode/x86") - elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/lib/xcode/x86") - end - - configuration({"xcode3 or xcode4", "x64"}) - libdirs("../extlibs/lib/xcode/x64") - libdirs("../lib/xcode/x64") - if (toolTable.Kind == "library") then - targetdir(toolTable.TargetDirectory .. "/xcode/x64") - elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/lib/xcode/x64") - end - - configuration("*Static") - defines("NAZARA_STATIC") - - configuration("Release*") - rtti(toolTable.EnableRTTI and "On" or "Off") - - if (toolTable.Kind == "library" or toolTable.Kind == "plugin") then - configuration("*Static") - kind("StaticLib") - - configuration("*Dynamic") - kind("SharedLib") - - configuration("DebugStatic") - targetsuffix("-s-d") - - configuration("ReleaseStatic") - targetsuffix("-s") - - configuration("DebugDynamic") - targetsuffix("-d") - end - - configuration({}) + libdirs({ + "../extlibs/lib/common", + "../lib" + }) files(toolTable.Files) excludes(toolTable.FilesExcluded) @@ -399,12 +293,25 @@ function NazaraBuild:Execute() includedirs(toolTable.Includes) links(toolTable.Libraries) + -- Output to lib/conf/arch + if (toolTable.Kind == "library") then + self:FilterLibDirectory(toolTable.TargetDirectory .. "/", targetdir) + elseif (toolTable.Kind == "plugin") then + self:FilterLibDirectory("../plugins/lib/", targetdir) + end + + filter("architecture:x86") + libdirs(toolTable.LibraryPaths.x86) + + filter("architecture:x86_64") + libdirs(toolTable.LibraryPaths.x64) + for k,v in pairs(toolTable.ConfigurationLibraries) do - configuration(k) + filter(k) links(v) end - configuration({}) + filter({}) end for k, exampleTable in ipairs(self.OrderedExamples) do @@ -435,7 +342,6 @@ function NazaraBuild:Execute() "../extlibs/include" }) libdirs("../lib") - targetdir(destPath) files(exampleTable.Files) excludes(exampleTable.FilesExcluded) @@ -444,41 +350,14 @@ function NazaraBuild:Execute() flags(exampleTable.Flags) includedirs(exampleTable.Includes) links(exampleTable.Libraries) - - configuration("Release*") - rtti(exampleTable.EnableRTTI and "On" or "Off") - - configuration("x32") - libdirs(exampleTable.LibraryPaths.x86) - - configuration("x64") - defines("NAZARA_PLATFORM_x64") - libdirs(exampleTable.LibraryPaths.x64) - - configuration({"codeblocks or codelite or gmake", "x32"}) - libdirs("../lib/" .. makeLibDir .. "/x86") - - configuration({"codeblocks or codelite or gmake", "x64"}) - libdirs("../lib/" .. makeLibDir .. "/x64") - - configuration({"vs*", "x32"}) - libdirs("../lib/msvc/x86") - - configuration({"vs*", "x64"}) - libdirs("../lib/msvc/x64") - - configuration({"xcode3 or xcode4", "x32"}) - libdirs("../lib/xcode/x86") - - configuration({"xcode3 or xcode4", "x64"}) - libdirs("../lib/xcode/x64") + targetdir(destPath) for k,v in pairs(exampleTable.ConfigurationLibraries) do - configuration(k) + filter(k) links(v) end - configuration({}) + filter({}) end end end @@ -718,10 +597,6 @@ function NazaraBuild:LoadConfig() end function NazaraBuild:MakeInstallCommands(infoTable) - if (PremakeVersion < 50) then - return - end - if (os.is("windows")) then configuration("*Dynamic") From 9e9b01eff5eb3454f056a2bbee6b2e5377cbb135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 21:30:49 +0100 Subject: [PATCH 11/81] .gitignore: Ignore GMake build files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 897acbca3..831ce911d 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,9 @@ build/**/*.workspace # CodeLite build/**/*.project +# GMake +build/**/*.make + # Visual Studio build/**/*.pdb build/**/*.filters From 6500d088e9034fe963fc4abb18655ab11cffa0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 21:59:48 +0100 Subject: [PATCH 12/81] Build: Fix some premake5 weirdness It seems some options are global and other local to the workspace (flags and buildoptions could be defined outside of the workspace, defines couldn't) --- build/scripts/common.lua | 157 +++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 74 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 402484e06..e7c685857 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -42,7 +42,6 @@ function NazaraBuild:Execute() return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end - local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake", "xcode3", "xcode4"}, " or ") local platformData @@ -52,59 +51,6 @@ function NazaraBuild:Execute() platformData = {"x86", "x64"} end - flags({ - "C++14", - "MultiProcessorCompile", - "NoMinimalRebuild" - }) - - self:FilterLibDirectory("../extlibs/lib/", libdirs) - - -- Fixes Premake stuff - filter({"kind:SharedLib", clangGccActions}) - implibprefix("lib") - filter({"kind:*Lib", clangGccActions, "system:Windows"}) - implibextension(".a") - filter({"kind:StaticLib", clangGccActions}) - targetextension(".a") - targetprefix("lib") - - -- General configuration - filter("kind:*Lib") - pic("On") - - filter({"kind:*Lib", "configurations:DebugStatic"}) - targetsuffix("-s-d") - - filter({"kind:*Lib", "configurations:ReleaseStatic"}) - targetsuffix("-s") - - filter({"kind:*Lib", "configurations:DebugDynamic"}) - targetsuffix("-d") - - filter("configurations:Debug*") - symbols("On") - - -- Setup some optimizations for release - filter("configurations:Release*") - flags("NoFramePointer") - optimize("Speed") - rtti("Off") - vectorextensions("SSE2") - - filter("configurations:*Static") - kind("StaticLib") - - filter("configurations:*Dynamic") - kind("SharedLib") - - -- Enable SSE math and vectorization optimizations - filter({"configurations:Release*", clangGccActions}) - buildoptions("-mfpmath=sse") - buildoptions("-ftree-vectorize") - - filter({}) - if (self.Actions[_ACTION] == nil) then if (self.Config["BuildDependencies"]) then workspace("NazaraExtlibs") @@ -116,6 +62,7 @@ function NazaraBuild:Execute() "ReleaseStatic" }) + self:PrepareGeneric() self:FilterLibDirectory("../extlibs/lib/", targetdir) filter(clangGccActions) @@ -156,30 +103,16 @@ function NazaraBuild:Execute() filter({}) end end - - -- General settings - filter("architecture:x86_64") - defines("NAZARA_PLATFORM_x64") - - filter("configurations:Debug*") - defines("NAZARA_DEBUG") - - filter("configurations:*Static") - defines("NAZARA_STATIC") - - filter("kind:*Lib") - defines("NAZARA_BUILD") - - filter({"system:not Windows", clangGccActions}) - buildoptions("-fvisibility=hidden") - - -- Add lib/conf/arch to library search path - self:FilterLibDirectory("../lib/", libdirs) - + -- Start defining projects workspace("NazaraEngine") platforms(platformData) + self:PrepareMainWorkspace() + + -- Add lib/conf/arch to library search path + self:FilterLibDirectory("../lib/", libdirs) + configurations({ -- "DebugStatic", -- "ReleaseStatic", @@ -757,6 +690,82 @@ function NazaraBuild:Process(infoTable) return true end +function NazaraBuild:PrepareGeneric() + flags({ + "C++14", + "MultiProcessorCompile", + "NoMinimalRebuild" + }) + + self:FilterLibDirectory("../extlibs/lib/", libdirs) + + -- Fixes Premake stuff + filter({"kind:SharedLib", clangGccActions}) + implibprefix("lib") + filter({"kind:*Lib", clangGccActions, "system:Windows"}) + implibextension(".a") + filter({"kind:StaticLib", clangGccActions}) + targetextension(".a") + targetprefix("lib") + + -- General configuration + filter("kind:*Lib") + pic("On") + + filter({"kind:*Lib", "configurations:DebugStatic"}) + targetsuffix("-s-d") + + filter({"kind:*Lib", "configurations:ReleaseStatic"}) + targetsuffix("-s") + + filter({"kind:*Lib", "configurations:DebugDynamic"}) + targetsuffix("-d") + + filter("configurations:Debug*") + symbols("On") + + -- Setup some optimizations for release + filter("configurations:Release*") + flags("NoFramePointer") + optimize("Speed") + rtti("Off") + vectorextensions("SSE2") + + filter("configurations:*Static") + kind("StaticLib") + + filter("configurations:*Dynamic") + kind("SharedLib") + + -- Enable SSE math and vectorization optimizations + filter({"configurations:Release*", clangGccActions}) + buildoptions("-mfpmath=sse") + buildoptions("-ftree-vectorize") + + filter({}) +end + +function NazaraBuild:PrepareMainWorkspace() + self:PrepareGeneric() + + filter("architecture:x86_64") + defines("NAZARA_PLATFORM_x64") + + filter("configurations:Debug*") + defines("NAZARA_DEBUG") + + filter("configurations:*Static") + defines("NAZARA_STATIC") + + filter("kind:*Lib") + defines("NAZARA_BUILD") + + filter({"system:not Windows", clangGccActions}) + buildoptions("-fvisibility=hidden") + + filter({}) +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 From 5e48f8b8b3ab536e494a4fe68beb62937ed92b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 22:04:47 +0100 Subject: [PATCH 13/81] Build: Fix install commands --- build/scripts/common.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e7c685857..0e46c9b9c 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -531,8 +531,10 @@ end function NazaraBuild:MakeInstallCommands(infoTable) if (os.is("windows")) then - configuration("*Dynamic") - + filter("kind:SharedLib") + + postbuildmessage("Copying " .. infoTable.Name .. " library and its dependencies to install/executable directories...") + for k,v in pairs(self.InstallDir) do local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) postbuildcommands({[[xcopy "%{path.translate(cfg.buildtarget.relpath)}" "]] .. destPath .. [[\" /E /Y]]}) @@ -541,24 +543,24 @@ function NazaraBuild:MakeInstallCommands(infoTable) for k,fileName in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} for k,v in pairs(infoTable.BinaryPaths.x86) do - table.insert(paths, {"x32", v .. "/" .. fileName .. ".dll"}) - table.insert(paths, {"x32", v .. "/lib" .. fileName .. ".dll"}) + table.insert(paths, {"x86", v .. "/" .. fileName .. ".dll"}) + table.insert(paths, {"x86", v .. "/lib" .. fileName .. ".dll"}) end for k,v in pairs(infoTable.BinaryPaths.x64) do - table.insert(paths, {"x64", v .. "/" .. fileName .. ".dll"}) - table.insert(paths, {"x64", v .. "/lib" .. fileName .. ".dll"}) + table.insert(paths, {"x86_64", v .. "/" .. fileName .. ".dll"}) + table.insert(paths, {"x86_64", v .. "/lib" .. fileName .. ".dll"}) end for k,v in pairs(paths) do - local config = v[1] + local arch = v[1] local srcPath = v[2] if (os.isfile(srcPath)) then if (infoTable.Kind == "plugin") then srcPath = "../../" .. srcPath end - configuration(config) + filter("architecture:" .. arch) for k,v in pairs(self.ExecutableDir) do local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]] @@ -568,6 +570,8 @@ function NazaraBuild:MakeInstallCommands(infoTable) end end end + + filter({}) end end From 0de741a541178df6e6e56baef40fde3fcda55d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 22:25:13 +0100 Subject: [PATCH 14/81] Build: Fix MSVC creating .a .. --- build/scripts/common.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 0e46c9b9c..dc340a12e 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -1,4 +1,7 @@ -NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table +NazaraBuild = {} + +-- I wish Premake had a way to know the compiler in advance +local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake", "xcode3", "xcode4"}, " or ") function NazaraBuild:AddExecutablePath(path) self.ExecutableDir[path] = true @@ -42,8 +45,6 @@ function NazaraBuild:Execute() return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end - local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake", "xcode3", "xcode4"}, " or ") - local platformData if (os.is64bit()) then platformData = {"x64", "x86"} From 0f14a57b2e1a4552b9280929fe07b79767893aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 22:41:22 +0100 Subject: [PATCH 15/81] Build: Cleanup common.lua --- build/scripts/common.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index dc340a12e..2fed34c43 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -124,12 +124,6 @@ function NazaraBuild:Execute() language("C++") location(_ACTION) - configuration("vs*") - buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj - flags("NoMinimalRebuild") - defines("_CRT_SECURE_NO_WARNINGS") - defines("_SCL_SECURE_NO_WARNINGS") - -- Modules if (_OPTIONS["united"]) then project("NazaraEngine") @@ -174,11 +168,11 @@ function NazaraBuild:Execute() libdirs(moduleTable.LibraryPaths.x64) for k,v in pairs(moduleTable.ConfigurationLibraries) do - configuration(k) + filter(k) links(v) end - configuration({}) + filter({}) end -- Tools @@ -753,6 +747,11 @@ end function NazaraBuild:PrepareMainWorkspace() self:PrepareGeneric() + filter("action:vs*") + buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj + defines("_CRT_SECURE_NO_WARNINGS") + defines("_SCL_SECURE_NO_WARNINGS") + filter("architecture:x86_64") defines("NAZARA_PLATFORM_x64") From 4f01e13b09ab1b8cc176c934e90d072125b17572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 23:12:08 +0100 Subject: [PATCH 16/81] Sdk: Fix typo --- SDK/include/NDK/Prerequesites.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Prerequesites.hpp b/SDK/include/NDK/Prerequesites.hpp index a2305c70f..78b894ccc 100644 --- a/SDK/include/NDK/Prerequesites.hpp +++ b/SDK/include/NDK/Prerequesites.hpp @@ -29,7 +29,7 @@ // Importation/Exportation of the API #if defined(NAZARA_STATIC) - #define #define NDK_API + #define NDK_API #else #ifdef NDK_BUILD #define NDK_API NAZARA_EXPORT From 638467f8791ba7752eb3f201a853c7f8d7345e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 6 Nov 2016 23:49:10 +0100 Subject: [PATCH 17/81] Build: Fix codeblocks debug and object directory --- build/scripts/actions/codeblocks/codeblocks_project.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/scripts/actions/codeblocks/codeblocks_project.lua b/build/scripts/actions/codeblocks/codeblocks_project.lua index 9882d5fbe..acfede4c2 100644 --- a/build/scripts/actions/codeblocks/codeblocks_project.lua +++ b/build/scripts/actions/codeblocks/codeblocks_project.lua @@ -102,10 +102,10 @@ _p(4,'