lua-users home
lua-l archive

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


Am 01.12.2012 um 13:32 schrieb Thijs Schreijer:

>> -----Original Message-----
>> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
>> Behalf Of Philipp Kraus
>> Sent: zaterdag 1 december 2012 12:47
>> To: Lua list mailing
>> Subject: user data
>> 
>> Hello,
>> 
>> I have found in the C reference of Lua the functions lua_islightuserdata
>> lua_isuserdata
>> 
>> What is the "user data" ? Eg I have got a Lua function that returns
> something,
>> which datatype should I return, so one of these function will be true.
>> How can I handle "user data" in C ?
> 
> Userdata is a c-side type (cannot be created in Lua, only passed to it).  It
> allows to represent an arbitrary chunk of memory in lua and pass it around
> as a lua value. By attaching a metatable you can provide lua with a simple
> means to perform actions on it. (btw; light user data is just a pointer, but
> is important on equality)
> 
> Check out the relevant part in PiL http://www.lua.org/pil/28.html

Can I modify eg array structures without copying into the Lua stack?
I have some vector & matrix data, at the moment I create a table with "newtable"
and push the data into it. Can I use this to allow the Lua script to modify the data
without copy like call-by-reference?

Phil