version 4.8.0

fix PICodeParser: complex static array dimensions, member template types for multideclaration
PIJSON::serialize and PIJSON::deserialize helpers
This commit is contained in:
2025-08-02 22:14:49 +03:00
parent cf25cacc17
commit a2c24c9f07
4 changed files with 53 additions and 37 deletions

View File

@@ -5,8 +5,8 @@ if (POLICY CMP0177)
endif()
project(PIP)
set(PIP_MAJOR 4)
set(PIP_MINOR 7)
set(PIP_REVISION 4)
set(PIP_MINOR 8)
set(PIP_REVISION 0)
set(PIP_SUFFIX )
set(PIP_COMPANY SHS)
set(PIP_DOMAIN org.SHS)

View File

@@ -818,7 +818,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
if (fc.trim().isEmpty()) return true;
if (fc.find(s_operator) >= 0) return true;
tmp_temp.clear();
// piCout << "parse member" << fc;
// piCout << "\nparse member <<<<" << fc << ">>>>";
int ts = fc.find('<'), te = 0;
PIString ctemp, crepl;
while (ts >= 0) {
@@ -847,10 +847,8 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
}
fc.cutRight(fc.size_s() - fc.findLast(')') - 1);
te = fc.find('(');
// piCout << fc;
for (ts = te - 1; ts >= 0; --ts)
if (!_isCChar(fc[ts]) && !(fc[ts].isDigit())) break;
// piCout << "takeMid" << ts + 1 << te - ts - 1;
me.meta = meta;
me.name = fc.takeMid(ts + 1, te - ts - 1);
if (me.name == parent->name) return true;
@@ -899,53 +897,46 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
if (fc.startsWith(s_using) || !(fc.contains(' ') || fc.contains('\t') || fc.contains('\n'))) return true;
int bits = extractMemberBits(fc);
tl = fc.split(',');
// piCout << "member" << fc << tl;
// piCout << "member after eb" << fc << ", bits =" << bits;
if (tl.isEmpty()) return true;
for (auto & v: tl)
removeAssignment(v);
bool vn = true;
ctemp = tl.front().trim();
// piCout << "member" << tl;
ctemp = s_s5 + tl.front().trim();
PIString meta_t;
if (ctemp.contains(s_M)) {
meta_t = ctemp.takeMid(ctemp.find(s_M), 5);
ctemp.trim();
}
for (ts = ctemp.size_s() - 1; ts > 0; --ts) {
if (vn) {
if (!_isCChar(ctemp[ts]) && !ctemp[ts].isDigit() && ctemp[ts] != '[' && ctemp[ts] != ']') vn = false;
} else {
if (_isCChar(ctemp[ts]) || ctemp[ts].isDigit()) break;
if (ctemp.find(s_s_const_s) >= 0) {
me.attributes |= Const;
ctemp.replaceAll(s_s_const_s, ' ');
}
if (ctemp.find(s_s_static_s) >= 0) {
me.attributes |= Static;
ctemp.replaceAll(s_s_static_s, ' ');
}
me.type = ctemp.takeLeft(ts + 1);
if (ctemp.find(s_s_mutable_s) >= 0) {
me.attributes |= Mutable;
ctemp.replaceAll(s_s_mutable_s, ' ');
}
if (ctemp.find(s_s_volatile_s) >= 0) {
me.attributes |= Volatile;
ctemp.replaceAll(s_s_volatile_s, ' ');
}
if (ctemp.find(s_s_extern_s) >= 0) {
me.attributes |= Extern;
ctemp.replaceAll(s_s_extern_s, ' ');
}
PIString type = ctemp.trim().takeWord();
ctemp.trim();
me.visibility = cur_def_vis;
ctemp += meta_t;
restoreTmpTemp(&me);
PIString type = s_s5 + me.type;
if (type.find(s_s_const_s) >= 0) {
me.attributes |= Const;
type.replaceAll(s_s_const_s, ' ');
}
if (type.find(s_s_static_s) >= 0) {
me.attributes |= Static;
type.replaceAll(s_s_static_s, ' ');
}
if (type.find(s_s_mutable_s) >= 0) {
me.attributes |= Mutable;
type.replaceAll(s_s_mutable_s, ' ');
}
if (type.find(s_s_volatile_s) >= 0) {
me.attributes |= Volatile;
type.replaceAll(s_s_volatile_s, ' ');
}
if (type.find(s_s_extern_s) >= 0) {
me.attributes |= Extern;
type.replaceAll(s_s_extern_s, ' ');
}
// me.type = s_s5 + me.type;
type.trim();
normalizeEntityNamespace(type);
tl[0] = ctemp.trim();
// piCout << "type" << type;
// piCout << "vars" << tl;
for (const auto & v: tl) {
crepl.clear();
@@ -972,6 +963,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
}
// PICout(PICoutManipulators::AddAll) << "var" << me.type << me.name << me.bits;
// piCout << "var" << v << me.type << me.name << me.bits;
restoreTmpTemp(&me);
parent->members << me;
}
}

View File

@@ -191,6 +191,12 @@ public:
static PIJSON newArray(const PIVariantVector & fields = {});
static PIJSON newString(const PIString & v = PIString());
template<typename T>
static PIJSON serialize(const T & v);
template<typename T>
static T deserialize(const PIJSON & json);
private:
static PIJSON & nullEntry();
static PIString parseName(PIString & s);

View File

@@ -392,4 +392,22 @@ inline void piDeserializeJSON(PIMap<K, T> & v, const PIJSON & js) {
}
// ---
// PIJSON static wrapper
// ---
template<typename T>
PIJSON PIJSON::serialize(const T & v) {
return piSerializeJSON(v);
}
template<typename T>
T PIJSON::deserialize(const PIJSON & json) {
T ret;
piDeserializeJSON(ret, json);
return ret;
}
#endif // pijsonserialization_h