From e294090c8efe428133e904ceec428b0dac9e3e5a Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 12 Sep 2022 14:17:27 -0600 Subject: [PATCH] Replace `sf::Uint32` with `std::uint32_t` --- examples/vulkan/Vulkan.cpp | 68 +++++++++---------- include/SFML/Config.hpp | 3 - include/SFML/Graphics/Color.hpp | 4 +- include/SFML/Graphics/Color.inl | 6 +- include/SFML/Graphics/Font.hpp | 8 +-- include/SFML/Graphics/RenderWindow.hpp | 2 +- include/SFML/Graphics/Text.hpp | 6 +- include/SFML/Network/IpAddress.hpp | 6 +- include/SFML/Network/Packet.hpp | 8 +-- include/SFML/Network/TcpSocket.hpp | 2 +- include/SFML/System/String.hpp | 24 +++---- include/SFML/System/Utf.hpp | 20 +++--- include/SFML/System/Utf.inl | 68 +++++++++---------- include/SFML/Window/ContextSettings.hpp | 14 ++-- include/SFML/Window/Event.hpp | 2 +- include/SFML/Window/Window.hpp | 6 +- include/SFML/Window/WindowBase.hpp | 4 +- src/SFML/Audio/SoundFileReaderWav.cpp | 20 +++--- src/SFML/Audio/SoundFileWriterWav.cpp | 12 ++-- src/SFML/Audio/SoundStream.cpp | 2 +- src/SFML/Graphics/Font.cpp | 12 ++-- src/SFML/Graphics/RenderTarget.cpp | 4 +- src/SFML/Graphics/RenderWindow.cpp | 2 +- src/SFML/Graphics/Text.cpp | 22 +++--- src/SFML/Network/IpAddress.cpp | 8 +-- src/SFML/Network/Packet.cpp | 52 +++++++------- src/SFML/Network/TcpSocket.cpp | 6 +- src/SFML/Network/Unix/SocketImpl.cpp | 2 +- src/SFML/Network/Unix/SocketImpl.hpp | 2 +- src/SFML/Network/Win32/SocketImpl.cpp | 2 +- src/SFML/Network/Win32/SocketImpl.hpp | 2 +- src/SFML/System/String.cpp | 16 ++--- src/SFML/Window/Android/WindowImplAndroid.cpp | 14 ++-- src/SFML/Window/DRM/DRMContext.cpp | 2 +- src/SFML/Window/GlContext.cpp | 2 +- src/SFML/Window/OSX/cpp_objc_conversion.mm | 4 +- src/SFML/Window/Unix/CursorImpl.cpp | 2 +- src/SFML/Window/Unix/VulkanImplX11.cpp | 2 +- src/SFML/Window/Unix/WindowImplX11.cpp | 4 +- src/SFML/Window/Win32/CursorImpl.cpp | 6 +- src/SFML/Window/Win32/VulkanImplWin32.cpp | 2 +- src/SFML/Window/Win32/WindowImplWin32.cpp | 4 +- src/SFML/Window/Win32/WindowImplWin32.hpp | 2 +- src/SFML/Window/Window.cpp | 10 +-- src/SFML/Window/WindowBase.cpp | 8 +-- src/SFML/Window/WindowImpl.cpp | 2 +- src/SFML/Window/WindowImpl.hpp | 5 +- src/SFML/Window/iOS/SFAppDelegate.hpp | 2 +- src/SFML/Window/iOS/SFAppDelegate.mm | 2 +- src/SFML/Window/iOS/SFView.mm | 2 +- test/Graphics/Image.cpp | 40 +++++------ test/Network/IpAddress.cpp | 2 +- test/System/Config.cpp | 2 - 53 files changed, 266 insertions(+), 268 deletions(-) diff --git a/examples/vulkan/Vulkan.cpp b/examples/vulkan/Vulkan.cpp index 42bb247cd..66c836559 100644 --- a/examples/vulkan/Vulkan.cpp +++ b/examples/vulkan/Vulkan.cpp @@ -396,7 +396,7 @@ public: vkWaitForFences(device, 1, &fence, VK_TRUE, std::numeric_limits::max()); if (commandBuffers.size()) - vkFreeCommandBuffers(device, commandPool, static_cast(commandBuffers.size()), commandBuffers.data()); + vkFreeCommandBuffers(device, commandPool, static_cast(commandBuffers.size()), commandBuffers.data()); commandBuffers.clear(); @@ -477,7 +477,7 @@ public: } // Retrieve the available instance layers - uint32_t objectCount = 0; + std::uint32_t objectCount = 0; std::vector layers; @@ -537,9 +537,9 @@ public: VkInstanceCreateInfo instanceCreateInfo = VkInstanceCreateInfo(); instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; instanceCreateInfo.pApplicationInfo = &applicationInfo; - instanceCreateInfo.enabledLayerCount = static_cast(validationLayers.size()); + instanceCreateInfo.enabledLayerCount = static_cast(validationLayers.size()); instanceCreateInfo.ppEnabledLayerNames = validationLayers.data(); - instanceCreateInfo.enabledExtensionCount = static_cast(requiredExtentions.size()); + instanceCreateInfo.enabledExtensionCount = static_cast(requiredExtentions.size()); instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data(); // Try to create a Vulkan instance with debug report enabled @@ -550,7 +550,7 @@ public: { requiredExtentions.pop_back(); - instanceCreateInfo.enabledExtensionCount = static_cast(requiredExtentions.size()); + instanceCreateInfo.enabledExtensionCount = static_cast(requiredExtentions.size()); instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data(); result = vkCreateInstance(&instanceCreateInfo, 0, &instance); @@ -607,7 +607,7 @@ public: } // Retrieve list of GPUs - uint32_t objectCount = 0; + std::uint32_t objectCount = 0; std::vector devices; @@ -720,7 +720,7 @@ public: void setupLogicalDevice() { // Select a queue family that supports graphics operations and surface presentation - uint32_t objectCount = 0; + std::uint32_t objectCount = 0; std::vector queueFamilyProperties; @@ -734,7 +734,7 @@ public: { VkBool32 surfaceSupported = VK_FALSE; - vkGetPhysicalDeviceSurfaceSupportKHR(gpu, static_cast(i), surface, &surfaceSupported); + vkGetPhysicalDeviceSurfaceSupportKHR(gpu, static_cast(i), surface, &surfaceSupported); if ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) && (surfaceSupported == VK_TRUE)) { @@ -754,7 +754,7 @@ public: VkDeviceQueueCreateInfo deviceQueueCreateInfo = VkDeviceQueueCreateInfo(); deviceQueueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; deviceQueueCreateInfo.queueCount = 1; - deviceQueueCreateInfo.queueFamilyIndex = static_cast(queueFamilyIndex); + deviceQueueCreateInfo.queueFamilyIndex = static_cast(queueFamilyIndex); deviceQueueCreateInfo.pQueuePriorities = &queuePriority; // Enable the swapchain extension @@ -780,14 +780,14 @@ public: } // Retrieve a handle to the logical device command queue - vkGetDeviceQueue(device, static_cast(queueFamilyIndex), 0, &queue); + vkGetDeviceQueue(device, static_cast(queueFamilyIndex), 0, &queue); } // Query surface formats and set up swapchain void setupSwapchain() { // Select a surface format that supports RGBA color format - uint32_t objectCount = 0; + std::uint32_t objectCount = 0; std::vector surfaceFormats; @@ -871,14 +871,14 @@ public: return; } - swapchainExtent.width = clamp(window.getSize().x, - surfaceCapabilities.minImageExtent.width, - surfaceCapabilities.maxImageExtent.width); - swapchainExtent.height = clamp(window.getSize().y, - surfaceCapabilities.minImageExtent.height, - surfaceCapabilities.maxImageExtent.height); + swapchainExtent.width = clamp(window.getSize().x, + surfaceCapabilities.minImageExtent.width, + surfaceCapabilities.maxImageExtent.width); + swapchainExtent.height = clamp(window.getSize().y, + surfaceCapabilities.minImageExtent.height, + surfaceCapabilities.maxImageExtent.height); - auto imageCount = clamp(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount); + auto imageCount = clamp(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount); VkSwapchainCreateInfoKHR swapchainCreateInfo = VkSwapchainCreateInfoKHR(); swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; @@ -908,7 +908,7 @@ public: void setupSwapchainImages() { // Retrieve swapchain images - uint32_t objectCount = 0; + std::uint32_t objectCount = 0; if (vkGetSwapchainImagesKHR(device, swapchain, &objectCount, 0) != VK_SUCCESS) { @@ -968,7 +968,7 @@ public: return; } - std::vector buffer(static_cast(file.getSize()) / sizeof(uint32_t)); + std::vector buffer(static_cast(file.getSize()) / sizeof(std::uint32_t)); if (file.read(buffer.data(), file.getSize()) != file.getSize()) { @@ -976,7 +976,7 @@ public: return; } - shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(uint32_t); + shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(std::uint32_t); shaderModuleCreateInfo.pCode = buffer.data(); if (vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &vertexShaderModule) != VK_SUCCESS) @@ -996,7 +996,7 @@ public: return; } - std::vector buffer(static_cast(file.getSize()) / sizeof(uint32_t)); + std::vector buffer(static_cast(file.getSize()) / sizeof(std::uint32_t)); if (file.read(buffer.data(), file.getSize()) != file.getSize()) { @@ -1004,7 +1004,7 @@ public: return; } - shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(uint32_t); + shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(std::uint32_t); shaderModuleCreateInfo.pCode = buffer.data(); if (vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &fragmentShaderModule) != VK_SUCCESS) @@ -1314,7 +1314,7 @@ public: // We want to be able to reset command buffers after submitting them VkCommandPoolCreateInfo commandPoolCreateInfo = VkCommandPoolCreateInfo(); commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - commandPoolCreateInfo.queueFamilyIndex = static_cast(queueFamilyIndex); + commandPoolCreateInfo.queueFamilyIndex = static_cast(queueFamilyIndex); commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; // Create our command pool @@ -1351,7 +1351,7 @@ public: VkPhysicalDeviceMemoryProperties memoryProperties = VkPhysicalDeviceMemoryProperties(); vkGetPhysicalDeviceMemoryProperties(gpu, &memoryProperties); - uint32_t memoryType = 0; + std::uint32_t memoryType = 0; for (; memoryType < memoryProperties.memoryTypeCount; ++memoryType) { @@ -1637,8 +1637,8 @@ public: } // Helper to create a generic image with the specified size, format, usage and memory flags - bool createImage(uint32_t width, - uint32_t height, + bool createImage(std::uint32_t width, + std::uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, @@ -1674,7 +1674,7 @@ public: VkPhysicalDeviceMemoryProperties memoryProperties = VkPhysicalDeviceMemoryProperties(); vkGetPhysicalDeviceMemoryProperties(gpu, &memoryProperties); - uint32_t memoryType = 0; + std::uint32_t memoryType = 0; for (; memoryType < memoryProperties.memoryTypeCount; ++memoryType) { @@ -2179,17 +2179,17 @@ public: descriptorPoolSizes[0] = VkDescriptorPoolSize(); descriptorPoolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - descriptorPoolSizes[0].descriptorCount = static_cast(swapchainImages.size()); + descriptorPoolSizes[0].descriptorCount = static_cast(swapchainImages.size()); descriptorPoolSizes[1] = VkDescriptorPoolSize(); descriptorPoolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - descriptorPoolSizes[1].descriptorCount = static_cast(swapchainImages.size()); + descriptorPoolSizes[1].descriptorCount = static_cast(swapchainImages.size()); VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = VkDescriptorPoolCreateInfo(); descriptorPoolCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; descriptorPoolCreateInfo.poolSizeCount = 2; descriptorPoolCreateInfo.pPoolSizes = descriptorPoolSizes; - descriptorPoolCreateInfo.maxSets = static_cast(swapchainImages.size()); + descriptorPoolCreateInfo.maxSets = static_cast(swapchainImages.size()); // Create the descriptor pool if (vkCreateDescriptorPool(device, &descriptorPoolCreateInfo, 0, &descriptorPool) != VK_SUCCESS) @@ -2208,7 +2208,7 @@ public: VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = VkDescriptorSetAllocateInfo(); descriptorSetAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; descriptorSetAllocateInfo.descriptorPool = descriptorPool; - descriptorSetAllocateInfo.descriptorSetCount = static_cast(swapchainImages.size()); + descriptorSetAllocateInfo.descriptorSetCount = static_cast(swapchainImages.size()); descriptorSetAllocateInfo.pSetLayouts = descriptorSetLayouts.data(); descriptorSets.resize(swapchainImages.size()); @@ -2272,7 +2272,7 @@ public: commandBufferAllocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; commandBufferAllocateInfo.commandPool = commandPool; commandBufferAllocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; - commandBufferAllocateInfo.commandBufferCount = static_cast(commandBuffers.size()); + commandBufferAllocateInfo.commandBufferCount = static_cast(commandBuffers.size()); // Allocate the command buffers from our command pool if (vkAllocateCommandBuffers(device, &commandBufferAllocateInfo, commandBuffers.data()) != VK_SUCCESS) @@ -2480,7 +2480,7 @@ public: void draw() { - uint32_t imageIndex = 0; + std::uint32_t imageIndex = 0; // If the objects we need to submit this frame are still pending, wait here vkWaitForFences(device, 1, &fences[currentFrame], VK_TRUE, std::numeric_limits::max()); diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index b5c93f6fd..9cc833b8f 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -167,9 +167,6 @@ //////////////////////////////////////////////////////////// namespace sf { -// 32 bits integer types -using Uint32 = std::uint32_t; - // 64 bits integer types using Int64 = std::int64_t; using Uint64 = std::uint64_t; diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp index ed3670d93..04b5f438f 100644 --- a/include/SFML/Graphics/Color.hpp +++ b/include/SFML/Graphics/Color.hpp @@ -66,7 +66,7 @@ public: /// \param color Number containing the RGBA components (in that order) /// //////////////////////////////////////////////////////////// - constexpr explicit Color(Uint32 color); + constexpr explicit Color(std::uint32_t color); //////////////////////////////////////////////////////////// /// \brief Retrieve the color as a 32-bit unsigned integer @@ -74,7 +74,7 @@ public: /// \return Color represented as a 32-bit unsigned integer /// //////////////////////////////////////////////////////////// - constexpr Uint32 toInteger() const; + constexpr std::uint32_t toInteger() const; //////////////////////////////////////////////////////////// // Static member data diff --git a/include/SFML/Graphics/Color.inl b/include/SFML/Graphics/Color.inl index 50abb81b7..4e6d25468 100644 --- a/include/SFML/Graphics/Color.inl +++ b/include/SFML/Graphics/Color.inl @@ -40,7 +40,7 @@ a(alpha) //////////////////////////////////////////////////////////// -constexpr Color::Color(Uint32 color) : +constexpr Color::Color(std::uint32_t color) : r(static_cast((color & 0xff000000) >> 24)), g(static_cast((color & 0x00ff0000) >> 16)), b(static_cast((color & 0x0000ff00) >> 8)), @@ -50,9 +50,9 @@ a(static_cast(color & 0x000000ff)) //////////////////////////////////////////////////////////// -constexpr Uint32 Color::toInteger() const +constexpr std::uint32_t Color::toInteger() const { - return static_cast((r << 24) | (g << 16) | (b << 8) | a); + return static_cast((r << 24) | (g << 16) | (b << 8) | a); } diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index 8849a6715..2b90f4501 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -199,7 +199,7 @@ public: /// \return The glyph corresponding to \a codePoint and \a characterSize /// //////////////////////////////////////////////////////////// - const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness = 0) const; + const Glyph& getGlyph(std::uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness = 0) const; //////////////////////////////////////////////////////////// /// \brief Determine if this font has a glyph representing the requested code point @@ -217,7 +217,7 @@ public: /// \return True if the codepoint has a glyph representation, false otherwise /// //////////////////////////////////////////////////////////// - bool hasGlyph(Uint32 codePoint) const; + bool hasGlyph(std::uint32_t codePoint) const; //////////////////////////////////////////////////////////// /// \brief Get the kerning offset of two glyphs @@ -235,7 +235,7 @@ public: /// \return Kerning value for \a first and \a second, in pixels /// //////////////////////////////////////////////////////////// - float getKerning(Uint32 first, Uint32 second, unsigned int characterSize, bool bold = false) const; + float getKerning(std::uint32_t first, std::uint32_t second, unsigned int characterSize, bool bold = false) const; //////////////////////////////////////////////////////////// /// \brief Get the line spacing @@ -391,7 +391,7 @@ private: /// \return The glyph corresponding to \a codePoint and \a characterSize /// //////////////////////////////////////////////////////////// - Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const; + Glyph loadGlyph(std::uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) const; //////////////////////////////////////////////////////////// /// \brief Find a suitable rectangle within the texture for a glyph diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp index cda7749fa..79776bdae 100644 --- a/include/SFML/Graphics/RenderWindow.hpp +++ b/include/SFML/Graphics/RenderWindow.hpp @@ -73,7 +73,7 @@ public: //////////////////////////////////////////////////////////// RenderWindow(VideoMode mode, const String& title, - Uint32 style = Style::Default, + std::uint32_t style = Style::Default, const ContextSettings& settings = ContextSettings()); //////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index 20ed716b3..5a3a18507 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -215,7 +215,7 @@ public: /// \see getStyle /// //////////////////////////////////////////////////////////// - void setStyle(Uint32 style); + void setStyle(std::uint32_t style); //////////////////////////////////////////////////////////// /// \brief Set the fill color of the text @@ -329,7 +329,7 @@ public: /// \see setStyle /// //////////////////////////////////////////////////////////// - Uint32 getStyle() const; + std::uint32_t getStyle() const; //////////////////////////////////////////////////////////// /// \brief Get the fill color of the text @@ -433,7 +433,7 @@ private: unsigned int m_characterSize; //!< Base size of characters, in pixels float m_letterSpacingFactor; //!< Spacing factor between letters float m_lineSpacingFactor; //!< Spacing factor between lines - Uint32 m_style; //!< Text style (see Style enum) + std::uint32_t m_style; //!< Text style (see Style enum) Color m_fillColor; //!< Text fill color Color m_outlineColor; //!< Text outline color float m_outlineThickness; //!< Thickness of the text's outline diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp index 62839bb93..385174551 100644 --- a/include/SFML/Network/IpAddress.hpp +++ b/include/SFML/Network/IpAddress.hpp @@ -86,7 +86,7 @@ public: /// \see toInteger /// //////////////////////////////////////////////////////////// - explicit IpAddress(Uint32 address); + explicit IpAddress(std::uint32_t address); //////////////////////////////////////////////////////////// /// \brief Get a string representation of the address @@ -116,7 +116,7 @@ public: /// \see toString /// //////////////////////////////////////////////////////////// - Uint32 toInteger() const; + std::uint32_t toInteger() const; //////////////////////////////////////////////////////////// /// \brief Get the computer's local address @@ -171,7 +171,7 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - Uint32 m_address; //!< Address stored as an unsigned 32 bits integer + std::uint32_t m_address; //!< Address stored as an unsigned 32 bits integer }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index ee118f5d1..93346b84a 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -238,7 +238,7 @@ public: //////////////////////////////////////////////////////////// /// \overload //////////////////////////////////////////////////////////// - Packet& operator>>(Uint32& data); + Packet& operator>>(std::uint32_t& data); //////////////////////////////////////////////////////////// /// \overload @@ -319,7 +319,7 @@ public: //////////////////////////////////////////////////////////// /// \overload //////////////////////////////////////////////////////////// - Packet& operator<<(Uint32 data); + Packet& operator<<(std::uint32_t data); //////////////////////////////////////////////////////////// /// \overload @@ -468,7 +468,7 @@ private: /// /// Usage example: /// \code -/// sf::Uint32 x = 24; +/// std::uint32_t x = 24; /// std::string s = "hello"; /// double d = 5.89; /// @@ -486,7 +486,7 @@ private: /// socket.receive(packet); /// /// // Extract the variables contained in the packet -/// sf::Uint32 x; +/// std::uint32_t x; /// std::string s; /// double d; /// if (packet >> x >> s >> d) diff --git a/include/SFML/Network/TcpSocket.hpp b/include/SFML/Network/TcpSocket.hpp index 1241a7cd6..fec233614 100644 --- a/include/SFML/Network/TcpSocket.hpp +++ b/include/SFML/Network/TcpSocket.hpp @@ -221,7 +221,7 @@ private: { PendingPacket(); - Uint32 Size; //!< Data of packet size + std::uint32_t Size; //!< Data of packet size std::size_t SizeReceived; //!< Number of size bytes received so far std::vector Data; //!< Data of the packet }; diff --git a/include/SFML/System/String.hpp b/include/SFML/System/String.hpp index 809739369..cb3b4623f 100644 --- a/include/SFML/System/String.hpp +++ b/include/SFML/System/String.hpp @@ -50,8 +50,8 @@ public: //////////////////////////////////////////////////////////// // Types //////////////////////////////////////////////////////////// - using Iterator = std::basic_string::iterator; //!< Iterator type - using ConstIterator = std::basic_string::const_iterator; //!< Read-only iterator type + using Iterator = std::basic_string::iterator; //!< Iterator type + using ConstIterator = std::basic_string::const_iterator; //!< Read-only iterator type //////////////////////////////////////////////////////////// // Static member data @@ -92,7 +92,7 @@ public: /// \param utf32Char UTF-32 character to convert /// //////////////////////////////////////////////////////////// - String(Uint32 utf32Char); + String(std::uint32_t utf32Char); //////////////////////////////////////////////////////////// /// \brief Construct from a null-terminated C-style ANSI string and a locale @@ -140,7 +140,7 @@ public: /// \param utf32String UTF-32 string to assign /// //////////////////////////////////////////////////////////// - String(const Uint32* utf32String); + String(const std::uint32_t* utf32String); //////////////////////////////////////////////////////////// /// \brief Construct from an UTF-32 string @@ -148,7 +148,7 @@ public: /// \param utf32String UTF-32 string to assign /// //////////////////////////////////////////////////////////// - String(const std::basic_string& utf32String); + String(const std::basic_string& utf32String); //////////////////////////////////////////////////////////// /// \brief Copy constructor @@ -202,8 +202,8 @@ public: /// \brief Create a new sf::String from a UTF-32 encoded string /// /// This function is provided for consistency, it is equivalent to - /// using the constructors that takes a const sf::Uint32* or - /// a std::basic_string. + /// using the constructors that takes a const std::uint32_t* or + /// a std::basic_string. /// /// \param begin Forward iterator to the beginning of the UTF-32 sequence /// \param end Forward iterator to the end of the UTF-32 sequence @@ -309,7 +309,7 @@ public: /// \see toUtf8, toUtf16 /// //////////////////////////////////////////////////////////// - std::basic_string toUtf32() const; + std::basic_string toUtf32() const; //////////////////////////////////////////////////////////// /// \brief Overload of assignment operator @@ -342,7 +342,7 @@ public: /// \return Character at position \a index /// //////////////////////////////////////////////////////////// - Uint32 operator[](std::size_t index) const; + std::uint32_t operator[](std::size_t index) const; //////////////////////////////////////////////////////////// /// \brief Overload of [] operator to access a character by its position @@ -355,7 +355,7 @@ public: /// \return Reference to the character at position \a index /// //////////////////////////////////////////////////////////// - Uint32& operator[](std::size_t index); + std::uint32_t& operator[](std::size_t index); //////////////////////////////////////////////////////////// /// \brief Clear the string @@ -479,7 +479,7 @@ public: /// \return Read-only pointer to the array of characters /// //////////////////////////////////////////////////////////// - const Uint32* getData() const; + const std::uint32_t* getData() const; //////////////////////////////////////////////////////////// /// \brief Return an iterator to the beginning of the string @@ -536,7 +536,7 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - std::basic_string m_string; //!< Internal string of UTF-32 characters + std::basic_string m_string; //!< Internal string of UTF-32 characters }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/Utf.hpp b/include/SFML/System/Utf.hpp index 75b1e9c81..c07c59ccf 100644 --- a/include/SFML/System/Utf.hpp +++ b/include/SFML/System/Utf.hpp @@ -70,7 +70,7 @@ public: /// //////////////////////////////////////////////////////////// template - static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0); + static In decode(In begin, In end, std::uint32_t& output, std::uint32_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-8 character @@ -86,7 +86,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Out encode(Uint32 input, Out output, std::uint8_t replacement = 0); + static Out encode(std::uint32_t input, Out output, std::uint8_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-8 character @@ -276,7 +276,7 @@ public: /// //////////////////////////////////////////////////////////// template - static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0); + static In decode(In begin, In end, std::uint32_t& output, std::uint32_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-16 character @@ -292,7 +292,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Out encode(Uint32 input, Out output, std::uint16_t replacement = 0); + static Out encode(std::uint32_t input, Out output, std::uint16_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-16 character @@ -483,7 +483,7 @@ public: /// //////////////////////////////////////////////////////////// template - static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0); + static In decode(In begin, In end, std::uint32_t& output, std::uint32_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-32 character @@ -500,7 +500,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Out encode(Uint32 input, Out output, Uint32 replacement = 0); + static Out encode(std::uint32_t input, Out output, std::uint32_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-32 character @@ -679,7 +679,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Uint32 decodeAnsi(In input, const std::locale& locale = std::locale()); + static std::uint32_t decodeAnsi(In input, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Decode a single wide character to UTF-32 @@ -694,7 +694,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Uint32 decodeWide(In input); + static std::uint32_t decodeWide(In input); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-32 character to ANSI @@ -712,7 +712,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Out encodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale()); + static Out encodeAnsi(std::uint32_t codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-32 character to wide @@ -729,7 +729,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Out encodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0); + static Out encodeWide(std::uint32_t codepoint, Out output, wchar_t replacement = 0); }; #include diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index 929f96c9c..063981fb5 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -45,7 +45,7 @@ OutputIt priv::copy(InputIt first, InputIt last, OutputIt d_first) } template -In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) +In Utf<8>::decode(In begin, In end, std::uint32_t& output, std::uint32_t replacement) { // clang-format off // Some useful precomputed data @@ -61,7 +61,7 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; - static constexpr Uint32 offsets[6] = + static constexpr std::uint32_t offsets[6] = { 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080 }; @@ -100,7 +100,7 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) //////////////////////////////////////////////////////////// template -Out Utf<8>::encode(Uint32 input, Out output, std::uint8_t replacement) +Out Utf<8>::encode(std::uint32_t input, Out output, std::uint8_t replacement) { // Some useful precomputed data static constexpr std::uint8_t firstBytes[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; @@ -151,7 +151,7 @@ Out Utf<8>::encode(Uint32 input, Out output, std::uint8_t replacement) template In Utf<8>::next(In begin, In end) { - Uint32 codepoint; + std::uint32_t codepoint; return decode(begin, end, codepoint); } @@ -177,8 +177,8 @@ Out Utf<8>::fromAnsi(In begin, In end, Out output, const std::locale& locale) { while (begin < end) { - Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale); - output = encode(codepoint, output); + std::uint32_t codepoint = Utf<32>::decodeAnsi(*begin++, locale); + output = encode(codepoint, output); } return output; @@ -191,8 +191,8 @@ Out Utf<8>::fromWide(In begin, In end, Out output) { while (begin < end) { - Uint32 codepoint = Utf<32>::decodeWide(*begin++); - output = encode(codepoint, output); + std::uint32_t codepoint = Utf<32>::decodeWide(*begin++); + output = encode(codepoint, output); } return output; @@ -218,7 +218,7 @@ Out Utf<8>::toAnsi(In begin, In end, Out output, char replacement, const std::lo { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale); } @@ -233,7 +233,7 @@ Out Utf<8>::toWide(In begin, In end, Out output, wchar_t replacement) { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); output = Utf<32>::encodeWide(codepoint, output, replacement); } @@ -250,7 +250,7 @@ Out Utf<8>::toLatin1(In begin, In end, Out output, char replacement) // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); *output++ = codepoint < 256 ? static_cast(codepoint) : replacement; } @@ -273,7 +273,7 @@ Out Utf<8>::toUtf16(In begin, In end, Out output) { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); output = Utf<16>::encode(codepoint, output); } @@ -288,7 +288,7 @@ Out Utf<8>::toUtf32(In begin, In end, Out output) { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); *output++ = codepoint; } @@ -299,7 +299,7 @@ Out Utf<8>::toUtf32(In begin, In end, Out output) //////////////////////////////////////////////////////////// template -In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement) +In Utf<16>::decode(In begin, In end, std::uint32_t& output, std::uint32_t replacement) { std::uint16_t first = *begin++; @@ -308,7 +308,7 @@ In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement) { if (begin < end) { - Uint32 second = *begin++; + std::uint32_t second = *begin++; if ((second >= 0xDC00) && (second <= 0xDFFF)) { // The second element is valid: convert the two elements to a UTF-32 character @@ -339,7 +339,7 @@ In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement) //////////////////////////////////////////////////////////// template -Out Utf<16>::encode(Uint32 input, Out output, std::uint16_t replacement) +Out Utf<16>::encode(std::uint32_t input, Out output, std::uint16_t replacement) { if (input <= 0xFFFF) { @@ -378,7 +378,7 @@ Out Utf<16>::encode(Uint32 input, Out output, std::uint16_t replacement) template In Utf<16>::next(In begin, In end) { - Uint32 codepoint; + std::uint32_t codepoint; return decode(begin, end, codepoint); } @@ -404,8 +404,8 @@ Out Utf<16>::fromAnsi(In begin, In end, Out output, const std::locale& locale) { while (begin < end) { - Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale); - output = encode(codepoint, output); + std::uint32_t codepoint = Utf<32>::decodeAnsi(*begin++, locale); + output = encode(codepoint, output); } return output; @@ -418,8 +418,8 @@ Out Utf<16>::fromWide(In begin, In end, Out output) { while (begin < end) { - Uint32 codepoint = Utf<32>::decodeWide(*begin++); - output = encode(codepoint, output); + std::uint32_t codepoint = Utf<32>::decodeWide(*begin++); + output = encode(codepoint, output); } return output; @@ -442,7 +442,7 @@ Out Utf<16>::toAnsi(In begin, In end, Out output, char replacement, const std::l { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale); } @@ -457,7 +457,7 @@ Out Utf<16>::toWide(In begin, In end, Out output, wchar_t replacement) { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); output = Utf<32>::encodeWide(codepoint, output, replacement); } @@ -488,7 +488,7 @@ Out Utf<16>::toUtf8(In begin, In end, Out output) { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); output = Utf<8>::encode(codepoint, output); } @@ -511,7 +511,7 @@ Out Utf<16>::toUtf32(In begin, In end, Out output) { while (begin < end) { - Uint32 codepoint; + std::uint32_t codepoint; begin = decode(begin, end, codepoint); *output++ = codepoint; } @@ -522,7 +522,7 @@ Out Utf<16>::toUtf32(In begin, In end, Out output) //////////////////////////////////////////////////////////// template -In Utf<32>::decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/) +In Utf<32>::decode(In begin, In /*end*/, std::uint32_t& output, std::uint32_t /*replacement*/) { output = *begin++; return begin; @@ -531,7 +531,7 @@ In Utf<32>::decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/) //////////////////////////////////////////////////////////// template -Out Utf<32>::encode(Uint32 input, Out output, Uint32 /*replacement*/) +Out Utf<32>::encode(std::uint32_t input, Out output, std::uint32_t /*replacement*/) { *output++ = input; return output; @@ -655,7 +655,7 @@ Out Utf<32>::toUtf32(In begin, In end, Out output) //////////////////////////////////////////////////////////// template -Uint32 Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale) +std::uint32_t Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale) { // On Windows, GCC's standard library (glibc++) has almost // no support for Unicode stuff. As a consequence, in this @@ -668,7 +668,7 @@ Uint32 Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale) wchar_t character = 0; mbtowc(&character, &input, 1); - return static_cast(character); + return static_cast(character); #else @@ -676,7 +676,7 @@ Uint32 Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale) const auto& facet = std::use_facet>(locale); // Use the facet to convert each character of the input string - return static_cast(facet.widen(input)); + return static_cast(facet.widen(input)); #endif } @@ -684,7 +684,7 @@ Uint32 Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale) //////////////////////////////////////////////////////////// template -Uint32 Utf<32>::decodeWide(In input) +std::uint32_t Utf<32>::decodeWide(In input) { // The encoding of wide characters is not well defined and is left to the system; // however we can safely assume that it is UCS-2 on Windows and @@ -692,13 +692,13 @@ Uint32 Utf<32>::decodeWide(In input) // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4, // and UCS-4 *is* UTF-32). - return static_cast(input); + return static_cast(input); } //////////////////////////////////////////////////////////// template -Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, [[maybe_unused]] const std::locale& locale) +Out Utf<32>::encodeAnsi(std::uint32_t codepoint, Out output, char replacement, [[maybe_unused]] const std::locale& locale) { // On Windows, gcc's standard library (glibc++) has almost // no support for Unicode stuff. As a consequence, in this @@ -733,7 +733,7 @@ Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, [[maybe_ //////////////////////////////////////////////////////////// template -Out Utf<32>::encodeWide(Uint32 codepoint, Out output, wchar_t replacement) +Out Utf<32>::encodeWide(std::uint32_t codepoint, Out output, wchar_t replacement) { // The encoding of wide characters is not well defined and is left to the system; // however we can safely assume that it is UCS-2 on Windows and diff --git a/include/SFML/Window/ContextSettings.hpp b/include/SFML/Window/ContextSettings.hpp index 8d6c20a50..5c222fa82 100644 --- a/include/SFML/Window/ContextSettings.hpp +++ b/include/SFML/Window/ContextSettings.hpp @@ -80,13 +80,13 @@ struct ContextSettings //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - unsigned int depthBits; //!< Bits of the depth buffer - unsigned int stencilBits; //!< Bits of the stencil buffer - unsigned int antialiasingLevel; //!< Level of antialiasing - unsigned int majorVersion; //!< Major number of the context version to create - unsigned int minorVersion; //!< Minor number of the context version to create - Uint32 attributeFlags; //!< The attribute flags to create the context with - bool sRgbCapable; //!< Whether the context framebuffer is sRGB capable + unsigned int depthBits; //!< Bits of the depth buffer + unsigned int stencilBits; //!< Bits of the stencil buffer + unsigned int antialiasingLevel; //!< Level of antialiasing + unsigned int majorVersion; //!< Major number of the context version to create + unsigned int minorVersion; //!< Minor number of the context version to create + std::uint32_t attributeFlags; //!< The attribute flags to create the context with + bool sRgbCapable; //!< Whether the context framebuffer is sRGB capable }; } // namespace sf diff --git a/include/SFML/Window/Event.hpp b/include/SFML/Window/Event.hpp index 6decd2074..b5e829435 100644 --- a/include/SFML/Window/Event.hpp +++ b/include/SFML/Window/Event.hpp @@ -74,7 +74,7 @@ public: //////////////////////////////////////////////////////////// struct TextEvent { - Uint32 unicode; //!< UTF-32 Unicode value of the character + std::uint32_t unicode; //!< UTF-32 Unicode value of the character }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 4af56acfc..54696fbad 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -83,7 +83,7 @@ public: //////////////////////////////////////////////////////////// Window(VideoMode mode, const String& title, - Uint32 style = Style::Default, + std::uint32_t style = Style::Default, const ContextSettings& settings = ContextSettings()); //////////////////////////////////////////////////////////// @@ -122,7 +122,7 @@ public: /// \param style %Window style, a bitwise OR combination of sf::Style enumerators /// //////////////////////////////////////////////////////////// - void create(VideoMode mode, const String& title, Uint32 style = Style::Default) override; + void create(VideoMode mode, const String& title, std::uint32_t style = Style::Default) override; //////////////////////////////////////////////////////////// /// \brief Create (or recreate) the window @@ -141,7 +141,7 @@ public: /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// - virtual void create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings); + virtual void create(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings); //////////////////////////////////////////////////////////// /// \brief Create (or recreate) the window from an existing control diff --git a/include/SFML/Window/WindowBase.hpp b/include/SFML/Window/WindowBase.hpp index 1b868dd4c..cda002d69 100644 --- a/include/SFML/Window/WindowBase.hpp +++ b/include/SFML/Window/WindowBase.hpp @@ -81,7 +81,7 @@ public: /// \param style %Window style, a bitwise OR combination of sf::Style enumerators /// //////////////////////////////////////////////////////////// - WindowBase(VideoMode mode, const String& title, Uint32 style = Style::Default); + WindowBase(VideoMode mode, const String& title, std::uint32_t style = Style::Default); //////////////////////////////////////////////////////////// /// \brief Construct the window from an existing control @@ -123,7 +123,7 @@ public: /// \param style %Window style, a bitwise OR combination of sf::Style enumerators /// //////////////////////////////////////////////////////////// - virtual void create(VideoMode mode, const String& title, Uint32 style = Style::Default); + virtual void create(VideoMode mode, const String& title, std::uint32_t style = Style::Default); //////////////////////////////////////////////////////////// /// \brief Create (or recreate) the window from an existing control diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index 86e5110d6..172bd90f0 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -68,24 +68,24 @@ bool decode(sf::InputStream& stream, std::uint16_t& value) return true; } -bool decode24bit(sf::InputStream& stream, sf::Uint32& value) +bool decode24bit(sf::InputStream& stream, std::uint32_t& value) { unsigned char bytes[3]; if (static_cast(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) return false; - value = static_cast(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16)); + value = static_cast(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16)); return true; } -bool decode(sf::InputStream& stream, sf::Uint32& value) +bool decode(sf::InputStream& stream, std::uint32_t& value) { unsigned char bytes[sizeof(value)]; if (static_cast(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) return false; - value = static_cast(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24)); + value = static_cast(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24)); return true; } @@ -184,7 +184,7 @@ Uint64 SoundFileReaderWav::read(std::int16_t* samples, Uint64 maxCount) case 3: { - Uint32 sample = 0; + std::uint32_t sample = 0; if (decode24bit(*m_stream, sample)) *samples++ = static_cast(sample >> 8); else @@ -194,7 +194,7 @@ Uint64 SoundFileReaderWav::read(std::int16_t* samples, Uint64 maxCount) case 4: { - Uint32 sample = 0; + std::uint32_t sample = 0; if (decode(*m_stream, sample)) *samples++ = static_cast(sample >> 16); else @@ -236,7 +236,7 @@ bool SoundFileReaderWav::parseHeader(Info& info) if (static_cast(m_stream->read(subChunkId, static_cast(sizeof(subChunkId)))) != sizeof(subChunkId)) return false; - Uint32 subChunkSize = 0; + std::uint32_t subChunkSize = 0; if (!decode(*m_stream, subChunkSize)) return false; Int64 subChunkStart = m_stream->tell(); @@ -262,13 +262,13 @@ bool SoundFileReaderWav::parseHeader(Info& info) info.channelCount = channelCount; // Sample rate - Uint32 sampleRate = 0; + std::uint32_t sampleRate = 0; if (!decode(*m_stream, sampleRate)) return false; info.sampleRate = sampleRate; // Byte rate - Uint32 byteRate = 0; + std::uint32_t byteRate = 0; if (!decode(*m_stream, byteRate)) return false; @@ -302,7 +302,7 @@ bool SoundFileReaderWav::parseHeader(Info& info) return false; // Channel mask - Uint32 channelMask = 0; + std::uint32_t channelMask = 0; if (!decode(*m_stream, channelMask)) return false; diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index 6a9112d8f..e944a72bf 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -50,7 +50,7 @@ void encode(std::ostream& stream, std::uint16_t value) stream.write(reinterpret_cast(bytes), sizeof(bytes)); } -void encode(std::ostream& stream, sf::Uint32 value) +void encode(std::ostream& stream, std::uint32_t value) { unsigned char bytes[] = { static_cast(value & 0x000000FF), @@ -128,14 +128,14 @@ bool SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann m_file.write(mainChunkId, sizeof(mainChunkId)); // Write the main chunk header - encode(m_file, static_cast(0)); // 0 is a placeholder, will be written later + encode(m_file, static_cast(0)); // 0 is a placeholder, will be written later char mainChunkFormat[4] = {'W', 'A', 'V', 'E'}; m_file.write(mainChunkFormat, sizeof(mainChunkFormat)); // Write the sub-chunk 1 ("format") id and size char fmtChunkId[4] = {'f', 'm', 't', ' '}; m_file.write(fmtChunkId, sizeof(fmtChunkId)); - Uint32 fmtChunkSize = 16; + std::uint32_t fmtChunkSize = 16; encode(m_file, fmtChunkSize); // Write the format (PCM) @@ -145,7 +145,7 @@ bool SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann // Write the sound attributes encode(m_file, static_cast(channelCount)); encode(m_file, sampleRate); - Uint32 byteRate = sampleRate * channelCount * 2; + std::uint32_t byteRate = sampleRate * channelCount * 2; encode(m_file, byteRate); auto blockAlign = static_cast(channelCount * 2); encode(m_file, blockAlign); @@ -155,7 +155,7 @@ bool SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann // Write the sub-chunk 2 ("data") id and size char dataChunkId[4] = {'d', 'a', 't', 'a'}; m_file.write(dataChunkId, sizeof(dataChunkId)); - Uint32 dataChunkSize = 0; // placeholder, will be written later + std::uint32_t dataChunkSize = 0; // placeholder, will be written later encode(m_file, dataChunkSize); return true; @@ -171,7 +171,7 @@ void SoundFileWriterWav::close() m_file.flush(); // Update the main chunk size and data sub-chunk size - Uint32 fileSize = static_cast(m_file.tellp()); + std::uint32_t fileSize = static_cast(m_file.tellp()); m_file.seekp(4); encode(m_file, fileSize - 8); // 8 bytes RIFF header m_file.seekp(40); diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 119e4af17..144862355 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -425,7 +425,7 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop) // Acquire audio data, also address EOF and error cases if they occur Chunk data = {nullptr, 0}; - for (Uint32 retryCount = 0; !onGetData(data) && (retryCount < BufferRetries); ++retryCount) + for (std::uint32_t retryCount = 0; !onGetData(data) && (retryCount < BufferRetries); ++retryCount) { // Check if the stream must loop or stop if (!m_loop) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index a73862993..b181f7ed0 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -79,9 +79,9 @@ inline T reinterpret(const U& input) } // Combine outline thickness, boldness and font glyph index into a single 64-bit key -sf::Uint64 combine(float outlineThickness, bool bold, sf::Uint32 index) +sf::Uint64 combine(float outlineThickness, bool bold, std::uint32_t index) { - return (static_cast(reinterpret(outlineThickness)) << 32) | + return (static_cast(reinterpret(outlineThickness)) << 32) | (static_cast(bold) << 31) | index; } } // namespace @@ -350,7 +350,7 @@ const Font::Info& Font::getInfo() const //////////////////////////////////////////////////////////// -const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const +const Glyph& Font::getGlyph(std::uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) const { // Get the page corresponding to the character size GlyphTable& glyphs = loadPage(characterSize).glyphs; @@ -376,14 +376,14 @@ const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool b //////////////////////////////////////////////////////////// -bool Font::hasGlyph(Uint32 codePoint) const +bool Font::hasGlyph(std::uint32_t codePoint) const { return FT_Get_Char_Index(m_fontHandles ? m_fontHandles->face.get() : nullptr, codePoint) != 0; } //////////////////////////////////////////////////////////// -float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize, bool bold) const +float Font::getKerning(std::uint32_t first, std::uint32_t second, unsigned int characterSize, bool bold) const { // Special case where first or second is 0 (null character) if (first == 0 || second == 0) @@ -548,7 +548,7 @@ Font::Page& Font::loadPage(unsigned int characterSize) const //////////////////////////////////////////////////////////// -Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const +Glyph Font::loadGlyph(std::uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) const { // The glyph to return Glyph glyph; diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index 4e311cfa7..59befffb9 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -79,7 +79,7 @@ bool isActive(sf::Uint64 id) } // Convert an sf::BlendMode::Factor constant to the corresponding OpenGL constant. -sf::Uint32 factorToGlConstant(sf::BlendMode::Factor blendFactor) +std::uint32_t factorToGlConstant(sf::BlendMode::Factor blendFactor) { // clang-format off switch (blendFactor) @@ -104,7 +104,7 @@ sf::Uint32 factorToGlConstant(sf::BlendMode::Factor blendFactor) // Convert an sf::BlendMode::BlendEquation constant to the corresponding OpenGL constant. -sf::Uint32 equationToGlConstant(sf::BlendMode::Equation blendEquation) +std::uint32_t equationToGlConstant(sf::BlendMode::Equation blendEquation) { switch (blendEquation) { diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 5b5a4f87f..8e778a14e 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -42,7 +42,7 @@ RenderWindow::RenderWindow() : m_defaultFrameBuffer(0) //////////////////////////////////////////////////////////// -RenderWindow::RenderWindow(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings) : +RenderWindow::RenderWindow(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings) : m_defaultFrameBuffer(0) { // Don't call the base class constructor because it contains virtual function calls diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 8d3f89e2a..0027d3762 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -205,7 +205,7 @@ void Text::setLineSpacing(float spacingFactor) //////////////////////////////////////////////////////////// -void Text::setStyle(Uint32 style) +void Text::setStyle(std::uint32_t style) { if (m_style != style) { @@ -298,7 +298,7 @@ float Text::getLineSpacing() const //////////////////////////////////////////////////////////// -Uint32 Text::getStyle() const +std::uint32_t Text::getStyle() const { return m_style; } @@ -344,11 +344,11 @@ Vector2f Text::findCharacterPos(std::size_t index) const float lineSpacing = m_font->getLineSpacing(m_characterSize) * m_lineSpacingFactor; // Compute the position - Vector2f position; - Uint32 prevChar = 0; + Vector2f position; + std::uint32_t prevChar = 0; for (std::size_t i = 0; i < index; ++i) { - Uint32 curChar = m_string[i]; + std::uint32_t curChar = m_string[i]; // Apply the kerning offset position.x += m_font->getKerning(prevChar, curChar, m_characterSize, isBold); @@ -465,14 +465,14 @@ void Text::ensureGeometryUpdate() const auto y = static_cast(m_characterSize); // Create one quad for each character - auto minX = static_cast(m_characterSize); - auto minY = static_cast(m_characterSize); - float maxX = 0.f; - float maxY = 0.f; - Uint32 prevChar = 0; + auto minX = static_cast(m_characterSize); + auto minY = static_cast(m_characterSize); + float maxX = 0.f; + float maxY = 0.f; + std::uint32_t prevChar = 0; for (std::size_t i = 0; i < m_string.getSize(); ++i) { - Uint32 curChar = m_string[i]; + std::uint32_t curChar = m_string[i]; // Skip the \r char to avoid weird graphical issues if (curChar == U'\r') diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index d96a64a46..849c7fc7f 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -62,7 +62,7 @@ std::optional IpAddress::resolve(std::string_view address) return Any; // Try to convert the address as a byte representation ("xxx.xxx.xxx.xxx") - if (const Uint32 ip = inet_addr(address.data()); ip != INADDR_NONE) + if (const std::uint32_t ip = inet_addr(address.data()); ip != INADDR_NONE) return IpAddress(ntohl(ip)); // Not a valid address, try to convert it as a host name @@ -75,7 +75,7 @@ std::optional IpAddress::resolve(std::string_view address) sockaddr_in sin; std::memcpy(&sin, result->ai_addr, sizeof(*result->ai_addr)); - const Uint32 ip = sin.sin_addr.s_addr; + const std::uint32_t ip = sin.sin_addr.s_addr; freeaddrinfo(result); return IpAddress(ntohl(ip)); @@ -93,7 +93,7 @@ m_address(htonl(static_cast((byte0 << 24) | (byte1 << 16) | (byte //////////////////////////////////////////////////////////// -IpAddress::IpAddress(Uint32 address) : m_address(htonl(address)) +IpAddress::IpAddress(std::uint32_t address) : m_address(htonl(address)) { } @@ -109,7 +109,7 @@ std::string IpAddress::toString() const //////////////////////////////////////////////////////////// -Uint32 IpAddress::toInteger() const +std::uint32_t IpAddress::toInteger() const { return ntohl(m_address); } diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index a3d1c4926..15bc1659f 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -188,7 +188,7 @@ Packet& Packet::operator>>(std::int32_t& data) if (checkSize(sizeof(data))) { std::memcpy(&data, &m_data[m_readPos], sizeof(data)); - data = static_cast(ntohl(static_cast(data))); + data = static_cast(ntohl(static_cast(data))); m_readPos += sizeof(data); } @@ -197,7 +197,7 @@ Packet& Packet::operator>>(std::int32_t& data) //////////////////////////////////////////////////////////// -Packet& Packet::operator>>(Uint32& data) +Packet& Packet::operator>>(std::uint32_t& data) { if (checkSize(sizeof(data))) { @@ -284,7 +284,7 @@ Packet& Packet::operator>>(double& data) Packet& Packet::operator>>(char* data) { // First extract string length - Uint32 length = 0; + std::uint32_t length = 0; *this >> length; if ((length > 0) && checkSize(length)) @@ -305,7 +305,7 @@ Packet& Packet::operator>>(char* data) Packet& Packet::operator>>(std::string& data) { // First extract string length - Uint32 length = 0; + std::uint32_t length = 0; *this >> length; data.clear(); @@ -326,15 +326,15 @@ Packet& Packet::operator>>(std::string& data) Packet& Packet::operator>>(wchar_t* data) { // First extract string length - Uint32 length = 0; + std::uint32_t length = 0; *this >> length; - if ((length > 0) && checkSize(length * sizeof(Uint32))) + if ((length > 0) && checkSize(length * sizeof(std::uint32_t))) { // Then extract characters - for (Uint32 i = 0; i < length; ++i) + for (std::uint32_t i = 0; i < length; ++i) { - Uint32 character = 0; + std::uint32_t character = 0; *this >> character; data[i] = static_cast(character); } @@ -349,16 +349,16 @@ Packet& Packet::operator>>(wchar_t* data) Packet& Packet::operator>>(std::wstring& data) { // First extract string length - Uint32 length = 0; + std::uint32_t length = 0; *this >> length; data.clear(); - if ((length > 0) && checkSize(length * sizeof(Uint32))) + if ((length > 0) && checkSize(length * sizeof(std::uint32_t))) { // Then extract characters - for (Uint32 i = 0; i < length; ++i) + for (std::uint32_t i = 0; i < length; ++i) { - Uint32 character = 0; + std::uint32_t character = 0; *this >> character; data += static_cast(character); } @@ -372,16 +372,16 @@ Packet& Packet::operator>>(std::wstring& data) Packet& Packet::operator>>(String& data) { // First extract the string length - Uint32 length = 0; + std::uint32_t length = 0; *this >> length; data.clear(); - if ((length > 0) && checkSize(length * sizeof(Uint32))) + if ((length > 0) && checkSize(length * sizeof(std::uint32_t))) { // Then extract characters - for (Uint32 i = 0; i < length; ++i) + for (std::uint32_t i = 0; i < length; ++i) { - Uint32 character = 0; + std::uint32_t character = 0; *this >> character; data += character; } @@ -436,16 +436,16 @@ Packet& Packet::operator<<(std::uint16_t data) //////////////////////////////////////////////////////////// Packet& Packet::operator<<(std::int32_t data) { - std::int32_t toWrite = static_cast(htonl(static_cast(data))); + std::int32_t toWrite = static_cast(htonl(static_cast(data))); append(&toWrite, sizeof(toWrite)); return *this; } //////////////////////////////////////////////////////////// -Packet& Packet::operator<<(Uint32 data) +Packet& Packet::operator<<(std::uint32_t data) { - Uint32 toWrite = htonl(data); + std::uint32_t toWrite = htonl(data); append(&toWrite, sizeof(toWrite)); return *this; } @@ -511,7 +511,7 @@ Packet& Packet::operator<<(double data) Packet& Packet::operator<<(const char* data) { // First insert string length - auto length = static_cast(std::strlen(data)); + auto length = static_cast(std::strlen(data)); *this << length; // Then insert characters @@ -525,7 +525,7 @@ Packet& Packet::operator<<(const char* data) Packet& Packet::operator<<(const std::string& data) { // First insert string length - auto length = static_cast(data.size()); + auto length = static_cast(data.size()); *this << length; // Then insert characters @@ -540,12 +540,12 @@ Packet& Packet::operator<<(const std::string& data) Packet& Packet::operator<<(const wchar_t* data) { // First insert string length - auto length = static_cast(std::wcslen(data)); + auto length = static_cast(std::wcslen(data)); *this << length; // Then insert characters for (const wchar_t* c = data; *c != L'\0'; ++c) - *this << static_cast(*c); + *this << static_cast(*c); return *this; } @@ -555,14 +555,14 @@ Packet& Packet::operator<<(const wchar_t* data) Packet& Packet::operator<<(const std::wstring& data) { // First insert string length - auto length = static_cast(data.size()); + auto length = static_cast(data.size()); *this << length; // Then insert characters if (length > 0) { for (wchar_t c : data) - *this << static_cast(c); + *this << static_cast(c); } return *this; @@ -573,7 +573,7 @@ Packet& Packet::operator<<(const std::wstring& data) Packet& Packet::operator<<(const String& data) { // First insert the string length - auto length = static_cast(data.getSize()); + auto length = static_cast(data.getSize()); *this << length; // Then insert characters diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 066a374a1..6eef9e37d 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -322,7 +322,7 @@ Socket::Status TcpSocket::send(Packet& packet) const void* data = packet.onSend(size); // First convert the packet size to network byte order - Uint32 packetSize = htonl(static_cast(size)); + std::uint32_t packetSize = htonl(static_cast(size)); // Allocate memory for the data block to send m_blockToSendBuffer.resize(sizeof(packetSize) + size); @@ -371,8 +371,8 @@ Socket::Status TcpSocket::receive(Packet& packet) packet.clear(); // We start by getting the size of the incoming packet - Uint32 packetSize = 0; - std::size_t received = 0; + std::uint32_t packetSize = 0; + std::size_t received = 0; if (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size)) { // Loop until we've received the entire size of the packet diff --git a/src/SFML/Network/Unix/SocketImpl.cpp b/src/SFML/Network/Unix/SocketImpl.cpp index ea8f2b93b..0e51557ca 100644 --- a/src/SFML/Network/Unix/SocketImpl.cpp +++ b/src/SFML/Network/Unix/SocketImpl.cpp @@ -39,7 +39,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -sockaddr_in SocketImpl::createAddress(Uint32 address, unsigned short port) +sockaddr_in SocketImpl::createAddress(std::uint32_t address, unsigned short port) { sockaddr_in addr; std::memset(&addr, 0, sizeof(addr)); diff --git a/src/SFML/Network/Unix/SocketImpl.hpp b/src/SFML/Network/Unix/SocketImpl.hpp index 04568fc27..636aded28 100644 --- a/src/SFML/Network/Unix/SocketImpl.hpp +++ b/src/SFML/Network/Unix/SocketImpl.hpp @@ -66,7 +66,7 @@ public: /// \return sockaddr_in ready to be used by socket functions /// //////////////////////////////////////////////////////////// - static sockaddr_in createAddress(Uint32 address, unsigned short port); + static sockaddr_in createAddress(std::uint32_t address, unsigned short port); //////////////////////////////////////////////////////////// /// \brief Return the value of the invalid socket diff --git a/src/SFML/Network/Win32/SocketImpl.cpp b/src/SFML/Network/Win32/SocketImpl.cpp index 0484f25b7..811a028c8 100644 --- a/src/SFML/Network/Win32/SocketImpl.cpp +++ b/src/SFML/Network/Win32/SocketImpl.cpp @@ -35,7 +35,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -sockaddr_in SocketImpl::createAddress(Uint32 address, unsigned short port) +sockaddr_in SocketImpl::createAddress(std::uint32_t address, unsigned short port) { sockaddr_in addr; std::memset(&addr, 0, sizeof(addr)); diff --git a/src/SFML/Network/Win32/SocketImpl.hpp b/src/SFML/Network/Win32/SocketImpl.hpp index 0f91c10b8..37144ae02 100644 --- a/src/SFML/Network/Win32/SocketImpl.hpp +++ b/src/SFML/Network/Win32/SocketImpl.hpp @@ -62,7 +62,7 @@ public: /// \return sockaddr_in ready to be used by socket functions /// //////////////////////////////////////////////////////////// - static sockaddr_in createAddress(Uint32 address, unsigned short port); + static sockaddr_in createAddress(std::uint32_t address, unsigned short port); //////////////////////////////////////////////////////////// /// \brief Return the value of the invalid socket diff --git a/src/SFML/System/String.cpp b/src/SFML/System/String.cpp index 930aed0ef..02dd023f3 100644 --- a/src/SFML/System/String.cpp +++ b/src/SFML/System/String.cpp @@ -35,7 +35,7 @@ namespace sf { //////////////////////////////////////////////////////////// -const std::size_t String::InvalidPos = std::basic_string::npos; +const std::size_t String::InvalidPos = std::basic_string::npos; //////////////////////////////////////////////////////////// @@ -59,7 +59,7 @@ String::String(wchar_t wideChar) //////////////////////////////////////////////////////////// -String::String(Uint32 utf32Char) +String::String(std::uint32_t utf32Char) { m_string += utf32Char; } @@ -112,7 +112,7 @@ String::String(const std::wstring& wideString) //////////////////////////////////////////////////////////// -String::String(const Uint32* utf32String) +String::String(const std::uint32_t* utf32String) { if (utf32String) m_string = utf32String; @@ -120,7 +120,7 @@ String::String(const Uint32* utf32String) //////////////////////////////////////////////////////////// -String::String(const std::basic_string& utf32String) : m_string(utf32String) +String::String(const std::basic_string& utf32String) : m_string(utf32String) { } @@ -210,7 +210,7 @@ std::basic_string String::toUtf16() const //////////////////////////////////////////////////////////// -std::basic_string String::toUtf32() const +std::basic_string String::toUtf32() const { return m_string; } @@ -233,14 +233,14 @@ String& String::operator+=(const String& right) //////////////////////////////////////////////////////////// -Uint32 String::operator[](std::size_t index) const +std::uint32_t String::operator[](std::size_t index) const { return m_string[index]; } //////////////////////////////////////////////////////////// -Uint32& String::operator[](std::size_t index) +std::uint32_t& String::operator[](std::size_t index) { return m_string[index]; } @@ -319,7 +319,7 @@ String String::substring(std::size_t position, std::size_t length) const //////////////////////////////////////////////////////////// -const Uint32* String::getData() const +const std::uint32_t* String::getData() const { return m_string.c_str(); } diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 76215e63b..141238c08 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -425,10 +425,10 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates& /* s event.type = Event::KeyReleased; forwardEvent(event); - if (Uint32 unicode = static_cast(getUnicode(_event))) + if (std::uint32_t unicode = static_cast(getUnicode(_event))) { event.type = Event::TextEntered; - event.text.unicode = static_cast(unicode); + event.text.unicode = static_cast(unicode); forwardEvent(event); } return 1; @@ -448,10 +448,10 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates& /* s // https://code.google.com/p/android/issues/detail?id=33998 return 0; } - else if (Uint32 unicode = static_cast(getUnicode(_event))) // This is a repeated sequence + else if (std::uint32_t unicode = static_cast(getUnicode(_event))) // This is a repeated sequence { event.type = Event::TextEntered; - event.text.unicode = static_cast(unicode); + event.text.unicode = static_cast(unicode); std::int32_t repeats = AKeyEvent_getRepeatCount(_event); for (std::int32_t i = 0; i < repeats; ++i) @@ -473,7 +473,7 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates& s if (device == AINPUT_SOURCE_MOUSE) event.type = Event::MouseMoved; - else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) + else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) event.type = Event::TouchMoved; std::size_t pointerCount = AMotionEvent_getPointerCount(_event); @@ -492,7 +492,7 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates& s states.mousePosition = Vector2i(event.mouseMove.x, event.mouseMove.y); } - else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) + else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) { if (states.touchEvents[id].x == x && states.touchEvents[id].y == y) continue; @@ -558,7 +558,7 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act if (id >= 0 && id < Mouse::ButtonCount) states.isButtonPressed[id] = false; } - else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) + else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) { event.type = Event::TouchEnded; event.touch.finger = static_cast(id); diff --git a/src/SFML/Window/DRM/DRMContext.cpp b/src/SFML/Window/DRM/DRMContext.cpp index 0a1b7ded1..7dde2264a 100644 --- a/src/SFML/Window/DRM/DRMContext.cpp +++ b/src/SFML/Window/DRM/DRMContext.cpp @@ -421,7 +421,7 @@ void DRMContext::createContext(DRMContext* shared) //////////////////////////////////////////////////////////// void DRMContext::createSurface(const Vector2u& size, unsigned int /*bpp*/, bool scanout) { - sf::Uint32 flags = GBM_BO_USE_RENDERING; + std::uint32_t flags = GBM_BO_USE_RENDERING; m_scanOut = scanout; if (m_scanOut) diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index bcdf1c7e4..31a868458 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -866,7 +866,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings) if (std::strstr(extensionString, "GL_ARB_compatibility")) { - m_settings.attributeFlags &= ~static_cast(ContextSettings::Core); + m_settings.attributeFlags &= ~static_cast(ContextSettings::Core); break; } } diff --git a/src/SFML/Window/OSX/cpp_objc_conversion.mm b/src/SFML/Window/OSX/cpp_objc_conversion.mm index da1989aef..69b46ec4b 100644 --- a/src/SFML/Window/OSX/cpp_objc_conversion.mm +++ b/src/SFML/Window/OSX/cpp_objc_conversion.mm @@ -45,8 +45,8 @@ NSString* stringToNSString(const std::string& string) //////////////////////////////////////////////////////////// NSString* sfStringToNSString(const sf::String& string) { - sf::Uint32 length = static_cast(string.getSize() * sizeof(sf::Uint32)); - const void* data = reinterpret_cast(string.getData()); + std::uint32_t length = static_cast(string.getSize() * sizeof(std::uint32_t)); + const void* data = reinterpret_cast(string.getData()); NSStringEncoding encoding; if (NSHostByteOrder() == NS_LittleEndian) diff --git a/src/SFML/Window/Unix/CursorImpl.cpp b/src/SFML/Window/Unix/CursorImpl.cpp index 88816bda9..a981eff11 100644 --- a/src/SFML/Window/Unix/CursorImpl.cpp +++ b/src/SFML/Window/Unix/CursorImpl.cpp @@ -80,7 +80,7 @@ bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, V const std::size_t numPixels = static_cast(size.x) * static_cast(size.y); for (std::size_t pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - cursorImage->pixels[pixelIndex] = static_cast( + cursorImage->pixels[pixelIndex] = static_cast( pixels[pixelIndex * 4 + 2] + (pixels[pixelIndex * 4 + 1] << 8) + (pixels[pixelIndex * 4 + 0] << 16) + (pixels[pixelIndex * 4 + 3] << 24)); } diff --git a/src/SFML/Window/Unix/VulkanImplX11.cpp b/src/SFML/Window/Unix/VulkanImplX11.cpp index 620eb25a4..7b5a54267 100644 --- a/src/SFML/Window/Unix/VulkanImplX11.cpp +++ b/src/SFML/Window/Unix/VulkanImplX11.cpp @@ -135,7 +135,7 @@ bool VulkanImplX11::isAvailable(bool requireGraphics) // Retrieve the available instance extensions std::vector extensionProperties; - uint32_t extensionCount = 0; + std::uint32_t extensionCount = 0; wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, nullptr); diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 695515509..f5d8357fc 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -1940,7 +1940,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) { // There might be more than 1 characters in this event, // so we must iterate it - Uint32 unicode = 0; + std::uint32_t unicode = 0; std::uint8_t* iter = keyBuffer; while (iter < keyBuffer + length) { @@ -1964,7 +1964,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) { Event textEvent; textEvent.type = Event::TextEntered; - textEvent.text.unicode = static_cast(keyBuffer[0]); + textEvent.text.unicode = static_cast(keyBuffer[0]); pushEvent(textEvent); } } diff --git a/src/SFML/Window/Win32/CursorImpl.cpp b/src/SFML/Window/Win32/CursorImpl.cpp index c6ea7a8bb..a810c2938 100644 --- a/src/SFML/Window/Win32/CursorImpl.cpp +++ b/src/SFML/Window/Win32/CursorImpl.cpp @@ -72,7 +72,7 @@ bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vecto bitmapHeader.bV5BlueMask = 0x000000ff; bitmapHeader.bV5AlphaMask = 0xff000000; - Uint32* bitmapData = nullptr; + std::uint32_t* bitmapData = nullptr; HDC screenDC = GetDC(nullptr); HBITMAP color = CreateDIBSection(screenDC, @@ -91,10 +91,10 @@ bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vecto // Fill our bitmap with the cursor color data // We'll have to swap the red and blue channels here - Uint32* bitmapOffset = bitmapData; + std::uint32_t* bitmapOffset = bitmapData; for (std::size_t remaining = size.x * size.y; remaining > 0; --remaining, pixels += 4) { - *bitmapOffset++ = static_cast((pixels[3] << 24) | (pixels[0] << 16) | (pixels[1] << 8) | pixels[2]); + *bitmapOffset++ = static_cast((pixels[3] << 24) | (pixels[0] << 16) | (pixels[1] << 8) | pixels[2]); } // Create a dummy mask bitmap (it won't be used) diff --git a/src/SFML/Window/Win32/VulkanImplWin32.cpp b/src/SFML/Window/Win32/VulkanImplWin32.cpp index 11cf7a904..d57764293 100644 --- a/src/SFML/Window/Win32/VulkanImplWin32.cpp +++ b/src/SFML/Window/Win32/VulkanImplWin32.cpp @@ -134,7 +134,7 @@ bool VulkanImplWin32::isAvailable(bool requireGraphics) // Retrieve the available instance extensions std::vector extensionProperties; - uint32_t extensionCount = 0; + std::uint32_t extensionCount = 0; wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr); diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 0704142eb..cbfbca152 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -159,7 +159,7 @@ m_cursorGrabbed(false) //////////////////////////////////////////////////////////// -WindowImplWin32::WindowImplWin32(VideoMode mode, const String& title, Uint32 style, const ContextSettings& /*settings*/) : +WindowImplWin32::WindowImplWin32(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& /*settings*/) : m_handle(nullptr), m_callback(0), m_cursorVisible(true), // might need to call GetCursorInfo @@ -712,7 +712,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) if (m_keyRepeatEnabled || ((lParam & (1 << 30)) == 0)) { // Get the code of the typed character - auto character = static_cast(wParam); + auto character = static_cast(wParam); // Check if it is the first part of a surrogate pair, or a regular character if ((character >= 0xD800) && (character <= 0xDBFF)) diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index 474b40d9c..f036b6b24 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -63,7 +63,7 @@ public: /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// - WindowImplWin32(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings); + WindowImplWin32(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings); //////////////////////////////////////////////////////////// /// \brief Destructor diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index a565e39eb..3043f27fd 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -43,7 +43,7 @@ Window::Window() : m_context(), m_frameTimeLimit(Time::Zero) //////////////////////////////////////////////////////////// -Window::Window(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings) : +Window::Window(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings) : m_context(), m_frameTimeLimit(Time::Zero) { @@ -66,14 +66,14 @@ Window::~Window() //////////////////////////////////////////////////////////// -void Window::create(VideoMode mode, const String& title, Uint32 style) +void Window::create(VideoMode mode, const String& title, std::uint32_t style) { Window::create(mode, title, style, ContextSettings()); } //////////////////////////////////////////////////////////// -void Window::create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings) +void Window::create(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings) { // Destroy the previous window implementation close(); @@ -85,7 +85,7 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con if (getFullscreenWindow()) { err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl; - style &= ~static_cast(Style::Fullscreen); + style &= ~static_cast(Style::Fullscreen); } else { @@ -104,7 +104,7 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con // Check validity of style according to the underlying platform #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID) if (style & Style::Fullscreen) - style &= ~static_cast(Style::Titlebar); + style &= ~static_cast(Style::Titlebar); else style |= Style::Titlebar; #else diff --git a/src/SFML/Window/WindowBase.cpp b/src/SFML/Window/WindowBase.cpp index dcea8fd39..553550c89 100644 --- a/src/SFML/Window/WindowBase.cpp +++ b/src/SFML/Window/WindowBase.cpp @@ -52,7 +52,7 @@ WindowBase::WindowBase() : m_impl(), m_size(0, 0) //////////////////////////////////////////////////////////// -WindowBase::WindowBase(VideoMode mode, const String& title, Uint32 style) : m_impl(), m_size(0, 0) +WindowBase::WindowBase(VideoMode mode, const String& title, std::uint32_t style) : m_impl(), m_size(0, 0) { WindowBase::create(mode, title, style); } @@ -73,7 +73,7 @@ WindowBase::~WindowBase() //////////////////////////////////////////////////////////// -void WindowBase::create(VideoMode mode, const String& title, Uint32 style) +void WindowBase::create(VideoMode mode, const String& title, std::uint32_t style) { // Destroy the previous window implementation close(); @@ -85,7 +85,7 @@ void WindowBase::create(VideoMode mode, const String& title, Uint32 style) if (getFullscreenWindow()) { err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl; - style &= ~static_cast(Style::Fullscreen); + style &= ~static_cast(Style::Fullscreen); } else { @@ -104,7 +104,7 @@ void WindowBase::create(VideoMode mode, const String& title, Uint32 style) // Check validity of style according to the underlying platform #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID) if (style & Style::Fullscreen) - style &= ~static_cast(Style::Titlebar); + style &= ~static_cast(Style::Titlebar); else style |= Style::Titlebar; #else diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index a2987019e..5c0178070 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -101,7 +101,7 @@ struct WindowImpl::JoystickStatesImpl }; //////////////////////////////////////////////////////////// -std::unique_ptr WindowImpl::create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings) +std::unique_ptr WindowImpl::create(VideoMode mode, const String& title, std::uint32_t style, const ContextSettings& settings) { return std::make_unique(mode, title, style, settings); } diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index 8f776a24a..46e9d475f 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -69,7 +69,10 @@ public: /// \return Pointer to the created window /// //////////////////////////////////////////////////////////// - static std::unique_ptr create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings); + static std::unique_ptr create(VideoMode mode, + const String& title, + std::uint32_t style, + const ContextSettings& settings); //////////////////////////////////////////////////////////// /// \brief Create a new window depending on to the current OS diff --git a/src/SFML/Window/iOS/SFAppDelegate.hpp b/src/SFML/Window/iOS/SFAppDelegate.hpp index eb845195f..5ac573808 100644 --- a/src/SFML/Window/iOS/SFAppDelegate.hpp +++ b/src/SFML/Window/iOS/SFAppDelegate.hpp @@ -99,7 +99,7 @@ /// \param character The typed character /// //////////////////////////////////////////////////////////// -- (void)notifyCharacter:(sf::Uint32)character; +- (void)notifyCharacter:(std::uint32_t)character; //////////////////////////////////////////////////////////// /// \brief Tells if the dimensions of the current window must be flipped when switching to a given orientation diff --git a/src/SFML/Window/iOS/SFAppDelegate.mm b/src/SFML/Window/iOS/SFAppDelegate.mm index ea991cd92..d37e02ad3 100644 --- a/src/SFML/Window/iOS/SFAppDelegate.mm +++ b/src/SFML/Window/iOS/SFAppDelegate.mm @@ -324,7 +324,7 @@ std::vector touchPositions; //////////////////////////////////////////////////////////// -- (void)notifyCharacter:(sf::Uint32)character +- (void)notifyCharacter:(std::uint32_t)character { if (self.sfWindow) { diff --git a/src/SFML/Window/iOS/SFView.mm b/src/SFML/Window/iOS/SFView.mm index 084f75909..b865cab06 100644 --- a/src/SFML/Window/iOS/SFView.mm +++ b/src/SFML/Window/iOS/SFView.mm @@ -77,7 +77,7 @@ const char* end = utf8 + std::strlen(utf8); while (utf8 < end) { - sf::Uint32 character; + std::uint32_t character; utf8 = sf::Utf8::decode(utf8, end, character); [[SFAppDelegate getInstance] notifyCharacter:character]; } diff --git a/test/Graphics/Image.cpp b/test/Graphics/Image.cpp index bd786b4c0..c3676e6b4 100644 --- a/test/Graphics/Image.cpp +++ b/test/Graphics/Image.cpp @@ -23,9 +23,9 @@ TEST_CASE("sf::Image - [graphics]") CHECK(image.getSize() == sf::Vector2u(10, 10)); CHECK(image.getPixelsPtr() != nullptr); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color(0, 0, 0)); } @@ -40,9 +40,9 @@ TEST_CASE("sf::Image - [graphics]") CHECK(image.getSize() == sf::Vector2u(10, 10)); CHECK(image.getPixelsPtr() != nullptr); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color::Red); } @@ -67,9 +67,9 @@ TEST_CASE("sf::Image - [graphics]") CHECK(image.getSize() == sf::Vector2u(10, 10)); CHECK(image.getPixelsPtr() != nullptr); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color::Red); } @@ -99,9 +99,9 @@ TEST_CASE("sf::Image - [graphics]") image2.create(sf::Vector2u(10, 10)); CHECK(image2.copy(image1, sf::Vector2u(0, 0))); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image1.getPixel(sf::Vector2u(i, j)) == image2.getPixel(sf::Vector2u(i, j))); } @@ -117,9 +117,9 @@ TEST_CASE("sf::Image - [graphics]") image2.create(sf::Vector2u(10, 10)); CHECK(image2.copy(image1, sf::Vector2u(0, 0), sf::IntRect(sf::Vector2i(0, 0), sf::Vector2i(5, 5)))); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { if (i <= 4 && j <= 4) CHECK(image2.getPixel(sf::Vector2u(i, j)) == sf::Color::Blue); @@ -151,9 +151,9 @@ TEST_CASE("sf::Image - [graphics]") image2.create(sf::Vector2u(10, 10), source); CHECK(image1.copy(image2, sf::Vector2u(0, 0), sf::IntRect(sf::Vector2i(0, 0), sf::Vector2i(10, 10)), true)); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image1.getPixel(sf::Vector2u(i, j)) == composite); } @@ -168,9 +168,9 @@ TEST_CASE("sf::Image - [graphics]") image2.create(sf::Vector2u(10, 10), sf::Color::Red); CHECK(!image2.copy(image1, sf::Vector2u(0, 0), sf::IntRect(sf::Vector2i(0, 0), sf::Vector2i(9, 9)))); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image2.getPixel(sf::Vector2u(i, j)) == sf::Color::Red); } @@ -187,9 +187,9 @@ TEST_CASE("sf::Image - [graphics]") image2.create(sf::Vector2u(10, 10), sf::Color::Red); CHECK(!image2.copy(image1, sf::Vector2u(0, 0), sf::IntRect(sf::Vector2i(5, 5), sf::Vector2i(9, 9)))); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image2.getPixel(sf::Vector2u(i, j)) == sf::Color::Red); } @@ -205,9 +205,9 @@ TEST_CASE("sf::Image - [graphics]") image.create(sf::Vector2u(10, 10), sf::Color::Blue); image.createMaskFromColor(sf::Color::Blue); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color(0, 0, 255, 0)); } @@ -220,9 +220,9 @@ TEST_CASE("sf::Image - [graphics]") image.create(sf::Vector2u(10, 10), sf::Color::Blue); image.createMaskFromColor(sf::Color::Blue, 100); - for (sf::Uint32 i = 0; i < 10; ++i) + for (std::uint32_t i = 0; i < 10; ++i) { - for (sf::Uint32 j = 0; j < 10; ++j) + for (std::uint32_t j = 0; j < 10; ++j) { CHECK(image.getPixel(sf::Vector2u(i, j)) == sf::Color(0, 0, 255, 100)); } diff --git a/test/Network/IpAddress.cpp b/test/Network/IpAddress.cpp index 882241522..92760b539 100644 --- a/test/Network/IpAddress.cpp +++ b/test/Network/IpAddress.cpp @@ -51,7 +51,7 @@ TEST_CASE("sf::IpAddress class - [network]") CHECK(ipAddress.toInteger() == 0x8EFA45EE); } - SUBCASE("Uint32 constructor") + SUBCASE("std::uint32_t constructor") { const sf::IpAddress ipAddress(0xDEADBEEF); CHECK(ipAddress.toString() == "222.173.190.239"s); diff --git a/test/System/Config.cpp b/test/System/Config.cpp index daf3ea707..5443a6014 100644 --- a/test/System/Config.cpp +++ b/test/System/Config.cpp @@ -14,8 +14,6 @@ TEST_CASE("SFML/Config.hpp") SUBCASE("Fixed width types") { - CHECK(sizeof(sf::Uint32) == 4); - CHECK(sizeof(sf::Int64) == 8); CHECK(sizeof(sf::Uint64) == 8); }