-
Notifications
You must be signed in to change notification settings - Fork 27
WASM bindings in ACT (through emscripten) #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…e). However, some important patches need to be moved. So binding is not functional
…ated through Python
…e seems to work too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
…e WASM bindings automatically (with cleanup)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces WASM (WebAssembly) bindings for ACT through Emscripten. The implementation allows automatic generation of JavaScript-friendly bindings from C++ implementations, making it easier to use ACT-generated components in web environments.
Key changes include:
- Adds complete WASM binding generation functionality to ACT's code generation pipeline
- Introduces wrapper generation for structs, classes, and methods to handle JavaScript interoperability
- Provides build tooling and examples for compiling WASM bindings using Emscripten
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
Source/buildbindingwasm.go | Core WASM binding generator with struct wrappers, method wrappers, and Emscripten bindings |
Source/automaticcomponenttoolkit.go | Integration of WASM binding generation into ACT's main workflow |
Examples/RTTI/RTTI_component/Examples/WASM/buildWASM.py | Python build script for compiling WASM bindings using Emscripten |
Examples/RTTI/RTTI_component/Bindings/WASM/rtti_bindings.cpp | Generated WASM binding file demonstrating the output |
Examples/RTTI/RTTI.xml | Configuration update to enable WASM binding generation |
Build/build.sh | Build script update to include the new WASM binding source file |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Vijai, overall looks good, check the comments from me and copilot. The one regarding indices looks doubtful. If its possible, it can be improved by adding error handling, input and output validations.
Regarding the return type and resolveCppType: is it always string from/to javascript? Is anyother type possible?
Also the binding implementation skips ImportedComponentDefinitions . Do you think it can be added later if its feasible?
… be any random string
…tToolkit into develop
Only string and bool are handled in resolveCppType. The else case deals with everything else. Everything isn't a string. |
Yes, it can be added later. |
@gangatp All of the comments in the PR have been addressed. The rest of the improvements can be made in future. |
@gangatp Now ACT generates a minimal example for WASM in line with other bindings. I have also included a relevant build script for WASM and included a more useful example. All of them run locally without issues. |
@gangatp I have also modified the Dockerfile for GitHub Actions. WASM examples are also built now by GitHub Actions. |
lib3mf_emscripten
repository work seamlessly with the bindings generated via ACT.Key Features
classParam
in ACT. We detect these and automatically make it work inside bindings. However, users can simply use pointers in Javascript. Here is an exampleIn the highlighted line above
AddLink
is actually supposed to have a signature like this in CppHowever, this cannot be implicitly constructor in WASM. So, we have a wrapper like this
This is automatically generated for all functions making it easy to write JS friendly code.
Known Issues
classParam<T>
is used in many methods in the volumetric extension.