I'm not sure if anyone out there is getting this since the last message I sent went unanswered.
I am using tolua and lua 3.1. On the whole it's a great set of tools. I am having trouble getting tolua/lua to garbage collect my C++ objects.
I have something like this:
static X Make();
which I bind using tolua. I had hoped that the static Make function would allow me to create objects that lua would garbage collect (and call their destructors). The user makes and object using
obj = X:Make()
which seems to work (the obj:Test() call works fine), but I can not get lua to garbage collect the object that it cloned in the tolua code. I have tried
obj = nil; collectgarbage();
with no luck. I can't seem to find the location in the tolua source where it calls the destructor either.
What is going on? How can I make lua own the object to the point of calling its destructor?
Also, when lua quits, does it garbage collect everything? Calling the needed hook functions and destructors or does it just free the memory?
It would be great if we could tell tolua in the cleaned header file when to destruct the objects returned to it (when lua owns the object). Because lua lacks exception handling, it would be nice to return object pointers from static functions and have lua own the objects. That way one can return 0 on an error which will be nil in lua.
f = File:Make('name')
File *File::Make(char *name); in C++ to make the object. This is better than
f = File:new('name')
since the constuctor has no way to fail in C++ except by throwing an exception. Perhaps this could be accomplished by extending the renaming syntax:
File *MakeFile @ own LuaFile(char *name);
or by adding a keyword to the cleaned header (a better idea I think)
own File *MakeFile @ LuaFile(char *name);
At this point I'd jsut be happy to figure out how to make the objects be garbage collected and destroyed. Am I missing something?
>From: "Russell Y. Webb" <[hidden email]> Tue Mar 16 19:27:23 1999
>I'm not sure if anyone out there is getting this since the last message
>I sent went unanswered.
We had a "disk full" problem in the server and all messages sent to lua-l
since Feb 23 have not been distributed nor archived; they were simply lost :-(
So, please everyone, send any messages again.
Sorry about that.