Created
September 13, 2021 08:35
-
-
Save carlopi/6b38fe1f2347a8cd712a9e9ff83c47ad to your computer and use it in GitHub Desktop.
Wrapping Cheerp ES6 modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[cheerp::jsexport]]int add(int a, int b) | |
{ | |
return a+b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
/opt/cheerp/bin/clang++ add.cpp -cheerp-make-module=es6 -o add.js -O3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {add} from "./wrap_add.js" | |
console.log(add(23, 19)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import instantiate from './add.js' | |
var module = await instantiate(); | |
var add = module.add; | |
export {add}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment