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:
@@ -5,8 +5,8 @@ if (POLICY CMP0177)
|
|||||||
endif()
|
endif()
|
||||||
project(PIP)
|
project(PIP)
|
||||||
set(PIP_MAJOR 4)
|
set(PIP_MAJOR 4)
|
||||||
set(PIP_MINOR 7)
|
set(PIP_MINOR 8)
|
||||||
set(PIP_REVISION 4)
|
set(PIP_REVISION 0)
|
||||||
set(PIP_SUFFIX )
|
set(PIP_SUFFIX )
|
||||||
set(PIP_COMPANY SHS)
|
set(PIP_COMPANY SHS)
|
||||||
set(PIP_DOMAIN org.SHS)
|
set(PIP_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -818,7 +818,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|||||||
if (fc.trim().isEmpty()) return true;
|
if (fc.trim().isEmpty()) return true;
|
||||||
if (fc.find(s_operator) >= 0) return true;
|
if (fc.find(s_operator) >= 0) return true;
|
||||||
tmp_temp.clear();
|
tmp_temp.clear();
|
||||||
// piCout << "parse member" << fc;
|
// piCout << "\nparse member <<<<" << fc << ">>>>";
|
||||||
int ts = fc.find('<'), te = 0;
|
int ts = fc.find('<'), te = 0;
|
||||||
PIString ctemp, crepl;
|
PIString ctemp, crepl;
|
||||||
while (ts >= 0) {
|
while (ts >= 0) {
|
||||||
@@ -847,10 +847,8 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|||||||
}
|
}
|
||||||
fc.cutRight(fc.size_s() - fc.findLast(')') - 1);
|
fc.cutRight(fc.size_s() - fc.findLast(')') - 1);
|
||||||
te = fc.find('(');
|
te = fc.find('(');
|
||||||
// piCout << fc;
|
|
||||||
for (ts = te - 1; ts >= 0; --ts)
|
for (ts = te - 1; ts >= 0; --ts)
|
||||||
if (!_isCChar(fc[ts]) && !(fc[ts].isDigit())) break;
|
if (!_isCChar(fc[ts]) && !(fc[ts].isDigit())) break;
|
||||||
// piCout << "takeMid" << ts + 1 << te - ts - 1;
|
|
||||||
me.meta = meta;
|
me.meta = meta;
|
||||||
me.name = fc.takeMid(ts + 1, te - ts - 1);
|
me.name = fc.takeMid(ts + 1, te - ts - 1);
|
||||||
if (me.name == parent->name) return true;
|
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;
|
if (fc.startsWith(s_using) || !(fc.contains(' ') || fc.contains('\t') || fc.contains('\n'))) return true;
|
||||||
int bits = extractMemberBits(fc);
|
int bits = extractMemberBits(fc);
|
||||||
tl = fc.split(',');
|
tl = fc.split(',');
|
||||||
// piCout << "member" << fc << tl;
|
|
||||||
// piCout << "member after eb" << fc << ", bits =" << bits;
|
// piCout << "member after eb" << fc << ", bits =" << bits;
|
||||||
if (tl.isEmpty()) return true;
|
if (tl.isEmpty()) return true;
|
||||||
for (auto & v: tl)
|
for (auto & v: tl)
|
||||||
removeAssignment(v);
|
removeAssignment(v);
|
||||||
bool vn = true;
|
// piCout << "member" << tl;
|
||||||
ctemp = tl.front().trim();
|
ctemp = s_s5 + tl.front().trim();
|
||||||
PIString meta_t;
|
PIString meta_t;
|
||||||
if (ctemp.contains(s_M)) {
|
if (ctemp.contains(s_M)) {
|
||||||
meta_t = ctemp.takeMid(ctemp.find(s_M), 5);
|
meta_t = ctemp.takeMid(ctemp.find(s_M), 5);
|
||||||
ctemp.trim();
|
ctemp.trim();
|
||||||
}
|
}
|
||||||
for (ts = ctemp.size_s() - 1; ts > 0; --ts) {
|
if (ctemp.find(s_s_const_s) >= 0) {
|
||||||
if (vn) {
|
me.attributes |= Const;
|
||||||
if (!_isCChar(ctemp[ts]) && !ctemp[ts].isDigit() && ctemp[ts] != '[' && ctemp[ts] != ']') vn = false;
|
ctemp.replaceAll(s_s_const_s, ' ');
|
||||||
} else {
|
|
||||||
if (_isCChar(ctemp[ts]) || ctemp[ts].isDigit()) break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
me.type = ctemp.takeLeft(ts + 1);
|
if (ctemp.find(s_s_static_s) >= 0) {
|
||||||
|
me.attributes |= Static;
|
||||||
|
ctemp.replaceAll(s_s_static_s, ' ');
|
||||||
|
}
|
||||||
|
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;
|
me.visibility = cur_def_vis;
|
||||||
ctemp += meta_t;
|
ctemp += meta_t;
|
||||||
restoreTmpTemp(&me);
|
// me.type = s_s5 + me.type;
|
||||||
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, ' ');
|
|
||||||
}
|
|
||||||
type.trim();
|
type.trim();
|
||||||
normalizeEntityNamespace(type);
|
normalizeEntityNamespace(type);
|
||||||
tl[0] = ctemp.trim();
|
tl[0] = ctemp.trim();
|
||||||
|
// piCout << "type" << type;
|
||||||
// piCout << "vars" << tl;
|
// piCout << "vars" << tl;
|
||||||
for (const auto & v: tl) {
|
for (const auto & v: tl) {
|
||||||
crepl.clear();
|
crepl.clear();
|
||||||
@@ -972,6 +963,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|||||||
}
|
}
|
||||||
// PICout(PICoutManipulators::AddAll) << "var" << me.type << me.name << me.bits;
|
// PICout(PICoutManipulators::AddAll) << "var" << me.type << me.name << me.bits;
|
||||||
// piCout << "var" << v << me.type << me.name << me.bits;
|
// piCout << "var" << v << me.type << me.name << me.bits;
|
||||||
|
restoreTmpTemp(&me);
|
||||||
parent->members << me;
|
parent->members << me;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,12 @@ public:
|
|||||||
static PIJSON newArray(const PIVariantVector & fields = {});
|
static PIJSON newArray(const PIVariantVector & fields = {});
|
||||||
static PIJSON newString(const PIString & v = PIString());
|
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:
|
private:
|
||||||
static PIJSON & nullEntry();
|
static PIJSON & nullEntry();
|
||||||
static PIString parseName(PIString & s);
|
static PIString parseName(PIString & s);
|
||||||
|
|||||||
@@ -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
|
#endif // pijsonserialization_h
|
||||||
|
|||||||
Reference in New Issue
Block a user