QProtobufSerializer: change fieldIndex to fieldNumber in encodeHeader

Pick-to: 6.9 6.8
Change-Id: I465aa746f0467933715091f6c5a1ba536b8313d2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Dennis Oberst 2025-04-04 13:19:49 +02:00
parent 9508b383f2
commit 4b536e162d
2 changed files with 7 additions and 7 deletions

View File

@ -270,21 +270,21 @@ void QProtobufSerializerImpl::serializeMessageFieldEnd(const QProtobufMessage *m
m_result = last;
}
QByteArray QProtobufSerializerImpl::encodeHeader(int fieldIndex, QtProtobuf::WireTypes wireType)
QByteArray QProtobufSerializerImpl::encodeHeader(int fieldNumber, QtProtobuf::WireTypes wireType)
{
// Encodes a property field index and its type into output bytes.
// Encodes a property field number and its type into output bytes.
// Header byte
// Meaning | Field index | Type
// Meaning | Field number | Type
// ---------- | ------------- | --------
// bit number | 7 6 5 4 3 | 2 1 0
// fieldIndex: The index of a property in parent object
// wireType: Serialization type used for the property with fieldIndex
// fieldNumber: The index of a property in parent object
// wireType: Serialization type used for the property with fieldNumber
// Returns a varint-encoded fieldIndex and wireType
uint32_t header = (fieldIndex << 3) | int(wireType);
uint32_t header = (fieldNumber << 3) | int(wireType);
return serializeVarintCommon<uint32_t>(header);
}

View File

@ -58,7 +58,7 @@ private:
void serializeMessageFieldEnd(const QProtobufMessage *message,
const QtProtobufPrivate::QProtobufFieldInfo &fieldInfo) override;
static QByteArray encodeHeader(int fieldIndex, QtProtobuf::WireTypes wireType);
static QByteArray encodeHeader(int fieldNumber, QtProtobuf::WireTypes wireType);
QByteArray m_result;
QList<QByteArray> m_state;