Add Packer/Unpacker, add serialization to LuaSnap

This commit is contained in:
2021-03-02 18:58:50 -05:00
parent 49df7b4895
commit 9d86347d54
5 changed files with 254 additions and 44 deletions

View File

@@ -14,6 +14,7 @@
#ifndef LUASNAP_HPP
#define LUASNAP_HPP
#include "packer.hpp"
#include "luastack.hpp"
class LuaSnap {
@@ -29,6 +30,14 @@ public:
//
lua_State *state() const { return state_; }
// Serialize the state of the lua interpreter.
//
void serialize(Packer *pk);
// Restore the the lua interpreter given a serialized state.
//
void deserialize(Unpacker *unpk);
// Return true if there's a saved snapshot.
//
bool have_snapshot() const;
@@ -44,6 +53,7 @@ public:
// If there is no snapshot, this panics.
//
void rollback();
};