MotleyCoderDev / wasm2brs

Bringing the power of WebAssembly to the Roku and supporting languages like C/C++/Rust.
https://motley-coder.com/2020/12/20/webassembly-on-roku/
Other
50 stars 5 forks source link

How do I make GUI program with wasm2brs? #2

Closed TheEpicFace007 closed 3 years ago

TrevorSundberg commented 3 years ago

Hi Vini,

C/C++ code can import functions from BrightScript can call them directly as long as they only take primitives such as Byte, Integer, LongInteger, Float, Double. This is because these types have a direct translation to WebAssembly. See for example: https://github.com/MotleyCoderDev/wasm2brs/blob/30bce4e437dce1a6bec1511ba465ae7b53d24f83/include/roku.h#L18 The ROKU_BUILTIN(...) will import a function defined in BrightScript under that exact name, such as Sleep.

That said, just like in WebAssembly there is no way without a binding/glue layer to import functions that take and return BrightScript objects. That means you'll need to write glue code in BrightScript that you then call from C/C++/Rust, and the glue code can only use primitive data types.

I personally see this library as being more useful for compiling and binding libraries to BrightScript, rather than writing an entire gui in C/C++. If you have other questions feel free to ask :)