bindbc-wgpu icon indicating copy to clipboard operation
bindbc-wgpu copied to clipboard

Generating bindings automatically

Open chances opened this issue 5 years ago • 7 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: eqrion/cbindgen#616
  • dpp I was seeing success using it with wgpu.h Con: It generates a bloated D file.
  • dstep
  • ~~htod~~ Unmaintained and doesn't work with wgpu.h

chances avatar Nov 04 '20 21:11 chances

I think a better alternative would be hooking rust's own bindgen functionality to generate d bindings.

moon-chilled avatar Nov 05 '20 04:11 moon-chilled

Perhaps an abstraction of cbindgen that transforms its Intermediate Representation into a D module with the necessary externs and whatnot?

cbindgen's Internals

chances avatar Nov 06 '20 01:11 chances

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.

moon-chilled avatar Nov 06 '20 22:11 moon-chilled

I just updated the bindings manually for #12 (ugh, 😝️).

@moon-chilled Have you made any progress experimenting with cbindgen?

chances avatar Nov 19 '20 13:11 chances

Finally available with ImportC? https://github.com/chances/wgpu-d

cyrusmsk avatar May 20 '22 17:05 cyrusmsk

@cyrusmsk Exactly, though wgpu-d is still quite verbose in its "idiomatic" wrapping.

ImportC is magic. 😄

chances avatar May 20 '22 22:05 chances

D support (WiP) - w/cpp_compat

  • https://github.com/mozilla/cbindgen/issues/866

I'm still tweaking functors support and some fixes to the order of opaque structure templates.

kassane avatar Oct 01 '24 23:10 kassane