-
Notifications
You must be signed in to change notification settings - Fork 7
Description
The main feature of this crate is that it is automatically generated. This allows to maintain the current version with minimal costs (as a pet project, no real development required).
A current implementation of generator works in few steps:
- parse FMOD C headers to collect API definition
- parse FMOD documentation additionally to fix some introspection issues
- generate FFI (no problems here, the result is even better than
bindgen) - apply some conversion rules to map FFI into Rust idiomatic API
But real using experience over more than a year has shown that this implementation does not work well enough.
The main problem is that the C API does not provide full type introspection (especially for arrays and mutable structures via *pointers). Together with inconsistent naming this leads to the fact that in some places the generated code is still ugly or does not implement the API correctly.
For example:
- (method overloading) Cannot create sound from byte array #11
- bad naming, case conversion errors like
object_3_dupdate,Convolutionreverb, etc - Correct generation of array arguments #8
- A lot of functions do not return the correct types or take incorrect parameters #6
Solution
We can use FMOD C# API version to implement new generator (or Unity version if it is different?). It solves the problem mentioned:
- C# reflection can be used to provide API definition without parsing
- Defines correct and more suitable types for Rust API
- Provides method overloading for example, create_sound
- Provides the naming as it was intended by the FMOD developers
The main task here is to implement matching and calling of FFI functions.