git-svn-id: svn://db.shs.com.ru/pip@603 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -298,20 +298,29 @@ void makeGetter(PIFile & f, const PICodeParser::Entity * e) {
|
||||
f << "\treturn ret;\n}\n";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void makeGetterHeader(PIFile & f, const PICodeParser::Entity * e) {
|
||||
f << "\nPIByteArray getter" << toCName(e->name) << "(const void * p, const char * name);";
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool meta, bool enums, bool streams, bool texts, bool getters) {
|
||||
PIVector<const PICodeParser::Entity * > ventities;
|
||||
PIString defname = out.replaceAll(".", "_").replaceAll("/", "_").replaceAll(":", "_").replaceAll("-", "_").toUpperCase() + "_H";
|
||||
bool inc_h, inc_cpp;
|
||||
inc_h = streams || texts;
|
||||
inc_cpp = !inc_h && getters;
|
||||
|
||||
PISet<PIString> inc_files;
|
||||
piForeachC (PICodeParser::Entity * e, parser.entities)
|
||||
if (e->name.find("::") < 0 && !e->name.startsWith("_PI"))
|
||||
inc_files << e->file;
|
||||
PIString inc_string;
|
||||
PIVector<PIString> incf = inc_files.toVector();
|
||||
piForeachC (PIString & i, incf) {
|
||||
if (i != parser.mainFile())
|
||||
inc_string << "\n#include \"" << i << "\"";
|
||||
}
|
||||
|
||||
PIFile f(out + ".cpp");
|
||||
f.clear();
|
||||
@@ -321,6 +330,7 @@ void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
|
||||
if (streams || texts)
|
||||
f << "#include <pichunkstream.h>\n";
|
||||
f << "#include \"" << out << ".h\"\n";
|
||||
if (inc_cpp) f << inc_string;
|
||||
f << "\nusing namespace PICodeInfo;\n\n";
|
||||
/*
|
||||
PIString entry, argtype, rettype, args;
|
||||
@@ -370,6 +380,13 @@ void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
|
||||
*/
|
||||
|
||||
if (meta || enums || getters) {
|
||||
if (getters) {
|
||||
f << "\n\n// Getter funtions\n";
|
||||
piForeachC (PICodeParser::Entity * e, parser.entities) {
|
||||
if (!e->has_name || e->name.startsWith("_PI")) continue;
|
||||
makeGetter(f, e);
|
||||
}
|
||||
}
|
||||
f << "\n\n// Metainformation\n\n__ClassInfo_" << defname << "_Initializer__::__ClassInfo_" << defname << "_Initializer__() {\n";
|
||||
f << "\tif (_inited_) return;\n\t_inited_ = true;\n\n";
|
||||
if (meta) {
|
||||
@@ -409,13 +426,6 @@ void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
|
||||
makeClassStream(f, e);
|
||||
}
|
||||
}
|
||||
if (getters) {
|
||||
f << "\n\n// Getter funtions\n";
|
||||
piForeachC (PICodeParser::Entity * e, parser.entities) {
|
||||
if (!e->has_name || e->name.startsWith("_PI")) continue;
|
||||
makeGetter(f, e);
|
||||
}
|
||||
}
|
||||
|
||||
f.close();
|
||||
|
||||
@@ -430,13 +440,7 @@ void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
|
||||
f << "\n";
|
||||
f << "#ifndef " << defname << "\n#define " << defname << "\n\n";
|
||||
f << "#include \"pivariant.h\"\n#include \"picodeinfo.h\"";
|
||||
if (streams || texts || getters) {
|
||||
PIVector<PIString> incf = inc_files.toVector();
|
||||
piForeachC (PIString & i, incf) {
|
||||
if (i != parser.mainFile())
|
||||
f << "\n#include \"" << i << "\"";
|
||||
}
|
||||
}
|
||||
if (inc_h) f << inc_string;
|
||||
/*
|
||||
f << "\n\n";
|
||||
piForeachC (PICodeParser::Entity * e, ventities)
|
||||
@@ -454,14 +458,14 @@ const PIVariant & arg1 = PIVariant(), const PIVariant & arg2 = PIVariant(), cons
|
||||
makeClassStreamHeader(f, e);
|
||||
}
|
||||
}
|
||||
if (getters) {
|
||||
/*if (getters) {
|
||||
f << "\n\n// Getter funtions\n";
|
||||
piForeachC (PICodeParser::Entity * e, parser.entities) {
|
||||
if (!e->has_name || e->name.startsWith("_PI")) continue;
|
||||
makeGetterHeader(f, e);
|
||||
}
|
||||
f << "\n";
|
||||
}
|
||||
}*/
|
||||
if (meta || enums || getters) {
|
||||
f << "\n\n// Metainformation\n\nclass __ClassInfo_" << defname << "_Initializer__ {\n";
|
||||
f << "public:\n\t__ClassInfo_" << defname << "_Initializer__();\n\tstatic bool _inited_;\n};\n";
|
||||
|
||||
Reference in New Issue
Block a user