Original Post
Hi, I do my best to try understand how handles work, but still hesitate to use them because I'm afraid there'll still some confusion for script writers. So I did some tries and have some questions about it. Here's a snippet of pseudo code, with my understood in comments, please let me know if I'm wrong:
// c++
class ACLASS
{
...blabla..AddRef..bla..Release()
int m_nValue; // setted to 0 by ctor()
}
// script
ACLASS obj; // creates an ACLASS instance in stack
ACLASS obj2; // creates an ACLASS instance in stack
ACLASS@ hObj; // creates an ACLASS handle (=null)
hObj.m_nValue = 1; // illegal, Null pointer access, hObj pointing to nothing
hObj = obj; // illegal, Null pointer access, hObj pointing to nothing
@hObj = obj; // hObj now points on obj, obj.refCount = 2
@hObj = @obj; // ??? seems to be same than above, what's the differences ???
obj2.m_nValue = 2;
hObj = obj2; // copy the contents of obj2 into obj (obj.m_nValue=2)
obj2.m_nValue = 3;
obj = obj2; // copy the contents of obj2 into obj (obj.m_nValue=3)
@obj = obj2; // ??? what's supposed to do ??? (seems to be allowed)
As you can see, there's mainly 2 points that confuse me (where there's ??? in comments) because we can write it in script. Without these, I think I would right understand object handles principles. Thanks in advance, Lbas