Hi,
I am working on exposing an application interface that uses the factory pattern on a regular basis:
//Existing C++ Factory class
class ObjectFactory
{
public:
Object* BuildObject();
}
Exposed as:
//Exposed Angelscript Factory class
class ObjectFactory
{
public:
Object@ BuildObject();
}
The issue is that the application does not implement reference counting, so all the "Object" instances do not have addref/release capabilities.
So far, it seems that the only way I can expose this to angelscript is to wrap both the factory and object classes into new classes that act as a proxy, just for reference counting, so that the built object can be properly destroyed when there is no more reference to it from the angelscript side. Is this correct, or have I missed an option to avoid this?
If it is not already available, what about implementing a specific option for type registration (something like asOBJ_AUTOREFCOUNT), so that the script engine does the reference counting for you and just calls a release function when refcount is 0? This would simplify wrapping a lot when the existing classes cannot be modified for reference counting.