Skip to content

Use FMOD C# API to generate this crate  #21

@lebedec

Description

@lebedec

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneed more coffeeExtra coffee is needed before I can do it

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions