Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCompiler: Don't allow to define an int as a group name in groups attr #9057

Merged
merged 3 commits into from
Nov 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions tools/mkclass/classcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,25 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
}

if (field.Type.IsName) {
m_Impl << "\t" << "if (";
if (field.Type.ArrayRank > 0) {
m_Impl << "\t\t\t" << "if (!" << valName << ".IsEmpty() && ";
Al2Klimov marked this conversation as resolved.
Show resolved Hide resolved

m_Impl << "!" << valName << ".IsString())" << std::endl
<< "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \""
<< field.Name << R"(" }, "It is not allowed to specify '" + )" << valName << R"( + "' of type '" + )"
<< valName << ".GetTypeName()" << R"( + "' as ')" << field.Type.TypeName
<< "' name. Expected type of '" << field.Type.TypeName << "' name: 'String'.\"));" << std::endl;
}

m_Impl << "\t\t\t" << "if (";

if (field.Type.ArrayRank > 0)
m_Impl << valName << ".IsEmpty() || ";
else
m_Impl << "!" << valName << ".IsEmpty() && ";

m_Impl << "!utils.ValidateName(\"" << field.Type.TypeName << "\", " << valName << "))" << std::endl
<< "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << R"(" }, "Object '" + )" << valName << R"( + "' of type ')" << field.Type.TypeName
<< "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << R"(" }, "Object '" + )" << valName << R"( + "' of type ')" << field.Type.TypeName
<< "' does not exist.\"));" << std::endl;
} else if (field.Type.ArrayRank > 0 && (ftype == "Number" || ftype == "Boolean")) {
m_Impl << "\t" << "try {" << std::endl
Expand Down