In my game, squirrel scripts can inherit from base C++ classes especially the class "Entity"
The problem is:
1)For an entity to be updated. It has to register itself to the EntityManager. But it has to stay alive so that it will not be GCed.
2)Some method returns new instances of class. ie: return new Object(). I see that Squirrel does not assume owner ships on those instance so it does not delete them.
Is there a way for me to assign ownership of objects between Squirrel and C++?
I tried to use reference counting but for problem number 2. Squirrel does not try to "delete" the object so there is no way I can decrease the ref counter and destroy that object.
3)Some methods only returns base class pointers. How can I cast it(in Squirrel) to derived class?
I don't want to write the whole framework in Squirrel because it would be quite slow.