Generalize DrivenEngine::drv_invoke

This commit is contained in:
2024-09-02 21:48:24 -04:00
parent 47a570064c
commit bf3e963949
11 changed files with 67 additions and 101 deletions

View File

@@ -8,28 +8,28 @@
//
// The actual contents of the datapack depends on the type of invocation:
//
// KIND_INVALID:
// InvocationKind::INVALID:
//
// Nothing.
//
// KIND_LUA_CALL:
// InvocationKind::LUA_CALL:
//
// A lua function call. The class name, the function name, and then
// the function arguments.
//
// KIND_LUA:
// InvocationKind::LUA_EXPR:
//
// A block of lua source code, in plaintext.
//
// KIND_FLUSH_PRINTS:
// InvocationKind::FLUSH_PRINTS:
//
// Line number in ascii.
//
// KIND_TICK:
// InvocationKind::TICK:
//
// Nothing.
//
// KIND_LUA_SOURCE:
// InvocationKind::LUA_SOURCE:
//
// Packaged lua sourcecode. See drvutil::package_lua_source.
//
@@ -42,30 +42,22 @@
#include "wrap-map.hpp"
#include "wrap-deque.hpp"
#include "streambuffer.hpp"
#include "enginewrapper.hpp"
class Invocation : public eng::opnew {
public:
enum Kind {
KIND_INVALID,
KIND_LUA_CALL,
KIND_LUA,
KIND_FLUSH_PRINTS,
KIND_TICK,
KIND_LUA_SOURCE,
};
private:
Kind kind_;
InvocationKind kind_;
int64_t actor_;
int64_t place_;
eng::string datapack_;
public:
Invocation();
Invocation(Kind kind, int64_t actor, int64_t place, std::string_view datapack);
Invocation(InvocationKind kind, int64_t actor, int64_t place, std::string_view datapack);
bool valid() const { return kind_ != KIND_INVALID; }
Kind kind() const { return kind_; }
bool valid() const { return kind_ != InvocationKind::INVALID; }
InvocationKind kind() const { return kind_; }
int64_t actor() const { return actor_; }
int64_t place() const { return place_; }
const eng::string &datapack() const { return datapack_; }