On 28/10/13 05:44, apscience wrote:
Hello again, As part of the project I’m working on I want to be able to stop, save the program state, and then load it at another time. Saving the program state includes the Lua state. However with OOLua I’m a little stumped on how to do this. Saving the C++ objects themselves is easy enough. I can save the Lua state using eris [1].
. My other thought would be to only
share a string id of objects with lua and then export c++ functions with OOLua as static functions which take the string id and then look up the correct c++ object. However that sounds like I’m remaking a lot of OOLua’s functionality there (like inheritance/type safety/etc.) Any thoughts would be appreciated. Thank you again for the help you’ve already provided. [1] https://github.com/fnuecke/eris
Sound interesting, I would be pleased if you kept me informed of your progress on this matter.
> However I’m not sure how I’d re-link the lua objects to the > C++ objects after loading the stateOOLua keeps a table of the mappings between class pointers and Lua userdata pointers that is stored in the registry which maybe of interest. See [1], although it is possible for there to be multiple entries in this table that point to the same userdata, this is due to offsets off pointers in class hierarchy.
[1] https://bitbucket.org/liamdevine/oolua/src/c9c4510f48ed5c2de4c64c79c0cedae8c5440442/include/proxy_storage.h?at=OOLua-2
-- Liam