Possible bug

Started by
3 comments, last by Rain Dog 18 years, 10 months ago
Man I wrote this topic once but must have pressed preview !! Anyways. I have something like the following: struct myStruct{ int x;}; class myClass{ public: vector<myStruct> myVec;} The class is registered just fine through AS as a property. Its other methods (not shown) work fine. I have registered std::vector using Deyja's tool. Everything generally works fine, however, when i do the following in script: //Script myStruct[] A; A = MyClass.myVec; The error message: Error: Can't implicitly convert from myStruct[]& to myStruct[]& Something is afoul.
Advertisement
It does indeed look like a bug.

It is probably related to the changes I made in how array objects are handled by the compiler. I assume that you are using version 2.2.0 or 2.2.1 WIP 1, am I right?

I'll look into this as soon as I can.

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

2.2.0WIP 5


I have not been aware of any release after that, but I looked at the site ( i generally come here ) and noticed that you have uploaded WIP2 even of 2.2.1
Sorry about the late answer, but I've been very busy at work and only got some time to look into this now.

It seems that this isn't a bug after all, although AngelScript should definitely give some better error message in this case.

You must have registered the myVec property of MyClass before registering the overloaded MyStruct[] array type. This makes AngelScript think that myVec is a built-in array type, which is not compatible with the overloaded MyStruct[] array type.

The following test works:

// Configure enginer = engine->RegisterGlobalFunction("void Assert(bool)", asFUNCTION(Assert), asCALL_CDECL); assert( r >= 0 );r = engine->RegisterObjectType("MyStruct", sizeof(MyStruct), asOBJ_CLASS); assert( r >= 0 );RegisterVector<MyStruct>("MyStruct[]", "MyStruct", engine);r = engine->RegisterObjectType("MyClass", sizeof(MyClass), asOBJ_CLASS_CD); assert( r >= 0 );r = engine->RegisterObjectBehaviour("MyClass", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(MyClass_Construct), asCALL_CDECL_OBJLAST); assert( r >= 0 );r = engine->RegisterObjectBehaviour("MyClass", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(MyClass_Destruct), asCALL_CDECL_OBJLAST); assert( r >= 0 );r = engine->RegisterObjectProperty("MyClass", "MyStruct[] myVec", offsetof(MyClass,myVec)); assert( r >= 0 );// Compile and execute scriptengine->AddScriptSection(0, TESTNAME, script2, strlen(script2), 0);r = engine->Build(0, &out);if( r < 0 ){	fail = true;	printf("%s: Failed to compile the script\n", TESTNAME);}r = engine->ExecuteString(0, "Test()", 0, &ctx);if( r != asEXECUTION_FINISHED ){	printf("%s: Failed to execute script\n", TESTNAME);	if( r == asEXECUTION_EXCEPTION )		PrintException(ctx);			fail = true;}


The script is the following:

void Test()             {                         MyStruct[] A;           MyClass B;              A = B.myVec;            Assert(A.size() == 2);}                       


The constructor for MyClass, resizes the myVec array to 2 elements.

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

Ok, it's highly likely that that was the case. I have since changed the order in which my objects were registered so I can't say for sure if that was the problem or not.

I also changed property to use an accessor.


This topic is closed to new replies.

Advertisement