[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Simple (?) question about metatables and userdata
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Thu, 15 Dec 2005 12:36:39 -0800
On 12/15/05, John Klimek <firstname.lastname@example.org> wrote:
> How would I make a C++ (or Delphi in my case) object *that is already
> created* accessible in Lua then?
There are a couple of strategies. First of all, you can create the
object as a Lua object in the first place. Secondly, instead of having
the userdata hold the object itself, you can just make a 4 (or 8)-byte
userdata and have it hold a pointer to the actual object. This is
known as pointer "boxing", and I believe there are luaL functions to
help you with it. In that case, you simply make your metatable
functions do an extra dereference on the contents of the userdata.