Return std::string from cheerp::genericjs function
Got this working by peeking at the
client::String
definition, but would like to know if there is a cleaner alternative. Also, I don't quite get what is happening there. Is getLocal
fully converted to JS? How is it able to manipulate a std::string
? Thanks in advance :)
1 Reply
If you are using a nightly build you should be able to use
key.toUtf8()
to get a properly converted std::string
This code is indeed fully compiled to JavaScript. [[cheerp::genericjs]]
has full access to linear memory types like std::string
. On the other hand code compiled to WebAssembly cannot access JavaScript data.
One of the biggest advantage of Cheerp is the ability of easily mixing JavaScript and WebAssembly code from a single C++ codebase.