working with boost::shared_ptr
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
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.
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.
...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement