Skip to content

Commit

Permalink
Minor bitser update (#1353)
Browse files Browse the repository at this point in the history
Also, jot down the exact commit it was taken from to ease maintenance.
  • Loading branch information
NiLuJe committed Apr 11, 2021
1 parent aebc008 commit 50e9354
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ffi/bitser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Taken from https://github.com/gvx/bitser,
Removed love specific features
NOTE: Taken from https://github.com/gvx/bitser @ 1d3ebe04cfd6ef2dd8ebd212a6ad06e96dfdc170,
Removed love specific features.
]]

local VERSION = '1.1'
Expand All @@ -34,6 +33,7 @@ local buf = nil
local buf_is_writable = true
local writable_buf = nil
local writable_buf_size = nil
local includeMetatables = true -- togglable with bitser.includeMetatables(false)
local SEEN_LEN = {}

local function Buffer_prereserve(min_size)
Expand Down Expand Up @@ -202,7 +202,7 @@ local function write_table(value, seen)
classkey = classkey_registry[classname]
Buffer_write_byte(242)
serialize_value(classname, seen)
elseif metatable then
elseif includeMetatables and metatable then
Buffer_write_byte(253)
else
Buffer_write_byte(240)
Expand All @@ -225,7 +225,7 @@ local function write_table(value, seen)
serialize_value(v, seen)
end
end
if metatable and not classname then
if includeMetatables and metatable and not classname then
serialize_value(metatable, seen)
end
end
Expand Down Expand Up @@ -327,7 +327,9 @@ local function deserialize_value(seen)
v[key] = deserialize_value(seen)
end
if t == 253 then
setmetatable(v, deserialize_value(seen))
if includeMetatables then
setmetatable(v, deserialize_value(seen))
end
end
return v
elseif t == 241 then
Expand Down Expand Up @@ -427,6 +429,8 @@ end, loads = function(str)
end
Buffer_newReader(str)
return deserialize_value({})
end, includeMetatables = function(bool)
includeMetatables = not not bool
end, register = function(name, resource)
assert(not resource_registry[name], name .. " already registered")
resource_registry[name] = resource
Expand Down
1 change: 1 addition & 0 deletions ffi/sha2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
-- 2 2018-10-07 Decreased module loading time in Lua 5.1 implementation branch (thanks to Peter Melnichenko for giving a hint)
-- 1 2018-10-06 First release (only SHA-2 functions)
-----------------------------------------------------------------------------
-- NOTE: This is https://github.com/Egor-Skriptunoff/pure_lua_SHA @ 304d4121f080e68ef209d3f5fe093e5a955a4978

local print_debug_messages = false -- set to true to view some messages about your system's abilities and implementation branch chosen for your system

Expand Down

0 comments on commit 50e9354

Please sign in to comment.