www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - htod feature request: save commands in translated file

reply Andrej Mitrovic <andrej.mitrovich none.com> writes:
I don't know where else to put this topic. Currently htod translates a C/CPP
header file to D and adds a line at the top such as:

/* Converted to D from someheaderfile.h by htod */

The Bindings project relies heavily on htod, but the problem is: when a new
version of a library comes out you're left wondering which commands were used
with htod to translate the header files.

So the feature request is, if I specify some commands to htod, such as:

htod cheader.h dimport.d -cpp -hc -hi

then htod should put those commands in the resulting file as a comment, e.g.:

/* Converted to D from someheaderfile.h by htod */
/* using arguments: -cpp -hc -hi */

Whaddya think?
Oct 17 2010
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 10/17/2010 07:52 PM, Andrej Mitrovic wrote:
 I don't know where else to put this topic. Currently htod translates a C/CPP
header file to D and adds a line at the top such as:

 /* Converted to D from someheaderfile.h by htod */

 The Bindings project relies heavily on htod, but the problem is: when a new
version of a library comes out you're left wondering which commands were used
with htod to translate the header files.

 So the feature request is, if I specify some commands to htod, such as:

 htod cheader.h dimport.d -cpp -hc -hi

 then htod should put those commands in the resulting file as a comment, e.g.:

 /* Converted to D from someheaderfile.h by htod */
 /* using arguments: -cpp -hc -hi */

 Whaddya think?
It's useful, as would be the addition "on 2010/10/17 at 20:38:50 CST" and the htod version used. Andrei
Oct 17 2010
next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
htod could also use a --help switch so we don't have to fire up the
browser every time we need to remind ourselves on what arguments it
can take. Or, you know, Walter could give us the source code and we'll
fix it for him. Hehe. :>

Here's one failed conversion from 5 minutes ago:

C:
typedef	struct SNDFILE_tag	SNDFILE ;

htod:
alias SNDFILE_tag SNDFILE;

This should be:
struct SNDFILE_tag {}
alias SNDFILE_tag SNDFILE;

But I guess that's a rare and dubious case.

On 10/18/10, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:
 On 10/17/2010 07:52 PM, Andrej Mitrovic wrote:
 I don't know where else to put this topic. Currently htod translates a
 C/CPP header file to D and adds a line at the top such as:

 /* Converted to D from someheaderfile.h by htod */

 The Bindings project relies heavily on htod, but the problem is: when a
 new version of a library comes out you're left wondering which commands
 were used with htod to translate the header files.

 So the feature request is, if I specify some commands to htod, such as:

 htod cheader.h dimport.d -cpp -hc -hi

 then htod should put those commands in the resulting file as a comment,
 e.g.:

 /* Converted to D from someheaderfile.h by htod */
 /* using arguments: -cpp -hc -hi */

 Whaddya think?
It's useful, as would be the addition "on 2010/10/17 at 20:38:50 CST" and the htod version used. Andrei
Oct 17 2010
parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Mon, 18 Oct 2010 07:51:34 +0400, Andrej Mitrovic  
<andrej.mitrovich gmail.com> wrote:

 htod could also use a --help switch so we don't have to fire up the
 browser every time we need to remind ourselves on what arguments it
 can take. Or, you know, Walter could give us the source code and we'll
 fix it for him. Hehe. :>

 Here's one failed conversion from 5 minutes ago:

 C:
 typedef	struct SNDFILE_tag	SNDFILE ;

 htod:
 alias SNDFILE_tag SNDFILE;

 This should be:
 struct SNDFILE_tag {}
 alias SNDFILE_tag SNDFILE;

 But I guess that's a rare and dubious case.
I think it should rather be struct SNDFILE_tag; // forward declaration alias SNDFILE_tag SNDFILE; You can't define a struct that have no idea about, its proper definition may follow any time.
Oct 17 2010
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Hmm.. okay. I copied those from a pretranslated .d file I found
googling. Otherwise, SNDFILE is internal to the library and I
shouldn't mess around with it except send and receive it via function
calls.

