From 15f84dc712ca8ccc53fe62a899b8b1ccaf97a9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 12 Jun 2018 11:37:44 +0200 Subject: [PATCH] Noexcept all the things! --- ChangeLog.md | 1 + SDK/include/NDK/BaseComponent.hpp | 4 +-- SDK/include/NDK/BaseWidget.hpp | 4 +-- SDK/include/NDK/System.hpp | 4 +-- SDK/include/NDK/Widgets/CheckboxWidget.hpp | 2 +- include/Nazara/Core/AbstractHash.hpp | 4 +-- include/Nazara/Core/ByteArray.hpp | 2 +- include/Nazara/Core/ByteStream.hpp | 4 +-- include/Nazara/Core/ByteStream.inl | 30 ------------------- include/Nazara/Core/CallOnExit.hpp | 4 +-- include/Nazara/Core/FileLogger.hpp | 4 +-- include/Nazara/Core/GuillotineBinPack.hpp | 4 +-- include/Nazara/Core/MemoryStream.hpp | 7 +++-- include/Nazara/Core/ParameterList.hpp | 4 ++- include/Nazara/Core/PrimitiveList.hpp | 4 +-- include/Nazara/Core/RefCounted.hpp | 4 +-- include/Nazara/Core/SerializationContext.hpp | 3 +- include/Nazara/Core/StdLogger.hpp | 4 +-- include/Nazara/Core/Stream.hpp | 4 +-- .../Nazara/Graphics/AbstractRenderQueue.hpp | 4 +-- .../Graphics/AbstractRenderTechnique.hpp | 4 +-- include/Nazara/Graphics/RenderQueue.hpp | 9 ++++-- include/Nazara/Graphics/Renderable.hpp | 4 +-- include/Nazara/Network/AbstractSocket.hpp | 2 +- include/Nazara/Network/ENetHost.hpp | 2 +- include/Nazara/Network/ENetPeer.hpp | 7 +++-- include/Nazara/Network/IpAddress.hpp | 4 +-- include/Nazara/Network/RUdpConnection.hpp | 2 +- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Network/UdpSocket.hpp | 2 +- include/Nazara/Network/UdpSocket.inl | 2 +- include/Nazara/Physics3D/PhysWorld3D.hpp | 4 +-- include/Nazara/Platform/CursorController.hpp | 4 +-- include/Nazara/Platform/EventHandler.hpp | 4 +-- include/Nazara/Utility/Buffer.hpp | 4 +-- src/Nazara/Network/AbstractSocket.cpp | 4 +-- src/Nazara/Network/ENetHost.cpp | 2 +- 37 files changed, 72 insertions(+), 91 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 9e20da937..8f7b68007 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -111,6 +111,7 @@ Nazara Engine: - InstancedRenderable::SetMaterial methods are now public. - Fixed Model copy constructor not copying materials - ⚠️ Added InstancedRenderable::Clone() method +- Fixed a lot of classes not having their move constructor/assignation operator marked noexcept Nazara Development Kit: - Added ImageWidget (#139) diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index 013fe255f..3dd90bb75 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -23,7 +23,7 @@ namespace Ndk using Factory = std::function; BaseComponent(ComponentIndex componentIndex); - BaseComponent(BaseComponent&&) = default; + BaseComponent(BaseComponent&&) noexcept = default; virtual ~BaseComponent(); virtual std::unique_ptr Clone() const = 0; @@ -34,7 +34,7 @@ namespace Ndk inline static ComponentIndex GetMaxComponentIndex(); BaseComponent& operator=(const BaseComponent&) = delete; - BaseComponent& operator=(BaseComponent&&) = default; + BaseComponent& operator=(BaseComponent&&) noexcept = default; protected: BaseComponent(const BaseComponent&) = default; diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index a8c3e5cd4..12ab85cd1 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -30,7 +30,7 @@ namespace Ndk BaseWidget(BaseWidget* parent); BaseWidget(const BaseWidget&) = delete; - BaseWidget(BaseWidget&&) = default; + BaseWidget(BaseWidget&&) = delete; virtual ~BaseWidget(); template T* Add(Args&&... args); @@ -72,7 +72,7 @@ namespace Ndk void Show(bool show = true); BaseWidget& operator=(const BaseWidget&) = delete; - BaseWidget& operator=(BaseWidget&&) = default; + BaseWidget& operator=(BaseWidget&&) = delete; struct Padding { diff --git a/SDK/include/NDK/System.hpp b/SDK/include/NDK/System.hpp index d1b3cc39e..538fe097c 100644 --- a/SDK/include/NDK/System.hpp +++ b/SDK/include/NDK/System.hpp @@ -17,11 +17,11 @@ namespace Ndk public: System(); System(const System&) = delete; - System(System&&) = default; + System(System&&) noexcept = default; virtual ~System(); System& operator=(const System&) = delete; - System& operator=(System&&) = default; + System& operator=(System&&) noexcept = default; static SystemIndex RegisterSystem(); }; diff --git a/SDK/include/NDK/Widgets/CheckboxWidget.hpp b/SDK/include/NDK/Widgets/CheckboxWidget.hpp index c938740e4..9d175fdbe 100644 --- a/SDK/include/NDK/Widgets/CheckboxWidget.hpp +++ b/SDK/include/NDK/Widgets/CheckboxWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Samy Bensaid +// Copyright (C) 2017 Samy Bensaid // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/Nazara/Core/AbstractHash.hpp b/include/Nazara/Core/AbstractHash.hpp index dc227d0f7..e99e174db 100644 --- a/include/Nazara/Core/AbstractHash.hpp +++ b/include/Nazara/Core/AbstractHash.hpp @@ -20,7 +20,7 @@ namespace Nz public: AbstractHash() = default; AbstractHash(const AbstractHash&) = delete; - AbstractHash(AbstractHash&&) = default; + AbstractHash(AbstractHash&&) noexcept = default; virtual ~AbstractHash(); virtual void Append(const UInt8* data, std::size_t len) = 0; @@ -31,7 +31,7 @@ namespace Nz virtual const char* GetHashName() const = 0; AbstractHash& operator=(const AbstractHash&) = delete; - AbstractHash& operator=(AbstractHash&&) = default; + AbstractHash& operator=(AbstractHash&&) noexcept = default; static std::unique_ptr Get(HashType hash); }; diff --git a/include/Nazara/Core/ByteArray.hpp b/include/Nazara/Core/ByteArray.hpp index 9cc226c1d..ac378b366 100644 --- a/include/Nazara/Core/ByteArray.hpp +++ b/include/Nazara/Core/ByteArray.hpp @@ -41,7 +41,7 @@ namespace Nz inline ByteArray(size_type n, value_type value); template ByteArray(InputIterator first, InputIterator last); ByteArray(const ByteArray& other) = default; - ByteArray(ByteArray&& other) = default; + ByteArray(ByteArray&& other) noexcept = default; ~ByteArray() = default; inline iterator Append(const void* buffer, size_type size); diff --git a/include/Nazara/Core/ByteStream.hpp b/include/Nazara/Core/ByteStream.hpp index 58dd138cd..2f1dba4b6 100644 --- a/include/Nazara/Core/ByteStream.hpp +++ b/include/Nazara/Core/ByteStream.hpp @@ -24,7 +24,7 @@ namespace Nz ByteStream(void* ptr, Nz::UInt64 size); ByteStream(const void* ptr, Nz::UInt64 size); ByteStream(const ByteStream&) = delete; - inline ByteStream(ByteStream&& stream); + ByteStream(ByteStream&& stream) noexcept = default; virtual ~ByteStream(); inline Endianness GetDataEndianness() const; @@ -50,7 +50,7 @@ namespace Nz ByteStream& operator<<(const T& value); ByteStream& operator=(const ByteStream&) = delete; - inline ByteStream& operator=(ByteStream&&); + ByteStream& operator=(ByteStream&&) noexcept = default; private: virtual void OnEmptyStream(); diff --git a/include/Nazara/Core/ByteStream.inl b/include/Nazara/Core/ByteStream.inl index afd9f1fd3..b0c4c8233 100644 --- a/include/Nazara/Core/ByteStream.inl +++ b/include/Nazara/Core/ByteStream.inl @@ -16,19 +16,6 @@ namespace Nz m_context.stream = stream; } - /*! - * \brief Constructs a ByteStream object by move semantic - * - * \param stream ByteStream to move into this - */ - - inline ByteStream::ByteStream(ByteStream&& stream) : - m_ownedStream(std::move(stream.m_ownedStream)), - m_context(stream.m_context) - { - stream.m_context.stream = nullptr; - } - /*! * \brief Destructs the object and calls FlushBits * @@ -204,23 +191,6 @@ namespace Nz return *this; } - - /*! - * \brief Moves the other byte stream into this - * \return A reference to this - * - * \param stream ByteStream to move in this - */ - - inline ByteStream& ByteStream::operator=(ByteStream&& stream) - { - m_context = stream.m_context; - m_ownedStream = std::move(stream.m_ownedStream); - - stream.m_context.stream = nullptr; - - return *this; - } } #include diff --git a/include/Nazara/Core/CallOnExit.hpp b/include/Nazara/Core/CallOnExit.hpp index 3b38a3fb2..c4d90e171 100644 --- a/include/Nazara/Core/CallOnExit.hpp +++ b/include/Nazara/Core/CallOnExit.hpp @@ -19,14 +19,14 @@ namespace Nz public: CallOnExit(Func func = nullptr); CallOnExit(const CallOnExit&) = delete; - CallOnExit(CallOnExit&&) = delete; + CallOnExit(CallOnExit&&) noexcept = delete; ~CallOnExit(); void CallAndReset(Func func = nullptr); void Reset(Func func = nullptr); CallOnExit& operator=(const CallOnExit&) = delete; - CallOnExit& operator=(CallOnExit&&) = default; + CallOnExit& operator=(CallOnExit&&) noexcept = default; private: Func m_func; diff --git a/include/Nazara/Core/FileLogger.hpp b/include/Nazara/Core/FileLogger.hpp index 8f4e4fb60..c722b3290 100644 --- a/include/Nazara/Core/FileLogger.hpp +++ b/include/Nazara/Core/FileLogger.hpp @@ -19,7 +19,7 @@ namespace Nz public: FileLogger(const String& logPath = "NazaraLog.log"); FileLogger(const FileLogger&) = default; - FileLogger(FileLogger&&) = default; + FileLogger(FileLogger&&) noexcept = default; ~FileLogger(); void EnableTimeLogging(bool enable); @@ -32,7 +32,7 @@ namespace Nz void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override; FileLogger& operator=(const FileLogger&) = default; - FileLogger& operator=(FileLogger&&) = default; + FileLogger& operator=(FileLogger&&) noexcept = default; private: File m_outputFile; diff --git a/include/Nazara/Core/GuillotineBinPack.hpp b/include/Nazara/Core/GuillotineBinPack.hpp index d9f2590a5..8c82bb5d5 100644 --- a/include/Nazara/Core/GuillotineBinPack.hpp +++ b/include/Nazara/Core/GuillotineBinPack.hpp @@ -26,7 +26,7 @@ namespace Nz GuillotineBinPack(unsigned int width, unsigned int height); GuillotineBinPack(const Vector2ui& size); GuillotineBinPack(const GuillotineBinPack&) = default; - GuillotineBinPack(GuillotineBinPack&&) = default; + GuillotineBinPack(GuillotineBinPack&&) noexcept = default; ~GuillotineBinPack() = default; void Clear(); @@ -52,7 +52,7 @@ namespace Nz void Reset(const Vector2ui& size); GuillotineBinPack& operator=(const GuillotineBinPack&) = default; - GuillotineBinPack& operator=(GuillotineBinPack&&) = default; + GuillotineBinPack& operator=(GuillotineBinPack&&) noexcept = default; enum FreeRectChoiceHeuristic : int { diff --git a/include/Nazara/Core/MemoryStream.hpp b/include/Nazara/Core/MemoryStream.hpp index fed53fe3b..808b410c8 100644 --- a/include/Nazara/Core/MemoryStream.hpp +++ b/include/Nazara/Core/MemoryStream.hpp @@ -8,6 +8,7 @@ #define NAZARA_MEMORYSTREAM_HPP #include +#include #include namespace Nz @@ -20,7 +21,7 @@ namespace Nz inline MemoryStream(); inline MemoryStream(ByteArray* byteArray, OpenModeFlags openMode = OpenMode_ReadWrite); MemoryStream(const MemoryStream&) = default; - MemoryStream(MemoryStream&&) = default; + MemoryStream(MemoryStream&&) noexcept = default; ~MemoryStream() = default; void Clear(); @@ -36,14 +37,14 @@ namespace Nz bool SetCursorPos(UInt64 offset) override; MemoryStream& operator=(const MemoryStream&) = default; - MemoryStream& operator=(MemoryStream&&) = default; + MemoryStream& operator=(MemoryStream&&) noexcept = default; private: void FlushStream() override; std::size_t ReadBlock(void* buffer, std::size_t size) override; std::size_t WriteBlock(const void* buffer, std::size_t size) override; - ByteArray* m_buffer; + MovablePtr m_buffer; UInt64 m_pos; }; } diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index bc0d33a81..4dba23207 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -72,7 +73,7 @@ namespace Nz std::atomic_uint counter; Destructor destructor; - void* ptr; + MovablePtr ptr; }; ParameterType type; @@ -81,6 +82,7 @@ namespace Nz // We define an empty constructor/destructor, to be able to put classes in the union Value() {} Value(const Value&) {} // Placeholder + Value(Value&&) noexcept {} // Placeholder ~Value() {} bool boolVal; diff --git a/include/Nazara/Core/PrimitiveList.hpp b/include/Nazara/Core/PrimitiveList.hpp index 98c132279..34014de47 100644 --- a/include/Nazara/Core/PrimitiveList.hpp +++ b/include/Nazara/Core/PrimitiveList.hpp @@ -19,7 +19,7 @@ namespace Nz public: PrimitiveList() = default; PrimitiveList(const PrimitiveList&) = default; - PrimitiveList(PrimitiveList&&) = default; + PrimitiveList(PrimitiveList&&) noexcept = default; ~PrimitiveList() = default; void AddBox(const Vector3f& lengths, const Vector3ui& subdivision = Vector3ui(0U), const Matrix4f& transformMatrix = Matrix4f::Identity()); @@ -41,7 +41,7 @@ namespace Nz std::size_t GetSize() const; PrimitiveList& operator=(const PrimitiveList&) = default; - PrimitiveList& operator=(PrimitiveList&&) = default; + PrimitiveList& operator=(PrimitiveList&&) noexcept = default; Primitive& operator()(unsigned int i); const Primitive& operator()(unsigned int i) const; diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index 421da4c0e..d348d9280 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -23,7 +23,7 @@ namespace Nz public: RefCounted(bool persistent = true); RefCounted(const RefCounted&) = delete; - RefCounted(RefCounted&&) = default; + RefCounted(RefCounted&&) = delete; virtual ~RefCounted(); void AddReference() const; @@ -37,7 +37,7 @@ namespace Nz bool SetPersistent(bool persistent = true, bool checkReferenceCount = false); RefCounted& operator=(const RefCounted&) = delete; - RefCounted& operator=(RefCounted&&) = default; + RefCounted& operator=(RefCounted&&) = delete; private: std::atomic_bool m_persistent; diff --git a/include/Nazara/Core/SerializationContext.hpp b/include/Nazara/Core/SerializationContext.hpp index 4111f7a7b..122fc41dc 100644 --- a/include/Nazara/Core/SerializationContext.hpp +++ b/include/Nazara/Core/SerializationContext.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace Nz @@ -18,7 +19,7 @@ namespace Nz struct NAZARA_CORE_API SerializationContext { - Stream* stream; + MovablePtr stream; Endianness endianness = Endianness_BigEndian; //< Default to Big Endian encoding UInt8 readBitPos = 8; //< 8 means no bit is currently read UInt8 readByte; //< Undefined value, will be initialized at the first bit read diff --git a/include/Nazara/Core/StdLogger.hpp b/include/Nazara/Core/StdLogger.hpp index 998ec7b53..5330d22ab 100644 --- a/include/Nazara/Core/StdLogger.hpp +++ b/include/Nazara/Core/StdLogger.hpp @@ -17,7 +17,7 @@ namespace Nz public: StdLogger() = default; StdLogger(const StdLogger&) = default; - StdLogger(StdLogger&&) = default; + StdLogger(StdLogger&&) noexcept = default; ~StdLogger(); void EnableStdReplication(bool enable) override; @@ -28,7 +28,7 @@ namespace Nz void WriteError(ErrorType type, const String& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override; StdLogger& operator=(const StdLogger&) = default; - StdLogger& operator=(StdLogger&&) = default; + StdLogger& operator=(StdLogger&&) noexcept = default; }; } diff --git a/include/Nazara/Core/Stream.hpp b/include/Nazara/Core/Stream.hpp index 2c140c144..a1f86e12e 100644 --- a/include/Nazara/Core/Stream.hpp +++ b/include/Nazara/Core/Stream.hpp @@ -20,7 +20,7 @@ namespace Nz { public: Stream(const Stream&) = default; - Stream(Stream&&) = default; + Stream(Stream&&) noexcept = default; virtual ~Stream(); virtual bool EndOfStream() const = 0; @@ -52,7 +52,7 @@ namespace Nz inline std::size_t Write(const void* buffer, std::size_t size); Stream& operator=(const Stream&) = default; - Stream& operator=(Stream&&) = default; + Stream& operator=(Stream&&) noexcept = default; protected: inline Stream(StreamOptionFlags streamOptions = StreamOption_None, OpenModeFlags openMode = OpenMode_NotOpen); diff --git a/include/Nazara/Graphics/AbstractRenderQueue.hpp b/include/Nazara/Graphics/AbstractRenderQueue.hpp index f4d268786..341d61607 100644 --- a/include/Nazara/Graphics/AbstractRenderQueue.hpp +++ b/include/Nazara/Graphics/AbstractRenderQueue.hpp @@ -32,7 +32,7 @@ namespace Nz AbstractRenderQueue() = default; AbstractRenderQueue(const AbstractRenderQueue&) = delete; - AbstractRenderQueue(AbstractRenderQueue&&) = default; + AbstractRenderQueue(AbstractRenderQueue&&) noexcept = default; virtual ~AbstractRenderQueue(); // Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards, @@ -55,7 +55,7 @@ namespace Nz virtual void Clear(bool fully = false); AbstractRenderQueue& operator=(const AbstractRenderQueue&) = delete; - AbstractRenderQueue& operator=(AbstractRenderQueue&&) = default; + AbstractRenderQueue& operator=(AbstractRenderQueue&&) noexcept = default; struct DirectionalLight { diff --git a/include/Nazara/Graphics/AbstractRenderTechnique.hpp b/include/Nazara/Graphics/AbstractRenderTechnique.hpp index 0897c5312..ede4225f7 100644 --- a/include/Nazara/Graphics/AbstractRenderTechnique.hpp +++ b/include/Nazara/Graphics/AbstractRenderTechnique.hpp @@ -22,7 +22,7 @@ namespace Nz public: AbstractRenderTechnique(); AbstractRenderTechnique(const AbstractRenderTechnique&) = delete; - AbstractRenderTechnique(AbstractRenderTechnique&&) = default; + AbstractRenderTechnique(AbstractRenderTechnique&&) noexcept = default; virtual ~AbstractRenderTechnique(); virtual void Clear(const SceneData& sceneData) const = 0; @@ -37,7 +37,7 @@ namespace Nz virtual bool IsInstancingEnabled() const; AbstractRenderTechnique& operator=(const AbstractRenderTechnique&) = delete; - AbstractRenderTechnique& operator=(AbstractRenderTechnique&&) = default; + AbstractRenderTechnique& operator=(AbstractRenderTechnique&&) noexcept = default; protected: bool m_instancingEnabled; diff --git a/include/Nazara/Graphics/RenderQueue.hpp b/include/Nazara/Graphics/RenderQueue.hpp index 8ddb725ca..0d1f1fb81 100644 --- a/include/Nazara/Graphics/RenderQueue.hpp +++ b/include/Nazara/Graphics/RenderQueue.hpp @@ -19,8 +19,13 @@ namespace Nz using Index = Nz::UInt64; RenderQueueInternal() = default; + RenderQueueInternal(const RenderQueueInternal&) = default; + RenderQueueInternal(RenderQueueInternal&&) = default; ~RenderQueueInternal() = default; + RenderQueueInternal& operator=(const RenderQueueInternal&) = default; + RenderQueueInternal& operator=(RenderQueueInternal&&) = default; + protected: using RenderDataPair = std::pair; @@ -39,7 +44,7 @@ namespace Nz RenderQueue() = default; RenderQueue(const RenderQueue&) = default; - RenderQueue(RenderQueue&&) = default; + RenderQueue(RenderQueue&&) noexcept = default; ~RenderQueue() = default; void Clear(); @@ -55,7 +60,7 @@ namespace Nz inline size_type size() const; RenderQueue& operator=(const RenderQueue&) = default; - RenderQueue& operator=(RenderQueue&&) = default; + RenderQueue& operator=(RenderQueue&&) noexcept = default; private: const RenderData& GetData(std::size_t i) const; diff --git a/include/Nazara/Graphics/Renderable.hpp b/include/Nazara/Graphics/Renderable.hpp index 62cf861c6..22b76d423 100644 --- a/include/Nazara/Graphics/Renderable.hpp +++ b/include/Nazara/Graphics/Renderable.hpp @@ -21,7 +21,7 @@ namespace Nz public: Renderable() = default; Renderable(const Renderable& renderable) = default; - Renderable(Renderable&&) = default; + Renderable(Renderable&&) noexcept = default; virtual ~Renderable(); virtual void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const = 0; @@ -33,7 +33,7 @@ namespace Nz virtual void UpdateBoundingVolume(const Matrix4f& transformMatrix); Renderable& operator=(const Renderable& renderable) = default; - Renderable& operator=(Renderable&& renderable) = default; + Renderable& operator=(Renderable&& renderable) noexcept = default; protected: virtual void MakeBoundingVolume() const = 0; diff --git a/include/Nazara/Network/AbstractSocket.hpp b/include/Nazara/Network/AbstractSocket.hpp index 0af1c8b19..315364e8d 100644 --- a/include/Nazara/Network/AbstractSocket.hpp +++ b/include/Nazara/Network/AbstractSocket.hpp @@ -19,7 +19,7 @@ namespace Nz { public: AbstractSocket(const AbstractSocket&) = delete; - AbstractSocket(AbstractSocket&& abstractSocket); + AbstractSocket(AbstractSocket&& abstractSocket) noexcept; virtual ~AbstractSocket(); void Close(); diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index d6e1a8018..28a2d2da5 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -135,7 +135,7 @@ namespace Nz std::vector m_peers; std::vector m_pendingIncomingPackets; std::vector m_pendingOutgoingPackets; - UInt8* m_receivedData; + MovablePtr m_receivedData; Bitset m_dispatchQueue; MemoryPool m_packetPool; IpAddress m_address; diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index c1822e761..f2435f579 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -1,4 +1,4 @@ -/* +/* Copyright(c) 2002 - 2016 Lee Salzman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -176,8 +177,8 @@ namespace Nz static constexpr std::size_t unsequencedWindow = ENetPeer_ReliableWindowSize / 32; - ENetHost* m_host; - IpAddress m_address; /**< Internet address of the peer */ + MovablePtr m_host; + IpAddress m_address; //< Internet address of the peer std::array m_unsequencedWindow; std::bernoulli_distribution m_packetLossProbability; std::list m_dispatchedCommands; diff --git a/include/Nazara/Network/IpAddress.hpp b/include/Nazara/Network/IpAddress.hpp index 965ad924f..9ef8823e7 100644 --- a/include/Nazara/Network/IpAddress.hpp +++ b/include/Nazara/Network/IpAddress.hpp @@ -32,7 +32,7 @@ namespace Nz inline explicit IpAddress(const char* address); inline explicit IpAddress(const String& address); IpAddress(const IpAddress&) = default; - IpAddress(IpAddress&&) = default; + IpAddress(IpAddress&&) noexcept = default; ~IpAddress() = default; bool BuildFromAddress(const char* address); @@ -53,7 +53,7 @@ namespace Nz inline explicit operator bool() const; IpAddress& operator=(const IpAddress&) = default; - IpAddress& operator=(IpAddress&&) = default; + IpAddress& operator=(IpAddress&&) noexcept = default; static String ResolveAddress(const IpAddress& address, String* service = nullptr, ResolveError* error = nullptr); static std::vector ResolveHostname(NetProtocol procol, const String& hostname, const String& protocol = "http", ResolveError* error = nullptr); diff --git a/include/Nazara/Network/RUdpConnection.hpp b/include/Nazara/Network/RUdpConnection.hpp index 64a30c0b8..0740b4647 100644 --- a/include/Nazara/Network/RUdpConnection.hpp +++ b/include/Nazara/Network/RUdpConnection.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index 39ac2d9ac..43b299994 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -24,7 +24,7 @@ namespace Nz public: inline TcpClient(); - TcpClient(TcpClient&& tcpClient) = default; + TcpClient(TcpClient&& tcpClient) noexcept = default; ~TcpClient() = default; SocketState Connect(const IpAddress& remoteAddress); diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 0b7c8d4d9..47a3a3bbc 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -21,7 +21,7 @@ namespace Nz public: inline UdpSocket(); inline UdpSocket(NetProtocol protocol); - inline UdpSocket(UdpSocket&& udpSocket); + inline UdpSocket(UdpSocket&& udpSocket) noexcept; ~UdpSocket() = default; inline SocketState Bind(UInt16 port); diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index ed43b3428..1879c1a8a 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -33,7 +33,7 @@ namespace Nz * \param udpSocket UdpSocket to move into this */ - inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) : + inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) noexcept : AbstractSocket(std::move(udpSocket)), m_boundAddress(std::move(udpSocket.m_boundAddress)) { diff --git a/include/Nazara/Physics3D/PhysWorld3D.hpp b/include/Nazara/Physics3D/PhysWorld3D.hpp index e32ba2528..223fce4fe 100644 --- a/include/Nazara/Physics3D/PhysWorld3D.hpp +++ b/include/Nazara/Physics3D/PhysWorld3D.hpp @@ -33,7 +33,7 @@ namespace Nz PhysWorld3D(); PhysWorld3D(const PhysWorld3D&) = delete; - PhysWorld3D(PhysWorld3D&&) = default; + PhysWorld3D(PhysWorld3D&&) noexcept = default; ~PhysWorld3D(); int CreateMaterial(String name = String()); @@ -61,7 +61,7 @@ namespace Nz void Step(float timestep); PhysWorld3D& operator=(const PhysWorld3D&) = delete; - PhysWorld3D& operator=(PhysWorld3D&&) = default; + PhysWorld3D& operator=(PhysWorld3D&&) noexcept = default; private: struct Callback diff --git a/include/Nazara/Platform/CursorController.hpp b/include/Nazara/Platform/CursorController.hpp index 8c4f8ed15..d27384d18 100644 --- a/include/Nazara/Platform/CursorController.hpp +++ b/include/Nazara/Platform/CursorController.hpp @@ -25,13 +25,13 @@ namespace Nz public: CursorController() = default; CursorController(const CursorController&) = delete; - CursorController(CursorController&&) = default; + CursorController(CursorController&&) noexcept = default; ~CursorController() = default; inline void UpdateCursor(const CursorRef& cursor); CursorController& operator=(const CursorController&) = delete; - CursorController& operator=(CursorController&&) = default; + CursorController& operator=(CursorController&&) noexcept = default; NazaraSignal(OnCursorUpdated, const CursorController* /*cursorController*/, const CursorRef& /*cursor*/); }; diff --git a/include/Nazara/Platform/EventHandler.hpp b/include/Nazara/Platform/EventHandler.hpp index 5aa12bae5..7404a26d6 100644 --- a/include/Nazara/Platform/EventHandler.hpp +++ b/include/Nazara/Platform/EventHandler.hpp @@ -25,13 +25,13 @@ namespace Nz public: EventHandler() = default; explicit EventHandler(const EventHandler&); - EventHandler(EventHandler&&) = default; + EventHandler(EventHandler&&) noexcept = default; ~EventHandler() = default; inline void Dispatch(const WindowEvent& event); EventHandler& operator=(const EventHandler&) = delete; - EventHandler& operator=(EventHandler&&) = default; + EventHandler& operator=(EventHandler&&) noexcept = default; NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/); NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/); diff --git a/include/Nazara/Utility/Buffer.hpp b/include/Nazara/Utility/Buffer.hpp index 1b7709efb..e125c63e9 100644 --- a/include/Nazara/Utility/Buffer.hpp +++ b/include/Nazara/Utility/Buffer.hpp @@ -33,7 +33,7 @@ namespace Nz Buffer(BufferType type); Buffer(BufferType type, UInt32 size, DataStorage storage = DataStorage_Software, BufferUsageFlags usage = 0); Buffer(const Buffer&) = delete; - Buffer(Buffer&&) = default; + Buffer(Buffer&&) = delete; ~Buffer(); bool CopyContent(const BufferRef& buffer); @@ -61,7 +61,7 @@ namespace Nz void Unmap() const; Buffer& operator=(const Buffer&) = delete; - Buffer& operator=(Buffer&&) = default; + Buffer& operator=(Buffer&&) = delete; static bool IsStorageSupported(DataStorage storage); template static BufferRef New(Args&&... args); diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index 879589cd6..64bdd0e0d 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -45,7 +45,7 @@ namespace Nz * \param abstractSocket AbstractSocket to move into this */ - AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) : + AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) noexcept : m_protocol(abstractSocket.m_protocol), m_lastError(abstractSocket.m_lastError), m_handle(abstractSocket.m_handle), diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 5eb8d5862..5744b8743 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -489,7 +489,7 @@ namespace Nz if (m_receivedDataLength < NazaraOffsetOf(ENetProtocolHeader, sentTime)) return false; - ENetProtocolHeader* header = reinterpret_cast(m_receivedData); + ENetProtocolHeader* header = reinterpret_cast(m_receivedData.Get()); UInt16 peerID = NetToHost(header->peerID); UInt8 sessionID = (peerID & ENetProtocolHeaderSessionMask) >> ENetProtocolHeaderSessionShift;