Skip to content

Commit

Permalink
Merge pull request #597 from iranl/update-libs
Browse files Browse the repository at this point in the history
Update libs
  • Loading branch information
iranl authored Jan 6, 2025
2 parents 5b5eb59 + a379b30 commit ce2696b
Show file tree
Hide file tree
Showing 83 changed files with 1,087 additions and 1,489 deletions.
40 changes: 40 additions & 0 deletions lib/ArduinoJson/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
ArduinoJson: change log
=======================

v7.3.0 (2024-12-29)
------

* Fix support for NUL characters in `deserializeJson()`
* Make `ElementProxy` and `MemberProxy` non-copyable
* Change string copy policy: only string literal are stored by pointer
* `JsonString` is now stored by copy, unless specified otherwise
* Replace undocumented `JsonString::Ownership` with `bool`
* Rename undocumented `JsonString::isLinked()` to `isStatic()`
* Move public facing SFINAEs to template declarations

> ### BREAKING CHANGES
>
> In previous versions, `MemberProxy` (the class returned by `operator[]`) could lead to dangling pointers when used with a temporary string.
> To prevent this issue, `MemberProxy` and `ElementProxy` are now non-copyable.
>
> Your code is likely to be affected if you use `auto` to store the result of `operator[]`. For example, the following line won't compile anymore:
>
> ```cpp
> auto value = doc["key"];
> ```
>
> To fix the issue, you must append either `.as<T>()` or `.to<T>()`, depending on the situation.
>
> For example, if you are extracting values from a JSON document, you should update like this:
>
> ```diff
> - auto config = doc["config"];
> + auto config = doc["config"].as<JsonObject>();
> const char* name = config["name"];
> ```
>
> However, if you are building a JSON document, you should update like this:
>
> ```diff
> - auto config = doc["config"];
> + auto config = doc["config"].to<JsonObject>();
> config["name"] = "ArduinoJson";
> ```
v7.2.1 (2024-11-15)
------
Expand Down
2 changes: 1 addition & 1 deletion lib/ArduinoJson/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(ESP_PLATFORM)
return()
endif()

project(ArduinoJson VERSION 7.2.1)
project(ArduinoJson VERSION 7.3.0)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
Expand Down
46 changes: 0 additions & 46 deletions lib/ArduinoJson/README

This file was deleted.

2 changes: 1 addition & 1 deletion lib/ArduinoJson/appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 7.2.1.{build}
version: 7.3.0.{build}
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
Expand Down
29 changes: 29 additions & 0 deletions lib/ArduinoJson/extras/scripts/extract_changes.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/awk -f

# Start echoing after the first list item
/\* / {
STARTED=1
EMPTY_LINE=0
}

# Remember if we have seen an empty line
/^[[:space:]]*$/ {
EMPTY_LINE=1
}

# Exit when seeing a new version number
/^v[[:digit:]]/ {
if (STARTED) exit
}

# Print if the line is not empty
# and restore the empty line we have skipped
!/^[[:space:]]*$/ {
if (STARTED) {
if (EMPTY_LINE) {
print ""
EMPTY_LINE=0
}
print
}
}
14 changes: 0 additions & 14 deletions lib/ArduinoJson/extras/scripts/get-release-body.sh

This file was deleted.

2 changes: 1 addition & 1 deletion lib/ArduinoJson/extras/scripts/get-release-page.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ date: '$(date +'%Y-%m-%d')'
$(extras/scripts/wandbox/publish.sh "$ARDUINOJSON_H")
---
$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG")
$(extras/scripts/extract_changes.awk "$CHANGELOG")
END
2 changes: 1 addition & 1 deletion lib/ArduinoJson/extras/scripts/wandbox/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ compile() {
"code":$(read_string "$FILE_PATH"),
"codes": [{"file":"ArduinoJson.h","code":$(read_string "$ARDUINOJSON_H")}],
"options": "warning,c++11",
"compiler": "gcc-5.5.0",
"compiler": "gcc-head",
"save": true
}
END
Expand Down
2 changes: 1 addition & 1 deletion lib/ArduinoJson/extras/tests/Deprecated/containsKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_CASE("JsonDocument::containsKey()") {

TEST_CASE("MemberProxy::containsKey()") {
JsonDocument doc;
auto mp = doc["hello"];
const auto& mp = doc["hello"];

SECTION("containsKey(const char*)") {
mp["key"] = "value";
Expand Down
1 change: 0 additions & 1 deletion lib/ArduinoJson/extras/tests/JsonArray/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ add_executable(JsonArrayTests
nesting.cpp
remove.cpp
size.cpp
std_string.cpp
subscript.cpp
unbound.cpp
)
Expand Down
151 changes: 91 additions & 60 deletions lib/ArduinoJson/extras/tests/JsonArray/add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,112 @@ TEST_CASE("JsonArray::add(T)") {

SECTION("int") {
array.add(123);

REQUIRE(123 == array[0].as<int>());
REQUIRE(array[0].is<int>());
REQUIRE(array[0].is<double>());
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
});
}

SECTION("double") {
array.add(123.45);

REQUIRE(123.45 == array[0].as<double>());
REQUIRE(array[0].is<double>());
REQUIRE_FALSE(array[0].is<bool>());
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
});
}

