accept() ignores pointers (6796,5602)

This commit is contained in:
Benoit Blanchon
2022-03-29 12:19:44 +02:00
parent 58dee1850d
commit fb88d4cda0
5 changed files with 7 additions and 11 deletions

View File

@@ -25,7 +25,7 @@ class JsonSerializer : public Visitor<size_t> {
VariantSlot *slot = array.head();
while (slot != 0) {
slot->data()->accept(*this);
slot->data()->resolve()->accept(*this);
slot = slot->next();
if (slot == 0)
@@ -46,7 +46,7 @@ class JsonSerializer : public Visitor<size_t> {
while (slot != 0) {
_formatter.writeString(slot->key());
write(':');
slot->data()->accept(*this);
slot->data()->resolve()->accept(*this);
slot = slot->next();
if (slot == 0)

View File

@@ -25,7 +25,7 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
_nesting++;
while (slot != 0) {
indent();
slot->data()->accept(*this);
slot->data()->resolve()->accept(*this);
slot = slot->next();
base::write(slot ? ",\r\n" : "\r\n");
@@ -48,7 +48,7 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
indent();
base::visitString(slot->key());
base::write(": ");
slot->data()->accept(*this);
slot->data()->resolve()->accept(*this);
slot = slot->next();
base::write(slot ? ",\r\n" : "\r\n");

View File

@@ -56,7 +56,7 @@ class MsgPackSerializer : public Visitor<size_t> {
writeInteger(uint32_t(n));
}
for (VariantSlot* slot = array.head(); slot; slot = slot->next()) {
slot->data()->accept(*this);
slot->data()->resolve()->accept(*this);
}
return bytesWritten();
}
@@ -74,7 +74,7 @@ class MsgPackSerializer : public Visitor<size_t> {
}
for (VariantSlot* slot = object.head(); slot; slot = slot->next()) {
visitString(slot->key());
slot->data()->accept(*this);
slot->data()->resolve()->accept(*this);
}
return bytesWritten();
}

View File

@@ -68,10 +68,6 @@ class VariantData {
case VALUE_IS_BOOLEAN:
return visitor.visitBoolean(_content.asBoolean != 0);
case VALUE_IS_POINTER: // P+0 G+46
ARDUINOJSON_ASSERT(_content.asPointer != 0);
return _content.asPointer->accept(visitor);
default:
return visitor.visitNull();
}

View File

@@ -14,7 +14,7 @@ template <typename TVisitor>
inline typename TVisitor::result_type variantAccept(const VariantData *var,
TVisitor &visitor) {
if (var != 0)
return var->accept(visitor);
return var->resolve()->accept(visitor);
else
return visitor.visitNull();
}