I'm working on some AngelScript bindings for a framework I'm working on, and I have created a generic reference countable class that works fine with AngelScript, but I have some problems when I want to interface the properties of the contained class with the scripts.
To give you an idea, let's say I have a class Texture. I have something like this in my Reference class:
class ScriptReferenceTexture
{
public:
SuperSmartPointer<Texture> Object;
uint32 ReferenceCount;
ScriptReferenceTexture() : ReferenceCount(1) {};
void AddReference()
{
ReferenceCount++;
};
void RemoveReference()
{
ReferenceCount--;
if(ReferenceCount == 0)
{
delete this;
};
};
static ScriptReferenceTexture *Factory()
{
return new ScriptReferenceTexture();
};
};
So this works fine for containing the Texture object, but let's say I want to connect a regular Texture to a ScriptTexture stored in another script class, or want to add methods that access the Texture's own methods. I can't do that since the reference counting bit isn't in the Texture class, and I'm using a smart pointer to store the texture class so modifying the Texture class is not going to work.
I really don't want to change my resource handling scheme since SuperSmartPointers are too important for the native side (since my framework should be used both with and without scripting), and they also allow for the implicit destruction of their contained object (which goes against the AngelScript reference style).
So does anyone have any idea of how I could solve this?