lua-users home
lua-l archive

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

On 12/15/05, John Klimek <> 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.