Re: Creating D bindings for a C library

2015-11-25 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

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_generators


Is htod maintained any more?  I had the impression it had kind of 
fallen by the wayside.


I'll give dstep a go, though. Thanks!


Re: Creating D bindings for a C library

2015-11-25 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

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-gotchas


Cool, 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.


Re: Creating D bindings for a C library

2015-11-25 Thread ponce via Digitalmars-d-learn
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:

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 :-)


If doing it by hand, some tips here: 
http://p0nce.github.io/d-idioms/#Porting-from-C-gotchas


Re: Creating D bindings for a C library

2015-11-25 Thread Andy Smith via Digitalmars-d-learn
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:
If doing it by hand, some tips here: 
http://p0nce.github.io/d-idioms/#Porting-from-C-gotchas


Cool, 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.


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.












Re: Creating D bindings for a C library

2015-11-25 Thread Andy Smith via Digitalmars-d-learn

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:

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-gotchas


Cool, 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.


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.


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 :-)


Re: Creating D bindings for a C library

2015-11-24 Thread cym13 via Digitalmars-d-learn
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:

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 :-)


There are some binding generator the most two famous being htod 
and dstep: 
http://wiki.dlang.org/List_of_Bindings#Binding_generators


Creating D bindings for a C library

2015-11-24 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

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


Re: Creating D bindings for a C library

2015-11-24 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
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 :-)