Closed davlhd closed 4 years ago
Hi @davlhd
Unfortunately passing a map is not possible in Wren (I mean the native map), at least at the moment. There is some talk about that here: https://github.com/wren-lang/wren/pull/725 which is only relatively new.
But, it is possible to do it with foreign class maps or lists. Essentially, creating a C++ map in Wren, putting in the data, then passing that C++ map instance from the Wren back to the C++. I have written a wrapper for lists and have written a tutorial for it here: https://matusnovak.github.io/wrenbind17/tutorial/lists/ I haven't written a wrapper for maps yet, but if you give me few hours I can do that now.
As for passing native Wren arrays, that has not been implemented here in WrenBind17. I am more than happy to receive some suggestions on the API design of that, because it was in my to-do list.
@davlhd
I have added some basic support for std::map
and std::unordered_map
. It's done via StdMapBindings<Key, Value>::bind(module, "ClassName");
The changes have been pushed to the master.
You can read more about it here: https://matusnovak.github.io/wrenbind17/tutorial/maps/ The tutorial also contains some pointers on how to implement a custom wrapper for your map in case you use non-std map.
Unfortunately native Wren maps are not supported at the moment as I have mentioned in the previous comment.
Does this solve your problem?
Hello,
I am playing around with wrenbind17 and I can not figure out how to pass a Wren map or Wren array from Wren to C++. Is that possible?
Thanks, David