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"; }