From 652d70fe2cc70bfe5f261287f353197f01bdb4a3 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 19 Dec 2022 11:46:44 +0100 Subject: [PATCH] Rename `Integer` to `JsonInteger` --- extras/tests/Numbers/parseNumber.cpp | 4 ++-- src/ArduinoJson.hpp | 2 +- src/ArduinoJson/Json/JsonSerializer.hpp | 2 +- src/ArduinoJson/Json/TextFormatter.hpp | 2 +- src/ArduinoJson/MsgPack/MsgPackSerializer.hpp | 6 +++--- src/ArduinoJson/Numbers/{Integer.hpp => JsonInteger.hpp} | 6 +++--- src/ArduinoJson/Numbers/arithmeticCompare.hpp | 2 +- src/ArduinoJson/Numbers/parseNumber.hpp | 4 ++-- src/ArduinoJson/Variant/ConverterImpl.hpp | 2 +- src/ArduinoJson/Variant/VariantCompare.hpp | 6 +++--- src/ArduinoJson/Variant/VariantContent.hpp | 4 ++-- src/ArduinoJson/Variant/Visitor.hpp | 4 ++-- 12 files changed, 22 insertions(+), 22 deletions(-) rename src/ArduinoJson/Numbers/{Integer.hpp => JsonInteger.hpp} (86%) diff --git a/extras/tests/Numbers/parseNumber.cpp b/extras/tests/Numbers/parseNumber.cpp index eb52f3a5..7dd5aa06 100644 --- a/extras/tests/Numbers/parseNumber.cpp +++ b/extras/tests/Numbers/parseNumber.cpp @@ -13,7 +13,7 @@ TEST_CASE("Test unsigned integer overflow") { second.init(); // Avoids MSVC warning C4127 (conditional expression is constant) - size_t integerSize = sizeof(Integer); + size_t integerSize = sizeof(JsonInteger); if (integerSize == 8) { parseNumber("18446744073709551615", first); @@ -33,7 +33,7 @@ TEST_CASE("Test signed integer overflow") { second.init(); // Avoids MSVC warning C4127 (conditional expression is constant) - size_t integerSize = sizeof(Integer); + size_t integerSize = sizeof(JsonInteger); if (integerSize == 8) { parseNumber("-9223372036854775808", first); diff --git a/src/ArduinoJson.hpp b/src/ArduinoJson.hpp index 7075a3be..ab70d3c1 100644 --- a/src/ArduinoJson.hpp +++ b/src/ArduinoJson.hpp @@ -50,7 +50,7 @@ namespace ArduinoJson { using ARDUINOJSON_NAMESPACE::JsonArray; using ARDUINOJSON_NAMESPACE::JsonArrayConst; using ARDUINOJSON_NAMESPACE::JsonFloat; -typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger; +using ARDUINOJSON_NAMESPACE::JsonInteger; using ARDUINOJSON_NAMESPACE::JsonObject; using ARDUINOJSON_NAMESPACE::JsonObjectConst; using ARDUINOJSON_NAMESPACE::JsonPair; diff --git a/src/ArduinoJson/Json/JsonSerializer.hpp b/src/ArduinoJson/Json/JsonSerializer.hpp index bc13b620..a56cbc32 100644 --- a/src/ArduinoJson/Json/JsonSerializer.hpp +++ b/src/ArduinoJson/Json/JsonSerializer.hpp @@ -78,7 +78,7 @@ class JsonSerializer : public Visitor { return bytesWritten(); } - size_t visitSignedInteger(Integer value) { + size_t visitSignedInteger(JsonInteger value) { _formatter.writeInteger(value); return bytesWritten(); } diff --git a/src/ArduinoJson/Json/TextFormatter.hpp b/src/ArduinoJson/Json/TextFormatter.hpp index 2f26fd64..d2cdd943 100644 --- a/src/ArduinoJson/Json/TextFormatter.hpp +++ b/src/ArduinoJson/Json/TextFormatter.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp b/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp index 6217d8bb..f7c904ea 100644 --- a/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp +++ b/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp @@ -23,8 +23,8 @@ class MsgPackSerializer : public Visitor { template typename enable_if::type visitFloat(T value32) { - if (canConvertNumber(value32)) { - Integer truncatedValue = Integer(value32); + if (canConvertNumber(value32)) { + JsonInteger truncatedValue = JsonInteger(value32); if (value32 == T(truncatedValue)) return visitSignedInteger(truncatedValue); } @@ -107,7 +107,7 @@ class MsgPackSerializer : public Visitor { return bytesWritten(); } - size_t visitSignedInteger(Integer value) { + size_t visitSignedInteger(JsonInteger value) { if (value > 0) { visitUnsignedInteger(static_cast(value)); } else if (value >= -0x20) { diff --git a/src/ArduinoJson/Numbers/Integer.hpp b/src/ArduinoJson/Numbers/JsonInteger.hpp similarity index 86% rename from src/ArduinoJson/Numbers/Integer.hpp rename to src/ArduinoJson/Numbers/JsonInteger.hpp index dbf65364..8fc12dc1 100644 --- a/src/ArduinoJson/Numbers/Integer.hpp +++ b/src/ArduinoJson/Numbers/JsonInteger.hpp @@ -12,10 +12,10 @@ namespace ARDUINOJSON_NAMESPACE { #if ARDUINOJSON_USE_LONG_LONG -typedef int64_t Integer; +typedef int64_t JsonInteger; typedef uint64_t UInt; #else -typedef long Integer; +typedef long JsonInteger; typedef unsigned long UInt; #endif @@ -23,7 +23,7 @@ typedef unsigned long UInt; #if ARDUINOJSON_HAS_LONG_LONG && !ARDUINOJSON_USE_LONG_LONG # define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \ - static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::Integer), \ + static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::JsonInteger), \ "To use 64-bit integers with ArduinoJson, you must set " \ "ARDUINOJSON_USE_LONG_LONG to 1. See " \ "https://arduinojson.org/v6/api/config/use_long_long/"); diff --git a/src/ArduinoJson/Numbers/arithmeticCompare.hpp b/src/ArduinoJson/Numbers/arithmeticCompare.hpp index e9cd2310..2c7e81b2 100644 --- a/src/ArduinoJson/Numbers/arithmeticCompare.hpp +++ b/src/ArduinoJson/Numbers/arithmeticCompare.hpp @@ -4,7 +4,7 @@ #pragma once -#include +#include #include namespace ARDUINOJSON_NAMESPACE { diff --git a/src/ArduinoJson/Numbers/parseNumber.hpp b/src/ArduinoJson/Numbers/parseNumber.hpp index 4730bd97..c06d2f57 100644 --- a/src/ArduinoJson/Numbers/parseNumber.hpp +++ b/src/ArduinoJson/Numbers/parseNumber.hpp @@ -71,9 +71,9 @@ inline bool parseNumber(const char* s, VariantData& result) { if (*s == '\0') { if (is_negative) { const mantissa_t sintMantissaMax = mantissa_t(1) - << (sizeof(Integer) * 8 - 1); + << (sizeof(JsonInteger) * 8 - 1); if (mantissa <= sintMantissaMax) { - result.setInteger(Integer(~mantissa + 1)); + result.setInteger(JsonInteger(~mantissa + 1)); return true; } } else { diff --git a/src/ArduinoJson/Variant/ConverterImpl.hpp b/src/ArduinoJson/Variant/ConverterImpl.hpp index cf6d2cb0..e12fff30 100644 --- a/src/ArduinoJson/Variant/ConverterImpl.hpp +++ b/src/ArduinoJson/Variant/ConverterImpl.hpp @@ -62,7 +62,7 @@ template struct Converter::value>::type> : private VariantAttorney { static void toJson(T src, VariantRef dst) { - dst.set(static_cast(src)); + dst.set(static_cast(src)); } static T fromJson(VariantConstRef src) { diff --git a/src/ArduinoJson/Variant/VariantCompare.hpp b/src/ArduinoJson/Variant/VariantCompare.hpp index 968e919b..03b8ba03 100644 --- a/src/ArduinoJson/Variant/VariantCompare.hpp +++ b/src/ArduinoJson/Variant/VariantCompare.hpp @@ -56,7 +56,7 @@ struct Comparer::value || return arithmeticCompare(lhs, rhs); } - CompareResult visitSignedInteger(Integer lhs) { + CompareResult visitSignedInteger(JsonInteger lhs) { return arithmeticCompare(lhs, rhs); } @@ -157,8 +157,8 @@ struct VariantComparer : ComparerBase { return accept(comparer); } - CompareResult visitSignedInteger(Integer lhs) { - Comparer comparer(lhs); + CompareResult visitSignedInteger(JsonInteger lhs) { + Comparer comparer(lhs); return accept(comparer); } diff --git a/src/ArduinoJson/Variant/VariantContent.hpp b/src/ArduinoJson/Variant/VariantContent.hpp index 240960bf..c4f4611c 100644 --- a/src/ArduinoJson/Variant/VariantContent.hpp +++ b/src/ArduinoJson/Variant/VariantContent.hpp @@ -7,8 +7,8 @@ #include // size_t #include -#include #include +#include namespace ARDUINOJSON_NAMESPACE { @@ -47,7 +47,7 @@ union VariantContent { JsonFloat asFloat; bool asBoolean; UInt asUnsignedInteger; - Integer asSignedInteger; + JsonInteger asSignedInteger; CollectionData asCollection; struct { const char* data; diff --git a/src/ArduinoJson/Variant/Visitor.hpp b/src/ArduinoJson/Variant/Visitor.hpp index f62301e6..0c833230 100644 --- a/src/ArduinoJson/Variant/Visitor.hpp +++ b/src/ArduinoJson/Variant/Visitor.hpp @@ -5,8 +5,8 @@ #pragma once #include -#include #include +#include namespace ARDUINOJSON_NAMESPACE { @@ -26,7 +26,7 @@ struct Visitor { return TResult(); } - TResult visitSignedInteger(Integer) { + TResult visitSignedInteger(JsonInteger) { return TResult(); }