Jump to content
  • Advertisement
Sign in to follow this  
Sir Ementaler

Incorrect results from functions returning function handles.

This topic is 950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Running AngelScript 2.31.1 WIP revision 2319, I have a script method registered in the following way:

ASengine->RegisterObjectMethod("Object", "func@ opCast()", asMETHOD(Object, operator asIScriptFunction*), asCALL_THISCALL);

where Object is a class and func is a funcdef. The method is implemented in such a way that it may return both null and non-null handles, but all results are considered null by the following script:

void main() {
	Object o;
	if (cast<func@>(o) is null)
		print("null");
}

I attempted to reproduce this using only a script, but the bug seems to occur only in application-registered functions. I spent some time debugging, and from what I understand, the function handle is erroneously placed into valueRegister instead of objectRegister because line 726 of as_callfunc.cpp doesn't predict function handles as returned types. Modifying the line to

if ( (descr->returnType.IsObject() || descr->returnType.IsFuncdef()) && !descr->returnType.IsReference() )

appears to fix the problem in this case.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!