I'm trying to register a C++ class into angelscript, here's the deal.
I MUST pass a value through the constructor into the class to do that I need to have the factory method be in my scriptingmanager class that looks like this
Image* ScriptingManager::ImageFactory(std::string& mFilename) {
return new Image(mFilename, this->m_pAFEngine->GetDriver());
}
ok the line that throws the error is this one.
r = this->m_pEngine->RegisterObjectBehaviour("Image", asBEHAVE_FACTORY, "Image f(string &in)", asMETHODPR(ScriptingManager, ImageFactory, (std::string&), Image*), asCALL_CDECL); assert(r >= 0);
with the error being
Message: Failed in call to function 'RegisterObjectBehaviour' with 'Image' and '
Image f(string &in)' (Code: -24) , On Line: 0Assertion failed: r >= 0, line 102
at this point i've tried these calls
r = this->m_pEngine->RegisterObjectBehaviour("Image", asBEHAVE_FACTORY, "Image@ f(string filename)", asMETHODPR(ScriptingManager, ImageFactory, (std::string), Image*), asCALL_CDECL); assert(r >= 0);
r = this->m_pEngine->RegisterObjectBehaviour("Image", asBEHAVE_FACTORY, "Image@ f(string &in)", asMETHODPR(ScriptingManager, ImageFactory, (std::string&), Image*), asCALL_CDECL); assert(r >= 0);
However when I call it like this
r = this->m_pEngine->RegisterObjectBehaviour("Image", asBEHAVE_FACTORY, "Image f(string &in)", asFUNCTIONPR(ImageFactory, (std::string&), Image*), asCALL_CDECL); assert(r >= 0);
All is well, unfortunatly that solution will not work for me as things need to be passed from the class into it.