|
|
|
|
@@ -108,7 +108,7 @@ void PICodeParser::parseFile(const PIString & file, bool follow_includes) {
|
|
|
|
|
piForeachC (Enum & c, enums) {
|
|
|
|
|
piCout << PIStringAscii("enum") << c.name << c.meta;
|
|
|
|
|
piForeachC (EnumeratorInfo & e, c.members)
|
|
|
|
|
piCout << " " << e.name << "=" << e.value << e.meta;
|
|
|
|
|
piCout << " " << e.name << '=' << e.value << e.meta;
|
|
|
|
|
}
|
|
|
|
|
piCout << "\n\nTypedefs:";
|
|
|
|
|
piForeachC (Typedef & c, typedefs)
|
|
|
|
|
@@ -119,7 +119,7 @@ void PICodeParser::parseFile(const PIString & file, bool follow_includes) {
|
|
|
|
|
void PICodeParser::parseFiles(const PIStringList & files, bool follow_includes) {
|
|
|
|
|
clear();
|
|
|
|
|
piForeachC (PIString & f, files)
|
|
|
|
|
parseFileInternal(f, follow_includes);
|
|
|
|
|
parseFileInternal(f, follow_includes);
|
|
|
|
|
/*piCout << "\n\nDefines:";
|
|
|
|
|
piForeachC (Define & m, defines)
|
|
|
|
|
piCout << PIStringAscii("define") << m.first << m.second;
|
|
|
|
|
@@ -277,11 +277,11 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
|
|
|
|
int nl = pfc.size_s();
|
|
|
|
|
if (pl == nl) break;
|
|
|
|
|
pl = nl;
|
|
|
|
|
if (pfc.left(9) == "namespace") {
|
|
|
|
|
if (pfc.left(9) == PIStringAscii("namespace")) {
|
|
|
|
|
pfc.cutLeft(pfc.find('{') + 1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (pfc.left(8) == "template") {
|
|
|
|
|
if (pfc.left(8) == PIStringAscii("template")) {
|
|
|
|
|
pfc.cutLeft(8);
|
|
|
|
|
pfc.takeRange('<', '>');
|
|
|
|
|
bool def = !isDeclaration(pfc, 0, &end);
|
|
|
|
|
@@ -290,11 +290,11 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
|
|
|
|
else pfc.takeSymbol();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (pfc.left(5) == PIStringAscii("class") || pfc.left(6) == "struct" || pfc.left(5) == "union") {
|
|
|
|
|
if (pfc.left(5) == PIStringAscii("class") || pfc.left(6) == PIStringAscii("struct") || pfc.left(5) == PIStringAscii("union")) {
|
|
|
|
|
int dind = pfc.find('{', 0), find = pfc.find(';', 0);
|
|
|
|
|
if (dind < 0 && find < 0) {pfc.cutLeft(6); continue;}
|
|
|
|
|
if (dind < 0 || find < dind) {pfc.cutLeft(6); continue;}
|
|
|
|
|
ccmn = pfc.left(dind) + "{\n" + pfc.mid(dind).takeRange('{', '}') + "\n}\n";
|
|
|
|
|
ccmn = pfc.left(dind) + PIStringAscii("{\n") + pfc.mid(dind).takeRange('{', '}') + PIStringAscii("\n}\n");
|
|
|
|
|
pfc.remove(0, ccmn.size());
|
|
|
|
|
parseClass(0, ccmn);
|
|
|
|
|
continue;
|
|
|
|
|
@@ -363,7 +363,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
|
|
|
|
cur_def_vis = (is_class ? Private : Public);
|
|
|
|
|
PIString cn = cd.mid(6).trim();
|
|
|
|
|
bool has_name = !cn.isEmpty();
|
|
|
|
|
if (cn.isEmpty()) cn = "<unnamed_" + PIString::fromNumber(anon_num++) + '>';
|
|
|
|
|
if (cn.isEmpty()) cn = PIStringAscii("<unnamed_") + PIString::fromNumber(anon_num++) + '>';
|
|
|
|
|
//piCout << "found " << typename_ << cn;
|
|
|
|
|
if (cn.isEmpty()) return 0;
|
|
|
|
|
Entity * e = new Entity();
|
|
|
|
|
@@ -393,7 +393,7 @@ PIString PICodeParser::parseClass(Entity * parent, PIString & fc) {
|
|
|
|
|
int ps = -1;
|
|
|
|
|
bool def = false;
|
|
|
|
|
PIString prev_namespace = cur_namespace, stmp;
|
|
|
|
|
cur_namespace = ce->name + "::";
|
|
|
|
|
cur_namespace = ce->name + PIStringAscii("::");
|
|
|
|
|
//piCout << "parse class" << ce->name << "namespace" << cur_namespace;
|
|
|
|
|
//piCout << "\nparse class" << ce->name << "namespace" << cur_namespace;
|
|
|
|
|
while (!fc.isEmpty()) {
|
|
|
|
|
@@ -425,7 +425,7 @@ PIString PICodeParser::parseClass(Entity * parent, PIString & fc) {
|
|
|
|
|
}
|
|
|
|
|
if (cw == PIStringAscii("friend")) {fc.cutLeft(fc.find(';') + 1); continue;}
|
|
|
|
|
if (cw == PIStringAscii("typedef")) {ce->typedefs << parseTypedef(fc.takeLeft(fc.find(';'))); typedefs << ce->typedefs.back(); typedefs.back().first.insert(0, cur_namespace); if (ce->typedefs.back().first.isEmpty()) ce->typedefs.pop_back(); fc.takeSymbol(); continue;}
|
|
|
|
|
if (cw == "template") {
|
|
|
|
|
if (cw == PIStringAscii("template")) {
|
|
|
|
|
fc.takeRange('<', '>');
|
|
|
|
|
def = !isDeclaration(fc, 0, &end);
|
|
|
|
|
fc.cutLeft(end);
|
|
|
|
|
@@ -453,7 +453,7 @@ PICodeParser::MetaMap PICodeParser::parseMeta(PIString & fc) {
|
|
|
|
|
if (fc.isEmpty()) return ret;
|
|
|
|
|
PIStringList ml = fc.split(',');
|
|
|
|
|
piForeachC (PIString & m, ml) {
|
|
|
|
|
int i = m.find("=");
|
|
|
|
|
int i = m.find('=');
|
|
|
|
|
if (i < 0) continue;
|
|
|
|
|
PIString mv = m.mid(i + 1).trim();
|
|
|
|
|
if (mv.startsWith('\"')) mv.cutLeft(1);
|
|
|
|
|
@@ -466,6 +466,8 @@ PICodeParser::MetaMap PICodeParser::parseMeta(PIString & fc) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool PICodeParser::parseEnum(Entity * parent, const PIString & name, PIString fc, const MetaMap & meta) {
|
|
|
|
|
static const PIString s_ss = PIStringAscii(" ");
|
|
|
|
|
static const PIString s_M = PIStringAscii("$M");
|
|
|
|
|
//piCout << PIStringAscii("enum") << name << fc;
|
|
|
|
|
Enum e(name);
|
|
|
|
|
e.meta = meta;
|
|
|
|
|
@@ -474,12 +476,12 @@ bool PICodeParser::parseEnum(Entity * parent, const PIString & name, PIString fc
|
|
|
|
|
int cv = -1, ind = 0;
|
|
|
|
|
piForeach (PIString & v, vl) {
|
|
|
|
|
MetaMap meta;
|
|
|
|
|
int mi = v.find(PIStringAscii("$M"));
|
|
|
|
|
int mi = v.find(s_M);
|
|
|
|
|
if (mi >= 0) {
|
|
|
|
|
meta = tmp_meta.value(v.takeMid(mi, 5));
|
|
|
|
|
v.replaceAll(" ", ' ');
|
|
|
|
|
v.replaceAll(s_ss, ' ');
|
|
|
|
|
}
|
|
|
|
|
vn = v; ind = v.find("=");
|
|
|
|
|
vn = v; ind = v.find('=');
|
|
|
|
|
if (ind > 0) {cv = v.right(v.size_s() - ind - 1).toInt(); vn = v.left(ind);}
|
|
|
|
|
if (ind < 0) ++cv;
|
|
|
|
|
e.members << EnumeratorInfo(vn.trim(), cv, meta);
|
|
|
|
|
@@ -512,8 +514,27 @@ PICodeParser::Typedef PICodeParser::parseTypedef(PIString fc) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|
|
|
|
static const PIString s_operator = PIStringAscii("operator");
|
|
|
|
|
static const PIString s_ss = PIStringAscii(" ");
|
|
|
|
|
static const PIString s_cs = PIStringAscii(", ");
|
|
|
|
|
static const PIString s_sb = PIStringAscii(" (");
|
|
|
|
|
static const PIString s_sM = PIStringAscii(" $M");
|
|
|
|
|
static const PIString s_M = PIStringAscii("$M");
|
|
|
|
|
static const PIString s_T = PIStringAscii("$T");
|
|
|
|
|
static const PIString s_inline_s = PIStringAscii("inline ");
|
|
|
|
|
static const PIString s_static_s = PIStringAscii("static ");
|
|
|
|
|
static const PIString s_virtual_s = PIStringAscii("virtual ");
|
|
|
|
|
static const PIString s_void = PIStringAscii("void");
|
|
|
|
|
static const PIString s_using = PIStringAscii("using");
|
|
|
|
|
static const PIString s_s5 = PIStringAscii(" ");
|
|
|
|
|
static const PIString s_s_const_s = PIStringAscii(" const ");
|
|
|
|
|
static const PIString s_s_static_s = PIStringAscii(" static ");
|
|
|
|
|
static const PIString s_s_mutable_s = PIStringAscii(" mutable ");
|
|
|
|
|
static const PIString s_s_volatile_s = PIStringAscii(" volatile ");
|
|
|
|
|
static const PIString s_s_extern_s = PIStringAscii(" extern ");
|
|
|
|
|
|
|
|
|
|
if (fc.trim().isEmpty()) return true;
|
|
|
|
|
if (fc.find("operator") >= 0) return true;
|
|
|
|
|
if (fc.find(s_operator) >= 0) return true;
|
|
|
|
|
tmp_temp.clear();
|
|
|
|
|
//piCout << "parse member" << fc;
|
|
|
|
|
int ts = fc.find('<'), te = 0;
|
|
|
|
|
@@ -521,22 +542,22 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|
|
|
|
while (ts >= 0) {
|
|
|
|
|
ctemp = fc.mid(ts).takeRange('<', '>');
|
|
|
|
|
if (ctemp.isEmpty()) {te = ts + 1; ts = fc.find('<', te); continue;}
|
|
|
|
|
crepl = PIStringAscii("$T") + PIString::fromNumber(tmp_temp.size_s()).expandLeftTo(3, '0');
|
|
|
|
|
crepl = s_T + PIString::fromNumber(tmp_temp.size_s()).expandLeftTo(3, '0');
|
|
|
|
|
fc.replace(ts, ctemp.size_s() + 2, crepl);
|
|
|
|
|
tmp_temp[crepl] = '<' + ctemp + '>';
|
|
|
|
|
ts = fc.find('<', te);
|
|
|
|
|
}
|
|
|
|
|
fc.replaceAll('\n', ' ').replaceAll('\t', ' ').replaceAll(" ", ' ').replaceAll(", ", ',').replaceAll(PIStringAscii(" ("), '(').replaceAll(PIStringAscii(" $M"), PIStringAscii("$M"));
|
|
|
|
|
fc.replaceAll('\n', ' ').replaceAll('\t', ' ').replaceAll(s_ss, ' ').replaceAll(s_cs, ',').replaceAll(s_sb, '(').replaceAll(s_sM, s_M);
|
|
|
|
|
//piCout << "parse member" << fc;
|
|
|
|
|
PIStringList tl, al;
|
|
|
|
|
Member me;
|
|
|
|
|
//piCout << fc;
|
|
|
|
|
if (fc.contains('(')) {
|
|
|
|
|
MetaMap meta;
|
|
|
|
|
int ind = fc.find(PIStringAscii("$M"));
|
|
|
|
|
int ind = fc.find(s_M);
|
|
|
|
|
if (ind >= 0) {
|
|
|
|
|
meta = tmp_meta.value(fc.takeMid(ind, 5));
|
|
|
|
|
fc.replaceAll(PIStringAscii(" "), ' ').replaceAll(PIStringAscii(" ("), '(');
|
|
|
|
|
fc.replaceAll(s_ss, ' ').replaceAll(s_sb, '(');
|
|
|
|
|
}
|
|
|
|
|
fc.cutRight(fc.size_s() - fc.findLast(')') - 1);
|
|
|
|
|
te = fc.find('(');
|
|
|
|
|
@@ -550,26 +571,26 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|
|
|
|
me.arguments_full = fc.takeMid(ts + 2).cutRight(1).split(',');
|
|
|
|
|
me.type = fc.cutRight(1).trim();
|
|
|
|
|
me.visibility = cur_def_vis;
|
|
|
|
|
if (me.type.find(PIStringAscii("inline ")) >= 0) {
|
|
|
|
|
if (me.type.find(s_inline_s) >= 0) {
|
|
|
|
|
me.attributes |= Inline;
|
|
|
|
|
me.type.removeAll(PIStringAscii("inline "));
|
|
|
|
|
me.type.removeAll(s_inline_s);
|
|
|
|
|
}
|
|
|
|
|
if (me.type.find(PIStringAscii("static ")) >= 0) {
|
|
|
|
|
if (me.type.find(s_static_s) >= 0) {
|
|
|
|
|
me.attributes |= Static;
|
|
|
|
|
me.type.removeAll(PIStringAscii("static "));
|
|
|
|
|
me.type.removeAll(s_static_s);
|
|
|
|
|
}
|
|
|
|
|
if (me.type.find(PIStringAscii("virtual ")) >= 0) {
|
|
|
|
|
if (me.type.find(s_virtual_s) >= 0) {
|
|
|
|
|
me.attributes |= Virtual;
|
|
|
|
|
me.type.removeAll(PIStringAscii("virtual "));
|
|
|
|
|
me.type.removeAll(s_virtual_s);
|
|
|
|
|
}
|
|
|
|
|
normalizeEntityNamespace(me.type);
|
|
|
|
|
int i = 0;
|
|
|
|
|
//piCout << me.arguments_full;
|
|
|
|
|
piForeach (PIString & a, me.arguments_full)
|
|
|
|
|
if ((i = a.find("=")) > 0)
|
|
|
|
|
if ((i = a.find('=')) > 0)
|
|
|
|
|
a.cutRight(a.size_s() - i).trim();
|
|
|
|
|
for (int j = 0; j < me.arguments_full.size_s(); ++j)
|
|
|
|
|
if (me.arguments_full[j] == PIStringAscii("void")) {
|
|
|
|
|
if (me.arguments_full[j] == s_void) {
|
|
|
|
|
me.arguments_full.remove(j);
|
|
|
|
|
--j;
|
|
|
|
|
}
|
|
|
|
|
@@ -590,7 +611,7 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|
|
|
|
parent->functions << me;
|
|
|
|
|
} else {
|
|
|
|
|
if (fc.endsWith(';')) fc.cutRight(1);
|
|
|
|
|
if (fc.startsWith(PIStringAscii("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);
|
|
|
|
|
tl = fc.split(',');
|
|
|
|
|
//piCout << "member" << fc << tl;
|
|
|
|
|
@@ -599,8 +620,8 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|
|
|
|
bool vn = true;
|
|
|
|
|
ctemp = tl.front().trim();
|
|
|
|
|
PIString meta_t;
|
|
|
|
|
if (ctemp.contains(PIStringAscii("$M")))
|
|
|
|
|
meta_t = ctemp.takeMid(ctemp.find(PIStringAscii("$M")));
|
|
|
|
|
if (ctemp.contains(s_M))
|
|
|
|
|
meta_t = ctemp.takeMid(ctemp.find(s_M));
|
|
|
|
|
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;}
|
|
|
|
|
@@ -609,26 +630,26 @@ bool PICodeParser::parseMember(Entity * parent, PIString & fc) {
|
|
|
|
|
me.visibility = cur_def_vis;
|
|
|
|
|
ctemp += meta_t;
|
|
|
|
|
restoreTmpTemp(&me);
|
|
|
|
|
PIString type = PIStringAscii(" ") + me.type;
|
|
|
|
|
if (type.find(PIStringAscii(" const ")) >= 0) {
|
|
|
|
|
PIString type = s_s5 + me.type;
|
|
|
|
|
if (type.find(s_s_const_s) >= 0) {
|
|
|
|
|
me.attributes |= Const;
|
|
|
|
|
type.replaceAll(PIStringAscii(" const "), ' ');
|
|
|
|
|
type.replaceAll(s_s_const_s, ' ');
|
|
|
|
|
}
|
|
|
|
|
if (type.find(PIStringAscii(" static ")) >= 0) {
|
|
|
|
|
if (type.find(s_s_static_s) >= 0) {
|
|
|
|
|
me.attributes |= Static;
|
|
|
|
|
type.replaceAll(PIStringAscii(" static "), ' ');
|
|
|
|
|
type.replaceAll(s_s_static_s, ' ');
|
|
|
|
|
}
|
|
|
|
|
if (type.find(PIStringAscii(" mutable ")) >= 0) {
|
|
|
|
|
if (type.find(s_s_mutable_s) >= 0) {
|
|
|
|
|
me.attributes |= Mutable;
|
|
|
|
|
type.replaceAll(PIStringAscii(" mutable "), ' ');
|
|
|
|
|
type.replaceAll(s_s_mutable_s, ' ');
|
|
|
|
|
}
|
|
|
|
|
if (type.find(PIStringAscii(" volatile ")) >= 0) {
|
|
|
|
|
if (type.find(s_s_volatile_s) >= 0) {
|
|
|
|
|
me.attributes |= Volatile;
|
|
|
|
|
type.replaceAll(PIStringAscii(" volatile "), ' ');
|
|
|
|
|
type.replaceAll(s_s_volatile_s, ' ');
|
|
|
|
|
}
|
|
|
|
|
if (type.find(PIStringAscii(" extern ")) >= 0) {
|
|
|
|
|
if (type.find(s_s_extern_s) >= 0) {
|
|
|
|
|
me.attributes |= Extern;
|
|
|
|
|
type.replaceAll(PIStringAscii(" extern "), ' ');
|
|
|
|
|
type.replaceAll(s_s_extern_s, ' ');
|
|
|
|
|
}
|
|
|
|
|
type.trim();
|
|
|
|
|
normalizeEntityNamespace(type);
|
|
|
|
|
@@ -677,6 +698,14 @@ int PICodeParser::extractMemberBits(PIString & fc) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PICodeParser::normalizeEntityNamespace(PIString & n) {
|
|
|
|
|
static const PIString s_const_s = PIStringAscii("const ");
|
|
|
|
|
static const PIString s_static_s = PIStringAscii("static ");
|
|
|
|
|
static const PIString s_mutable_s = PIStringAscii("mutable ");
|
|
|
|
|
static const PIString s_volatile_s = PIStringAscii("volatile ");
|
|
|
|
|
static const PIString s_s_const_s = PIStringAscii(" const ");
|
|
|
|
|
static const PIString s_s_static_s = PIStringAscii(" static ");
|
|
|
|
|
static const PIString s_s_mutable_s = PIStringAscii(" mutable ");
|
|
|
|
|
static const PIString s_s_volatile_s = PIStringAscii(" volatile ");
|
|
|
|
|
PIString suff, pref;
|
|
|
|
|
for (int i = n.size_s() - 1; i > 0; --i)
|
|
|
|
|
if (_isCChar(n[i]) || n[i].isDigit()) {
|
|
|
|
|
@@ -685,10 +714,10 @@ void PICodeParser::normalizeEntityNamespace(PIString & n) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
n.push_front(' ');
|
|
|
|
|
if (n.find(PIStringAscii(" static ")) >= 0) {n.replaceAll(PIStringAscii(" static "), ""); pref += PIStringAscii("static ");}
|
|
|
|
|
if (n.find(PIStringAscii(" const ")) >= 0) {n.replaceAll(PIStringAscii(" const "), ""); pref += PIStringAscii("const ");}
|
|
|
|
|
if (n.find(PIStringAscii(" mutable ")) >= 0) {n.replaceAll(PIStringAscii(" mutable "), ""); pref += PIStringAscii("mutable ");}
|
|
|
|
|
if (n.find(PIStringAscii(" volatile ")) >= 0) {n.replaceAll(PIStringAscii(" volatile "), ""); pref += PIStringAscii("volatile ");}
|
|
|
|
|
if (n.find(s_s_const_s) >= 0) {n.replaceAll(s_s_const_s, ""); pref += s_const_s;}
|
|
|
|
|
if (n.find(s_s_static_s) >= 0) {n.replaceAll(s_s_static_s, ""); pref += s_static_s;}
|
|
|
|
|
if (n.find(s_s_mutable_s) >= 0) {n.replaceAll(s_s_mutable_s, ""); pref += s_mutable_s;}
|
|
|
|
|
if (n.find(s_s_volatile_s) >= 0) {n.replaceAll(s_s_volatile_s, ""); pref += s_volatile_s;}
|
|
|
|
|
n.trim();
|
|
|
|
|
int f = 0;
|
|
|
|
|
piForeachC (Entity * e, entities) {
|
|
|
|
|
@@ -697,27 +726,29 @@ void PICodeParser::normalizeEntityNamespace(PIString & n) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((f = e->name.find(n)) >= 0)
|
|
|
|
|
if (e->name.mid(f - 1, 1) == PIChar(':'))
|
|
|
|
|
if (e->name.at(f - 1) == PIChar(':'))
|
|
|
|
|
if (e->name.find(cur_namespace) >= 0) {
|
|
|
|
|
n = pref + e->name + suff;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
piForeachC (Enum & e, enums)
|
|
|
|
|
if ((f = e.name.find(n)) >= 0)
|
|
|
|
|
if (e.name.mid(f - 1, 1) == PIChar(':'))
|
|
|
|
|
if (e.name.find(cur_namespace) >= 0) {
|
|
|
|
|
//piCout << "change" << n << "to" << e.name + suff;
|
|
|
|
|
n = pref + e.name + suff;
|
|
|
|
|
return;
|
|
|
|
|
piForeachC (Enum & e, enums) {
|
|
|
|
|
if ((f = e.name.find(n)) >= 0)
|
|
|
|
|
if (e.name.at(f - 1) == PIChar(':'))
|
|
|
|
|
if (e.name.find(cur_namespace) >= 0) {
|
|
|
|
|
//piCout << "change" << n << "to" << e.name + suff;
|
|
|
|
|
n = pref + e.name + suff;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
piForeachC (Typedef & e, typedefs)
|
|
|
|
|
if ((f = e.first.find(n)) >= 0)
|
|
|
|
|
if (e.first.mid(f - 1, 1) == PIChar(':'))
|
|
|
|
|
if (e.first.find(cur_namespace) >= 0) {
|
|
|
|
|
//piCout << "change" << n << "to" << e.name + suff;
|
|
|
|
|
n = pref + e.first + suff;
|
|
|
|
|
return;
|
|
|
|
|
piForeachC (Typedef & e, typedefs) {
|
|
|
|
|
if ((f = e.first.find(n)) >= 0)
|
|
|
|
|
if (e.first.at(f - 1) == PIChar(':'))
|
|
|
|
|
if (e.first.find(cur_namespace) >= 0) {
|
|
|
|
|
//piCout << "change" << n << "to" << e.name + suff;
|
|
|
|
|
n = pref + e.first + suff;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
n = (pref + n + suff).trim();
|
|
|
|
|
}
|
|
|
|
|
@@ -864,9 +895,9 @@ bool PICodeParser::isDeclaration(const PIString & fc, int start, int * end) {
|
|
|
|
|
bool PICodeParser::isMainFile(const PIString & fc) {
|
|
|
|
|
int si = 0;
|
|
|
|
|
while (si >= 0) {
|
|
|
|
|
int csi = fc.find(" main", si);
|
|
|
|
|
if (csi < 0) csi = fc.find("\tmain", si);
|
|
|
|
|
if (csi < 0) csi = fc.find("\nmain", si);
|
|
|
|
|
int csi = fc.find(PIStringAscii(" main"), si);
|
|
|
|
|
if (csi < 0) csi = fc.find(PIStringAscii("\tmain"), si);
|
|
|
|
|
if (csi < 0) csi = fc.find(PIStringAscii("\nmain"), si);
|
|
|
|
|
if (csi < 0) return false;
|
|
|
|
|
si = csi;
|
|
|
|
|
int fi = fc.find('(', si + 5);
|
|
|
|
|
@@ -874,7 +905,7 @@ bool PICodeParser::isMainFile(const PIString & fc) {
|
|
|
|
|
if (fi - si < 10) {
|
|
|
|
|
PIString ms(fc.mid(si, fi - si + 1));
|
|
|
|
|
ms.removeAll(' ').removeAll('\t').removeAll('\n');
|
|
|
|
|
if (ms == "main(") return true;
|
|
|
|
|
if (ms == PIStringAscii("main(")) return true;
|
|
|
|
|
}
|
|
|
|
|
si += 5;
|
|
|
|
|
}
|
|
|
|
|
@@ -925,7 +956,7 @@ PIString PICodeParser::procMacros(PIString fc) {
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (mif.left(4) == "else" && ifcnt == 0) {
|
|
|
|
|
if (mif.left(4) == PIStringAscii("else") && ifcnt == 0) {
|
|
|
|
|
//piCout << "main else" << skip << grab;
|
|
|
|
|
if (grab) pfc << procMacros(nfc);
|
|
|
|
|
if (skip && !cond_ok) {skip = false; grab = true;}
|
|
|
|
|
@@ -959,7 +990,7 @@ bool PICodeParser::parseDirective(PIString d) {
|
|
|
|
|
if (d.isEmpty()) return true;
|
|
|
|
|
PIString dname = d.takeCWord();
|
|
|
|
|
//piCout << "parseDirective" << d;
|
|
|
|
|
if (dname == "include") {
|
|
|
|
|
if (dname == PIStringAscii("include")) {
|
|
|
|
|
d.replaceAll('<', '\"').replaceAll('>', '\"');
|
|
|
|
|
PIString cf = cur_file, ifc = d.takeRange('\"', '\"');
|
|
|
|
|
if (with_includes) {
|
|
|
|
|
@@ -982,7 +1013,7 @@ bool PICodeParser::parseDirective(PIString d) {
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (dname == "undef") {
|
|
|
|
|
if (dname == PIStringAscii("undef")) {
|
|
|
|
|
PIString mname = d.takeCWord();
|
|
|
|
|
for (int i = 0; i < defines.size_s(); ++i)
|
|
|
|
|
if (defines[i].first == mname) {defines.remove(i); --i;}
|
|
|
|
|
|