Use codegen for FFI / style builder
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 222
- Avg merge
- 10h 41m
- Merged PRs (30d)
- 40
Description
## What problem does this solve or what need does it fill?
Bindings to languages other than Rust require a lot of repetitive type/function definitions (repeated across each set of bindings, and again in the core library).
## What solution would you like?
A custom codegen solution similar to Yoga's [enums.py](https://github.com/facebook/yoga/blob/main/enums.py) (but also covering style getters/setters) that could be used to generate (parts of) each FFI implementation, and also for implementing a style builder in the Rust API (and *maybe* also for definining the core implementations of some style enums.
## What alternative(s) have you considered?
- **Custom code for each FFI binding**. This will be hard to maintain / limit the number of language bindings we can support.
- **Using custom derives / macros to generate code**. This was initially my preferred approach but doesn't seem viable in practice due to differences in the API required by the specifics of each language (e.g. how one binds to C may be different to how ones binds to JS/WASM)
- **Generic FFI libraries like uniffi**. These seem to suffer from similar limitations to the macro approaches, and also have a limited set of languages they support, and are opinionated about how to bind to the language. They may be more viable in future.
Other solutions to solve and/or work around the problem presented.
## Additional context
- https://github.com/DioxusLabs/taffy/pull/404
- https://github.com/DioxusLabs/taffy/pull/394
- https://github.com/DioxusLabs/taffy/issues/275
---
**Note: This is not blocking for releasing bindings but will likely be wanted before adding more than one or two sets of bindings.**
Contributor guide
Research direction
Start by reviewing pull requests 404 and 394 and issue 275 to understand the existing binding definitions and style APIs. Compare the repeated FFI and Rust style-builder work described there, then establish the supported generation targets and scope; done should mean an agreed codegen approach covering the required bindings and style getters/setters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100