Is it possible to pass a pointer to an instanced class method (&creationsClass.createScriptObject) when registering an object behavior?
I need specific behavior for certain script objects when they're created. I'm trying to avoid using static variables and classes as much as possible which doesn't allow me to simply create a static variable to store the object type for the garbage collector and many other things I need to instantiate a script object.
I kind of want to do something like this (but obviously it doesn't work):
#define asInstanceMethod(c,m) asSMethodPtr<sizeof(c)>::Convert((&c.m))
void Texture::registerAS(asIScriptEngine* engine, ScriptObjectCreationCache& creationCache) {
int r;
static const char* const strComponent = "Texture";
r = engine->RegisterObjectType(strComponent, sizeof(Texture), asOBJ_REF | asOBJ_GC); assert(r >= 0);
r = engine->RegisterObjectBehaviour(strComponent, asBEHAVE_FACTORY, "Texture@ f()", asInstanceMethod(creationCache, TSFactory), asCALL_CDECL); assert( r >= 0 );
r = engine->RegisterObjectBehaviour(strComponent, asBEHAVE_FACTORY, "Texture@ f(const string &in)", asInstanceMethod(creationCache, TSFactoryArg), asCALL_CDECL); assert( r >= 0 );
registerMembers<Texture>(engine, strComponent);
}
I would greatly appreciate any additional info.
edit: I left a pretty crappy post earlier because I had to quickly go somewhere.. I fixed it up now ;)