-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcompat1x.lua
More file actions
29 lines (24 loc) · 731 Bytes
/
compat1x.lua
File metadata and controls
29 lines (24 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- vstruct 1.x compatibility module
local vstruct = require "vstruct"
vstruct.WARN = true
local function warning(f, level)
return function(...)
if vstruct.WARN then
local info = debug.getinfo(level or 2)
io.stderr:write(info.short_src..":"..info.currentline..": vstruct: call to legacy API\n")
end
return f(...)
end
end
vstruct.unpack = warning(vstruct.read)
vstruct.unpackvals = warning(vstruct.readvals)
vstruct.pack = warning(vstruct.write)
do
local _compile = vstruct.compile
function vstruct.compile(...)
local obj = _compile(...)
obj.unpack = warning(function(...) return obj:read(...) end)
obj.pack = warning(function(...) return obj:write(...) end)
return obj
end
end