Jump to content
  • Advertisement
Sign in to follow this  
jedjed

working with boost::shared_ptr

This topic is 3045 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I'm looking into using AngelScript but I'm curious how it should work with boost::shared_ptr ? Basically all the objects I want to pass to the script are shared pointers in my app. So in my app I have: typedef boost::shared_ptr<ILocation> ILocationPtr; and a function called: ILocationPtr getLocation(int x,int y) that I want the scripts to call. I register it like: r = mEngine->RegisterGlobalFunction("ILocation@ getLocation(int,int)", asFUNCTION(createLocation), asCALL_CDECL); But this doesn't work. When the script calls getLocation the value of y is garbled. And it crashes when it tries to return the ILocationPtr How should I be doing this? Thanks

Share this post


Link to post
Share on other sites
Advertisement
In this case a value type would be better and safer (if it's all about x and y positions).
But if you want to use shared_ptr, as I read on other threads about it, you must create a proxy object that holds a shared_ptr in it and wraps every object method checking if the pointer is valid before calling it.
Anyway, in my project, the best solution I found was to use reference counted objects.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!