Skip to content

Commit

Permalink
libcore|Scripting: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 17, 2016
1 parent 9dfeaf4 commit 635a868
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions doomsday/sdk/libcore/src/scriptsys/builtinexpression.cpp
Expand Up @@ -370,10 +370,7 @@ void BuiltInExpression::operator << (Reader &from)
_arg = Expression::constructFrom(from);
}

static struct {
char const *str;
BuiltInExpression::Type type;
} types[] = {
static QHash<String, BuiltInExpression::Type> const types {
{ "File", BuiltInExpression::AS_FILE },
{ "Number", BuiltInExpression::AS_NUMBER },
{ "Record", BuiltInExpression::AS_RECORD },
Expand All @@ -393,27 +390,21 @@ static struct {
{ "subrecords", BuiltInExpression::RECORD_SUBRECORDS },
{ "timedelta", BuiltInExpression::TIME_DELTA },
{ "typeof", BuiltInExpression::TYPE_OF },
{ NULL, BuiltInExpression::NONE }
};

BuiltInExpression::Type BuiltInExpression::findType(String const &identifier)
{
for (duint i = 0; types[i].str; ++i)
{
if (identifier == types[i].str)
{
return types[i].type;
}
}
auto found = types.find(identifier);
if (found != types.end()) return found.value();
return NONE;
}

StringList BuiltInExpression::identifiers()
{
StringList names;
for (int i = 0; types[i].str; ++i)
foreach (auto const &t, types.keys())
{
names << types[i].str;
names << t;
}
return names;
}

0 comments on commit 635a868

Please sign in to comment.