I managed to add bindings to my library, thanks. However, most of the functions in the library rely on passing char* back-and-forth, so adding wrapper functions to all of them is unfeasible. It would also make the API look different from JS than from C, which is a blocker for me. Do you maybe know when char* support would be added to embind? — Lóránt
On Tue, Aug 26, 2014 at 10:31 PM, Chad Austin <[email protected]> wrote: > I believe that's on the embind todo list. (Since pointers don't have > unambiguous semantics, the bindings would need explicit pointer policies, > and that work hasn't been done yet.) > However, there's a workaround! You can do something like: > #include <Library.h> > // assume Library.h declares: void libraryFunction(const char*); > static void libraryFunctionWrapper(const std::string& s) { > libraryFunction(s.c_str()); > } > EMSCRIPTEN_BINDINGS(Library) { > function("libraryFunction", &libraryFunctionWrapper); > } > On Tue, Aug 26, 2014 at 1:28 PM, Lóránt Pintér <[email protected]> > wrote: >> Hi, >> >> Is it possible in embind to treat char* as a JS string? If not, how can I >> call a C function with a char* parameter from JS? >> >> Thanks >> — >> Lóránt >> >> -- >> 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. >> > -- > Chad Austin > Technical Director, IMVU > http://engineering.imvu.com <http://www.imvu.com/members/Chad/> > http://chadaustin.me > -- > 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. -- 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.
