Show (short) list of possible enum values when an invalid value is encountered (resolves #1318)

All enum errors have (hopefully) been changed to a luax_enumerror, which has a
fixed error message. If additionally a list of valid options is passed, it
lists that in the error message. For every enum error with few options I've
implemented this using a getConstants call.

This solution has been designed specifically to reduce the number of template
instantiations (as I've been told that was a concern). All new template code
happens in places where there already was an instantiation of the relevant
StringMap. Of course there is still std::vector<std::string>...

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2017-10-02 17:11:53 +02:00
parent ac84589c57
commit 9e4374935d
72 changed files with 366 additions and 101 deletions
+35
View File
@@ -1444,6 +1444,11 @@ bool Graphics::getConstant(DrawMode in, const char *&out)
return drawModes.find(in, out);
}
std::vector<std::string> Graphics::getConstants(DrawMode)
{
return drawModes.getNames();
}
bool Graphics::getConstant(const char *in, ArcMode &out)
{
return arcModes.find(in, out);
@@ -1454,6 +1459,11 @@ bool Graphics::getConstant(ArcMode in, const char *&out)
return arcModes.find(in, out);
}
std::vector<std::string> Graphics::getConstants(ArcMode)
{
return arcModes.getNames();
}
bool Graphics::getConstant(const char *in, BlendMode &out)
{
return blendModes.find(in, out);
@@ -1464,6 +1474,11 @@ bool Graphics::getConstant(BlendMode in, const char *&out)
return blendModes.find(in, out);
}
std::vector<std::string> Graphics::getConstants(BlendMode)
{
return blendModes.getNames();
}
bool Graphics::getConstant(const char *in, BlendAlpha &out)
{
return blendAlphaModes.find(in, out);
@@ -1474,6 +1489,11 @@ bool Graphics::getConstant(BlendAlpha in, const char *&out)
return blendAlphaModes.find(in, out);
}
std::vector<std::string> Graphics::getConstants(BlendAlpha)
{
return blendAlphaModes.getNames();
}
bool Graphics::getConstant(const char *in, LineStyle &out)
{
return lineStyles.find(in, out);
@@ -1484,6 +1504,11 @@ bool Graphics::getConstant(LineStyle in, const char *&out)
return lineStyles.find(in, out);
}
std::vector<std::string> Graphics::getConstants(LineStyle)
{
return lineStyles.getNames();
}
bool Graphics::getConstant(const char *in, LineJoin &out)
{
return lineJoins.find(in, out);
@@ -1494,6 +1519,11 @@ bool Graphics::getConstant(LineJoin in, const char *&out)
return lineJoins.find(in, out);
}
std::vector<std::string> Graphics::getConstants(LineJoin)
{
return lineJoins.getNames();
}
bool Graphics::getConstant(const char *in, Feature &out)
{
return features.find(in, out);
@@ -1524,6 +1554,11 @@ bool Graphics::getConstant(StackType in, const char *&out)
return stackTypes.find(in, out);
}
std::vector<std::string> Graphics::getConstants(StackType)
{
return stackTypes.getNames();
}
StringMap<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM>::Entry Graphics::drawModeEntries[] =
{
{ "line", DRAW_LINE },