Просмотр исходного кода

Rename `Integer` to `JsonInteger`

Benoit Blanchon 3 лет назад
Родитель
Сommit
652d70fe2c

+ 2 - 2
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);

+ 1 - 1
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;

+ 1 - 1
src/ArduinoJson/Json/JsonSerializer.hpp

@@ -78,7 +78,7 @@ class JsonSerializer : public Visitor<size_t> {
     return bytesWritten();
   }
 
-  size_t visitSignedInteger(Integer value) {
+  size_t visitSignedInteger(JsonInteger value) {
     _formatter.writeInteger(value);
     return bytesWritten();
   }

+ 1 - 1
src/ArduinoJson/Json/TextFormatter.hpp

@@ -9,7 +9,7 @@
 
 #include <ArduinoJson/Json/EscapeSequence.hpp>
 #include <ArduinoJson/Numbers/FloatParts.hpp>
-#include <ArduinoJson/Numbers/Integer.hpp>
+#include <ArduinoJson/Numbers/JsonInteger.hpp>
 #include <ArduinoJson/Polyfills/assert.hpp>
 #include <ArduinoJson/Polyfills/attributes.hpp>
 #include <ArduinoJson/Polyfills/type_traits.hpp>

+ 3 - 3
src/ArduinoJson/MsgPack/MsgPackSerializer.hpp

@@ -23,8 +23,8 @@ class MsgPackSerializer : public Visitor<size_t> {
 
   template <typename T>
   typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) {
-    if (canConvertNumber<Integer>(value32)) {
-      Integer truncatedValue = Integer(value32);
+    if (canConvertNumber<JsonInteger>(value32)) {
+      JsonInteger truncatedValue = JsonInteger(value32);
       if (value32 == T(truncatedValue))
         return visitSignedInteger(truncatedValue);
     }
@@ -107,7 +107,7 @@ class MsgPackSerializer : public Visitor<size_t> {
     return bytesWritten();
   }
 
-  size_t visitSignedInteger(Integer value) {
+  size_t visitSignedInteger(JsonInteger value) {
     if (value > 0) {
       visitUnsignedInteger(static_cast<UInt>(value));
     } else if (value >= -0x20) {

+ 3 - 3
src/ArduinoJson/Numbers/Integer.hpp → 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/");

+ 1 - 1
src/ArduinoJson/Numbers/arithmeticCompare.hpp

@@ -4,7 +4,7 @@
 
 #pragma once
 
-#include <ArduinoJson/Numbers/Integer.hpp>
+#include <ArduinoJson/Numbers/JsonInteger.hpp>
 #include <ArduinoJson/Polyfills/type_traits.hpp>
 
 namespace ARDUINOJSON_NAMESPACE {

+ 2 - 2
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 {

+ 1 - 1
src/ArduinoJson/Variant/ConverterImpl.hpp

@@ -62,7 +62,7 @@ template <typename T>
 struct Converter<T, typename enable_if<is_enum<T>::value>::type>
     : private VariantAttorney {
   static void toJson(T src, VariantRef dst) {
-    dst.set(static_cast<Integer>(src));
+    dst.set(static_cast<JsonInteger>(src));
   }
 
   static T fromJson(VariantConstRef src) {

+ 3 - 3
src/ArduinoJson/Variant/VariantCompare.hpp

@@ -56,7 +56,7 @@ struct Comparer<T, typename enable_if<is_integral<T>::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<Integer> comparer(lhs);
+  CompareResult visitSignedInteger(JsonInteger lhs) {
+    Comparer<JsonInteger> comparer(lhs);
     return accept(comparer);
   }
 

+ 2 - 2
src/ArduinoJson/Variant/VariantContent.hpp

@@ -7,8 +7,8 @@
 #include <stddef.h>  // size_t
 
 #include <ArduinoJson/Collection/CollectionData.hpp>
-#include <ArduinoJson/Numbers/Integer.hpp>
 #include <ArduinoJson/Numbers/JsonFloat.hpp>
+#include <ArduinoJson/Numbers/JsonInteger.hpp>
 
 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;

+ 2 - 2
src/ArduinoJson/Variant/Visitor.hpp

@@ -5,8 +5,8 @@
 #pragma once
 
 #include <ArduinoJson/Collection/CollectionData.hpp>
-#include <ArduinoJson/Numbers/Integer.hpp>
 #include <ArduinoJson/Numbers/JsonFloat.hpp>
+#include <ArduinoJson/Numbers/JsonInteger.hpp>
 
 namespace ARDUINOJSON_NAMESPACE {
 
@@ -26,7 +26,7 @@ struct Visitor {
     return TResult();
   }
 
-  TResult visitSignedInteger(Integer) {
+  TResult visitSignedInteger(JsonInteger) {
     return TResult();
   }