From 8315c95ffec43213a53e12b9a529008f934007b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Wed, 8 Apr 2020 14:17:10 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@1005 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/core/pibytearray.cpp | 2 +- utils/code_model_generator/main.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src_main/core/pibytearray.cpp b/src_main/core/pibytearray.cpp index ccf81177..46c5eed7 100755 --- a/src_main/core/pibytearray.cpp +++ b/src_main/core/pibytearray.cpp @@ -388,7 +388,7 @@ PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) { assert(s.size_s() >= 4); int sz = 0; s >> sz; - if (sz > s.size_s()) { + if (sz > (s.size_s() - 4)) { piCout << "[PIByteArray] Warning: operator >> wants too much data, discard!" << sz << s.size_s(); s.clear(); v.clear(); diff --git a/utils/code_model_generator/main.cpp b/utils/code_model_generator/main.cpp index 19857d25..b6f599f4 100755 --- a/utils/code_model_generator/main.cpp +++ b/utils/code_model_generator/main.cpp @@ -82,7 +82,7 @@ PIString toCName(const PIString &s) { void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) { - f << "\n\tci = new ClassInfo();\n"; + f << "\n\t{\n\tClassInfo * ci = new ClassInfo();\n"; f << "\tci->type = \"" << e->type << "\";\n"; f << "\tci->name = \"" << e->name << "\";\n"; f << "\tci->has_name = " << (e->has_name ? "true" : "false") << ";\n"; @@ -97,6 +97,7 @@ void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) { } piForeachC (PICodeParser::Entity * p, e->parents) f << "\tci->parents << \"" << p->name << "\";\n"; + if (!e->members.isEmpty()) f << "\n\tTypeInfo ti;\n"; piForeachC (PICodeParser::Member & m, e->members) { f << "\tti = TypeInfo(\"" << m.name << "\", \"" << m.type << "\""; if (m.attributes != 0) { @@ -122,6 +123,7 @@ void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) { f << "\tci->variables << ti;\n"; } PIString arg; + if (!e->functions.isEmpty()) f << "\n\tFunctionInfo * fi;\n"; piForeachC (PICodeParser::Member & m, e->functions) { if (e->name.findCWord(m.name) >= 0) continue; f << "\tci->functions.push_back(FunctionInfo()); fi = &(ci->functions.back());\n"; @@ -159,6 +161,7 @@ void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) { f << "\tfi->meta[\"" << i.key() << "\"] = PIString::fromUTF8(\"" << i.value() << "\");\n"; } } + f << "\n\t}"; } @@ -418,10 +421,10 @@ void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met 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) { - f << "\tClassInfo * ci, * pci = new ClassInfo();\n\tTypeInfo * ni;\n\tFunctionInfo * fi;\n\tTypeInfo ti;\n"; + f << "\tClassInfo * pci = new ClassInfo();\n"; f << "\t(*classesInfo)[\"\"] = pci;\n"; } - if (enums) { + if (enums && !parser.enums.isEmpty()) { f << "\tEnumInfo * ei;\n"; f << "\t(*enumsInfo)[\"\"] = new EnumInfo();\n"; }