2021-07-19 15:32:34 -04:00
|
|
|
|
2022-02-23 23:08:28 -05:00
|
|
|
#include "wrap-string.hpp"
|
|
|
|
|
#include "wrap-map.hpp"
|
|
|
|
|
#include "wrap-deque.hpp"
|
|
|
|
|
#include "wrap-sstream.hpp"
|
|
|
|
|
|
2021-07-19 15:32:34 -04:00
|
|
|
#include "invocation.hpp"
|
|
|
|
|
|
|
|
|
|
Invocation::Invocation() : kind_(KIND_INVALID), actor_(0), place_(0) {}
|
|
|
|
|
|
2023-10-19 19:42:33 -04:00
|
|
|
Invocation::Invocation(Kind kind, int64_t actor, int64_t place, std::string_view datapack)
|
|
|
|
|
: kind_(kind), actor_(actor), place_(place), datapack_(datapack) {}
|
|
|
|
|
|
2021-11-16 12:20:11 -05:00
|
|
|
|
2021-07-19 15:32:34 -04:00
|
|
|
void Invocation::serialize(StreamBuffer *sb) const {
|
|
|
|
|
sb->write_uint8(kind_);
|
|
|
|
|
sb->write_int64(actor_);
|
|
|
|
|
sb->write_int64(place_);
|
2023-10-19 19:42:33 -04:00
|
|
|
sb->write_string(datapack_);
|
2021-07-19 15:32:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Invocation::deserialize(StreamBuffer *sb) {
|
|
|
|
|
kind_ = Kind(sb->read_uint8());
|
|
|
|
|
actor_ = sb->read_int64();
|
|
|
|
|
place_ = sb->read_int64();
|
2023-10-19 19:42:33 -04:00
|
|
|
datapack_ = sb->read_string();
|
2021-07-19 15:32:34 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-10 16:00:47 -04:00
|
|
|
eng::string Invocation::debug_string() const {
|
2022-02-24 02:17:41 -05:00
|
|
|
eng::ostringstream oss;
|
2021-11-11 16:23:11 -05:00
|
|
|
oss << "inv[";
|
|
|
|
|
switch (kind_) {
|
|
|
|
|
case KIND_INVALID: oss << "invalid"; break;
|
2024-08-28 19:40:23 -04:00
|
|
|
case KIND_ENGIO: oss << "engio"; break;
|
|
|
|
|
case KIND_LUA_CALL: oss << "lua_call"; break;
|
2021-11-11 16:23:11 -05:00
|
|
|
case KIND_LUA: oss << "lua"; break;
|
|
|
|
|
case KIND_FLUSH_PRINTS: oss << "flush_prints"; break;
|
2021-11-26 15:45:36 -05:00
|
|
|
case KIND_TICK: oss << "tick"; break;
|
2021-12-15 14:18:19 -05:00
|
|
|
case KIND_LUA_SOURCE: oss << "lua_source"; break;
|
2021-11-11 16:23:11 -05:00
|
|
|
default: oss << "UNKNOWN"; break;
|
|
|
|
|
}
|
|
|
|
|
oss << " a=" << actor_;
|
|
|
|
|
oss << " p=" << place_;
|
2023-10-19 19:42:33 -04:00
|
|
|
oss << " dp=" << datapack_.size() << " bytes";
|
2021-11-11 16:23:11 -05:00
|
|
|
oss << "]";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|