lua-users home
lua-l archive

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


Ok, since there seems to be some confusion, Ill start over.

I have created a Singleton Object Factory in C++. I ask it to create
me a new instance of a class and it provides me with a pointer to my
new instance.

I already know in lua I can create the binding functions to allow lua
to create instances of my class, but I don't *want* lua to create the
instances. I want my application to create the instances, and handle
their deletion.

I want to pass to lua a "pointer" to the instance I created and be
able to store it in a table, along with other instances.

I then want to be able to call a lua script that iterates over the
table, calling scripts on each instance of the class that has been
created and registered.

When i am done with the object, I will remove the "pointer" from the
table and call a c++ function from lua to clean up the instance.

I hope thats more understandable, I'm not exactly sure what parts I
didn't explain well enough before.

About the light user data, yeah, I read over those and it doesn't seem
like it will work, since you can't use metatables to create methods on
them like full userdata.

Thanks,
Ryan

On Tue, 06 Jul 2004 17:59:44 +0100, Daniel Silverstone
<dsilvers@digital-scurf.org> wrote:
> Peter Bradshaw wrote:
> > (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.
> 
> Erm, Light userdatas can't have metatables.
> 
> D.
> 
> --
> Daniel Silverstone                         http://www.digital-scurf.org/
> PGP mail accepted and encouraged.            Key Id: 2BC8 4016 2068 7895
>