OK so I have a C++ class that is exposed to Lua using SWIG. The script creates the object but a manager class also has a pointer to the object so it can be modified in C++(or another script) for whatever reason.
The problem is that when the script finishes the object is freed, how can I control what the Garbage collector collects without having to implement a gc metamethod?
Here is an example:
--Script that creates the object
someObject = Utils.Object("Obj name");
Now the Object has registered itself with the manager so the rest of the application(and other scripts) can access it.
--Another script
obj = ObjManager:GetObject(0);
Clearly not a very realistic example but hopefully it illustrates my question. Is there a way to veto the garbage collector without a gc metamethod in C++?
Just to clarify the manager is in C++, and Utils is the module name housing the exposed class. Also the object registers itself to the manager in its constructor.
Thanks in advance.