Alon's suggestion to put something on the wiki impelled me to write a tutorial for using emscripten::val to call into JavaScript from C++. This is convenient when you have a C++ codebase and want to make a few quick calls into JavaScript.
Using Web Audio API from C++ with emscripten::val: https://github.com/kripken/emscripten/wiki/Using-Web-Audio-API-from-C---with-emscripten::val On Sun, Apr 13, 2014 at 2:19 PM, Alon Zakai <[email protected]> wrote: > Info looks correct, thanks - please feel free to add that to the relevant > wiki page(s). > > - Alon > > > > On Sun, Apr 13, 2014 at 11:39 AM, Joshua Litt <[email protected]>wrote: > >> Just in case someone comes later and wants to know - to call JS from >> emscripten C++ is a bit non obvious. The wiki has a few terse lines about >> the procedure, but actually omits some of the details. >> >> First of all, in C++ you do the following: >> extern "C" { >> extern void my_js(void* a, void* b); >> } >> >> For whatever you want the prototype to be. >> >> Then, you create a JS file which will be linked with your compiled C >> code. The format of the JS file is odd: >> mergeInto(LibraryManager.library, { >> my_js: function(a, b) { >> console.log(a + " " + b); >> call_into_actual_code(a, b); >> } >> }) >> >> where call_into_actual_code is some other JS function in your normal JS >> frontend. >> >> The final step - you don't include the JS file which is linked in with >> emscripten into your webpage. The test mentioned in the wiki does have >> this information, but its kind of tough to pick out in a 2500 line python >> file. >> >> I have to say, this is one amazingly awesome project! Huge thanks to the >> team(also please correct any of the above info if its wrong) >> >> -- >> 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. > -- 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.
