Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualizackp

Posted 28 February 2013 - 12:37 PM

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 ;)


#4izackp

Posted 28 February 2013 - 12:30 PM

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. 


#3izackp

Posted 28 February 2013 - 12:26 PM

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.


#2izackp

Posted 28 February 2013 - 12:17 PM

Is it possible to pass a pointer to an instance function (&creationsClass.createScriptObject) when registering an object behavior? i need specific behavior for different instances of the script engine.


#1izackp

Posted 28 February 2013 - 10:49 AM

Is it possible to pass a pointer to a instance function (&creationsObj.createScriptObject) when registering an object behavior? i need specific behavior for different instances of the script engine?


PARTNERS