sorcery  Diff

Differences From Artifact [9fd6c4419a]:

To Artifact [30a22c2236]:


     1         --- minetest provides its own built-in serializer mechanisms.
     2         --- however, these leave much to be desired: the first works
     3         --- by converting values to *lua source code* and 'deserializes'
     4         --- these values by executing it in a mildly sandboxed env.
     5         --- it's LSON basically. the other serializer is JSON. clearly
     6         --- we need something better. if this was lua 5.3, we'd just
     7         --- use string.pack, but alas, they had to use luajit, which
     8         --- is stuck on an ancient version because it no longer exists.
     9         --- if we built against moonjit, we could use pack, but then
    10         --- that would raise compat issues for other users who might
    11         --- want to use these mods. so we need to write our own.
            1  +-- minetest provides its own  built-in serializer mechanisms. however,
            2  +-- these  leave much  to be  desired:  the first  works by  converting
            3  +-- values  to *lua  source code*  and 'deserializes'  these values  by
            4  +-- executing it  in a mildly  sandboxed env. it's LSON  basically. the
            5  +-- other serializer is JSON. clearly we need something better. if this
            6  +-- was lua 5.3,  we'd just use string.pack, but alas,  they had to use
            7  +-- luajit, which is  stuck on an ancient version because  it no longer
            8  +-- exists. if  we built against moonjit,  we could use pack,  but then
            9  +-- that would  raise compat issues for  other users who might  want to
           10  +-- use these mods. so we need to write our own.
           11  +--
           12  +-- good news  is, it's very easy  to do better than  both the minetest
           13  +-- people and the  clowns at PUC-Rio. (if only we  had general purpose
           14  +-- bitops, it would be even easier)
    12     15   --
    13         --- good news is, it's very easy to do better than both the
    14         --- minetest people and the clowns at PUC-Rio. (if only we had
    15         --- general purpose bitops, it would be even easier)
           16  +-- WARNING: when storing binary data  in minetest metadata stores, the
           17  +-- bytes  0x01-0x03 MUST  be avoided  or they  will break  the kvstore
           18  +-- format and  the item/node's metadata  will become corrupt.  use the
           19  +-- lib.str.meta_{,de}armor functions  on the output of  pack/unpack to
           20  +-- safely store and retrieve data structures from meta storage.
    16     21   
    17     22   local m = {
    18     23   	err = {
    19     24   		unmarshalled = {
    20     25   			exp = 'the bytes passed are not a marshalled data structure';
    21     26   		};
    22     27   		corrupt = {