Add parents (de)serialization in pip_cmg
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
|
||||
bool writeClassJSONMembersOut(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) var_prefix += ".";
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
writeClassJSONMembersOut(rt, p, var_prefix);
|
||||
}
|
||||
PIVector<PICodeParser::Member> ml;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -57,16 +61,16 @@ bool writeClassJSONMembersOut(Runtime & rt, const PICodeParser::Entity * e, PISt
|
||||
if (is_union) break;
|
||||
}
|
||||
if (is_union) return true;
|
||||
/*for (const PICodeParser::Entity * ce: e->children) {
|
||||
if (!ce->is_anonymous) continue;
|
||||
if (!writeClassJSONMembersOut(rt, ce)) return false;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool writeClassJSONMembersIn(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) var_prefix += ".";
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
writeClassJSONMembersIn(rt, p, var_prefix);
|
||||
}
|
||||
PIVector<PICodeParser::Member> ml;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -105,10 +109,6 @@ bool writeClassJSONMembersIn(Runtime & rt, const PICodeParser::Entity * e, PIStr
|
||||
if (is_union) break;
|
||||
}
|
||||
if (is_union) return true;
|
||||
/*for (const PICodeParser::Entity * ce: e->children) {
|
||||
if (!ce->is_anonymous) continue;
|
||||
if (!writeClassJSONMembersIn(rt, ce)) return false;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,10 @@ bool needClassJSON(const PICodeParser::Entity * e) {
|
||||
if (m.meta.value("id") == "-") continue;
|
||||
return true;
|
||||
}
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
if (needClassJSON(p)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user