executor_func update

This commit is contained in:
MihailRis 2024-05-10 19:36:25 +03:00
parent 172cfe4ec9
commit 9dc3c40b69

View File

@ -23,6 +23,7 @@ namespace cmd {
}; };
class Command; class Command;
class CommandsInterpreter;
struct Prompt { struct Prompt {
Command* command; Command* command;
@ -31,6 +32,7 @@ namespace cmd {
}; };
using executor_func = std::function<dynamic::Value( using executor_func = std::function<dynamic::Value(
CommandsInterpreter*,
dynamic::List_sptr args, dynamic::List_sptr args,
dynamic::Map_sptr kwargs dynamic::Map_sptr kwargs
)>; )>;
@ -67,8 +69,8 @@ namespace cmd {
return &found->second; return &found->second;
} }
dynamic::Value execute(const Prompt& prompt) { dynamic::Value execute(CommandsInterpreter* interpreter, const Prompt& prompt) {
return executor(prompt.args, prompt.kwargs); return executor(interpreter, prompt.args, prompt.kwargs);
} }
const std::string& getName() const { const std::string& getName() const {
@ -99,7 +101,7 @@ namespace cmd {
} }
dynamic::Value execute(const Prompt& prompt) { dynamic::Value execute(const Prompt& prompt) {
return prompt.command->execute(prompt); return prompt.command->execute(this, prompt);
} }
dynamic::Value& operator[](const std::string& name) { dynamic::Value& operator[](const std::string& name) {