Skip to content

Commit

Permalink
Mark JsonArray, JsonObject, and JsonVariant as final
Browse files Browse the repository at this point in the history
See #2056
Ported from 483a2c9
  • Loading branch information
bblanchon committed Feb 18, 2024
1 parent 0e7262a commit 5ed9daa
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ HEAD
----

* Improve error messages when using `char` or `char*` (issue #2043)
* Mark `JsonArray`, `JsonObject`, and `JsonVariant` as `final` (issue #2056)

v6.21.5 (2024-01-10)
-------
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Array/JsonArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JsonObject;

// A reference to an array in a JsonDocument
// https://arduinojson.org/v6/api/jsonarray/
class JsonArray : public detail::VariantOperators<JsonArray> {
class JsonArray final : public detail::VariantOperators<JsonArray> {
friend class detail::VariantAttorney;

public:
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Array/JsonArrayConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JsonObject;

// A read-only reference to an array in a JsonDocument
// https://arduinojson.org/v6/api/jsonarrayconst/
class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
class JsonArrayConst final : public detail::VariantOperators<JsonArrayConst> {
friend class JsonArray;
friend class detail::VariantAttorney;

Expand Down
8 changes: 4 additions & 4 deletions src/ArduinoJson/Array/JsonArrayIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

class VariantPtr {
class VariantPtr final {
public:
VariantPtr(detail::MemoryPool* pool, detail::VariantData* data)
: variant_(pool, data) {}
Expand All @@ -26,7 +26,7 @@ class VariantPtr {
JsonVariant variant_;
};

class JsonArrayIterator {
class JsonArrayIterator final {
friend class JsonArray;

public:
Expand Down Expand Up @@ -65,7 +65,7 @@ class JsonArrayIterator {
detail::VariantSlot* slot_;
};

class VariantConstPtr {
class VariantConstPtr final {
public:
VariantConstPtr(const detail::VariantData* data) : variant_(data) {}

Expand All @@ -81,7 +81,7 @@ class VariantConstPtr {
JsonVariantConst variant_;
};

class JsonArrayConstIterator {
class JsonArrayConstIterator final {
friend class JsonArray;

public:
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Object/JsonObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JsonArray;

// A reference to an object in a JsonDocument.
// https://arduinojson.org/v6/api/jsonobject/
class JsonObject : public detail::VariantOperators<JsonObject> {
class JsonObject final : public detail::VariantOperators<JsonObject> {
friend class detail::VariantAttorney;

public:
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Object/JsonObjectConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

// A read-only reference to an object in a JsonDocument.
// https://arduinojson.org/v6/api/jsonobjectconst/
class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
class JsonObjectConst final : public detail::VariantOperators<JsonObjectConst> {
friend class JsonObject;
friend class detail::VariantAttorney;

Expand Down
8 changes: 4 additions & 4 deletions src/ArduinoJson/Object/JsonObjectIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

class JsonPairPtr {
class JsonPairPtr final {
public:
JsonPairPtr(detail::MemoryPool* pool, detail::VariantSlot* slot)
: pair_(pool, slot) {}
Expand All @@ -26,7 +26,7 @@ class JsonPairPtr {
JsonPair pair_;
};

class JsonObjectIterator {
class JsonObjectIterator final {
friend class JsonObject;

public:
Expand Down Expand Up @@ -66,7 +66,7 @@ class JsonObjectIterator {
detail::VariantSlot* slot_;
};

class JsonPairConstPtr {
class JsonPairConstPtr final {
public:
JsonPairConstPtr(const detail::VariantSlot* slot) : pair_(slot) {}

Expand All @@ -82,7 +82,7 @@ class JsonPairConstPtr {
JsonPairConst pair_;
};

class JsonObjectConstIterator {
class JsonObjectConstIterator final {
friend class JsonObject;

public:
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/Object/JsonPair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

// A key-value pair.
// https://arduinojson.org/v6/api/jsonobject/begin_end/
class JsonPair {
class JsonPair final {
public:
// INTERNAL USE ONLY
JsonPair(detail::MemoryPool* pool, detail::VariantSlot* slot) {
Expand Down Expand Up @@ -40,7 +40,7 @@ class JsonPair {

// A read-only key-value pair.
// https://arduinojson.org/v6/api/jsonobjectconst/begin_end/
class JsonPairConst {
class JsonPairConst final {
public:
JsonPairConst(const detail::VariantSlot* slot) {
if (slot) {
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/Variant/JsonVariant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

// A reference to a value in a JsonDocument.
// https://arduinojson.org/v6/api/jsonvariant/
class JsonVariant : public detail::VariantRefBase<JsonVariant>,
public detail::VariantOperators<JsonVariant> {
class JsonVariant final : public detail::VariantRefBase<JsonVariant>,
public detail::VariantOperators<JsonVariant> {
friend class detail::VariantAttorney;

public:
Expand Down
5 changes: 3 additions & 2 deletions src/ArduinoJson/Variant/JsonVariantConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class JsonObject;

// A read-only reference to a value in a JsonDocument
// https://arduinojson.org/v6/api/jsonarrayconst/
class JsonVariantConst : public detail::VariantTag,
public detail::VariantOperators<JsonVariantConst> {
class JsonVariantConst final
: public detail::VariantTag,
public detail::VariantOperators<JsonVariantConst> {
friend class detail::VariantAttorney;

public:
Expand Down

0 comments on commit 5ed9daa

Please sign in to comment.