I read this in the documentation:
"Remember that it is legal for the script to attempt a cast on a null pointer, in which case the result is also a null pointer. This means that the reference cast behaviour must not be implemented as a virtual class method, because then the call will crash if the object pointer is null."
However, if I actually implement this like this:
r = m_engine->RegisterObjectMethod(name, "void opCast(?&out)", asFUNCTION(ScriptClassCast), asCALL_CDECL_OBJFIRST); assert(r >= 0);
With this being the signature for ScriptClassCast:
static void ScriptClassCast(void* obj, void** outRef, int typeId);
I get a null pointer access exception on this line of Angelscript:
Derived@ test = cast<Derived>(foo.someNullHandle);
And the ScriptClassCast function to actually perform the cast is not called.
It looks like I'm mostly doing the same thing as the documentation states, except that I'm testing against the derived class at run-time (eg via "?&out")
Any help would be appreciated!