我正在使用webassembly,到目前为止,我能够管理emscripten将我的测试c项目编译为wasm文件
em提供了2个文件,即
mainTest.js mainTest.wasm
当我在我的html页面加载mainTest.js然后我得到一个名为的Java脚本对象
“模块”.
我确实找到了如何从javascript调用c / wasm方法,例如:
var myTestInteger = Module._callMyTestMethod();
并从中读取字符串
Module.wasmMemory.buffer
,但我不明白如何从C代码调用javascript.
即我希望能够像这样做:
#ifdef __cplusplus
extern "C" {
#endif
extern void testExternJSMethod();
int main()
{
cout << " Hello From my Test1 !" << endl;
testExternJSMethod();
return 0;
}
int EMSCRIPTEN_KEEPALIVE callMyTestMethod(){
return 26;
}
#ifdef __cplusplus
}
#endif
我正在加载另一个名为utils.js的js文件中的my js方法testExternMethod
function testExternMethod() {