Add parents (de)serialization in pip_cmg
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
|
||||
void writeGetterTypeMembers(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;
|
||||
writeGetterTypeMembers(rt, p, var_prefix);
|
||||
}
|
||||
PISet<int> used_id;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || !m.dims.isEmpty() || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -43,6 +47,10 @@ void writeGetterTypeMembers(Runtime & rt, const PICodeParser::Entity * e, PIStri
|
||||
|
||||
void writeGetterValueMembers(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;
|
||||
writeGetterValueMembers(rt, p, var_prefix);
|
||||
}
|
||||
PISet<int> used_id;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || !m.dims.isEmpty() || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -65,6 +73,10 @@ void writeGetterValueMembers(Runtime & rt, const PICodeParser::Entity * e, PIStr
|
||||
|
||||
void writeGetterOffsetMembers(Runtime & rt, const PICodeParser::Entity * e, PIString entity_name, PIString var_prefix) {
|
||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) var_prefix += ".";
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
writeGetterOffsetMembers(rt, p, entity_name, var_prefix);
|
||||
}
|
||||
PISet<int> used_id;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || !m.dims.isEmpty() || m.isBitfield() || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -117,5 +129,9 @@ bool needClassGetter(const PICodeParser::Entity * e) {
|
||||
if (m.attributes[PICodeParser::Static]) continue;
|
||||
return true;
|
||||
}
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
if (needClassGetter(p)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
|
||||
void writeClassInfoMembers(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;
|
||||
writeClassInfoMembers(rt, p, var_prefix);
|
||||
}
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
auto type = findEntity(rt, m.type);
|
||||
if (type) {
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
bool writeClassStreamMembersOut(Runtime & rt, const PICodeParser::Entity * e, int & cnt, bool simple, PIString var_prefix) {
|
||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) var_prefix += ".";
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
if (!writeClassStreamMembersOut(rt, p, cnt, simple, var_prefix)) return false;
|
||||
}
|
||||
PIVector<PICodeParser::Member> ml;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -83,6 +87,10 @@ bool writeClassStreamMembersOut(Runtime & rt, const PICodeParser::Entity * e, in
|
||||
|
||||
bool writeClassStreamMembersIn(Runtime & rt, const PICodeParser::Entity * e, int & cnt, bool simple, PIString var_prefix) {
|
||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) var_prefix += ".";
|
||||
for (const PICodeParser::Entity * p: e->parents) {
|
||||
if (p->is_anonymous) continue;
|
||||
if (!writeClassStreamMembersIn(rt, p, cnt, simple, var_prefix)) return false;
|
||||
}
|
||||
PIVector<PICodeParser::Member> ml;
|
||||
for (const PICodeParser::Member & m: e->members) {
|
||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
||||
@@ -166,6 +174,10 @@ bool needClassStream(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 (needClassStream(p)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user