I found an reference bug in angelscript.
class A
{
A& do( );
};
A& A::do( )
{
... do something. ..
}
AS Code :
{
A a;
a.do( );
}
I use asOBJ_REF to count the object used number.
Release() will call 2 times. ( 1 time is correct, My refcount is 1 )
Thanks, I'll look into it.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
If I can reproduce the bug I'll fix it for the next version.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I haven't been able to reproduce this problem.
This is the class I wrote to test it:
And this is how I register it:
This only calls Release 1 time:
Did you perhaps register the Do() method with "refclass @Do()"? That would explains why AngelScript called Release() twice in your case.
This is the class I wrote to test it:
class CRefClass{public: CRefClass() { refCount = 1; } ~CRefClass() { } int AddRef() { return ++refCount; } int Release() { int r = --refCount; if( refCount == 0 ) delete this; return r; } CRefClass &Do() { return *this; } int refCount;};CRefClass *Factory(){ return new CRefClass;}
And this is how I register it:
r = engine->RegisterObjectType("refclass", sizeof(CRefClass), asOBJ_REF); assert(r >= 0); r = engine->RegisterObjectBehaviour("refclass", asBEHAVE_FACTORY, "refclass@ f()", asFUNCTION(Factory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("refclass", asBEHAVE_ADDREF, "void f()", asMETHOD(CRefClass, AddRef), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectBehaviour("refclass", asBEHAVE_RELEASE, "void f()", asMETHOD(CRefClass, Release), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("refclass", "refclass &Do()", asMETHOD(CRefClass,Do), asCALL_THISCALL); assert(r >= 0);
This only calls Release 1 time:
r = engine->ExecuteString(0, "refclass ref; ref.Do()");
Did you perhaps register the Do() method with "refclass @Do()"? That would explains why AngelScript called Release() twice in your case.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement