From 05690b963df9a62bd00d245447f0d440229e3732 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 12 Sep 2022 15:44:40 -0600 Subject: [PATCH] Replace `sf::Int64` with `std::int64_t` --- examples/voip/Server.cpp | 2 +- include/SFML/Audio/Music.hpp | 2 +- include/SFML/Audio/SoundStream.hpp | 4 ++-- include/SFML/Config.hpp | 1 - include/SFML/Network/Packet.hpp | 4 ++-- include/SFML/System/FileInputStream.hpp | 8 +++---- include/SFML/System/InputStream.hpp | 16 +++++++------- include/SFML/System/MemoryInputStream.hpp | 14 ++++++------- include/SFML/System/Time.hpp | 18 ++++++++-------- include/SFML/System/Time.inl | 14 ++++++------- src/SFML/Audio/Music.cpp | 8 +++---- src/SFML/Audio/SoundFileReaderFlac.cpp | 8 +++---- src/SFML/Audio/SoundFileReaderMp3.cpp | 6 +++--- src/SFML/Audio/SoundFileReaderOgg.cpp | 2 +- src/SFML/Audio/SoundFileReaderWav.cpp | 21 ++++++++++--------- src/SFML/Audio/SoundStream.cpp | 4 ++-- src/SFML/Graphics/Font.cpp | 5 +++-- src/SFML/Graphics/Shader.cpp | 8 +++---- src/SFML/Network/Packet.cpp | 12 +++++------ src/SFML/System/Android/ResourceStream.cpp | 8 +++---- src/SFML/System/Android/ResourceStream.hpp | 8 +++---- src/SFML/System/FileInputStream.cpp | 14 ++++++------- src/SFML/System/MemoryInputStream.cpp | 14 ++++++------- src/SFML/System/Unix/SleepImpl.cpp | 2 +- src/SFML/Window/Android/WindowImplAndroid.cpp | 4 ++-- test/Network/Packet.cpp | 10 ++++----- test/System/Config.cpp | 1 - test/System/Time.cpp | 16 +++++++------- 28 files changed, 117 insertions(+), 117 deletions(-) diff --git a/examples/voip/Server.cpp b/examples/voip/Server.cpp index 214fe8d68..cdf893a78 100644 --- a/examples/voip/Server.cpp +++ b/examples/voip/Server.cpp @@ -82,7 +82,7 @@ private: // (don't forget that we run in two separate threads) { std::scoped_lock lock(m_mutex); - m_tempBuffer.assign(m_samples.begin() + static_cast::difference_type>(m_offset), + m_tempBuffer.assign(m_samples.begin() + static_cast::difference_type>(m_offset), m_samples.end()); } diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp index 20f0069fa..76b57da1d 100644 --- a/include/SFML/Audio/Music.hpp +++ b/include/SFML/Audio/Music.hpp @@ -239,7 +239,7 @@ protected: /// \return The seek position after looping (or -1 if there's no loop) /// //////////////////////////////////////////////////////////// - Int64 onLoop() override; + std::int64_t onLoop() override; private: //////////////////////////////////////////////////////////// diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 2dd2ddd44..24e3d9565 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -249,7 +249,7 @@ protected: /// \return The seek position after looping (or -1 if there's no loop) /// //////////////////////////////////////////////////////////// - virtual Int64 onLoop(); + virtual std::int64_t onLoop(); //////////////////////////////////////////////////////////// /// \brief Set the processing interval @@ -347,7 +347,7 @@ private: std::int32_t m_format; //!< Format of the internal sound buffers bool m_loop; //!< Loop flag (true to loop, false to play once) Uint64 m_samplesProcessed; //!< Number of samples processed since beginning of the stream - Int64 m_bufferSeeks[BufferCount]; //!< If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation. + std::int64_t m_bufferSeeks[BufferCount]; //!< If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation. Time m_processingInterval; //!< Interval for checking and filling the internal sound buffers. }; diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 9cc833b8f..39648c6fc 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -168,7 +168,6 @@ namespace sf { // 64 bits integer types -using Int64 = std::int64_t; using Uint64 = std::uint64_t; } // namespace sf diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index 93346b84a..01ba3bef6 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -243,7 +243,7 @@ public: //////////////////////////////////////////////////////////// /// \overload //////////////////////////////////////////////////////////// - Packet& operator>>(Int64& data); + Packet& operator>>(std::int64_t& data); //////////////////////////////////////////////////////////// /// \overload @@ -324,7 +324,7 @@ public: //////////////////////////////////////////////////////////// /// \overload //////////////////////////////////////////////////////////// - Packet& operator<<(Int64 data); + Packet& operator<<(std::int64_t data); //////////////////////////////////////////////////////////// /// \overload diff --git a/include/SFML/System/FileInputStream.hpp b/include/SFML/System/FileInputStream.hpp index f704efa5d..302236601 100644 --- a/include/SFML/System/FileInputStream.hpp +++ b/include/SFML/System/FileInputStream.hpp @@ -114,7 +114,7 @@ public: /// \return The number of bytes actually read, or -1 on error /// //////////////////////////////////////////////////////////// - [[nodiscard]] Int64 read(void* data, Int64 size) override; + [[nodiscard]] std::int64_t read(void* data, std::int64_t size) override; //////////////////////////////////////////////////////////// /// \brief Change the current reading position @@ -124,7 +124,7 @@ public: /// \return The position actually sought to, or -1 on error /// //////////////////////////////////////////////////////////// - [[nodiscard]] Int64 seek(Int64 position) override; + [[nodiscard]] std::int64_t seek(std::int64_t position) override; //////////////////////////////////////////////////////////// /// \brief Get the current reading position in the stream @@ -132,7 +132,7 @@ public: /// \return The current position, or -1 on error. /// //////////////////////////////////////////////////////////// - [[nodiscard]] Int64 tell() override; + [[nodiscard]] std::int64_t tell() override; //////////////////////////////////////////////////////////// /// \brief Return the size of the stream @@ -140,7 +140,7 @@ public: /// \return The total number of bytes available in the stream, or -1 on error /// //////////////////////////////////////////////////////////// - Int64 getSize() override; + std::int64_t getSize() override; private: //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/InputStream.hpp b/include/SFML/System/InputStream.hpp index 74997d7a2..c91c84f77 100644 --- a/include/SFML/System/InputStream.hpp +++ b/include/SFML/System/InputStream.hpp @@ -62,7 +62,7 @@ public: /// \return The number of bytes actually read, or -1 on error /// //////////////////////////////////////////////////////////// - [[nodiscard]] virtual Int64 read(void* data, Int64 size) = 0; + [[nodiscard]] virtual std::int64_t read(void* data, std::int64_t size) = 0; //////////////////////////////////////////////////////////// /// \brief Change the current reading position @@ -72,7 +72,7 @@ public: /// \return The position actually sought to, or -1 on error /// //////////////////////////////////////////////////////////// - [[nodiscard]] virtual Int64 seek(Int64 position) = 0; + [[nodiscard]] virtual std::int64_t seek(std::int64_t position) = 0; //////////////////////////////////////////////////////////// /// \brief Get the current reading position in the stream @@ -80,7 +80,7 @@ public: /// \return The current position, or -1 on error. /// //////////////////////////////////////////////////////////// - [[nodiscard]] virtual Int64 tell() = 0; + [[nodiscard]] virtual std::int64_t tell() = 0; //////////////////////////////////////////////////////////// /// \brief Return the size of the stream @@ -88,7 +88,7 @@ public: /// \return The total number of bytes available in the stream, or -1 on error /// //////////////////////////////////////////////////////////// - virtual Int64 getSize() = 0; + virtual std::int64_t getSize() = 0; }; } // namespace sf @@ -123,13 +123,13 @@ public: /// /// [[nodiscard]] bool open(const std::filesystem::path& filename); /// -/// [[nodiscard]] Int64 read(void* data, Int64 size); +/// [[nodiscard]] std::int64_t read(void* data, std::int64_t size); /// -/// [[nodiscard]] Int64 seek(Int64 position); +/// [[nodiscard]] std::int64_t seek(std::int64_t position); /// -/// [[nodiscard]] Int64 tell(); +/// [[nodiscard]] std::int64_t tell(); /// -/// Int64 getSize(); +/// std::int64_t getSize(); /// /// private: /// diff --git a/include/SFML/System/MemoryInputStream.hpp b/include/SFML/System/MemoryInputStream.hpp index 4dd0df5ea..3112f66ee 100644 --- a/include/SFML/System/MemoryInputStream.hpp +++ b/include/SFML/System/MemoryInputStream.hpp @@ -73,7 +73,7 @@ public: /// \return The number of bytes actually read, or -1 on error /// //////////////////////////////////////////////////////////// - [[nodiscard]] Int64 read(void* data, Int64 size) override; + [[nodiscard]] std::int64_t read(void* data, std::int64_t size) override; //////////////////////////////////////////////////////////// /// \brief Change the current reading position @@ -83,7 +83,7 @@ public: /// \return The position actually sought to, or -1 on error /// //////////////////////////////////////////////////////////// - [[nodiscard]] Int64 seek(Int64 position) override; + [[nodiscard]] std::int64_t seek(std::int64_t position) override; //////////////////////////////////////////////////////////// /// \brief Get the current reading position in the stream @@ -91,7 +91,7 @@ public: /// \return The current position, or -1 on error. /// //////////////////////////////////////////////////////////// - [[nodiscard]] Int64 tell() override; + [[nodiscard]] std::int64_t tell() override; //////////////////////////////////////////////////////////// /// \brief Return the size of the stream @@ -99,15 +99,15 @@ public: /// \return The total number of bytes available in the stream, or -1 on error /// //////////////////////////////////////////////////////////// - Int64 getSize() override; + std::int64_t getSize() override; private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - const char* m_data; //!< Pointer to the data in memory - Int64 m_size; //!< Total size of the data - Int64 m_offset; //!< Current reading position + const char* m_data; //!< Pointer to the data in memory + std::int64_t m_size; //!< Total size of the data + std::int64_t m_offset; //!< Current reading position }; } // namespace sf diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp index 44aa99d72..4654739a1 100644 --- a/include/SFML/System/Time.hpp +++ b/include/SFML/System/Time.hpp @@ -85,7 +85,7 @@ public: /// \see asSeconds, asMilliseconds /// //////////////////////////////////////////////////////////// - constexpr Int64 asMicroseconds() const; + constexpr std::int64_t asMicroseconds() const; //////////////////////////////////////////////////////////// /// \brief Return the time value as a std::chorono::duration @@ -112,7 +112,7 @@ public: private: friend constexpr Time seconds(float); friend constexpr Time milliseconds(std::int32_t); - friend constexpr Time microseconds(Int64); + friend constexpr Time microseconds(std::int64_t); private: //////////////////////////////////////////////////////////// @@ -158,7 +158,7 @@ constexpr Time milliseconds(std::int32_t amount); /// \see seconds, milliseconds /// //////////////////////////////////////////////////////////// -constexpr Time microseconds(Int64 amount); +constexpr Time microseconds(std::int64_t amount); //////////////////////////////////////////////////////////// /// \relates Time @@ -313,7 +313,7 @@ constexpr Time& operator-=(Time& left, Time right); /// \return \a left multiplied by \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] constexpr Time operator*(Time left, Int64 right); +[[nodiscard]] constexpr Time operator*(Time left, std::int64_t right); //////////////////////////////////////////////////////////// /// \relates Time @@ -337,7 +337,7 @@ constexpr Time& operator-=(Time& left, Time right); /// \return \a left multiplied by \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] constexpr Time operator*(Int64 left, Time right); +[[nodiscard]] constexpr Time operator*(std::int64_t left, Time right); //////////////////////////////////////////////////////////// /// \relates Time @@ -361,7 +361,7 @@ constexpr Time& operator*=(Time& left, float right); /// \return \a left multiplied by \a right /// //////////////////////////////////////////////////////////// -constexpr Time& operator*=(Time& left, Int64 right); +constexpr Time& operator*=(Time& left, std::int64_t right); //////////////////////////////////////////////////////////// /// \relates Time @@ -385,7 +385,7 @@ constexpr Time& operator*=(Time& left, Int64 right); /// \return \a left divided by \a right /// //////////////////////////////////////////////////////////// -[[nodiscard]] constexpr Time operator/(Time left, Int64 right); +[[nodiscard]] constexpr Time operator/(Time left, std::int64_t right); //////////////////////////////////////////////////////////// /// \relates Time @@ -409,7 +409,7 @@ constexpr Time& operator/=(Time& left, float right); /// \return \a left divided by \a right /// //////////////////////////////////////////////////////////// -constexpr Time& operator/=(Time& left, Int64 right); +constexpr Time& operator/=(Time& left, std::int64_t right); //////////////////////////////////////////////////////////// /// \relates Time @@ -485,7 +485,7 @@ constexpr Time& operator%=(Time& left, Time right); /// std::int32_t milli = t1.asMilliseconds(); // 100 /// /// sf::Time t2 = sf::milliseconds(30); -/// Int64 micro = t2.asMicroseconds(); // 30000 +/// std::int64_t micro = t2.asMicroseconds(); // 30000 /// /// sf::Time t3 = sf::microseconds(-800000); /// float sec = t3.asSeconds(); // -0.8 diff --git a/include/SFML/System/Time.inl b/include/SFML/System/Time.inl index f776490cb..9dbc25a31 100644 --- a/include/SFML/System/Time.inl +++ b/include/SFML/System/Time.inl @@ -51,7 +51,7 @@ constexpr std::int32_t Time::asMilliseconds() const //////////////////////////////////////////////////////////// -constexpr Int64 Time::asMicroseconds() const +constexpr std::int64_t Time::asMicroseconds() const { return m_microseconds.count(); } @@ -87,7 +87,7 @@ constexpr Time milliseconds(std::int32_t amount) //////////////////////////////////////////////////////////// -constexpr Time microseconds(Int64 amount) +constexpr Time microseconds(std::int64_t amount) { return Time(std::chrono::microseconds(amount)); } @@ -178,7 +178,7 @@ constexpr Time operator*(Time left, float right) //////////////////////////////////////////////////////////// -constexpr Time operator*(Time left, Int64 right) +constexpr Time operator*(Time left, std::int64_t right) { return microseconds(left.asMicroseconds() * right); } @@ -192,7 +192,7 @@ constexpr Time operator*(float left, Time right) //////////////////////////////////////////////////////////// -constexpr Time operator*(Int64 left, Time right) +constexpr Time operator*(std::int64_t left, Time right) { return right * left; } @@ -206,7 +206,7 @@ constexpr Time& operator*=(Time& left, float right) //////////////////////////////////////////////////////////// -constexpr Time& operator*=(Time& left, Int64 right) +constexpr Time& operator*=(Time& left, std::int64_t right) { return left = left * right; } @@ -220,7 +220,7 @@ constexpr Time operator/(Time left, float right) //////////////////////////////////////////////////////////// -constexpr Time operator/(Time left, Int64 right) +constexpr Time operator/(Time left, std::int64_t right) { return microseconds(left.asMicroseconds() / right); } @@ -234,7 +234,7 @@ constexpr Time& operator/=(Time& left, float right) //////////////////////////////////////////////////////////// -constexpr Time& operator/=(Time& left, Int64 right) +constexpr Time& operator/=(Time& left, std::int64_t right) { return left = left / right; } diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index a06053967..f3d0d5f95 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -214,7 +214,7 @@ void Music::onSeek(Time timeOffset) //////////////////////////////////////////////////////////// -Int64 Music::onLoop() +std::int64_t Music::onLoop() { // Called by underlying SoundStream so we can determine where to loop. std::scoped_lock lock(m_mutex); @@ -224,7 +224,7 @@ Int64 Music::onLoop() // Looping is enabled, and either we're at the loop end, or we're at the EOF // when it's equivalent to the loop end (loop end takes priority). Send us to loop begin m_file.seek(m_loopSpan.offset); - return static_cast(m_file.getSampleOffset()); + return static_cast(m_file.getSampleOffset()); } else if (getLoop() && (currentOffset >= m_file.getSampleCount())) { @@ -256,7 +256,7 @@ Uint64 Music::timeToSamples(Time position) const // Always ROUND, no unchecked truncation, hence the addition in the numerator. // This avoids most precision errors arising from "samples => Time => samples" conversions // Original rounding calculation is ((Micros * Freq * Channels) / 1000000) + 0.5 - // We refactor it to keep Int64 as the data type throughout the whole operation. + // We refactor it to keep std::int64_t as the data type throughout the whole operation. return ((static_cast(position.asMicroseconds()) * getSampleRate() * getChannelCount()) + 500000) / 1000000; } @@ -268,7 +268,7 @@ Time Music::samplesToTime(Uint64 samples) const // Make sure we don't divide by 0 if (getSampleRate() != 0 && getChannelCount() != 0) - position = microseconds(static_cast((samples * 1000000) / (getChannelCount() * getSampleRate()))); + position = microseconds(static_cast((samples * 1000000) / (getChannelCount() * getSampleRate()))); return position; } diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp index d70ddda3f..36659b329 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.cpp +++ b/src/SFML/Audio/SoundFileReaderFlac.cpp @@ -39,7 +39,7 @@ FLAC__StreamDecoderReadStatus streamRead(const FLAC__StreamDecoder*, FLAC__byte { auto* data = static_cast(clientData); - sf::Int64 count = data->stream->read(buffer, static_cast(*bytes)); + std::int64_t count = data->stream->read(buffer, static_cast(*bytes)); if (count > 0) { *bytes = static_cast(count); @@ -59,7 +59,7 @@ FLAC__StreamDecoderSeekStatus streamSeek(const FLAC__StreamDecoder*, FLAC__uint6 { auto* data = static_cast(clientData); - sf::Int64 position = data->stream->seek(static_cast(absoluteByteOffset)); + std::int64_t position = data->stream->seek(static_cast(absoluteByteOffset)); if (position >= 0) return FLAC__STREAM_DECODER_SEEK_STATUS_OK; else @@ -70,7 +70,7 @@ FLAC__StreamDecoderTellStatus streamTell(const FLAC__StreamDecoder*, FLAC__uint6 { auto* data = static_cast(clientData); - sf::Int64 position = data->stream->tell(); + std::int64_t position = data->stream->tell(); if (position >= 0) { *absoluteByteOffset = static_cast(position); @@ -86,7 +86,7 @@ FLAC__StreamDecoderLengthStatus streamLength(const FLAC__StreamDecoder*, FLAC__u { auto* data = static_cast(clientData); - sf::Int64 count = data->stream->getSize(); + std::int64_t count = data->stream->getSize(); if (count >= 0) { *streamLength = static_cast(count); diff --git a/src/SFML/Audio/SoundFileReaderMp3.cpp b/src/SFML/Audio/SoundFileReaderMp3.cpp index 3f0b3d950..9051eb016 100644 --- a/src/SFML/Audio/SoundFileReaderMp3.cpp +++ b/src/SFML/Audio/SoundFileReaderMp3.cpp @@ -57,13 +57,13 @@ namespace std::size_t readCallback(void* ptr, std::size_t size, void* data) { sf::InputStream* stream = static_cast(data); - return static_cast(stream->read(ptr, static_cast(size))); + return static_cast(stream->read(ptr, static_cast(size))); } int seekCallback(std::uint64_t offset, void* data) { sf::InputStream* stream = static_cast(data); - sf::Int64 position = stream->seek(static_cast(offset)); + std::int64_t position = stream->seek(static_cast(offset)); return position < 0 ? -1 : 0; } @@ -83,7 +83,7 @@ bool SoundFileReaderMp3::check(InputStream& stream) { std::uint8_t header[10]; - if (static_cast(stream.read(header, static_cast(sizeof(header)))) < sizeof(header)) + if (static_cast(stream.read(header, static_cast(sizeof(header)))) < sizeof(header)) return false; if (hasValidId3Tag(header)) diff --git a/src/SFML/Audio/SoundFileReaderOgg.cpp b/src/SFML/Audio/SoundFileReaderOgg.cpp index a197a0662..04d9144f1 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.cpp +++ b/src/SFML/Audio/SoundFileReaderOgg.cpp @@ -39,7 +39,7 @@ namespace std::size_t read(void* ptr, std::size_t size, std::size_t nmemb, void* data) { auto* stream = static_cast(data); - return static_cast(stream->read(ptr, static_cast(size * nmemb))); + return static_cast(stream->read(ptr, static_cast(size * nmemb))); } int seek(void* data, ogg_int64_t offset, int whence) diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index 172bd90f0..05a75b9b9 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -49,7 +49,7 @@ bool decode(sf::InputStream& stream, std::uint8_t& value) bool decode(sf::InputStream& stream, std::int16_t& value) { unsigned char bytes[sizeof(value)]; - if (static_cast(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) + if (static_cast(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) return false; value = static_cast(bytes[0] | (bytes[1] << 8)); @@ -60,7 +60,7 @@ bool decode(sf::InputStream& stream, std::int16_t& value) bool decode(sf::InputStream& stream, std::uint16_t& value) { unsigned char bytes[sizeof(value)]; - if (static_cast(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) + if (static_cast(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) return false; value = static_cast(bytes[0] | (bytes[1] << 8)); @@ -71,7 +71,7 @@ bool decode(sf::InputStream& stream, std::uint16_t& 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)) + 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)); @@ -82,7 +82,7 @@ bool decode24bit(sf::InputStream& stream, std::uint32_t& 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)) + 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)); @@ -109,7 +109,7 @@ namespace priv bool SoundFileReaderWav::check(InputStream& stream) { char header[mainChunkSize]; - if (stream.read(header, sizeof(header)) < static_cast(sizeof(header))) + if (stream.read(header, sizeof(header)) < static_cast(sizeof(header))) return false; return (header[0] == 'R') && (header[1] == 'I') && (header[2] == 'F') && (header[3] == 'F') && (header[8] == 'W') && @@ -143,7 +143,7 @@ void SoundFileReaderWav::seek(Uint64 sampleOffset) { assert(m_stream); - if (m_stream->seek(static_cast(m_dataStart + sampleOffset * m_bytesPerSample) == -1)) + if (m_stream->seek(static_cast(m_dataStart + sampleOffset * m_bytesPerSample) == -1)) err() << "Failed to seek WAV sound stream" << std::endl; } @@ -224,7 +224,8 @@ bool SoundFileReaderWav::parseHeader(Info& info) // If we are here, it means that the first part of the header // (the format) has already been checked char mainChunk[mainChunkSize]; - if (static_cast(m_stream->read(mainChunk, static_cast(sizeof(mainChunk)))) != sizeof(mainChunk)) + if (static_cast(m_stream->read(mainChunk, static_cast(sizeof(mainChunk)))) != + sizeof(mainChunk)) return false; // Parse all the sub-chunks @@ -233,13 +234,13 @@ bool SoundFileReaderWav::parseHeader(Info& info) { // Parse the sub-chunk id and size char subChunkId[4]; - if (static_cast(m_stream->read(subChunkId, static_cast(sizeof(subChunkId)))) != + if (static_cast(m_stream->read(subChunkId, static_cast(sizeof(subChunkId)))) != sizeof(subChunkId)) return false; std::uint32_t subChunkSize = 0; if (!decode(*m_stream, subChunkSize)) return false; - Int64 subChunkStart = m_stream->tell(); + std::int64_t subChunkStart = m_stream->tell(); if (subChunkStart == -1) return false; @@ -308,7 +309,7 @@ bool SoundFileReaderWav::parseHeader(Info& info) // Subformat char subformat[16]; - if (static_cast(m_stream->read(subformat, static_cast(sizeof(subformat)))) != + if (static_cast(m_stream->read(subformat, static_cast(sizeof(subformat)))) != sizeof(subformat)) return false; diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 144862355..385911c45 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -260,7 +260,7 @@ bool SoundStream::getLoop() const //////////////////////////////////////////////////////////// -Int64 SoundStream::onLoop() +std::int64_t SoundStream::onLoop() { onSeek(Time::Zero); return 0; @@ -290,7 +290,7 @@ void SoundStream::streamData() // Create the buffers alCheck(alGenBuffers(BufferCount, m_buffers)); - for (Int64& bufferSeek : m_bufferSeeks) + for (std::int64_t& bufferSeek : m_bufferSeeks) bufferSeek = NoLoop; // Fill the queue diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index b181f7ed0..b4f58fbdf 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -53,12 +53,13 @@ namespace // FreeType callbacks that operate on a sf::InputStream unsigned long read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count) { - auto convertedOffset = static_cast(offset); + auto convertedOffset = static_cast(offset); auto* stream = static_cast(rec->descriptor.pointer); if (stream->seek(convertedOffset) == convertedOffset) { if (count > 0) - return static_cast(stream->read(reinterpret_cast(buffer), static_cast(count))); + return static_cast( + stream->read(reinterpret_cast(buffer), static_cast(count))); else return 0; } diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 9a6d4cfc4..210cf7d4f 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -102,8 +102,8 @@ bool getFileContents(const std::filesystem::path& filename, std::vector& b // Read the contents of a stream into an array of char bool getStreamContents(sf::InputStream& stream, std::vector& buffer) { - bool success = true; - sf::Int64 size = stream.getSize(); + bool success = true; + std::int64_t size = stream.getSize(); if (size > 0) { buffer.resize(static_cast(size)); @@ -114,8 +114,8 @@ bool getStreamContents(sf::InputStream& stream, std::vector& buffer) return false; } - sf::Int64 read = stream.read(buffer.data(), size); - success = (read == size); + std::int64_t read = stream.read(buffer.data(), size); + success = (read == size); } buffer.push_back('\0'); return success; diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index 15bc1659f..d1a8bb5be 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -211,7 +211,7 @@ Packet& Packet::operator>>(std::uint32_t& data) //////////////////////////////////////////////////////////// -Packet& Packet::operator>>(Int64& data) +Packet& Packet::operator>>(std::int64_t& data) { if (checkSize(sizeof(data))) { @@ -220,10 +220,10 @@ Packet& Packet::operator>>(Int64& data) std::uint8_t bytes[sizeof(data)]; std::memcpy(bytes, &m_data[m_readPos], sizeof(data)); - data = (static_cast(bytes[0]) << 56) | (static_cast(bytes[1]) << 48) | - (static_cast(bytes[2]) << 40) | (static_cast(bytes[3]) << 32) | - (static_cast(bytes[4]) << 24) | (static_cast(bytes[5]) << 16) | - (static_cast(bytes[6]) << 8) | (static_cast(bytes[7])); + data = (static_cast(bytes[0]) << 56) | (static_cast(bytes[1]) << 48) | + (static_cast(bytes[2]) << 40) | (static_cast(bytes[3]) << 32) | + (static_cast(bytes[4]) << 24) | (static_cast(bytes[5]) << 16) | + (static_cast(bytes[6]) << 8) | (static_cast(bytes[7])); m_readPos += sizeof(data); } @@ -452,7 +452,7 @@ Packet& Packet::operator<<(std::uint32_t data) //////////////////////////////////////////////////////////// -Packet& Packet::operator<<(Int64 data) +Packet& Packet::operator<<(std::int64_t data) { // Since htonll is not available everywhere, we have to convert // to network byte order (big endian) manually diff --git a/src/SFML/System/Android/ResourceStream.cpp b/src/SFML/System/Android/ResourceStream.cpp index 443d14f6c..b686837e7 100644 --- a/src/SFML/System/Android/ResourceStream.cpp +++ b/src/SFML/System/Android/ResourceStream.cpp @@ -57,7 +57,7 @@ ResourceStream::~ResourceStream() //////////////////////////////////////////////////////////// -Int64 ResourceStream::read(void* data, Int64 size) +std::int64_t ResourceStream::read(void* data, std::int64_t size) { if (m_file) { @@ -71,7 +71,7 @@ Int64 ResourceStream::read(void* data, Int64 size) //////////////////////////////////////////////////////////// -Int64 ResourceStream::seek(Int64 position) +std::int64_t ResourceStream::seek(std::int64_t position) { if (m_file) { @@ -85,7 +85,7 @@ Int64 ResourceStream::seek(Int64 position) //////////////////////////////////////////////////////////// -Int64 ResourceStream::tell() +std::int64_t ResourceStream::tell() { if (m_file) { @@ -99,7 +99,7 @@ Int64 ResourceStream::tell() //////////////////////////////////////////////////////////// -Int64 ResourceStream::getSize() +std::int64_t ResourceStream::getSize() { if (m_file) { diff --git a/src/SFML/System/Android/ResourceStream.hpp b/src/SFML/System/Android/ResourceStream.hpp index da559fd0a..d2f95ec20 100644 --- a/src/SFML/System/Android/ResourceStream.hpp +++ b/src/SFML/System/Android/ResourceStream.hpp @@ -72,7 +72,7 @@ public: /// \return The number of bytes actually read, or -1 on error /// //////////////////////////////////////////////////////////// - Int64 read(void* data, Int64 size) override; + std::int64_t read(void* data, std::int64_t size) override; //////////////////////////////////////////////////////////// /// \brief Change the current reading position in the asset file @@ -82,7 +82,7 @@ public: /// \return The position actually sought to, or -1 on error /// //////////////////////////////////////////////////////////// - Int64 seek(Int64 position) override; + std::int64_t seek(std::int64_t position) override; //////////////////////////////////////////////////////////// /// \brief Get the current reading position in the asset file @@ -90,7 +90,7 @@ public: /// \return The current position, or -1 on error. /// //////////////////////////////////////////////////////////// - Int64 tell() override; + std::int64_t tell() override; //////////////////////////////////////////////////////////// /// \brief Return the size of the asset file @@ -98,7 +98,7 @@ public: /// \return The total number of bytes available in the asset, or -1 on error /// //////////////////////////////////////////////////////////// - Int64 getSize() override; + std::int64_t getSize() override; private: //////////////////////////////////////////////////////////// diff --git a/src/SFML/System/FileInputStream.cpp b/src/SFML/System/FileInputStream.cpp index a928ec84d..2f919ec28 100644 --- a/src/SFML/System/FileInputStream.cpp +++ b/src/SFML/System/FileInputStream.cpp @@ -77,13 +77,13 @@ bool FileInputStream::open(const std::filesystem::path& filename) //////////////////////////////////////////////////////////// -Int64 FileInputStream::read(void* data, Int64 size) +std::int64_t FileInputStream::read(void* data, std::int64_t size) { #ifdef SFML_SYSTEM_ANDROID return m_file->read(data, size); #else if (m_file) - return static_cast(std::fread(data, 1, static_cast(size), m_file.get())); + return static_cast(std::fread(data, 1, static_cast(size), m_file.get())); else return -1; #endif @@ -91,7 +91,7 @@ Int64 FileInputStream::read(void* data, Int64 size) //////////////////////////////////////////////////////////// -Int64 FileInputStream::seek(Int64 position) +std::int64_t FileInputStream::seek(std::int64_t position) { #ifdef SFML_SYSTEM_ANDROID return m_file->seek(position); @@ -112,7 +112,7 @@ Int64 FileInputStream::seek(Int64 position) //////////////////////////////////////////////////////////// -Int64 FileInputStream::tell() +std::int64_t FileInputStream::tell() { #ifdef SFML_SYSTEM_ANDROID return m_file->tell(); @@ -126,16 +126,16 @@ Int64 FileInputStream::tell() //////////////////////////////////////////////////////////// -Int64 FileInputStream::getSize() +std::int64_t FileInputStream::getSize() { #ifdef SFML_SYSTEM_ANDROID return m_file->getSize(); #else if (m_file) { - Int64 position = tell(); + std::int64_t position = tell(); std::fseek(m_file.get(), 0, SEEK_END); - Int64 size = tell(); + std::int64_t size = tell(); if (seek(position) == -1) return -1; diff --git a/src/SFML/System/MemoryInputStream.cpp b/src/SFML/System/MemoryInputStream.cpp index 3a8720e0b..2c7299ab3 100644 --- a/src/SFML/System/MemoryInputStream.cpp +++ b/src/SFML/System/MemoryInputStream.cpp @@ -42,19 +42,19 @@ MemoryInputStream::MemoryInputStream() : m_data(nullptr), m_size(0), m_offset(0) void MemoryInputStream::open(const void* data, std::size_t sizeInBytes) { m_data = static_cast(data); - m_size = static_cast(sizeInBytes); + m_size = static_cast(sizeInBytes); m_offset = 0; } //////////////////////////////////////////////////////////// -Int64 MemoryInputStream::read(void* data, Int64 size) +std::int64_t MemoryInputStream::read(void* data, std::int64_t size) { if (!m_data) return -1; - Int64 endPosition = m_offset + size; - Int64 count = endPosition <= m_size ? size : m_size - m_offset; + std::int64_t endPosition = m_offset + size; + std::int64_t count = endPosition <= m_size ? size : m_size - m_offset; if (count > 0) { @@ -67,7 +67,7 @@ Int64 MemoryInputStream::read(void* data, Int64 size) //////////////////////////////////////////////////////////// -Int64 MemoryInputStream::seek(Int64 position) +std::int64_t MemoryInputStream::seek(std::int64_t position) { if (!m_data) return -1; @@ -78,7 +78,7 @@ Int64 MemoryInputStream::seek(Int64 position) //////////////////////////////////////////////////////////// -Int64 MemoryInputStream::tell() +std::int64_t MemoryInputStream::tell() { if (!m_data) return -1; @@ -88,7 +88,7 @@ Int64 MemoryInputStream::tell() //////////////////////////////////////////////////////////// -Int64 MemoryInputStream::getSize() +std::int64_t MemoryInputStream::getSize() { if (!m_data) return -1; diff --git a/src/SFML/System/Unix/SleepImpl.cpp b/src/SFML/System/Unix/SleepImpl.cpp index 9446377da..51827dbb3 100644 --- a/src/SFML/System/Unix/SleepImpl.cpp +++ b/src/SFML/System/Unix/SleepImpl.cpp @@ -37,7 +37,7 @@ namespace sf::priv //////////////////////////////////////////////////////////// void sleepImpl(Time time) { - const Int64 usecs = time.asMicroseconds(); + const std::int64_t usecs = time.asMicroseconds(); // Construct the time to wait timespec ti; diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 141238c08..6a2dda8df 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -341,8 +341,8 @@ int WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates& s } // Retrieve everything we need to create this MotionEvent in Java - Int64 downTime = AMotionEvent_getDownTime(_event); - Int64 eventTime = AMotionEvent_getEventTime(_event); + std::int64_t downTime = AMotionEvent_getDownTime(_event); + std::int64_t eventTime = AMotionEvent_getEventTime(_event); std::int32_t action = AMotionEvent_getAction(_event); float x = AMotionEvent_getX(_event, 0); float y = AMotionEvent_getY(_event, 0); diff --git a/test/Network/Packet.cpp b/test/Network/Packet.cpp index 4a6935329..fc8d1f1ad 100644 --- a/test/Network/Packet.cpp +++ b/test/Network/Packet.cpp @@ -42,12 +42,12 @@ TEST_CASE("sf::Packet class - [network]") testPacketStreamOperators(std::numeric_limits::max()); } - SUBCASE("Int64") + SUBCASE("std::int64_t") { - testPacketStreamOperators(sf::Int64(0)); - testPacketStreamOperators(sf::Int64(1)); - testPacketStreamOperators(std::numeric_limits::min()); - testPacketStreamOperators(std::numeric_limits::max()); + testPacketStreamOperators(std::int64_t(0)); + testPacketStreamOperators(std::int64_t(1)); + testPacketStreamOperators(std::numeric_limits::min()); + testPacketStreamOperators(std::numeric_limits::max()); } } } diff --git a/test/System/Config.cpp b/test/System/Config.cpp index 5443a6014..61c1df28b 100644 --- a/test/System/Config.cpp +++ b/test/System/Config.cpp @@ -14,7 +14,6 @@ TEST_CASE("SFML/Config.hpp") SUBCASE("Fixed width types") { - CHECK(sizeof(sf::Int64) == 8); CHECK(sizeof(sf::Uint64) == 8); } } diff --git a/test/System/Time.cpp b/test/System/Time.cpp index b5f1642f2..092f01559 100644 --- a/test/System/Time.cpp +++ b/test/System/Time.cpp @@ -236,18 +236,18 @@ TEST_CASE("sf::Time class - [system]") { CHECK(sf::seconds(1) * 2.0f == sf::seconds(2)); CHECK(sf::seconds(12) * 0.5f == sf::seconds(6)); - CHECK(sf::seconds(1) * static_cast(2) == sf::seconds(2)); - CHECK(sf::seconds(42) * static_cast(2) == sf::seconds(84)); + CHECK(sf::seconds(1) * static_cast(2) == sf::seconds(2)); + CHECK(sf::seconds(42) * static_cast(2) == sf::seconds(84)); CHECK(2.0f * sf::seconds(1) == sf::seconds(2)); CHECK(0.5f * sf::seconds(12) == sf::seconds(6)); - CHECK(static_cast(2) * sf::seconds(1) == sf::seconds(2)); - CHECK(static_cast(2) * sf::seconds(42) == sf::seconds(84)); + CHECK(static_cast(2) * sf::seconds(1) == sf::seconds(2)); + CHECK(static_cast(2) * sf::seconds(42) == sf::seconds(84)); } SUBCASE("operator*=") { sf::Time time = sf::milliseconds(1'000); - time *= static_cast(10); + time *= static_cast(10); CHECK(time == sf::milliseconds(10'000)); time *= 0.1f; CHECK(time.asMilliseconds() == 1'000); @@ -257,8 +257,8 @@ TEST_CASE("sf::Time class - [system]") { CHECK(sf::seconds(1) / 2.0f == sf::seconds(0.5f)); CHECK(sf::seconds(12) / 0.5f == sf::seconds(24)); - CHECK(sf::seconds(1) / static_cast(2) == sf::seconds(0.5f)); - CHECK(sf::seconds(42) / static_cast(2) == sf::seconds(21)); + CHECK(sf::seconds(1) / static_cast(2) == sf::seconds(0.5f)); + CHECK(sf::seconds(42) / static_cast(2) == sf::seconds(21)); CHECK(sf::seconds(1) / sf::seconds(1) == 1.0f); CHECK(sf::milliseconds(10) / sf::microseconds(1) == Approx(10'000.f)); } @@ -266,7 +266,7 @@ TEST_CASE("sf::Time class - [system]") SUBCASE("operator/=") { sf::Time time = sf::milliseconds(1'000); - time /= static_cast(2); + time /= static_cast(2); CHECK(time == sf::milliseconds(500)); time /= 0.5f; CHECK(time.asMilliseconds() == 1'000);