My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Fixed
Owner:  ----
Closed:  Feb 2012


 
Reported by browny.d...@googlemail.com, Sep 20, 2011
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.


Sep 24, 2011
#1 browny.d...@googlemail.com
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();
	}
Feb 8, 2012
Project Member #2 gameh...@gmail.com
This has been fixed by treating Array<Dynamic> as Dynamic.
Status: Fixed

Powered by Google Project Hosting