From 754efd75c5f8b843e25f2ff8510bfc2a25fd1de1 Mon Sep 17 00:00:00 2001 From: Michael M Date: Wed, 7 Jun 2017 15:56:49 -0700 Subject: [PATCH] ExpressionParser: remove DummyExpression --- .../ControlReference/ExpressionParser.cpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index 277cfb3c70..4bd4901cdd 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -217,18 +217,6 @@ public: virtual operator std::string() const { return ""; } }; -class DummyExpression : public ExpressionNode -{ -public: - std::string name; - - DummyExpression(const std::string& name_) : name(name_) {} - ControlState GetValue() const override { return 0.0; } - void SetValue(ControlState value) override {} - int CountNumControls() const override { return 0; } - operator std::string() const override { return "`" + name + "`"; } -}; - class ControlExpression : public ExpressionNode { public: @@ -243,9 +231,13 @@ public: { } - ControlState GetValue() const override { return control->ToInput()->GetState(); } - void SetValue(ControlState value) override { control->ToOutput()->SetState(value); } - int CountNumControls() const override { return 1; } + ControlState GetValue() const override { return control ? control->ToInput()->GetState() : 0.0; } + void SetValue(ControlState value) override + { + if (control) + control->ToOutput()->SetState(value); + } + int CountNumControls() const override { return control ? 1 : 0; } operator std::string() const override { return "`" + static_cast(qualifier) + "`"; } }; @@ -402,7 +394,7 @@ private: std::shared_ptr device = finder.FindDevice(tok.qualifier); Device::Control* control = finder.FindControl(tok.qualifier); if (control == nullptr) - return {ParseStatus::NoDevice, std::make_unique(tok.qualifier)}; + return {ParseStatus::NoDevice, std::make_unique(tok.qualifier, control)}; return {ParseStatus::Successful, std::make_unique(tok.qualifier, std::move(device), control)};