SECTION("bool") {
array.add(true);
REQUIRE(true == array[0].as<bool>());

REQUIRE(array[0].as<bool>() == true);
REQUIRE(array[0].is<bool>());
REQUIRE_FALSE(array[0].is<int>());
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
});
}

SECTION("string literal") {
array.add("hello");

REQUIRE(array[0].as<std::string>() == "hello");
REQUIRE(array[0].is<const char*>());
REQUIRE(array[0].is<int>() == false);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
});
}

SECTION("std::string") {
array.add("hello"_s);

REQUIRE(array[0].as<std::string>() == "hello");
REQUIRE(array[0].is<const char*>() == true);
REQUIRE(array[0].is<int>() == false);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
});
}

SECTION("const char*") {
const char* str = "hello";
array.add(str);
REQUIRE(str == array[0].as<std::string>());
REQUIRE(array[0].is<const char*>());
REQUIRE_FALSE(array[0].is<int>());

REQUIRE(array[0].as<std::string>() == "hello");
REQUIRE(array[0].as<const char*>() != str);
REQUIRE(array[0].is<const char*>() == true);
REQUIRE(array[0].is<int>() == false);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
});
}

SECTION("serialized(const char*)") {
array.add(serialized("{}"));

REQUIRE(doc.as<std::string>() == "[{}]");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("{}")),
});
}

SECTION("serialized(char*)") {
array.add(serialized(const_cast<char*>("{}")));

REQUIRE(doc.as<std::string>() == "[{}]");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("{}")),
});
}

SECTION("serialized(std::string)") {
array.add(serialized("{}"_s));

REQUIRE(doc.as<std::string>() == "[{}]");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("{}")),
});
}

SECTION("serialized(std::string)") {
array.add(serialized("\0XX"_s));

REQUIRE(doc.as<std::string>() == "[\0XX]"_s);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString(" XX")),
});
}

#ifdef HAS_VARIABLE_LENGTH_ARRAY
Expand All @@ -52,7 +133,12 @@ TEST_CASE("JsonArray::add(T)") {

array.add(vla);

REQUIRE("world"_s == array[0]);
strcpy(vla, "hello");
REQUIRE(array[0] == "world"_s);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
});
}
#endif

Expand Down Expand Up @@ -99,61 +185,6 @@ TEST_CASE("JsonArray::add(T)") {

REQUIRE(str == array[0]);
}

SECTION("should not duplicate const char*") {
array.add("world");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
});
}

SECTION("should duplicate char*") {
array.add(const_cast<char*>("world"));
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("world")),
});
}

SECTION("should duplicate std::string") {
array.add("world"_s);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("world")),
});
}

SECTION("should duplicate serialized(const char*)") {
array.add(serialized("{}"));
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("{}")),
});
}

SECTION("should duplicate serialized(char*)") {
array.add(serialized(const_cast<char*>("{}")));
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("{}")),
});
}

SECTION("should duplicate serialized(std::string)") {
array.add(serialized("{}"_s));
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("{}")),
});
}

SECTION("should duplicate serialized(std::string)") {
array.add(serialized("\0XX"_s));
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString(" XX")),
});
}
}

TEST_CASE("JsonArray::add<T>()") {
Expand Down
Loading

0 comments on commit ce2696b

Please sign in to comment.