lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, Ben

On the second thought, approach with serializing userdata to Lua string will
not work at all for us. There's equally complex space of C++ objects as you
have with Lua objects, so we need a table of permanents and already
serialized objects as context in userdata's __persist function. This is that
very (void *ud) context passed to the Pluto on persist/unpersist call, and
we need it in both save and load of userdata.

The smallest change is to pass chunk_reader/writer and (void *ud) to
__persist metamethod and fixup closure as light userdatas.

By the way, in the example of our serialization I sent you earlier, the
writer/reader functions were sent to save/load userdata's methods. Actually
they were closures with context in upvalues (to be totally correct, in
current implementation they are userdatas with __call metamethod, thanks to
flexibility of Lua :) ).

Best Regards,
Grisha