Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 May 2013
Offline Last Active Jun 13 2013 10:55 AM

Topics I've Started

Object Handle vs Object reference

15 May 2013 - 06:51 PM

Since I can use Object reference as parameters in my functions and the object handle is in fact NOT a pointer, is there really any reason of using (or even having) object handles? I just can't find that good reason.


The only difference I see is that I can reseat the object handle with different object and I can also use it as a return parameter of function.


I really don't know, I wanted to wrap my head around the need for object handles - especially the reason why I would want to use them, but since I can pass reference in functions, I can't find any reasonable reason to use them.

Is there some safety issue, speed issue or something else? Is there something obvious I don't see?


Give me some ideas. Thanks. Love the angelscript, I just want to understand it better.

Help with Copy Constructor and Object handle as argument

13 May 2013 - 07:27 AM

I am trying to do a copy constructor on asOBJ_REF class. Seems the asBEHAVE_CONSTRUCT does not apply to asOBJ_REF classes.


Any ideas?


I settled so far for 


RegisterObjectMethod("image", "void Copy(const image &in)", asMETHOD(CByteImage,Copy), asCALL_THISCALL); assert( r >= 0 );


However my image class asBEHAVE_FACTORY is all object  handles, but I seems not to be able to make the Copy accept the object handles as argument.


so I can go 



and it is fine





would throw compile error.


I tried

RegisterObjectMethod("image", "void Copy(const image @&in)", asMETHOD(CByteImage,Copy), asCALL_THISCALL); assert( r >= 0 );


and while it is accepted, the runtime runs into what seems an endless loop (well it does returns after 7 sec which is probably some protection in the angelscript), so I don't think this is how I am supposed to do it.


Any help & ideas?


BTW, speeds are pretty awesome. I use it for image processing (the looping through the pixels is the main toll) and the scripted version vs native code is about 10-12x slower. So if native version would be 35ms,, the scripted version would be for example 450 ms. I think that is pretty amazing.