digitalmars.D.learn - Creating D bindings for a C library
- Joseph Rushton Wakeling (10/10) Nov 24 2015 Hello all,
- Joseph Rushton Wakeling (6/7) Nov 24 2015 I should probably clarify that I know what to do assuming I have
- cym13 (5/12) Nov 24 2015 There are some binding generator the most two famous being htod
- Joseph Rushton Wakeling (4/7) Nov 25 2015 Is htod maintained any more? I had the impression it had kind of
- ponce (4/11) Nov 25 2015 If doing it by hand, some tips here:
- Joseph Rushton Wakeling (4/6) Nov 25 2015 Cool, thanks. The stuff about using c_long and c_ulong is
- Andy Smith (13/19) Nov 25 2015 Hi Joseph,
- Andy Smith (6/26) Nov 25 2015 PS - I forgot to insert the words 'by hand' in there somewhere.
Hello all, I'm considering creating some D bindings for a C library. Before I start, I was wondering if anyone could advise me on the current state-of-the-art in automatically converting C headers to .d or .di files; it's a long time since I've looked at anything to do with this and the interfacing-with-C page in the D reference doesn't mention any tools. Thanks in advance for any advice, Best wishes, -- Joe
Nov 24 2015
On Tuesday, 24 November 2015 at 23:14:14 UTC, Joseph Rushton Wakeling wrote:I'm considering creating some D bindings for a C library.I should probably clarify that I know what to do assuming I have to write all the bindings manually. However, as the library has quite a lot of header files, I'd really much rather auto-convert as much as possible, hence the questions above :-)
Nov 24 2015
On Tuesday, 24 November 2015 at 23:22:24 UTC, Joseph Rushton Wakeling wrote:On Tuesday, 24 November 2015 at 23:14:14 UTC, Joseph Rushton Wakeling wrote:There are some binding generator the most two famous being htod and dstep: http://wiki.dlang.org/List_of_Bindings#Binding_generatorsI'm considering creating some D bindings for a C library.I should probably clarify that I know what to do assuming I have to write all the bindings manually. However, as the library has quite a lot of header files, I'd really much rather auto-convert as much as possible, hence the questions above :-)
Nov 24 2015
On Tuesday, 24 November 2015 at 23:49:26 UTC, cym13 wrote:There are some binding generator the most two famous being htod and dstep: http://wiki.dlang.org/List_of_Bindings#Binding_generatorsIs htod maintained any more? I had the impression it had kind of fallen by the wayside. I'll give dstep a go, though. Thanks!
Nov 25 2015
On Tuesday, 24 November 2015 at 23:22:24 UTC, Joseph Rushton Wakeling wrote:On Tuesday, 24 November 2015 at 23:14:14 UTC, Joseph Rushton Wakeling wrote:If doing it by hand, some tips here: http://p0nce.github.io/d-idioms/#Porting-from-C-gotchasI'm considering creating some D bindings for a C library.I should probably clarify that I know what to do assuming I have to write all the bindings manually. However, as the library has quite a lot of header files, I'd really much rather auto-convert as much as possible, hence the questions above :-)
Nov 25 2015
On Wednesday, 25 November 2015 at 17:45:48 UTC, ponce wrote:If doing it by hand, some tips here: http://p0nce.github.io/d-idioms/#Porting-from-C-gotchasCool, thanks. The stuff about using c_long and c_ulong is particularly useful/relevant to my use-case, so it's good to be reminded of that.
Nov 25 2015
On Wednesday, 25 November 2015 at 19:40:28 UTC, Joseph Rushton Wakeling wrote:On Wednesday, 25 November 2015 at 17:45:48 UTC, ponce wrote:Hi Joseph, How's things in Berlin? :-) I'm not sure how complex the C-Api you're wrapping is, but I have to say I found that writing a minimal (but complete) subset of an existing C-API to be quite straightforward and enjoyable. A plus point was that selecting only the useful minimal subset meant the D wrapper ended up being a lot cleaner and meant that unused (or undesirable) features simply weren't there in the wrapped API. YMMV but it's one to bear in mind... Cheers, A.If doing it by hand, some tips here: http://p0nce.github.io/d-idioms/#Porting-from-C-gotchasCool, thanks. The stuff about using c_long and c_ulong is particularly useful/relevant to my use-case, so it's good to be reminded of that.
Nov 25 2015
On Wednesday, 25 November 2015 at 21:19:51 UTC, Andy Smith wrote:On Wednesday, 25 November 2015 at 19:40:28 UTC, Joseph Rushton Wakeling wrote:PS - I forgot to insert the words 'by hand' in there somewhere. Also for additional guidance aldacron has some good blog posts on the wrapping process on the web somewhere. I pretty much used his guidance when I started my experiments with wrapping and have to say I was pretty satisfied with the end results :-)On Wednesday, 25 November 2015 at 17:45:48 UTC, ponce wrote:Hi Joseph, How's things in Berlin? :-) I'm not sure how complex the C-Api you're wrapping is, but I have to say I found that writing a minimal (but complete) subset of an existing C-API to be quite straightforward and enjoyable. A plus point was that selecting only the useful minimal subset meant the D wrapper ended up being a lot cleaner and meant that unused (or undesirable) features simply weren't there in the wrapped API. YMMV but it's one to bear in mind... Cheers, A.If doing it by hand, some tips here: http://p0nce.github.io/d-idioms/#Porting-from-C-gotchasCool, thanks. The stuff about using c_long and c_ulong is particularly useful/relevant to my use-case, so it's good to be reminded of that.
Nov 25 2015