2019-01-26 11:17:30 -07:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-01-26 11:17:30 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-11-22 12:51:57 -07:00
|
|
|
#include <string_view>
|
2019-10-11 18:38:18 -06:00
|
|
|
#include <variant>
|
2019-01-26 11:17:30 -07:00
|
|
|
#include <vector>
|
|
|
|
|
2019-11-22 12:48:10 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2019-01-26 11:17:30 -07:00
|
|
|
#include "InputCommon/ControlReference/ExpressionParser.h"
|
|
|
|
|
2019-11-22 12:44:33 -07:00
|
|
|
namespace ciface::ExpressionParser
|
2019-01-26 11:17:30 -07:00
|
|
|
{
|
2019-10-18 13:54:02 -06:00
|
|
|
constexpr ControlState CONDITION_THRESHOLD = 0.5;
|
|
|
|
|
2019-01-26 11:17:30 -07:00
|
|
|
class FunctionExpression : public Expression
|
|
|
|
{
|
|
|
|
public:
|
2019-10-11 18:38:18 -06:00
|
|
|
struct ArgumentsAreValid
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExpectedArguments
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
};
|
|
|
|
|
|
|
|
using ArgumentValidation = std::variant<ArgumentsAreValid, ExpectedArguments>;
|
|
|
|
|
2019-01-26 11:17:30 -07:00
|
|
|
int CountNumControls() const override;
|
|
|
|
void UpdateReferences(ControlEnvironment& env) override;
|
|
|
|
|
2019-10-11 18:38:18 -06:00
|
|
|
ArgumentValidation SetArguments(std::vector<std::unique_ptr<Expression>>&& args);
|
2019-01-26 11:17:30 -07:00
|
|
|
|
2019-04-04 16:35:49 -06:00
|
|
|
void SetValue(ControlState value) override;
|
|
|
|
|
2019-01-26 11:17:30 -07:00
|
|
|
protected:
|
2019-10-11 18:38:18 -06:00
|
|
|
virtual ArgumentValidation
|
|
|
|
ValidateArguments(const std::vector<std::unique_ptr<Expression>>& args) = 0;
|
2019-01-26 11:17:30 -07:00
|
|
|
|
|
|
|
Expression& GetArg(u32 number);
|
|
|
|
const Expression& GetArg(u32 number) const;
|
2019-01-26 12:18:20 -07:00
|
|
|
u32 GetArgCount() const;
|
2019-01-26 11:17:30 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::unique_ptr<Expression>> m_args;
|
|
|
|
};
|
|
|
|
|
2019-11-22 12:51:57 -07:00
|
|
|
std::unique_ptr<FunctionExpression> MakeFunctionExpression(std::string_view name);
|
2019-01-26 11:17:30 -07:00
|
|
|
|
2019-11-22 12:44:33 -07:00
|
|
|
} // namespace ciface::ExpressionParser
|