var worksheet : Worksheet = workbook.Sheets['somesheetname'];
so, array access with a string. But how can I write the extern so I can
do array access with strings?
I tried:
extern class Workbook {
public var Sheets:Map<String,Worksheet>;
}
but I get errors like this one:
No @:arrayAccess function accepts argument of Int
Thanks!
Nathan
Dan Korostelev
unread,
Nov 11, 2015, 9:24:41 AM11/11/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Haxe
For such an extern where array-access is used in JavaScript API, you most probably want to use haxe.DynamicAccess instead of Map, since Map is a Haxe-implemented class and it doesn't map to plain javascript objects, unlike haxe.DynamicAccess.
Also, the `No @:arrayAccess function accepts argument of Int` means that you try to pass integer key when String (or other) type is expected.
среда, 11 ноября 2015 г., 17:17:31 UTC+3 пользователь Nathan Hüsken написал:
Nathan Hüsken
unread,
Nov 11, 2015, 9:58:34 AM11/11/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to haxe...@googlegroups.com
Hey,
Thanks that works! I have a follow up question. What do I do, when
direct array access is possible? Like this:
var cell : Cell = sheet['cellName'];
where "sheet" is of type extern class Sheet?
Can I somehow derive from haxe.DynamicAccess[Cell]? I tried that, but it
did not work.
I also tried:
extern class Sheet {
@:arrayAccess
public function get(c : String) : Cell;
@:arrayAcess
public function set(c : String, c : Cell) : Cell;
}
but it also does not work.
Thanks!
Nathan
tom rhodes
unread,
Mar 8, 2017, 10:25:21 AM3/8/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to haxe...@googlegroups.com
Digging up an old post here :)
@Nathan, did you get any working externs done? I need to do the exact same thing and have run into the exact same issues.
For Sheet I have...
package;
extern class Sheet
{
@arrayAccess
public function get(key:String):Dynamic;
@arrayAccess
public function set(key:String, value:Dynamic):Dynamic;
function getCell(address:Dynamic):Dynamic;
}
But I'm getting errors like "Array Access is not allowed on Sheet"...