From 8f4b1f65ceb18c306a1e240534ba13fa6a0752e0 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 14 Feb 2022 12:17:19 +0100 Subject: [PATCH] Added new version of ArduinoJson. Removed effect_freeverb_simd. Removed teensy_board_detection.h and exchanged checing for macros from TeensyDuino. --- MicroDexed.ino | 37 +- UI.hpp | 8 +- config.h | 54 +- effect_freeverb_simd.cpp | 848 ------------------ effect_freeverb_simd.h | 185 ---- teensy_board_detection.h | 50 -- third-party/ArduinoJson/ArduinoJson.h | 2 +- third-party/ArduinoJson/CHANGELOG.md | 454 +--------- third-party/ArduinoJson/CMakeLists.txt | 7 +- third-party/ArduinoJson/LICENSE.md | 2 +- third-party/ArduinoJson/README.md | 45 +- third-party/ArduinoJson/appveyor.yml | 47 +- .../JsonConfigFile/JsonConfigFile.ino | 2 +- .../JsonFilterExample/JsonFilterExample.ino | 2 +- .../JsonGeneratorExample.ino | 2 +- .../JsonHttpClient/JsonHttpClient.ino | 2 +- .../JsonParserExample/JsonParserExample.ino | 2 +- .../examples/JsonServer/JsonServer.ino | 2 +- .../examples/JsonUdpBeacon/JsonUdpBeacon.ino | 2 +- .../examples/MsgPackParser/MsgPackParser.ino | 2 +- .../ProgmemExample/ProgmemExample.ino | 10 +- .../examples/StringExample/StringExample.ino | 2 +- .../extras/ci/espidf/CMakeLists.txt | 2 +- .../extras/ci/espidf/main/CMakeLists.txt | 2 +- .../extras/ci/espidf/main/main.cpp | 2 +- .../ArduinoJson/extras/conf_test/avr.cpp | 16 + .../ArduinoJson/extras/conf_test/esp8266.cpp | 16 + .../ArduinoJson/extras/conf_test/x64.cpp | 15 + .../ArduinoJson/extras/conf_test/x86.cpp | 15 + .../ArduinoJson/extras/fuzzing/CMakeLists.txt | 2 +- .../ArduinoJson/extras/fuzzing/reproducer.cpp | 2 +- .../extras/scripts/get-release-body.sh | 2 +- .../ArduinoJson/extras/scripts/publish.sh | 13 +- .../scripts/wandbox/JsonGeneratorExample.cpp | 2 +- .../scripts/wandbox/JsonParserExample.cpp | 2 +- .../scripts/wandbox/MsgPackParserExample.cpp | 2 +- .../extras/scripts/wandbox/publish.sh | 4 +- .../ArduinoJson/extras/tests/CMakeLists.txt | 2 +- .../extras/tests/Cpp11/CMakeLists.txt | 2 +- .../extras/tests/Cpp17/CMakeLists.txt | 2 +- .../extras/tests/Cpp17/string_view.cpp | 21 +- .../extras/tests/Cpp20/CMakeLists.txt | 2 +- .../extras/tests/FailingBuilds/CMakeLists.txt | 2 +- .../extras/tests/FailingBuilds/Issue1189.cpp | 2 +- .../extras/tests/FailingBuilds/Issue978.cpp | 2 +- .../tests/FailingBuilds/assign_char.cpp | 2 +- .../FailingBuilds/delete_jsondocument.cpp | 2 +- .../tests/FailingBuilds/read_long_long.cpp | 2 +- .../tests/FailingBuilds/variant_as_char.cpp | 2 +- .../tests/FailingBuilds/write_long_long.cpp | 2 +- .../extras/tests/Helpers/Arduino.h | 5 +- .../extras/tests/Helpers/CustomReader.hpp | 2 +- .../extras/tests/Helpers/api/Print.h | 2 +- .../extras/tests/Helpers/api/Stream.h | 2 +- .../extras/tests/Helpers/api/String.h | 13 +- .../tests/Helpers/progmem_emulation.hpp | 17 +- .../tests/IntegrationTests/CMakeLists.txt | 2 +- .../tests/IntegrationTests/gbathree.cpp | 2 +- .../tests/IntegrationTests/issue772.cpp | 2 +- .../tests/IntegrationTests/openweathermap.cpp | 2 +- .../tests/IntegrationTests/round_trip.cpp | 2 +- .../extras/tests/JsonArray/CMakeLists.txt | 4 +- .../extras/tests/JsonArray/add.cpp | 2 +- .../extras/tests/JsonArray/clear.cpp | 2 +- .../extras/tests/JsonArray/copyArray.cpp | 69 +- .../extras/tests/JsonArray/createNested.cpp | 2 +- .../extras/tests/JsonArray/equals.cpp | 2 +- .../extras/tests/JsonArray/get.cpp | 2 +- .../extras/tests/JsonArray/isNull.cpp | 2 +- .../extras/tests/JsonArray/iterator.cpp | 2 +- .../extras/tests/JsonArray/memoryUsage.cpp | 2 +- .../extras/tests/JsonArray/nesting.cpp | 2 +- .../extras/tests/JsonArray/remove.cpp | 2 +- .../extras/tests/JsonArray/size.cpp | 2 +- .../extras/tests/JsonArray/std_string.cpp | 2 +- .../extras/tests/JsonArray/subscript.cpp | 2 +- .../extras/tests/JsonArray/unbound.cpp | 35 + .../tests/JsonDeserializer/CMakeLists.txt | 2 +- .../JsonDeserializer/DeserializationError.cpp | 46 +- .../extras/tests/JsonDeserializer/array.cpp | 2 +- .../tests/JsonDeserializer/array_static.cpp | 2 +- .../extras/tests/JsonDeserializer/filter.cpp | 16 +- .../JsonDeserializer/incomplete_input.cpp | 2 +- .../tests/JsonDeserializer/input_types.cpp | 2 +- .../tests/JsonDeserializer/invalid_input.cpp | 2 +- .../extras/tests/JsonDeserializer/misc.cpp | 2 +- .../tests/JsonDeserializer/nestingLimit.cpp | 2 +- .../extras/tests/JsonDeserializer/number.cpp | 2 +- .../extras/tests/JsonDeserializer/object.cpp | 18 +- .../tests/JsonDeserializer/object_static.cpp | 2 +- .../extras/tests/JsonDeserializer/string.cpp | 32 +- .../tests/JsonDocument/BasicJsonDocument.cpp | 40 +- .../extras/tests/JsonDocument/CMakeLists.txt | 3 +- .../JsonDocument/DynamicJsonDocument.cpp | 15 +- .../tests/JsonDocument/ElementProxy.cpp | 2 +- .../extras/tests/JsonDocument/MemberProxy.cpp | 2 +- .../tests/JsonDocument/StaticJsonDocument.cpp | 2 +- .../extras/tests/JsonDocument/add.cpp | 2 +- .../extras/tests/JsonDocument/compare.cpp | 2 +- .../extras/tests/JsonDocument/containsKey.cpp | 2 +- .../tests/JsonDocument/createNested.cpp | 2 +- .../extras/tests/JsonDocument/isNull.cpp | 2 +- .../extras/tests/JsonDocument/nesting.cpp | 2 +- .../extras/tests/JsonDocument/overflowed.cpp | 8 +- .../extras/tests/JsonDocument/remove.cpp | 2 +- .../extras/tests/JsonDocument/shrinkToFit.cpp | 2 +- .../extras/tests/JsonDocument/size.cpp | 2 +- .../extras/tests/JsonDocument/subscript.cpp | 2 +- .../extras/tests/JsonDocument/swap.cpp | 27 + .../extras/tests/JsonObject/CMakeLists.txt | 2 +- .../extras/tests/JsonObject/clear.cpp | 2 +- .../extras/tests/JsonObject/containsKey.cpp | 2 +- .../extras/tests/JsonObject/copy.cpp | 2 +- .../tests/JsonObject/createNestedArray.cpp | 2 +- .../tests/JsonObject/createNestedObject.cpp | 2 +- .../extras/tests/JsonObject/equals.cpp | 2 +- .../extras/tests/JsonObject/invalid.cpp | 2 +- .../extras/tests/JsonObject/isNull.cpp | 2 +- .../extras/tests/JsonObject/iterator.cpp | 2 +- .../extras/tests/JsonObject/memoryUsage.cpp | 2 +- .../extras/tests/JsonObject/nesting.cpp | 2 +- .../extras/tests/JsonObject/remove.cpp | 2 +- .../extras/tests/JsonObject/size.cpp | 2 +- .../extras/tests/JsonObject/std_string.cpp | 2 +- .../extras/tests/JsonObject/subscript.cpp | 2 +- .../tests/JsonSerializer/CMakeLists.txt | 2 +- .../tests/JsonSerializer/CustomWriter.cpp | 2 +- .../extras/tests/JsonSerializer/JsonArray.cpp | 2 +- .../tests/JsonSerializer/JsonArrayPretty.cpp | 2 +- .../tests/JsonSerializer/JsonObject.cpp | 2 +- .../tests/JsonSerializer/JsonObjectPretty.cpp | 2 +- .../tests/JsonSerializer/JsonVariant.cpp | 6 +- .../tests/JsonSerializer/std_stream.cpp | 2 +- .../tests/JsonSerializer/std_string.cpp | 12 +- .../extras/tests/JsonVariant/CMakeLists.txt | 4 +- .../extras/tests/JsonVariant/add.cpp | 2 +- .../extras/tests/JsonVariant/as.cpp | 23 +- .../extras/tests/JsonVariant/clear.cpp | 2 +- .../extras/tests/JsonVariant/compare.cpp | 2 +- .../extras/tests/JsonVariant/containsKey.cpp | 2 +- .../extras/tests/JsonVariant/converters.cpp | 2 +- .../extras/tests/JsonVariant/copy.cpp | 4 +- .../extras/tests/JsonVariant/createNested.cpp | 2 +- .../extras/tests/JsonVariant/is.cpp | 21 +- .../extras/tests/JsonVariant/isnull.cpp | 2 +- .../extras/tests/JsonVariant/memoryUsage.cpp | 6 +- .../extras/tests/JsonVariant/misc.cpp | 2 +- .../extras/tests/JsonVariant/nesting.cpp | 2 +- .../extras/tests/JsonVariant/or.cpp | 14 +- .../extras/tests/JsonVariant/overflow.cpp | 2 +- .../extras/tests/JsonVariant/remove.cpp | 2 +- .../extras/tests/JsonVariant/set.cpp | 2 +- .../extras/tests/JsonVariant/subscript.cpp | 6 +- .../extras/tests/JsonVariant/types.cpp | 2 +- .../extras/tests/JsonVariant/unbound.cpp | 66 ++ .../extras/tests/MemoryPool/CMakeLists.txt | 2 +- .../extras/tests/MemoryPool/StringCopier.cpp | 23 +- .../extras/tests/MemoryPool/allocVariant.cpp | 2 +- .../extras/tests/MemoryPool/clear.cpp | 2 +- .../extras/tests/MemoryPool/saveString.cpp | 27 +- .../extras/tests/MemoryPool/size.cpp | 2 +- .../extras/tests/Misc/CMakeLists.txt | 3 +- .../extras/tests/Misc/FloatParts.cpp | 2 +- .../extras/tests/Misc/JsonString.cpp | 27 +- .../extras/tests/Misc/NoArduinoHeader.cpp | 20 + .../ArduinoJson/extras/tests/Misc/Readers.cpp | 2 +- .../extras/tests/Misc/StringAdapters.cpp | 188 ++-- .../extras/tests/Misc/StringWriter.cpp | 16 +- .../extras/tests/Misc/TypeTraits.cpp | 2 +- .../ArduinoJson/extras/tests/Misc/Utf16.cpp | 2 +- .../ArduinoJson/extras/tests/Misc/Utf8.cpp | 5 +- .../extras/tests/Misc/arithmeticCompare.cpp | 2 +- .../extras/tests/Misc/conflicts.cpp | 2 +- .../extras/tests/Misc/custom_string.hpp | 2 +- .../extras/tests/Misc/deprecated.cpp | 2 +- .../extras/tests/Misc/printable.cpp | 4 +- .../extras/tests/Misc/unsigned_char.cpp | 2 +- .../ArduinoJson/extras/tests/Misc/version.cpp | 2 +- .../extras/tests/Misc/weird_strcmp.hpp | 6 + .../tests/MixedConfiguration/CMakeLists.txt | 3 +- .../MixedConfiguration/enable_comments_0.cpp | 2 +- .../MixedConfiguration/enable_comments_1.cpp | 2 +- .../MixedConfiguration/enable_progmem_1.cpp | 12 +- .../enable_string_deduplication_0.cpp | 4 +- .../enable_string_deduplication_1.cpp | 4 +- .../tests/MixedConfiguration/issue1707.cpp | 17 + .../tests/MsgPackDeserializer/CMakeLists.txt | 2 +- .../MsgPackDeserializer/deserializeArray.cpp | 2 +- .../MsgPackDeserializer/deserializeObject.cpp | 2 +- .../deserializeStaticVariant.cpp | 2 +- .../deserializeVariant.cpp | 2 +- .../MsgPackDeserializer/doubleToFloat.cpp | 2 +- .../tests/MsgPackDeserializer/filter.cpp | 16 +- .../MsgPackDeserializer/incompleteInput.cpp | 2 +- .../tests/MsgPackDeserializer/input_types.cpp | 2 +- .../extras/tests/MsgPackDeserializer/misc.cpp | 2 +- .../MsgPackDeserializer/nestingLimit.cpp | 2 +- .../MsgPackDeserializer/notSupported.cpp | 2 +- .../tests/MsgPackSerializer/CMakeLists.txt | 2 +- .../MsgPackSerializer/destination_types.cpp | 2 +- .../tests/MsgPackSerializer/measure.cpp | 2 +- .../MsgPackSerializer/serializeArray.cpp | 2 +- .../MsgPackSerializer/serializeObject.cpp | 2 +- .../MsgPackSerializer/serializeVariant.cpp | 4 +- .../extras/tests/Numbers/CMakeLists.txt | 2 +- .../extras/tests/Numbers/convertNumber.cpp | 2 +- .../extras/tests/Numbers/parseDouble.cpp | 2 +- .../extras/tests/Numbers/parseFloat.cpp | 2 +- .../extras/tests/Numbers/parseInteger.cpp | 2 +- .../extras/tests/Numbers/parseNumber.cpp | 2 +- .../extras/tests/TextFormatter/CMakeLists.txt | 2 +- .../extras/tests/TextFormatter/writeFloat.cpp | 2 +- .../tests/TextFormatter/writeInteger.cpp | 2 +- .../tests/TextFormatter/writeString.cpp | 2 +- .../extras/tests/catch/CMakeLists.txt | 3 + third-party/ArduinoJson/library.json | 2 +- third-party/ArduinoJson/library.properties | 2 +- third-party/ArduinoJson/src/ArduinoJson.h | 4 +- third-party/ArduinoJson/src/ArduinoJson.hpp | 9 +- .../src/ArduinoJson/Array/ArrayFunctions.hpp | 2 +- .../src/ArduinoJson/Array/ArrayImpl.hpp | 2 +- .../src/ArduinoJson/Array/ArrayIterator.hpp | 2 +- .../src/ArduinoJson/Array/ArrayRef.hpp | 2 +- .../src/ArduinoJson/Array/ArrayShortcuts.hpp | 2 +- .../src/ArduinoJson/Array/ElementProxy.hpp | 2 +- .../src/ArduinoJson/Array/Utilities.hpp | 154 ++-- .../ArduinoJson/Collection/CollectionData.hpp | 11 +- .../ArduinoJson/Collection/CollectionImpl.hpp | 29 +- .../src/ArduinoJson/Configuration.hpp | 174 ++-- .../Deserialization/DeserializationError.hpp | 23 +- .../ArduinoJson/Deserialization/Filter.hpp | 2 +- .../Deserialization/NestingLimit.hpp | 2 +- .../ArduinoJson/Deserialization/Reader.hpp | 2 +- .../Readers/ArduinoStreamReader.hpp | 2 +- .../Readers/ArduinoStringReader.hpp | 4 +- .../Deserialization/Readers/FlashReader.hpp | 4 +- .../Readers/IteratorReader.hpp | 2 +- .../Deserialization/Readers/RamReader.hpp | 2 +- .../Readers/StdStreamReader.hpp | 2 +- .../Deserialization/Readers/VariantReader.hpp | 2 +- .../Deserialization/deserialize.hpp | 2 +- .../Document/BasicJsonDocument.hpp | 14 +- .../Document/DynamicJsonDocument.hpp | 2 +- .../src/ArduinoJson/Document/JsonDocument.hpp | 15 +- .../Document/StaticJsonDocument.hpp | 6 +- .../src/ArduinoJson/Json/EscapeSequence.hpp | 2 +- .../src/ArduinoJson/Json/JsonDeserializer.hpp | 17 +- .../src/ArduinoJson/Json/JsonSerializer.hpp | 8 +- .../src/ArduinoJson/Json/Latch.hpp | 2 +- .../ArduinoJson/Json/PrettyJsonSerializer.hpp | 2 +- .../src/ArduinoJson/Json/TextFormatter.hpp | 13 +- .../src/ArduinoJson/Json/Utf16.hpp | 2 +- .../ArduinoJson/src/ArduinoJson/Json/Utf8.hpp | 2 +- .../src/ArduinoJson/Memory/Alignment.hpp | 2 +- .../src/ArduinoJson/Memory/MemoryPool.hpp | 16 +- .../src/ArduinoJson/Misc/SafeBoolIdiom.hpp | 26 + .../src/ArduinoJson/Misc/SerializedValue.hpp | 2 +- .../src/ArduinoJson/Misc/Visitable.hpp | 2 +- .../MsgPack/MsgPackDeserializer.hpp | 19 +- .../ArduinoJson/MsgPack/MsgPackSerializer.hpp | 8 +- .../src/ArduinoJson/MsgPack/endianess.hpp | 23 +- .../src/ArduinoJson/MsgPack/ieee754.hpp | 2 +- .../ArduinoJson/src/ArduinoJson/Namespace.hpp | 2 +- .../src/ArduinoJson/Numbers/Float.hpp | 2 +- .../src/ArduinoJson/Numbers/FloatParts.hpp | 2 +- .../src/ArduinoJson/Numbers/FloatTraits.hpp | 44 +- .../src/ArduinoJson/Numbers/Integer.hpp | 2 +- .../ArduinoJson/Numbers/arithmeticCompare.hpp | 2 +- .../src/ArduinoJson/Numbers/convertNumber.hpp | 2 +- .../src/ArduinoJson/Numbers/parseNumber.hpp | 2 +- .../src/ArduinoJson/Object/MemberProxy.hpp | 2 +- .../ArduinoJson/Object/ObjectFunctions.hpp | 9 +- .../src/ArduinoJson/Object/ObjectImpl.hpp | 6 +- .../src/ArduinoJson/Object/ObjectIterator.hpp | 2 +- .../src/ArduinoJson/Object/ObjectRef.hpp | 12 +- .../ArduinoJson/Object/ObjectShortcuts.hpp | 2 +- .../src/ArduinoJson/Object/Pair.hpp | 2 +- .../src/ArduinoJson/Polyfills/alias_cast.hpp | 2 +- .../src/ArduinoJson/Polyfills/assert.hpp | 2 +- .../src/ArduinoJson/Polyfills/attributes.hpp | 2 +- .../src/ArduinoJson/Polyfills/ctype.hpp | 2 +- .../src/ArduinoJson/Polyfills/integer.hpp | 2 +- .../src/ArduinoJson/Polyfills/limits.hpp | 2 +- .../src/ArduinoJson/Polyfills/math.hpp | 2 +- .../src/ArduinoJson/Polyfills/mpl/max.hpp | 2 +- .../src/ArduinoJson/Polyfills/pgmspace.hpp | 38 +- .../Polyfills/pgmspace_generic.hpp | 12 +- .../ArduinoJson/Polyfills/preprocessor.hpp | 2 +- .../ArduinoJson/Polyfills/static_array.hpp | 24 +- .../src/ArduinoJson/Polyfills/type_traits.hpp | 2 +- .../Polyfills/type_traits/conditional.hpp | 2 +- .../Polyfills/type_traits/declval.hpp | 2 +- .../Polyfills/type_traits/enable_if.hpp | 2 +- .../type_traits/integral_constant.hpp | 2 +- .../Polyfills/type_traits/is_array.hpp | 2 +- .../Polyfills/type_traits/is_base_of.hpp | 2 +- .../Polyfills/type_traits/is_class.hpp | 2 +- .../Polyfills/type_traits/is_const.hpp | 2 +- .../Polyfills/type_traits/is_convertible.hpp | 2 +- .../Polyfills/type_traits/is_enum.hpp | 2 +- .../type_traits/is_floating_point.hpp | 2 +- .../Polyfills/type_traits/is_integral.hpp | 2 +- .../Polyfills/type_traits/is_pointer.hpp | 2 +- .../Polyfills/type_traits/is_same.hpp | 2 +- .../Polyfills/type_traits/is_signed.hpp | 2 +- .../Polyfills/type_traits/is_unsigned.hpp | 2 +- .../Polyfills/type_traits/make_unsigned.hpp | 2 +- .../Polyfills/type_traits/make_void.hpp | 2 +- .../Polyfills/type_traits/remove_const.hpp | 2 +- .../Polyfills/type_traits/remove_cv.hpp | 2 +- .../type_traits/remove_reference.hpp | 2 +- .../Polyfills/type_traits/type_identity.hpp | 2 +- .../Serialization/CountingDecorator.hpp | 2 +- .../src/ArduinoJson/Serialization/Writer.hpp | 2 +- .../Writers/ArduinoStringWriter.hpp | 2 +- .../Serialization/Writers/DummyWriter.hpp | 2 +- .../Serialization/Writers/PrintWriter.hpp | 4 +- .../Writers/StaticStringWriter.hpp | 2 +- .../Serialization/Writers/StdStreamWriter.hpp | 2 +- .../Serialization/Writers/StdStringWriter.hpp | 2 +- .../src/ArduinoJson/Serialization/measure.hpp | 2 +- .../ArduinoJson/Serialization/serialize.hpp | 2 +- .../StringStorage/StringCopier.hpp | 36 +- .../ArduinoJson/StringStorage/StringMover.hpp | 19 +- .../StringStorage/StringStorage.hpp | 2 +- .../Strings/Adapters/ArduinoString.hpp | 24 + .../Strings/Adapters/FlashString.hpp | 80 ++ .../Strings/Adapters/JsonString.hpp | 20 + .../Strings/Adapters/RamString.hpp | 119 +++ .../Strings/Adapters/StdString.hpp | 23 + .../Strings/Adapters/StringView.hpp | 20 + .../src/ArduinoJson/Strings/IsString.hpp | 11 +- .../src/ArduinoJson/Strings/StoragePolicy.hpp | 53 +- .../src/ArduinoJson/Strings/String.hpp | 37 +- .../ArduinoJson/Strings/StringAdapters.hpp | 81 +- .../src/ArduinoJson/Variant/Converter.hpp | 2 +- .../src/ArduinoJson/Variant/ConverterImpl.hpp | 95 +- .../src/ArduinoJson/Variant/SlotFunctions.hpp | 44 +- .../ArduinoJson/Variant/VariantCompare.hpp | 12 +- .../ArduinoJson/Variant/VariantContent.hpp | 5 +- .../src/ArduinoJson/Variant/VariantData.hpp | 131 ++- .../ArduinoJson/Variant/VariantFunctions.hpp | 21 +- .../src/ArduinoJson/Variant/VariantImpl.hpp | 46 +- .../ArduinoJson/Variant/VariantOperators.hpp | 4 +- .../src/ArduinoJson/Variant/VariantRef.hpp | 4 +- .../ArduinoJson/Variant/VariantShortcuts.hpp | 2 +- .../src/ArduinoJson/Variant/VariantSlot.hpp | 22 +- .../src/ArduinoJson/Variant/VariantTag.hpp | 2 +- .../src/ArduinoJson/Variant/VariantTo.hpp | 2 +- .../src/ArduinoJson/Variant/Visitor.hpp | 4 +- .../src/ArduinoJson/compatibility.hpp | 2 +- .../ArduinoJson/src/ArduinoJson/version.hpp | 8 +- third-party/ArduinoJson/src/CMakeLists.txt | 2 +- 353 files changed, 2245 insertions(+), 2617 deletions(-) delete mode 100644 effect_freeverb_simd.cpp delete mode 100644 effect_freeverb_simd.h delete mode 100644 teensy_board_detection.h create mode 100644 third-party/ArduinoJson/extras/conf_test/avr.cpp create mode 100644 third-party/ArduinoJson/extras/conf_test/esp8266.cpp create mode 100644 third-party/ArduinoJson/extras/conf_test/x64.cpp create mode 100644 third-party/ArduinoJson/extras/conf_test/x86.cpp create mode 100644 third-party/ArduinoJson/extras/tests/JsonArray/unbound.cpp create mode 100644 third-party/ArduinoJson/extras/tests/JsonDocument/swap.cpp create mode 100644 third-party/ArduinoJson/extras/tests/JsonVariant/unbound.cpp create mode 100644 third-party/ArduinoJson/extras/tests/Misc/NoArduinoHeader.cpp create mode 100644 third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Misc/SafeBoolIdiom.hpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoString.hpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdString.hpp create mode 100644 third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringView.hpp diff --git a/MicroDexed.ino b/MicroDexed.ino index 5b81347..4beeb4d 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -22,6 +22,17 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + TODO + #if defined(ARDUINO_TEENSY41) + #define NUM_DRUMSET_CONFIG 71 + #elif defined(ARDUINO_TEENSY40) + #define NUM_DRUMSET_CONFIG 47 + #else + #define NUM_DRUMSET_CONFIG 19 + #endif +*/ + #include #include "config.h" #include @@ -41,8 +52,6 @@ using namespace TeensyTimerTool; #include "effect_mono_stereo.h" #if defined(USE_PLATEREVERB) #include "effect_platervbstereo.h" -#elif defined(USE_FREEVERB_SIMD) -#include "effect_freeverb_simd.h" #else #include "effect_freeverbf.h" #endif @@ -102,8 +111,6 @@ AudioMixer<3> reverb_mixer_l; #endif #if defined(USE_PLATEREVERB) AudioEffectPlateReverb reverb; -#elif defined(USE_FREEVERB_SIMD) -AudioEffectFreeverbSIMDStereo freeverb; #else AudioEffectFreeverbStereoFloat freeverb; #endif @@ -384,7 +391,7 @@ char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; char receive_bank_filename[FILENAME_LEN]; uint8_t selected_instance_id = 0; uint8_t seq_UI_last_step = 0; -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #if NUM_DEXED>1 int8_t midi_decay[NUM_DEXED] = { -1, -1}; #else @@ -449,7 +456,7 @@ void setup() #endif #endif -#if defined(DEBUG) && defined(TEENSY_4) +#if defined(DEBUG) && (defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)) Serial.println(F("-------------------------------------------------------------------------------")); Serial.println(F("Latest crash report:")); Serial.println(CrashReport); @@ -836,7 +843,7 @@ void loop() { for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) if (midi_decay_timer > MIDI_DECAY_TIMER && midi_decay[instance_id] > 0) { midi_decay[instance_id]--; @@ -866,7 +873,7 @@ void loop() } #endif } -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) if (midi_decay_timer > MIDI_DECAY_LEVEL_TIME) { midi_decay_timer = 0; @@ -1077,7 +1084,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) MicroDexed[instance_id]->keydown(inNumber, uint8_t(float(configuration.dexed[instance_id].velocity_level / 127.0)*inVelocity + 0.5)); midi_voices[instance_id]++; -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) { midi_decay_timer = 0; @@ -2868,13 +2875,11 @@ void generate_version_string(char* buffer, uint8_t len) memset(buffer, 0, len); strncat(buffer, VERSION, len); -#if defined(TEENSY3_5) - strncat(buffer, "-3.5", 4); -#elif defined(TEENSY3_6) +#if defined(ARDUINO_TEENSY36) strncat(buffer, "-3.6", 4); -#elif defined(TEENSY4_0) +#elif defined(ARDUINO_TEENSY40) strncat(buffer, "-4.0", 4); -#elif defined(TEENSY4_1) +#elif defined(ARDUINO_TEENSY41) strncat(buffer, "-4.1", 4); #endif #if defined(USE_FX) @@ -3154,7 +3159,7 @@ void show_cpu_and_mem_usage(void) Serial.print(AudioProcessorUsageMax(), 2); Serial.print(F("%|CPUMAXCNT:")); Serial.print(cpumax, DEC); -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) Serial.print(F("|CPUTEMP:")); Serial.print(tempmonGetTemp(), 2); Serial.print(F("C|MEM:")); @@ -3393,7 +3398,7 @@ void SerialPrintFormatInt3(uint8_t num) Serial.print(buf); } -#ifdef TEENSY3_6 +#if defined(ARDUINO_TEENSY36) /* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ extern "C" char* sbrk(int incr); uint32_t FreeMem(void) diff --git a/UI.hpp b/UI.hpp index 2598355..e9edcee 100644 --- a/UI.hpp +++ b/UI.hpp @@ -35,8 +35,6 @@ #include "effect_stereo_mono.h" #if defined(USE_PLATEREVERB) #include "effect_platervbstereo.h" -#elif defined(USE_FREEVERB_SIMD) -#include "effect_freeverb_simd.h" #else #include "effect_freeverbf.h" #endif @@ -117,8 +115,6 @@ extern AudioMixer<3> reverb_mixer_l; #endif #if defined(USE_PLATEREVERB) extern AudioEffectPlateReverb reverb; -#elif defined(USE_FREEVERB_SIMD) -extern AudioEffectFreeverbSIMDStereo freeverb; #else extern AudioEffectFreeverbStereoFloat freeverb; #endif @@ -410,7 +406,7 @@ LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control); #if defined(USE_FX) -#if defined(TEENSY4) +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #include "UI_FX_T4.h" #else #include "UI_FX_T3_6.h" @@ -7757,7 +7753,7 @@ void UI_func_voice_select(uint8_t param) display.createChar(2, (uint8_t*)special_chars[18]); // favorites symbol -#ifdef TEENSY3_6 +#if defined(TEENSY36) display.createChar(6, (uint8_t*)special_chars[16]); // MIDI activity note symbol display.createChar(7, (uint8_t*)special_chars[16]); // MIDI activity note symbol #endif diff --git a/config.h b/config.h index 45be3e6..3b7f02e 100644 --- a/config.h +++ b/config.h @@ -28,7 +28,6 @@ #include #include "midinotes.h" -#include "teensy_board_detection.h" // If you want to test the system with Linux and without any keyboard and/or audio equipment, you can do the following: // 1. In Arduino-IDE enable "Tools->USB-Type->Serial + MIDI + Audio" @@ -101,7 +100,7 @@ //* DEXED SEQUENCER, EPIANO AND EFFECTS SETTINGS //************************************************************************************************* // Number of Dexed instances -#if defined(TEENSY3_6) +#if defined(ARDUINO_TEENSY36) #warning >>> Sorry, only one instance possible for Teensy-3.6 #define NUM_DEXED 1 // 1 or 2 - nothing else! #else @@ -112,7 +111,7 @@ #define USE_FX 1 // NUMBER OF PARALLEL SAMPLEDRUMS -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #define NUM_DRUMS 8 #else #define NUM_DRUMS 4 @@ -124,7 +123,7 @@ // NUMBER OF SAMPLES IN DRUMSET #if defined(ARDUINO_TEENSY41) #define NUM_DRUMSET_CONFIG 71 -#elif defined(TEENSY4) +#elif defined(ARDUINO_TEENSY40) #define NUM_DRUMSET_CONFIG 47 #else #define NUM_DRUMSET_CONFIG 19 @@ -133,7 +132,7 @@ // SEQUENCER #define NUM_SEQ_PATTERN 24 #define NUM_SEQ_TRACKS 6 -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #define USE_SEQUENCER #endif @@ -156,25 +155,28 @@ //#define SGTL5000_AUDIO_THRU 1 #define SGTL5000_HEADPHONE_VOLUME 0.8 #endif -#if defined(TEENSY4) +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #define USE_PLATEREVERB 1 #else -//#define USE_FREEVERB_SIMD #define USE_FREEVERB_FP #endif // DELAYTIME #if NUM_DEXED > 1 -# if defined(TEENSY4) +# if defined(ARDUINO_TEENSY41) # define DELAY_MAX_TIME 500 +# elif defined(ARDUINO_TEENSY41) +# define DELAY_MAX_TIME 250 # else # define DELAY_MAX_TIME 100 # endif #else -# if defined(TEENSY3_6) +# if defined(ARDUINO_TEENSY36) # define DELAY_MAX_TIME 400 -# elif defined(TEENSY4) +# elif defined(ARDUINO_TEENSY41) # define DELAY_MAX_TIME 1000 +# elif defined(ARDUINO_TEENSY41) +# define DELAY_MAX_TIME 500 # else # define DELAY_MAX_TIME 200 # endif @@ -278,7 +280,7 @@ #define SDCARD_AUDIO_CS_PIN 10 #define SDCARD_AUDIO_MOSI_PIN 7 #define SDCARD_AUDIO_SCK_PIN 14 -#if defined(ARDUINO_TEENSY41) || defined(TEENSY3_6) // new detection logic to also find on board SD Card from Teensy 4.1 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY36) // new detection logic to also find on board SD Card from Teensy 4.1 // Teensy 3.6 & 4.1 internal SD card #define SDCARD_TEENSY_CS_PIN BUILTIN_SDCARD #define SDCARD_TEENSY_MOSI_PIN 11 @@ -295,19 +297,19 @@ #define ENC_L_PIN_A 3 #define ENC_L_PIN_B 2 #define BUT_L_PIN 4 -#if defined(TEENSY3_6) +#if defined(ARDUINO_TEENSY36) #define ENC_R_PIN_A 28 #define ENC_R_PIN_B 29 #define BUT_R_PIN 30 #else -#if defined(TEENSY4_0) +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #define ENC_R_PIN_A 6 #define ENC_R_PIN_B 5 #define BUT_R_PIN 8 //#define ENC_R_PIN_A 17 //#define ENC_R_PIN_B 16 //#define BUT_R_PIN 5 -#else // ARDUINO_TEENSY41 +#else // ARDUINO_ARDUINO_TEENSY41 #define ENC_R_PIN_A 24 #define ENC_R_PIN_B 5 #define BUT_R_PIN 9 @@ -362,13 +364,13 @@ // MAX_NOTES SETTINGS // Teensy-4.x settings -#ifdef TEENSY4 +#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) #define MAX_NOTES 32 #define MIDI_DECAY_LEVEL_TIME 500 #endif // Teensy-3.6 settings -#if defined(TEENSY3_6) +#if defined(ARDUINO_TEENSY36) #undef USE_SEQUENCER # if defined(USE_FX) # warning >>> With enabled FX a maximum of 12 voices is possible (due to RAM and CPU limitations) @@ -398,7 +400,7 @@ # endif #endif -#ifdef TEENSY3_5 +#if defined(ARDUINO_TEENSY35) #error >>> Not supported anymore!!! #endif @@ -942,3 +944,21 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } #endif + +/* From: https://forum.pjrc.com/threads/68048-Predefined-Macros + ARDUINO_ARCH_AVR - Avr Architecture / (all Teensy < 3.0) + TEENSYDUINO=Version - Is a Teensy + gives TD version + KINETISL - Teensy LC + KINETISK - All Teensy 3.x + __MK20DX128__ - Teensy 3.0 + __MK20DX256__ - Teensy 3.1, 3.2 + __MK64FX512__ - Teensy 3.5 + __MK66FX1M0__ - Teensy 3.6 + __IMXRT1062__ - all Teensy 4.x + Teensy 4 MM + ARDUINO_TEENSY2 - Teensy 2 + ARDUINO_TEENSY30 - Teensy 3.0 + [...] + ARDUINO_TEENSY40 - Teensy 4.0 + ARDUINO_TEENSY41 - Teensy 4.1 + ARDUINO_TEENSYMM - Teensy 4 MM +*/ diff --git a/effect_freeverb_simd.cpp b/effect_freeverb_simd.cpp deleted file mode 100644 index 4a73b63..0000000 --- a/effect_freeverb_simd.cpp +++ /dev/null @@ -1,848 +0,0 @@ -/* Audio Library for Teensy 3.X - Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com - - Development of this audio library was funded by PJRC.COM, LLC by sales of - Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop - open source software by purchasing Teensy or other PJRC products. - - 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 (c)2021 H. Wirtz , M. Koslowski -, 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, development funding 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. -*/ - -#ifdef USE_FREEVERB_SIMD -// A fixed point implementation of Freeverb by Jezar at Dreampoint -// http://blog.bjornroche.com/2012/06/freeverb-original-public-domain-code-by.html -// https://music.columbia.edu/pipermail/music-dsp/2001-October/045433.html - -#include -#include "effect_freeverb_simd.h" -#include "utility/dspinst.h" - -AudioEffectFreeverbSIMD::AudioEffectFreeverbSIMD() : AudioStream(1, inputQueueArray) -{ - memset(comb1buf, 0, sizeof(comb1buf)); - memset(comb2buf, 0, sizeof(comb2buf)); - memset(comb3buf, 0, sizeof(comb3buf)); - memset(comb4buf, 0, sizeof(comb4buf)); - memset(comb5buf, 0, sizeof(comb5buf)); - memset(comb6buf, 0, sizeof(comb6buf)); - memset(comb7buf, 0, sizeof(comb7buf)); - memset(comb8buf, 0, sizeof(comb8buf)); - comb1index = 0; - comb2index = 0; - comb3index = 0; - comb4index = 0; - comb5index = 0; - comb6index = 0; - comb7index = 0; - comb8index = 0; - comb1filter = 0; - comb2filter = 0; - comb3filter = 0; - comb4filter = 0; - comb5filter = 0; - comb6filter = 0; - comb7filter = 0; - comb8filter = 0; - combdamp1 = 6553; - combdamp2 = 26215; - combfeeback = 27524; - memset(allpass1buf, 0, sizeof(allpass1buf)); - memset(allpass2buf, 0, sizeof(allpass2buf)); - memset(allpass3buf, 0, sizeof(allpass3buf)); - memset(allpass4buf, 0, sizeof(allpass4buf)); - allpass1index = 0; - allpass2index = 0; - allpass3index = 0; - allpass4index = 0; -} - - -// cleaner sat16 by http://www.moseleyinstruments.com/ -__attribute__((unused)) -static int16_t sat16(int32_t n, int rshift) { - // we should always round towards 0 - // to avoid recirculating round-off noise - // - // a 2s complement positive number is always - // rounded down, so we only need to take - // care of negative numbers - if (n < 0) { - n = n + (~(0xFFFFFFFFUL << rshift)); - } - n = n >> rshift; - if (n > 32767) { - return 32767; - } - if (n < -32768) { - return -32768; - } - return n; -} - -// TODO: move this to one of the data files, use in output_adat.cpp, output_tdm.cpp, etc -static const audio_block_t zeroblock = { - 0, 0, 0, { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#if AUDIO_BLOCK_SAMPLES > 16 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif -#if AUDIO_BLOCK_SAMPLES > 32 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif -#if AUDIO_BLOCK_SAMPLES > 48 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif -#if AUDIO_BLOCK_SAMPLES > 64 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif -#if AUDIO_BLOCK_SAMPLES > 80 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif -#if AUDIO_BLOCK_SAMPLES > 96 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif -#if AUDIO_BLOCK_SAMPLES > 112 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#endif - } -}; - -void AudioEffectFreeverbSIMD::update() -{ -#if defined(__ARM_ARCH_7EM__) - const audio_block_t *block; - audio_block_t *outblock; - int i; - int16_t input, bufout, output; - int32_t sum; - - uint32_t PackA, PackB; - - - outblock = allocate(); - if (!outblock) { - audio_block_t *tmp = receiveReadOnly(0); - if (tmp) release(tmp); - return; - } - block = receiveReadOnly(0); - if (!block) block = &zeroblock; - - - for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) { - - // TODO: scale numerical range depending on roomsize & damping - - asm volatile( - "MUL %[RESULT], %[BLOCK], %[CONST]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(input) - :[BLOCK]"r"((int32_t)block->data[i]), [CONST]"r"(8738), [R_RND]"r"(0x1FFFF), [I_SHIFT]"i"(17) - : - ); - - sum = 0; - -/* -asm volatile ( - "QADD %[SUM], %[C1], %[C2]\n" - "QADD %[SUM], %[C3], %[C4]\n" - "QADD %[SUM], %[C5], %[C6]\n" - "QADD %[SUM], %[C7], %[C8]\n" - :[SUM]"=r"(sum) - :[C1]"r"((int32_t)comb1buf[comb1index]),[C2]"r"((int32_t)comb2buf[comb2index]),[C3]"r"((int32_t)comb3buf[comb3index]),[C4]"r"((int32_t)comb4buf[comb4index]),[C5]"r"((int32_t)comb5buf[comb5index]),[C6]"r"((int32_t)comb6buf[comb6index]),[C7]"r"((int32_t)comb7buf[comb7index]),[C8]"r"((int32_t)comb8buf[comb8index]) - : - ); -*/ - asm volatile ( - "QADD %[SUM], %[C1], %[C2]\n" - "QADD %[SUM], %[C3], %[SUM]\n" - "QADD %[SUM], %[C4], %[SUM]\n" - "QADD %[SUM], %[C5], %[SUM]\n" - "QADD %[SUM], %[C6], %[SUM]\n" - "QADD %[SUM], %[C7], %[SUM]\n" - "QADD %[SUM], %[C8], %[SUM]\n" - :[SUM]"=r"(sum) - :[C1]"r"((int32_t)comb1buf[comb1index]), [C2]"r"((int32_t)comb2buf[comb2index]), [C3]"r"((int32_t)comb3buf[comb3index]), [C4]"r"((int32_t)comb4buf[comb4index]), [C5]"r"((int32_t)comb5buf[comb5index]), [C6]"r"((int32_t)comb6buf[comb6index]), [C7]"r"((int32_t)comb7buf[comb7index]), [C8]"r"((int32_t)comb8buf[comb8index]) - : - ); - - //output = asm_sat16((sum * 31457), 0x1FFFF, 17); - - asm volatile ( - "MUL %[RESULT], %[SUM], %[CONST]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(output) - :[SUM]"r"((int32_t)sum), [CONST]"r"(31457), [R_RND]"r"(0x1FFFF), [I_SHIFT]"i"(17) - : - ); - - // Comb1 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb1buf[comb1index]), [INBOT]"r"(comb1filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb1filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb1buf[comb1index]) - :[FIL]"r"(comb1filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - // Comb2 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb2buf[comb2index]), [INBOT]"r"(comb2filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb2filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb2buf[comb2index]) - :[FIL]"r"(comb2filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - - // Comb3 - - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb3buf[comb3index]), [INBOT]"r"(comb3filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb3filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb3buf[comb3index]) - :[FIL]"r"(comb3filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - // Comb4 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb4buf[comb4index]), [INBOT]"r"(comb4filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb4filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb4buf[comb4index]) - :[FIL]"r"(comb4filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - - - // Comb5 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb5buf[comb5index]), [INBOT]"r"(comb5filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb5filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb5buf[comb5index]) - :[FIL]"r"(comb5filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - - // Comb6 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb6buf[comb6index]), [INBOT]"r"(comb6filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb6filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb6buf[comb6index]) - :[FIL]"r"(comb6filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - // Comb7 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb7buf[comb7index]), [INBOT]"r"(comb7filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb7filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - asm volatile ( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb7buf[comb7index]) - :[FIL]"r"(comb7filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - - // Comb8 - asm volatile ( - "PKHBT %[PACKA], %[INBOT], %[INTOP], LSL #16\n" - :[PACKA]"=&r"(PackA) - :[INTOP]"r"(comb8buf[comb8index]), [INBOT]"r"(comb8filter) - : - ); - asm volatile ( - "PKHBT %[PACKB], %[INBOT], %[INTOP], LSL #16\n" - :[PACKB]"=&r"(PackB) - :[INTOP]"r"(combdamp2), [INBOT]"r"(combdamp1) - : - ); - asm volatile( - "BIC %[RESULT], %[RESULT], #0\n" - "SMLAD %[RESULT], %[PACKA], %[PACKB], %[RESULT]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(comb8filter) - :[PACKA]"r"(PackA), [PACKB]"r"(PackB), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - :"memory" - ); - - - asm volatile( - "MUL %[RESULT], %[FIL], %[FB]\n" - "CMN %[RESULT], #0\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - "ADD %[RESULT], %[RESULT], %[IN]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(comb8buf[comb8index]) - :[FIL]"r"(comb8filter), [IN]"r"((int32_t)input), [FB]"r"((int32_t)combfeeback), [R_RND]"r"(0x7FFF), [I_SHIFT]"i"(15) - : - ); - - - bufout = allpass1buf[allpass1index]; - allpass1buf[allpass1index] = output + (bufout >> 1); - asm volatile( - "SUBS %[RESULT], %[BUF], %[OUT]\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(output) - :[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1) - : - ); - - - bufout = allpass2buf[allpass2index]; - allpass2buf[allpass2index] = output + (bufout >> 1); - asm volatile( - "SUBS %[RESULT], %[BUF], %[OUT]\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(output) - :[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1) - : - ); - - - bufout = allpass3buf[allpass3index]; - allpass3buf[allpass3index] = output + (bufout >> 1); - asm volatile( - "SUBS %[RESULT], %[BUF], %[OUT]\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(output) - :[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1) - : - ); - - - bufout = allpass4buf[allpass4index]; - allpass4buf[allpass4index] = output + (bufout >> 1); - asm volatile( - "SUBS %[RESULT], %[BUF], %[OUT]\n" - "IT MI\n" - "ADDMI %[RESULT], %[RESULT], %[R_RND]\n" - "SSAT %[RESULT], #16, %[RESULT], ASR %[I_SHIFT]\n" - :[RESULT]"=&r"(output) - :[BUF]"r"((int32_t)bufout), [OUT]"r"((int32_t)output), [R_RND]"r"(0x1), [I_SHIFT]"i"(1) - : - ); - - - asm volatile( - "MUL %[RESULT], %[OUT], %[CONST]\n" - "SSAT %[RESULT], #16, %[RESULT]\n" - :[RESULT]"=&r"(outblock->data[i]) - :[OUT]"r"((int32_t)output), [CONST]"r"(30) - : - ); - - - if (++allpass1index >= sizeof(allpass1buf) / sizeof(int16_t)) allpass1index = 0; - if (++allpass2index >= sizeof(allpass2buf) / sizeof(int16_t)) allpass2index = 0; - if (++allpass3index >= sizeof(allpass3buf) / sizeof(int16_t)) allpass3index = 0; - if (++allpass4index >= sizeof(allpass4buf) / sizeof(int16_t)) allpass4index = 0; - - if (++comb1index >= sizeof(comb1buf) / sizeof(int16_t)) comb1index = 0; - if (++comb2index >= sizeof(comb2buf) / sizeof(int16_t)) comb2index = 0; - if (++comb3index >= sizeof(comb3buf) / sizeof(int16_t)) comb3index = 0; - if (++comb4index >= sizeof(comb4buf) / sizeof(int16_t)) comb4index = 0; - if (++comb5index >= sizeof(comb5buf) / sizeof(int16_t)) comb5index = 0; - if (++comb6index >= sizeof(comb6buf) / sizeof(int16_t)) comb6index = 0; - if (++comb7index >= sizeof(comb7buf) / sizeof(int16_t)) comb7index = 0; - if (++comb8index >= sizeof(comb8buf) / sizeof(int16_t)) comb8index = 0; - } - transmit(outblock); - release(outblock); - if (block != &zeroblock) release((audio_block_t *)block); - -#elif defined(KINETISL) - audio_block_t *block; - block = receiveReadOnly(0); - if (block) release(block); -#endif -} - -AudioEffectFreeverbSIMDStereo::AudioEffectFreeverbSIMDStereo() : AudioStream(1, inputQueueArray) -{ - memset(comb1bufL, 0, sizeof(comb1bufL)); - memset(comb2bufL, 0, sizeof(comb2bufL)); - memset(comb3bufL, 0, sizeof(comb3bufL)); - memset(comb4bufL, 0, sizeof(comb4bufL)); - memset(comb5bufL, 0, sizeof(comb5bufL)); - memset(comb6bufL, 0, sizeof(comb6bufL)); - memset(comb7bufL, 0, sizeof(comb7bufL)); - memset(comb8bufL, 0, sizeof(comb8bufL)); - comb1indexL = 0; - comb2indexL = 0; - comb3indexL = 0; - comb4indexL = 0; - comb5indexL = 0; - comb6indexL = 0; - comb7indexL = 0; - comb8indexL = 0; - comb1filterL = 0; - comb2filterL = 0; - comb3filterL = 0; - comb4filterL = 0; - comb5filterL = 0; - comb6filterL = 0; - comb7filterL = 0; - comb8filterL = 0; - memset(comb1bufR, 0, sizeof(comb1bufR)); - memset(comb2bufR, 0, sizeof(comb2bufR)); - memset(comb3bufR, 0, sizeof(comb3bufR)); - memset(comb4bufR, 0, sizeof(comb4bufR)); - memset(comb5bufR, 0, sizeof(comb5bufR)); - memset(comb6bufR, 0, sizeof(comb6bufR)); - memset(comb7bufR, 0, sizeof(comb7bufR)); - memset(comb8bufR, 0, sizeof(comb8bufR)); - comb1indexR = 0; - comb2indexR = 0; - comb3indexR = 0; - comb4indexR = 0; - comb5indexR = 0; - comb6indexR = 0; - comb7indexR = 0; - comb8indexR = 0; - comb1filterR = 0; - comb2filterR = 0; - comb3filterR = 0; - comb4filterR = 0; - comb5filterR = 0; - comb6filterR = 0; - comb7filterR = 0; - comb8filterR = 0; - combdamp1 = 6553; - combdamp2 = 26215; - combfeeback = 27524; - memset(allpass1bufL, 0, sizeof(allpass1bufL)); - memset(allpass2bufL, 0, sizeof(allpass2bufL)); - memset(allpass3bufL, 0, sizeof(allpass3bufL)); - memset(allpass4bufL, 0, sizeof(allpass4bufL)); - allpass1indexL = 0; - allpass2indexL = 0; - allpass3indexL = 0; - allpass4indexL = 0; - memset(allpass1bufR, 0, sizeof(allpass1bufR)); - memset(allpass2bufR, 0, sizeof(allpass2bufR)); - memset(allpass3bufR, 0, sizeof(allpass3bufR)); - memset(allpass4bufR, 0, sizeof(allpass4bufR)); - allpass1indexR = 0; - allpass2indexR = 0; - allpass3indexR = 0; - allpass4indexR = 0; -} - -void AudioEffectFreeverbSIMDStereo::update() -{ -#if defined(__ARM_ARCH_7EM__) - const audio_block_t *block; - audio_block_t *outblockL; - audio_block_t *outblockR; - int i; - int16_t input, bufout, outputL, outputR; - int32_t sum; - - block = receiveReadOnly(0); - outblockL = allocate(); - outblockR = allocate(); - if (!outblockL || !outblockR) { - if (outblockL) release(outblockL); - if (outblockR) release(outblockR); - if (block) release((audio_block_t *)block); - return; - } - if (!block) block = &zeroblock; - - for (i = 0; i < AUDIO_BLOCK_SAMPLES; i++) { - // TODO: scale numerical range depending on roomsize & damping - input = sat16(block->data[i] * 8738, 17); // for numerical headroom - sum = 0; - - bufout = comb1bufL[comb1indexL]; - sum += bufout; - comb1filterL = sat16(bufout * combdamp2 + comb1filterL * combdamp1, 15); - comb1bufL[comb1indexL] = sat16(input + sat16(comb1filterL * combfeeback, 15), 0); - if (++comb1indexL >= sizeof(comb1bufL) / sizeof(int16_t)) comb1indexL = 0; - - bufout = comb2bufL[comb2indexL]; - sum += bufout; - comb2filterL = sat16(bufout * combdamp2 + comb2filterL * combdamp1, 15); - comb2bufL[comb2indexL] = sat16(input + sat16(comb2filterL * combfeeback, 15), 0); - if (++comb2indexL >= sizeof(comb2bufL) / sizeof(int16_t)) comb2indexL = 0; - - bufout = comb3bufL[comb3indexL]; - sum += bufout; - comb3filterL = sat16(bufout * combdamp2 + comb3filterL * combdamp1, 15); - comb3bufL[comb3indexL] = sat16(input + sat16(comb3filterL * combfeeback, 15), 0); - if (++comb3indexL >= sizeof(comb3bufL) / sizeof(int16_t)) comb3indexL = 0; - - bufout = comb4bufL[comb4indexL]; - sum += bufout; - comb4filterL = sat16(bufout * combdamp2 + comb4filterL * combdamp1, 15); - comb4bufL[comb4indexL] = sat16(input + sat16(comb4filterL * combfeeback, 15), 0); - if (++comb4indexL >= sizeof(comb4bufL) / sizeof(int16_t)) comb4indexL = 0; - - bufout = comb5bufL[comb5indexL]; - sum += bufout; - comb5filterL = sat16(bufout * combdamp2 + comb5filterL * combdamp1, 15); - comb5bufL[comb5indexL] = sat16(input + sat16(comb5filterL * combfeeback, 15), 0); - if (++comb5indexL >= sizeof(comb5bufL) / sizeof(int16_t)) comb5indexL = 0; - - bufout = comb6bufL[comb6indexL]; - sum += bufout; - comb6filterL = sat16(bufout * combdamp2 + comb6filterL * combdamp1, 15); - comb6bufL[comb6indexL] = sat16(input + sat16(comb6filterL * combfeeback, 15), 0); - if (++comb6indexL >= sizeof(comb6bufL) / sizeof(int16_t)) comb6indexL = 0; - - bufout = comb7bufL[comb7indexL]; - sum += bufout; - comb7filterL = sat16(bufout * combdamp2 + comb7filterL * combdamp1, 15); - comb7bufL[comb7indexL] = sat16(input + sat16(comb7filterL * combfeeback, 15), 0); - if (++comb7indexL >= sizeof(comb7bufL) / sizeof(int16_t)) comb7indexL = 0; - - bufout = comb8bufL[comb8indexL]; - sum += bufout; - comb8filterL = sat16(bufout * combdamp2 + comb8filterL * combdamp1, 15); - comb8bufL[comb8indexL] = sat16(input + sat16(comb8filterL * combfeeback, 15), 0); - if (++comb8indexL >= sizeof(comb8bufL) / sizeof(int16_t)) comb8indexL = 0; - - outputL = sat16(sum * 31457, 17); - sum = 0; - - bufout = comb1bufR[comb1indexR]; - sum += bufout; - comb1filterR = sat16(bufout * combdamp2 + comb1filterR * combdamp1, 15); - comb1bufR[comb1indexR] = sat16(input + sat16(comb1filterR * combfeeback, 15), 0); - if (++comb1indexR >= sizeof(comb1bufR) / sizeof(int16_t)) comb1indexR = 0; - - bufout = comb2bufR[comb2indexR]; - sum += bufout; - comb2filterR = sat16(bufout * combdamp2 + comb2filterR * combdamp1, 15); - comb2bufR[comb2indexR] = sat16(input + sat16(comb2filterR * combfeeback, 15), 0); - if (++comb2indexR >= sizeof(comb2bufR) / sizeof(int16_t)) comb2indexR = 0; - - bufout = comb3bufR[comb3indexR]; - sum += bufout; - comb3filterR = sat16(bufout * combdamp2 + comb3filterR * combdamp1, 15); - comb3bufR[comb3indexR] = sat16(input + sat16(comb3filterR * combfeeback, 15), 0); - if (++comb3indexR >= sizeof(comb3bufR) / sizeof(int16_t)) comb3indexR = 0; - - bufout = comb4bufR[comb4indexR]; - sum += bufout; - comb4filterR = sat16(bufout * combdamp2 + comb4filterR * combdamp1, 15); - comb4bufR[comb4indexR] = sat16(input + sat16(comb4filterR * combfeeback, 15), 0); - if (++comb4indexR >= sizeof(comb4bufR) / sizeof(int16_t)) comb4indexR = 0; - - bufout = comb5bufR[comb5indexR]; - sum += bufout; - comb5filterR = sat16(bufout * combdamp2 + comb5filterR * combdamp1, 15); - comb5bufR[comb5indexR] = sat16(input + sat16(comb5filterR * combfeeback, 15), 0); - if (++comb5indexR >= sizeof(comb5bufR) / sizeof(int16_t)) comb5indexR = 0; - - bufout = comb6bufR[comb6indexR]; - sum += bufout; - comb6filterR = sat16(bufout * combdamp2 + comb6filterR * combdamp1, 15); - comb6bufR[comb6indexR] = sat16(input + sat16(comb6filterR * combfeeback, 15), 0); - if (++comb6indexR >= sizeof(comb6bufR) / sizeof(int16_t)) comb6indexR = 0; - - bufout = comb7bufR[comb7indexR]; - sum += bufout; - comb7filterR = sat16(bufout * combdamp2 + comb7filterR * combdamp1, 15); - comb7bufR[comb7indexR] = sat16(input + sat16(comb7filterR * combfeeback, 15), 0); - if (++comb7indexR >= sizeof(comb7bufR) / sizeof(int16_t)) comb7indexR = 0; - - bufout = comb8bufR[comb8indexR]; - sum += bufout; - comb8filterR = sat16(bufout * combdamp2 + comb8filterR * combdamp1, 15); - comb8bufR[comb8indexR] = sat16(input + sat16(comb8filterR * combfeeback, 15), 0); - if (++comb8indexR >= sizeof(comb8bufR) / sizeof(int16_t)) comb8indexR = 0; - - outputR = sat16(sum * 31457, 17); - - bufout = allpass1bufL[allpass1indexL]; - allpass1bufL[allpass1indexL] = outputL + (bufout >> 1); - outputL = sat16(bufout - outputL, 1); - if (++allpass1indexL >= sizeof(allpass1bufL) / sizeof(int16_t)) allpass1indexL = 0; - - bufout = allpass2bufL[allpass2indexL]; - allpass2bufL[allpass2indexL] = outputL + (bufout >> 1); - outputL = sat16(bufout - outputL, 1); - if (++allpass2indexL >= sizeof(allpass2bufL) / sizeof(int16_t)) allpass2indexL = 0; - - bufout = allpass3bufL[allpass3indexL]; - allpass3bufL[allpass3indexL] = outputL + (bufout >> 1); - outputL = sat16(bufout - outputL, 1); - if (++allpass3indexL >= sizeof(allpass3bufL) / sizeof(int16_t)) allpass3indexL = 0; - - bufout = allpass4bufL[allpass4indexL]; - allpass4bufL[allpass4indexL] = outputL + (bufout >> 1); - outputL = sat16(bufout - outputL, 1); - if (++allpass4indexL >= sizeof(allpass4bufL) / sizeof(int16_t)) allpass4indexL = 0; - - outblockL->data[i] = sat16(outputL * 30, 0); - - bufout = allpass1bufR[allpass1indexR]; - allpass1bufR[allpass1indexR] = outputR + (bufout >> 1); - outputR = sat16(bufout - outputR, 1); - if (++allpass1indexR >= sizeof(allpass1bufR) / sizeof(int16_t)) allpass1indexR = 0; - - bufout = allpass2bufR[allpass2indexR]; - allpass2bufR[allpass2indexR] = outputR + (bufout >> 1); - outputR = sat16(bufout - outputR, 1); - if (++allpass2indexR >= sizeof(allpass2bufR) / sizeof(int16_t)) allpass2indexR = 0; - - bufout = allpass3bufR[allpass3indexR]; - allpass3bufR[allpass3indexR] = outputR + (bufout >> 1); - outputR = sat16(bufout - outputR, 1); - if (++allpass3indexR >= sizeof(allpass3bufR) / sizeof(int16_t)) allpass3indexR = 0; - - bufout = allpass4bufR[allpass4indexR]; - allpass4bufR[allpass4indexR] = outputR + (bufout >> 1); - outputR = sat16(bufout - outputR, 1); - if (++allpass4indexR >= sizeof(allpass4bufR) / sizeof(int16_t)) allpass4indexR = 0; - - outblockR->data[i] = sat16(outputL * 30, 0); - } - transmit(outblockL, 0); - transmit(outblockR, 1); - release(outblockL); - release(outblockR); - if (block != &zeroblock) release((audio_block_t *)block); - -#elif defined(KINETISL) - audio_block_t *block; - block = receiveReadOnly(0); - if (block) release(block); -#endif -} -#endif diff --git a/effect_freeverb_simd.h b/effect_freeverb_simd.h deleted file mode 100644 index f89317d..0000000 --- a/effect_freeverb_simd.h +++ /dev/null @@ -1,185 +0,0 @@ -/* Audio Library for Teensy 3.X - Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com - - Development of this audio library was funded by PJRC.COM, LLC by sales of - Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop - open source software by purchasing Teensy or other PJRC products. - - 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, development funding 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. -*/ - -#ifdef USE_FREEVERB_SIMD -#ifndef effect_freeverb_simd_h_ -#define effect_freeverb_simd_h_ -#include -#include "AudioStream.h" - -class AudioEffectFreeverbSIMD : public AudioStream -{ - public: - AudioEffectFreeverbSIMD(); - virtual void update(); - void roomsize(float n) { - if (n > 1.0f) n = 1.0f; - else if (n < 0.0f) n = 0.0f; - combfeeback = (int)(n * 9175.04f) + 22937; - } - void damping(float n) { - if (n > 1.0f) n = 1.0f; - else if (n < 0.0f) n = 0.0f; - int x1 = (int)(n * 13107.2f); - int x2 = 32768 - x1; - __disable_irq(); - combdamp1 = x1; - combdamp2 = x2; - __enable_irq(); - } - private: - audio_block_t *inputQueueArray[1]; - int16_t comb1buf[1116]; - int16_t comb2buf[1188]; - int16_t comb3buf[1277]; - int16_t comb4buf[1356]; - int16_t comb5buf[1422]; - int16_t comb6buf[1491]; - int16_t comb7buf[1557]; - int16_t comb8buf[1617]; - uint16_t comb1index; - uint16_t comb2index; - uint16_t comb3index; - uint16_t comb4index; - uint16_t comb5index; - uint16_t comb6index; - uint16_t comb7index; - uint16_t comb8index; - int16_t comb1filter; - int16_t comb2filter; - int16_t comb3filter; - int16_t comb4filter; - int16_t comb5filter; - int16_t comb6filter; - int16_t comb7filter; - int16_t comb8filter; - int16_t combdamp1; - int16_t combdamp2; - int16_t combfeeback; - int16_t allpass1buf[556]; - int16_t allpass2buf[441]; - int16_t allpass3buf[341]; - int16_t allpass4buf[225]; - uint16_t allpass1index; - uint16_t allpass2index; - uint16_t allpass3index; - uint16_t allpass4index; -}; - - -class AudioEffectFreeverbSIMDStereo : public AudioStream -{ - public: - AudioEffectFreeverbSIMDStereo(); - virtual void update(); - void roomsize(float n) { - if (n > 1.0f) n = 1.0f; - else if (n < 0.0f) n = 0.0f; - combfeeback = (int)(n * 9175.04f) + 22937; - } - void damping(float n) { - if (n > 1.0f) n = 1.0f; - else if (n < 0.0f) n = 0.0f; - int x1 = (int)(n * 13107.2f); - int x2 = 32768 - x1; - __disable_irq(); - combdamp1 = x1; - combdamp2 = x2; - __enable_irq(); - } - private: - audio_block_t *inputQueueArray[1]; - int16_t comb1bufL[1116]; - int16_t comb2bufL[1188]; - int16_t comb3bufL[1277]; - int16_t comb4bufL[1356]; - int16_t comb5bufL[1422]; - int16_t comb6bufL[1491]; - int16_t comb7bufL[1557]; - int16_t comb8bufL[1617]; - uint16_t comb1indexL; - uint16_t comb2indexL; - uint16_t comb3indexL; - uint16_t comb4indexL; - uint16_t comb5indexL; - uint16_t comb6indexL; - uint16_t comb7indexL; - uint16_t comb8indexL; - int16_t comb1filterL; - int16_t comb2filterL; - int16_t comb3filterL; - int16_t comb4filterL; - int16_t comb5filterL; - int16_t comb6filterL; - int16_t comb7filterL; - int16_t comb8filterL; - int16_t comb1bufR[1139]; - int16_t comb2bufR[1211]; - int16_t comb3bufR[1300]; - int16_t comb4bufR[1379]; - int16_t comb5bufR[1445]; - int16_t comb6bufR[1514]; - int16_t comb7bufR[1580]; - int16_t comb8bufR[1640]; - uint16_t comb1indexR; - uint16_t comb2indexR; - uint16_t comb3indexR; - uint16_t comb4indexR; - uint16_t comb5indexR; - uint16_t comb6indexR; - uint16_t comb7indexR; - uint16_t comb8indexR; - int16_t comb1filterR; - int16_t comb2filterR; - int16_t comb3filterR; - int16_t comb4filterR; - int16_t comb5filterR; - int16_t comb6filterR; - int16_t comb7filterR; - int16_t comb8filterR; - int16_t combdamp1; - int16_t combdamp2; - int16_t combfeeback; - int16_t allpass1bufL[556]; - int16_t allpass2bufL[441]; - int16_t allpass3bufL[341]; - int16_t allpass4bufL[225]; - uint16_t allpass1indexL; - uint16_t allpass2indexL; - uint16_t allpass3indexL; - uint16_t allpass4indexL; - int16_t allpass1bufR[579]; - int16_t allpass2bufR[464]; - int16_t allpass3bufR[364]; - int16_t allpass4bufR[248]; - uint16_t allpass1indexR; - uint16_t allpass2indexR; - uint16_t allpass3indexR; - uint16_t allpass4indexR; -}; - -#endif -#endif diff --git a/teensy_board_detection.h b/teensy_board_detection.h deleted file mode 100644 index d4c2f93..0000000 --- a/teensy_board_detection.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - MicroDexed - - MicroDexed is a port of the Dexed sound engine - (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6/4.x with audio shield. - Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android - - (c)2018-2022 H. Wirtz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#ifndef TEENSY_BOARD_DETECTION_H_INCLUDED -#define TEENSY_BOARD_DETECTION_H_INCLUDED - - -// Teensy-4.x -#if defined(__IMXRT1062__) || defined (ARDUINO_TEENSY40) || defined (ARDUINO_TEENSY41) -#define TEENSY4 -#if defined (ARDUINO_TEENSY40) -#define TEENSY4_0 -#elif defined (ARDUINO_TEENSY41) -#define TEENSY4_1 -#endif -#endif - -// Teensy-3.6 -#if defined(__MK66FX1M0__) -# define TEENSY3_6 -#endif - -// Teensy-3.5 -#if defined (__MK64FX512__) -#define TEENSY3_5 -#endif - -#endif diff --git a/third-party/ArduinoJson/ArduinoJson.h b/third-party/ArduinoJson/ArduinoJson.h index ba79dc8..7e3afa5 100644 --- a/third-party/ArduinoJson/ArduinoJson.h +++ b/third-party/ArduinoJson/ArduinoJson.h @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include "src/ArduinoJson.h" diff --git a/third-party/ArduinoJson/CHANGELOG.md b/third-party/ArduinoJson/CHANGELOG.md index 1d910d2..f49c949 100644 --- a/third-party/ArduinoJson/CHANGELOG.md +++ b/third-party/ArduinoJson/CHANGELOG.md @@ -1,6 +1,40 @@ ArduinoJson: change log ======================= +v6.19.2 (2022-02-14) +------- + +* Fix `cannot convert 'pgm_p' to 'const void*'` (issue #1707) + +v6.19.1 (2022-01-14) +------- + +* Fix crash when adding an object member in a too small `JsonDocument` +* Fix filter not working in zero-copy mode (issue #1697) + +v6.19.0 (2022-01-08) +------- + +* Remove `ARDUINOJSON_EMBEDDED_MODE` and assume we run on an embedded platform. + Dependent settings (like `ARDUINOJSON_DEFAULT_NESTING_LIMIT`) must be set individually. +* Change the default of `ARDUINOJSON_USE_DOUBLE` to `1` +* Change the default of `ARDUINOJSON_USE_LONG_LONG` to `1` on 32-bit platforms +* Add `as()` and `is()` +* Add safe bool idiom in `JsonString` +* Add support for NUL in string values (issue #1646) +* Add support for arbitrary array rank in `copyArray()` +* Add support for `char[][]` in `copyArray()` +* Remove `DeserializationError == bool` and `DeserializationError != bool` +* Renamed undocumented function `isUndefined()` to `isUnbound()` +* Fix `JsonVariant::memoryUsage()` for raw strings +* Fix `call of overloaded 'swap(BasicJsonDocument&, BasicJsonDocument&)' is ambiguous` (issue #1678) +* Fix inconsistent pool capacity between `BasicJsonDocument`'s copy and move constructors +* Fix inconsistent pool capacity between `BasicJsonDocument`'s copy and move assignments +* Fix return type of `StaticJsonDocument::operator=` +* Avoid pool reallocation in `BasicJsonDocument`'s copy assignment if capacity is the same +* Avoid including `Arduino.h` when all its features are disabled (issue #1692, PR #1693 by @paulocsanz) +* Assume `PROGMEM` is available as soon as `ARDUINO` is defined (consequence of #1693) + v6.18.5 (2021-09-28) ------- @@ -731,423 +765,3 @@ v6.0.0-beta (2018-06-07) > obj["key"] = "value"; > serializeJson(doc, Serial); > ``` - -v5.13.2 -------- - -* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693) -* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu) -* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky) -* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`... - -v5.13.1 -------- - -* Fixed `JsonVariant::operator|(int)` that returned the default value if the variant contained a double (issue #675) -* Allowed non-quoted key to contain underscores (issue #665) - -v5.13.0 -------- - -* Changed the rules of string duplication (issue #658) -* `RawJson()` accepts any kind of string and obeys to the same rules for duplication -* Changed the return type of `strdup()` to `const char*` to prevent double duplication -* Marked `strdup()` as deprecated - -> ### New rules for string duplication -> -> | type | duplication | -> |:---------------------------|:------------| -> | const char* | no | -> | char* | ~~no~~ yes | -> | String | yes | -> | std::string | yes | -> | const __FlashStringHelper* | yes | -> -> These new rules make `JsonBuffer::strdup()` useless. - -v5.12.0 -------- - -* Added `JsonVariant::operator|` to return a default value (see below) -* Added a clear error message when compiled as C instead of C++ (issue #629) -* Added detection of MPLAB XC compiler (issue #629) -* Added detection of Keil ARM Compiler (issue #629) -* Added an example that shows how to save and load a configuration file -* Reworked all other examples - -> ### How to use the new feature? -> -> If you have a block like this: -> -> ```c++ -> const char* ssid = root["ssid"]; -> if (!ssid) -> ssid = "default ssid"; -> ``` -> -> You can simplify like that: -> -> ```c++ -> const char* ssid = root["ssid"] | "default ssid"; -> ``` - -v5.11.2 -------- - -* Fixed `DynamicJsonBuffer::clear()` not resetting allocation size (issue #561) -* Fixed incorrect rounding for float values (issue #588) - -v5.11.1 -------- - -* Removed dependency on `PGM_P` as Particle 0.6.2 doesn't define it (issue #546) -* Fixed warning "dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]" -* Fixed warning "floating constant exceeds range of 'float' [-Woverflow]" (issue #544) -* Fixed warning "this statement may fall through" [-Wimplicit-fallthrough=] (issue #539) -* Removed `ARDUINOJSON_DOUBLE_IS_64BITS` as it became useless. -* Fixed too many decimals places in float serialization (issue #543) - -v5.11.0 -------- - -* Made `JsonBuffer` non-copyable (PR #524 by @luisrayas3) -* Added `StaticJsonBuffer::clear()` -* Added `DynamicJsonBuffer::clear()` - -v5.10.1 -------- - -* Fixed IntelliSense errors in Visual Micro (issue #483) -* Fixed compilation in IAR Embedded Workbench (issue #515) -* Fixed reading "true" as a float (issue #516) -* Added `ARDUINOJSON_DOUBLE_IS_64BITS` -* Added `ARDUINOJSON_EMBEDDED_MODE` - -v5.10.0 -------- - -* Removed configurable number of decimal places (issues #288, #427 and #506) -* Changed exponentiation thresholds to `1e7` and `1e-5` (issues #288, #427 and #506) -* `JsonVariant::is()` now returns `true` for integers -* Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495) -* Fixed error `forming reference to reference` (issue #495) - -> ### BREAKING CHANGES :warning: -> -> | Old syntax | New syntax | -> |:--------------------------------|:--------------------| -> | `double_with_n_digits(3.14, 2)` | `3.14` | -> | `float_with_n_digits(3.14, 2)` | `3.14f` | -> | `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` | -> | `arr.add(3.14, 2)` | `arr.add(3.14)` | -> -> | Input | Old output | New output | -> |:----------|:-----------|:-----------| -> | `3.14159` | `3.14` | `3.14159` | -> | `42.0` | `42.00` | `42` | -> | `0.0` | `0.00` | `0` | -> -> | Expression | Old result | New result | -> |:-------------------------------|:-----------|:-----------| -> | `JsonVariant(42).is()` | `true` | `true` | -> | `JsonVariant(42).is()` | `false` | `true` | -> | `JsonVariant(42).is()` | `false` | `true` | - -v5.9.0 ------- - -* Added `JsonArray::remove(iterator)` (issue #479) -* Added `JsonObject::remove(iterator)` -* Renamed `JsonArray::removeAt(size_t)` into `remove(size_t)` -* Renamed folder `include/` to `src/` -* Fixed warnings `floating constant exceeds range of float`and `floating constant truncated to zero` (issue #483) -* Removed `Print` class and converted `printTo()` to a template method (issue #276) -* Removed example `IndentedPrintExample.ino` -* Now compatible with Particle 0.6.1, thanks to Jacob Nite (issue #294 and PR #461 by @foodbag) - -v5.8.4 ------- - -* Added custom implementation of `strtod()` (issue #453) -* Added custom implementation of `strtol()` (issue #465) -* `char` is now treated as an integral type (issue #337, #370) - -v5.8.3 ------- - -* Fixed an access violation in `DynamicJsonBuffer` when memory allocation fails (issue #433) -* Added operators `==` and `!=` for two `JsonVariant`s (issue #436) -* Fixed `JsonVariant::operator[const FlashStringHelper*]` (issue #441) - -v5.8.2 ------- - -* Fixed parsing of comments (issue #421) -* Fixed ignored `Stream` timeout (issue #422) -* Made sure we don't read more that necessary (issue #422) -* Fixed error when the key of a `JsonObject` is a `char[]` (issue #423) -* Reduced code size when using `const` references -* Fixed error with string of type `unsigned char*` (issue #428) -* Added `deprecated` attribute on `asArray()`, `asObject()` and `asString()` (issue #420) - -v5.8.1 ------- - -* Fixed error when assigning a `volatile int` to a `JsonVariant` (issue #415) -* Fixed errors with Variable Length Arrays (issue #416) -* Fixed error when both `ARDUINOJSON_ENABLE_STD_STREAM` and `ARDUINOJSON_ENABLE_ARDUINO_STREAM` are set to `1` -* Fixed error "Stream does not name a type" (issue #412) - -v5.8.0 ------- - -* Added operator `==` to compare `JsonVariant` and strings (issue #402) -* Added support for `Stream` (issue #300) -* Reduced memory consumption by not duplicating spaces and comments - -> ### BREAKING CHANGES :warning: -> -> `JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`. -> -> This means that if you have code like: -> -> ```c++ -> void myFunction(JsonBuffer& jsonBuffer); -> ``` -> -> you need to replace it with one of the following: -> -> ```c++ -> void myFunction(DynamicJsonBuffer& jsonBuffer); -> void myFunction(StaticJsonBufferBase& jsonBuffer); -> template void myFunction(TJsonBuffer& jsonBuffer); -> ``` - -v5.7.3 ------- - -* Added an `printTo(char[N])` and `prettyPrintTo(char[N])` (issue #292) -* Added ability to set a nested value like this: `root["A"]["B"] = "C"` (issue #352) -* Renamed `*.ipp` to `*Impl.hpp` because they were ignored by Arduino IDE (issue #396) - -v5.7.2 ------- - -* Made PROGMEM available on more platforms (issue #381) -* Fixed PROGMEM causing an exception on ESP8266 (issue #383) - -v5.7.1 ------- - -* Added support for PROGMEM (issue #76) -* Fixed compilation error when index is not an `int` (issue #381) - -v5.7.0 ------- - -* Templatized all functions using `String` or `std::string` -* Removed `ArduinoJson::String` -* Removed `JsonVariant::defaultValue()` -* Removed non-template `JsonObject::get()` and `JsonArray.get()` -* Fixed support for `StringSumHelper` (issue #184) -* Replaced `ARDUINOJSON_USE_ARDUINO_STRING` by `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_ARDUINO_STRING` (issue #378) -* Added example `StringExample.ino` to show where `String` can be used -* Increased default nesting limit to 50 when compiled for a computer (issue #349) - -> ### BREAKING CHANGES :warning: -> -> The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return. -> -> Old code: -> -> ```c++ -> #define ARDUINOJSON_USE_ARDUINO_STRING 0 -> JsonVariant value1 = myObject.get("myKey"); -> JsonVariant value2 = myArray.get(0); -> ``` -> -> New code: -> -> ```c++ -> #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 -> #define ARDUINOJSON_ENABLE_STD_STRING 1 -> JsonVariant value1 = myObject.get("myKey"); -> JsonVariant value2 = myArray.get(0); -> ``` - -v5.6.7 ------- - -* Fixed `array[idx].as()` and `object[key].as()` -* Fixed return value of `JsonObject::set()` (issue #350) -* Fixed undefined behavior in `Prettyfier` and `Print` (issue #354) -* Fixed parser that incorrectly rejected floats containing a `+` (issue #349) - -v5.6.6 ------- - -* Fixed `-Wparentheses` warning introduced in v5.6.5 (PR #335 by @nuket) -* Added `.mbedignore` for ARM mbdeb (PR #334 by @nuket) -* Fixed `JsonVariant::success()` which didn't propagate `JsonArray::success()` nor `JsonObject::success()` (issue #342). - -v5.6.5 ------- - -* `as()` now returns `true` when input is `null` (issue #330) - -v5.6.4 ------- - -* Fixed error in float serialization (issue #324) - -v5.6.3 ------- - -* Improved speed of float serialization (about twice faster) -* Added `as()` as a synonym for `as()`... (issue #291) -* Fixed `call of overloaded isinf(double&) is ambiguous` (issue #284) - -v5.6.2 ------- - -* Fixed build when another lib does `#undef isnan` (issue #284) - -v5.6.1 ------- - -* Added missing `#pragma once` (issue #310) - -v5.6.0 ------- - -* ArduinoJson is now a header-only library (issue #199) - -v5.5.1 ------- - -* Fixed compilation error with Intel Galileo (issue #299) - -v5.5.0 ------- - -* Added `JsonVariant::success()` (issue #279) -* Renamed `JsonVariant::invalid()` to `JsonVariant::defaultValue()` - -v5.4.0 ------- - -* Changed `::String` to `ArduinoJson::String` (issue #275) -* Changed `::Print` to `ArduinoJson::Print` too - -v5.3.0 ------- - -* Added custom implementation of `ftoa` (issues #266, #267, #269 and #270) -* Added `JsonVariant JsonBuffer::parse()` (issue #265) -* Fixed `unsigned long` printed as `signed long` (issue #170) - -v5.2.0 ------- - -* Added `JsonVariant::as()` as a synonym for `JsonVariant::as()` (issue #257) -* Added example `JsonHttpClient` (issue #256) -* Added `JsonArray::copyTo()` and `JsonArray::copyFrom()` (issue #254) -* Added `RawJson()` to insert pregenerated JSON portions (issue #259) - -v5.1.1 ------- - -* Removed `String` duplication when one replaces a value in a `JsonObject` (PR #232 by @ulion) - -v5.1.0 ------- - -* Added support of `long long` (issue #171) -* Moved all build settings to `ArduinoJson/Configuration.hpp` - -> ### BREAKING CHANGE :warning: -> -> If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`. - -v5.0.8 ------- - -* Made the library compatible with [PlatformIO](http://platformio.org/) (issue #181) -* Fixed `JsonVariant::is()` that was incorrectly returning false (issue #214) - -v5.0.7 ------- - -* Made library easier to use from a CMake project: simply `add_subdirectory(ArduinoJson/src)` -* Changed `String` to be a `typedef` of `std::string` (issues #142 and #161) - -> ### BREAKING CHANGES :warning: -> -> - `JsonVariant(true).as()` now returns `"true"` instead of `"1"` -> - `JsonVariant(false).as()` now returns `"false"` instead of `"0"` - -v5.0.6 ------- - -* Added parameter to `DynamicJsonBuffer` constructor to set initial size (issue #152) -* Fixed warning about library category in Arduino 1.6.6 (issue #147) -* Examples: Added a loop to wait for serial port to be ready (issue #156) - -v5.0.5 ------- - -* Added overload `JsonObjectSuscript::set(value, decimals)` (issue #143) -* Use `float` instead of `double` to reduce the size of `JsonVariant` (issue #134) - -v5.0.4 ------- - -* Fixed ambiguous overload with `JsonArraySubscript` and `JsonObjectSubscript` (issue #122) - -v5.0.3 ------- - -* Fixed `printTo(String)` which wrote numbers instead of strings (issue #120) -* Fixed return type of `JsonArray::is()` and some others (issue #121) - -v5.0.2 ------- - -* Fixed segmentation fault in `parseObject(String)` and `parseArray(String)`, when the - `StaticJsonBuffer` is too small to hold a copy of the string -* Fixed Clang warning "register specifier is deprecated" (issue #102) -* Fixed GCC warning "declaration shadows a member" (issue #103) -* Fixed memory alignment, which made ESP8266 crash (issue #104) -* Fixed compilation on Visual Studio 2010 and 2012 (issue #107) - -v5.0.1 ------- - -* Fixed compilation with Arduino 1.0.6 (issue #99) - -v5.0.0 ------- - -* Added support of `String` class (issues #55, #56, #70, #77) -* Added `JsonBuffer::strdup()` to make a copy of a string (issues #10, #57) -* Implicitly call `strdup()` for `String` but not for `char*` (issues #84, #87) -* Added support of non standard JSON input (issue #44) -* Added support of comments in JSON input (issue #88) -* Added implicit cast between numerical types (issues #64, #69, #93) -* Added ability to read number values as string (issue #90) -* Redesigned `JsonVariant` to leverage converting constructors instead of assignment operators (issue #66) -* Switched to new the library layout (requires Arduino 1.0.6 or above) - -> ### BREAKING CHANGES :warning: -> -> - `JsonObject::add()` was renamed to `set()` -> - `JsonArray::at()` and `JsonObject::at()` were renamed to `get()` -> - Number of digits of floating point value are now set with `double_with_n_digits()` - -**Personal note about the `String` class**: -Support of the `String` class has been added to the library because many people use it in their programs. -However, you should not see this as an invitation to use the `String` class. -The `String` class is **bad** because it uses dynamic memory allocation. -Compared to static allocation, it compiles to a bigger, slower program, and is less predictable. -You certainly don't want that in an embedded environment! diff --git a/third-party/ArduinoJson/CMakeLists.txt b/third-party/ArduinoJson/CMakeLists.txt index b14cb0e..d5a32a9 100644 --- a/third-party/ArduinoJson/CMakeLists.txt +++ b/third-party/ArduinoJson/CMakeLists.txt @@ -1,17 +1,16 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.15) if(ESP_PLATFORM) # Build ArduinoJson as an ESP-IDF component idf_component_register(INCLUDE_DIRS src) - target_compile_definitions(${COMPONENT_LIB} INTERFACE ARDUINOJSON_EMBEDDED_MODE=1) return() endif() -project(ArduinoJson VERSION 6.18.5) +project(ArduinoJson VERSION 6.19.2) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/third-party/ArduinoJson/LICENSE.md b/third-party/ArduinoJson/LICENSE.md index 901bbb1..dee0b5b 100644 --- a/third-party/ArduinoJson/LICENSE.md +++ b/third-party/ArduinoJson/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) --------------------- -Copyright © 2014-2021 Benoit BLANCHON +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: diff --git a/third-party/ArduinoJson/README.md b/third-party/ArduinoJson/README.md index 440fca6..bf1ba11 100644 --- a/third-party/ArduinoJson/README.md +++ b/third-party/ArduinoJson/README.md @@ -5,15 +5,13 @@ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/bblanchon/ArduinoJson/Continuous%20Integration?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) -[![Coverage Status](https://coveralls.io/repos/github/bblanchon/ArduinoJson/badge.svg?branch=6.x)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) - - -[![Discord](https://img.shields.io/discord/844900310409150494.svg?logo=discord&logoColor=white&color=007ec6)](https://discord.gg/DzN6hHHD4h) +[![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/bblanchon/ArduinoJson?label=quality&logo=lgtm)](https://lgtm.com/projects/g/bblanchon/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.19.2&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.19.2) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.19.2)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.19.2) [![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-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.5)](https://www.ardu-badge.com/ArduinoJson/6.18.5) - ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). ## Features @@ -36,10 +34,10 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/?utm_source=github&utm_medium=readme) * [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/?utm_source=github&utm_medium=readme) * [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/?utm_source=github&utm_medium=readme) - * Deduplicates strings + * [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/?utm_source=github&utm_medium=readme) * Versatile * Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/?utm_source=github&utm_medium=readme) - * Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/?utm_source=github&utm_medium=readme), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme) and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/?utm_source=github&utm_medium=readme) + * Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/?utm_source=github&utm_medium=readme), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme), and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/?utm_source=github&utm_medium=readme) * Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/?utm_source=github&utm_medium=readme) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme) * Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme) * Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme#custom-writer) @@ -53,9 +51,10 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * Arduino boards: [Uno](https://amzn.to/38aL2ik), [Due](https://amzn.to/36YkWi2), [Micro](https://amzn.to/35WkdwG), [Nano](https://amzn.to/2QTvwRX), [Mega](https://amzn.to/36XWhuf), [Yun](https://amzn.to/30odURc), [Leonardo](https://amzn.to/36XWjlR)... * Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB) * Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)... - * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj) + * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj) * Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)... * Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)... + * Soft cores: [Nios II](https://en.wikipedia.org/wiki/Nios_II)... * Tested on all major development environments * [Arduino IDE](https://www.arduino.cc/en/Main/Software) * [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/) @@ -82,7 +81,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * Well tested * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) * Continuously tested on - * [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) + * [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) * [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [Clang 3.5, 3.6, 3.7, 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) @@ -99,6 +98,7 @@ 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 @@ -139,11 +139,24 @@ serializeJson(doc, Serial); See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme) -## Support the project ❤️ +## Sponsors + +ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it! + +

