Assert on Parameters in constructor.

Started by
3 comments, last by WitchLord 19 years ago
I have a small small class that i would like to be able to pass a string reference object in as a parameter in the constructor of the object. The problem is that i get an assertion at this line: as_compiler.cpp line 229: // At this point there should be no variables allocated assert(variableAllocations.GetLength() == freeVariables.GetLength());
Advertisement
This looks like a bug in the library.

Could you show me the script statement you use to create this object? And how you registered the constructor function?

What version of the library are you using? 2.1.0 WIP 6?

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

r=engine->RegisterObjectBehaviour("File", asBEHAVE_CONSTRUCT, "void f(string &in)", asFUNCTION(FileInitConstructor), asCALL_CDECL_OBJLAST); assert(r >= 0);



The exception occures before the constructor is called, the script looks like this:

void main(){    File f("c:/test.txt");}



The constructor is basic:

static void FileInitConstructor(string &Path, ASFileIO *file){	new(file) ASFileIO(Path);}
Thanks. I'll try to fix this problem during the weekend (or earlier if possible).

The problem is in the compilation of the script, so the implementation of your constructor is not the cause of the problem. What I find the most strange is that I already have a test similar to this that works without problem.

From teststdstring.cpp:

engine->RegisterObjectType("obj", 4, asOBJ_PRIMITIVE);engine->RegisterObjectBehaviour("obj", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Construct1), asCALL_CDECL_OBJLAST);engine->RegisterObjectBehaviour("obj", asBEHAVE_CONSTRUCT, "void f(string &in)", asFUNCTION(Construct2), asCALL_CDECL_OBJLAST);engine->RegisterObjectBehaviour("obj", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(Destruct), asCALL_CDECL_OBJLAST);// Verify that it is possible to use the string in constructor parametersengine->ExecuteString(0, "obj a; a = obj(\"test\")", &out);


It could be that you are declaring the variable with the constructor parameters directly, whereas in my test I instanciate the object constructor as a temporary variable. I'll verify this.

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

I managed to fix the problem already. I hope to have the new version available tomorrow or the day after.

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