I'm using Angelscript for my game, it's going good so far except I had a problem I couldn't solve although I've tried everything. I've been reading the documentation but there was no reference there for this, so I'm posting it here.
r = engine->RegisterObjectBehaviour("Input", asBEHAVE_FACTORY, "Input@ f()", asFUNCTION(this->ScriptInput_Factory() ), asCALL_CDECL);
See, the factory function is in this bigger class "Scripting"(so this-> is the "Scripting" class), where all scripting related things go on, like registering globals etc. When I write the function static, it works(with other objects I've tried) but this time I need a variable in Scripting to create the class. When I open the application and create the object in script the application crashes at code execution. I've also done debugging, the factory function(Scripting::ScriptInput_Factory) is called properly. So, what could it be?
ScriptInput* Scripting::ScriptInput_Factory() is the decleration of the factory function.
Thank you in advance.
Edit : Fool me.. After another debugging I noticed the code above executes the function. I've done it like this in the first place but changed it, as I thought this wasn't supposed to be the way, when I got this nasty compiler error :
r = engine->RegisterObjectBehaviour("Input", asBEHAVE_FACTORY, "Input@ f()", asFUNCTION(&Scripting::ScriptInput_Factory ), asCALL_THISCALL);
error C2440: 'type cast' : cannot convert from 'ScriptInput *(__thiscall Scripting::* )(void)' to 'size_t'
1> There is no context in which this conversion is possible
1> d:\gamedev\the new game\scripting.cpp(134) : see reference to function template instantiation 'asSFuncPtr asFunctionPtr<scriptInput*(__thiscall Scripting::* )(void)>(T)' being compiled
1> with
1> [
1> T=ScriptInput *(__thiscall Scripting::* )(void)
1> ]