// 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
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Object handles script syntax
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:
@hObj = obj; // hObj now points on obj, obj.refCount = 2@hObj = @obj; // ??? seems to be same than above, what's the differences ???
These mean the exact same thing. In the first alternative the compiler implicitly converts the rvalue to a handle since it knows that you're trying to copy the handle, not the object.
@obj = obj2; // ??? what's supposed to do ??? (seems to be allowed)
This ought to have given a compiler error. You've found a bug with this scenario. I'll have to fix this a.s.a.p.
Regards,
Andreas
I've fixed the bug and will release a new version this weekend.
Thanks for letting me know about the bug.
Regards,
Andreas
Thanks for letting me know about the bug.
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement