Map iteration
TheoSabattie opened this issue · comments
Hi',
static function main()
{
var test4:Map<String, Float> = new Map<String, Float>();
test4.set("test1", 5.2);
test4.set("test2", 99.2);
test4.set("test3", 0.001);
test4.keys();
for (i in test4) {
trace(i);
}
}
generated code:
static public function main ()
{
$test4 = new StringMap();
$test4->set("test1", 5.2);
$test4->set("test2", 99.2);
$test4->set("test3", 0.001);
$test4->keys();
$tmp = $test4->iterator();
while (($tmp->hasNext)()) {
$i = ($tmp->next)();
(Log::$trace)($i, new HxAnon([
"fileName" => "Main.hx",
"lineNumber" => 20,
"className" => "Main",
"methodName" => "main",
]));
}
}
Error:
Fatal error: Uncaught Error: Class 'haxe\ds\_hx_array_iterator' not found in C:\Users\Theo Sabattie\Desktop\testPHP\bin\lib\haxe\ds\StringMap.php:62 Stack trace: #0 C:\Users\Theo Sabattie\Desktop\testPHP\bin\lib\Main.php(18): haxe\ds\StringMap->keys() #1 C:\Users\Theo Sabattie\Desktop\testPHP\bin\index.php(12): Main::main() #2 {main} thrown in C:\Users\Theo Sabattie\Desktop\testPHP\bin\lib\haxe\ds\StringMap.php on line 62
StringMap generated code:
/**
* @return object
*/
public function getIterator ()
{
return $this->iterator();
}
/**
* @return object
*/
public function iterator ()
{
return new _hx_array_iterator(array_values($this->h));
}
/**
* @return object
*/
public function keys ()
{
return new _hx_array_iterator(array_map("strval", array_keys($this->h)));
}
_hx_array_iterator seems to be old genphp because you made an ArrayIterator class.
Thanks.
StringMap
is not implemented yet. It will be done as part of #12
Implemented in c6c8772