lua-users home
lua-l archive

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


(I've only been a lua user for about a month, so I may be about to get
rudely slapped for inaccuracy).

Light userdata sounds like exactly what you want. You just push a
pointer into lua and that's what you get back.

Setting the metatable from C and then checking it seems to be the way
to ensure type safety.

On Tue, 6 Jul 2004 08:18:24 -0700, William Roper <lacutis@gmail.com> wrote:
> I've been reading up as much as I can on Lua the last month or so,
> including the book, and I have a project that I am not sure the best
> way to go about integrating Lua into it.
> 
> Basically what I need to is this.
> 
> I have a Singleton Object factory in C++ that creates objects (of
> course). What I need is for once these objects are created in C++ pass
> them into lua to be stored into a table.
> Then my program is going to call a lua script which iterates on the
> table of objects and processes scripts for each one in order.
> 
> I've figured out how to create instances of a C++ class IN Lua, but I
> haven't really seen a way to pass already created class objects into
> the Lua environment to be handled by Lua.
> 
> I also don't want them garbage collected, since I will handle that in
> my script. I understand that probably isn't a problem since Lua didnt
> create them, but I wanted to be sure.
> 
> Thanks in advance,
> Ryan.
>