lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Newberry wrote:
[...]
> The missing concept in precisely what has to happen for the userdata
> I've created to be referenced? Do I push the userdata ptr onto the
> return stack using lua_pushlightuserdata( ptr ) and then, in the script,
> set a table element to the return value?

A userdata is just another Lua object type, like a lightuserdata. So
just push it onto the stack and return it. You don't need to use
lightuserdatas at all.

Basically:

lightuserdata: 4 bytes only, no metatable, no notification when GCd

userdata: any number of bytes, metatable, notification when GCd

Check out the example here: http://www.lua.org/pil/28.1.html

- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "People who think they know everything really annoy those of us who
│ know we don't." --- Bjarne Stroustrup
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKhzsIf9E0noFvlzgRApXnAJ95YVNQj3/pFimihcaFBc04d4CwKACg387L
Hn8x9kNNGixMEoTAL9VsrkU=
=k9vO
-----END PGP SIGNATURE-----