28 lines
788 B
C++
28 lines
788 B
C++
#pragma once
|
|
|
|
#include "_global.h"
|
|
|
|
class ExpressionFunctions
|
|
{
|
|
public:
|
|
using CBEXPRESSIONFUNCTION = std::function<duint(int argc, duint* argv, void* userdata)>;
|
|
|
|
static void Init();
|
|
static bool Register(const String & name, int argc, CBEXPRESSIONFUNCTION cbFunction, void* userdata = nullptr);
|
|
static bool Unregister(const String & name);
|
|
static bool Call(const String & name, std::vector<duint> & argv, duint & result);
|
|
static bool GetArgc(const String & name, int & argc);
|
|
|
|
private:
|
|
struct Function
|
|
{
|
|
String name;
|
|
int argc;
|
|
CBEXPRESSIONFUNCTION cbFunction;
|
|
void* userdata;
|
|
};
|
|
|
|
static bool isValidName(const String & name);
|
|
|
|
static std::unordered_map<String, Function> mFunctions;
|
|
}; |