Skip to content
Permalink
Browse files

ExpressionParser: Make function names case sensitive.

  • Loading branch information...
jordan-woyak committed Jan 9, 2019
1 parent 2b02974 commit 2a377e35ed3f3afefdb5dce5474f2c5bb9c89a54
Showing with 7 additions and 11 deletions.
  1. +7 −11 Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
@@ -477,7 +477,7 @@ class UnknownFunctionExpression : public FunctionExpression
}
ControlState GetValue() const override { return 0.0; }
void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "Unknown"; }
std::string GetFuncName() const override { return "unknown"; }
};

class ToggleExpression : public FunctionExpression
@@ -506,7 +506,7 @@ class ToggleExpression : public FunctionExpression
}

void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "Toggle"; }
std::string GetFuncName() const override { return "toggle"; }

mutable bool m_released{};
mutable bool m_state{};
@@ -535,7 +535,7 @@ class SinExpression : public FunctionExpression

ControlState GetValue() const override { return std::sin(GetArg(0).GetValue()); }
void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "Sin"; }
std::string GetFuncName() const override { return "sin"; }
};

class TimerExpression : public FunctionExpression
@@ -574,7 +574,7 @@ class TimerExpression : public FunctionExpression
return progress;
}
void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "Timer"; }
std::string GetFuncName() const override { return "timer"; }

private:
using Clock = std::chrono::steady_clock;
@@ -596,7 +596,7 @@ class IfExpression : public FunctionExpression
}

void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "If"; }
std::string GetFuncName() const override { return "if"; }
};

class UnaryMinusExpression : public FunctionExpression
@@ -614,7 +614,7 @@ class UnaryMinusExpression : public FunctionExpression
}

void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "Minus"; }
std::string GetFuncName() const override { return "minus"; }
};

class WhileExpression : public FunctionExpression
@@ -644,15 +644,11 @@ class WhileExpression : public FunctionExpression
}

void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "While"; }
std::string GetFuncName() const override { return "while"; }
};

std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string name)
{
// Case insensitive matching.
std::transform(name.begin(), name.end(), name.begin(),
[](char c) { return std::tolower(c, std::locale::classic()); });

if (name.empty())
return std::make_unique<NotExpression>();
else if ("if" == name)

0 comments on commit 2a377e3

Please sign in to comment.
You can’t perform that action at this time.