Generating bindings automatically
chances opened this issue · comments
@gecko0307 From your comment in #7, the wgpu function declarations are being hand-written?
Alternatives
https://wiki.dlang.org/Bindings#Binding_generators
- cbindgen
@moon-chilled's common format issue: mozilla/cbindgen#616 - dpp
I was seeing success using it withwgpu.h
Con: It generates a bloated D file. - dstep
htod
Unmaintained and doesn't work withwgpu.h
I think a better alternative would be hooking rust's own bindgen functionality to generate d bindings.
Perhaps an abstraction of cbindgen that transforms its Intermediate Representation into a D module with the necessary extern
s and whatnot?
Actually, upon thinking about the matter a bit more, I think even better would be for cbindgen to dump its internal representation into some common format—json or similar—which can be consumed by any language. (Like how bindings are automatically generated for xcb and opengl based on xml specs.) I'll file a ticket on cbindgen later.
I just updated the bindings manually for #12 (ugh, 😝️).
@moon-chilled Have you made any progress experimenting with cbindgen?
Finally available with ImportC? https://github.com/chances/wgpu-d
@cyrusmsk Exactly, though wgpu-d is still quite verbose in its "idiomatic" wrapping.
ImportC is magic. 😄