+ + Tech Explorations + + + Programming Electronics Academy + +

+

+ + 1technophile + +

-Do you like this library? -Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)! +If you run a commercial project that embeds ArduinoJson, think about [sponsoring the library's development](https://github.com/sponsors/bblanchon): it ensures the code that your products rely on stays actively maintained. It can also give your project some exposure to the makers' community. -What? You don't like it but you *love* it? -You can support the project by [purchasing my book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme). -Alternatively, you can make a recurring donation via [GitHub Sponsors](https://github.com/sponsors/bblanchon). +If you are an individual user and want to support the development (or give a sign of appreciation), consider purchasing the book [Mastering ArduinoJson](https://arduinojson.org/book/) ❤, or simply [cast a star](https://github.com/bblanchon/ArduinoJson/stargazers) ⭐. diff --git a/third-party/ArduinoJson/appveyor.yml b/third-party/ArduinoJson/appveyor.yml index 2882fda..a4c35ee 100644 --- a/third-party/ArduinoJson/appveyor.yml +++ b/third-party/ArduinoJson/appveyor.yml @@ -1,22 +1,37 @@ -version: 6.18.5.{build} +version: 6.19.2.{build} environment: matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - CMAKE_GENERATOR: Visual Studio 16 2019 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - CMAKE_GENERATOR: Visual Studio 15 2017 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - CMAKE_GENERATOR: Visual Studio 14 2015 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - CMAKE_GENERATOR: Visual Studio 12 2013 - - CMAKE_GENERATOR: Visual Studio 11 2012 - - CMAKE_GENERATOR: Visual Studio 10 2010 - - CMAKE_GENERATOR: MinGW Makefiles + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + CMAKE_GENERATOR: Visual Studio 17 2022 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + CMAKE_GENERATOR: Visual Studio 16 2019 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CMAKE_GENERATOR: Visual Studio 15 2017 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CMAKE_GENERATOR: Visual Studio 14 2015 + - CMAKE_GENERATOR: Visual Studio 12 2013 + - CMAKE_GENERATOR: Visual Studio 11 2012 + - CMAKE_GENERATOR: Visual Studio 10 2010 + - CMAKE_GENERATOR: Ninja + MINGW: MinGW # MinGW 32-bit 5.3.0 + - CMAKE_GENERATOR: Ninja + MINGW32: i686-5.3.0-posix-dwarf-rt_v4-rev0 # MinGW-w64 5.3.0 + - CMAKE_GENERATOR: Ninja + MINGW32: i686-6.3.0-posix-dwarf-rt_v5-rev1 # MinGW-w64 6.3.0 i686 + - CMAKE_GENERATOR: Ninja + MINGW64: x86_64-6.3.0-posix-seh-rt_v5-rev1 # MinGW-w64 6.3.0 x86_64 + - CMAKE_GENERATOR: Ninja + MINGW64: x86_64-7.3.0-posix-seh-rt_v5-rev0 # MinGW-w64 7.3.0 x86_64 + - CMAKE_GENERATOR: Ninja + MINGW64: x86_64-8.1.0-posix-seh-rt_v6-rev0 # MinGW-w64 8.1.0 x86_64 configuration: Debug before_build: -- set PATH=C:\MinGW\bin;%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW -- cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" . + - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW + - if defined MINGW set PATH=C:\%MINGW%\bin;%PATH% + - if defined MINGW32 set PATH=C:\mingw-w64\%MINGW32%\mingw32\bin;%PATH% + - if defined MINGW64 set PATH=C:\mingw-w64\%MINGW64%\mingw64\bin;%PATH% + - cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" . build_script: -- cmake --build . --config %CONFIGURATION% + - cmake --build . --config %CONFIGURATION% test_script: -- ctest -C %CONFIGURATION% --output-on-failure . + - ctest -C %CONFIGURATION% --output-on-failure . diff --git a/third-party/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino b/third-party/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino index 88d3f13..3443ba7 100644 --- a/third-party/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino +++ b/third-party/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to store your project configuration in a file. diff --git a/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino b/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino index 927a628..f50187a 100644 --- a/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino +++ b/third-party/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to use DeserializationOpion::Filter diff --git a/third-party/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/third-party/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino index b924e65..ae1c0e2 100644 --- a/third-party/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino +++ b/third-party/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to generate a JSON document with ArduinoJson. diff --git a/third-party/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino b/third-party/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino index 032e3c5..8e2e6d7 100644 --- a/third-party/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino +++ b/third-party/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to parse a JSON document in an HTTP response. diff --git a/third-party/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino b/third-party/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino index c2a44d2..10f1419 100644 --- a/third-party/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino +++ b/third-party/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to deserialize a JSON document with ArduinoJson. diff --git a/third-party/ArduinoJson/examples/JsonServer/JsonServer.ino b/third-party/ArduinoJson/examples/JsonServer/JsonServer.ino index 2c46dd5..52d55c5 100644 --- a/third-party/ArduinoJson/examples/JsonServer/JsonServer.ino +++ b/third-party/ArduinoJson/examples/JsonServer/JsonServer.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to implement an HTTP server that sends a JSON document diff --git a/third-party/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/third-party/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino index ffa8414..87965a3 100644 --- a/third-party/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino +++ b/third-party/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to send a JSON document to a UDP socket. diff --git a/third-party/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino b/third-party/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino index e7da098..a14245b 100644 --- a/third-party/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino +++ b/third-party/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to deserialize a MessagePack document with diff --git a/third-party/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino b/third-party/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino index 203c888..8cb4ddd 100644 --- a/third-party/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino +++ b/third-party/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows the different ways you can use Flash strings with @@ -14,8 +14,6 @@ #include void setup() { -#ifdef PROGMEM // <- check that Flash strings are supported - DynamicJsonDocument doc(1024); // You can use a Flash String as your JSON input. @@ -46,12 +44,6 @@ void setup() { if (obj["sensor"] == F("gps")) { // ... } - -#else - -#warning PROGMEM is not supported on this platform - -#endif } void loop() { diff --git a/third-party/ArduinoJson/examples/StringExample/StringExample.ino b/third-party/ArduinoJson/examples/StringExample/StringExample.ino index 22330f5..0fd3068 100644 --- a/third-party/ArduinoJson/examples/StringExample/StringExample.ino +++ b/third-party/ArduinoJson/examples/StringExample/StringExample.ino @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows the different ways you can use String with ArduinoJson. diff --git a/third-party/ArduinoJson/extras/ci/espidf/CMakeLists.txt b/third-party/ArduinoJson/extras/ci/espidf/CMakeLists.txt index 3932d3b..e3c4475 100644 --- a/third-party/ArduinoJson/extras/ci/espidf/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/ci/espidf/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License cmake_minimum_required(VERSION 3.5) diff --git a/third-party/ArduinoJson/extras/ci/espidf/main/CMakeLists.txt b/third-party/ArduinoJson/extras/ci/espidf/main/CMakeLists.txt index e501acd..f06bfda 100644 --- a/third-party/ArduinoJson/extras/ci/espidf/main/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/ci/espidf/main/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License idf_component_register(SRCS "main.cpp" diff --git a/third-party/ArduinoJson/extras/ci/espidf/main/main.cpp b/third-party/ArduinoJson/extras/ci/espidf/main/main.cpp index f3ec000..50d7ec0 100644 --- a/third-party/ArduinoJson/extras/ci/espidf/main/main.cpp +++ b/third-party/ArduinoJson/extras/ci/espidf/main/main.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/conf_test/avr.cpp b/third-party/ArduinoJson/extras/conf_test/avr.cpp new file mode 100644 index 0000000..cd0b4bd --- /dev/null +++ b/third-party/ArduinoJson/extras/conf_test/avr.cpp @@ -0,0 +1,16 @@ +#include + +static_assert(ARDUINOJSON_USE_LONG_LONG == 0, "ARDUINOJSON_USE_LONG_LONG"); + +static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 1, + "ARDUINOJSON_SLOT_OFFSET_SIZE"); + +static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); + +static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); + +static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 8, + "sizeof(VariantSlot)"); + +void setup() {} +void loop() {} diff --git a/third-party/ArduinoJson/extras/conf_test/esp8266.cpp b/third-party/ArduinoJson/extras/conf_test/esp8266.cpp new file mode 100644 index 0000000..bb9988b --- /dev/null +++ b/third-party/ArduinoJson/extras/conf_test/esp8266.cpp @@ -0,0 +1,16 @@ +#include + +static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG"); + +static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 2, + "ARDUINOJSON_SLOT_OFFSET_SIZE"); + +static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); + +static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); + +static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 16, + "sizeof(VariantSlot)"); + +void setup() {} +void loop() {} diff --git a/third-party/ArduinoJson/extras/conf_test/x64.cpp b/third-party/ArduinoJson/extras/conf_test/x64.cpp new file mode 100644 index 0000000..8cd6c06 --- /dev/null +++ b/third-party/ArduinoJson/extras/conf_test/x64.cpp @@ -0,0 +1,15 @@ +#include + +static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG"); + +static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 4, + "ARDUINOJSON_SLOT_OFFSET_SIZE"); + +static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); + +static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); + +static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 32, + "sizeof(VariantSlot)"); + +int main() {} diff --git a/third-party/ArduinoJson/extras/conf_test/x86.cpp b/third-party/ArduinoJson/extras/conf_test/x86.cpp new file mode 100644 index 0000000..dab9da6 --- /dev/null +++ b/third-party/ArduinoJson/extras/conf_test/x86.cpp @@ -0,0 +1,15 @@ +#include + +static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG"); + +static_assert(ARDUINOJSON_SLOT_OFFSET_SIZE == 2, + "ARDUINOJSON_SLOT_OFFSET_SIZE"); + +static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); + +static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); + +static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 16, + "sizeof(VariantSlot)"); + +int main() {} diff --git a/third-party/ArduinoJson/extras/fuzzing/CMakeLists.txt b/third-party/ArduinoJson/extras/fuzzing/CMakeLists.txt index 53f4880..e5d6a36 100644 --- a/third-party/ArduinoJson/extras/fuzzing/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/fuzzing/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License if(MSVC) diff --git a/third-party/ArduinoJson/extras/fuzzing/reproducer.cpp b/third-party/ArduinoJson/extras/fuzzing/reproducer.cpp index 21e218e..8681801 100644 --- a/third-party/ArduinoJson/extras/fuzzing/reproducer.cpp +++ b/third-party/ArduinoJson/extras/fuzzing/reproducer.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // This file is NOT use by Google's OSS fuzz diff --git a/third-party/ArduinoJson/extras/scripts/get-release-body.sh b/third-party/ArduinoJson/extras/scripts/get-release-body.sh index 1514ecd..7c842c2 100644 --- a/third-party/ArduinoJson/extras/scripts/get-release-body.sh +++ b/third-party/ArduinoJson/extras/scripts/get-release-body.sh @@ -8,7 +8,7 @@ CHANGELOG="$2" cat << END ## Changes -$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG") +$(awk '/\* /{ FOUND=1 } /^[[:space:]]*$/ { if(FOUND) exit } { if(FOUND) print }' "$CHANGELOG") [View version history](https://github.com/bblanchon/ArduinoJson/blob/$TAG/CHANGELOG.md) END diff --git a/third-party/ArduinoJson/extras/scripts/publish.sh b/third-party/ArduinoJson/extras/scripts/publish.sh index 3552ef9..c5a4eef 100644 --- a/third-party/ArduinoJson/extras/scripts/publish.sh +++ b/third-party/ArduinoJson/extras/scripts/publish.sh @@ -2,18 +2,25 @@ set -eu +which awk sed jq 7z curl perl >/dev/null + cd "$(dirname "$0")/../.." +if ! git diff --quiet --exit-code; then + echo "Repository contains uncommitted changes" + exit +fi + VERSION="$1" DATE=$(date +%F) TAG="v$VERSION" -VERSION_REGEX="[0-9a-z\\.\\-]+" +VERSION_REGEX='[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9]+)?' update_version_in_source () { IFS=".-" read MAJOR MINOR REVISION EXTRA < <(echo "$VERSION") UNDERLINE=$(printf -- '-%.0s' $(seq 1 ${#TAG})) - sed -i~ -bE "s/version=$VERSION_REGEX/version=$VERSION/; s|ardu-badge.com/ArduinoJson/$VERSION_REGEX|ardu-badge.com/ArduinoJson/$VERSION|; " README.md + sed -i~ -bE "1,20{s/$VERSION_REGEX/$VERSION/g}" README.md rm README.md~ sed -i~ -bE "4s/HEAD/$TAG ($DATE)/; 5s/-+/$UNDERLINE/" CHANGELOG.md @@ -62,7 +69,7 @@ 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" +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" echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md" diff --git a/third-party/ArduinoJson/extras/scripts/wandbox/JsonGeneratorExample.cpp b/third-party/ArduinoJson/extras/scripts/wandbox/JsonGeneratorExample.cpp index ffa0762..0090c84 100644 --- a/third-party/ArduinoJson/extras/scripts/wandbox/JsonGeneratorExample.cpp +++ b/third-party/ArduinoJson/extras/scripts/wandbox/JsonGeneratorExample.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to generate a JSON document with ArduinoJson. diff --git a/third-party/ArduinoJson/extras/scripts/wandbox/JsonParserExample.cpp b/third-party/ArduinoJson/extras/scripts/wandbox/JsonParserExample.cpp index 15fe7e4..f513caf 100644 --- a/third-party/ArduinoJson/extras/scripts/wandbox/JsonParserExample.cpp +++ b/third-party/ArduinoJson/extras/scripts/wandbox/JsonParserExample.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to deserialize a JSON document with ArduinoJson. diff --git a/third-party/ArduinoJson/extras/scripts/wandbox/MsgPackParserExample.cpp b/third-party/ArduinoJson/extras/scripts/wandbox/MsgPackParserExample.cpp index 32ac47d..186816e 100644 --- a/third-party/ArduinoJson/extras/scripts/wandbox/MsgPackParserExample.cpp +++ b/third-party/ArduinoJson/extras/scripts/wandbox/MsgPackParserExample.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // This example shows how to generate a JSON document with ArduinoJson. diff --git a/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh b/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh index 2884363..0900cb0 100644 --- a/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh +++ b/third-party/ArduinoJson/extras/scripts/wandbox/publish.sh @@ -15,13 +15,13 @@ compile() { "code":$(read_string "$FILE_PATH"), "codes": [{"file":"ArduinoJson.h","code":$(read_string "$ARDUINOJSON_H")}], "options": "warning", - "compiler": "gcc-4.9.3", + "compiler": "gcc-4.9.4", "save": true } END URL=$(curl -sS -H "Content-type: application/json" -d @parameters.json https://wandbox.org/api/compile.json | jq --raw-output .url) rm parameters.json - echo "$1: $URL" + [ -n "$URL" ] && echo "$1: $URL" } compile "JsonGeneratorExample" diff --git a/third-party/ArduinoJson/extras/tests/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/CMakeLists.txt index 2c0b3a1..faf4cd9 100644 --- a/third-party/ArduinoJson/extras/tests/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License set(CMAKE_CXX_STANDARD 98) diff --git a/third-party/ArduinoJson/extras/tests/Cpp11/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/Cpp11/CMakeLists.txt index bae9fa9..18e54ba 100644 --- a/third-party/ArduinoJson/extras/tests/Cpp11/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/Cpp11/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License if("cxx_nullptr" IN_LIST CMAKE_CXX_COMPILE_FEATURES) diff --git a/third-party/ArduinoJson/extras/tests/Cpp17/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/Cpp17/CMakeLists.txt index 80bf97b..05af200 100644 --- a/third-party/ArduinoJson/extras/tests/Cpp17/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/Cpp17/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License if(MSVC_VERSION LESS 1910) diff --git a/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp b/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp index 56ad48c..729c59a 100644 --- a/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp +++ b/third-party/ArduinoJson/extras/tests/Cpp17/string_view.cpp @@ -8,7 +8,7 @@ #endif TEST_CASE("string_view") { - StaticJsonDocument<128> doc; + StaticJsonDocument<256> doc; JsonVariant variant = doc.to(); SECTION("deserializeJson()") { @@ -57,6 +57,12 @@ TEST_CASE("string_view") { doc.add(std::string_view("example two", 7)); REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(2) + 8); + + doc.add(std::string_view("example\0tree", 12)); + REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(3) + 21); + + doc.add(std::string_view("example\0tree and a half", 12)); + REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(4) + 21); } SECTION("as()") { @@ -72,6 +78,12 @@ TEST_CASE("string_view") { REQUIRE(doc["s"].is() == true); REQUIRE(doc["i"].is() == false); } + + SECTION("String containing NUL") { + doc.set(std::string("hello\0world", 11)); + REQUIRE(doc.as().size() == 11); + REQUIRE(doc.as() == std::string_view("hello\0world", 11)); + } } using ARDUINOJSON_NAMESPACE::adaptString; @@ -80,10 +92,9 @@ TEST_CASE("StringViewAdapter") { std::string_view str("bravoXXX", 5); auto adapter = adaptString(str); - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); + CHECK(stringCompare(adapter, adaptString("alpha", 5)) > 0); + CHECK(stringCompare(adapter, adaptString("bravo", 5)) == 0); + CHECK(stringCompare(adapter, adaptString("charlie", 7)) < 0); CHECK(adapter.size() == 5); } diff --git a/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt index 8953409..2c9a72b 100644 --- a/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License if(MSVC_VERSION LESS 1910) diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt index 10bda9c..dc76c91 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License macro(build_should_fail target) diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue1189.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue1189.cpp index baf82f7..e86bb99 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue1189.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue1189.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue978.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue978.cpp index aebcd59..112d36d 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue978.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/Issue978.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/assign_char.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/assign_char.cpp index 28f6248..633b54d 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/assign_char.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/assign_char.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/delete_jsondocument.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/delete_jsondocument.cpp index b99fa5d..ef2b0e8 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/delete_jsondocument.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/delete_jsondocument.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/read_long_long.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/read_long_long.cpp index 242231f..d900a7f 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/read_long_long.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/read_long_long.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_USE_LONG_LONG 0 diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/variant_as_char.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/variant_as_char.cpp index 5080861..41885cf 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/variant_as_char.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/variant_as_char.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/FailingBuilds/write_long_long.cpp b/third-party/ArduinoJson/extras/tests/FailingBuilds/write_long_long.cpp index 130fabb..2213a4d 100644 --- a/third-party/ArduinoJson/extras/tests/FailingBuilds/write_long_long.cpp +++ b/third-party/ArduinoJson/extras/tests/FailingBuilds/write_long_long.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_USE_LONG_LONG 0 diff --git a/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h b/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h index a369622..4f24b26 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h +++ b/third-party/ArduinoJson/extras/tests/Helpers/Arduino.h @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -7,3 +7,6 @@ #include "api/Print.h" #include "api/Stream.h" #include "api/String.h" +#include "progmem_emulation.hpp" + +#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 c76ce2a..8a97b50 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp +++ b/third-party/ArduinoJson/extras/tests/Helpers/CustomReader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/extras/tests/Helpers/api/Print.h b/third-party/ArduinoJson/extras/tests/Helpers/api/Print.h index 5af49b4..864fb41 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/api/Print.h +++ b/third-party/ArduinoJson/extras/tests/Helpers/api/Print.h @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/extras/tests/Helpers/api/Stream.h b/third-party/ArduinoJson/extras/tests/Helpers/api/Stream.h index 907e69f..8cc18d2 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/api/Stream.h +++ b/third-party/ArduinoJson/extras/tests/Helpers/api/Stream.h @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/extras/tests/Helpers/api/String.h b/third-party/ArduinoJson/extras/tests/Helpers/api/String.h index 31609de..b2d5ac5 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/api/String.h +++ b/third-party/ArduinoJson/extras/tests/Helpers/api/String.h @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -32,6 +32,17 @@ class String { return _str == s; } + String& operator=(const char* s) { + _str.assign(s); + return *this; + } + + char operator[](unsigned int index) const { + if (index >= _str.size()) + return 0; + return _str[index]; + } + friend std::ostream& operator<<(std::ostream& lhs, const ::String& rhs) { lhs << rhs._str; return lhs; diff --git a/third-party/ArduinoJson/extras/tests/Helpers/progmem_emulation.hpp b/third-party/ArduinoJson/extras/tests/Helpers/progmem_emulation.hpp index 086ce10..41597dc 100644 --- a/third-party/ArduinoJson/extras/tests/Helpers/progmem_emulation.hpp +++ b/third-party/ArduinoJson/extras/tests/Helpers/progmem_emulation.hpp @@ -1,9 +1,8 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include // uint8_t -#include // strcmp, strlen... #define PROGMEM @@ -24,19 +23,7 @@ inline uint8_t pgm_read_byte(const void* p) { return *reinterpret_cast(convertFlashToPtr(p)); } -inline void* pgm_read_ptr(const void* p) { - return *reinterpret_cast(convertFlashToPtr(p)); -} - -inline float pgm_read_float(const void* p) { - return *reinterpret_cast(convertFlashToPtr(p)); -} - -inline uint32_t pgm_read_dword(const void* p) { - return *reinterpret_cast(convertFlashToPtr(p)); -} - -#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ +#define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \ 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 8fd6921..88b5ba6 100644 --- a/third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/IntegrationTests/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(IntegrationTests diff --git a/third-party/ArduinoJson/extras/tests/IntegrationTests/gbathree.cpp b/third-party/ArduinoJson/extras/tests/IntegrationTests/gbathree.cpp index c82752b..2190eb1 100644 --- a/third-party/ArduinoJson/extras/tests/IntegrationTests/gbathree.cpp +++ b/third-party/ArduinoJson/extras/tests/IntegrationTests/gbathree.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/IntegrationTests/issue772.cpp b/third-party/ArduinoJson/extras/tests/IntegrationTests/issue772.cpp index 928fcd5..4984b43 100644 --- a/third-party/ArduinoJson/extras/tests/IntegrationTests/issue772.cpp +++ b/third-party/ArduinoJson/extras/tests/IntegrationTests/issue772.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/IntegrationTests/openweathermap.cpp b/third-party/ArduinoJson/extras/tests/IntegrationTests/openweathermap.cpp index 3259244..44e2f76 100644 --- a/third-party/ArduinoJson/extras/tests/IntegrationTests/openweathermap.cpp +++ b/third-party/ArduinoJson/extras/tests/IntegrationTests/openweathermap.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/IntegrationTests/round_trip.cpp b/third-party/ArduinoJson/extras/tests/IntegrationTests/round_trip.cpp index 4646e35..edc5538 100644 --- a/third-party/ArduinoJson/extras/tests/IntegrationTests/round_trip.cpp +++ b/third-party/ArduinoJson/extras/tests/IntegrationTests/round_trip.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonArray/CMakeLists.txt index e0052a9..e679718 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonArray/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(JsonArrayTests @@ -17,7 +17,7 @@ add_executable(JsonArrayTests size.cpp std_string.cpp subscript.cpp - undefined.cpp + unbound.cpp ) add_test(JsonArray JsonArrayTests) diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/add.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/add.cpp index 446f1bd..c6b1b9a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/add.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/add.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/clear.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/clear.cpp index 568c6aa..baeb022 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/clear.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/clear.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp index 3f5f47c..599821d 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/copyArray.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -32,6 +32,56 @@ TEST_CASE("copyArray()") { CHECK(std::string("[\"a\",\"b\",\"c\"]") == json); } + SECTION("const char*[] -> JsonArray") { + DynamicJsonDocument doc(4096); + JsonArray array = doc.to(); + char json[32]; + const char* source[] = {"a", "b", "c"}; + + bool ok = copyArray(source, array); + CHECK(ok); + + serializeJson(array, json); + CHECK(std::string("[\"a\",\"b\",\"c\"]") == json); + } + + SECTION("const char[][] -> JsonArray") { + DynamicJsonDocument doc(4096); + JsonArray array = doc.to(); + char json[32]; + char source[][2] = {"a", "b", "c"}; + + bool ok = copyArray(source, array); + CHECK(ok); + + serializeJson(array, json); + CHECK(std::string("[\"a\",\"b\",\"c\"]") == json); + } + + SECTION("const char[][] -> JsonDocument") { + DynamicJsonDocument doc(4096); + char json[32]; + char source[][2] = {"a", "b", "c"}; + + bool ok = copyArray(source, doc); + CHECK(ok); + + serializeJson(doc, json); + CHECK(std::string("[\"a\",\"b\",\"c\"]") == json); + } + + SECTION("const char[][] -> MemberProxy") { + DynamicJsonDocument doc(4096); + char json[32]; + char source[][2] = {"a", "b", "c"}; + + bool ok = copyArray(source, doc["data"]); + CHECK(ok); + + serializeJson(doc, json); + CHECK(std::string("{\"data\":[\"a\",\"b\",\"c\"]}") == json); + } + SECTION("int[] -> JsonDocument") { DynamicJsonDocument doc(4096); char json[32]; @@ -174,6 +224,23 @@ TEST_CASE("copyArray()") { CHECK("" == destination[3]); } + SECTION("JsonArray -> char[N][]") { + DynamicJsonDocument doc(4096); + char json[] = "[\"a12345\",\"b123456\",\"c1234567\"]"; + DeserializationError err = deserializeJson(doc, json); + CHECK(err == DeserializationError::Ok); + JsonArray array = doc.as(); + + char destination[4][8] = {{0}}; + size_t result = copyArray(array, destination); + + CHECK(3 == result); + CHECK(std::string("a12345") == destination[0]); + CHECK(std::string("b123456") == destination[1]); + CHECK(std::string("c123456") == destination[2]); // truncated + CHECK(std::string("") == destination[3]); + } + SECTION("JsonDocument -> int[]") { DynamicJsonDocument doc(4096); char json[] = "[1,2,3]"; diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/createNested.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/createNested.cpp index 9ff5544..dbc4c30 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/createNested.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/createNested.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/equals.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/equals.cpp index 718f3af..f4f9b52 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/equals.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/equals.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/get.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/get.cpp index 3aa6858..895a2f6 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/get.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/get.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/isNull.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/isNull.cpp index 75fdbf6..ad953b9 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/isNull.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/isNull.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/iterator.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/iterator.cpp index 591593d..435a5bb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/iterator.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/iterator.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/memoryUsage.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/memoryUsage.cpp index 624a891..05b743f 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/memoryUsage.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/memoryUsage.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/nesting.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/nesting.cpp index f1e0264..2118f5f 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/nesting.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/nesting.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/remove.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/remove.cpp index 2cf1dc0..b9e86fd 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/remove.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/remove.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/size.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/size.cpp index 5aab205..68b10de 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/size.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/size.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/std_string.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/std_string.cpp index a65c321..b7de0ef 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/std_string.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/std_string.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/subscript.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/subscript.cpp index 74180ba..1d5a6a5 100644 --- a/third-party/ArduinoJson/extras/tests/JsonArray/subscript.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonArray/subscript.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonArray/unbound.cpp b/third-party/ArduinoJson/extras/tests/JsonArray/unbound.cpp new file mode 100644 index 0000000..792feec --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/JsonArray/unbound.cpp @@ -0,0 +1,35 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#include +#include + +using namespace Catch::Matchers; + +TEST_CASE("Unbound JsonArray") { + JsonArray array; + + SECTION("SubscriptFails") { + REQUIRE(array[0].isNull()); + } + + SECTION("AddFails") { + array.add(1); + REQUIRE(0 == array.size()); + } + + SECTION("CreateNestedArrayFails") { + REQUIRE(array.createNestedArray().isNull()); + } + + SECTION("CreateNestedObjectFails") { + REQUIRE(array.createNestedObject().isNull()); + } + + SECTION("PrintToWritesBrackets") { + char buffer[32]; + serializeJson(array, buffer, sizeof(buffer)); + REQUIRE_THAT(buffer, Equals("null")); + } +} diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonDeserializer/CMakeLists.txt index 01ce19b..429c375 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(JsonDeserializerTests diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/DeserializationError.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/DeserializationError.cpp index 3e79290..01ddaf6 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/DeserializationError.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/DeserializationError.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -11,14 +11,14 @@ void testStringification(DeserializationError error, std::string expected) { void testBoolification(DeserializationError error, bool expected) { // DeserializationError on left-hand side - CHECK(error == expected); - CHECK(error != !expected); - CHECK(!error == !expected); + CHECK(bool(error) == expected); + CHECK(bool(error) != !expected); + CHECK(!bool(error) == !expected); // DeserializationError on right-hand side - CHECK(expected == error); - CHECK(!expected != error); - CHECK(!expected == !error); + CHECK(expected == bool(error)); + CHECK(!expected != bool(error)); + CHECK(!expected == !bool(error)); } #define TEST_STRINGIFICATION(symbol) \ @@ -70,34 +70,24 @@ TEST_CASE("DeserializationError") { } } - SECTION("Comparisons") { + SECTION("Use in a condition") { DeserializationError invalidInput(DeserializationError::InvalidInput); DeserializationError ok(DeserializationError::Ok); - SECTION("DeserializationError == bool") { - REQUIRE(invalidInput == true); - REQUIRE(ok == false); - } - - SECTION("bool == DeserializationError") { - REQUIRE(true == invalidInput); - REQUIRE(false == ok); - } - - SECTION("DeserializationError != bool") { - REQUIRE(invalidInput != false); - REQUIRE(ok != true); + SECTION("if (!err)") { + if (!invalidInput) + FAIL(); } - SECTION("bool != DeserializationError") { - REQUIRE(false != invalidInput); - REQUIRE(true != ok); + SECTION("if (err)") { + if (ok) + FAIL(); } + } - SECTION("Negations") { - REQUIRE(!invalidInput == false); - REQUIRE(!ok == true); - } + SECTION("Comparisons") { + DeserializationError invalidInput(DeserializationError::InvalidInput); + DeserializationError ok(DeserializationError::Ok); SECTION("DeserializationError == Code") { REQUIRE(invalidInput == DeserializationError::InvalidInput); diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/array.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/array.cpp index 209fd60..2e0038e 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/array.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/array.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/array_static.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/array_static.cpp index c5689a8..d828518 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/array_static.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/array_static.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp index 6e24081..e950f76 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_ENABLE_COMMENTS 1 @@ -667,6 +667,20 @@ TEST_CASE("Filtering") { } } +TEST_CASE("Zero-copy mode") { // issue #1697 + char input[] = "{\"include\":42,\"exclude\":666}"; + + StaticJsonDocument<256> filter; + filter["include"] = true; + + StaticJsonDocument<256> doc; + DeserializationError err = + deserializeJson(doc, input, DeserializationOption::Filter(filter)); + + REQUIRE(err == DeserializationError::Ok); + CHECK(doc.as() == "{\"include\":42}"); +} + TEST_CASE("Overloads") { StaticJsonDocument<256> doc; StaticJsonDocument<256> filter; diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/incomplete_input.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/incomplete_input.cpp index 85ea552..4e5bcdb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/incomplete_input.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/incomplete_input.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_DECODE_UNICODE 1 diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp index 757298b..7f9f00a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/input_types.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/invalid_input.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/invalid_input.cpp index b369052..f358008 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/invalid_input.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/invalid_input.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_DECODE_UNICODE 1 diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/misc.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/misc.cpp index ab77ed1..dc8083c 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/misc.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/misc.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/nestingLimit.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/nestingLimit.cpp index 06c9c92..0cdcb3e 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/nestingLimit.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/nestingLimit.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/number.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/number.cpp index f659d20..44e24cb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/number.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/number.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_USE_LONG_LONG 0 diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp index 4c77075..e5d5de7 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/object.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -279,6 +279,22 @@ TEST_CASE("deserialize JSON object") { REQUIRE(err == DeserializationError::Ok); REQUIRE(doc["a"] == 2); } + + SECTION("Repeated key with zero copy mode") { // issue #1697 + char input[] = "{a:{b:{c:1}},a:2}"; + DeserializationError err = deserializeJson(doc, input); + + REQUIRE(err == DeserializationError::Ok); + REQUIRE(doc["a"] == 2); + } + + SECTION("NUL in keys") { // we don't support NULs in keys + DeserializationError err = + deserializeJson(doc, "{\"x\\u0000a\":1,\"x\\u0000b\":2}"); + + REQUIRE(err == DeserializationError::Ok); + REQUIRE(doc.as() == "{\"x\":2}"); + } } SECTION("Should clear the JsonObject") { diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/object_static.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/object_static.cpp index b15d150..a326afe 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/object_static.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/object_static.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp index 5ab8764..8f93ac6 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_DECODE_UNICODE 1 @@ -60,9 +60,8 @@ TEST_CASE("\\u0000") { CHECK(result[4] == 'z'); CHECK(result[5] == 0); - // ArduinoJson strings doesn't store string length, so the following returns 2 - // instead of 5 (issue #1646) - CHECK(doc.as().size() == 2); + CHECK(doc.as().size() == 5); + CHECK(doc.as().size() == 5); } TEST_CASE("Truncated JSON string") { @@ -97,12 +96,37 @@ TEST_CASE("Not enough room to save the key") { DynamicJsonDocument doc(JSON_OBJECT_SIZE(1) + 8); SECTION("Quoted string") { + REQUIRE(deserializeJson(doc, "{\"example\":1}") == + DeserializationError::Ok); REQUIRE(deserializeJson(doc, "{\"accuracy\":1}") == DeserializationError::NoMemory); + REQUIRE(deserializeJson(doc, "{\"hello\":1,\"world\"}") == + DeserializationError::NoMemory); // fails in the second string } SECTION("Non-quoted string") { + REQUIRE(deserializeJson(doc, "{example:1}") == DeserializationError::Ok); REQUIRE(deserializeJson(doc, "{accuracy:1}") == DeserializationError::NoMemory); + REQUIRE(deserializeJson(doc, "{hello:1,world}") == + DeserializationError::NoMemory); // fails in the second string + } +} + +TEST_CASE("Empty memory pool") { + // NOLINTNEXTLINE(clang-analyzer-optin.portability.UnixAPI) + DynamicJsonDocument doc(0); + + SECTION("Input is const char*") { + REQUIRE(deserializeJson(doc, "\"hello\"") == + DeserializationError::NoMemory); + REQUIRE(deserializeJson(doc, "\"\"") == DeserializationError::NoMemory); + } + + SECTION("Input is const char*") { + char hello[] = "\"hello\""; + REQUIRE(deserializeJson(doc, hello) == DeserializationError::Ok); + char empty[] = "\"hello\""; + REQUIRE(deserializeJson(doc, empty) == DeserializationError::Ok); } } diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp index 15b30f9..d207440 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/BasicJsonDocument.cpp @@ -1,14 +1,14 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include #include // malloc, free #include #include +#include using ARDUINOJSON_NAMESPACE::addPadding; -using ARDUINOJSON_NAMESPACE::move; class SpyingAllocator { public: @@ -78,7 +78,7 @@ TEST_CASE("BasicJsonDocument") { BasicJsonDocument doc1(4096, log); doc1.set(std::string("The size of this string is 32!!")); - BasicJsonDocument doc2(move(doc1)); + BasicJsonDocument doc2(std::move(doc1)); REQUIRE(doc2.as() == "The size of this string is 32!!"); REQUIRE(doc1.as() == "null"); @@ -89,7 +89,7 @@ TEST_CASE("BasicJsonDocument") { } #endif - SECTION("Copy assign") { + SECTION("Copy assign larger") { { BasicJsonDocument doc1(4096, log); doc1.set(std::string("The size of this string is 32!!")); @@ -104,6 +104,36 @@ TEST_CASE("BasicJsonDocument") { REQUIRE(log.str() == "A4096A8FA4096FF"); } + SECTION("Copy assign smaller") { + { + BasicJsonDocument doc1(1024, log); + doc1.set(std::string("The size of this string is 32!!")); + BasicJsonDocument doc2(4096, log); + + doc2 = doc1; + + REQUIRE(doc1.as() == "The size of this string is 32!!"); + REQUIRE(doc2.as() == "The size of this string is 32!!"); + REQUIRE(doc2.capacity() == 1024); + } + REQUIRE(log.str() == "A1024A4096FA1024FF"); + } + + SECTION("Copy assign same size") { + { + BasicJsonDocument doc1(1024, log); + doc1.set(std::string("The size of this string is 32!!")); + BasicJsonDocument doc2(1024, log); + + doc2 = doc1; + + REQUIRE(doc1.as() == "The size of this string is 32!!"); + REQUIRE(doc2.as() == "The size of this string is 32!!"); + REQUIRE(doc2.capacity() == 1024); + } + REQUIRE(log.str() == "A1024A1024FF"); + } + #if ARDUINOJSON_HAS_RVALUE_REFERENCES SECTION("Move assign") { { @@ -111,7 +141,7 @@ TEST_CASE("BasicJsonDocument") { doc1.set(std::string("The size of this string is 32!!")); BasicJsonDocument doc2(8, log); - doc2 = move(doc1); + doc2 = std::move(doc1); REQUIRE(doc2.as() == "The size of this string is 32!!"); REQUIRE(doc1.as() == "null"); diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt index 18c07f0..e44689c 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(JsonDocumentTests @@ -19,6 +19,7 @@ add_executable(JsonDocumentTests size.cpp StaticJsonDocument.cpp subscript.cpp + swap.cpp ) add_test(JsonDocument JsonDocumentTests) diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp index 6cf953a..8a5c7bb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/DynamicJsonDocument.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -138,27 +138,26 @@ TEST_CASE("DynamicJsonDocument constructor") { } TEST_CASE("DynamicJsonDocument assignment") { - SECTION("Copy assignment preserves the buffer when capacity is sufficient") { + SECTION("Copy assignment reallocates when capacity is smaller") { DynamicJsonDocument doc1(1234); deserializeJson(doc1, "{\"hello\":\"world\"}"); + DynamicJsonDocument doc2(8); - DynamicJsonDocument doc2(doc1.capacity()); doc2 = doc1; REQUIRE_JSON(doc2, "{\"hello\":\"world\"}"); REQUIRE(doc2.capacity() == doc1.capacity()); } - SECTION("Copy assignment realloc the buffer when capacity is insufficient") { - DynamicJsonDocument doc1(1234); + SECTION("Copy assignment reallocates when capacity is larger") { + DynamicJsonDocument doc1(100); deserializeJson(doc1, "{\"hello\":\"world\"}"); - DynamicJsonDocument doc2(8); + DynamicJsonDocument doc2(1234); - REQUIRE(doc2.capacity() < doc1.memoryUsage()); doc2 = doc1; - REQUIRE(doc2.capacity() >= doc1.memoryUsage()); REQUIRE_JSON(doc2, "{\"hello\":\"world\"}"); + REQUIRE(doc2.capacity() == doc1.capacity()); } SECTION("Assign from StaticJsonDocument") { diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp index 1fcd24b..9e4c7a9 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp index cf4e563..813152d 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/StaticJsonDocument.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/StaticJsonDocument.cpp index f9ecc2e..fe193e4 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/StaticJsonDocument.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/StaticJsonDocument.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/add.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/add.cpp index c32858e..109bd08 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/add.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/add.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp index 44139e0..24d27bc 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/compare.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/containsKey.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/containsKey.cpp index 88940d4..6936043 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/containsKey.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/containsKey.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/createNested.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/createNested.cpp index 5fc7eb5..258f051 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/createNested.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/createNested.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/isNull.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/isNull.cpp index 741f280..cfb70dd 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/isNull.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/isNull.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/nesting.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/nesting.cpp index e8ac2e5..3284dd1 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/nesting.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/nesting.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/overflowed.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/overflowed.cpp index f7b3898..cea0db9 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/overflowed.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/overflowed.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -35,6 +35,12 @@ TEST_CASE("JsonDocument::overflowed()") { CHECK(doc.overflowed() == false); } + SECTION("returns true after a failed member add") { + StaticJsonDocument<1> doc; + doc["example"] = true; + CHECK(doc.overflowed() == true); + } + SECTION("returns true after a failed deserialization") { StaticJsonDocument doc; deserializeJson(doc, "[\"example\"]"); diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/remove.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/remove.cpp index 84b8b6d..2fb8cad 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/remove.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/remove.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp index 64950c0..0eb34e8 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/shrinkToFit.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/size.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/size.cpp index 8dcbf01..4fbb6e2 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/size.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/size.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/subscript.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/subscript.cpp index 8dc6fac..4ba6ff8 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDocument/subscript.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/subscript.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonDocument/swap.cpp b/third-party/ArduinoJson/extras/tests/JsonDocument/swap.cpp new file mode 100644 index 0000000..60d672f --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/JsonDocument/swap.cpp @@ -0,0 +1,27 @@ +#include + +#include +#include +#include + +using namespace std; + +TEST_CASE("std::swap") { + SECTION("DynamicJsonDocument*") { + DynamicJsonDocument *p1, *p2; + swap(p1, p2); // issue #1678 + } + + SECTION("DynamicJsonDocument") { + DynamicJsonDocument doc1(0x10), doc2(0x20); + doc1.set("hello"); + doc2.set("world"); + + swap(doc1, doc2); + + CHECK(doc1.capacity() == 0x20); + CHECK(doc1.as() == "world"); + CHECK(doc2.capacity() == 0x10); + CHECK(doc2.as() == "hello"); + } +} diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonObject/CMakeLists.txt index 6b8a9fd..9e5ac48 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonObject/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(JsonObjectTests diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/clear.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/clear.cpp index c18bc5e..da17b2c 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/clear.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/clear.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/containsKey.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/containsKey.cpp index a666f53..75991ac 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/containsKey.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/containsKey.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/copy.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/copy.cpp index 8a82675..c5514a2 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/copy.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/copy.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/createNestedArray.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/createNestedArray.cpp index 0841201..6871794 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/createNestedArray.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/createNestedArray.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/createNestedObject.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/createNestedObject.cpp index 602f1bb..47d76b2 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/createNestedObject.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/createNestedObject.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/equals.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/equals.cpp index de81f75..101c612 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/equals.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/equals.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/invalid.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/invalid.cpp index 3423c4e..199c8f0 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/invalid.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/invalid.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/isNull.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/isNull.cpp index 4ef3d2d..4440348 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/isNull.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/isNull.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/iterator.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/iterator.cpp index ee556b3..e9f2cd2 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/iterator.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/iterator.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/memoryUsage.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/memoryUsage.cpp index 197cb68..835ee4a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/memoryUsage.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/memoryUsage.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/nesting.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/nesting.cpp index 8c73cd8..7937c28 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/nesting.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/nesting.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/remove.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/remove.cpp index 14d1fd5..6a2efdb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/remove.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/remove.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/size.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/size.cpp index 47a6fee..0d82cfb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/size.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/size.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/std_string.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/std_string.cpp index 045f945..e985421 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/std_string.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/std_string.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonObject/subscript.cpp b/third-party/ArduinoJson/extras/tests/JsonObject/subscript.cpp index aa4e2a1..b579249 100644 --- a/third-party/ArduinoJson/extras/tests/JsonObject/subscript.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonObject/subscript.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonSerializer/CMakeLists.txt index 5bb2cab..ece6dbc 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(JsonSerializerTests diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp index 01a5212..05d8704 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/CustomWriter.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArray.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArray.cpp index 9f8a241..e018de7 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArray.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArray.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArrayPretty.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArrayPretty.cpp index 8e7a915..8c319fc 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArrayPretty.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonArrayPretty.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObject.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObject.cpp index a1aa931..b457c66 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObject.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObject.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObjectPretty.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObjectPretty.cpp index 3096cf8..ec4ae71 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObjectPretty.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonObjectPretty.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonVariant.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonVariant.cpp index 492f886..18d51f5 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonVariant.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/JsonVariant.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -63,6 +63,10 @@ TEST_CASE("serializeJson(JsonVariant)") { SECTION("Escape tab") { check(std::string("hello\tworld"), "\"hello\\tworld\""); } + + SECTION("NUL char") { + check(std::string("hello\0world", 11), "\"hello\\u0000world\""); + } } SECTION("SerializedValue") { diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/std_stream.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/std_stream.cpp index 6cd9a14..7452028 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/std_stream.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/std_stream.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonSerializer/std_string.cpp b/third-party/ArduinoJson/extras/tests/JsonSerializer/std_string.cpp index ab835dc..7a145da 100644 --- a/third-party/ArduinoJson/extras/tests/JsonSerializer/std_string.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonSerializer/std_string.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -45,3 +45,13 @@ TEST_CASE("serialize JsonObject to std::string") { REQUIRE("{\r\n \"key\": \"value\"\r\n}" == json); } } + +TEST_CASE("serialize an std::string containing a NUL") { + StaticJsonDocument<256> doc; + doc.set(std::string("hello\0world", 11)); + CHECK(doc.memoryUsage() == 12); + + std::string json; + serializeJson(doc, json); + CHECK("\"hello\\u0000world\"" == json); +} diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/JsonVariant/CMakeLists.txt index a06dc88..134c675 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(JsonVariantTests @@ -22,7 +22,7 @@ add_executable(JsonVariantTests set.cpp subscript.cpp types.cpp - undefined.cpp + unbound.cpp ) add_test(JsonVariant JsonVariantTests) diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/add.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/add.cpp index cfdfe94..526e914 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/add.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/add.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/as.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/as.cpp index add6b10..455b8d8 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/as.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/as.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -24,6 +24,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(0.0f == variant.as()); REQUIRE(0 == variant.as()); REQUIRE("null" == variant.as()); + REQUIRE(variant.as().isNull()); } SECTION("set(4.2)") { @@ -34,6 +35,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == "4.2"); REQUIRE(variant.as() == 4L); REQUIRE(variant.as() == 4U); + REQUIRE(variant.as().isNull()); } SECTION("set(0.0)") { @@ -41,6 +43,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == false); REQUIRE(variant.as() == 0L); + REQUIRE(variant.as().isNull()); } SECTION("set(false)") { @@ -50,6 +53,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == 0.0); REQUIRE(variant.as() == 0L); REQUIRE(variant.as() == "false"); + REQUIRE(variant.as().isNull()); } SECTION("set(true)") { @@ -59,6 +63,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == 1.0); REQUIRE(variant.as() == 1L); REQUIRE(variant.as() == "true"); + REQUIRE(variant.as().isNull()); } SECTION("set(42)") { @@ -69,6 +74,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == 42); REQUIRE(variant.as() == 42U); // issue #1601 REQUIRE(variant.as() == "42"); + REQUIRE(variant.as().isNull()); } SECTION("set(42L)") { @@ -77,6 +83,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == true); REQUIRE(variant.as() == 42.0); REQUIRE(variant.as() == "42"); + REQUIRE(variant.as().isNull()); } SECTION("set(-42L)") { @@ -84,6 +91,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == -42.0); REQUIRE(variant.as() == "-42"); + REQUIRE(variant.as().isNull()); } SECTION("set(42UL)") { @@ -92,6 +100,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == true); REQUIRE(variant.as() == 42.0); REQUIRE(variant.as() == "42"); + REQUIRE(variant.as().isNull()); } SECTION("set(0L)") { @@ -100,6 +109,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == false); REQUIRE(variant.as() == 0.0); REQUIRE(variant.as() == "0"); + REQUIRE(variant.as().isNull()); } SECTION("set(0UL)") { @@ -108,6 +118,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == false); REQUIRE(variant.as() == 0.0); REQUIRE(variant.as() == "0"); + REQUIRE(variant.as().isNull()); } SECTION("set(null)") { @@ -117,12 +128,15 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == 0.0); REQUIRE(variant.as() == 0L); REQUIRE(variant.as() == "null"); + REQUIRE(variant.as().isNull()); } SECTION("set(\"42\")") { variant.set("42"); REQUIRE(variant.as() == 42L); + REQUIRE(variant.as() == "42"); + REQUIRE(variant.as().isStatic() == true); } SECTION("set(\"hello\")") { @@ -133,6 +147,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == std::string("hello")); REQUIRE(variant.as() == std::string("hello")); REQUIRE(variant.as() == std::string("hello")); + REQUIRE(variant.as() == "hello"); } SECTION("set(std::string(\"4.2\"))") { @@ -143,6 +158,8 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == 4.2); REQUIRE(variant.as() == std::string("4.2")); REQUIRE(variant.as() == std::string("4.2")); + REQUIRE(variant.as() == "4.2"); + REQUIRE(variant.as().isStatic() == false); } SECTION("set(\"true\")") { @@ -150,6 +167,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == true); REQUIRE(variant.as() == 0); + REQUIRE(variant.as() == "true"); } SECTION("set(-1e300)") { @@ -159,6 +177,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == -1e300); REQUIRE(variant.as() < 0); REQUIRE(my::isinf(variant.as())); + REQUIRE(variant.as().isNull()); } SECTION("set(1e300)") { @@ -168,6 +187,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == 1e300); REQUIRE(variant.as() > 0); REQUIRE(my::isinf(variant.as())); + REQUIRE(variant.as().isNull()); } SECTION("set(1e-300)") { @@ -176,6 +196,7 @@ TEST_CASE("JsonVariant::as()") { REQUIRE(variant.as() == true); REQUIRE(variant.as() == 1e-300); REQUIRE(variant.as() == 0); + REQUIRE(variant.as().isNull()); } SECTION("to()") { diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/clear.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/clear.cpp index 230386d..2b40e32 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/clear.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/clear.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/compare.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/compare.cpp index 68e2e2f..63adbc2 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/compare.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/compare.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/containsKey.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/containsKey.cpp index e5d3f2a..51bf500 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/containsKey.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/containsKey.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp index 51aedc1..3c4ad6d 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/converters.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/copy.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/copy.cpp index 75c1aee..7784f0c 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/copy.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/copy.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -89,7 +89,7 @@ TEST_CASE("JsonVariant::set(JsonVariant)") { unboundVariant.set(var1); - REQUIRE(unboundVariant.isUndefined()); + REQUIRE(unboundVariant.isUnbound()); REQUIRE(unboundVariant.isNull()); } } diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/createNested.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/createNested.cpp index 76564da..34c74c4 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/createNested.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/createNested.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/is.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/is.cpp index f4fe672..6d04f0a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/is.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/is.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -11,7 +11,7 @@ TEST_CASE("JsonVariant::is()") { DynamicJsonDocument doc(4096); JsonVariant variant = doc.to(); - SECTION("undefined") { + SECTION("unbound") { variant = JsonVariant(); CHECK(variant.is() == false); @@ -22,8 +22,10 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); } SECTION("null") { @@ -35,6 +37,7 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); } @@ -50,6 +53,7 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); } @@ -65,6 +69,7 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); } @@ -85,6 +90,7 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); } SECTION("double") { @@ -100,6 +106,7 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == false); CHECK(variant.is() == false); CHECK(variant.is() == false); + CHECK(variant.is() == false); CHECK(variant.is() == false); } @@ -109,6 +116,7 @@ TEST_CASE("JsonVariant::is()") { CHECK(variant.is() == true); CHECK(variant.is() == true); CHECK(variant.is() == true); + CHECK(variant.is() == true); CHECK(variant.is() == true); CHECK(variant.is() == true); CHECK(variant.is() == false); @@ -160,7 +168,7 @@ TEST_CASE("JsonVariantConst::is()") { JsonVariant variant = doc.to(); JsonVariantConst cvariant = variant; - SECTION("undefined") { + SECTION("unbound") { cvariant = JsonVariantConst(); CHECK(cvariant.is() == false); @@ -173,6 +181,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); + CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); } @@ -186,6 +195,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); + CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); } @@ -201,6 +211,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); + CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); } @@ -216,6 +227,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); + CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); } @@ -236,6 +248,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); + CHECK(cvariant.is() == false); } SECTION("double") { @@ -251,6 +264,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); + CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); } @@ -260,6 +274,7 @@ TEST_CASE("JsonVariantConst::is()") { CHECK(cvariant.is() == true); CHECK(cvariant.is() == true); CHECK(cvariant.is() == true); + CHECK(cvariant.is() == true); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); CHECK(cvariant.is() == false); diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/isnull.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/isnull.cpp index bfd4d51..7e29039 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/isnull.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/isnull.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/memoryUsage.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/memoryUsage.cpp index 9c5c6fd..59587db 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/memoryUsage.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/memoryUsage.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -30,10 +30,12 @@ TEST_CASE("JsonVariant::memoryUsage()") { SECTION("returns size of owned string") { var.set(std::string("hello")); REQUIRE(var.memoryUsage() == 6); + REQUIRE(var.memoryUsage() == doc.memoryUsage()); } SECTION("returns size of owned raw") { var.set(serialized(std::string("hello"))); - REQUIRE(var.memoryUsage() == 5); + REQUIRE(var.memoryUsage() == 6); + REQUIRE(var.memoryUsage() == doc.memoryUsage()); } } diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp index 6fd4f92..05976c3 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/misc.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/nesting.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/nesting.cpp index 74d049b..3e936fb 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/nesting.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/nesting.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/or.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/or.cpp index 582c2d1..7d1c190 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/or.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/or.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -9,30 +9,30 @@ TEST_CASE("JsonVariant::operator|()") { DynamicJsonDocument doc(4096); JsonVariant variant = doc["value"].to(); - SECTION("undefined") { - SECTION("undefined | const char*") { + SECTION("null") { + SECTION("null | const char*") { std::string result = variant | "default"; REQUIRE(result == "default"); } - SECTION("undefined | int") { + SECTION("null | int") { int result = variant | 42; REQUIRE(result == 42); } - SECTION("undefined | bool") { + SECTION("null | bool") { bool result = variant | true; REQUIRE(result == true); } - SECTION("undefined | ElementProxy") { + SECTION("null | ElementProxy") { doc["array"][0] = 42; JsonVariantConst result = variant | doc["array"][0]; REQUIRE(result == 42); } - SECTION("undefined | MemberProxy") { + SECTION("null | MemberProxy") { doc["other"] = 42; JsonVariantConst result = variant | doc["other"]; diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/overflow.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/overflow.cpp index 8d1f8c4..ff0e3aa 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/overflow.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/overflow.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/remove.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/remove.cpp index 2c4556a..c744e19 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/remove.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/remove.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/set.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/set.cpp index afad2f6..f0bfba3 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/set.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/set.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/subscript.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/subscript.cpp index 91b6b78..9662555 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/subscript.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/subscript.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -9,7 +9,7 @@ TEST_CASE("JsonVariant::operator[]") { DynamicJsonDocument doc(4096); JsonVariant var = doc.to(); - SECTION("The JsonVariant is undefined") { + SECTION("The JsonVariant is null") { REQUIRE(0 == var.size()); REQUIRE(var["0"].isNull()); REQUIRE(var[0].isNull()); @@ -136,7 +136,7 @@ TEST_CASE("JsonVariantConst::operator[]") { JsonVariant var = doc.to(); JsonVariantConst cvar = var; - SECTION("The JsonVariant is undefined") { + SECTION("The JsonVariant is null") { REQUIRE(0 == cvar.size()); REQUIRE(cvar["0"].isNull()); REQUIRE(cvar[0].isNull()); diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/types.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/types.cpp index d2665bf..448d41a 100644 --- a/third-party/ArduinoJson/extras/tests/JsonVariant/types.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/types.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/JsonVariant/unbound.cpp b/third-party/ArduinoJson/extras/tests/JsonVariant/unbound.cpp new file mode 100644 index 0000000..8089e1c --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/JsonVariant/unbound.cpp @@ -0,0 +1,66 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#include +#include + +TEST_CASE("Unbound JsonVariant") { + JsonVariant variant; + + SECTION("as()") { + CHECK(variant.as() == false); + CHECK(variant.as() == 0); + CHECK(variant.as() == 0.0f); + CHECK(variant.as() == 0); + CHECK(variant.as() == "null"); + CHECK(variant.as().isNull()); + CHECK(variant.as().isNull()); + CHECK(variant.as().isNull()); + CHECK(variant.as().isNull()); + CHECK(variant.as().isNull()); + CHECK(variant.as().isNull()); + CHECK(variant.as().isNull()); + } + + SECTION("is()") { + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + CHECK_FALSE(variant.is()); + } + + SECTION("set()") { + CHECK_FALSE(variant.set("42")); + CHECK_FALSE(variant.set(42.0)); + CHECK_FALSE(variant.set(42L)); + CHECK_FALSE(variant.set(42U)); + CHECK_FALSE(variant.set(serialized("42"))); + CHECK_FALSE(variant.set(true)); + } + + SECTION("add()") { + CHECK_FALSE(variant.add("42")); + CHECK_FALSE(variant.add(42.0)); + CHECK_FALSE(variant.add(42L)); + CHECK_FALSE(variant.add(42U)); + CHECK_FALSE(variant.add(serialized("42"))); + CHECK_FALSE(variant.add(true)); + } + + SECTION("operator[]") { + CHECK(variant[0].isNull()); + CHECK(variant["key"].isNull()); + CHECK_FALSE(variant[0].set(1)); + CHECK_FALSE(variant["key"].set(1)); + CHECK_FALSE(variant[std::string("key")].set(1)); + } +} diff --git a/third-party/ArduinoJson/extras/tests/MemoryPool/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/MemoryPool/CMakeLists.txt index a77089c..80ba3c6 100644 --- a/third-party/ArduinoJson/extras/tests/MemoryPool/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/MemoryPool/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(MemoryPoolTests diff --git a/third-party/ArduinoJson/extras/tests/MemoryPool/StringCopier.cpp b/third-party/ArduinoJson/extras/tests/MemoryPool/StringCopier.cpp index 7d6a192..ba39cfd 100644 --- a/third-party/ArduinoJson/extras/tests/MemoryPool/StringCopier.cpp +++ b/third-party/ArduinoJson/extras/tests/MemoryPool/StringCopier.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -11,15 +11,15 @@ TEST_CASE("StringCopier") { char buffer[4096]; SECTION("Works when buffer is big enough") { - MemoryPool pool(buffer, addPadding(JSON_STRING_SIZE(6))); + MemoryPool pool(buffer, addPadding(JSON_STRING_SIZE(5))); StringCopier str(pool); str.startString(); str.append("hello"); - str.append('\0'); REQUIRE(str.isValid() == true); - REQUIRE(str.c_str() == std::string("hello")); + REQUIRE(str.str() == "hello"); + REQUIRE(pool.overflowed() == false); } SECTION("Returns null when too small") { @@ -30,6 +30,7 @@ TEST_CASE("StringCopier") { str.append("hello world!"); REQUIRE(str.isValid() == false); + REQUIRE(pool.overflowed() == true); } SECTION("Increases size of memory pool") { @@ -37,10 +38,19 @@ TEST_CASE("StringCopier") { StringCopier str(pool); str.startString(); - str.append('h'); str.save(); REQUIRE(1 == pool.size()); + REQUIRE(pool.overflowed() == false); + } + + SECTION("Works when memory pool is 0 bytes") { + MemoryPool pool(buffer, 0); + StringCopier str(pool); + + str.startString(); + REQUIRE(str.isValid() == false); + REQUIRE(pool.overflowed() == true); } } @@ -48,8 +58,7 @@ static const char* addStringToPool(MemoryPool& pool, const char* s) { StringCopier str(pool); str.startString(); str.append(s); - str.append('\0'); - return str.save(); + return str.save().c_str(); } TEST_CASE("StringCopier::save() deduplicates strings") { diff --git a/third-party/ArduinoJson/extras/tests/MemoryPool/allocVariant.cpp b/third-party/ArduinoJson/extras/tests/MemoryPool/allocVariant.cpp index 97111b3..606d6d7 100644 --- a/third-party/ArduinoJson/extras/tests/MemoryPool/allocVariant.cpp +++ b/third-party/ArduinoJson/extras/tests/MemoryPool/allocVariant.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MemoryPool/clear.cpp b/third-party/ArduinoJson/extras/tests/MemoryPool/clear.cpp index 391254d..f4ab796 100644 --- a/third-party/ArduinoJson/extras/tests/MemoryPool/clear.cpp +++ b/third-party/ArduinoJson/extras/tests/MemoryPool/clear.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MemoryPool/saveString.cpp b/third-party/ArduinoJson/extras/tests/MemoryPool/saveString.cpp index f398ea7..0c16b67 100644 --- a/third-party/ArduinoJson/extras/tests/MemoryPool/saveString.cpp +++ b/third-party/ArduinoJson/extras/tests/MemoryPool/saveString.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -12,6 +12,10 @@ static const char *saveString(MemoryPool &pool, const char *s) { return pool.saveString(adaptString(const_cast(s))); } +static const char *saveString(MemoryPool &pool, const char *s, size_t n) { + return pool.saveString(adaptString(s, n)); +} + TEST_CASE("MemoryPool::saveString()") { char buffer[32]; MemoryPool pool(buffer, 32); @@ -30,6 +34,27 @@ TEST_CASE("MemoryPool::saveString()") { REQUIRE(pool.size() == 6); } + SECTION("Deduplicates identical strings that contain NUL") { + const char *a = saveString(pool, "hello\0world", 11); + const char *b = saveString(pool, "hello\0world", 11); + REQUIRE(a == b); + REQUIRE(pool.size() == 12); + } + + SECTION("Reuse part of a string if it ends with NUL") { + const char *a = saveString(pool, "hello\0world", 11); + const char *b = saveString(pool, "hello"); + REQUIRE(a == b); + REQUIRE(pool.size() == 12); + } + + SECTION("Don't stop on first NUL") { + const char *a = saveString(pool, "hello"); + const char *b = saveString(pool, "hello\0world", 11); + REQUIRE(a != b); + REQUIRE(pool.size() == 18); + } + SECTION("Returns NULL when full") { REQUIRE(pool.capacity() == 32); diff --git a/third-party/ArduinoJson/extras/tests/MemoryPool/size.cpp b/third-party/ArduinoJson/extras/tests/MemoryPool/size.cpp index 2b36daf..47603fe 100644 --- a/third-party/ArduinoJson/extras/tests/MemoryPool/size.cpp +++ b/third-party/ArduinoJson/extras/tests/MemoryPool/size.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/Misc/CMakeLists.txt index 7aca704..114ebb7 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/Misc/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(MiscTests @@ -8,6 +8,7 @@ add_executable(MiscTests deprecated.cpp FloatParts.cpp JsonString.cpp + NoArduinoHeader.cpp printable.cpp Readers.cpp StringAdapters.cpp diff --git a/third-party/ArduinoJson/extras/tests/Misc/FloatParts.cpp b/third-party/ArduinoJson/extras/tests/Misc/FloatParts.cpp index e8f52c8..736b176 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/FloatParts.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/FloatParts.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/JsonString.cpp b/third-party/ArduinoJson/extras/tests/Misc/JsonString.cpp index eb25146..10d08d3 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/JsonString.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/JsonString.cpp @@ -1,10 +1,12 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include #include +#include + TEST_CASE("JsonString") { SECTION("Default constructor creates a null JsonString") { JsonString s; @@ -14,6 +16,23 @@ TEST_CASE("JsonString") { CHECK(s.isStatic() == true); } + SECTION("Compare null with boolean") { + JsonString s; + + CHECK(bool(s) == false); + CHECK(false == bool(s)); + CHECK(bool(s) != true); + CHECK(true != bool(s)); + } + + SECTION("Compare non-null with boolean") { + JsonString s("hello"); + CHECK(bool(s) == true); + CHECK(true == bool(s)); + CHECK(bool(s) != false); + CHECK(false != bool(s)); + } + SECTION("Compare null with null") { JsonString a, b; @@ -57,4 +76,10 @@ TEST_CASE("JsonString") { CHECK(a == b); CHECK_FALSE(a != b); } + + SECTION("std::stream") { + std::stringstream ss; + ss << JsonString("hello world!"); + CHECK(ss.str() == "hello world!"); + } } diff --git a/third-party/ArduinoJson/extras/tests/Misc/NoArduinoHeader.cpp b/third-party/ArduinoJson/extras/tests/Misc/NoArduinoHeader.cpp new file mode 100644 index 0000000..43a82b2 --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/Misc/NoArduinoHeader.cpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#define ARDUINO 1 +#define ARDUINOJSON_ENABLE_PROGMEM 0 +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 +#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 +#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 +#include + +#include + +TEST_CASE("Arduino.h") { +#ifdef ARDUINO_H_INCLUDED + FAIL("Arduino.h should not be included"); +#else + INFO("Arduino.h not included"); +#endif +} diff --git a/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp b/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp index 525fac3..e46ad1e 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/Readers.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp index 4250f90..82139ee 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/StringAdapters.cpp @@ -1,12 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_ENABLE_PROGMEM 1 #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #include "custom_string.hpp" -#include "progmem_emulation.hpp" #include "weird_strcmp.hpp" #include @@ -15,106 +14,75 @@ using namespace ARDUINOJSON_NAMESPACE; -TEST_CASE("const char*") { +TEST_CASE("ZeroTerminatedRamString") { SECTION("null") { - StringAdapter adapter(NULL); + ZeroTerminatedRamString s = adaptString(static_cast(0)); - CHECK(adapter.compare("bravo") < 0); - CHECK(adapter.compare(NULL) == 0); - - CHECK(adapter.size() == 0); + CHECK(s.isNull() == true); + CHECK(s.size() == 0); } SECTION("non-null") { - StringAdapter adapter("bravo"); - - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); + ZeroTerminatedRamString s = adaptString("bravo"); - CHECK(adapter.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); } } -TEST_CASE("const char* + size") { +TEST_CASE("SizedRamString") { SECTION("null") { - StringAdapter adapter(NULL, 10); - - CHECK(adapter.compare("bravo") < 0); - CHECK(adapter.compare(NULL) == 0); + SizedRamString s = adaptString(static_cast(0), 10); - CHECK(adapter.size() == 10); + CHECK(s.isNull() == true); } SECTION("non-null") { - StringAdapter adapter("bravo", 5); + SizedRamString s = adaptString("bravo", 5); - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); - - CHECK(adapter.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); } } -TEST_CASE("const __FlashStringHelper*") { +TEST_CASE("FlashString") { SECTION("null") { - StringAdapter adapter(NULL); - - CHECK(adapter.compare("bravo") < 0); - CHECK(adapter.compare(NULL) == 0); + FlashString s = adaptString(static_cast(0)); - CHECK(adapter.size() == 0); + CHECK(s.isNull() == true); + CHECK(s.size() == 0); } SECTION("non-null") { - StringAdapter adapter = adaptString(F("bravo")); + FlashString s = adaptString(F("bravo")); - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); - - CHECK(adapter.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); } } TEST_CASE("std::string") { - std::string str("bravo"); - StringAdapter adapter(str); - - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); + std::string orig("bravo"); + SizedRamString s = adaptString(orig); - CHECK(adapter.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); } TEST_CASE("Arduino String") { - ::String str("bravo"); - StringAdapter< ::String> adapter(str); + ::String orig("bravo"); + SizedRamString s = adaptString(orig); - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); - - CHECK(adapter.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); } TEST_CASE("custom_string") { - custom_string str("bravo"); - StringAdapter adapter(str); - - CHECK(adapter.compare(NULL) > 0); - CHECK(adapter.compare("alpha") > 0); - CHECK(adapter.compare("bravo") == 0); - CHECK(adapter.compare("charlie") < 0); + custom_string orig("bravo"); + SizedRamString s = adaptString(orig); - CHECK(adapter.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); } TEST_CASE("IsString") { @@ -142,3 +110,93 @@ TEST_CASE("IsString") { CHECK(IsString::value == true); } } + +TEST_CASE("stringCompare") { + SECTION("ZeroTerminatedRamString vs ZeroTerminatedRamString") { + CHECK(stringCompare(adaptString("bravo"), adaptString("alpha")) > 0); + CHECK(stringCompare(adaptString("bravo"), adaptString("bravo")) == 0); + CHECK(stringCompare(adaptString("bravo"), adaptString("charlie")) < 0); + } + + SECTION("ZeroTerminatedRamString vs SizedRamString") { + CHECK(stringCompare(adaptString("bravo"), adaptString("alpha?", 5)) > 0); + CHECK(stringCompare(adaptString("bravo"), adaptString("bravo?", 4)) > 0); + CHECK(stringCompare(adaptString("bravo"), adaptString("bravo?", 5)) == 0); + CHECK(stringCompare(adaptString("bravo"), adaptString("bravo?", 6)) < 0); + CHECK(stringCompare(adaptString("bravo"), adaptString("charlie?", 7)) < 0); + } + + SECTION("SizedRamString vs SizedRamString") { + // clang-format off + CHECK(stringCompare(adaptString("bravo!", 5), adaptString("alpha?", 5)) > 0); + CHECK(stringCompare(adaptString("bravo!", 5), adaptString("bravo?", 5)) == 0); + CHECK(stringCompare(adaptString("bravo!", 5), adaptString("charlie?", 7)) < 0); + + CHECK(stringCompare(adaptString("bravo!", 5), adaptString("bravo!", 4)) > 0); + CHECK(stringCompare(adaptString("bravo!", 5), adaptString("bravo!", 5)) == 0); + CHECK(stringCompare(adaptString("bravo!", 5), adaptString("bravo!", 6)) < 0); + // clang-format on + } + + SECTION("FlashString vs FlashString") { + // clang-format off + CHECK(stringCompare(adaptString(F("bravo")), adaptString(F("alpha"))) > 0); + CHECK(stringCompare(adaptString(F("bravo")), adaptString(F("bravo"))) == 0); + CHECK(stringCompare(adaptString(F("bravo")), adaptString(F("charlie"))) < 0); + // clang-format on + } + + SECTION("FlashString vs SizedRamString") { + // clang-format off + CHECK(stringCompare(adaptString(F("bravo")), adaptString("alpha?", 5)) > 0); + CHECK(stringCompare(adaptString(F("bravo")), adaptString("bravo?", 5)) == 0); + CHECK(stringCompare(adaptString(F("bravo")), adaptString("charlie?", 7)) < 0); + + CHECK(stringCompare(adaptString(F("bravo")), adaptString("bravo!", 4)) > 0); + CHECK(stringCompare(adaptString(F("bravo")), adaptString("bravo!", 5)) == 0); + CHECK(stringCompare(adaptString(F("bravo")), adaptString("bravo!", 6)) < 0); + // clang-format on + } + + SECTION("ZeroTerminatedRamString vs FlashString") { + // clang-format off + CHECK(stringCompare(adaptString("bravo"), adaptString(F("alpha?"), 5)) > 0); + CHECK(stringCompare(adaptString("bravo"), adaptString(F("bravo?"), 4)) > 0); + CHECK(stringCompare(adaptString("bravo"), adaptString(F("bravo?"), 5)) == 0); + CHECK(stringCompare(adaptString("bravo"), adaptString(F("bravo?"), 6)) < 0); + CHECK(stringCompare(adaptString("bravo"), adaptString(F("charlie?"), 7)) < 0); + // clang-format on + } +} + +TEST_CASE("stringEquals()") { + SECTION("ZeroTerminatedRamString vs ZeroTerminatedRamString") { + CHECK(stringEquals(adaptString("bravo"), adaptString("brav")) == false); + CHECK(stringEquals(adaptString("bravo"), adaptString("bravo")) == true); + CHECK(stringEquals(adaptString("bravo"), adaptString("bravo!")) == false); + } + + SECTION("ZeroTerminatedRamString vs SizedRamString") { + // clang-format off + CHECK(stringEquals(adaptString("bravo"), adaptString("bravo!", 4)) == false); + CHECK(stringEquals(adaptString("bravo"), adaptString("bravo!", 5)) == true); + CHECK(stringEquals(adaptString("bravo"), adaptString("bravo!", 6)) == false); + // clang-format on + } + + SECTION("FlashString vs SizedRamString") { + // clang-format off + CHECK(stringEquals(adaptString(F("bravo")), adaptString("bravo!", 4)) == false); + CHECK(stringEquals(adaptString(F("bravo")), adaptString("bravo!", 5)) == true); + CHECK(stringEquals(adaptString(F("bravo")), adaptString("bravo!", 6)) == false); + // clang-format on + } + + SECTION("SizedRamString vs SizedRamString") { + // clang-format off + CHECK(stringEquals(adaptString("bravo?", 5), adaptString("bravo!", 4)) == false); + CHECK(stringEquals(adaptString("bravo?", 5), adaptString("bravo!", 5)) == true); + CHECK(stringEquals(adaptString("bravo?", 5), adaptString("bravo!", 6)) == false); + // clang-format on + } +} diff --git a/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp b/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp index 0df5a5b..bdb5bdb 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/StringWriter.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 @@ -135,20 +135,6 @@ TEST_CASE("Writer") { REQUIRE("ABCD" == output); } -TEST_CASE("IsWriteableString") { - SECTION("std::string") { - REQUIRE(IsWriteableString::value == true); - } - - SECTION("custom_string") { - REQUIRE(IsWriteableString::value == true); - } - - SECTION("basic_string") { - REQUIRE(IsWriteableString >::value == false); - } -} - TEST_CASE("serializeJson(doc, String)") { StaticJsonDocument<1024> doc; doc["hello"] = "world"; diff --git a/third-party/ArduinoJson/extras/tests/Misc/TypeTraits.cpp b/third-party/ArduinoJson/extras/tests/Misc/TypeTraits.cpp index de76f4c..0b2b1ce 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/TypeTraits.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/TypeTraits.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/Utf16.cpp b/third-party/ArduinoJson/extras/tests/Misc/Utf16.cpp index 3e56647..31ab7ec 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/Utf16.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/Utf16.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/Utf8.cpp b/third-party/ArduinoJson/extras/tests/Misc/Utf8.cpp index baff622..38e839a 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/Utf8.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/Utf8.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -18,8 +18,7 @@ static void testCodepoint(uint32_t codepoint, std::string expected) { CAPTURE(codepoint); Utf8::encodeCodepoint(codepoint, str); - str.append('\0'); - REQUIRE(str.c_str() == expected); + REQUIRE(str.str().c_str() == expected); } TEST_CASE("Utf8::encodeCodepoint()") { diff --git a/third-party/ArduinoJson/extras/tests/Misc/arithmeticCompare.cpp b/third-party/ArduinoJson/extras/tests/Misc/arithmeticCompare.cpp index 57fdd57..a67943e 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/arithmeticCompare.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/arithmeticCompare.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp b/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp index e94024c..991a94e 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/conflicts.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // Include any header that might use the conflicting macros diff --git a/third-party/ArduinoJson/extras/tests/Misc/custom_string.hpp b/third-party/ArduinoJson/extras/tests/Misc/custom_string.hpp index c8f6ada..3c5b7c1 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/custom_string.hpp +++ b/third-party/ArduinoJson/extras/tests/Misc/custom_string.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/extras/tests/Misc/deprecated.cpp b/third-party/ArduinoJson/extras/tests/Misc/deprecated.cpp index 591ada8..646ca05 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/deprecated.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/deprecated.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_DEPRECATED(msg) // nothing diff --git a/third-party/ArduinoJson/extras/tests/Misc/printable.cpp b/third-party/ArduinoJson/extras/tests/Misc/printable.cpp index 27ac15e..7cec8f9 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/printable.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/printable.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -60,6 +60,7 @@ TEST_CASE("Printable") { CHECK(printable.totalBytesWritten() == 7); CHECK(doc.overflowed() == false); CHECK(doc.memoryUsage() == 8); + CHECK(doc.as().memoryUsage() == 8); } SECTION("Via Print::write(const char* size_t)") { @@ -69,6 +70,7 @@ TEST_CASE("Printable") { CHECK(printable.totalBytesWritten() == 7); CHECK(doc.overflowed() == false); CHECK(doc.memoryUsage() == 8); + CHECK(doc.as().memoryUsage() == 8); } } diff --git a/third-party/ArduinoJson/extras/tests/Misc/unsigned_char.cpp b/third-party/ArduinoJson/extras/tests/Misc/unsigned_char.cpp index acdbe93..7a5e3ee 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/unsigned_char.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/unsigned_char.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/version.cpp b/third-party/ArduinoJson/extras/tests/Misc/version.cpp index 88cc9ec..486a867 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/version.cpp +++ b/third-party/ArduinoJson/extras/tests/Misc/version.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Misc/weird_strcmp.hpp b/third-party/ArduinoJson/extras/tests/Misc/weird_strcmp.hpp index 3dbc0cf..ff755ef 100644 --- a/third-party/ArduinoJson/extras/tests/Misc/weird_strcmp.hpp +++ b/third-party/ArduinoJson/extras/tests/Misc/weird_strcmp.hpp @@ -1,5 +1,11 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + #include +#include // strcmp, strncmp + // Issue #1198: strcmp() implementation that returns a value larger than 8-bit namespace ARDUINOJSON_NAMESPACE { diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/MixedConfiguration/CMakeLists.txt index de6db8c..01d1216 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(MixedConfigurationTests @@ -16,6 +16,7 @@ add_executable(MixedConfigurationTests enable_progmem_1.cpp enable_string_deduplication_0.cpp enable_string_deduplication_1.cpp + issue1707.cpp use_double_0.cpp use_double_1.cpp ) diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_0.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_0.cpp index fd8434f..6329021 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_0.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_0.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_ENABLE_COMMENTS 0 diff --git a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_1.cpp b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_1.cpp index cc36eaf..1846292 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_1.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_comments_1.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_ENABLE_COMMENTS 1 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 1f8e8ca..9ddf7f2 100644 --- a/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/enable_progmem_1.cpp @@ -1,9 +1,7 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License -#include "progmem_emulation.hpp" - #define ARDUINOJSON_ENABLE_PROGMEM 1 #include @@ -52,6 +50,14 @@ TEST_CASE("Flash strings") { } } +TEST_CASE("parseNumber()") { // tables are in Flash + using ARDUINOJSON_NAMESPACE::parseNumber; + + CHECK(parseNumber("1") == 1.f); + CHECK(parseNumber("1.23") == 1.23f); + CHECK(parseNumber("-1.23e34") == -1.23e34f); +} + TEST_CASE("strlen_P") { CHECK(strlen_P(PSTR("")) == 0); CHECK(strlen_P(PSTR("a")) == 1); 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 2cf6a78..d9ca166 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 @@ -1,9 +1,7 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, 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 799e992..27fc18d 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 @@ -1,9 +1,7 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, 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 new file mode 100644 index 0000000..befdee5 --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/MixedConfiguration/issue1707.cpp @@ -0,0 +1,17 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#define ARDUINO +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) + +#include + +#include + +TEST_CASE("Issue1707") { + StaticJsonDocument<128> doc; + + DeserializationError err = deserializeJson(doc, F("{\"hello\":12}")); + REQUIRE(err == DeserializationError::Ok); +} diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/CMakeLists.txt index 3ca4d0b..f243527 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(MsgPackDeserializerTests diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeArray.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeArray.cpp index 877a707..4540bd0 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeArray.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeArray.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeObject.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeObject.cpp index 37e1e67..7a0e7b8 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeObject.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeObject.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeStaticVariant.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeStaticVariant.cpp index 415bb4d..2d4093c 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeStaticVariant.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeStaticVariant.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeVariant.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeVariant.cpp index f242231..be20b9c 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeVariant.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/deserializeVariant.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/doubleToFloat.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/doubleToFloat.cpp index 9fd938c..b0470de 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/doubleToFloat.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/doubleToFloat.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/filter.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/filter.cpp index 5687bd0..583c42f 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/filter.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/filter.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -1027,6 +1027,20 @@ TEST_CASE("deserializeMsgPack() filter") { } } +TEST_CASE("Zero-copy mode") { // issue #1697 + char input[] = "\x82\xA7include\x01\xA6ignore\x02"; + + StaticJsonDocument<256> filter; + filter["include"] = true; + + StaticJsonDocument<256> doc; + DeserializationError err = + deserializeMsgPack(doc, input, 18, DeserializationOption::Filter(filter)); + + CHECK(err == DeserializationError::Ok); + CHECK(doc.as() == "{\"include\":1}"); +} + TEST_CASE("Overloads") { StaticJsonDocument<256> doc; StaticJsonDocument<256> filter; diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/incompleteInput.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/incompleteInput.cpp index 488f889..029facf 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/incompleteInput.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/incompleteInput.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/input_types.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/input_types.cpp index 952a840..af9b693 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/input_types.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/input_types.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/misc.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/misc.cpp index 41b7331..0717171 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/misc.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/misc.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/nestingLimit.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/nestingLimit.cpp index bb9bb51..6005f55 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/nestingLimit.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/nestingLimit.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/notSupported.cpp b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/notSupported.cpp index bf87e93..5e204cd 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/notSupported.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackDeserializer/notSupported.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/CMakeLists.txt index 1f8e20e..9a7721e 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(MsgPackSerializerTests diff --git a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/destination_types.cpp b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/destination_types.cpp index 7923800..ae58063 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/destination_types.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/destination_types.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/measure.cpp b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/measure.cpp index fb2ec76..d49bcd9 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/measure.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/measure.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeArray.cpp b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeArray.cpp index a77041b..74de8f1 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeArray.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeArray.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeObject.cpp b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeObject.cpp index 974ea63..e5c167a 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeObject.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeObject.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeVariant.cpp b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeVariant.cpp index 9b61f53..7817946 100644 --- a/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeVariant.cpp +++ b/third-party/ArduinoJson/extras/tests/MsgPackSerializer/serializeVariant.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include @@ -31,7 +31,7 @@ static void checkVariant(T value, const std::string& expected) { } TEST_CASE("serialize MsgPack value") { - SECTION("undefined") { + SECTION("unbound") { checkVariant(JsonVariant(), "\xC0"); // we represent undefined as nil } diff --git a/third-party/ArduinoJson/extras/tests/Numbers/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/Numbers/CMakeLists.txt index 7d11034..9bcf334 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/Numbers/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(NumbersTests diff --git a/third-party/ArduinoJson/extras/tests/Numbers/convertNumber.cpp b/third-party/ArduinoJson/extras/tests/Numbers/convertNumber.cpp index 0fdc20d..1c36aa0 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/convertNumber.cpp +++ b/third-party/ArduinoJson/extras/tests/Numbers/convertNumber.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Numbers/parseDouble.cpp b/third-party/ArduinoJson/extras/tests/Numbers/parseDouble.cpp index aae2888..1ce9a02 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/parseDouble.cpp +++ b/third-party/ArduinoJson/extras/tests/Numbers/parseDouble.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_USE_DOUBLE 1 diff --git a/third-party/ArduinoJson/extras/tests/Numbers/parseFloat.cpp b/third-party/ArduinoJson/extras/tests/Numbers/parseFloat.cpp index f05ab7d..ec69cab 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/parseFloat.cpp +++ b/third-party/ArduinoJson/extras/tests/Numbers/parseFloat.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #define ARDUINOJSON_USE_DOUBLE 0 diff --git a/third-party/ArduinoJson/extras/tests/Numbers/parseInteger.cpp b/third-party/ArduinoJson/extras/tests/Numbers/parseInteger.cpp index a5a9039..aae66e8 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/parseInteger.cpp +++ b/third-party/ArduinoJson/extras/tests/Numbers/parseInteger.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp b/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp index 91c98e3..eb52f3a 100644 --- a/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp +++ b/third-party/ArduinoJson/extras/tests/Numbers/parseNumber.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/TextFormatter/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/TextFormatter/CMakeLists.txt index edbb965..57a3f85 100644 --- a/third-party/ArduinoJson/extras/tests/TextFormatter/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/TextFormatter/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License add_executable(TextFormatterTests diff --git a/third-party/ArduinoJson/extras/tests/TextFormatter/writeFloat.cpp b/third-party/ArduinoJson/extras/tests/TextFormatter/writeFloat.cpp index e908fc4..87eef3d 100644 --- a/third-party/ArduinoJson/extras/tests/TextFormatter/writeFloat.cpp +++ b/third-party/ArduinoJson/extras/tests/TextFormatter/writeFloat.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/TextFormatter/writeInteger.cpp b/third-party/ArduinoJson/extras/tests/TextFormatter/writeInteger.cpp index 37fa446..cc29fc0 100644 --- a/third-party/ArduinoJson/extras/tests/TextFormatter/writeInteger.cpp +++ b/third-party/ArduinoJson/extras/tests/TextFormatter/writeInteger.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/TextFormatter/writeString.cpp b/third-party/ArduinoJson/extras/tests/TextFormatter/writeString.cpp index eccc4b4..67b12b5 100644 --- a/third-party/ArduinoJson/extras/tests/TextFormatter/writeString.cpp +++ b/third-party/ArduinoJson/extras/tests/TextFormatter/writeString.cpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #include diff --git a/third-party/ArduinoJson/extras/tests/catch/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/catch/CMakeLists.txt index 55c4522..776a07a 100644 --- a/third-party/ArduinoJson/extras/tests/catch/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/catch/CMakeLists.txt @@ -2,6 +2,9 @@ # Copyright Benoit Blanchon 2014-2021 # MIT License +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED OFF) + add_library(catch catch.hpp catch.cpp diff --git a/third-party/ArduinoJson/library.json b/third-party/ArduinoJson/library.json index ec44d20..a982484 100644 --- a/third-party/ArduinoJson/library.json +++ b/third-party/ArduinoJson/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/bblanchon/ArduinoJson.git" }, - "version": "6.18.5", + "version": "6.19.2", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" diff --git a/third-party/ArduinoJson/library.properties b/third-party/ArduinoJson/library.properties index f0002ec..fa4790c 100644 --- a/third-party/ArduinoJson/library.properties +++ b/third-party/ArduinoJson/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=6.18.5 +version=6.19.2 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. diff --git a/third-party/ArduinoJson/src/ArduinoJson.h b/third-party/ArduinoJson/src/ArduinoJson.h index 2984c23..f79212d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson.h +++ b/third-party/ArduinoJson/src/ArduinoJson.h @@ -1,12 +1,12 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #ifdef __cplusplus -#include "ArduinoJson.hpp" +# include "ArduinoJson.hpp" using namespace ArduinoJson; diff --git a/third-party/ArduinoJson/src/ArduinoJson.hpp b/third-party/ArduinoJson/src/ArduinoJson.hpp index d16ca08..abb8dd1 100644 --- a/third-party/ArduinoJson/src/ArduinoJson.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson.hpp @@ -1,11 +1,18 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include "ArduinoJson/Configuration.hpp" +// 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 +# include +#endif + #if !ARDUINOJSON_DEBUG # ifdef __clang__ # pragma clang system_header diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp index e7cdc4c..0b4d342 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp index ae06b20..dcb4ff0 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp index fcacc6b..cde9a24 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp index 4f8d0c6..a5df7ab 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp index fd26d04..1854a8c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp index c1016eb..d54de49 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp b/third-party/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp index 619b91d..b8e87f2 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp @@ -1,133 +1,103 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include #include -#include namespace ARDUINOJSON_NAMESPACE { -// Copy a 1D array to a JsonArray +// Trivial form to stop the recursion +template +inline typename enable_if::value, bool>::type copyArray( + const T& src, VariantRef dst) { + return dst.set(src); +} + +// Copy array to a JsonArray/JsonVariant/MemberProxy/ElementProxy template -inline typename enable_if::value && - !is_base_of::value, +inline typename enable_if::value, bool>::type copyArray(T (&src)[N], const TDestination& dst) { return copyArray(src, N, dst); } -// Copy a 1D array to a JsonDocument -template -inline bool copyArray(T (&src)[N], JsonDocument& dst) { - return copyArray(src, dst.to()); -} - -// Copy a 1D array to a JsonArray +// Copy ptr+size to a JsonArray/JsonVariant/MemberProxy/ElementProxy template -inline typename enable_if::value && - !is_base_of::value, +inline typename enable_if::value, bool>::type -copyArray(T* src, size_t len, const TDestination& dst) { +copyArray(const T* src, size_t len, const TDestination& dst) { bool ok = true; for (size_t i = 0; i < len; i++) { - ok &= dst.add(src[i]); + ok &= copyArray(src[i], dst.addElement()); } return ok; } -// Copy a 1D array to a JsonDocument -template -inline bool copyArray(T* src, size_t len, JsonDocument& dst) { - return copyArray(src, len, dst.to()); +// Special case for char[] which much be treated as const char* +template +inline bool copyArray(const char* src, size_t, const TDestination& dst) { + return dst.set(src); } -// Copy a 2D array to a JsonArray -template -inline typename enable_if::value, - bool>::type -copyArray(T (&src)[N1][N2], const TDestination& dst) { - bool ok = true; - for (size_t i = 0; i < N1; i++) { - ArrayRef nestedArray = dst.createNestedArray(); - for (size_t j = 0; j < N2; j++) { - ok &= nestedArray.add(src[i][j]); - } - } - return ok; -} - -// Copy a 2D array to a JsonDocument -template -inline bool copyArray(T (&src)[N1][N2], JsonDocument& dst) { +// Copy array to a JsonDocument +template +inline bool copyArray(const T& src, JsonDocument& dst) { return copyArray(src, dst.to()); } +// Copy a ptr+size array to a JsonDocument template -class ArrayCopier1D : public Visitor { - public: - ArrayCopier1D(T* destination, size_t capacity) - : _destination(destination), _capacity(capacity) {} - - size_t visitArray(const CollectionData& array) { - size_t size = 0; - VariantSlot* slot = array.head(); - - while (slot != 0 && size < _capacity) { - _destination[size++] = - Converter::fromJson(VariantConstRef(slot->data())); - slot = slot->next(); - } - return size; - } - - private: - T* _destination; - size_t _capacity; -}; - -template -class ArrayCopier2D : public Visitor { - public: - ArrayCopier2D(T (*destination)[N1][N2]) : _destination(destination) {} - - void visitArray(const CollectionData& array) { - VariantSlot* slot = array.head(); - size_t n = 0; - while (slot != 0 && n < N1) { - ArrayCopier1D copier((*_destination)[n++], N2); - variantAccept(slot->data(), copier); - slot = slot->next(); - } - } - - private: - T (*_destination)[N1][N2]; - size_t _capacity1, _capacity2; -}; +inline bool copyArray(const T* src, size_t len, JsonDocument& dst) { + return copyArray(src, len, dst.to()); +} -// Copy a JsonArray to a 1D array -template +// Trivial case form to stop the recursion +template inline typename enable_if::value, size_t>::type copyArray( - const TSource& src, T (&dst)[N]) { + VariantConstRef src, T& dst) { + dst = src.as(); + return 1; +} + +// Copy a JsonArray to array +template +inline size_t copyArray(ArrayConstRef src, T (&dst)[N]) { return copyArray(src, dst, N); } -// Copy a JsonArray to a 1D array -template -inline size_t copyArray(const TSource& src, T* dst, size_t len) { - ArrayCopier1D copier(dst, len); +// Copy a JsonArray to ptr+size +template +inline size_t copyArray(ArrayConstRef src, T* dst, size_t len) { + size_t i = 0; + for (ArrayConstRef::iterator it = src.begin(); it != src.end() && i < len; + ++it) + copyArray(*it, dst[i++]); + return i; +} - return src.accept(copier); +// Special case for char[] which must be treated as a string +template +inline size_t copyArray(VariantConstRef src, char (&dst)[N]) { + String s = src; + size_t len = N - 1; + if (len > s.size()) + len = s.size(); + memcpy(dst, s.c_str(), len); + dst[len] = 0; + return 1; } -// Copy a JsonArray to a 2D array -template -inline void copyArray(const TSource& src, T (&dst)[N1][N2]) { - ArrayCopier2D copier(&dst); - src.accept(copier); +// Copy a JsonDocument to an array +// (JsonDocument doesn't implicitly convert to JsonArrayConst) +template +inline typename enable_if::value && + is_base_of::value, + size_t>::type +copyArray(const TSource& src, T& dst) { + return copyArray(src.template as(), dst); } } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp index d2bca45..74b6054 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -40,14 +40,15 @@ class CollectionData { // Object only - template - VariantData *addMember(TAdaptedString key, MemoryPool *pool); + template + VariantData *addMember(TAdaptedString key, MemoryPool *pool, TStoragePolicy); template VariantData *getMember(TAdaptedString key) const; - template - VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool); + template + VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool, + TStoragePolicy); template void removeMember(TAdaptedString key) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp index f814bcd..60f5cb1 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp @@ -1,10 +1,12 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include +#include +#include #include namespace ARDUINOJSON_NAMESPACE { @@ -34,11 +36,12 @@ inline VariantData* CollectionData::addElement(MemoryPool* pool) { return slotData(addSlot(pool)); } -template +template inline VariantData* CollectionData::addMember(TAdaptedString key, - MemoryPool* pool) { + MemoryPool* pool, + TStoragePolicy storage) { VariantSlot* slot = addSlot(pool); - if (!slotSetKey(slot, key, pool)) { + if (!slotSetKey(slot, key, pool, storage)) { removeSlot(slot); return 0; } @@ -61,10 +64,8 @@ inline bool CollectionData::copyFrom(const CollectionData& src, for (VariantSlot* s = src._head; s; s = s->next()) { VariantData* var; if (s->key() != 0) { - if (s->ownsKey()) - var = addMember(adaptString(const_cast(s->key())), pool); - else - var = addMember(adaptString(s->key()), pool); + String key(s->key(), !s->ownsKey()); + var = addMember(adaptString(key), pool, getStringStoragePolicy(key)); } else { var = addElement(pool); } @@ -105,9 +106,11 @@ inline bool CollectionData::equalsArray(const CollectionData& other) const { template inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { + if (key.isNull()) + return 0; VariantSlot* slot = _head; while (slot) { - if (key.compare(slot->key()) == 0) + if (stringEquals(key, adaptString(slot->key()))) break; slot = slot->next(); } @@ -137,9 +140,9 @@ inline VariantData* CollectionData::getMember(TAdaptedString key) const { return slot ? slot->data() : 0; } -template -inline VariantData* CollectionData::getOrAddMember(TAdaptedString key, - MemoryPool* pool) { +template +inline VariantData* CollectionData::getOrAddMember( + TAdaptedString key, MemoryPool* pool, TStoragePolicy storage_policy) { // ignore null key if (key.isNull()) return 0; @@ -149,7 +152,7 @@ inline VariantData* CollectionData::getOrAddMember(TAdaptedString key, if (slot) return slot->data(); - return addMember(key, pool); + return addMember(key, pool, storage_policy); } inline VariantData* CollectionData::getElement(size_t index) const { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp b/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp index 8e2c7d8..ed5687a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Configuration.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -26,135 +26,96 @@ # define ARDUINOJSON_HAS_INT64 0 #endif -// Small or big machine? -#ifndef ARDUINOJSON_EMBEDDED_MODE -# if defined(ARDUINO) /* Arduino*/ \ - || defined(__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench */ \ - || defined(__XC) /* MPLAB XC compiler */ \ - || defined(__ARMCC_VERSION) /* Keil ARM Compiler */ \ - || defined(__NIOS2__) /* Altera Nios II EDS */ \ - || defined(__AVR) /* Atmel AVR8/GNU C Compiler */ -# define ARDUINOJSON_EMBEDDED_MODE 1 -# else -# define ARDUINOJSON_EMBEDDED_MODE 0 -# endif -#endif - -// Auto enable std::stream if the right headers are here and no conflicting -// macro is defined -#if !defined(ARDUINOJSON_ENABLE_STD_STREAM) && defined(__has_include) -# if __has_include() && \ +// Support std::istream and std::ostream +#ifndef ARDUINOJSON_ENABLE_STD_STREAM +# ifdef __has_include +# if __has_include() && \ __has_include() && \ !defined(min) && \ !defined(max) -# define ARDUINOJSON_ENABLE_STD_STREAM 1 +# define ARDUINOJSON_ENABLE_STD_STREAM 1 +# else +# define ARDUINOJSON_ENABLE_STD_STREAM 0 +# endif # else -# define ARDUINOJSON_ENABLE_STD_STREAM 0 +# ifdef ARDUINO +# define ARDUINOJSON_ENABLE_STD_STREAM 0 +# else +# define ARDUINOJSON_ENABLE_STD_STREAM 1 +# endif # endif #endif -// Auto enable std::string if the right header is here and no conflicting -// macro is defined -#if !defined(ARDUINOJSON_ENABLE_STD_STRING) && defined(__has_include) -# if __has_include() && !defined(min) && !defined(max) -# define ARDUINOJSON_ENABLE_STD_STRING 1 +// Support std::string +#ifndef ARDUINOJSON_ENABLE_STD_STRING +# ifdef __has_include +# if __has_include() && !defined(min) && !defined(max) +# define ARDUINOJSON_ENABLE_STD_STRING 1 +# else +# define ARDUINOJSON_ENABLE_STD_STRING 0 +# endif # else -# define ARDUINOJSON_ENABLE_STD_STRING 0 +# ifdef ARDUINO +# define ARDUINOJSON_ENABLE_STD_STRING 0 +# else +# define ARDUINOJSON_ENABLE_STD_STRING 1 +# endif # endif #endif +// Support for std::string_view #ifndef ARDUINOJSON_ENABLE_STRING_VIEW # ifdef __has_include # if __has_include() && __cplusplus >= 201703L # define ARDUINOJSON_ENABLE_STRING_VIEW 1 +# else +# define ARDUINOJSON_ENABLE_STRING_VIEW 0 # endif +# else +# define ARDUINOJSON_ENABLE_STRING_VIEW 0 # endif #endif -#ifndef ARDUINOJSON_ENABLE_STRING_VIEW -# define ARDUINOJSON_ENABLE_STRING_VIEW 0 -#endif - -#if ARDUINOJSON_EMBEDDED_MODE - -// Store floats by default to reduce the memory usage (issue #134) -# ifndef ARDUINOJSON_USE_DOUBLE -# define ARDUINOJSON_USE_DOUBLE 0 -# endif - -// Store longs by default, because they usually match the size of a float. -# ifndef ARDUINOJSON_USE_LONG_LONG -# define ARDUINOJSON_USE_LONG_LONG 0 -# endif -// Embedded systems usually don't have std::string -# ifndef ARDUINOJSON_ENABLE_STD_STRING -# define ARDUINOJSON_ENABLE_STD_STRING 0 -# endif +// Store floating-point values with float (0) or double (1) +#ifndef ARDUINOJSON_USE_DOUBLE +# define ARDUINOJSON_USE_DOUBLE 1 +#endif -// Embedded systems usually don't have std::stream -# ifndef ARDUINOJSON_ENABLE_STD_STREAM -# define ARDUINOJSON_ENABLE_STD_STREAM 0 +// Store integral values with long (0) or long long (1) +#ifndef ARDUINOJSON_USE_LONG_LONG +# if ARDUINOJSON_HAS_LONG_LONG && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ >= 4 || \ + defined(_MSC_VER) +# define ARDUINOJSON_USE_LONG_LONG 1 # endif +#endif +#ifndef ARDUINOJSON_USE_LONG_LONG +# define ARDUINOJSON_USE_LONG_LONG 0 +#endif // Limit nesting as the stack is likely to be small -# ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT -# define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 -# endif +#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT +# 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 +#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 -# ifndef ARDUINOJSON_USE_DOUBLE -# define ARDUINOJSON_USE_DOUBLE 1 -# endif - -// Use long long when available -# ifndef ARDUINOJSON_USE_LONG_LONG -# if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64 -# define ARDUINOJSON_USE_LONG_LONG 1 -# else -# define ARDUINOJSON_USE_LONG_LONG 0 -# endif -# endif - -// On a computer, we can use std::string -# ifndef ARDUINOJSON_ENABLE_STD_STRING -# define ARDUINOJSON_ENABLE_STD_STRING 1 -# endif - -// On a computer, we can assume std::stream -# ifndef ARDUINOJSON_ENABLE_STD_STREAM -# define ARDUINOJSON_ENABLE_STD_STREAM 1 -# endif - -// On a computer, the stack is large so we can increase nesting limit -# ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT -# 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 1 +# elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ >= 8 || \ + defined(_WIN64) && _WIN64 +// Address space == 64-bit => max 2147483647 values # define ARDUINOJSON_SLOT_OFFSET_SIZE 4 +# else +// Address space == 32-bit => max 32767 values +# define ARDUINOJSON_SLOT_OFFSET_SIZE 2 # endif - -#endif // ARDUINOJSON_EMBEDDED_MODE +#endif #ifdef ARDUINO -# include - // Enable support for Arduino's String class # ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING # define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 @@ -170,6 +131,11 @@ # define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 # endif +// Enable support for PROGMEM +# ifndef ARDUINOJSON_ENABLE_PROGMEM +# define ARDUINOJSON_ENABLE_PROGMEM 1 +# endif + #else // ARDUINO // Disable support for Arduino's String class @@ -187,16 +153,12 @@ # define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 # endif -#endif // ARDUINO - -#ifndef ARDUINOJSON_ENABLE_PROGMEM -# if defined(PROGMEM) && defined(pgm_read_byte) && defined(pgm_read_dword) && \ - defined(pgm_read_ptr) && defined(pgm_read_float) -# define ARDUINOJSON_ENABLE_PROGMEM 1 -# else +// Disable support for PROGMEM +# ifndef ARDUINOJSON_ENABLE_PROGMEM # define ARDUINOJSON_ENABLE_PROGMEM 0 # endif -#endif + +#endif // ARDUINO // Convert unicode escape sequence (\u0123) to UTF-8 #ifndef ARDUINOJSON_DECODE_UNICODE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp index 11ec7df..96b3a17 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp @@ -1,9 +1,10 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include #include #include #include @@ -14,11 +15,7 @@ namespace ARDUINOJSON_NAMESPACE { -class DeserializationError { - // safe bool idiom - typedef void (DeserializationError::*bool_type)() const; - void safeBoolHelper() const {} - +class DeserializationError : public SafeBoolIdom { public: enum Code { Ok, @@ -58,19 +55,7 @@ class DeserializationError { // Behaves like a bool operator bool_type() const { - return _code != Ok ? &DeserializationError::safeBoolHelper : 0; - } - friend bool operator==(bool value, const DeserializationError& err) { - return static_cast(err) == value; - } - friend bool operator==(const DeserializationError& err, bool value) { - return static_cast(err) == value; - } - friend bool operator!=(bool value, const DeserializationError& err) { - return static_cast(err) != value; - } - friend bool operator!=(const DeserializationError& err, bool value) { - return static_cast(err) != value; + return _code != Ok ? safe_true() : safe_false(); } // Returns internal enum, useful for switch statement diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp index de94b94..8a091bb 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp index 06964b4..af5724d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp index 20f77af..4e1958c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp index 724638f..179e376 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp index 71571d4..652409a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp @@ -1,9 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include + namespace ARDUINOJSON_NAMESPACE { template diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp index 7eca134..c48248c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp @@ -1,9 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include + namespace ARDUINOJSON_NAMESPACE { template <> diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp index 37c3c31..1c470c0 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp index 67cf682..1181297 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp index eebaa2c..c92f793 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp index e56e262..569fa2c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp index 2329542..805cbb0 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp b/third-party/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp index 5c85d8a..1b02c86 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Document/BasicJsonDocument.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -14,7 +14,6 @@ template class AllocatorOwner { public: AllocatorOwner() {} - AllocatorOwner(const AllocatorOwner& src) : _allocator(src._allocator) {} AllocatorOwner(TAllocator a) : _allocator(a) {} void* allocate(size_t size) { @@ -98,7 +97,9 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument { template BasicJsonDocument& operator=(const T& src) { - reallocPoolIfTooSmall(src.memoryUsage()); + size_t requiredSize = src.memoryUsage(); + if (requiredSize > capacity()) + reallocPool(requiredSize); set(src); return *this; } @@ -136,8 +137,9 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument { return MemoryPool(reinterpret_cast(this->allocate(capa)), capa); } - void reallocPoolIfTooSmall(size_t requiredSize) { - if (requiredSize <= capacity()) + void reallocPool(size_t requiredSize) { + size_t capa = addPadding(requiredSize); + if (capa == _pool.capacity()) return; freePool(); replacePool(allocPool(addPadding(requiredSize))); @@ -148,7 +150,7 @@ class BasicJsonDocument : AllocatorOwner, public JsonDocument { } void copyAssignFrom(const JsonDocument& src) { - reallocPoolIfTooSmall(src.capacity()); + reallocPool(src.capacity()); set(src); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Document/DynamicJsonDocument.hpp b/third-party/ArduinoJson/src/ArduinoJson/Document/DynamicJsonDocument.hpp index de6f411..514fe3a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Document/DynamicJsonDocument.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Document/DynamicJsonDocument.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp b/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp index d81853c..90e22e7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -138,14 +139,14 @@ class JsonDocument : public Visitable { // containsKey(const __FlashStringHelper*) const template bool containsKey(TChar* key) const { - return !getMember(key).isUndefined(); + return !getMember(key).isUnbound(); } // containsKey(const std::string&) const // containsKey(const String&) const template bool containsKey(const TString& key) const { - return !getMember(key).isUndefined(); + return !getMember(key).isUnbound(); } // operator[](const std::string&) @@ -244,14 +245,18 @@ class JsonDocument : public Visitable { // getOrAddMember(const __FlashStringHelper*) template FORCE_INLINE VariantRef getOrAddMember(TChar* key) { - return VariantRef(&_pool, _data.getOrAddMember(adaptString(key), &_pool)); + return VariantRef(&_pool, + _data.getOrAddMember(adaptString(key), &_pool, + getStringStoragePolicy(key))); } // getOrAddMember(const std::string&) // getOrAddMember(const String&) template FORCE_INLINE VariantRef getOrAddMember(const TString& key) { - return VariantRef(&_pool, _data.getOrAddMember(adaptString(key), &_pool)); + return VariantRef(&_pool, + _data.getOrAddMember(adaptString(key), &_pool, + getStringStoragePolicy(key))); } FORCE_INLINE VariantRef addElement() { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp b/third-party/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp index fbbadd4..557c999 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Document/StaticJsonDocument.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -33,13 +33,13 @@ class StaticJsonDocument : public JsonDocument { set(src); } - StaticJsonDocument operator=(const StaticJsonDocument& src) { + StaticJsonDocument& operator=(const StaticJsonDocument& src) { set(src); return *this; } template - StaticJsonDocument operator=(const T& src) { + StaticJsonDocument& operator=(const T& src) { set(src); return *this; } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/EscapeSequence.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/EscapeSequence.hpp index 811e825..c21a58e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/EscapeSequence.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/EscapeSequence.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp index 1a07be8..3d51717 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/JsonDeserializer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -231,12 +231,12 @@ class JsonDeserializer { return false; } - const char *key = _stringStorage.c_str(); + String key = _stringStorage.str(); - TFilter memberFilter = filter[key]; + TFilter memberFilter = filter[key.c_str()]; if (memberFilter.allow()) { - VariantData *variant = object.getMember(adaptString(key)); + VariantData *variant = object.getMember(adaptString(key.c_str())); if (!variant) { // Save key in memory pool. // This MUST be done before adding the slot. @@ -249,7 +249,7 @@ class JsonDeserializer { return false; } - slot->setKey(key, typename TStringStorage::storage_policy()); + slot->setKey(key); variant = slot->data(); } @@ -345,8 +345,7 @@ class JsonDeserializer { _stringStorage.startString(); if (!parseQuotedString()) return false; - const char *value = _stringStorage.save(); - variant.setStringPointer(value, typename TStringStorage::storage_policy()); + variant.setString(_stringStorage.save()); return true; } @@ -402,8 +401,6 @@ class JsonDeserializer { _stringStorage.append(c); } - _stringStorage.append('\0'); - if (!_stringStorage.isValid()) { _error = DeserializationError::NoMemory; return false; @@ -427,8 +424,6 @@ class JsonDeserializer { return false; } - _stringStorage.append('\0'); - if (!_stringStorage.isValid()) { _error = DeserializationError::NoMemory; return false; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp index 5cb9aa2..db5803c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -8,6 +8,7 @@ #include #include #include +#include namespace ARDUINOJSON_NAMESPACE { @@ -68,6 +69,11 @@ class JsonSerializer : public Visitor { return bytesWritten(); } + size_t visitString(const char *value, size_t n) { + _formatter.writeString(value, n); + return bytesWritten(); + } + size_t visitRawJson(const char *data, size_t n) { _formatter.writeRaw(data, n); return bytesWritten(); diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/Latch.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/Latch.hpp index 70866d6..c422fef 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/Latch.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/Latch.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp index dbb0c17..cbd6654 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp index 7795671..26754d8 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -41,13 +41,22 @@ class TextFormatter { writeRaw('\"'); } + void writeString(const char *value, size_t n) { + ARDUINOJSON_ASSERT(value != NULL); + writeRaw('\"'); + while (n--) writeChar(*value++); + writeRaw('\"'); + } + void writeChar(char c) { char specialChar = EscapeSequence::escapeChar(c); if (specialChar) { writeRaw('\\'); writeRaw(specialChar); - } else { + } else if (c) { writeRaw(c); + } else { + writeRaw("\\u0000"); } } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp index e2b9010..3a22bf3 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/Utf16.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp index c8f1103..0ec23ac 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Memory/Alignment.hpp b/third-party/ArduinoJson/src/ArduinoJson/Memory/Alignment.hpp index bf16798..c505fe8 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Memory/Alignment.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Memory/Alignment.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp b/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp index 04e5b2d..3745bfd 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Memory/MemoryPool.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -60,7 +60,7 @@ class MemoryPool { } template - const char* saveString(const TAdaptedString& str) { + const char* saveString(TAdaptedString str) { if (str.isNull()) return 0; @@ -74,7 +74,7 @@ class MemoryPool { char* newCopy = allocString(n + 1); if (newCopy) { - str.copyTo(newCopy, n); + stringGetChars(str, newCopy, n); newCopy[n] = 0; // force null-terminator } return newCopy; @@ -87,13 +87,14 @@ class MemoryPool { const char* saveStringFromFreeZone(size_t len) { #if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION - const char* dup = findString(adaptString(_left)); + const char* dup = findString(adaptString(_left, len)); if (dup) return dup; #endif const char* str = _left; _left += len; + *_left++ = 0; checkInvariants(); return str; } @@ -165,9 +166,10 @@ class MemoryPool { #if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION template - const char* findString(const TAdaptedString& str) { - for (char* next = _begin; next < _left; ++next) { - if (str.compare(next) == 0) + const char* findString(const TAdaptedString& str) const { + size_t n = str.size(); + for (char* next = _begin; next + n < _left; ++next) { + if (next[n] == '\0' && stringEquals(str, adaptString(next, n))) return next; // jump to next terminator diff --git a/third-party/ArduinoJson/src/ArduinoJson/Misc/SafeBoolIdiom.hpp b/third-party/ArduinoJson/src/ArduinoJson/Misc/SafeBoolIdiom.hpp new file mode 100644 index 0000000..ff4bf53 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Misc/SafeBoolIdiom.hpp @@ -0,0 +1,26 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +class SafeBoolIdom { + protected: + typedef void (T::*bool_type)() const; + void safeBoolHelper() const {} + + static bool_type safe_true() { + return &SafeBoolIdom::safeBoolHelper; + } + + static bool_type safe_false() { + return 0; + } +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp b/third-party/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp index 30173bf..217c6f3 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Misc/SerializedValue.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Misc/Visitable.hpp b/third-party/ArduinoJson/src/ArduinoJson/Misc/Visitable.hpp index f25d12f..2efced6 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Misc/Visitable.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Misc/Visitable.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp index fbeb05d..41da6f0 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -48,6 +48,11 @@ class MsgPackDeserializer { bool allowValue = filter.allowValue(); + if (allowValue) { + // callers pass a null pointer only when value must be ignored + ARDUINOJSON_ASSERT(variant != 0); + } + switch (code) { case 0xc0: // already null @@ -331,8 +336,7 @@ class MsgPackDeserializer { bool readString(VariantData *variant, size_t n) { if (!readString(n)) return false; - variant->setStringPointer(_stringStorage.save(), - typename TStringStorage::storage_policy()); + variant->setString(_stringStorage.save()); return true; } @@ -344,7 +348,6 @@ class MsgPackDeserializer { return false; _stringStorage.append(static_cast(c)); } - _stringStorage.append('\0'); if (!_stringStorage.isValid()) { _error = DeserializationError::NoMemory; return false; @@ -419,11 +422,13 @@ class MsgPackDeserializer { if (!readKey()) return false; - const char *key = _stringStorage.c_str(); - TFilter memberFilter = filter[key]; + String key = _stringStorage.str(); + TFilter memberFilter = filter[key.c_str()]; VariantData *member; if (memberFilter.allow()) { + ARDUINOJSON_ASSERT(object); + // Save key in memory pool. // This MUST be done before adding the slot. key = _stringStorage.save(); @@ -434,7 +439,7 @@ class MsgPackDeserializer { return false; } - slot->setKey(key, typename TStringStorage::storage_policy()); + slot->setKey(key); member = slot->data(); } else { diff --git a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp index b1cd872..51e929b 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -78,9 +78,11 @@ class MsgPackSerializer : public Visitor { } size_t visitString(const char* value) { - ARDUINOJSON_ASSERT(value != NULL); + return visitString(value, strlen(value)); + } - size_t n = strlen(value); + size_t visitString(const char* value, size_t n) { + ARDUINOJSON_ASSERT(value != NULL); if (n < 0x20) { writeByte(uint8_t(0xA0 + n)); diff --git a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/endianess.hpp b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/endianess.hpp index 74f7e9d..446c1cf 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/endianess.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/endianess.hpp @@ -1,29 +1,34 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include -#include namespace ARDUINOJSON_NAMESPACE { #if ARDUINOJSON_LITTLE_ENDIAN +inline void swapBytes(uint8_t &a, uint8_t &b) { + uint8_t t(a); + a = b; + b = t; +} + inline void fixEndianess(uint8_t *p, integral_constant) { - swap(p[0], p[7]); - swap(p[1], p[6]); - swap(p[2], p[5]); - swap(p[3], p[4]); + swapBytes(p[0], p[7]); + swapBytes(p[1], p[6]); + swapBytes(p[2], p[5]); + swapBytes(p[3], p[4]); } inline void fixEndianess(uint8_t *p, integral_constant) { - swap(p[0], p[3]); - swap(p[1], p[2]); + swapBytes(p[0], p[3]); + swapBytes(p[1], p[2]); } inline void fixEndianess(uint8_t *p, integral_constant) { - swap(p[0], p[1]); + swapBytes(p[0], p[1]); } inline void fixEndianess(uint8_t *, integral_constant) {} diff --git a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/ieee754.hpp b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/ieee754.hpp index 016d533..16f380a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/MsgPack/ieee754.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/MsgPack/ieee754.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Namespace.hpp b/third-party/ArduinoJson/src/ArduinoJson/Namespace.hpp index 26def8a..ac4004e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Namespace.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Namespace.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/Float.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/Float.hpp index bbaca04..4c6c0f7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/Float.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/Float.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp index 4e53add..2f28ff7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp index 60b1dfd..0af77f3 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -158,24 +158,42 @@ struct FloatTraits { } static T positiveBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( - T, factors, - ARDUINOJSON_EXPAND6({1e1f, 1e2f, 1e4f, 1e8f, 1e16f, 1e32f})); - return ARDUINOJSON_READ_STATIC_ARRAY(T, factors, 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)); } static T negativeBinaryPowerOfTen(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( - T, factors, - ARDUINOJSON_EXPAND6({1e-1f, 1e-2f, 1e-4f, 1e-8f, 1e-16f, 1e-32f})); - return ARDUINOJSON_READ_STATIC_ARRAY(T, factors, 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)); } static T negativeBinaryPowerOfTenPlusOne(int index) { - ARDUINOJSON_DEFINE_STATIC_ARRAY( - T, factors, - ARDUINOJSON_EXPAND6({1e0f, 1e-1f, 1e-3f, 1e-7f, 1e-15f, 1e-31f})); - return ARDUINOJSON_READ_STATIC_ARRAY(T, factors, 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)); } static T forge(uint32_t bits) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/Integer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/Integer.hpp index e0ed519..dbf6536 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/Integer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/Integer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/arithmeticCompare.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/arithmeticCompare.hpp index bfd41d5..6e777c0 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/arithmeticCompare.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/arithmeticCompare.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp index 3087459..87547f5 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp b/third-party/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp index cf050c7..0273d07 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp index f1463a3..e8fff4d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/MemberProxy.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectFunctions.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectFunctions.hpp index 1b46e84..0f0b7eb 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectFunctions.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectFunctions.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -40,12 +40,13 @@ void objectRemove(CollectionData *obj, TAdaptedString key) { obj->removeMember(key); } -template +template inline VariantData *objectGetOrAddMember(CollectionData *obj, - TAdaptedString key, MemoryPool *pool) { + TAdaptedString key, MemoryPool *pool, + TStoragePolicy storage_policy) { if (!obj) return 0; - return obj->getOrAddMember(key, pool); + return obj->getOrAddMember(key, pool, storage_policy); } } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectImpl.hpp index d66b61c..66793a7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectImpl.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -40,14 +40,14 @@ template template inline typename enable_if::value, bool>::type ObjectShortcuts::containsKey(const TString& key) const { - return !impl()->getMember(key).isUndefined(); + return !impl()->getMember(key).isUnbound(); } template template inline typename enable_if::value, bool>::type ObjectShortcuts::containsKey(TChar* key) const { - return !impl()->getMember(key).isUndefined(); + return !impl()->getMember(key).isUnbound(); } template diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectIterator.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectIterator.hpp index d729459..d715e40 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectIterator.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectIterator.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp index 047d9b1..6cf9c14 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectRef.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -77,7 +77,7 @@ class ObjectConstRef : public ObjectRefBase, // containsKey(const String&) const template FORCE_INLINE bool containsKey(const TString& key) const { - return !getMember(key).isUndefined(); + return !getMember(key).isUnbound(); } // containsKey(char*) const @@ -85,7 +85,7 @@ class ObjectConstRef : public ObjectRefBase, // containsKey(const __FlashStringHelper*) const template FORCE_INLINE bool containsKey(TChar* key) const { - return !getMember(key).isUndefined(); + return !getMember(key).isUnbound(); } // getMember(const std::string&) const @@ -196,7 +196,8 @@ class ObjectRef : public ObjectRefBase, template FORCE_INLINE VariantRef getOrAddMember(const TString& key) const { return VariantRef(_pool, - objectGetOrAddMember(_data, adaptString(key), _pool)); + objectGetOrAddMember(_data, adaptString(key), _pool, + getStringStoragePolicy(key))); } // getOrAddMember(char*) const @@ -205,7 +206,8 @@ class ObjectRef : public ObjectRefBase, template FORCE_INLINE VariantRef getOrAddMember(TChar* key) const { return VariantRef(_pool, - objectGetOrAddMember(_data, adaptString(key), _pool)); + objectGetOrAddMember(_data, adaptString(key), _pool, + getStringStoragePolicy(key))); } FORCE_INLINE bool operator==(ObjectRef rhs) const { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectShortcuts.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectShortcuts.hpp index 0f3409f..0d70464 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectShortcuts.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/ObjectShortcuts.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Object/Pair.hpp b/third-party/ArduinoJson/src/ArduinoJson/Object/Pair.hpp index 44fce75..e9e71eb 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Object/Pair.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Object/Pair.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/alias_cast.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/alias_cast.hpp index 8f8e277..7030b7d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/alias_cast.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/alias_cast.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/assert.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/assert.hpp index f5fa946..9b17ab4 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/assert.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/assert.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp index 8ef33af..a4a330b 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/attributes.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/ctype.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/ctype.hpp index bd7a8cc..7a957b9 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/ctype.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/ctype.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp index 066c7b8..08708d5 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/limits.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/limits.hpp index 68a2bf8..9c26b67 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/limits.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/limits.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/math.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/math.hpp index eff272a..2b77c5c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/math.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/math.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/mpl/max.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/mpl/max.hpp index 9ac47a5..e3b0911 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/mpl/max.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/mpl/max.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace.hpp index f253818..afef4ce 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace.hpp @@ -1,9 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include + #include #include #include @@ -12,7 +14,7 @@ namespace ARDUINOJSON_NAMESPACE { // Wraps a const char* so that the our functions are picked only if the // originals are missing struct pgm_p { - pgm_p(const char* p) : address(p) {} + pgm_p(const void* p) : address(reinterpret_cast(p)) {} const char* address; }; } // namespace ARDUINOJSON_NAMESPACE @@ -65,6 +67,22 @@ inline int strcmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b) { } #endif +#ifndef memcmp_P +inline int memcmp_P(const void* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) { + const uint8_t* p1 = reinterpret_cast(a); + const char* p2 = b.address; + ARDUINOJSON_ASSERT(p1 != NULL); + ARDUINOJSON_ASSERT(p2 != NULL); + while (n-- > 0) { + uint8_t v1 = *p1++; + uint8_t v2 = pgm_read_byte(p2++); + if (v1 != v2) + return v1 - v2; + } + return 0; +} +#endif + #ifndef memcpy_P inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) { uint8_t* d = reinterpret_cast(dst); @@ -77,3 +95,19 @@ inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) { return dst; } #endif + +#ifndef pgm_read_dword +inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) { + uint32_t result; + memcpy_P(&result, p.address, 4); + return result; +} +#endif + +#ifndef pgm_read_ptr +inline void* pgm_read_ptr(ARDUINOJSON_NAMESPACE::pgm_p p) { + void* result; + memcpy_P(&result, p.address, sizeof(result)); + return result; +} +#endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp index f5bbd85..d9e964b 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp @@ -1,10 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include +#include #include namespace ARDUINOJSON_NAMESPACE { @@ -14,15 +15,6 @@ typename enable_if::value, T>::type pgm_read(const void* p) { return reinterpret_cast(pgm_read_ptr(p)); } -template -typename enable_if::value && - sizeof(T) == sizeof(float), // on AVR sizeof(double) == - // sizeof(float) - T>::type -pgm_read(const void* p) { - return pgm_read_float(p); -} - template typename enable_if::value, T>::type pgm_read( const void* p) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp index 488654b..c9b97c9 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp index b070628..b2ebbf6 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -10,25 +10,21 @@ # include -# ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY -# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ +# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY +# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \ static type const name[] PROGMEM = value; # endif -# ifndef ARDUINOJSON_READ_STATIC_ARRAY -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \ - pgm_read(name + index) -# 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 -# ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY -# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ - static type const name[] = value; -# endif +# define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \ + static type const name[] = value; -# ifndef ARDUINOJSON_READ_STATIC_ARRAY -# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] -# endif +# define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index] #endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp index 24440b1..f7afcb7 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp index e42d1bb..0f2dc58 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/declval.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/declval.hpp index 8708112..4dd5ed9 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/declval.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/declval.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp index cc29b33..3eec34c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp index b53d711..f258539 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_array.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_array.hpp index ee739a7..935671d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_array.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_array.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp index 32b41cd..bb8a650 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_class.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_class.hpp index a3808f3..7722c5f 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_class.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_class.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_const.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_const.hpp index 32e758c..f66d142 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_const.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_const.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp index b3a073b..cf6888e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_enum.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_enum.hpp index 26aec1d..de6663a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_enum.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_enum.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp index fb42f05..c725eb8 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_integral.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_integral.hpp index 65918cf..fc0da04 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_integral.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_integral.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp index a249539..8a99cdb 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_same.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_same.hpp index db5da9b..956db6b 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_same.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_same.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_signed.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_signed.hpp index 3e064e3..d6c7016 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_signed.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_signed.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp index 57acff2..84b7d05 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_unsigned.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp index 4cf2d08..f7fc371 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_unsigned.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp index cb2ebde..bd2d744 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/make_void.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp index 5a19eb1..77fb438 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp index 021e0ec..64f6e10 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp index 1812850..b63d1ae 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp index c464a47..b797b51 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp index 3d89fb1..6fc4689 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp index f9a9798..e69247c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writer.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp index 5bb1ebd..4990747 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/DummyWriter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/DummyWriter.hpp index a26a1f1..430865e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/DummyWriter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/DummyWriter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/PrintWriter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/PrintWriter.hpp index 13a6491..cfac79f 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/PrintWriter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/PrintWriter.hpp @@ -1,9 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include + namespace ARDUINOJSON_NAMESPACE { template diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StaticStringWriter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StaticStringWriter.hpp index 1a4213b..4be265a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StaticStringWriter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StaticStringWriter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStreamWriter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStreamWriter.hpp index e08ba4d..e77b445 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStreamWriter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStreamWriter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp index c1f7cc0..d5e8d49 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/measure.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/measure.hpp index 6d19994..d139127 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/measure.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/measure.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp b/third-party/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp index 16d2e4e..addb428 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringCopier.hpp b/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringCopier.hpp index 80670aa..455a155 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringCopier.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringCopier.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -15,11 +15,14 @@ class StringCopier { void startString() { _pool->getFreeZone(&_ptr, &_capacity); _size = 0; + if (_capacity == 0) + _pool->markAsOverflowed(); } - const char* save() { + String save() { ARDUINOJSON_ASSERT(_ptr); - return _pool->saveStringFromFreeZone(_size); + ARDUINOJSON_ASSERT(_size < _capacity); // needs room for the terminator + return String(_pool->saveStringFromFreeZone(_size), _size, false); } void append(const char* s) { @@ -31,27 +34,26 @@ class StringCopier { } void append(char c) { - if (!_ptr) - return; - - if (_size >= _capacity) { - _ptr = 0; + if (_size + 1 < _capacity) + _ptr[_size++] = c; + else _pool->markAsOverflowed(); - return; - } - - _ptr[_size++] = c; } - bool isValid() { - return _ptr != 0; + bool isValid() const { + return !_pool->overflowed(); } - const char* c_str() { - return _ptr; + size_t size() const { + return _size; } - typedef storage_policies::store_by_copy storage_policy; + String str() const { + ARDUINOJSON_ASSERT(_ptr); + ARDUINOJSON_ASSERT(_size < _capacity); + _ptr[_size] = 0; + return String(_ptr, _size, false); + } private: MemoryPool* _pool; diff --git a/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringMover.hpp b/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringMover.hpp index f727a7d..4ed7d92 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringMover.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringMover.hpp @@ -1,11 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include -#include +#include namespace ARDUINOJSON_NAMESPACE { @@ -17,8 +17,10 @@ class StringMover { _startPtr = _writePtr; } - const char* save() const { - return _startPtr; + FORCE_INLINE String save() { + String s = str(); + _writePtr++; + return s; } void append(char c) { @@ -29,11 +31,14 @@ class StringMover { return true; } - const char* c_str() const { - return _startPtr; + String str() const { + _writePtr[0] = 0; // terminator + return String(_startPtr, size(), true); } - typedef storage_policies::store_by_address storage_policy; + size_t size() const { + return size_t(_writePtr - _startPtr); + } private: char* _writePtr; diff --git a/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringStorage.hpp b/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringStorage.hpp index 36e6326..2c85cbf 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringStorage.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/StringStorage/StringStorage.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoString.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoString.hpp new file mode 100644 index 0000000..27977a6 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoString.hpp @@ -0,0 +1,24 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +inline SizedRamString adaptString(const ::String& s) { + return SizedRamString(s.c_str(), s.length()); +} + +template <> +struct IsString< ::String> : true_type {}; + +template <> +struct IsString< ::StringSumHelper> : true_type {}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp new file mode 100644 index 0000000..048d7c1 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp @@ -0,0 +1,80 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +class FlashString { + public: + static const size_t typeSortKey = 1; + + FlashString(const __FlashStringHelper* str, size_t sz) + : _str(reinterpret_cast(str)), _size(sz) {} + + bool isNull() const { + return !_str; + } + + char operator[](size_t i) const { + ARDUINOJSON_ASSERT(_str != 0); + ARDUINOJSON_ASSERT(i <= _size); + return static_cast(pgm_read_byte(_str + i)); + } + + size_t size() const { + return _size; + } + + friend bool stringEquals(FlashString a, SizedRamString b) { + ARDUINOJSON_ASSERT(a.typeSortKey < b.typeSortKey); + ARDUINOJSON_ASSERT(!a.isNull()); + ARDUINOJSON_ASSERT(!b.isNull()); + if (a.size() != b.size()) + return false; + return ::memcmp_P(b.data(), a._str, a._size) == 0; + } + + friend int stringCompare(FlashString a, SizedRamString b) { + ARDUINOJSON_ASSERT(a.typeSortKey < b.typeSortKey); + ARDUINOJSON_ASSERT(!a.isNull()); + ARDUINOJSON_ASSERT(!b.isNull()); + size_t minsize = a.size() < b.size() ? a.size() : b.size(); + int res = ::memcmp_P(b.data(), a._str, minsize); + if (res) + return -res; + if (a.size() < b.size()) + return -1; + if (a.size() > b.size()) + return 1; + return 0; + } + + friend void stringGetChars(FlashString s, char* p, size_t n) { + ARDUINOJSON_ASSERT(s.size() <= n); + ::memcpy_P(p, s._str, n); + } + + private: + const char* _str; + size_t _size; +}; + +inline FlashString adaptString(const __FlashStringHelper* s) { + return FlashString(s, s ? strlen_P(reinterpret_cast(s)) : 0); +} + +inline FlashString adaptString(const __FlashStringHelper* s, size_t n) { + return FlashString(s, n); +} + +template <> +struct IsString : true_type {}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp new file mode 100644 index 0000000..fac729f --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +inline SizedRamString adaptString(const String& s) { + return SizedRamString(s.c_str(), s.size()); +} + +template <> +struct IsString : true_type {}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp new file mode 100644 index 0000000..1d39916 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp @@ -0,0 +1,119 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include // size_t +#include // strcmp + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +class ZeroTerminatedRamString { + public: + static const size_t typeSortKey = 3; + + ZeroTerminatedRamString(const char* str) : _str(str) {} + + bool isNull() const { + return !_str; + } + + size_t size() const { + return _str ? ::strlen(_str) : 0; + } + + char operator[](size_t i) const { + ARDUINOJSON_ASSERT(_str != 0); + ARDUINOJSON_ASSERT(i <= size()); + return _str[i]; + } + + const char* data() const { + return _str; + } + + friend int stringCompare(ZeroTerminatedRamString a, + ZeroTerminatedRamString b) { + ARDUINOJSON_ASSERT(!a.isNull()); + ARDUINOJSON_ASSERT(!b.isNull()); + return ::strcmp(a._str, b._str); + } + + friend bool stringEquals(ZeroTerminatedRamString a, + ZeroTerminatedRamString b) { + return stringCompare(a, b) == 0; + } + + protected: + const char* _str; +}; + +template <> +struct IsString : true_type {}; + +inline ZeroTerminatedRamString adaptString(const char* s) { + return ZeroTerminatedRamString(s); +} + +template <> +struct IsString : true_type {}; + +inline ZeroTerminatedRamString adaptString(const unsigned char* s) { + return adaptString(reinterpret_cast(s)); +} + +template <> +struct IsString : true_type {}; + +inline ZeroTerminatedRamString adaptString(const signed char* s) { + return adaptString(reinterpret_cast(s)); +} + +class SizedRamString { + public: + static const size_t typeSortKey = 2; + + SizedRamString(const char* str, size_t sz) : _str(str), _size(sz) {} + + bool isNull() const { + return !_str; + } + + size_t size() const { + return _size; + } + + char operator[](size_t i) const { + ARDUINOJSON_ASSERT(_str != 0); + ARDUINOJSON_ASSERT(i <= size()); + return _str[i]; + } + + const char* data() const { + return _str; + } + + protected: + const char* _str; + size_t _size; +}; + +inline SizedRamString adaptString(const char* s, size_t n) { + return SizedRamString(s, n); +} + +template +struct IsString : true_type {}; + +template +struct IsString : true_type {}; + +template +inline SizedRamString adaptString(char s[N]) { + return SizedRamString(s, strlen(s)); +} +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdString.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdString.hpp new file mode 100644 index 0000000..9802606 --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StdString.hpp @@ -0,0 +1,23 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +inline SizedRamString adaptString( + const std::basic_string& s) { + return SizedRamString(s.c_str(), s.size()); +} + +template +struct IsString > : true_type { +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringView.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringView.hpp new file mode 100644 index 0000000..2f431ac --- /dev/null +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringView.hpp @@ -0,0 +1,20 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2022, Benoit BLANCHON +// MIT License + +#pragma once + +#include + +#include + +namespace ARDUINOJSON_NAMESPACE { + +inline SizedRamString adaptString(const std::string_view& s) { + return SizedRamString(s.data(), s.size()); +} + +template <> +struct IsString : true_type {}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/IsString.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/IsString.hpp index af5a91a..077b166 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/IsString.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/IsString.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -7,12 +7,11 @@ #include namespace ARDUINOJSON_NAMESPACE { -template + +template struct IsString : false_type {}; -template -struct IsString : IsString {}; +template +struct IsString : IsString {}; -template -struct IsString : IsString {}; } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/StoragePolicy.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/StoragePolicy.hpp index df0d62b..2a01f0d 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/StoragePolicy.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/StoragePolicy.hpp @@ -1,15 +1,56 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include +#include + namespace ARDUINOJSON_NAMESPACE { -namespace storage_policies { -struct store_by_address {}; -struct store_by_copy {}; -struct decide_at_runtime {}; -} // namespace storage_policies +struct LinkStringStoragePolicy { + template + bool store(TAdaptedString str, MemoryPool *, TCallback callback) { + String storedString(str.data(), str.size(), true); + callback(storedString); + return !str.isNull(); + } +}; + +struct CopyStringStoragePolicy { + template + bool store(TAdaptedString str, MemoryPool *pool, TCallback callback); +}; + +class LinkOrCopyStringStoragePolicy : LinkStringStoragePolicy, + CopyStringStoragePolicy { + public: + LinkOrCopyStringStoragePolicy(bool link) : _link(link) {} + + template + bool store(TAdaptedString str, MemoryPool *pool, TCallback callback) { + if (_link) + return LinkStringStoragePolicy::store(str, pool, callback); + else + return CopyStringStoragePolicy::store(str, pool, callback); + } + + private: + bool _link; +}; + +template +inline CopyStringStoragePolicy getStringStoragePolicy(const T &) { + return CopyStringStoragePolicy(); +} + +inline LinkStringStoragePolicy getStringStoragePolicy(const char *) { + return LinkStringStoragePolicy(); +} + +inline LinkOrCopyStringStoragePolicy getStringStoragePolicy(const String &s) { + return LinkOrCopyStringStoragePolicy(s.isStatic()); +} } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp index fff4077..1c71c67 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/String.hpp @@ -1,16 +1,28 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once +#include + +#if ARDUINOJSON_ENABLE_STD_STREAM +# include +#endif + namespace ARDUINOJSON_NAMESPACE { -class String { +class String : public SafeBoolIdom { public: - String() : _data(0), _isStatic(true) {} + String() : _data(0), _size(0), _isStatic(true) {} + String(const char* data, bool isStaticData = true) - : _data(data), _isStatic(isStaticData) {} + : _data(data), + _size(data ? ::strlen(data) : 0), + _isStatic(isStaticData) {} + + String(const char* data, size_t sz, bool isStaticData = true) + : _data(data), _size(sz), _isStatic(isStaticData) {} const char* c_str() const { return _data; @@ -24,6 +36,15 @@ class String { return _isStatic; } + size_t size() const { + return _size; + } + + // safe bool idiom + operator bool_type() const { + return _data ? safe_true() : safe_false(); + } + friend bool operator==(String lhs, String rhs) { if (lhs._data == rhs._data) return true; @@ -44,8 +65,16 @@ class String { return strcmp(lhs._data, rhs._data) != 0; } +#if ARDUINOJSON_ENABLE_STD_STREAM + friend std::ostream& operator<<(std::ostream& lhs, const String& rhs) { + lhs.write(rhs.c_str(), static_cast(rhs.size())); + return lhs; + } +#endif + private: const char* _data; + size_t _size; bool _isStatic; }; diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp index ba763a6..0be5cd9 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/StringAdapters.hpp @@ -1,27 +1,88 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once -#include -#include -#include -#include +#include +#include +#include #if ARDUINOJSON_ENABLE_STD_STRING -# include +# include #endif #if ARDUINOJSON_ENABLE_STRING_VIEW -# include +# include #endif #if ARDUINOJSON_ENABLE_ARDUINO_STRING -# include +# include #endif #if ARDUINOJSON_ENABLE_PROGMEM -# include -# include +# include #endif + +namespace ARDUINOJSON_NAMESPACE { + +template +typename enable_if::type +stringCompare(TAdaptedString1 s1, TAdaptedString2 s2) { + ARDUINOJSON_ASSERT(!s1.isNull()); + ARDUINOJSON_ASSERT(!s2.isNull()); + size_t size1 = s1.size(); + size_t size2 = s2.size(); + size_t n = size1 < size2 ? size1 : size2; + for (size_t i = 0; i < n; i++) { + if (s1[i] != s2[i]) + return s1[i] - s2[i]; + } + if (size1 < size2) + return -1; + if (size1 > size2) + return 1; + return 0; +} + +template +typename enable_if< + (TAdaptedString1::typeSortKey > TAdaptedString2::typeSortKey), int>::type +stringCompare(TAdaptedString1 s1, TAdaptedString2 s2) { + return -stringCompare(s2, s1); +} + +template +typename enable_if::type +stringEquals(TAdaptedString1 s1, TAdaptedString2 s2) { + ARDUINOJSON_ASSERT(!s1.isNull()); + ARDUINOJSON_ASSERT(!s2.isNull()); + size_t size1 = s1.size(); + size_t size2 = s2.size(); + if (size1 != size2) + return false; + for (size_t i = 0; i < size1; i++) { + if (s1[i] != s2[i]) + return false; + } + return true; +} + +template +typename enable_if< + (TAdaptedString1::typeSortKey > TAdaptedString2::typeSortKey), bool>::type +stringEquals(TAdaptedString1 s1, TAdaptedString2 s2) { + return stringEquals(s2, s1); +} + +template +static void stringGetChars(TAdaptedString s, char* p, size_t n) { + ARDUINOJSON_ASSERT(s.size() <= n); + for (size_t i = 0; i < n; i++) { + p[i] = s[i]; + } +} + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/Converter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/Converter.hpp index 88afa52..f9ce9ab 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/Converter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/Converter.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp index e3288c8..a825760 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp @@ -1,10 +1,10 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once -#include +#include #include #include @@ -115,10 +115,29 @@ struct Converter::value>::type> { template <> struct Converter { static void toJson(const char* src, VariantRef dst) { - variantSetString(getData(dst), adaptString(src), getPool(dst)); + variantSetString(getData(dst), adaptString(src), getPool(dst), + getStringStoragePolicy(src)); } static const char* fromJson(VariantConstRef src) { + const VariantData* data = getData(src); + return data ? data->asString().c_str() : 0; + } + + static bool checkJson(VariantConstRef src) { + const VariantData* data = getData(src); + return data && data->isString(); + } +}; + +template <> +struct Converter { + static void toJson(String src, VariantRef dst) { + variantSetString(getData(dst), adaptString(src), getPool(dst), + getStringStoragePolicy(src)); + } + + static String fromJson(VariantConstRef src) { const VariantData* data = getData(src); return data ? data->asString() : 0; } @@ -134,25 +153,8 @@ inline typename enable_if::value, bool>::type convertToJson( const T& src, VariantRef dst) { VariantData* data = getData(dst); MemoryPool* pool = getPool(dst); - return variantSetString(data, adaptString(src), pool); -} - -template -inline typename enable_if::value>::type convertFromJson( - VariantConstRef src, T& dst) { - const VariantData* data = getData(src); - const char* cstr = data != 0 ? data->asString() : 0; - if (cstr) - dst = cstr; - else - serializeJson(src, dst); -} - -template -inline typename enable_if::value, bool>::type -canConvertFromJson(VariantConstRef src, const T&) { - const VariantData* data = getData(src); - return data && data->isString(); + return variantSetString(data, adaptString(src), pool, + getStringStoragePolicy(src)); } template <> @@ -174,7 +176,7 @@ struct Converter, VariantData* data = getData(dst); MemoryPool* pool = getPool(dst); if (data) - data->setOwnedRaw(src, pool); + data->storeOwnedRaw(src, pool); } }; @@ -204,10 +206,9 @@ class MemoryPoolPrint : public Print { pool->getFreeZone(&_string, &_capacity); } - const char* c_str() { - _string[_size++] = 0; - ARDUINOJSON_ASSERT(_size <= _capacity); - return _pool->saveStringFromFreeZone(_size); + String str() { + ARDUINOJSON_ASSERT(_size < _capacity); + return String(_pool->saveStringFromFreeZone(_size), _size, false); } size_t write(uint8_t c) { @@ -251,7 +252,39 @@ inline void convertToJson(const ::Printable& src, VariantRef dst) { data->setNull(); return; } - data->setStringPointer(print.c_str(), storage_policies::store_by_copy()); + data->setString(print.str()); +} + +#endif + +#if ARDUINOJSON_ENABLE_ARDUINO_STRING + +inline void convertFromJson(VariantConstRef src, ::String& dst) { + String str = src.as(); + if (str) + dst = str.c_str(); + else + serializeJson(src, dst); +} + +inline bool canConvertFromJson(VariantConstRef src, const ::String&) { + return src.is(); +} + +#endif + +#if ARDUINOJSON_ENABLE_STD_STRING + +inline void convertFromJson(VariantConstRef src, std::string& dst) { + String str = src.as(); + if (str) + dst.assign(str.c_str(), str.size()); + else + serializeJson(src, dst); +} + +inline bool canConvertFromJson(VariantConstRef src, const std::string&) { + return src.is(); } #endif @@ -259,13 +292,13 @@ inline void convertToJson(const ::Printable& src, VariantRef dst) { #if ARDUINOJSON_ENABLE_STRING_VIEW inline void convertFromJson(VariantConstRef src, std::string_view& dst) { - const char* str = src.as(); + String str = src.as(); if (str) // the standard doesn't allow passing null to the constructor - dst = std::string_view(str); + dst = std::string_view(str.c_str(), str.size()); } inline bool canConvertFromJson(VariantConstRef src, const std::string_view&) { - return src.is(); + return src.is(); } #endif diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/SlotFunctions.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/SlotFunctions.hpp index 74ac5a7..9119a46 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/SlotFunctions.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/SlotFunctions.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -9,40 +9,26 @@ namespace ARDUINOJSON_NAMESPACE { -template -inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool) { - if (!var) - return false; - return slotSetKey(var, key, pool, typename TAdaptedString::storage_policy()); -} +struct SlotKeySetter { + SlotKeySetter(VariantSlot* instance) : _instance(instance) {} -template -inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool, - storage_policies::decide_at_runtime) { - if (key.isStatic()) { - return slotSetKey(var, key, pool, storage_policies::store_by_address()); - } else { - return slotSetKey(var, key, pool, storage_policies::store_by_copy()); + template + void operator()(TStoredString s) { + if (!s) + return; + ARDUINOJSON_ASSERT(_instance != 0); + _instance->setKey(s); } -} -template -inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool*, - storage_policies::store_by_address) { - ARDUINOJSON_ASSERT(var); - var->setKey(key.data(), storage_policies::store_by_address()); - return true; -} + VariantSlot* _instance; +}; -template +template inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool, - storage_policies::store_by_copy) { - const char* dup = pool->saveString(key); - if (!dup) + TStoragePolicy storage) { + if (!var) return false; - ARDUINOJSON_ASSERT(var); - var->setKey(dup, storage_policies::store_by_copy()); - return true; + return storage.store(key, pool, SlotKeySetter(var)); } inline size_t slotSize(const VariantSlot* var) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp index 4e0471a..a71f3e0 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace ARDUINOJSON_NAMESPACE { @@ -23,12 +23,12 @@ struct Comparer; template struct Comparer::value>::type> : ComparerBase { - T rhs; + T rhs; // TODO: store adapted string? explicit Comparer(T value) : rhs(value) {} - CompareResult visitString(const char *lhs) { - int i = adaptString(rhs).compare(lhs); + CompareResult visitString(const char *lhs, size_t n) { + int i = stringCompare(adaptString(rhs), adaptString(lhs, n)); if (i < 0) return COMPARE_RESULT_GREATER; else if (i > 0) @@ -150,7 +150,7 @@ struct Comparer::value>::type> return accept(comparer); } - CompareResult visitString(const char *lhs) { + CompareResult visitString(const char *lhs, size_t) { Comparer comparer(lhs); return accept(comparer); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantContent.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantContent.hpp index 2952611..dbe833e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantContent.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantContent.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -49,10 +49,9 @@ union VariantContent { UInt asUnsignedInteger; Integer asSignedInteger; CollectionData asCollection; - const char *asString; struct { const char *data; size_t size; - } asRaw; + } asString; }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp index 388b7e2..6f80763 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -50,11 +51,13 @@ class VariantData { case VALUE_IS_LINKED_STRING: case VALUE_IS_OWNED_STRING: - return visitor.visitString(_content.asString); + return visitor.visitString(_content.asString.data, + _content.asString.size); case VALUE_IS_OWNED_RAW: case VALUE_IS_LINKED_RAW: - return visitor.visitRawJson(_content.asRaw.data, _content.asRaw.size); + return visitor.visitRawJson(_content.asString.data, + _content.asString.size); case VALUE_IS_SIGNED_INTEGER: return visitor.visitSignedInteger(_content.asSignedInteger); @@ -76,7 +79,7 @@ class VariantData { template T asFloat() const; - const char *asString() const; + String asString() const; bool asBoolean() const; @@ -96,24 +99,7 @@ class VariantData { return const_cast(this)->asObject(); } - bool copyFrom(const VariantData &src, MemoryPool *pool) { - switch (src.type()) { - case VALUE_IS_ARRAY: - return toArray().copyFrom(src._content.asCollection, pool); - case VALUE_IS_OBJECT: - return toObject().copyFrom(src._content.asCollection, pool); - case VALUE_IS_OWNED_STRING: - return setString(adaptString(const_cast(src._content.asString)), - pool); - case VALUE_IS_OWNED_RAW: - return setOwnedRaw( - serialized(src._content.asRaw.data, src._content.asRaw.size), pool); - default: - setType(src.type()); - _content = src._content; - return true; - } - } + bool copyFrom(const VariantData &src, MemoryPool *pool); bool isArray() const { return (_flags & VALUE_IS_ARRAY) != 0; @@ -185,20 +171,20 @@ class VariantData { void setLinkedRaw(SerializedValue value) { if (value.data()) { setType(VALUE_IS_LINKED_RAW); - _content.asRaw.data = value.data(); - _content.asRaw.size = value.size(); + _content.asString.data = value.data(); + _content.asString.size = value.size(); } else { setType(VALUE_IS_NULL); } } template - bool setOwnedRaw(SerializedValue value, MemoryPool *pool) { + bool storeOwnedRaw(SerializedValue value, MemoryPool *pool) { const char *dup = pool->saveString(adaptString(value.data(), value.size())); if (dup) { setType(VALUE_IS_OWNED_RAW); - _content.asRaw.data = dup; - _content.asRaw.size = value.size(); + _content.asString.data = dup; + _content.asString.size = value.size(); return true; } else { setType(VALUE_IS_NULL); @@ -222,21 +208,14 @@ class VariantData { setType(VALUE_IS_NULL); } - void setStringPointer(const char *s, storage_policies::store_by_copy) { - ARDUINOJSON_ASSERT(s != 0); - setType(VALUE_IS_OWNED_STRING); - _content.asString = s; - } - - void setStringPointer(const char *s, storage_policies::store_by_address) { - ARDUINOJSON_ASSERT(s != 0); - setType(VALUE_IS_LINKED_STRING); - _content.asString = s; - } - - template - bool setString(TAdaptedString value, MemoryPool *pool) { - return storeString(value, pool, typename TAdaptedString::storage_policy()); + void setString(String s) { + ARDUINOJSON_ASSERT(s); + if (s.isStatic()) + setType(VALUE_IS_LINKED_STRING); + else + setType(VALUE_IS_OWNED_STRING); + _content.asString.data = s.c_str(); + _content.asString.size = s.size(); } CollectionData &toArray() { @@ -254,9 +233,10 @@ class VariantData { size_t memoryUsage() const { switch (type()) { case VALUE_IS_OWNED_STRING: - return strlen(_content.asString) + 1; case VALUE_IS_OWNED_RAW: - return _content.asRaw.size; + // We always add a zero at the end: the deduplication function uses it + // to detect the beginning of the next string. + return _content.asString.size + 1; case VALUE_IS_OBJECT: case VALUE_IS_ARRAY: return _content.asCollection.memoryUsage(); @@ -298,18 +278,19 @@ class VariantData { return isObject() ? _content.asCollection.getMember(key) : 0; } - template - VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool) { + template + VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool, + TStoragePolicy storage_policy) { if (isNull()) toObject(); if (!isObject()) return 0; - return _content.asCollection.getOrAddMember(key, pool); + return _content.asCollection.getOrAddMember(key, pool, storage_policy); } void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance) { if (_flags & OWNED_VALUE_BIT) - _content.asString += stringDistance; + _content.asString.data += stringDistance; if (_flags & COLLECTION_MASK) _content.asCollection.movePointers(stringDistance, variantDistance); } @@ -318,46 +299,36 @@ class VariantData { return _flags & VALUE_MASK; } + template + inline bool storeString(TAdaptedString value, MemoryPool *pool, + TStoragePolicy storage) { + if (value.isNull()) { + setNull(); + return true; + } + + return storage.store(value, pool, VariantStringSetter(this)); + } + private: void setType(uint8_t t) { _flags &= OWNED_KEY_BIT; _flags |= t; } - template - inline bool storeString(TAdaptedString value, MemoryPool *pool, - storage_policies::decide_at_runtime) { - if (value.isStatic()) - return storeString(value, pool, storage_policies::store_by_address()); - else - return storeString(value, pool, storage_policies::store_by_copy()); - } - - template - inline bool storeString(TAdaptedString value, MemoryPool *, - storage_policies::store_by_address) { - if (value.isNull()) - setNull(); - else - setStringPointer(value.data(), storage_policies::store_by_address()); - return true; - } + struct VariantStringSetter { + VariantStringSetter(VariantData *instance) : _instance(instance) {} - template - inline bool storeString(TAdaptedString value, MemoryPool *pool, - storage_policies::store_by_copy) { - if (value.isNull()) { - setNull(); - return true; + template + void operator()(TStoredString s) { + if (s) + _instance->setString(s); + else + _instance->setNull(); } - const char *copy = pool->saveString(value); - if (!copy) { - setNull(); - return false; - } - setStringPointer(copy, storage_policies::store_by_copy()); - return true; - } + + VariantData *_instance; + }; }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp index 3fc9cbb..8890597 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp @@ -1,10 +1,11 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once #include +#include #include namespace ARDUINOJSON_NAMESPACE { @@ -49,12 +50,10 @@ inline void variantSetNull(VariantData *var) { var->setNull(); } -template +template inline bool variantSetString(VariantData *var, TAdaptedString value, - MemoryPool *pool) { - if (!var) - return false; - return var->setString(value, pool); + MemoryPool *pool, TStoragePolicy storage_policy) { + return var != 0 ? var->storeString(value, pool, storage_policy) : 0; } inline size_t variantSize(const VariantData *var) { @@ -87,14 +86,20 @@ inline NO_INLINE VariantData *variantGetOrAddElement(VariantData *var, template NO_INLINE VariantData *variantGetOrAddMember(VariantData *var, TChar *key, MemoryPool *pool) { - return var != 0 ? var->getOrAddMember(adaptString(key), pool) : 0; + if (!var) + return 0; + return var->getOrAddMember(adaptString(key), pool, + getStringStoragePolicy(key)); } template NO_INLINE VariantData *variantGetOrAddMember(VariantData *var, const TString &key, MemoryPool *pool) { - return var != 0 ? var->getOrAddMember(adaptString(key), pool) : 0; + if (!var) + return 0; + return var->getOrAddMember(adaptString(key), pool, + getStringStoragePolicy(key)); } inline bool variantIsNull(const VariantData *var) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantImpl.hpp index ea49a92..bd3ce07 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantImpl.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -26,7 +26,7 @@ inline T VariantData::asIntegral() const { return convertNumber(_content.asSignedInteger); case VALUE_IS_LINKED_STRING: case VALUE_IS_OWNED_STRING: - return parseNumber(_content.asString); + return parseNumber(_content.asString.data); case VALUE_IS_FLOAT: return convertNumber(_content.asFloat); default: @@ -62,7 +62,7 @@ inline T VariantData::asFloat() const { return static_cast(_content.asSignedInteger); case VALUE_IS_LINKED_STRING: case VALUE_IS_OWNED_STRING: - return parseNumber(_content.asString); + return parseNumber(_content.asString.data); case VALUE_IS_FLOAT: return static_cast(_content.asFloat); default: @@ -70,13 +70,36 @@ inline T VariantData::asFloat() const { } } -inline const char *VariantData::asString() const { +inline String VariantData::asString() const { switch (type()) { case VALUE_IS_LINKED_STRING: + return String(_content.asString.data, _content.asString.size, true); case VALUE_IS_OWNED_STRING: - return _content.asString; + return String(_content.asString.data, _content.asString.size, false); default: - return 0; + return String(); + } +} + +inline bool VariantData::copyFrom(const VariantData &src, MemoryPool *pool) { + switch (src.type()) { + case VALUE_IS_ARRAY: + return toArray().copyFrom(src._content.asCollection, pool); + case VALUE_IS_OBJECT: + return toObject().copyFrom(src._content.asCollection, pool); + case VALUE_IS_OWNED_STRING: { + String value = src.asString(); + return storeString(adaptString(value), pool, + getStringStoragePolicy(value)); + } + case VALUE_IS_OWNED_RAW: + return storeOwnedRaw( + serialized(src._content.asString.data, src._content.asString.size), + pool); + default: + setType(src.type()); + _content = src._content; + return true; } } @@ -145,4 +168,15 @@ inline VariantConstRef operator|(VariantConstRef preferedValue, inline bool VariantRef::set(char value) const { return set(value); } + +// TODO: move somewhere else +template +bool CopyStringStoragePolicy::store(TAdaptedString str, MemoryPool *pool, + TCallback callback) { + const char *copy = pool->saveString(str); + String storedString(copy, str.size(), false); + callback(storedString); + return copy != 0; +} + } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp index 54174a4..a56c53a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantOperators.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -17,7 +17,7 @@ CompareResult compare(const T1 &lhs, const T2 &rhs); // VariantCompare.cpp template struct VariantOperators { - // Returns the default value if the VariantRef is undefined or incompatible + // Returns the default value if the VariantRef is unbound or incompatible // // int operator|(JsonVariant, int) // float operator|(JsonVariant, float) diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp index b05ed90..0865d69 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -32,7 +32,7 @@ class VariantRefBase : public VariantTag { return variantIsNull(_data); } - FORCE_INLINE bool isUndefined() const { + FORCE_INLINE bool isUnbound() const { return !_data; } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantShortcuts.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantShortcuts.hpp index e62847f..3b32483 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantShortcuts.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantShortcuts.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp index a271c1e..8f4169c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantSlot.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -7,7 +7,6 @@ #include #include #include -#include #include namespace ARDUINOJSON_NAMESPACE { @@ -77,16 +76,13 @@ class VariantSlot { _next = VariantSlotDiff(slot - this); } - void setKey(const char* k, storage_policies::store_by_copy) { - ARDUINOJSON_ASSERT(k != NULL); - _flags |= OWNED_KEY_BIT; - _key = k; - } - - void setKey(const char* k, storage_policies::store_by_address) { - ARDUINOJSON_ASSERT(k != NULL); - _flags &= VALUE_MASK; - _key = k; + void setKey(String k) { + ARDUINOJSON_ASSERT(k); + if (k.isStatic()) + _flags &= VALUE_MASK; + else + _flags |= OWNED_KEY_BIT; + _key = k.c_str(); } const char* key() const { @@ -107,7 +103,7 @@ class VariantSlot { if (_flags & OWNED_KEY_BIT) _key += stringDistance; if (_flags & OWNED_VALUE_BIT) - _content.asString += stringDistance; + _content.asString.data += stringDistance; if (_flags & COLLECTION_MASK) _content.asCollection.movePointers(stringDistance, variantDistance); } diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp index 7164164..94ec38b 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTag.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp index 352ecba..932977f 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/Visitor.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/Visitor.hpp index 33237dd..778f81c 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/Visitor.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/Visitor.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once @@ -46,7 +46,7 @@ struct Visitor { return TResult(); } - TResult visitString(const char *) { + TResult visitString(const char *, size_t) { return TResult(); } }; diff --git a/third-party/ArduinoJson/src/ArduinoJson/compatibility.hpp b/third-party/ArduinoJson/src/ArduinoJson/compatibility.hpp index cca477e..ca178a2 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/compatibility.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/compatibility.hpp @@ -1,5 +1,5 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License // // clang-format off diff --git a/third-party/ArduinoJson/src/ArduinoJson/version.hpp b/third-party/ArduinoJson/src/ArduinoJson/version.hpp index 6cff6e0..5beae8a 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/version.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/version.hpp @@ -1,10 +1,10 @@ // ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 +// Copyright © 2014-2022, Benoit BLANCHON // MIT License #pragma once -#define ARDUINOJSON_VERSION "6.18.5" +#define ARDUINOJSON_VERSION "6.19.2" #define ARDUINOJSON_VERSION_MAJOR 6 -#define ARDUINOJSON_VERSION_MINOR 18 -#define ARDUINOJSON_VERSION_REVISION 5 +#define ARDUINOJSON_VERSION_MINOR 19 +#define ARDUINOJSON_VERSION_REVISION 2 diff --git a/third-party/ArduinoJson/src/CMakeLists.txt b/third-party/ArduinoJson/src/CMakeLists.txt index b76e580..ebc83a9 100644 --- a/third-party/ArduinoJson/src/CMakeLists.txt +++ b/third-party/ArduinoJson/src/CMakeLists.txt @@ -1,5 +1,5 @@ # ArduinoJson - https://arduinojson.org -# Copyright Benoit Blanchon 2014-2021 +# Copyright © 2014-2022, Benoit BLANCHON # MIT License # I have no idea what this is about, I simply followed the instructions from: