Skip to content
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

Use FMOD C# API to generate this crate #21

Open
lebedec opened this issue Oct 16, 2024 · 0 comments
Open

Use FMOD C# API to generate this crate #21

lebedec opened this issue Oct 16, 2024 · 0 comments
Labels
enhancement New feature or request need more coffee Extra coffee is needed before I can do it

Comments

@lebedec
Copy link
Owner

lebedec commented Oct 16, 2024

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:

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.

@lebedec lebedec added enhancement New feature or request need more coffee Extra coffee is needed before I can do it labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need more coffee Extra coffee is needed before I can do it
Projects
None yet
Development

No branches or pull requests

1 participant