Advertisement

AngelScript 1.10.0 FINAL (2004/11/02)

Started by November 02, 2004 03:42 PM
44 comments, last by jetro 20 years ago
Hmm...I can't really chop my code up to provide a simple example, but I can describe the situation. I have an array of pointers to a class with properties and methods. In a loop i call a method that returns new instances

MyClass *[] c(5);int i;for(i=0;i<5;++i) {  c=RegisteredAllocatorForMyClass();  c->RegisteredDoStuff(45.0f,1.0f);}


And I get two problems:
the first, execution dies inside the for loop (but where, i'm not sure yet)
the second, if I change to MyClass [] and get rid of the allocation then I get No matching signatures to 'RegisteredDoStuff(const float, const float)'. I registered as non-const. If I change the registartion and internal methods to const I still get the error.

Also note that if I allocate like this

MyClass *ptr=RegisteredAllocatorForMyClass();


It does allocate (but I still get the No Matching signatures problem). That's all I've been able to figure out so far.
Dan Royer, OwnerMarginally Clever Games
Ok, that information might be enough for me to find the problem. I'll give it a try and let you know.

But before that I'd like to know if you noticed the post by Licu about the pointer related bug in AS 1.10? If you didn't then this may actually be what is causing your problems.

You'll find the bug fix for the -> operator in that thread.

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 added the fix for the -> operator and now I get an assert about
instr->StackSize == StackSize
Dan Royer, OwnerMarginally Clever Games
There seems to be a problem with arrays of pointers. I've written a test case using your example and it gives errors it shouldn't.

I'm looking into this right now, but I might not be able to fix it until Sunday.

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

Well that throws my schedule off a couple of days, but I'll find things to work on in the meantime. I wish you godspeed with whatever you're doing :)
Dan Royer, OwnerMarginally Clever Games
The problem I had found was related to me using integer to index the arrays. Once I change the type of n to uint it worked fine. (NOTE: I will improve the implicit casting rules for the next version)

void Test()                                {                                            class1*[] c(5);                            uint i;                                    for( i = 0; i < 5; ++i )                   {                                            c = class1Factory();                    c->function();                        }                                        }                                         


This compiles and executes without problem (except that the compiler reports c as uninitialized, which is a bug but not a critical one).

The assert(instr->StackSize == StackSize) is probably related to the first problem you mentioned. It seems the compiler is trying to dereference a registered object even though it shouldn't.

This might be related to how you have registered your type. Can you show me how you registered the type in question? The one that was being dereferenced?

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 meant to type uint. Sorry.

  asEngine->RegisterObjectType("ObjectInstance", sizeof(ObjectInstance), asOBJ_CLASS);  asEngine->RegisterGlobalFunction("ObjectInstance *CreateObjectInstance(ObjectType *type)",asFUNCTION(::CreateObjectInstance),asCALL_CDECL);  asEngine->RegisterGlobalFunction("void ReleaseObjectInstance(ObjectInstance *)",asFUNCTION(::ReleaseObjectInstance),asCALL_CDECL);  asEngine->RegisterObjectMethod("ObjectInstance","GfxTexture *GetTexture()",asMETHOD(ObjectInstance, GetTexture), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetTexture(GfxTexture *)",asMETHOD(ObjectInstance, SetTexture), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","GfxMesh *GetMesh()",asMETHOD(ObjectInstance, GetMesh), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetMesh(GfxMesh *)",asMETHOD(ObjectInstance, SetMesh), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","bool ComesBefore(ObjectInstance *)",asMETHOD(ObjectInstance, ComesBefore), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","ObjectType *GetType()",asMETHOD(ObjectInstance, GetType), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetPosition(float,float)",asMETHOD(ObjectInstance, SetPosition), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void GetPosition(float&,float&)",asMETHOD(ObjectInstance, GetPosition), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetVelocity(float,float)",asMETHOD(ObjectInstance, SetVelocity), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetAngle(float)",asMETHOD(ObjectInstance, SetAngle), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetAngularVelocity(float)",asMETHOD(ObjectInstance, SetAngularVelocity), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void AssignPhysics(ObjectPhysicsDescription &opd)",asMETHOD(ObjectInstance, AssignPhysics),asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetName(string &)",asMETHOD(ObjectInstance, SetName), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetStack(int pos,float v)",asMETHOD(ObjectInstance, SetStack), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","float GetStack(int pos)",asMETHOD(ObjectInstance, GetStack), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","void SetImmaterial(bool state)",asMETHOD(ObjectInstance, SetImmaterial), asCALL_THISCALL);  asEngine->RegisterObjectMethod("ObjectInstance","bool GetImmaterial()",asMETHOD(ObjectInstance, GetImmaterial), asCALL_THISCALL);
Dan Royer, OwnerMarginally Clever Games
Hmm, I can't see anything wrong with the way you registered the object.

I think I'll need to know what script function it is that is causing the assert failure. Would it be possible for you to find this? Simply comment out the script functions one by one until you find the one that fails compiling.

In the meanwhile I will look through the library code for possible causes.

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

ObjectInstance *[] instanceArray(5);uint i=0;instanceArray=ObtainObjectInstance(type);

is causing the problem.
Dan Royer, OwnerMarginally Clever Games
Unfortunately I don't seem to be able to reproduce the problem. Everything seems to work fine for me.

I will continue to search but without being able to reproduce the problem myself it is highly unlikely I'll find 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

This topic is closed to new replies.

Advertisement