Lua.VM.Stdlib.String.Pack (Lua v1.0.0-rc.0)
View SourceImplementation of string.pack/2, string.unpack/2,3, and
string.packsize/1 per Lua 5.3 §6.4.2.
The format-string mini-language is parsed once into a list of
operations, which are then driven by the appropriate evaluator
(pack, unpack, or packsize). All arithmetic on the platform's
size_t / lua_Integer / lua_Number widths uses 8 bytes (we run on the
64-bit BEAM); native endianness is treated as little-endian to match
the dominant host architecture and PUC-Lua's tpack.lua assumptions.
Errors are raised as Lua.VM.RuntimeError so that pcall's
string.find(err, msg) checks in tpack.lua work as written.
Summary
Functions
Implements string.pack(fmt, ...).
Implements string.packsize(fmt).
Implements string.unpack(fmt, s [, pos]).