@guillegpra/mini-playground
v1.0.1
Published
Mini Playground: Uses a C program compiled to WASM
Readme
Playground demo
First version demo playground based on Monaco Editor and Emscripten.
How it works
The playground asks the user for code input using Monaco Editor and when the user clicks on the Run button, it calls the upper_case function written in C in the file core/to-upper-case.c.
The upper_case function is executed in JavaScript thanks to Emscripten. This tool is a compiler that compiles C and C++ code to WebAssembly or a subset of JavaScript. Thus, the to-upper-case.c is compiled with emcc command exporting the upper_case function to use it in our page.
$ emcc to-upper-case.c -s EXPORTED_FUNCTIONS='["_upper_case","_main"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]' --post-js to-upper-case.js -o out.jsNOTE: In case you want to run this command, make sure your machine has Emscripten installed. See how to install it here.
Installation
Clone this repository and install Monaco Editor:
$ npm install monaco-editorOr run the builder.sh script:
$ ./builder.shThen, run index.html against your localhost.
Documentation
Documentation for this module is auto-generated using JSDoc. It might be necessary to install it, which can be done globally:
$ npm install -g jsdocOr locally:
$ npm install --save-dev jsdocTo generate the documentation, run the command jsdoc (or ./node_modules/.bin/jsdoc if it was installed locally) with the configuration file conf.json.
$ jsdoc -c conf.jsonThe HTML documentation will then be saved in the out folder.
