Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qt.h #174

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Define FmqQVariant
beckdave committed Apr 8, 2024
commit 43ac3b5bdc6cfaaf8c211645b3adb352db1adfbc
32 changes: 32 additions & 0 deletions inc/finalmq/Qt/qtdata.fmq
Original file line number Diff line number Diff line change
@@ -231,7 +231,39 @@

{"type":"FmqQPalette","attrs":["qttype:QPalette"],"desc":"","fields":[
{"tid":"struct[]","type":"FmqQPaletteColorRole", "name":"goups", "attrs":["fixedarray:3"], "desc":"","flags":[]}
]},

{"type":"FmqQVariant","attrs":["qttype:QVariant"],"desc":"desc","fields":[
{"tid":"TYPE_UINT32","type":"","name":"typeId","attrs":["indexoffset:1,indexmode:mapping,0:0,1:1,2:2,3:3,4:4,5:5,6:6,32:7,33:8,34:9,35:10,36:11,37:12,38:13,31:14,7:15,10:16,12:17,13:18,19:19,20:20,21:21,22:22,25:23,26:24"],"desc":"desc","flags":["METAFLAG_INDEX"]},
{"tid":"TYPE_UINT8","type":"","name":"isnull","desc":"desc","flags":[]},
{"tid":"TYPE_UINT8","type":"","name":"valueUnknown","desc":"desc","attrs":["fixedarray:0"],"flags":[]},
{"tid":"TYPE_BOOL", "name":"valueBool"},
{"tid":"TYPE_INT32", "name":"valueInt"},
{"tid":"TYPE_UINT32", "name":"valueUInt"},
{"tid":"TYPE_INT64", "name":"valueLongLong"},
{"tid":"TYPE_UINT64", "name":"valueULongLong"},
{"tid":"TYPE_DOUBLE", "name":"valueDouble"},
{"tid":"TYPE_INT32", "name":"valueLong"},
{"tid":"TYPE_INT16", "name":"valueShort"},
{"tid":"TYPE_INT8", "name":"valueChar"},
{"tid":"TYPE_UINT32", "name":"valueULong"},
{"tid":"TYPE_UINT16", "name":"valueUShort"},
{"tid":"TYPE_UINT8", "name":"valueUChar"},
{"tid":"TYPE_FLOAT", "name":"valueFloat"},
{"tid":"TYPE_UINT64", "name":"valueVoidStar"},
{"tid":"TYPE_UINT16", "name":"valueQChar"},
{"tid":"TYPE_STRING", "name":"valueQString"},
{"tid":"TYPE_ARRAY_STRING", "name":"valueQStringList"},
{"tid":"TYPE_BYTES", "name":"valueQByteArray"},
{"tid":"TYPE_ARRAY_BOOL", "name":"valueQBitArray"},
{"tid":"TYPE_STRUCT", "type":"FmqQRect", "name":"valueQRect"},
{"tid":"TYPE_STRUCT", "type":"FmqQRectF", "name":"valueQRectF"},
{"tid":"TYPE_STRUCT", "type":"FmqQSize", "name":"valueQSize"},
{"tid":"TYPE_STRUCT", "type":"FmqQSizeF", "name":"valueQSizeF"},
{"tid":"TYPE_STRUCT", "type":"FmqQPoint", "name":"valuePoint"},
{"tid":"TYPE_STRUCT", "type":"FmqQPointF", "name":"valuePointF"}
]}

]
}

2 changes: 1 addition & 1 deletion inc/finalmq/serializeqt/ParserQt.h
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ namespace finalmq {
bool parseArrayPng(const MetaField& field, std::vector<Bytes>& value);

bool parseQVariantHeader(const MetaField& field);
void checkIndex(const MetaField& field, std::int64_t value, std::int64_t& index);
void checkIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset);
bool getPngSize(std::uint32_t& size);

