Jump to page: 1 2
Thread overview
bcd.gen: A generator for bindings to C++ in D
May 28, 2006
Gregor Richards
May 29, 2006
Gregor Richards
May 29, 2006
Gregor Richards
May 29, 2006
Gregor Richards
Jun 01, 2006
Gregor Richards
Jun 01, 2006
Daniel Keep
Jun 01, 2006
clayasaurus
Jun 01, 2006
Gregor Richards
Jun 01, 2006
Gregor Richards
Jun 02, 2006
Gregor Richards
Jun 03, 2006
BLS
Jun 04, 2006
Gregor Richards
Jun 07, 2006
Bruno Medeiros
Jun 07, 2006
Gregor Richards
Jun 07, 2006
Gregor Richards
May 28, 2006
[Gregor is insane 8-D]

I'm writing a generator for bindings to C++ in D.  It's in a semi-working state right now, so I figured I'd tell people it exists.

It works by using GCCXML to parse the C++ header, then making extern "C" wrapper classes for every function in .cc files, then calling those from .d files made to mimic the layout of the C++ classes.  The code is ugly, but to the end-user it's entirely transparent.  Because it mimics the layout of the C++ classes, if you know how to use a library in C++, it should be very similar in D (with BCD bindings).

Before you ask, no, it does not support:

 * Templates
 * Multiple inheritance
 * That other crazy C++ feature you're thinking about right now

It's still in a VERY beta stage, but it's working at least enough to get a binding to FLTK2 and make a window with a widget.  That's something :)

It's hosted on dsource, at http://www.dsource.org/projects/bcd

 - Gregor Richards
May 29, 2006
bcd.gen now supports C as well as C++.  bcd/libxml2 is a binding to libxml2.

 - Gregor Richards
May 29, 2006
Gregor Richards wrote:

> It's hosted on dsource, at http://www.dsource.org/projects/bcd

Tried to use the web page to find a download, but got this instead:
could not translate host name "localhost" to address: Name or service not known

In the end I just gave up and hacked an non-svn address together:
svn checkout http://svn.dsource.org/projects/bcd/trunk

Which worked better... Is there a tarball or is SVN supposed to work ?
--anders
May 29, 2006
Anders F Björklund wrote:
> Which worked better... Is there a tarball or is SVN supposed to work ?
> --anders

It's not in releasable state yet, so just SVN.  SVN should work.

 - Gregor Richards
May 29, 2006
Gregor Richards wrote:

> It's not in releasable state yet, so just SVN.  SVN should work.

Actually I meant like a "daily tarball" from the SVN repository,
but using the HTTP protocol instead of SVN made it limp along...

--anders
May 29, 2006
Anders F Björklund wrote:
> Gregor Richards wrote:
> 
>> It's not in releasable state yet, so just SVN.  SVN should work.
> 
> 
> Actually I meant like a "daily tarball" from the SVN repository,
> but using the HTTP protocol instead of SVN made it limp along...
> 
> --anders

Probably a good idea.  I wonder if that can be done automatically through Trac ... if not, I can set up a cronjob.

 - Gregor Richards
June 01, 2006
Some more BCD news.

A) BCD now supports enough C to bind GTK+.  Hooplah.

B) Killer feature: You can reflect D classes into C++, and instantiate C++ templates with them.  There are limitations (it only reflects operators, and not all operators are the same between the two), but it does work.

C) One of these days, I'll document bcd.gen.  Really.  Maybe.

 - Gregor Richards
June 01, 2006
Gregor Richards wrote:
> Some more BCD news.
> 
> A) BCD now supports enough C to bind GTK+.  Hooplah.

Pardon my use of profanity, but:

Holy sh*t!

> 
> B) Killer feature: You can reflect D classes into C++, and instantiate C++ templates with them.  There are limitations (it only reflects operators, and not all operators are the same between the two), but it does work.
> 

Just... wow.

Seriously, this is awesome stuff.  Fantastic work.

	-- Daniel

-- 
Unlike Knuth, I have neither proven or tried the above; it may not even make sense.

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/
June 01, 2006
Gregor Richards wrote:
> Some more BCD news.
> 
> A) BCD now supports enough C to bind GTK+.  Hooplah.
> 
> B) Killer feature: You can reflect D classes into C++, and instantiate C++ templates with them.  There are limitations (it only reflects operators, and not all operators are the same between the two), but it does work.
> 
> C) One of these days, I'll document bcd.gen.  Really.  Maybe.
> 
>  - Gregor Richards

You should give libpng a whirl, it is written in C and would be nice but a real headache to manually port to D.
June 01, 2006
clayasaurus wrote:
> You should give libpng a whirl, it is written in C and would be nice but a real headache to manually port to D.

Unfortunately, libpng uses setjmp/longjmp, so binding it would involve making a system-independent binding to those, first ... that would certainly be possible, but ow :)

 - Gregor Richards

PS: The main difficulty in making a system-independent binding to setjmp/longjmp is that jmpbufs are different sizes on every system. They're 24 bytes on x86/Linux, 64 bytes (IIRC) on x86/Windows, and a different size on just about every system.  Pfft.
« First   ‹ Prev
1 2