From 99308ce921c2eff2dc074006a31dc2b0f4b7b660 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 2 Nov 2021 10:52:50 +0100 Subject: [PATCH 1/3] `ClassCompiler`: Don't allow to use an int as a group name `groups` attr --- tools/mkclass/classcompiler.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index f6793da501b..2b5d6fbdb46 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -517,7 +517,17 @@ 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() && "; + + m_Impl << "!" << valName << ".IsString())" << std::endl + << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" + << field.Name << R"(" }, "Object '" + )" << valName << R"( + "' of type ')" + << field.Type.TypeName + << "' has an invalid name.\"));" << std::endl; + } + + m_Impl << "\t\t\t" << "if ("; if (field.Type.ArrayRank > 0) m_Impl << valName << ".IsEmpty() || "; @@ -525,7 +535,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) m_Impl << "!" << valName << ".IsEmpty() && "; m_Impl << "!utils.ValidateName(\"" << field.Type.TypeName << "\", " << valName << "))" << std::endl - << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" << field.Name << R"(" }, "Object '" + )" << valName << R"( + "' of type ')" << field.Type.TypeName + << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(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 From 03f12d12c68e94da8e17ba8f083caa2b32da6b88 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 2 Nov 2021 15:02:37 +0100 Subject: [PATCH 2/3] WIP --- tools/mkclass/classcompiler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 2b5d6fbdb46..0c2b4ead481 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -522,9 +522,9 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) m_Impl << "!" << valName << ".IsString())" << std::endl << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(this), { \"" - << field.Name << R"(" }, "Object '" + )" << valName << R"( + "' of type ')" - << field.Type.TypeName - << "' has an invalid name.\"));" << std::endl; + << 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 ("; From c95372bd4cba8f9feb3aeb6a34edbaeed1b2ffc9 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 2 Nov 2021 17:18:38 +0100 Subject: [PATCH 3/3] WIP --- tools/mkclass/classcompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 0c2b4ead481..12946b3c3c6 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -524,7 +524,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast(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; + << "' name. Expected type of '" << field.Type.TypeName << "' name: 'String'.\"));" << std::endl; } m_Impl << "\t\t\t" << "if (";