[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Convert userdata to hex string
- From: Vaughan McAlley <ockegheim@...>
- Date: Sun, 21 Feb 2010 18:59:53 +1100
I agree... strings are an excellent way of getting arbitary data in
and out of Lua. All you probably need to do is pass the address and
length to lua_pushlstring. Lua makes its own copy, so you don't need
to worry about what Lua might do with it.
On 21 February 2010 18:10, steve donovan <email@example.com> wrote:
> On Sat, Feb 20, 2010 at 11:58 PM, Peter Cawley <firstname.lastname@example.org> wrote:
>> functions, etc. To get the contents of a userdata, you need to use the
>> C functions designed specifically for that userdata, which in turn
>> employ the base C API function lua_touserdata to get memory access to
>> the userdata.
> An interesting possibility is a small C extension which can work with
> arbitrary userdata as memory buffers, rather like how Alien works with
> buffers. One could define a userdata-to-string converter, bearing in
> mind that Lua strings can contain embedded nuls and then use one of
> the struct, pack, etc libraries to decode that string.