Funcdefs are not tracked properly by the engine

Started by
1 comment, last by Solokiller 8 years, 5 months ago

It appears that funcdefs are not tracked properly by the engine. Registering a funcdef, and then attempting to retrieve it immediately afterwards results in a null pointer being returned:


const int iTypeId = pEngine->RegisterFuncdef( "void foo()" );

asIScriptFunction* pFunction = pEngine->GetFuncDefFromTypeId( iTypeId );

From what i can tell, the internal type id to object type map isn't updated to include funcdefs.

Because of this, IsCompatibleWithTypeId doesn't work either.

Advertisement

asIScriptEngine::RegisterFuncdef does not return a type id, that's why GetFuncdefFromTypeId doesn't find anything. It's unofficial (i.e. not documented and subject to change) but RegisterFuncdef currently returns the internal function id for the funcdef. The GetFunctionById method can be used to retrieve the asIScriptFunction for that id.

To get the actual type id for the funcdef you need to use asIScriptEngine::GetTypeIdByDecl.

Regards,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Alright, thanks. I was able to solve my problem by retrieving the funcdef using the previous funcdef count as a starting point, then using GetFuncdefByIndex to get it.

This topic is closed to new replies.

Advertisement