| Issue 138: | Arrays in function calls on CPP Target is not a pointer | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
import flash.Lib;
class Sample
{
public var _myArray:Array<String>;
public function new()
{
_myArray = new Array<String>();
_myArray.push("String1");
_myArray.push("String2");
trace('right' + _myArray.length);
clear(_myArray);
trace('wrong' + _myArray.length);
var i:Int;
for (i in 0..._myArray.length)
_myArray.pop();
trace('right' + _myArray.length);
}
public static function clear(array:Array<Dynamic>)
{
var i:Int;
for (i in 0...array.length)
array.pop();
}
public static function main()
{
new Sample();
}
}
If I compile the code to windows cpp 32 bit The Array is not cleared with the function. Compiling to flash works. Seems like Arrays are not passed to the function in cpp as pointer (vb would be by reference?)
What is the expected output? What do you see instead?
Expected and works for example on flash target
2
0
0
I see
2
2
0
What version of the product are you using? On what operating system?
Windows7 target cpp 32 nme 3.01 hxcpp 2.08
Please provide any additional information below.
Feb 8, 2012
This has been fixed by treating Array<Dynamic> as Dynamic.
Status:
Fixed
|
Additional finding: If i change the function parameter to array:Array<String> it works correct on cpp. So the bug is only with the dynamic datatype. public static function clear(array:Array<String>) { var i:Int; for (i in 0...array.length) array.pop(); }