Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

Object ownership

Last post 10-09-2008, 5:39 AM by bullno1. 0 replies.
Sort Posts: Previous Next
  •  10-09-2008, 5:39 AM 2827

    Object ownership

    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.

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems