diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md index d140edaa2..c819bb791 100644 --- a/lib/ArduinoJson/CHANGELOG.md +++ b/lib/ArduinoJson/CHANGELOG.md @@ -1,6 +1,13 @@ ArduinoJson: change log ======================= +v6.17.1 (2020-11-07) +------- + +* Fixed error `ambiguous overload for 'operator|'` (issue #1411) +* Fixed `operator|(MemberProxy, JsonObject)` (issue #1415) +* Allowed more than 32767 values in non-embedded mode (issue #1414) + v6.17.0 (2020-10-19) ------- diff --git a/lib/ArduinoJson/CONTRIBUTING.md b/lib/ArduinoJson/CONTRIBUTING.md new file mode 100644 index 000000000..5d4b96cf9 --- /dev/null +++ b/lib/ArduinoJson/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# Contribution to ArduinoJson + +First, thank you for taking the time to contribute to this project. + +You can submit changes via GitHub Pull Requests. + +Please: + +1. Unit test every change in behavior +2. Use clang-format in "file" mode to format the code +3. Consider using the Continuous Integration (Travis and AppVeyor) diff --git a/lib/ArduinoJson/README.md b/lib/ArduinoJson/README.md index 3516985e8..bbb852728 100644 --- a/lib/ArduinoJson/README.md +++ b/lib/ArduinoJson/README.md @@ -2,7 +2,7 @@ --- -[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.17.0)](https://www.ardu-badge.com/ArduinoJson/6.17.0) +[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.17.1)](https://www.ardu-badge.com/ArduinoJson/6.17.1) [![Build Status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=6.x)](https://travis-ci.org/bblanchon/ArduinoJson) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp index 6d47ef371..41166b6ae 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -19,10 +19,13 @@ namespace ARDUINOJSON_NAMESPACE { template class ElementProxy : public VariantOperators >, public VariantShortcuts >, - public Visitable { + public Visitable, + public VariantTag { typedef ElementProxy this_type; public: + typedef VariantRef variant_type; + FORCE_INLINE ElementProxy(TArray array, size_t index) : _array(array), _index(index) {} diff --git a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp index 42ba498ef..32a6f339b 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp @@ -83,6 +83,18 @@ #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 #endif +// Number of bits to store the pointer to next node +// (saves RAM but limits the number of values in a document) +#ifndef ARDUINOJSON_SLOT_OFFSET_SIZE +#if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 2 +// Address space == 16-bit => max 127 values +#define ARDUINOJSON_SLOT_OFFSET_SIZE 1 +#else +// Address space > 16-bit => max 32767 values +#define ARDUINOJSON_SLOT_OFFSET_SIZE 2 +#endif +#endif + #else // ARDUINOJSON_EMBEDDED_MODE // On a computer we have plenty of memory so we can use doubles @@ -114,6 +126,11 @@ #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 #endif +// Number of bits to store the pointer to next node +#ifndef ARDUINOJSON_SLOT_OFFSET_SIZE +#define ARDUINOJSON_SLOT_OFFSET_SIZE 4 +#endif + #endif // ARDUINOJSON_EMBEDDED_MODE #ifdef ARDUINO diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp index 76228541c..8d9d63d35 100644 --- a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp @@ -48,7 +48,7 @@ class MsgPackDeserializer { template bool parseVariant(VariantData &variant, TFilter filter, NestingLimit nestingLimit) { - uint8_t code = 0; + uint8_t code = 0; if (!readByte(code)) return false; diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp index a9ee6034f..1963deaea 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp @@ -21,10 +21,13 @@ namespace ARDUINOJSON_NAMESPACE { template class MemberProxy : public VariantOperators >, public VariantShortcuts >, - public Visitable { + public Visitable, + public VariantTag { typedef MemberProxy this_type; public: + typedef VariantRef variant_type; + FORCE_INLINE MemberProxy(TObject variant, TStringRef key) : _object(variant), _key(key) {} diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp new file mode 100644 index 000000000..8dfebb092 --- /dev/null +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp @@ -0,0 +1,30 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include // int8_t, int16_t + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct int_t; + +template <> +struct int_t<8> { + typedef int8_t type; +}; + +template <> +struct int_t<16> { + typedef int16_t type; +}; + +template <> +struct int_t<32> { + typedef int32_t type; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp index 79379e814..df4e9df28 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace ARDUINOJSON_NAMESPACE { @@ -17,23 +18,23 @@ CompareResult compare(const T1 &lhs, const T2 &rhs); // VariantCompare.cpp template struct VariantOperators { - // Returns the default value if the VariantRef is undefined of incompatible + // Returns the default value if the VariantRef is undefined or incompatible template - friend typename enable_if::value, T>::type operator|( - const TVariant &variant, const T &defaultValue) { + friend typename enable_if::value, T>::type operator|( + const TVariant &variant, T defaultValue) { if (variant.template is()) return variant.template as(); else return defaultValue; } - - // Returns the default value if the VariantRef is undefined of incompatible - // Special case for string: null is treated as undefined + // Returns the default value if the VariantRef is undefined or incompatible template - friend typename enable_if::value, T>::type operator|( - const TVariant &variant, T defaultValue) { - const char *value = variant.template as(); - return value ? value : defaultValue; + friend typename enable_if::value, typename T::variant_type>::type + operator|(const TVariant &variant, T defaultValue) { + if (variant) + return variant; + else + return defaultValue; } // value == TVariant diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp index c82ec1eac..a8b9067a6 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace ARDUINOJSON_NAMESPACE { @@ -23,12 +24,9 @@ namespace ARDUINOJSON_NAMESPACE { class ArrayRef; class ObjectRef; -template -class MemberProxy; - // Contains the methods shared by VariantRef and VariantConstRef template -class VariantRefBase { +class VariantRefBase : public VariantTag { public: // Tells wether the variant has the specified type. // Returns true if the variant has type type T, false otherwise. diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp index af6467097..38494f3b0 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp @@ -4,15 +4,15 @@ #pragma once -#include // int8_t, int16_t - +#include +#include #include #include #include namespace ARDUINOJSON_NAMESPACE { -typedef conditional::type VariantSlotDiff; +typedef int_t::type VariantSlotDiff; class VariantSlot { // CAUTION: same layout as VariantData @@ -61,11 +61,19 @@ class VariantSlot { } void setNext(VariantSlot* slot) { + ARDUINOJSON_ASSERT(!slot || slot - this >= + numeric_limits::lowest()); + ARDUINOJSON_ASSERT(!slot || slot - this <= + numeric_limits::highest()); _next = VariantSlotDiff(slot ? slot - this : 0); } void setNextNotNull(VariantSlot* slot) { ARDUINOJSON_ASSERT(slot != 0); + ARDUINOJSON_ASSERT(slot - this >= + numeric_limits::lowest()); + ARDUINOJSON_ASSERT(slot - this <= + numeric_limits::highest()); _next = VariantSlotDiff(slot - this); } diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp new file mode 100644 index 000000000..e9a08aecd --- /dev/null +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp @@ -0,0 +1,16 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +struct VariantTag {}; + +template +struct IsVariant : is_base_of {}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/version.hpp b/lib/ArduinoJson/src/ArduinoJson/version.hpp index 46b6bc62e..cd57a4dae 100644 --- a/lib/ArduinoJson/src/ArduinoJson/version.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/version.hpp @@ -4,7 +4,7 @@ #pragma once -#define ARDUINOJSON_VERSION "6.17.0" +#define ARDUINOJSON_VERSION "6.17.1" #define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MINOR 17 -#define ARDUINOJSON_VERSION_REVISION 0 +#define ARDUINOJSON_VERSION_REVISION 1 diff --git a/lib/ArduinoJson/src/CMakeLists.txt b/lib/ArduinoJson/src/CMakeLists.txt deleted file mode 100644 index de0032ae2..000000000 --- a/lib/ArduinoJson/src/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# ArduinoJson - arduinojson.org -# Copyright Benoit Blanchon 2014-2020 -# MIT License - -# I have no idea what this is about, I simply followed the instructions from: -# https://dominikberner.ch/cmake-interface-lib/ - -add_library(ArduinoJson INTERFACE) - -include(GNUInstallDirs) - -# Adding the install interface generator expression makes sure that the include -# files are installed to the proper location (provided by GNUInstallDirs) -target_include_directories(ArduinoJson - INTERFACE - $ - $ -) - -target_compile_definitions(ArduinoJson - INTERFACE - ARDUINOJSON_DEBUG=$ -) - -# locations are provided by GNUInstallDirs -install( - TARGETS - ArduinoJson - EXPORT - ArduinoJson_Targets - ARCHIVE DESTINATION - ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION - ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION - ${CMAKE_INSTALL_BINDIR} -) - -include(CMakePackageConfigHelpers) - -if(${CMAKE_VERSION} VERSION_GREATER "3.14.0") - set(ARCH_INDEPENDENT "ARCH_INDEPENDENT") -endif() - -write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/ArduinoJsonConfigVersion.cmake" - VERSION - ${PROJECT_VERSION} - COMPATIBILITY - SameMajorVersion - ${ARCH_INDEPENDENT} -) - -configure_package_config_file( - "${PROJECT_SOURCE_DIR}/extras/ArduinoJsonConfig.cmake.in" - "${PROJECT_BINARY_DIR}/ArduinoJsonConfig.cmake" - INSTALL_DESTINATION - ${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake) - -install( - EXPORT - ArduinoJson_Targets - FILE - ArduinoJsonTargets.cmake - DESTINATION - ${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake -) - -install( - FILES - "${PROJECT_BINARY_DIR}/ArduinoJsonConfig.cmake" - "${PROJECT_BINARY_DIR}/ArduinoJsonConfigVersion.cmake" - DESTINATION - "${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake" -) - -install( - FILES - ArduinoJson.h - ArduinoJson.hpp - DESTINATION - include -) - -install( - DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}/ArduinoJson" - DESTINATION - include -)