[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Nil-ing userdata
- From: David Pirrò <david.pirro@...>
- Date: Fri, 22 Oct 2010 19:18:05 +0200
Dear LuaList,
I'm quite new to lua, so pardon me if this is a stupid/ old question.
I'm currently embedding lua in a C++ programm I've written.
I've used a version of lunar.h to bind my C++ objects to lua, by using userdatas (with all the necessary methods in the metatable, like "__gc" and so on...) containing the pointer to the C++ objects.
Everything (with a little work...) is going well until now.
But now I have a problem.
I have to objects in lua:
s = Scene:new();
m = Mass:new(s); \\ mass that belongs the scene "s"
I want to explicitly delete such an object from lua code in this way:
s:deleteMass(m);
deleting the C++ object is no problem.
But how do I "force" lua to garbage collect the "m" object?
That would be something like:
s:deleteMass(m);
m = nil;
but in one call.
Can I set the "m" userdata to nil from the lua C API?
Hope that's somehow clear...
Thank you very much for your help.
Bests,
David