From eeb96199f9bf41c941c52c35b1b601b774ce63e8 Mon Sep 17 00:00:00 2001 From: Proddy Date: Fri, 10 Feb 2023 20:27:45 +0100 Subject: [PATCH] 6.20.1 --- lib/ArduinoJson/CHANGELOG.md | 7 ++ lib/ArduinoJson/{LICENSE.md => LICENSE.txt} | 20 ++--- lib/ArduinoJson/README.md | 14 ++-- .../Deserialization/DeserializationError.hpp | 20 ++--- .../MsgPack/MsgPackDeserializer.hpp | 2 +- .../src/ArduinoJson/Numbers/FloatTraits.hpp | 83 +++++++++---------- .../Polyfills/pgmspace_generic.hpp | 37 +++++++-- .../ArduinoJson/Polyfills/static_array.hpp | 30 ------- .../ArduinoJson/Variant/VariantCompare.hpp | 2 +- .../ArduinoJson/Variant/VariantRefBase.hpp | 8 +- lib/ArduinoJson/src/ArduinoJson/version.hpp | 4 +- 11 files changed, 110 insertions(+), 117 deletions(-) rename lib/ArduinoJson/{LICENSE.md => LICENSE.txt} (99%) delete mode 100644 lib/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md index a0125a958..dd4945bce 100644 --- a/lib/ArduinoJson/CHANGELOG.md +++ b/lib/ArduinoJson/CHANGELOG.md @@ -1,6 +1,13 @@ ArduinoJson: change log ======================= +v6.20.1 (2023-02-08) +------- + +* Remove explicit exclusion of `as()` and `as()` (issue #1860) + If you try to call them, you'll now get the same error message as any unsupported type. + You could also add a custom converter for `char*` and `char`. + v6.20.0 (2022-12-26) ------- diff --git a/lib/ArduinoJson/LICENSE.md b/lib/ArduinoJson/LICENSE.txt similarity index 99% rename from lib/ArduinoJson/LICENSE.md rename to lib/ArduinoJson/LICENSE.txt index dee0b5ba4..e59620d1d 100644 --- a/lib/ArduinoJson/LICENSE.md +++ b/lib/ArduinoJson/LICENSE.txt @@ -1,10 +1,10 @@ -The MIT License (MIT) ---------------------- - -Copyright © 2014-2022, Benoit BLANCHON - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) +--------------------- + +Copyright © 2014-2022, Benoit BLANCHON + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/ArduinoJson/README.md b/lib/ArduinoJson/README.md index 1e843d80b..b0f539dd3 100644 --- a/lib/ArduinoJson/README.md +++ b/lib/ArduinoJson/README.md @@ -1,17 +1,18 @@

- ArduinoJson + ArduinoJson

--- -[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bblanchon/ArduinoJson/ci.yml?branch=6.x)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bblanchon/ArduinoJson/ci.yml?branch=6.x&logo=github)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) [![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![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) [![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) -[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.20.0&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.20.0) -[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.20.0)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.20.0) -[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers) -[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon) +[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.20.1&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.20.1) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.20.1)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.20.1) +[![ESP IDF](https://img.shields.io/static/v1?label=ESP+IDF&message=v6.20.1&logo=cpu&logoColor=white&color=blue)](https://components.espressif.com/components/bblanchon/arduinojson) +[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github&color=orange)](https://github.com/bblanchon/ArduinoJson/stargazers) +[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github&color=orange)](https://github.com/sponsors/bblanchon) ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). @@ -99,7 +100,6 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed) - * [Discord server](https://discord.gg/DzN6hHHD4h) ## Quickstart diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp index 96b3a178b..16c52ffd2 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp @@ -6,8 +6,8 @@ #include #include +#include #include -#include #if ARDUINOJSON_ENABLE_STD_STREAM # include @@ -74,16 +74,16 @@ class DeserializationError : public SafeBoolIdom { #if ARDUINOJSON_ENABLE_PROGMEM const __FlashStringHelper* f_str() const { - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s0, "Ok"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s1, "EmptyInput"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s2, "IncompleteInput"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s3, "InvalidInput"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s4, "NoMemory"); - ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s5, "TooDeep"); - ARDUINOJSON_DEFINE_STATIC_ARRAY( + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s0, "Ok"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s1, "EmptyInput"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s2, "IncompleteInput"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s3, "InvalidInput"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s4, "NoMemory"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s5, "TooDeep"); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5})); - return ARDUINOJSON_READ_STATIC_ARRAY(const __FlashStringHelper*, messages, - _code); + return reinterpret_cast( + pgm_read(messages + _code)); } #endif diff --git a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp index fd434d5c3..5013d2e29 100644 --- a/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp @@ -37,7 +37,7 @@ class MsgPackDeserializer { NestingLimit nestingLimit) { DeserializationError::Code err; - uint8_t code = 0; + uint8_t code = 0; // TODO: why do we need to initialize this variable? err = readByte(code); if (err) return err; diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp index 4d5782b7a..08aa3d66a 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include namespace ARDUINOJSON_NAMESPACE { @@ -49,7 +49,7 @@ struct FloatTraits { } static T positiveBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( // + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( // uint32_t, factors, ARDUINOJSON_EXPAND18({ 0x40240000, 0x00000000, // 1e1 @@ -62,13 +62,12 @@ struct FloatTraits { 0x5A827748, 0xF9301D32, // 1e128 0x75154FDD, 0x7F73BF3C // 1e256 })); - return forge( - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1)); + return forge(pgm_read(factors + 2 * index), + pgm_read(factors + 2 * index + 1)); } static T negativeBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( // + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( // uint32_t, factors, ARDUINOJSON_EXPAND18({ 0x3FB99999, 0x9999999A, // 1e-1 @@ -81,13 +80,12 @@ struct FloatTraits { 0x255BBA08, 0xCF8C979D, // 1e-128 0x0AC80628, 0x64AC6F43 // 1e-256 })); - return forge( - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1)); + return forge(pgm_read(factors + 2 * index), + pgm_read(factors + 2 * index + 1)); } static T negativeBinaryPowerOfTenPlusOne(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( // + ARDUINOJSON_DEFINE_PROGMEM_ARRAY( // uint32_t, factors, ARDUINOJSON_EXPAND18({ 0x3FF00000, 0x00000000, // 1e0 @@ -100,9 +98,8 @@ struct FloatTraits { 0x25915445, 0x81B7DEC2, // 1e-127 0x0AFE07B2, 0x7DD78B14 // 1e-255 })); - return forge( - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index), - ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, 2 * index + 1)); + return forge(pgm_read(factors + 2 * index), + pgm_read(factors + 2 * index + 1)); } static T nan() { @@ -175,42 +172,42 @@ struct FloatTraits { } static T positiveBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, - ARDUINOJSON_EXPAND6({ - 0x41200000, // 1e1f - 0x42c80000, // 1e2f - 0x461c4000, // 1e4f - 0x4cbebc20, // 1e8f - 0x5a0e1bca, // 1e16f - 0x749dc5ae // 1e32f - })); - return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors, + ARDUINOJSON_EXPAND6({ + 0x41200000, // 1e1f + 0x42c80000, // 1e2f + 0x461c4000, // 1e4f + 0x4cbebc20, // 1e8f + 0x5a0e1bca, // 1e16f + 0x749dc5ae // 1e32f + })); + return forge(pgm_read(factors + index)); } static T negativeBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, - ARDUINOJSON_EXPAND6({ - 0x3dcccccd, // 1e-1f - 0x3c23d70a, // 1e-2f - 0x38d1b717, // 1e-4f - 0x322bcc77, // 1e-8f - 0x24e69595, // 1e-16f - 0x0a4fb11f // 1e-32f - })); - return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors, + ARDUINOJSON_EXPAND6({ + 0x3dcccccd, // 1e-1f + 0x3c23d70a, // 1e-2f + 0x38d1b717, // 1e-4f + 0x322bcc77, // 1e-8f + 0x24e69595, // 1e-16f + 0x0a4fb11f // 1e-32f + })); + return forge(pgm_read(factors + index)); } static T negativeBinaryPowerOfTenPlusOne(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY(uint32_t, factors, - ARDUINOJSON_EXPAND6({ - 0x3f800000, // 1e0f - 0x3dcccccd, // 1e-1f - 0x3a83126f, // 1e-3f - 0x33d6bf95, // 1e-7f - 0x26901d7d, // 1e-15f - 0x0c01ceb3 // 1e-31f - })); - return forge(ARDUINOJSON_READ_STATIC_ARRAY(uint32_t, factors, index)); + ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors, + ARDUINOJSON_EXPAND6({ + 0x3f800000, // 1e0f + 0x3dcccccd, // 1e-1f + 0x3a83126f, // 1e-3f + 0x33d6bf95, // 1e-7f + 0x26901d7d, // 1e-15f + 0x0c01ceb3 // 1e-31f + })); + return forge(pgm_read(factors + index)); } static T forge(uint32_t bits) { diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp index d9e964b85..106e01451 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp @@ -5,20 +5,41 @@ #pragma once #include -#include -#include + +#if ARDUINOJSON_ENABLE_PROGMEM +# include +# include +#endif namespace ARDUINOJSON_NAMESPACE { -template -typename enable_if::value, T>::type pgm_read(const void* p) { - return reinterpret_cast(pgm_read_ptr(p)); -} +#if ARDUINOJSON_ENABLE_PROGMEM + +# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY +# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ + static type const name[] PROGMEM = value; +# endif template -typename enable_if::value, T>::type pgm_read( - const void* p) { +inline const T* pgm_read(const T* const* p) { + return reinterpret_cast(pgm_read_ptr(p)); +} + +inline uint32_t pgm_read(const uint32_t* p) { return pgm_read_dword(p); } +#else + +# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY +# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ + static type const name[] = value; +# endif + +template +inline T pgm_read(const T* p) { + return *p; +} + +#endif } // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp deleted file mode 100644 index b2ebbf6b2..000000000 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// ArduinoJson - https://arduinojson.org -// Copyright © 2014-2022, Benoit BLANCHON -// MIT License - -#pragma once - -#include - -#if ARDUINOJSON_ENABLE_PROGMEM - -# include - -# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY -# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ - static type const name[] PROGMEM = value; -# endif - -# define ARDUINOJSON_DEFINE_STATIC_ARRAY ARDUINOJSON_DEFINE_PROGMEM_ARRAY - -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ - pgm_read(name + index) - -#else // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0 - -# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ - static type const name[] = value; - -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] - -#endif diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp index e680f5a85..b6e7ea8c9 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp @@ -22,7 +22,7 @@ struct Comparer; template struct Comparer::value>::type> : ComparerBase { - T rhs; + T rhs; // TODO: store adapted string? explicit Comparer(T value) : rhs(value) {} diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp index ddfcf0d60..c2df2dc62 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp @@ -46,11 +46,9 @@ class VariantRefBase : public VariantTag { // Casts the value to the specified type. // https://arduinojson.org/v6/api/jsonvariant/as/ template - FORCE_INLINE typename enable_if::value && - !is_same::value && - !ConverterNeedsWriteableRef::value, - T>::type - as() const { + FORCE_INLINE + typename enable_if::value, T>::type + as() const { return Converter::fromJson(getVariantConst()); } diff --git a/lib/ArduinoJson/src/ArduinoJson/version.hpp b/lib/ArduinoJson/src/ArduinoJson/version.hpp index 7f4aff88f..30f688cc1 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.20.0" +#define ARDUINOJSON_VERSION "6.20.1" #define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MINOR 20 -#define ARDUINOJSON_VERSION_REVISION 0 +#define ARDUINOJSON_VERSION_REVISION 1