Sign in to follow this  

working with boost::shared_ptr

This topic is 2836 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
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

This topic is 2836 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this