You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.metatype
to 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:
cdata
types defined by third-party libraries or the runtime's FFI layer provide optional metatype-based interfacesRoadmap:
cdata
types) that are worth aliasing in this wayThe text was updated successfully, but these errors were encountered: