Add parents (de)serialization in pip_cmg #206
@@ -580,6 +580,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
|||||||
static const PIString s_ss = PIStringAscii(" ");
|
static const PIString s_ss = PIStringAscii(" ");
|
||||||
static const PIString s_M = PIStringAscii("$M");
|
static const PIString s_M = PIStringAscii("$M");
|
||||||
static const PIString s_class = PIStringAscii("class");
|
static const PIString s_class = PIStringAscii("class");
|
||||||
|
static const PIString s_public = PIStringAscii("public");
|
||||||
PIString cd = fc.trimmed().removeAll('\n').replaceAll('\t', ' ').replaceAll(s_ss, ' '), pn;
|
PIString cd = fc.trimmed().removeAll('\n').replaceAll('\t', ' ').replaceAll(s_ss, ' '), pn;
|
||||||
MetaMap meta;
|
MetaMap meta;
|
||||||
int ind = cd.find(s_M);
|
int ind = cd.find(s_M);
|
||||||
@@ -587,18 +588,25 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
|||||||
meta = tmp_meta.value(cd.takeMid(ind, 5));
|
meta = tmp_meta.value(cd.takeMid(ind, 5));
|
||||||
cd.replaceAll(s_ss, ' ');
|
cd.replaceAll(s_ss, ' ');
|
||||||
}
|
}
|
||||||
// piCout << "found class <****\n" << cd << "\n****>";
|
PIString typename_ = cd.left(6).trim();
|
||||||
|
bool is_class = typename_ == s_class;
|
||||||
ind = cd.find(':');
|
ind = cd.find(':');
|
||||||
|
// piCout << "found class <****\n" << cd << "\n****>";
|
||||||
PIVector<Entity *> parents;
|
PIVector<Entity *> parents;
|
||||||
if (ind > 0) {
|
if (ind > 0) {
|
||||||
PIStringList pl = cd.takeMid(ind + 1).trim().split(',');
|
PIStringList pl = cd.takeMid(ind + 1).trim().split(',');
|
||||||
cd.cutRight(1);
|
cd.cutRight(1);
|
||||||
Entity * pe = 0;
|
Entity * pe = 0;
|
||||||
for (const auto & p: pl) {
|
for (const auto & p: pl) {
|
||||||
if (p.contains(' '))
|
PIString access;
|
||||||
|
if (p.contains(' ')) {
|
||||||
|
access = p.left(p.find(' ')).trim();
|
||||||
pn = p.mid(p.find(' ') + 1);
|
pn = p.mid(p.find(' ') + 1);
|
||||||
else
|
} else {
|
||||||
pn = p;
|
pn = p;
|
||||||
|
}
|
||||||
|
bool is_public = access.isEmpty() ? !is_class : access == s_public;
|
||||||
|
if (!is_public) continue;
|
||||||
pe = findEntityByName(pn);
|
pe = findEntityByName(pn);
|
||||||
if (pe == 0)
|
if (pe == 0)
|
||||||
; //{piCout << "Error: can`t find" << pn;}
|
; //{piCout << "Error: can`t find" << pn;}
|
||||||
@@ -606,8 +614,6 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
|||||||
parents << pe;
|
parents << pe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PIString typename_ = cd.left(6).trim();
|
|
||||||
bool is_class = typename_ == s_class;
|
|
||||||
Visibility vis = cur_def_vis;
|
Visibility vis = cur_def_vis;
|
||||||
cur_def_vis = (is_class ? Private : Public);
|
cur_def_vis = (is_class ? Private : Public);
|
||||||
PIString cn = cd.mid(6).trim();
|
PIString cn = cd.mid(6).trim();
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
void writeGetterTypeMembers(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
void writeGetterTypeMembers(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PISet<int> used_id;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || !m.dims.isEmpty() || (m.visibility != PICodeParser::Public)) continue;
|
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) {
|
void writeGetterValueMembers(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PISet<int> used_id;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || !m.dims.isEmpty() || (m.visibility != PICodeParser::Public)) continue;
|
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) {
|
void writeGetterOffsetMembers(Runtime & rt, const PICodeParser::Entity * e, PIString entity_name, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PISet<int> used_id;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || !m.dims.isEmpty() || m.isBitfield() || (m.visibility != PICodeParser::Public)) continue;
|
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;
|
if (m.attributes[PICodeParser::Static]) continue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
for (const PICodeParser::Entity * p: e->parents) {
|
||||||
|
if (p->is_anonymous) continue;
|
||||||
|
if (needClassGetter(p)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
bool writeClassJSONMembersOut(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
bool writeClassJSONMembersOut(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PIVector<PICodeParser::Member> ml;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
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) break;
|
||||||
}
|
}
|
||||||
if (is_union) return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool writeClassJSONMembersIn(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
bool writeClassJSONMembersIn(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PIVector<PICodeParser::Member> ml;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
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) break;
|
||||||
}
|
}
|
||||||
if (is_union) return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +121,10 @@ bool needClassJSON(const PICodeParser::Entity * e) {
|
|||||||
if (m.meta.value("id") == "-") continue;
|
if (m.meta.value("id") == "-") continue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
for (const PICodeParser::Entity * p: e->parents) {
|
||||||
|
if (p->is_anonymous) continue;
|
||||||
|
if (needClassJSON(p)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
|
|
||||||
void writeClassInfoMembers(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
void writeClassInfoMembers(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
auto type = findEntity(rt, m.type);
|
auto type = findEntity(rt, m.type);
|
||||||
if (type) {
|
if (type) {
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
bool writeClassStreamMembersOut(Runtime & rt, const PICodeParser::Entity * e, int & cnt, bool simple, PIString var_prefix) {
|
bool writeClassStreamMembersOut(Runtime & rt, const PICodeParser::Entity * e, int & cnt, bool simple, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PIVector<PICodeParser::Member> ml;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
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) {
|
bool writeClassStreamMembersIn(Runtime & rt, const PICodeParser::Entity * e, int & cnt, bool simple, PIString var_prefix) {
|
||||||
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) 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;
|
PIVector<PICodeParser::Member> ml;
|
||||||
for (const PICodeParser::Member & m: e->members) {
|
for (const PICodeParser::Member & m: e->members) {
|
||||||
if (m.is_type_ptr || (m.visibility != PICodeParser::Public)) continue;
|
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;
|
if (m.meta.value("id") == "-") continue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
for (const PICodeParser::Entity * p: e->parents) {
|
||||||
|
if (p->is_anonymous) continue;
|
||||||
|
if (needClassStream(p)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user