Structure Packing
wiki
Here's various resources on packing and unpacking C structures.
The Lua string library, including
[string.byte]
and
[string.char]
, along with
BitwiseOperators
, provide very rudimentary functions for doing this.
[lpack]
(5.0/5.1) - a library for packing and unpacking binary data, written in C. (
LuizHenriqueDeFigueiredo
)
[struct]
(5.0) - another library for packing and unpacking binary data, written in C. (
RobertoIerusalimschy
)
[2]
- extensions by Flemming Madsen
[Alien]
"uses a slightly modified version of Roberto Ierusalimschy’s struct library that can unpack binary blobs (userdata) instead of just strings". notes:
LuaList:2009-10/msg00489.html
[Lunary]
(5.1) - another library for packing and unpacking binary data, written in C. (
[differences from other libraries]
) (Jérôme Vuarand)
[vstruct]
(5.1) - a library for packing and unpacking binary data, written entirely in Lua, using the string library. (Ben Kelly)
Notes/Examples:
Comparison of above structure packing libraries -
LuaList:2010-03/msg00292.html
(Sam Roberts)
ReadWriteFormat
- simple pack/unpack implemented with Lua string library
PortableNetworkGraphicsParser
/
ModuleCompressDeflateLua
- examples of unpacking using Lua string library
the
[LuaJIT]
FFI allows defining structs in standard C syntax. They can be accessed just like table elements
[1]
.
struct was at least at one time considered for
LuaFiveTwo
(
LuaList:2008-02/msg00720.html
).
Other programming languages cross reference:
Perl
[unpack]
[pack]
, Python
[struct library]
[Wikipedia:Data structure alignment]
RecentChanges
·
preferences
edit
·
history
Last edited December 2, 2011 10:07 pm GMT
(diff)