lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Sep 3, 2008 at 11:27 PM, Joshua Jensen
<> wrote:
> ----- Original Message -----
> From: Fabio Mascarenhas
> (I also don't like passing the buffer size along... is there a reason it
> can't be obtained via lua_objlen()?)

Buffers can be light userdata, too (you can pass a pointer to
alien.buffer and it just sets the metatable), and the size you want to
unpack can be smaller than the size of the buffer, so there are cases
where the size has to be explicit. But you are right that unpack can
be a little smarter and not need the size if you want to unpack a full

Alas, using struct.unpack is a temporary bandaid while I do not
implement an struct abstraction on top of the buffers (like array).
The support for figuring out offsets from a description of the struct
is already in core.c, in the form of alien.sizeof and alien.align, so
it can be implemented as a Lua addon (just like arrays).

> Josh

Fabio Mascarenhas