On 10/18/10, Denis Koroskin <2korden gmail.com> wrote:
 On Mon, 18 Oct 2010 07:51:34 +0400, Andrej Mitrovic
 <andrej.mitrovich gmail.com> wrote:

 htod could also use a --help switch so we don't have to fire up the
 browser every time we need to remind ourselves on what arguments it
 can take. Or, you know, Walter could give us the source code and we'll
 fix it for him. Hehe. :>

 Here's one failed conversion from 5 minutes ago:

 C:
 typedef	struct SNDFILE_tag	SNDFILE ;

 htod:
 alias SNDFILE_tag SNDFILE;

 This should be:
 struct SNDFILE_tag {}
 alias SNDFILE_tag SNDFILE;

 But I guess that's a rare and dubious case.
I think it should rather be struct SNDFILE_tag; // forward declaration alias SNDFILE_tag SNDFILE; You can't define a struct that have no idea about, its proper definition may follow any time.
Oct 17 2010
prev sibling parent reply "Gour D." <gour atmarama.net> writes:
On Sun, 17 Oct 2010 20:39:02 -0500
 "Andrei" =3D=3D Andrei Alexandrescu wrote:
Andrei> > Whaddya think? Andrei>=20 Andrei> It's useful, as would be the addition "on 2010/10/17 at Andrei> 20:38:50 CST" and the htod version used. What about http://github.com/klickverbot/swig/commits/swigd (Swig4D) to create D-bindings for C-libs? Sincerely, Gour --=20 Gour | Hlapicina, Croatia | GPG key: CDBF17CA ----------------------------------------------------------------
Oct 17 2010
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
This is cool! I was going to look for some SWIG-like tools these days.
I saw the swig4d project on dsource, but it's page says it's
abandoned. I didn't know there was an active on github. Thanks.

On 10/18/10, Gour D. <gour atmarama.net> wrote:
 On Sun, 17 Oct 2010 20:39:02 -0500
 "Andrei" == Andrei Alexandrescu wrote:
Andrei> > Whaddya think? Andrei> Andrei> It's useful, as would be the addition "on 2010/10/17 at Andrei> 20:38:50 CST" and the htod version used. What about http://github.com/klickverbot/swig/commits/swigd (Swig4D) to create D-bindings for C-libs? Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: CDBF17CA ----------------------------------------------------------------
Oct 18 2010
next sibling parent klickverbot <see klickverbot.at> writes:
On 10/18/10 5:39 PM, Andrej Mitrovic wrote:
 […] I didn't know there was an active on github. […]
That's probably because I haven't officially announced it yet – I am currently trying to get it into SWIG trunk. After this is done (which could take quite some time, since I have not received a real response to my post at the SWIG mailing list yet), I will also try to get all other SWIG-related pages marked as obsolete to avoid confusion. At the moment, you can simply contact me via mail if you hit any bugs or have any related questions. David
Oct 18 2010
prev sibling parent "Gour D." <gour atmarama.net> writes:
On Mon, 18 Oct 2010 17:39:46 +0200
 "Andrej" =3D=3D Andrej Mitrovic wrote:
Andrej> This is cool! I was going to look for some SWIG-like tools Andrej> these days. I saw the swig4d project on dsource, but it's page Andrej> says it's abandoned. I didn't know there was an active on Andrej> github. Thanks. And today I went and skimmed over Swig's docs...Boy, it has improved a LOT since I was looking at it some years ago. It seems I can tweak D-side of the interface to bring some type-safety to the bindings (something I was accustomed to while being in Haskell world where one can tailor Haskell side of the data and have types checked at compile time). Otoh, it would be nice if someone could clear this stalled data on dsource.org which just helps spreading FUD about D. Sincerely, Gour --=20 Gour | Hlapicina, Croatia | GPG key: CDBF17CA ----------------------------------------------------------------
Oct 18 2010