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

Create FFI metatypes for the most commonly used cdata types to make creating and managing them more user-friendly #504

Open
8 tasks
Duckwhale opened this issue Feb 10, 2024 · 0 comments

Comments

@Duckwhale
Copy link
Member

Duckwhale commented Feb 10, 2024

The FFI bindings provide interfaces to a lot of (object-oriented or OOP-like) C and C++ libraries. But using them is too cumbersome. Partially, this is by design; the idea is to provide layered APIs, and the higher-level ones would be easier to use.

Nonetheless, it should be possible to employ ffi.metatypeto create idiomatic interfaces without too much overhead or writing large amounts of boilerplate. This would probably require different approaches depending on the library in question.

Goals:

  • All cdata types defined by third-party libraries or the runtime's FFI layer provide optional metatype-based interfaces
  • Those that allocate resources (like image data or GPU buffers) should come with finalizers that free them on GC
  • If that isn't possible for some metatype, a workaround might be to create a Lua table wrapper instead (not ideal)

Roadmap:

  • Compile a list of required metatypes (cdata types) that are worth aliasing in this way
  • Investigate whether any of them require finalizers and what resources need to be released when
  • Investigate which (if any) can NOT be handled via metatypes and find a workaround for them
  • Create the actual metatypes
  • Add unit tests for them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: The time is nigh (Planning)
Development

No branches or pull requests

1 participant