mirror of
https://github.com/bytedream/litbwraw.git
synced 2025-05-09 12:15:13 +02:00
16 lines
534 B
JavaScript
16 lines
534 B
JavaScript
async function main() {
|
|
const wasm = await import('./target/wasm32-unknown-emscripten/debug/example-library.js');
|
|
const module = {
|
|
print: (str) => console.log(str),
|
|
printErr: (str) => console.error(str),
|
|
}
|
|
|
|
const exampleLibrary = await wasm.default(module);
|
|
const luaInstance = exampleLibrary.ccall('lua_new', 'number', [], []);
|
|
const luaExecute = exampleLibrary.cwrap('lua_execute', null, ['number', 'string']);
|
|
|
|
luaExecute(luaInstance, 'print("Hello from WebAssembly Lua!")');
|
|
}
|
|
|
|
main();
|