Hi Sebastian, This is really nice! I watched your talk as well at CppCon ( https://www.youtube.com/watch?v=CLuhogat6aY), very interesting.
For a while it's seemed like we need something in this general area, so it's great to see it happen! I think this is a very good design, too (the performance issue with strings is the one concern I have, but as you say in the talk, that can be optimized - I'd use EM_JS for that probably). Did you have ideas about integrating this with upstream Emscripten? I think that might make sense to do, although maybe as part of a larger conversation on our bindings story (atm we have embind and the WebIDL binder, which already have some overlap). - Alon Zakai On Tue, Dec 28, 2021 at 2:21 AM Sebastian Theophil <stheop...@gmail.com> wrote: > Hi, > > I wanted to plug my own project for some time here on the mailing list > because it also handles JavaScript - C++ interop and now wajic came up so I > thought I pitch in. > > My project https://github.com/think-cell/typescripten produces type-safe > C++ interfaces to JavaScript standard libraries or third-party libraries. > It reads TypeScript interface definition files and transforms them into C++ > shims based on emscripten. > > The resulting C++ code is often a straight-forward port from > TypeScript/JavaScript, e.g., > > JavaScript: > > var elem = document.createElement("p") > elem.innerText = "Hello CppCon 2021" > elem.style.fontSize = "20.0" > document.body.appendChild(elem) > > C++: > > auto elem = js::document()->createElement(js::string("p")); > elem->innerText(js::string("Hello CppCon 2021")); > elem->style()->fontSize(js::string("20vh")); > js::document()->body()->appendChild(elem); > > No macros and the C++ functions return typed JavaScript objects! Because > we use the TypeScript interface definitions, the C++ code is typechecked. > Passing a number to fontSize will create a compiler error. > > The project is not yet meaningfully complete but it bootstraps > successfully, i.e., the compiler understands the interface definition file > for the TypeScript compiler and parser API that it uses itself. TypeScript > generic constraints are not yet supported, for example, but should be. > > Maybe somebody else finds this useful. We have used it internally for a > small web app already that needed to call the tableau.com JavaScript API. > > Regards > Sebastian > > -- > 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 emscripten-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/CAN%3D%3DuddahRRPV02%3DT9TaQd2%3D3YzxqHDBAqg8%3DsWJL-Taqh4-SQ%40mail.gmail.com > <https://groups.google.com/d/msgid/emscripten-discuss/CAN%3D%3DuddahRRPV02%3DT9TaQd2%3D3YzxqHDBAqg8%3DsWJL-Taqh4-SQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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 emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpSo_RuoctMU1TZObpugbtxS%3DgqrU-41typx2LuDKKMkWw%40mail.gmail.com.