Replace sf::Int8 with std::int8_t

This commit is contained in:
Chris Thrasher 2022-09-03 13:58:02 -06:00 committed by Lukas Dürrenberger
parent 82b48a7520
commit af34794123
5 changed files with 11 additions and 13 deletions

View File

@ -168,7 +168,6 @@
namespace sf namespace sf
{ {
// 8 bits integer types // 8 bits integer types
using Int8 = std::int8_t;
using Uint8 = std::uint8_t; using Uint8 = std::uint8_t;
// 16 bits integer types // 16 bits integer types

View File

@ -213,7 +213,7 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& operator>>(Int8& data); Packet& operator>>(std::int8_t& data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
@ -294,7 +294,7 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& operator<<(Int8 data); Packet& operator<<(std::int8_t data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
@ -498,7 +498,7 @@ private:
/// Packets have built-in operator >> and << overloads for /// Packets have built-in operator >> and << overloads for
/// standard types: /// standard types:
/// \li bool /// \li bool
/// \li fixed-size integer types (sf::Int8/16/32, sf::Uint8/16/32) /// \li fixed-size integer types (int[8|16|32]_t, uint[8|16|32]_t)
/// \li floating point numbers (float, double) /// \li floating point numbers (float, double)
/// \li string types (char*, wchar_t*, std::string, std::wstring, sf::String) /// \li string types (char*, wchar_t*, std::string, std::wstring, sf::String)
/// ///
@ -510,7 +510,7 @@ private:
/// struct MyStruct /// struct MyStruct
/// { /// {
/// float number; /// float number;
/// sf::Int8 integer; /// std::int8_t integer;
/// std::string str; /// std::string str;
/// }; /// };
/// ///

View File

@ -129,7 +129,7 @@ Packet& Packet::operator>>(bool& data)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& Packet::operator>>(Int8& data) Packet& Packet::operator>>(std::int8_t& data)
{ {
if (checkSize(sizeof(data))) if (checkSize(sizeof(data)))
{ {
@ -400,7 +400,7 @@ Packet& Packet::operator<<(bool data)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& Packet::operator<<(Int8 data) Packet& Packet::operator<<(std::int8_t data)
{ {
append(&data, sizeof(data)); append(&data, sizeof(data));
return *this; return *this;

View File

@ -18,12 +18,12 @@ TEST_CASE("sf::Packet class - [network]")
{ {
SUBCASE("Stream operators") SUBCASE("Stream operators")
{ {
SUBCASE("Int8") SUBCASE("std::int8_t")
{ {
testPacketStreamOperators(sf::Int8(0)); testPacketStreamOperators(std::int8_t(0));
testPacketStreamOperators(sf::Int8(1)); testPacketStreamOperators(std::int8_t(1));
testPacketStreamOperators(std::numeric_limits<sf::Int8>::min()); testPacketStreamOperators(std::numeric_limits<std::int8_t>::min());
testPacketStreamOperators(std::numeric_limits<sf::Int8>::max()); testPacketStreamOperators(std::numeric_limits<std::int8_t>::max());
} }
SUBCASE("Int16") SUBCASE("Int16")

View File

@ -14,7 +14,6 @@ TEST_CASE("SFML/Config.hpp")
SUBCASE("Fixed width types") SUBCASE("Fixed width types")
{ {
CHECK(sizeof(sf::Int8) == 1);
CHECK(sizeof(sf::Uint8) == 1); CHECK(sizeof(sf::Uint8) == 1);
CHECK(sizeof(sf::Int16) == 2); CHECK(sizeof(sf::Int16) == 2);