[angelscript] AS 2.2.0 WIP 3

  • From: "Andreas Jonsson" <andreas@xxxxxxxxxxxxx>
  • To: "angelscript" <angelscript@xxxxxxxxxxxxx>
  • Date: Sat, 7 May 2005 10:42:39 -0300

I've made a small addition for this version: auto handles.
It's now possible to register application functions as follows:

enigne->RegisterGlobalFunction("obj@+ PickOne(obj@+, obj@+)", 
asFUNCTION(PickOne), asCALL_CDECL);

void *PickOne(void *a, void *b)
{
  return chooseTheFirst ? a : b;
}

The library will then take care of increasing the reference counter on the 
returned object handle, and decrease the reference counter on the arguments 
once the function returns. This makes the C++ code a little simpler, though 
obviously at a small performance cost since the library has to dynamically 
determine what needs to be done. 

The main reason I added this feature, is that some application use a different 
set of rules for managing reference counters, or perhaps the application wishes 
to register functions that don't even know about any reference counters. 
Previously it was necessary to write wrappers for these cases, but that is no 
longer so.

I hope you like this addition.

I'm continuing to investigate the best way to implement garbage collection for 
the next WIP, that will introduce structures that can hold handles to other 
structures.

Regards,
Andreas
AngelScript - AngelCode Scripting Library
http://www.angelcode.com/angelscript/
http://www.angelcode.com/forums/

Other related posts:

  • » [angelscript] AS 2.2.0 WIP 3