bool parseSize(const MetaField& field, std::uint32_t& value);
15 changes: 11 additions & 4 deletions src/serialize/ParserAbortAndIndex.cpp
Original file line number Diff line number Diff line change
@@ -746,6 +746,7 @@ void ParserAbortAndIndex::enterArrayEnum(const MetaField& field, const std::vect

static const std::string INDEXMODE = "indexmode";
static const std::string INDEXMODE_MAPPING = "mapping";
static const std::string INDEXOFFSET = "indexoffset";


void ParserAbortAndIndex::checkIndex(const MetaField& field, std::int64_t value)
@@ -755,6 +756,12 @@ void ParserAbortAndIndex::checkIndex(const MetaField& field, std::int64_t value)
assert(!m_levelState.empty());
LevelState& levelState = m_levelState.back();

std::int64_t indexOffset = 0;
const std::string& strIndexOffset = field.getProperty(INDEXOFFSET);
if (!strIndexOffset.empty())
{
indexOffset = atoll(strIndexOffset.c_str());
}
const std::string& indexmode = field.getProperty(INDEXMODE);
if (indexmode == INDEXMODE_MAPPING)
{
@@ -767,8 +774,8 @@ void ParserAbortAndIndex::checkIndex(const MetaField& field, std::int64_t value)
else
{
int indexMapped = atoi(strIndexMapped.c_str());
levelState.indexOfIndexField = field.index;
levelState.index = field.index + 1 + indexMapped;
levelState.indexOfIndexField = field.index + indexOffset;
levelState.index = field.index + indexOffset + 1 + indexMapped;
}
}
else
@@ -779,8 +786,8 @@ void ParserAbortAndIndex::checkIndex(const MetaField& field, std::int64_t value)
}
else
{
levelState.indexOfIndexField = field.index;
levelState.index = field.index + 1 + value;
levelState.indexOfIndexField = field.index + indexOffset;
levelState.index = field.index + indexOffset + 1 + value;
}
}
}
42 changes: 28 additions & 14 deletions src/serializeqt/ParserQt.cpp
Original file line number Diff line number Diff line change
@@ -106,14 +106,22 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
bool ok = true;
bool abortStruct = false;
std::int64_t index = INDEX_NOT_AVAILABLE;
std::int64_t indexOffset = 0;

const ssize_t numberOfFields = stru.getFieldsSize();
for (ssize_t i = 0; i < numberOfFields && ok && !abortStruct; ++i)
{
if (index >= 0)
{
i = index;
index = INDEX_ABORTSTRUCT;
if (indexOffset == 0)
{
i = index;
index = INDEX_ABORTSTRUCT;
}
else
{
--indexOffset;
}
}
const MetaField* field = stru.getFieldByIndex(i);
assert(field);
@@ -159,7 +167,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterInt8(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -175,7 +183,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterUInt8(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -191,7 +199,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterInt16(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -207,7 +215,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterUInt16(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -223,7 +231,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterInt32(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -239,7 +247,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterUInt32(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -255,7 +263,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterInt64(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -271,7 +279,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
if (ok)
{
m_visitor.enterUInt64(*field, value);
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
break;
@@ -432,7 +440,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant)
}
else
{
checkIndex(*field, value, index);
checkIndex(*field, value, index, indexOffset);
}
}
}
@@ -1211,12 +1219,18 @@ bool ParserQt::parseQVariantHeader(const MetaField& /*field*/)

static const std::string INDEXMODE = "indexmode";
static const std::string INDEXMODE_MAPPING = "mapping";
static const std::string INDEXOFFSET = "indexoffset";


void ParserQt::checkIndex(const MetaField& field, std::int64_t value, std::int64_t& index)
void ParserQt::checkIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset)
{
if ((field.flags & MetaFieldFlags::METAFLAG_INDEX) != 0)
{
const std::string& strIndexOffset = field.getProperty(INDEXOFFSET);
if (!strIndexOffset.empty())
{
indexOffset = atoll(strIndexOffset.c_str());
}
const std::string& indexmode = field.getProperty(INDEXMODE);
if (indexmode == INDEXMODE_MAPPING)
{
@@ -1229,7 +1243,7 @@ void ParserQt::checkIndex(const MetaField& field, std::int64_t value, std::int64
else
{
int indexMapped = atoi(strIndexMapped.c_str());
index = field.index + 1 + indexMapped;
index = field.index + indexOffset + 1 + indexMapped;
}
}
else
@@ -1240,7 +1254,7 @@ void ParserQt::checkIndex(const MetaField& field, std::int64_t value, std::int64
}
else
{
index = field.index + 1 + value;
index = field.index + indexOffset + 1 + value;
}
}
}