Advertisement

Wrong parameters order in constructor

Started by February 04, 2009 06:15 PM
1 comment, last by WitchLord 15 years, 9 months ago
Hello, I've encountered following issue: class Whatever { Whatever(uint x, uint y) { Log("X, Y: " + x + ", " + y); } } for(uint i = 0; i < 100; i ++) { Whatever whatever(i, i*10); } And the output is: X, Y: 0, 0 X, Y: 10, 1 X, Y: 20, 2 X, Y: 30, 3 and so on... The issue arose with latest revisions (349 and 350), but I've encountered it once before when tried to call constructor from constructor: class Cl { uint x; uint y; Cl(uint x) { Cl(x, 1); } Cl(uint x, uint y) { this.x = x; this.y = y; } }
Thanks scypior,

You're absolutely right. I'll have this bug fixed right away.

AngelScript doesn't support calling another constructor from within a constructor. That syntax should have created a new instance of the object.

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

Advertisement
The loop in asCCompiler::CompileFactory (as_compiler.cpp, line 187) was inverting the order of the arguments. The loop should be changed to the following:

int asCCompiler::CompileFactory(asCBuilder *builder, asCScriptCode *script, asCScriptFunction *outFunc){  ...	// Copy all arguments to the top of the stack	int argDwords = (int)outFunc->GetSpaceNeededForArguments();	for( int a = argDwords-1; a >= 0; a-- )		byteCode.InstrSHORT(BC_PshV4, -a);  ...}


I'll have this checked in as soon as possible.

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