I can't speak to the nuances of what you are trying to do, personally I abandoned embind when it became clear I would end up having to wrap my entire api anyways. The regular emscripten C interfaces are pretty intuitive, though I am not sure there is anyway to pass in structs and this has made it a real pain for me(20+ arguments to functions).
This article: http://kapadia.github.io/emscripten/2013/09/13/emscripten-pointers-and-pointers.html explains well how to pass in arrays to emscripten compiled C, you can wrap your C++ functions in C and then pass in arrays that way. Sorry I can't help more with embind. On Saturday, April 12, 2014 2:19:34 AM UTC-7, [email protected] wrote: > > I am in the process of porting a crypto implementation to JS using > emscripten. The compilation of C++ code to js is pretty smooth. But I have > some issues in dealing the interaction of JS and compiled C++ code. I have > a few question and hope to get some advice from this list. > > 1. In recent releases uses fastcomp, and and it seems embind no longer > works. If I use 'extern "C"' to disable the c++ mangling, and use cwrap > to call c function from Js, it should work, right? > > 2. I personally prefer to use "embind", that allow me to expose C++ class > to JS directly. I will have to use 12.0 or earlier release. Is it a > recommended practice? Can I expect embind be supported again? > > 3. I need to pass ArrayBuffer from JS to compiled C++ code, and get back a > new (or modified) ArrayBuffer. It is not clear to me how can I do it. The > simplified code will be something like this: > class MyCrypto { > MyCryto(); > > void Process(const string& input, vector<string>& output); > }; > > EMSCRIPTEN_BINDINGS(MyCryptoModule) { > class_<MyCrypto>("MyCrypto").constructor() > .function("Process", &MyCrypto::Process); > register_vector<std::string>("VectorString"); > } > > > This code compiled well. But I don't know how JS code can be written to > call function. > > var crypto = new Module.MyCrypto(); > crypto.Process(...); > > I would like the input to be ArrayBuffer, > var input = new ArrayBuffer(256); > > What will be the output look like? Will this work at all? > > If std::vector brings trouble, I can give it up and change "output" to be > std::string. > void Process(const string& input, string& output); > > Compiler will complain about this form. > error: non-const lvalue reference to type 'basic_string[[3 * ...]>' cannot > bind to a temporary of type 'basic_string[[3 * ...]> > > Thanks in advance > > lucoy > > > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
