0.8.11 • Published 2 years ago

wasm2lua v0.8.11

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

🎉 wasm2lua 🎊

npm.io npm.io

travis ci

Have YOU ever wanted to run C++/C/Rust/javascript/banana/etc. on Lua without using native modules?

GOOD NEWS, fam: wasm2lua can compile WebAssembly modules to pure Lua (or with FFI LuaJIT for extra speed). This means that anything that can be compiled to WASM can be compiled to Lua! Long Live John Lua!

Notes

  • The generated code is heavily dependent upon the LuaJIT bit library
  • Some of @webassemblyjs's libraries are monkey patched at runtime
  • luamin is monkey patched at runtime
  • The WASI API is still under heavy development
  • Emscripten is NOT supported out of the box. You will need to compile things via the WASI ecosystem.

Usage

wasm2lua <in.wasm> <out.lua>

lua-webidl <in.idl> <out.cpp> --cpp

(Run those commands with --help for other options)

See HOWTO-BINDINGS.md in this repository for reference on how to use the WebIDL binder.

Installation

npm i -g wasm2lua

Projects that use wasm2lua

BONUS: duktape via wasm2lua

int main(int argc, char *argv[]) {
	duk_context *ctx = duk_create_heap_default();

	(void) argc; (void) argv;  /* suppress warning */

	duk_push_c_function(ctx, native_print, DUK_VARARGS);
	duk_put_global_string(ctx, "print");
	duk_push_c_function(ctx, native_adder, DUK_VARARGS);
	duk_put_global_string(ctx, "adder");

	duk_eval_string(ctx, "print('Hello world!');");

	duk_eval_string(ctx, "print('2+3=' + adder(2, 3));");
	duk_pop(ctx);  /* pop eval result */

	duk_destroy_heap(ctx);

	return 0;
}

duktape demo

0.8.9

2 years ago

0.8.11

2 years ago

0.8.10

2 years ago

0.8.8

2 years ago

0.8.7

2 years ago

0.8.6

2 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.0

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago