Hi evryone,
First, great job :). I've been playing for several days with squirrel, and I find it fantastic ...
Now, about the problem. The following code
class Base {
t = [0];
constructor()
{
::print(t[0] + " Base constructor\n");
t[0] ++;
}
}
::Base();
::Base();
::Base();
yields:
0 Base constructor
1 Base constructor
2 Base constructor
So the table t, is actulay one table shared by all instances of the class. It is not actualy a static member, because if you initialize it in the constructor ( t = [] ) everything works as expexted. Is this the inteded behaviour? I find it a little confusing, and I wasn't able to locate any reference in the documentation.
A quick search through the code showed, that the prooblem ( if it is really a problem ) is in the instance constructoe - sqclass.cpp line 145:
for(SQUnsignedInteger n = 0; n < nvalues; n++) {
new (&_values
![No [N]](/emoticons/emotion-45.gif)
) SQObjectPtr(_class->_defaultvalues
![No [N]](/emoticons/emotion-45.gif)
.val);
}
When instancing the new object should get complete copy of the defaultvalues and just a reference.
btw. Squirrel version 2.2. I haven't checked with the older versions.