diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp index 7ded53299..69de18e01 100644 --- a/examples/shader/Shader.cpp +++ b/examples/shader/Shader.cpp @@ -137,11 +137,11 @@ public: m_points.setPrimitiveType(sf::Points); for (int i = 0; i < 40000; ++i) { - float x = static_cast(std::rand() % 800); - float y = static_cast(std::rand() % 600); - sf::Uint8 r = static_cast(std::rand() % 255); - sf::Uint8 g = static_cast(std::rand() % 255); - sf::Uint8 b = static_cast(std::rand() % 255); + auto x = static_cast(std::rand() % 800); + auto y = static_cast(std::rand() % 600); + auto r = static_cast(std::rand() % 255); + auto g = static_cast(std::rand() % 255); + auto b = static_cast(std::rand() % 255); m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b))); } diff --git a/examples/vulkan/Vulkan.cpp b/examples/vulkan/Vulkan.cpp index 80a4a7aef..4134d1e6d 100644 --- a/examples/vulkan/Vulkan.cpp +++ b/examples/vulkan/Vulkan.cpp @@ -804,7 +804,7 @@ public: swapchainExtent.width = clamp(window.getSize().x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); swapchainExtent.height = clamp(window.getSize().y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); - uint32_t 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; diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index adf5c3ccd..8bd2ea10d 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -656,7 +656,7 @@ Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale) #else // Get the facet of the locale which deals with character conversion - const std::ctype& facet = std::use_facet< std::ctype >(locale); + const auto& facet = std::use_facet< std::ctype >(locale); // Use the facet to convert each character of the input string return static_cast(facet.widen(input)); @@ -705,7 +705,7 @@ Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const st #else // Get the facet of the locale which deals with character conversion - const std::ctype& facet = std::use_facet< std::ctype >(locale); + const auto& facet = std::use_facet< std::ctype >(locale); // Use the facet to convert each character of the input string *output++ = facet.narrow(static_cast(codepoint), replacement); diff --git a/src/SFML/Audio/InputSoundFile.cpp b/src/SFML/Audio/InputSoundFile.cpp index 115dc3054..d55d26be4 100644 --- a/src/SFML/Audio/InputSoundFile.cpp +++ b/src/SFML/Audio/InputSoundFile.cpp @@ -71,7 +71,7 @@ bool InputSoundFile::openFromFile(const std::string& filename) return false; // Wrap the file into a stream - FileInputStream* file = new FileInputStream; + auto* file = new FileInputStream; m_stream = file; m_streamOwned = true; @@ -111,7 +111,7 @@ bool InputSoundFile::openFromMemory(const void* data, std::size_t sizeInBytes) return false; // Wrap the memory file into a stream - MemoryInputStream* memory = new MemoryInputStream; + auto* memory = new MemoryInputStream; m_stream = memory; m_streamOwned = true; diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index b551a8f99..97be42ce4 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -261,7 +261,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate) soundPtr->resetBuffer(); // Fill the buffer - ALsizei size = static_cast(m_samples.size() * sizeof(Int16)); + auto size = static_cast(m_samples.size() * sizeof(Int16)); alCheck(alBufferData(m_buffer, format, m_samples.data(), size, static_cast(sampleRate))); // Compute the duration diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp index 702346065..3abf98650 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.cpp +++ b/src/SFML/Audio/SoundFileReaderFlac.cpp @@ -35,7 +35,7 @@ namespace { FLAC__StreamDecoderReadStatus streamRead(const FLAC__StreamDecoder*, FLAC__byte buffer[], std::size_t* bytes, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); sf::Int64 count = data->stream->read(buffer, static_cast(*bytes)); if (count > 0) @@ -55,7 +55,7 @@ namespace FLAC__StreamDecoderSeekStatus streamSeek(const FLAC__StreamDecoder*, FLAC__uint64 absoluteByteOffset, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); sf::Int64 position = data->stream->seek(static_cast(absoluteByteOffset)); if (position >= 0) @@ -66,7 +66,7 @@ namespace FLAC__StreamDecoderTellStatus streamTell(const FLAC__StreamDecoder*, FLAC__uint64* absoluteByteOffset, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); sf::Int64 position = data->stream->tell(); if (position >= 0) @@ -82,7 +82,7 @@ namespace FLAC__StreamDecoderLengthStatus streamLength(const FLAC__StreamDecoder*, FLAC__uint64* streamLength, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); sf::Int64 count = data->stream->getSize(); if (count >= 0) @@ -98,14 +98,14 @@ namespace FLAC__bool streamEof(const FLAC__StreamDecoder*, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); return data->stream->tell() == data->stream->getSize(); } FLAC__StreamDecoderWriteStatus streamWrite(const FLAC__StreamDecoder*, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); // Reserve memory if we're going to use the leftovers buffer unsigned int frameSamples = frame->header.blocksize * frame->header.channels; @@ -158,7 +158,7 @@ namespace void streamMetadata(const FLAC__StreamDecoder*, const FLAC__StreamMetadata* meta, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); if (meta->type == FLAC__METADATA_TYPE_STREAMINFO) { @@ -170,7 +170,7 @@ namespace void streamError(const FLAC__StreamDecoder*, FLAC__StreamDecoderErrorStatus, void* clientData) { - sf::priv::SoundFileReaderFlac::ClientData* data = static_cast(clientData); + auto* data = static_cast(clientData); data->error = true; } } diff --git a/src/SFML/Audio/SoundFileReaderOgg.cpp b/src/SFML/Audio/SoundFileReaderOgg.cpp index adf9c9e20..84d6c228a 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.cpp +++ b/src/SFML/Audio/SoundFileReaderOgg.cpp @@ -37,13 +37,13 @@ namespace { size_t read(void* ptr, size_t size, size_t nmemb, void* data) { - sf::InputStream* stream = static_cast(data); + auto* stream = static_cast(data); return static_cast(stream->read(ptr, static_cast(size * nmemb))); } int seek(void* data, ogg_int64_t offset, int whence) { - sf::InputStream* stream = static_cast(data); + auto* stream = static_cast(data); switch (whence) { case SEEK_SET: @@ -59,7 +59,7 @@ namespace long tell(void* data) { - sf::InputStream* stream = static_cast(data); + auto* stream = static_cast(data); return static_cast(stream->tell()); } diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index 4590cb1ba..c7b4aafde 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -155,7 +155,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount) assert(m_stream); Uint64 count = 0; - Uint64 startPos = static_cast(m_stream->tell()); + auto startPos = static_cast(m_stream->tell()); // Tracking of m_dataEnd is important to prevent sf::Music from reading // data until EOF, as WAV files may have metadata at the end. diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index 5b298a668..bbdd63694 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -165,7 +165,7 @@ bool SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann encode(m_file, sampleRate); Uint32 byteRate = sampleRate * channelCount * 2; encode(m_file, byteRate); - Uint16 blockAlign = static_cast(channelCount * 2); + auto blockAlign = static_cast(channelCount * 2); encode(m_file, blockAlign); Uint16 bitsPerSample = 16; encode(m_file, bitsPerSample); diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 6c88e04db..bdd8d23c9 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -452,7 +452,7 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop) unsigned int buffer = m_buffers[bufferNum]; // Fill the buffer - ALsizei size = static_cast(data.sampleCount * sizeof(Int16)); + auto size = static_cast(data.sampleCount * sizeof(Int16)); alCheck(alBufferData(buffer, m_format, data.samples, size, static_cast(m_sampleRate))); // Push it into the sound queue diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 1cd012630..f4bc85366 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -48,8 +48,8 @@ namespace // FreeType callbacks that operate on a sf::InputStream unsigned long read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count) { - sf::Int64 convertedOffset = static_cast(offset); - sf::InputStream* stream = static_cast(rec->descriptor.pointer); + auto convertedOffset = static_cast(offset); + auto* stream = static_cast(rec->descriptor.pointer); if (stream->seek(convertedOffset) == convertedOffset) { if (count > 0) @@ -281,7 +281,7 @@ bool Font::loadFromStream(InputStream& stream) stream.seek(0); // Prepare a wrapper for our stream, that we'll pass to FreeType callbacks - FT_StreamRec* rec = new FT_StreamRec; + auto* rec = new FT_StreamRec; std::memset(rec, 0, sizeof(*rec)); rec->base = nullptr; rec->size = static_cast(stream.getSize()); @@ -382,7 +382,7 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize, if (first == 0 || second == 0) return 0.f; - FT_Face face = static_cast(m_face); + auto face = static_cast(m_face); if (face && setCurrentSize(characterSize)) { @@ -391,8 +391,8 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize, FT_UInt index2 = FT_Get_Char_Index(face, second); // Retrieve position compensation deltas generated by FT_LOAD_FORCE_AUTOHINT flag - float firstRsbDelta = static_cast(getGlyph(first, characterSize, bold).rsbDelta); - float secondLsbDelta = static_cast(getGlyph(second, characterSize, bold).lsbDelta); + auto firstRsbDelta = static_cast(getGlyph(first, characterSize, bold).rsbDelta); + auto secondLsbDelta = static_cast(getGlyph(second, characterSize, bold).lsbDelta); // Get the kerning vector if present FT_Vector kerning; @@ -419,7 +419,7 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize, //////////////////////////////////////////////////////////// float Font::getLineSpacing(unsigned int characterSize) const { - FT_Face face = static_cast(m_face); + auto face = static_cast(m_face); if (face && setCurrentSize(characterSize)) { @@ -435,7 +435,7 @@ float Font::getLineSpacing(unsigned int characterSize) const //////////////////////////////////////////////////////////// float Font::getUnderlinePosition(unsigned int characterSize) const { - FT_Face face = static_cast(m_face); + auto face = static_cast(m_face); if (face && setCurrentSize(characterSize)) { @@ -455,7 +455,7 @@ float Font::getUnderlinePosition(unsigned int characterSize) const //////////////////////////////////////////////////////////// float Font::getUnderlineThickness(unsigned int characterSize) const { - FT_Face face = static_cast(m_face); + auto face = static_cast(m_face); if (face && setCurrentSize(characterSize)) { @@ -573,7 +573,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f Glyph glyph; // First, transform our ugly void* to a FT_Face - FT_Face face = static_cast(m_face); + auto face = static_cast(m_face); if (!face) return glyph; @@ -600,13 +600,13 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f { if (bold) { - FT_OutlineGlyph outlineGlyph = reinterpret_cast(glyphDesc); + auto outlineGlyph = reinterpret_cast(glyphDesc); FT_Outline_Embolden(&outlineGlyph->outline, weight); } if (outlineThickness != 0) { - FT_Stroker stroker = static_cast(m_stroker); + auto stroker = static_cast(m_stroker); FT_Stroker_Set(stroker, static_cast(outlineThickness * static_cast(1 << 6)), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0); FT_Glyph_Stroke(&glyphDesc, stroker, true); @@ -617,7 +617,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f // Warning! After this line, do not read any data from glyphDesc directly, use // bitmapGlyph.root to access the FT_Glyph data. FT_Glyph_To_Bitmap(&glyphDesc, FT_RENDER_MODE_NORMAL, 0, 1); - FT_BitmapGlyph bitmapGlyph = reinterpret_cast(glyphDesc); + auto bitmapGlyph = reinterpret_cast(glyphDesc); FT_Bitmap& bitmap = bitmapGlyph->bitmap; // Apply bold if necessary -- fallback technique using bitmap (lower quality) @@ -805,7 +805,7 @@ bool Font::setCurrentSize(unsigned int characterSize) const // FT_Set_Pixel_Sizes is an expensive function, so we must call it // only when necessary to avoid killing performances - FT_Face face = static_cast(m_face); + auto face = static_cast(m_face); FT_UShort currentSize = face->size->metrics.x_ppem; if (currentSize != characterSize) diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 53846e595..7fd25cfb6 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -211,8 +211,8 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co } // Then find the valid bounds of the destination rectangle - unsigned int width = static_cast(srcRect.width); - unsigned int height = static_cast(srcRect.height); + auto width = static_cast(srcRect.width); + auto height = static_cast(srcRect.height); if (destX + width > m_size.x) width = m_size.x - destX; if (destY + height > m_size.y) height = m_size.y - destY; diff --git a/src/SFML/Graphics/ImageLoader.cpp b/src/SFML/Graphics/ImageLoader.cpp index a9e7475bf..d2b6f7ae8 100644 --- a/src/SFML/Graphics/ImageLoader.cpp +++ b/src/SFML/Graphics/ImageLoader.cpp @@ -50,25 +50,25 @@ namespace // stb_image callbacks that operate on a sf::InputStream int read(void* user, char* data, int size) { - sf::InputStream* stream = static_cast(user); + auto* stream = static_cast(user); return static_cast(stream->read(data, size)); } void skip(void* user, int size) { - sf::InputStream* stream = static_cast(user); + auto* stream = static_cast(user); stream->seek(stream->tell() + size); } int eof(void* user) { - sf::InputStream* stream = static_cast(user); + auto* stream = static_cast(user); return stream->tell() >= stream->getSize(); } // stb_image callback for constructing a buffer void bufferFromCallback(void* context, void* data, int size) { - sf::Uint8* source = static_cast(data); - std::vector* dest = static_cast*>(context); + auto* source = static_cast(data); + auto* dest = static_cast*>(context); std::copy(source, source + size, std::back_inserter(*dest)); } } @@ -154,7 +154,7 @@ bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, st int width = 0; int height = 0; int channels = 0; - const unsigned char* buffer = static_cast(data); + const auto* buffer = static_cast(data); unsigned char* ptr = stbi_load_from_memory(buffer, static_cast(dataSize), &width, &height, &channels, STBI_rgb_alpha); if (ptr) diff --git a/src/SFML/Graphics/RenderTextureImplFBO.cpp b/src/SFML/Graphics/RenderTextureImplFBO.cpp index c3592867d..b58a06925 100644 --- a/src/SFML/Graphics/RenderTextureImplFBO.cpp +++ b/src/SFML/Graphics/RenderTextureImplFBO.cpp @@ -66,7 +66,7 @@ namespace { if (it->first == contextId) { - GLuint frameBuffer = static_cast(it->second); + auto frameBuffer = static_cast(it->second); glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer)); staleFrameBuffers.erase(it++); diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 156014261..c65e243a6 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -968,7 +968,7 @@ void Shader::bindTextures() const auto it = m_textures.begin(); for (std::size_t i = 0; i < m_textures.size(); ++i) { - GLint index = static_cast(i + 1); + auto index = static_cast(i + 1); glCheck(GLEXT_glUniform1i(it->first, index)); glCheck(GLEXT_glActiveTexture(GLEXT_GL_TEXTURE0 + static_cast(index))); Texture::bind(it->second); diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp index 96e5fe97c..43ab2e7eb 100644 --- a/src/SFML/Graphics/Shape.cpp +++ b/src/SFML/Graphics/Shape.cpp @@ -237,7 +237,7 @@ void Shape::updateFillColors() //////////////////////////////////////////////////////////// void Shape::updateTexCoords() { - FloatRect convertedTextureRect = FloatRect(m_textureRect); + FloatRect convertedTextureRect(m_textureRect); for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i) { diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp index 37d69bcad..926cf7eeb 100644 --- a/src/SFML/Graphics/Sprite.cpp +++ b/src/SFML/Graphics/Sprite.cpp @@ -124,8 +124,8 @@ const Color& Sprite::getColor() const //////////////////////////////////////////////////////////// FloatRect Sprite::getLocalBounds() const { - float width = static_cast(std::abs(m_textureRect.width)); - float height = static_cast(std::abs(m_textureRect.height)); + auto width = static_cast(std::abs(m_textureRect.width)); + auto height = static_cast(std::abs(m_textureRect.height)); return FloatRect(0.f, 0.f, width, height); } @@ -165,7 +165,7 @@ void Sprite::updatePositions() //////////////////////////////////////////////////////////// void Sprite::updateTexCoords() { - FloatRect convertedTextureRect = FloatRect(m_textureRect); + FloatRect convertedTextureRect(m_textureRect); float left = convertedTextureRect.left; float right = left + convertedTextureRect.width; diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index f6abfdf36..b22ee2c8e 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -434,11 +434,11 @@ void Text::ensureGeometryUpdate() const whitespaceWidth += letterSpacing; float lineSpacing = m_font->getLineSpacing(m_characterSize) * m_lineSpacingFactor; float x = 0.f; - float y = static_cast(m_characterSize); + auto y = static_cast(m_characterSize); // Create one quad for each character - float minX = static_cast(m_characterSize); - float minY = static_cast(m_characterSize); + auto minX = static_cast(m_characterSize); + auto minY = static_cast(m_characterSize); float maxX = 0.f; float maxY = 0.f; Uint32 prevChar = 0; diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index be8102262..535599107 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -412,7 +412,7 @@ Packet& Packet::operator <<(Uint8 data) //////////////////////////////////////////////////////////// Packet& Packet::operator <<(Int16 data) { - Int16 toWrite = static_cast(htons(static_cast(data))); + auto toWrite = static_cast(htons(static_cast(data))); append(&toWrite, sizeof(toWrite)); return *this; } @@ -507,7 +507,7 @@ Packet& Packet::operator <<(double data) Packet& Packet::operator <<(const char* data) { // First insert string length - Uint32 length = static_cast(std::strlen(data)); + auto length = static_cast(std::strlen(data)); *this << length; // Then insert characters @@ -521,7 +521,7 @@ Packet& Packet::operator <<(const char* data) Packet& Packet::operator <<(const std::string& data) { // First insert string length - Uint32 length = static_cast(data.size()); + auto length = static_cast(data.size()); *this << length; // Then insert characters @@ -536,7 +536,7 @@ Packet& Packet::operator <<(const std::string& data) Packet& Packet::operator <<(const wchar_t* data) { // First insert string length - Uint32 length = static_cast(std::wcslen(data)); + auto length = static_cast(std::wcslen(data)); *this << length; // Then insert characters @@ -551,7 +551,7 @@ Packet& Packet::operator <<(const wchar_t* data) Packet& Packet::operator <<(const std::wstring& data) { // First insert string length - Uint32 length = static_cast(data.size()); + auto length = static_cast(data.size()); *this << length; // Then insert characters @@ -569,7 +569,7 @@ Packet& Packet::operator <<(const std::wstring& data) Packet& Packet::operator <<(const String& data) { // First insert the string length - Uint32 length = static_cast(data.getSize()); + auto length = static_cast(data.getSize()); *this << length; // Then insert characters diff --git a/src/SFML/System/Err.cpp b/src/SFML/System/Err.cpp index 4dc2f5094..9296a6b11 100644 --- a/src/SFML/System/Err.cpp +++ b/src/SFML/System/Err.cpp @@ -83,7 +83,7 @@ private: if (pbase() != pptr()) { // Print the contents of the write buffer into the standard error output - std::size_t size = static_cast(pptr() - pbase()); + auto size = static_cast(pptr() - pbase()); fwrite(pbase(), 1, size, stderr); // Reset the pointer position to the beginning of the write buffer diff --git a/src/SFML/System/Unix/ThreadImpl.cpp b/src/SFML/System/Unix/ThreadImpl.cpp index a169f3740..343d0d18a 100644 --- a/src/SFML/System/Unix/ThreadImpl.cpp +++ b/src/SFML/System/Unix/ThreadImpl.cpp @@ -76,7 +76,7 @@ void ThreadImpl::terminate() void* ThreadImpl::entryPoint(void* userData) { // The Thread instance is stored in the user data - Thread* owner = static_cast(userData); + auto* owner = static_cast(userData); #ifndef SFML_SYSTEM_ANDROID // Tell the thread to handle cancel requests immediately diff --git a/src/SFML/System/Win32/ThreadImpl.cpp b/src/SFML/System/Win32/ThreadImpl.cpp index 01b051436..aec029b83 100644 --- a/src/SFML/System/Win32/ThreadImpl.cpp +++ b/src/SFML/System/Win32/ThreadImpl.cpp @@ -77,7 +77,7 @@ void ThreadImpl::terminate() unsigned int __stdcall ThreadImpl::entryPoint(void* userData) { // The Thread instance is stored in the user data - Thread* owner = static_cast(userData); + auto* owner = static_cast(userData); // Forward to the owner owner->run(); diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index 2250128ed..05dd56d95 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -239,9 +239,9 @@ namespace { extensions.clear(); - glGetErrorFuncType glGetErrorFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetError")); - glGetIntegervFuncType glGetIntegervFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetIntegerv")); - glGetStringFuncType glGetStringFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetString")); + auto glGetErrorFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetError")); + auto glGetIntegervFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetIntegerv")); + auto glGetStringFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetString")); if (!glGetErrorFunc || !glGetIntegervFunc || !glGetStringFunc) return; @@ -250,7 +250,7 @@ namespace int majorVersion = 0; glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion); - glGetStringiFuncType glGetStringiFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetStringi")); + auto glGetStringiFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetStringi")); if (glGetErrorFunc() == GL_INVALID_ENUM || !glGetStringiFunc) { @@ -754,11 +754,11 @@ void GlContext::initialize(const ContextSettings& requestedSettings) int minorVersion = 0; // Try the new way first - glGetIntegervFuncType glGetIntegervFunc = reinterpret_cast(getFunction("glGetIntegerv")); - glGetErrorFuncType glGetErrorFunc = reinterpret_cast(getFunction("glGetError")); - glGetStringFuncType glGetStringFunc = reinterpret_cast(getFunction("glGetString")); - glEnableFuncType glEnableFunc = reinterpret_cast(getFunction("glEnable")); - glIsEnabledFuncType glIsEnabledFunc = reinterpret_cast(getFunction("glIsEnabled")); + auto glGetIntegervFunc = reinterpret_cast(getFunction("glGetIntegerv")); + auto glGetErrorFunc = reinterpret_cast(getFunction("glGetError")); + auto glGetStringFunc = reinterpret_cast(getFunction("glGetString")); + auto glEnableFunc = reinterpret_cast(getFunction("glEnable")); + auto glIsEnabledFunc = reinterpret_cast(getFunction("glIsEnabled")); if (!glGetIntegervFunc || !glGetErrorFunc || !glGetStringFunc || !glEnableFunc || !glIsEnabledFunc) { @@ -837,7 +837,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings) { m_settings.attributeFlags |= ContextSettings::Core; - glGetStringiFuncType glGetStringiFunc = reinterpret_cast(getFunction("glGetStringi")); + auto glGetStringiFunc = reinterpret_cast(getFunction("glGetStringi")); if (glGetStringiFunc) { @@ -901,7 +901,7 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings) { // Perform checks to inform the user if they are getting a context they might not have expected - glGetStringFuncType glGetStringFunc = reinterpret_cast(getFunction("glGetString")); + auto glGetStringFunc = reinterpret_cast(getFunction("glGetString")); if (!glGetStringFunc) { diff --git a/src/SFML/Window/Unix/VulkanImplX11.cpp b/src/SFML/Window/Unix/VulkanImplX11.cpp index 1bd5701f8..2f0cdb07b 100644 --- a/src/SFML/Window/Unix/VulkanImplX11.cpp +++ b/src/SFML/Window/Unix/VulkanImplX11.cpp @@ -201,7 +201,7 @@ bool VulkanImplX11::createVulkanSurface(const VkInstance& instance, WindowHandle // Make a copy of the instance handle since we get it passed as a reference VkInstance inst = instance; - PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = reinterpret_cast(wrapper.vkGetInstanceProcAddr(inst, "vkCreateXlibSurfaceKHR")); + auto vkCreateXlibSurfaceKHR = reinterpret_cast(wrapper.vkGetInstanceProcAddr(inst, "vkCreateXlibSurfaceKHR")); if (!vkCreateXlibSurfaceKHR) return false; diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 5b4227252..bbf339023 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -1002,7 +1002,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 { // X11 wants BGRA pixels: swap red and blue channels // Note: this memory will be freed by XDestroyImage - Uint8* iconPixels = static_cast(std::malloc(width * height * 4)); + auto* iconPixels = static_cast(std::malloc(width * height * 4)); for (std::size_t i = 0; i < width * height; ++i) { iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; @@ -1013,7 +1013,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 // Create the icon pixmap Visual* defVisual = DefaultVisual(m_display, m_screen); - unsigned int defDepth = static_cast(DefaultDepth(m_display, m_screen)); + auto defDepth = static_cast(DefaultDepth(m_display, m_screen)); XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, reinterpret_cast(iconPixels), width, height, 32, 0); if (!iconImage) { diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp index 22ecc896b..73db3091d 100644 --- a/src/SFML/Window/Win32/JoystickImpl.cpp +++ b/src/SFML/Window/Win32/JoystickImpl.cpp @@ -404,7 +404,7 @@ void JoystickImpl::initializeDInput() { // Try to get the address of the DirectInput8Create entry point using DirectInput8CreateFunc = HRESULT (*)(HINSTANCE, DWORD, const IID &, LPVOID *, LPUNKNOWN); - DirectInput8CreateFunc directInput8Create = reinterpret_cast(reinterpret_cast(GetProcAddress(dinput8dll, "DirectInput8Create"))); + auto directInput8Create = reinterpret_cast(reinterpret_cast(GetProcAddress(dinput8dll, "DirectInput8Create"))); if (directInput8Create) { diff --git a/src/SFML/Window/Win32/VulkanImplWin32.cpp b/src/SFML/Window/Win32/VulkanImplWin32.cpp index 082487264..633b741bf 100644 --- a/src/SFML/Window/Win32/VulkanImplWin32.cpp +++ b/src/SFML/Window/Win32/VulkanImplWin32.cpp @@ -203,7 +203,7 @@ bool VulkanImplWin32::createVulkanSurface(const VkInstance& instance, WindowHand // Make a copy of the instance handle since we get it passed as a reference VkInstance inst = instance; - PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = reinterpret_cast(wrapper.vkGetInstanceProcAddr(inst, "vkCreateWin32SurfaceKHR")); + auto vkCreateWin32SurfaceKHR = reinterpret_cast(wrapper.vkGetInstanceProcAddr(inst, "vkCreateWin32SurfaceKHR")); if (!vkCreateWin32SurfaceKHR) return false; diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 2ce273236..ed7f9c8e5 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -192,12 +192,12 @@ WglContext::~WglContext() //////////////////////////////////////////////////////////// GlFunctionPointer WglContext::getFunction(const char* name) { - GlFunctionPointer address = reinterpret_cast(wglGetProcAddress(reinterpret_cast(name))); + auto address = reinterpret_cast(wglGetProcAddress(reinterpret_cast(name))); if (address) { // Test whether the returned value is a valid error code - ptrdiff_t errorCode = reinterpret_cast(address); + auto errorCode = reinterpret_cast(address); if ((errorCode != -1) && (errorCode != 1) && (errorCode != 2) && (errorCode != 3)) return address; diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 69ccfb7ab..69fc1117a 100755 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -86,7 +86,7 @@ namespace }; using SetProcessDpiAwarenessFuncType = HRESULT (*)(ProcessDpiAwareness); - SetProcessDpiAwarenessFuncType SetProcessDpiAwarenessFunc = reinterpret_cast(reinterpret_cast(GetProcAddress(shCoreDll, "SetProcessDpiAwareness"))); + auto SetProcessDpiAwarenessFunc = reinterpret_cast(reinterpret_cast(GetProcAddress(shCoreDll, "SetProcessDpiAwareness"))); if (SetProcessDpiAwarenessFunc) { @@ -114,7 +114,7 @@ namespace if (user32Dll) { using SetProcessDPIAwareFuncType = BOOL (*)(); - SetProcessDPIAwareFuncType SetProcessDPIAwareFunc = reinterpret_cast(reinterpret_cast(GetProcAddress(user32Dll, "SetProcessDPIAware"))); + auto SetProcessDPIAwareFunc = reinterpret_cast(reinterpret_cast(GetProcAddress(user32Dll, "SetProcessDPIAware"))); if (SetProcessDPIAwareFunc) { @@ -658,7 +658,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) { // We override the returned information to remove the default limit // (the OS doesn't allow windows bigger than the desktop by default) - MINMAXINFO* info = reinterpret_cast(lParam); + auto* info = reinterpret_cast(lParam); info->ptMaxTrackSize.x = 50000; info->ptMaxTrackSize.y = 50000; break; @@ -694,7 +694,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) if (m_keyRepeatEnabled || ((lParam & (1 << 30)) == 0)) { // Get the code of the typed character - Uint32 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)) @@ -765,7 +765,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) position.y = static_cast(HIWORD(lParam)); ScreenToClient(m_handle, &position); - Int16 delta = static_cast(HIWORD(wParam)); + auto delta = static_cast(HIWORD(wParam)); Event event; @@ -793,7 +793,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) position.y = static_cast(HIWORD(lParam)); ScreenToClient(m_handle, &position); - Int16 delta = static_cast(HIWORD(wParam)); + auto delta = static_cast(HIWORD(wParam)); Event event; event.type = Event::MouseWheelScrolled; @@ -991,7 +991,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam) if ((wParam == DBT_DEVICEARRIVAL) || (wParam == DBT_DEVICEREMOVECOMPLETE)) { // Some sort of device change has happened, update joystick connections if it is a device interface - DEV_BROADCAST_HDR* deviceBroadcastHeader = reinterpret_cast(lParam); + auto* deviceBroadcastHeader = reinterpret_cast(lParam); if (deviceBroadcastHeader && (deviceBroadcastHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)) JoystickImpl::updateConnections(); @@ -1131,7 +1131,7 @@ LRESULT CALLBACK WindowImplWin32::globalOnEvent(HWND handle, UINT message, WPARA if (message == WM_CREATE) { // Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow) - LONG_PTR window = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); + auto window = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); // Set as the "user data" parameter of the window SetWindowLongPtrW(handle, GWLP_USERDATA, window); diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 15ddc3027..e7933c86a 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -205,7 +205,7 @@ void WindowImpl::processJoystickEvents() { if (caps.axes[j]) { - Joystick::Axis axis = static_cast(j); + auto axis = static_cast(j); float prevPos = m_previousAxes[i][axis]; float currPos = m_joystickStates[i].axes[axis]; if (std::abs(currPos - prevPos) >= m_joystickThreshold) @@ -250,7 +250,7 @@ void WindowImpl::processSensorEvents() for (unsigned int i = 0; i < Sensor::Count; ++i) { - Sensor::Type sensor = static_cast(i); + auto sensor = static_cast(i); // Only process enabled sensors if (SensorManager::getInstance().isEnabled(sensor))