Advertisement

Object handles script syntax

Started by December 09, 2005 08:07 AM
2 comments, last by Lbas 18 years, 11 months ago
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
Lbas
@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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
I've fixed the bug and will release a new version this weekend.

Thanks for letting me know about the bug.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

As always, great job, andreas !
Thanks,

Best Regards,
Lbas
Lbas

This topic is closed to new replies.

Advertisement