diff --git a/config.h b/config.h index 306a334..1be95aa 100644 --- a/config.h +++ b/config.h @@ -250,7 +250,7 @@ #define VOICE_NAME_LEN 12 // 11 (plus '\0') #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define CONFIG_FILENAME_LEN 50 -#define DRUM_NAME_LEN 9 +#define DRUM_NAME_LEN 10 #define PERFORMANCE_NAME_LEN 11 #define FAV_CONFIG_PATH "FAVCFG" diff --git a/third-party/ArduinoJson/CHANGELOG.md b/third-party/ArduinoJson/CHANGELOG.md index bee7434..28c506a 100644 --- a/third-party/ArduinoJson/CHANGELOG.md +++ b/third-party/ArduinoJson/CHANGELOG.md @@ -1,6 +1,28 @@ ArduinoJson: change log ======================= +v6.21.3 (2023-07-23) +------- + +* Fix compatibility with the Blynk libary (issue #1914) +* Fix double lookup in `to()` +* Fix double call to `size()` in `serializeMsgPack()` +* Include `ARDUINOJSON_SLOT_OFFSET_SIZE` in the namespace name +* Show a link to the documentation when user passes an unsupported input type + +v6.21.2 (2023-04-12) +------- + +* Fix compatibility with the Zephyr Project (issue #1905) +* Allow using PROGMEM outside of Arduino (issue #1903) +* Set default for `ARDUINOJSON_ENABLE_PROGMEM` to `1` on AVR + +v6.21.1 (2023-03-27) +------- + +* Double speed of `DynamicJsonDocument::garbageCollect()` +* Fix compatibility with GCC 5.2 (issue #1897) + v6.21.0 (2023-03-14) ------- diff --git a/third-party/ArduinoJson/CMakeLists.txt b/third-party/ArduinoJson/CMakeLists.txt index 575b5d0..a79bc66 100644 --- a/third-party/ArduinoJson/CMakeLists.txt +++ b/third-party/ArduinoJson/CMakeLists.txt @@ -10,7 +10,7 @@ if(ESP_PLATFORM) return() endif() -project(ArduinoJson VERSION 6.21.0) +project(ArduinoJson VERSION 6.21.3) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/third-party/ArduinoJson/README.md b/third-party/ArduinoJson/README.md index fdb3f88..16d93a3 100644 --- a/third-party/ArduinoJson/README.md +++ b/third-party/ArduinoJson/README.md @@ -8,9 +8,9 @@ [![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.21.0&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.21.0) -[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.21.0)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.21.0) -[![ESP IDF](https://img.shields.io/static/v1?label=ESP+IDF&message=v6.21.0&logo=cpu&logoColor=white&color=blue)](https://components.espressif.com/components/bblanchon/arduinojson) +[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.21.3&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.21.3) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.21.3)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.21.3) +[![ESP IDF](https://img.shields.io/static/v1?label=ESP+IDF&message=v6.21.3&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) @@ -85,7 +85,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) * Continuously tested on * [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) - * [GCC 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) + * [GCC 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [Clang 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) * Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/) diff --git a/third-party/ArduinoJson/appveyor.yml b/third-party/ArduinoJson/appveyor.yml index 591b242..4a9789b 100644 --- a/third-party/ArduinoJson/appveyor.yml +++ b/third-party/ArduinoJson/appveyor.yml @@ -1,4 +1,4 @@ -version: 6.21.0.{build} +version: 6.21.3.{build} environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 diff --git a/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino b/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino index fc980aa..6937a00 100644 --- a/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino +++ b/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino @@ -14,7 +14,7 @@ void setup() { while (!Serial) continue; // The huge input: an extract from OpenWeatherMap response - const __FlashStringHelper* input_json = F( + auto input_json = F( "{\"cod\":\"200\",\"message\":0,\"list\":[{\"dt\":1581498000,\"main\":{" "\"temp\":3.23,\"feels_like\":-3.63,\"temp_min\":3.23,\"temp_max\":4.62," "\"pressure\":1014,\"sea_level\":1014,\"grnd_level\":1010,\"humidity\":" diff --git a/third-party/ArduinoJson/extras/conf_test/avr.cpp b/third-party/ArduinoJson/extras/conf_test/avr.cpp index fda9446..b2b105e 100644 --- a/third-party/ArduinoJson/extras/conf_test/avr.cpp +++ b/third-party/ArduinoJson/extras/conf_test/avr.cpp @@ -1,5 +1,7 @@ #include +static_assert(ARDUINOJSON_ENABLE_PROGMEM == 1, "ARDUINOJSON_ENABLE_PROGMEM"); + static_assert(ARDUINOJSON_USE_LONG_LONG == 0, "ARDUINOJSON_USE_LONG_LONG"); static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 1, diff --git a/third-party/ArduinoJson/extras/scripts/get-release-page.sh b/third-party/ArduinoJson/extras/scripts/get-release-page.sh index 2acb8d8..9bf943e 100755 --- a/third-party/ArduinoJson/extras/scripts/get-release-page.sh +++ b/third-party/ArduinoJson/extras/scripts/get-release-page.sh @@ -4,14 +4,14 @@ set -eu VERSION="$1" CHANGELOG="$2" -FRONTMATTER="$3" +ARDUINOJSON_H="$3" cat << END --- branch: v6 version: $VERSION date: '$(date +'%Y-%m-%d')' -$(cat "$FRONTMATTER") +$(extras/scripts/wandbox/publish.sh "$ARDUINOJSON_H") --- $(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG") diff --git a/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh b/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh index d410c47..3ee7f91 100755 --- a/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh +++ b/third-party/ArduinoJson/extras/scripts/publish-particle-library.sh @@ -14,5 +14,5 @@ cp -r "$SOURCE_DIR/src" "$WORK_DIR/" cp -r "$SOURCE_DIR/examples" "$WORK_DIR/" cd "$WORK_DIR" -particle library upload -particle library publish +particle library upload -v +particle library publish -v diff --git a/third-party/ArduinoJson/extras/scripts/publish.sh b/third-party/ArduinoJson/extras/scripts/publish.sh index a562a24..af9546a 100755 --- a/third-party/ArduinoJson/extras/scripts/publish.sh +++ b/third-party/ArduinoJson/extras/scripts/publish.sh @@ -46,6 +46,7 @@ update_version_in_source () { -e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \ -e "s/ARDUINOJSON_VERSION_MINOR .*$/ARDUINOJSON_VERSION_MINOR $MINOR/" \ -e "s/ARDUINOJSON_VERSION_REVISION .*$/ARDUINOJSON_VERSION_REVISION $REVISION/" \ + -e "s/ARDUINOJSON_VERSION_MACRO .*$/ARDUINOJSON_VERSION_MACRO V$MAJOR$MINOR$REVISION/" \ src/ArduinoJson/version.hpp rm src/ArduinoJson/version.hpp*~ } @@ -72,7 +73,6 @@ push extras/scripts/build-arduino-package.sh . "../ArduinoJson-$TAG.zip" extras/scripts/build-single-header.sh "src/ArduinoJson.h" "../ArduinoJson-$TAG.h" extras/scripts/build-single-header.sh "src/ArduinoJson.hpp" "../ArduinoJson-$TAG.hpp" -extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG-wandbox.txt" || echo "Wandbox failed!" -extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md" +extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG.md" echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md" diff --git a/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh b/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh index 0900cb0..b3f7077 100755 --- a/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh +++ b/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh @@ -14,8 +14,8 @@ compile() { { "code":$(read_string "$FILE_PATH"), "codes": [{"file":"ArduinoJson.h","code":$(read_string "$ARDUINOJSON_H")}], - "options": "warning", - "compiler": "gcc-4.9.4", + "options": "warning,c++11", + "compiler": "gcc-5.5.0", "save": true } END diff --git a/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h b/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h index 5f6f3fe..ef3640d 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h +++ b/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h @@ -7,5 +7,7 @@ #include "api/Print.h" #include "api/Stream.h" #include "api/String.h" +#include "avr/pgmspace.h" +#define ARDUINO #define ARDUINO_H_INCLUDED 1 diff --git a/third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp b/third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp index da19d3f..66525a2 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp +++ b/third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp @@ -7,18 +7,18 @@ #include class CustomReader { - std::stringstream _stream; + std::stringstream stream_; public: - CustomReader(const char* input) : _stream(input) {} + CustomReader(const char* input) : stream_(input) {} CustomReader(const CustomReader&) = delete; int read() { - return _stream.get(); + return stream_.get(); } size_t readBytes(char* buffer, size_t length) { - _stream.read(buffer, static_cast(length)); - return static_cast(_stream.gcount()); + stream_.read(buffer, static_cast(length)); + return static_cast(stream_.gcount()); } }; diff --git a/third-party/ArduinoJson/extras/tests/Helpers/avr/pgmspace.h b/third-party/ArduinoJson/extras/tests/Helpers/avr/pgmspace.h new file mode 100644 index 0000000..378065d --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/Helpers/avr/pgmspace.h @@ -0,0 +1,31 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2023, Benoit BLANCHON +// MIT License + +#pragma once + +#include // uint8_t + +#define PROGMEM + +class __FlashStringHelper; + +inline const void* convertPtrToFlash(const void* s) { + return reinterpret_cast(s) + 42; +} + +inline const void* convertFlashToPtr(const void* s) { + return reinterpret_cast(s) - 42; +} + +#define PSTR(X) reinterpret_cast(convertPtrToFlash(X)) +#define F(X) reinterpret_cast(PSTR(X)) + +inline uint8_t pgm_read_byte(const void* p) { + return *reinterpret_cast(convertFlashToPtr(p)); +} + +#define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, ...) \ + static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = __VA_ARGS__; \ + static type const* name = reinterpret_cast( \ + convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem))); diff --git a/third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt index e8113e2..9ee858d 100644 --- a/third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt @@ -9,7 +9,7 @@ add_executable(IntegrationTests openweathermap.cpp ) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6) target_compile_options(IntegrationTests PUBLIC -fsingle-precision-constant # issue 544 diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp index 6c21c6f..788319f 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp @@ -24,6 +24,30 @@ TEST_CASE("deserializeJson(char*)") { } } +TEST_CASE("deserializeJson(unsigned char*, unsigned int)") { // issue #1897 + StaticJsonDocument<1024> doc; + + unsigned char input[] = "{\"hello\":\"world\"}"; + unsigned char* input_ptr = input; + unsigned int size = sizeof(input); + + DeserializationError err = deserializeJson(doc, input_ptr, size); + + REQUIRE(err == DeserializationError::Ok); +} + +TEST_CASE("deserializeJson(uint8_t*, size_t)") { // issue #1898 + StaticJsonDocument<1024> doc; + + uint8_t input[] = "{\"hello\":\"world\"}"; + uint8_t* input_ptr = input; + size_t size = sizeof(input); + + DeserializationError err = deserializeJson(doc, input_ptr, size); + + REQUIRE(err == DeserializationError::Ok); +} + TEST_CASE("deserializeJson(const std::string&)") { DynamicJsonDocument doc(4096); diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp index 9f034f0..348fd94 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp @@ -10,29 +10,29 @@ class SpyingAllocator { public: - SpyingAllocator(const SpyingAllocator& src) : _log(src._log) {} - SpyingAllocator(std::ostream& log) : _log(log) {} + SpyingAllocator(const SpyingAllocator& src) : log_(src.log_) {} + SpyingAllocator(std::ostream& log) : log_(log) {} SpyingAllocator& operator=(const SpyingAllocator& src) = delete; void* allocate(size_t n) { - _log << "A" << n; + log_ << "A" << n; return malloc(n); } void deallocate(void* p) { - _log << "F"; + log_ << "F"; free(p); } private: - std::ostream& _log; + std::ostream& log_; }; class ControllableAllocator { public: - ControllableAllocator() : _enabled(true) {} + ControllableAllocator() : enabled_(true) {} void* allocate(size_t n) { - return _enabled ? malloc(n) : 0; + return enabled_ ? malloc(n) : 0; } void deallocate(void* p) { @@ -40,11 +40,11 @@ class ControllableAllocator { } void disable() { - _enabled = false; + enabled_ = false; } private: - bool _enabled; + bool enabled_; }; TEST_CASE("BasicJsonDocument") { diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp index cc76972..a442334 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp @@ -10,36 +10,36 @@ class ArmoredAllocator { public: - ArmoredAllocator() : _ptr(0), _size(0) {} + ArmoredAllocator() : ptr_(0), size_(0) {} void* allocate(size_t size) { - _ptr = malloc(size); - _size = size; - return _ptr; + ptr_ = malloc(size); + size_ = size; + return ptr_; } void deallocate(void* ptr) { - REQUIRE(ptr == _ptr); + REQUIRE(ptr == ptr_); free(ptr); - _ptr = 0; - _size = 0; + ptr_ = 0; + size_ = 0; } void* reallocate(void* ptr, size_t new_size) { - REQUIRE(ptr == _ptr); + REQUIRE(ptr == ptr_); // don't call realloc, instead alloc a new buffer and erase the old one // this way we make sure we support relocation void* new_ptr = malloc(new_size); - memcpy(new_ptr, _ptr, std::min(new_size, _size)); - memset(_ptr, '#', _size); // erase - free(_ptr); - _ptr = new_ptr; + memcpy(new_ptr, ptr_, std::min(new_size, size_)); + memset(ptr_, '#', size_); // erase + free(ptr_); + ptr_ = new_ptr; return new_ptr; } private: - void* _ptr; - size_t _size; + void* ptr_; + size_t size_; }; typedef BasicJsonDocument ShrinkToFitTestDocument; diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp index b6d8be7..a84657a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp @@ -12,21 +12,21 @@ class CustomWriter { CustomWriter& operator=(const CustomWriter&) = delete; size_t write(uint8_t c) { - _str.append(1, static_cast(c)); + str_.append(1, static_cast(c)); return 1; } size_t write(const uint8_t* s, size_t n) { - _str.append(reinterpret_cast(s), n); + str_.append(reinterpret_cast(s), n); return n; } const std::string& str() const { - return _str; + return str_; } private: - std::string _str; + std::string str_; }; TEST_CASE("CustomWriter") { diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp index 4de066a..cd4e7c2 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp @@ -74,18 +74,18 @@ TEST_CASE("Custom converter with overloading") { class Complex { public: - explicit Complex(double r, double i) : _real(r), _imag(i) {} + explicit Complex(double r, double i) : real_(r), imag_(i) {} double real() const { - return _real; + return real_; } double imag() const { - return _imag; + return imag_; } private: - double _real, _imag; + double real_, imag_; }; namespace ArduinoJson { @@ -152,3 +152,16 @@ TEST_CASE("ConverterNeedsWriteableRef") { CHECK(ConverterNeedsWriteableRef::value == true); CHECK(ConverterNeedsWriteableRef::value == false); } + +namespace ArduinoJson { +void convertToJson(char c, JsonVariant var) { + char buf[] = {c, 0}; + var.set(buf); +} +} // namespace ArduinoJson + +TEST_CASE("Convert char to string") { // issue #1922 + StaticJsonDocument<64> doc; + doc.set('a'); + REQUIRE(doc.as() == "a"); +} diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp index 91489f9..7089f64 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp @@ -5,6 +5,11 @@ #include #include +TEST_CASE("VariantData") { + REQUIRE(std::is_standard_layout::value == + true); +} + TEST_CASE("JsonVariant from JsonArray") { SECTION("JsonArray is null") { JsonArray arr; diff --git a/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp b/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp index bd04e16..0b8f4d5 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp @@ -170,19 +170,19 @@ TEST_CASE("IteratorReader") { class StreamStub : public Stream { public: - StreamStub(const char* s) : _stream(s) {} + StreamStub(const char* s) : stream_(s) {} int read() { - return _stream.get(); + return stream_.get(); } size_t readBytes(char* buffer, size_t length) { - _stream.read(buffer, static_cast(length)); - return static_cast(_stream.gcount()); + stream_.read(buffer, static_cast(length)); + return static_cast(stream_.gcount()); } private: - std::istringstream _stream; + std::istringstream stream_; }; TEST_CASE("Reader") { diff --git a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp index cc6d681..1c77e08 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp @@ -2,17 +2,16 @@ // Copyright © 2014-2023, Benoit BLANCHON // MIT License -#define ARDUINOJSON_ENABLE_PROGMEM 1 - -#include "custom_string.hpp" -#include "progmem_emulation.hpp" -#include "weird_strcmp.hpp" +#include #include #include #include +#include "custom_string.hpp" +#include "weird_strcmp.hpp" + using namespace ArduinoJson::detail; TEST_CASE("ZeroTerminatedRamString") { diff --git a/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp b/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp index 3cc1333..81cb88e 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp @@ -2,10 +2,13 @@ // Copyright © 2014-2023, Benoit BLANCHON // MIT License -#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 +#include + #define ARDUINOJSON_STRING_BUFFER_SIZE 5 #include + #include + #include "custom_string.hpp" using namespace ArduinoJson::detail; diff --git a/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp b/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp index 0956682..75c6c11 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp @@ -52,5 +52,11 @@ #define BLOCKSIZE #define CAPACITY +// issue #1905 +#define _current + +// issue #1914 +#define V6 6 + // catch.hpp mutes several warnings, this file also allows to detect them #include "ArduinoJson.h" diff --git a/third-party/ArduinoJson/extras/tests/Misc/printable.cpp b/third-party/ArduinoJson/extras/tests/Misc/printable.cpp index 0c6e8e1..09c23ad 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/printable.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/printable.cpp @@ -29,21 +29,21 @@ struct PrintAllAtOnce { template struct PrintableString : public Printable { - PrintableString(const char* s) : _str(s), _total(0) {} + PrintableString(const char* s) : str_(s), total_(0) {} virtual size_t printTo(Print& p) const { - size_t result = PrintPolicy::printStringTo(_str, p); - _total += result; + size_t result = PrintPolicy::printStringTo(str_, p); + total_ += result; return result; } size_t totalBytesWritten() const { - return _total; + return total_; } private: - std::string _str; - mutable size_t _total; + std::string str_; + mutable size_t total_; }; TEST_CASE("Printable") { diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp index 92a3cbf..2cc683d 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp @@ -2,8 +2,6 @@ // Copyright © 2014-2023, Benoit BLANCHON // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_PROGMEM 1 #include diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp index d763eec..7277af9 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_0.cpp @@ -2,8 +2,6 @@ // Copyright © 2014-2023, Benoit BLANCHON // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 0 diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp index a8388a9..d3b2285 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_string_deduplication_1.cpp @@ -2,8 +2,6 @@ // Copyright © 2014-2023, Benoit BLANCHON // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp index f3ab7f9..f8ca566 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp @@ -5,8 +5,6 @@ #define ARDUINO #define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) -#include "progmem_emulation.hpp" - #include #include diff --git a/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp b/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp index 3522151..48163c1 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp +++ b/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp @@ -10,8 +10,6 @@ using namespace ArduinoJson::detail; TEST_CASE("Test unsigned integer overflow") { VariantData first, second; - first.init(); - second.init(); // Avoids MSVC warning C4127 (conditional expression is constant) size_t integerSize = sizeof(JsonInteger); @@ -30,8 +28,6 @@ TEST_CASE("Test unsigned integer overflow") { TEST_CASE("Test signed integer overflow") { VariantData first, second; - first.init(); - second.init(); // Avoids MSVC warning C4127 (conditional expression is constant) size_t integerSize = sizeof(JsonInteger); @@ -50,7 +46,6 @@ TEST_CASE("Test signed integer overflow") { TEST_CASE("Invalid value") { VariantData result; - result.init(); parseNumber("6a3", result); diff --git a/third-party/ArduinoJson/idf_component.yml b/third-party/ArduinoJson/idf_component.yml index 78dd0b2..51be472 100644 --- a/third-party/ArduinoJson/idf_component.yml +++ b/third-party/ArduinoJson/idf_component.yml @@ -1,4 +1,4 @@ -version: "6.21.0" +version: "6.21.3" description: >- A simple and efficient JSON library for embedded C++. ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ fixed allocation, ✔ zero-copy, ✔ streams, ✔ filtering, and more. @@ -8,5 +8,6 @@ url: https://arduinojson.org/ files: exclude: - "**/.vs/**/*" + - ".devcontainer/**/*" - "examples/**/*" - "extras/**/*" diff --git a/third-party/ArduinoJson/library.json b/third-party/ArduinoJson/library.json index b385770..9b5d7df 100644 --- a/third-party/ArduinoJson/library.json +++ b/third-party/ArduinoJson/library.json @@ -7,12 +7,13 @@ "type": "git", "url": "https://github.com/bblanchon/ArduinoJson.git" }, - "version": "6.21.0", + "version": "6.21.3", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" }, "exclude": [ + ".devcontainer", ".github", "extras" ], diff --git a/third-party/ArduinoJson/library.properties b/third-party/ArduinoJson/library.properties index e6e3134..6a285cf 100644 --- a/third-party/ArduinoJson/library.properties +++ b/third-party/ArduinoJson/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=6.21.0 +version=6.21.3 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. diff --git a/third-party/ArduinoJson/src/ArduinoJson.hpp b/third-party/ArduinoJson/src/ArduinoJson.hpp index 0c8832a..2d1b0be 100644 --- a/third-party/ArduinoJson/src/ArduinoJson.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson.hpp @@ -13,7 +13,8 @@ // Include Arduino.h before stdlib.h to avoid conflict with atexit() // https://github.com/bblanchon/ArduinoJson/pull/1693#issuecomment-1001060240 #if ARDUINOJSON_ENABLE_ARDUINO_STRING || ARDUINOJSON_ENABLE_ARDUINO_STREAM || \ - ARDUINOJSON_ENABLE_ARDUINO_PRINT || ARDUINOJSON_ENABLE_PROGMEM + ARDUINOJSON_ENABLE_ARDUINO_PRINT || \ + (ARDUINOJSON_ENABLE_PROGMEM && defined(ARDUINO)) # include #endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp index 1a9e9ce..d6e9aa5 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -17,10 +17,10 @@ class ElementProxy : public VariantRefBase>, public: ElementProxy(TUpstream upstream, size_t index) - : _upstream(upstream), _index(index) {} + : upstream_(upstream), index_(index) {} ElementProxy(const ElementProxy& src) - : _upstream(src._upstream), _index(src._index) {} + : upstream_(src.upstream_), index_(src.index_) {} FORCE_INLINE ElementProxy& operator=(const ElementProxy& src) { this->set(src); @@ -41,20 +41,20 @@ class ElementProxy : public VariantRefBase>, private: FORCE_INLINE MemoryPool* getPool() const { - return VariantAttorney::getPool(_upstream); + return VariantAttorney::getPool(upstream_); } FORCE_INLINE VariantData* getData() const { - return variantGetElement(VariantAttorney::getData(_upstream), _index); + return variantGetElement(VariantAttorney::getData(upstream_), index_); } FORCE_INLINE VariantData* getOrCreateData() const { - return variantGetOrAddElement(VariantAttorney::getOrCreateData(_upstream), - _index, VariantAttorney::getPool(_upstream)); + return variantGetOrAddElement(VariantAttorney::getOrCreateData(upstream_), + index_, VariantAttorney::getPool(upstream_)); } - TUpstream _upstream; - size_t _index; + TUpstream upstream_; + size_t index_; }; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp index 00df67c..d208e41 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp @@ -20,32 +20,32 @@ class JsonArray : public detail::VariantOperators { typedef JsonArrayIterator iterator; // Constructs an unbound reference. - FORCE_INLINE JsonArray() : _data(0), _pool(0) {} + FORCE_INLINE JsonArray() : data_(0), pool_(0) {} // INTERNAL USE ONLY FORCE_INLINE JsonArray(detail::MemoryPool* pool, detail::CollectionData* data) - : _data(data), _pool(pool) {} + : data_(data), pool_(pool) {} // Returns a JsonVariant pointing to the array. // https://arduinojson.org/v6/api/jsonvariant/ operator JsonVariant() { - void* data = _data; // prevent warning cast-align - return JsonVariant(_pool, reinterpret_cast(data)); + void* data = data_; // prevent warning cast-align + return JsonVariant(pool_, reinterpret_cast(data)); } // Returns a read-only reference to the array. // https://arduinojson.org/v6/api/jsonarrayconst/ operator JsonArrayConst() const { - return JsonArrayConst(_data); + return JsonArrayConst(data_); } // Appends a new (null) element to the array. // Returns a reference to the new element. // https://arduinojson.org/v6/api/jsonarray/add/ JsonVariant add() const { - if (!_data) + if (!data_) return JsonVariant(); - return JsonVariant(_pool, _data->addElement(_pool)); + return JsonVariant(pool_, data_->addElement(pool_)); } // Appends a value to the array. @@ -65,9 +65,9 @@ class JsonArray : public detail::VariantOperators { // Returns an iterator to the first element of the array. // https://arduinojson.org/v6/api/jsonarray/begin/ FORCE_INLINE iterator begin() const { - if (!_data) + if (!data_) return iterator(); - return iterator(_pool, _data->head()); + return iterator(pool_, data_->head()); } // Returns an iterator following the last element of the array. @@ -79,41 +79,41 @@ class JsonArray : public detail::VariantOperators { // Copies an array. // https://arduinojson.org/v6/api/jsonarray/set/ FORCE_INLINE bool set(JsonArrayConst src) const { - if (!_data || !src._data) + if (!data_ || !src.data_) return false; - return _data->copyFrom(*src._data, _pool); + return data_->copyFrom(*src.data_, pool_); } // Compares the content of two arrays. FORCE_INLINE bool operator==(JsonArray rhs) const { - return JsonArrayConst(_data) == JsonArrayConst(rhs._data); + return JsonArrayConst(data_) == JsonArrayConst(rhs.data_); } // Removes the element at the specified iterator. // ⚠️ Doesn't release the memory associated with the removed element. // https://arduinojson.org/v6/api/jsonarray/remove/ FORCE_INLINE void remove(iterator it) const { - if (!_data) + if (!data_) return; - _data->removeSlot(it._slot); + data_->removeSlot(it.slot_); } // Removes the element at the specified index. // ⚠️ Doesn't release the memory associated with the removed element. // https://arduinojson.org/v6/api/jsonarray/remove/ FORCE_INLINE void remove(size_t index) const { - if (!_data) + if (!data_) return; - _data->removeElement(index); + data_->removeElement(index); } // Removes all the elements of the array. // ⚠️ Doesn't release the memory associated with the removed elements. // https://arduinojson.org/v6/api/jsonarray/clear/ void clear() const { - if (!_data) + if (!data_) return; - _data->clear(); + data_->clear(); } // Gets or sets the element at the specified index. @@ -133,54 +133,54 @@ class JsonArray : public detail::VariantOperators { } operator JsonVariantConst() const { - return JsonVariantConst(collectionToVariant(_data)); + return JsonVariantConst(collectionToVariant(data_)); } // Returns true if the reference is unbound. // https://arduinojson.org/v6/api/jsonarray/isnull/ FORCE_INLINE bool isNull() const { - return _data == 0; + return data_ == 0; } // Returns true if the reference is bound. // https://arduinojson.org/v6/api/jsonarray/isnull/ FORCE_INLINE operator bool() const { - return _data != 0; + return data_ != 0; } // Returns the number of bytes occupied by the array. // https://arduinojson.org/v6/api/jsonarray/memoryusage/ FORCE_INLINE size_t memoryUsage() const { - return _data ? _data->memoryUsage() : 0; + return data_ ? data_->memoryUsage() : 0; } // Returns the depth (nesting level) of the array. // https://arduinojson.org/v6/api/jsonarray/nesting/ FORCE_INLINE size_t nesting() const { - return variantNesting(collectionToVariant(_data)); + return variantNesting(collectionToVariant(data_)); } // Returns the number of elements in the array. // https://arduinojson.org/v6/api/jsonarray/size/ FORCE_INLINE size_t size() const { - return _data ? _data->size() : 0; + return data_ ? data_->size() : 0; } private: detail::MemoryPool* getPool() const { - return _pool; + return pool_; } detail::VariantData* getData() const { - return collectionToVariant(_data); + return collectionToVariant(data_); } detail::VariantData* getOrCreateData() const { - return collectionToVariant(_data); + return collectionToVariant(data_); } - detail::CollectionData* _data; - detail::MemoryPool* _pool; + detail::CollectionData* data_; + detail::MemoryPool* pool_; }; template <> diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp index 6c60e98..6a6463c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp @@ -24,9 +24,9 @@ class JsonArrayConst : public detail::VariantOperators { // Returns an iterator to the first element of the array. // https://arduinojson.org/v6/api/jsonarrayconst/begin/ FORCE_INLINE iterator begin() const { - if (!_data) + if (!data_) return iterator(); - return iterator(_data->head()); + return iterator(data_->head()); } // Returns an iterator to the element following the last element of the array. @@ -36,18 +36,18 @@ class JsonArrayConst : public detail::VariantOperators { } // Creates an unbound reference. - FORCE_INLINE JsonArrayConst() : _data(0) {} + FORCE_INLINE JsonArrayConst() : data_(0) {} // INTERNAL USE ONLY FORCE_INLINE JsonArrayConst(const detail::CollectionData* data) - : _data(data) {} + : data_(data) {} // Compares the content of two arrays. // Returns true if the two arrays are equal. FORCE_INLINE bool operator==(JsonArrayConst rhs) const { - if (_data == rhs._data) + if (data_ == rhs.data_) return true; - if (!_data || !rhs._data) + if (!data_ || !rhs.data_) return false; iterator it1 = begin(); @@ -70,49 +70,49 @@ class JsonArrayConst : public detail::VariantOperators { // Returns the element at the specified index. // https://arduinojson.org/v6/api/jsonarrayconst/subscript/ FORCE_INLINE JsonVariantConst operator[](size_t index) const { - return JsonVariantConst(_data ? _data->getElement(index) : 0); + return JsonVariantConst(data_ ? data_->getElement(index) : 0); } operator JsonVariantConst() const { - return JsonVariantConst(collectionToVariant(_data)); + return JsonVariantConst(collectionToVariant(data_)); } // Returns true if the reference is unbound. // https://arduinojson.org/v6/api/jsonarrayconst/isnull/ FORCE_INLINE bool isNull() const { - return _data == 0; + return data_ == 0; } // Returns true if the reference is bound. // https://arduinojson.org/v6/api/jsonarrayconst/isnull/ FORCE_INLINE operator bool() const { - return _data != 0; + return data_ != 0; } // Returns the number of bytes occupied by the array. // https://arduinojson.org/v6/api/jsonarrayconst/memoryusage/ FORCE_INLINE size_t memoryUsage() const { - return _data ? _data->memoryUsage() : 0; + return data_ ? data_->memoryUsage() : 0; } // Returns the depth (nesting level) of the array. // https://arduinojson.org/v6/api/jsonarrayconst/nesting/ FORCE_INLINE size_t nesting() const { - return variantNesting(collectionToVariant(_data)); + return variantNesting(collectionToVariant(data_)); } // Returns the number of elements in the array. // https://arduinojson.org/v6/api/jsonarrayconst/size/ FORCE_INLINE size_t size() const { - return _data ? _data->size() : 0; + return data_ ? data_->size() : 0; } private: const detail::VariantData* getData() const { - return collectionToVariant(_data); + return collectionToVariant(data_); } - const detail::CollectionData* _data; + const detail::CollectionData* data_; }; template <> diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp index 3e1b752..d9048b2 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/JsonArrayIterator.hpp @@ -12,110 +12,110 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE class VariantPtr { public: VariantPtr(detail::MemoryPool* pool, detail::VariantData* data) - : _variant(pool, data) {} + : variant_(pool, data) {} JsonVariant* operator->() { - return &_variant; + return &variant_; } JsonVariant& operator*() { - return _variant; + return variant_; } private: - JsonVariant _variant; + JsonVariant variant_; }; class JsonArrayIterator { friend class JsonArray; public: - JsonArrayIterator() : _slot(0) {} + JsonArrayIterator() : slot_(0) {} explicit JsonArrayIterator(detail::MemoryPool* pool, detail::VariantSlot* slot) - : _pool(pool), _slot(slot) {} + : pool_(pool), slot_(slot) {} JsonVariant operator*() const { - return JsonVariant(_pool, _slot->data()); + return JsonVariant(pool_, slot_->data()); } VariantPtr operator->() { - return VariantPtr(_pool, _slot->data()); + return VariantPtr(pool_, slot_->data()); } bool operator==(const JsonArrayIterator& other) const { - return _slot == other._slot; + return slot_ == other.slot_; } bool operator!=(const JsonArrayIterator& other) const { - return _slot != other._slot; + return slot_ != other.slot_; } JsonArrayIterator& operator++() { - _slot = _slot->next(); + slot_ = slot_->next(); return *this; } JsonArrayIterator& operator+=(size_t distance) { - _slot = _slot->next(distance); + slot_ = slot_->next(distance); return *this; } private: - detail::MemoryPool* _pool; - detail::VariantSlot* _slot; + detail::MemoryPool* pool_; + detail::VariantSlot* slot_; }; class VariantConstPtr { public: - VariantConstPtr(const detail::VariantData* data) : _variant(data) {} + VariantConstPtr(const detail::VariantData* data) : variant_(data) {} JsonVariantConst* operator->() { - return &_variant; + return &variant_; } JsonVariantConst& operator*() { - return _variant; + return variant_; } private: - JsonVariantConst _variant; + JsonVariantConst variant_; }; class JsonArrayConstIterator { friend class JsonArray; public: - JsonArrayConstIterator() : _slot(0) {} + JsonArrayConstIterator() : slot_(0) {} explicit JsonArrayConstIterator(const detail::VariantSlot* slot) - : _slot(slot) {} + : slot_(slot) {} JsonVariantConst operator*() const { - return JsonVariantConst(_slot->data()); + return JsonVariantConst(slot_->data()); } VariantConstPtr operator->() { - return VariantConstPtr(_slot->data()); + return VariantConstPtr(slot_->data()); } bool operator==(const JsonArrayConstIterator& other) const { - return _slot == other._slot; + return slot_ == other.slot_; } bool operator!=(const JsonArrayConstIterator& other) const { - return _slot != other._slot; + return slot_ != other.slot_; } JsonArrayConstIterator& operator++() { - _slot = _slot->next(); + slot_ = slot_->next(); return *this; } JsonArrayConstIterator& operator+=(size_t distance) { - _slot = _slot->next(distance); + slot_ = slot_->next(distance); return *this; } private: - const detail::VariantSlot* _slot; + const detail::VariantSlot* slot_; }; ARDUINOJSON_END_PUBLIC_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp index aa807b5..090c98b 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp @@ -16,8 +16,8 @@ class VariantData; class VariantSlot; class CollectionData { - VariantSlot* _head; - VariantSlot* _tail; + VariantSlot* head_; + VariantSlot* tail_; public: // Must be a POD! @@ -67,7 +67,7 @@ class CollectionData { bool copyFrom(const CollectionData& src, MemoryPool* pool); VariantSlot* head() const { - return _head; + return head_; } void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance); diff --git a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp index c99b524..134d5bd 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp @@ -16,13 +16,13 @@ inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { if (!slot) return 0; - if (_tail) { - ARDUINOJSON_ASSERT(pool->owns(_tail)); // Can't alter a linked array/object - _tail->setNextNotNull(slot); - _tail = slot; + if (tail_) { + ARDUINOJSON_ASSERT(pool->owns(tail_)); // Can't alter a linked array/object + tail_->setNextNotNull(slot); + tail_ = slot; } else { - _head = slot; - _tail = slot; + head_ = slot; + tail_ = slot; } slot->clear(); @@ -45,8 +45,8 @@ inline VariantData* CollectionData::addMember(TAdaptedString key, } inline void CollectionData::clear() { - _head = 0; - _tail = 0; + head_ = 0; + tail_ = 0; } template @@ -57,7 +57,7 @@ inline bool CollectionData::containsKey(const TAdaptedString& key) const { inline bool CollectionData::copyFrom(const CollectionData& src, MemoryPool* pool) { clear(); - for (VariantSlot* s = src._head; s; s = s->next()) { + for (VariantSlot* s = src.head_; s; s = s->next()) { VariantData* var; if (s->key() != 0) { JsonString key(s->key(), @@ -78,7 +78,7 @@ template inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { if (key.isNull()) return 0; - VariantSlot* slot = _head; + VariantSlot* slot = head_; while (slot) { if (stringEquals(key, adaptString(slot->key()))) break; @@ -88,13 +88,13 @@ inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { } inline VariantSlot* CollectionData::getSlot(size_t index) const { - if (!_head) + if (!head_) return 0; - return _head->next(index); + return head_->next(index); } inline VariantSlot* CollectionData::getPreviousSlot(VariantSlot* target) const { - VariantSlot* current = _head; + VariantSlot* current = head_; while (current) { VariantSlot* next = current->next(); if (next == target) @@ -132,7 +132,7 @@ inline VariantData* CollectionData::getElement(size_t index) const { inline VariantData* CollectionData::getOrAddElement(size_t index, MemoryPool* pool) { - VariantSlot* slot = _head; + VariantSlot* slot = head_; while (slot && index > 0) { slot = slot->next(); index--; @@ -154,9 +154,9 @@ inline void CollectionData::removeSlot(VariantSlot* slot) { if (prev) prev->setNext(next); else - _head = next; + head_ = next; if (!next) - _tail = prev; + tail_ = prev; } inline void CollectionData::removeElement(size_t index) { @@ -165,7 +165,7 @@ inline void CollectionData::removeElement(size_t index) { inline size_t CollectionData::memoryUsage() const { size_t total = 0; - for (VariantSlot* s = _head; s; s = s->next()) { + for (VariantSlot* s = head_; s; s = s->next()) { total += sizeof(VariantSlot) + s->data()->memoryUsage(); if (s->ownsKey()) total += strlen(s->key()) + 1; @@ -174,7 +174,7 @@ inline size_t CollectionData::memoryUsage() const { } inline size_t CollectionData::size() const { - return slotSize(_head); + return slotSize(head_); } template @@ -188,9 +188,9 @@ inline void movePointer(T*& p, ptrdiff_t offset) { inline void CollectionData::movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance) { - movePointer(_head, variantDistance); - movePointer(_tail, variantDistance); - for (VariantSlot* slot = _head; slot; slot = slot->next()) + movePointer(head_, variantDistance); + movePointer(tail_, variantDistance); + for (VariantSlot* slot = head_; slot; slot = slot->next()) slot->movePointers(stringDistance, variantDistance); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp b/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp index b33a833..ac0ea66 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp @@ -130,9 +130,13 @@ # define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 # endif -// Disable support for PROGMEM +// Enable PROGMEM support on AVR only # ifndef ARDUINOJSON_ENABLE_PROGMEM -# define ARDUINOJSON_ENABLE_PROGMEM 0 +# ifdef __AVR__ +# define ARDUINOJSON_ENABLE_PROGMEM 1 +# else +# define ARDUINOJSON_ENABLE_PROGMEM 0 +# endif # endif #endif // ARDUINO diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp index 2e97a02..1bfc393 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp @@ -26,49 +26,49 @@ class DeserializationError { }; DeserializationError() {} - DeserializationError(Code c) : _code(c) {} + DeserializationError(Code c) : code_(c) {} // Compare with DeserializationError friend bool operator==(const DeserializationError& lhs, const DeserializationError& rhs) { - return lhs._code == rhs._code; + return lhs.code_ == rhs.code_; } friend bool operator!=(const DeserializationError& lhs, const DeserializationError& rhs) { - return lhs._code != rhs._code; + return lhs.code_ != rhs.code_; } // Compare with Code friend bool operator==(const DeserializationError& lhs, Code rhs) { - return lhs._code == rhs; + return lhs.code_ == rhs; } friend bool operator==(Code lhs, const DeserializationError& rhs) { - return lhs == rhs._code; + return lhs == rhs.code_; } friend bool operator!=(const DeserializationError& lhs, Code rhs) { - return lhs._code != rhs; + return lhs.code_ != rhs; } friend bool operator!=(Code lhs, const DeserializationError& rhs) { - return lhs != rhs._code; + return lhs != rhs.code_; } // Returns true if there is an error explicit operator bool() const { - return _code != Ok; + return code_ != Ok; } // Returns internal enum, useful for switch statement Code code() const { - return _code; + return code_; } const char* c_str() const { static const char* messages[] = { "Ok", "EmptyInput", "IncompleteInput", "InvalidInput", "NoMemory", "TooDeep"}; - ARDUINOJSON_ASSERT(static_cast(_code) < + ARDUINOJSON_ASSERT(static_cast(code_) < sizeof(messages) / sizeof(messages[0])); - return messages[_code]; + return messages[code_]; } #if ARDUINOJSON_ENABLE_PROGMEM @@ -82,12 +82,12 @@ class DeserializationError { ARDUINOJSON_DEFINE_PROGMEM_ARRAY(const char*, messages, {s0, s1, s2, s3, s4, s5}); return reinterpret_cast( - detail::pgm_read(messages + _code)); + detail::pgm_read(messages + code_)); } #endif private: - Code _code; + Code code_; }; #if ARDUINOJSON_ENABLE_STD_STREAM diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp index 8857ced..3988302 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp @@ -11,34 +11,34 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE namespace DeserializationOption { class Filter { public: - explicit Filter(JsonVariantConst v) : _variant(v) {} + explicit Filter(JsonVariantConst v) : variant_(v) {} bool allow() const { - return _variant; + return variant_; } bool allowArray() const { - return _variant == true || _variant.is(); + return variant_ == true || variant_.is(); } bool allowObject() const { - return _variant == true || _variant.is(); + return variant_ == true || variant_.is(); } bool allowValue() const { - return _variant == true; + return variant_ == true; } template Filter operator[](const TKey& key) const { - if (_variant == true) // "true" means "allow recursively" + if (variant_ == true) // "true" means "allow recursively" return *this; - JsonVariantConst member = _variant[key]; - return Filter(member.isNull() ? _variant["*"] : member); + JsonVariantConst member = variant_[key]; + return Filter(member.isNull() ? variant_["*"] : member); } private: - JsonVariantConst _variant; + JsonVariantConst variant_; }; } // namespace DeserializationOption diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp index 6d2f675..6434275 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp @@ -12,20 +12,20 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE namespace DeserializationOption { class NestingLimit { public: - NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} - explicit NestingLimit(uint8_t n) : _value(n) {} + NestingLimit() : value_(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} + explicit NestingLimit(uint8_t n) : value_(n) {} NestingLimit decrement() const { - ARDUINOJSON_ASSERT(_value > 0); - return NestingLimit(static_cast(_value - 1)); + ARDUINOJSON_ASSERT(value_ > 0); + return NestingLimit(static_cast(value_ - 1)); } bool reached() const { - return _value == 0; + return value_ == 0; } private: - uint8_t _value; + uint8_t value_; }; } // namespace DeserializationOption diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp index e52af6d..4443768 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp @@ -15,18 +15,20 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template struct Reader { public: - Reader(TSource& source) : _source(&source) {} + Reader(TSource& source) : source_(&source) {} int read() { - return _source->read(); // Error here? You passed an unsupported input type + // clang-format off + return source_->read(); // Error here? See https://arduinojson.org/v6/invalid-input/ + // clang-format on } size_t readBytes(char* buffer, size_t length) { - return _source->readBytes(buffer, length); + return source_->readBytes(buffer, length); } private: - TSource* _source; + TSource* source_; }; template diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp index ac4f212..8a87388 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp @@ -12,20 +12,20 @@ template struct Reader::value>::type> { public: - explicit Reader(Stream& stream) : _stream(&stream) {} + explicit Reader(Stream& stream) : stream_(&stream) {} int read() { - // don't use _stream.read() as it ignores the timeout + // don't use stream_.read() as it ignores the timeout char c; - return _stream->readBytes(&c, 1) ? static_cast(c) : -1; + return stream_->readBytes(&c, 1) ? static_cast(c) : -1; } size_t readBytes(char* buffer, size_t length) { - return _stream->readBytes(buffer, length); + return stream_->readBytes(buffer, length); } private: - Stream* _stream; + Stream* stream_; }; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp index da6880d..97714af 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp @@ -4,51 +4,51 @@ #pragma once -#include +#include ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template <> struct Reader { - const char* _ptr; + const char* ptr_; public: explicit Reader(const __FlashStringHelper* ptr) - : _ptr(reinterpret_cast(ptr)) {} + : ptr_(reinterpret_cast(ptr)) {} int read() { - return pgm_read_byte(_ptr++); + return pgm_read_byte(ptr_++); } size_t readBytes(char* buffer, size_t length) { - memcpy_P(buffer, _ptr, length); - _ptr += length; + memcpy_P(buffer, ptr_, length); + ptr_ += length; return length; } }; template <> struct BoundedReader { - const char* _ptr; - const char* _end; + const char* ptr_; + const char* end_; public: explicit BoundedReader(const __FlashStringHelper* ptr, size_t size) - : _ptr(reinterpret_cast(ptr)), _end(_ptr + size) {} + : ptr_(reinterpret_cast(ptr)), end_(ptr_ + size) {} int read() { - if (_ptr < _end) - return pgm_read_byte(_ptr++); + if (ptr_ < end_) + return pgm_read_byte(ptr_++); else return -1; } size_t readBytes(char* buffer, size_t length) { - size_t available = static_cast(_end - _ptr); + size_t available = static_cast(end_ - ptr_); if (available < length) length = available; - memcpy_P(buffer, _ptr, length); - _ptr += length; + memcpy_P(buffer, ptr_, length); + ptr_ += length; return length; } }; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp index 7189079..c0ca4a7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp @@ -8,23 +8,23 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template class IteratorReader { - TIterator _ptr, _end; + TIterator ptr_, end_; public: explicit IteratorReader(TIterator begin, TIterator end) - : _ptr(begin), _end(end) {} + : ptr_(begin), end_(end) {} int read() { - if (_ptr < _end) - return static_cast(*_ptr++); + if (ptr_ < end_) + return static_cast(*ptr_++); else return -1; } size_t readBytes(char* buffer, size_t length) { size_t i = 0; - while (i < length && _ptr < _end) - buffer[i++] = *_ptr++; + while (i < length && ptr_ < end_) + buffer[i++] = *ptr_++; return i; } }; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp index 78d0199..eff67ba 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp @@ -21,19 +21,19 @@ struct IsCharOrVoid : IsCharOrVoid {}; template struct Reader::value>::type> { - const char* _ptr; + const char* ptr_; public: explicit Reader(const void* ptr) - : _ptr(ptr ? reinterpret_cast(ptr) : "") {} + : ptr_(ptr ? reinterpret_cast(ptr) : "") {} int read() { - return static_cast(*_ptr++); + return static_cast(*ptr_++); } size_t readBytes(char* buffer, size_t length) { for (size_t i = 0; i < length; i++) - buffer[i] = *_ptr++; + buffer[i] = *ptr_++; return length; } }; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp index ecace42..41e0c00 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp @@ -12,19 +12,19 @@ template struct Reader::value>::type> { public: - explicit Reader(std::istream& stream) : _stream(&stream) {} + explicit Reader(std::istream& stream) : stream_(&stream) {} int read() { - return _stream->get(); + return stream_->get(); } size_t readBytes(char* buffer, size_t length) { - _stream->read(buffer, static_cast(length)); - return static_cast(_stream->gcount()); + stream_->read(buffer, static_cast(length)); + return static_cast(stream_->gcount()); } private: - std::istream* _stream; + std::istream* stream_; }; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp index 1d08680..9f4d78e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp @@ -12,6 +12,17 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE +// A meta-function that returns the first type of the parameter pack +// or void if empty +template +struct first_or_void { + using type = void; +}; +template +struct first_or_void { + using type = T; +}; + template