From 85301e2baeda9a97c4c5ebbf07807566831e22d1 Mon Sep 17 00:00:00 2001 From: Michael M Date: Wed, 7 Jun 2017 16:03:36 -0700 Subject: [PATCH] ParseStatus: replace NoDevice with EmptyExpression --- Source/Core/DolphinWX/Input/InputConfigDiag.cpp | 9 +++++---- .../InputCommon/ControlReference/ExpressionParser.cpp | 8 +++----- .../Core/InputCommon/ControlReference/ExpressionParser.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp index ccf2d42f4f..a8c70c3ee6 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp @@ -347,11 +347,12 @@ void ControlDialog::UpdateGUI() case ParseStatus::SyntaxError: m_error_label->SetLabel(_("Syntax error")); break; - case ParseStatus::NoDevice: - m_error_label->SetLabel(_("Device not found")); + case ParseStatus::Successful: + m_error_label->SetLabel(control_reference->BoundCount() > 0 ? "" : _("Device not found")); break; - default: + case ParseStatus::EmptyExpression: m_error_label->SetLabel(""); + break; } }; @@ -408,7 +409,7 @@ bool ControlDialog::Validate() UpdateGUI(); const auto parse_status = control_reference->GetParseStatus(); - return parse_status == ParseStatus::Successful || parse_status == ParseStatus::NoDevice; + return parse_status == ParseStatus::Successful || parse_status == ParseStatus::EmptyExpression; } void InputConfigDialog::SetDevice(wxCommandEvent&) diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index 4bd4901cdd..d2cef8c917 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -10,6 +10,7 @@ #include #include +#include "Common/StringUtil.h" #include "InputCommon/ControlReference/ExpressionParser.h" using namespace ciface::Core; @@ -393,9 +394,6 @@ 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, control)}; - return {ParseStatus::Successful, std::make_unique(tok.qualifier, std::move(device), control)}; } @@ -510,8 +508,8 @@ Expression::~Expression() static std::pair> ParseExpressionInner(const std::string& str, ControlFinder& finder) { - if (str == "") - return std::make_pair(ParseStatus::Successful, nullptr); + if (StripSpaces(str).empty()) + return std::make_pair(ParseStatus::EmptyExpression, nullptr); Lexer l(str); std::vector tokens; diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.h b/Source/Core/InputCommon/ControlReference/ExpressionParser.h index d05ac6f546..55bf86b951 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.h +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.h @@ -63,7 +63,7 @@ enum class ParseStatus { Successful, SyntaxError, - NoDevice, + EmptyExpression, }; std::pair> ParseExpression(const std::string& expr,