After recent update, I get lots of "The operand is implicitly converted to handle in order to compare them" warnings, all from "hSth == (or !=) null".
I tried turning on asEP_ALLOW_IMPLICIT_HANDLE_TYPES, but that doesn't change anything. My handle types don't have copy operators (in fact, with exception of add-on array, they can't be instanced in script), so I could skip all @, and work with handles more like with pointers in c++. Does/will implicit handles work that way?
My engine uses run-time declared types that works like simplified class inheritance. Base class is defined in C++ (and can be derived from other class using single inheritance model) and run-time declared class can add extra properties and events (thanks for update with function pointers
void ASClassDownCast(asIScriptGeneric* gen)
{
void* p = gen->GetObject();
gen->SetReturnObject(p);
}
void ASClassUpCast(asIScriptGeneric* gen)
{
ITHEntity* pGE = static_cast(gen->GetObject());
if(pGE == NULL)
{
gen->SetReturnObject(NULL);
return;
}
int RetType = gen->GetReturnTypeId();
const ITHClass* pCls = pGE->GetClass();
while(pCls)
{
if(pCls->GetScriptType() == RetType)
{
gen->SetReturnObject(pGE);
return;
}
pCls = pCls->GetBaseClass();
}
gen->SetReturnObject(NULL);
}
void ASRegisterClassCastOp(asIScriptEngine* engine, const CTHString& SuperCls, const CTHString& DerivedCls)
{
int r = 0;
CTHString Decl;
Decl.Empty();
Decl << SuperCls << "@ f()";
r = engine->RegisterObjectBehaviour(DerivedCls.c_str(), asBEHAVE_IMPLICIT_REF_CAST, Decl.c_str(), asFUNCTION(ASClassDownCast), asCALL_GENERIC); assert( r >= 0 );
Decl.Empty();
Decl << DerivedCls << "@ f()";
r = engine->RegisterObjectBehaviour(SuperCls.c_str(), asBEHAVE_REF_CAST, Decl.c_str(), asFUNCTION(ASClassUpCast), asCALL_GENERIC); assert( r >= 0 );
}
I found that DownCast is more than 10x faster (I know it does little work). After code inspection i found that GetReturnTypeId (or rather GetTypeIdFromDataType) does lots of things (some loops, creating new type id's etc). And the question now. Can return type id be somewhere cashed or how can I speed things up a bit here?






