Thread overview
best D pattern for C parameter references?
Feb 02, 2003
Robert M. Münch
Feb 02, 2003
Burton Radons
Feb 04, 2003
Robert M. Münch
Feb 04, 2003
Ilya Minkov
Feb 04, 2003
Mike Wynn
Feb 05, 2003
Robert M. Münch
February 02, 2003
Hi, I'm currently playing around using different DLLs from D. I saw that
quite some C/C++ functions use notation like this:
    void version(short &major, short &minor);

How should I convert this best to the D world? I first converted the
funciton delcation like this:
    extern (C) export void version (short &major, short &minor);

And tried to call it from D with:
    short major, minor;
    version (major, minor);

Of course this doesn't work. The only way I have found so far is this:
    extern (C) export void version (short *major, short *minor);
    short major, minor;
    version (&major, &minor);

Is there any better way to do it? A more Dlish way?

--
Robert M. Münch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax   : +49 (0)721 8408 9112
Web   : http://www.robertmuench.de


February 02, 2003
Robert M. Münch wrote:
> Hi, I'm currently playing around using different DLLs from D. I saw that
> quite some C/C++ functions use notation like this:
>     void version(short &major, short &minor);
> 
> How should I convert this best to the D world? I first converted the
> funciton delcation like this:
>     extern (C) export void version (short &major, short &minor);
> 
> And tried to call it from D with:
>     short major, minor;
>     version (major, minor);
> 
> Of course this doesn't work. The only way I have found so far is this:
>     extern (C) export void version (short *major, short *minor);
>     short major, minor;
>     version (&major, &minor);
> 
> Is there any better way to do it? A more Dlish way?

extern (C) void version (inout short major, inout short minor);
short major, minor;
version (major, minor);

February 04, 2003
"Burton Radons" <loth@users.sourceforge.net> schrieb im Newsbeitrag news:b1j4or$s3m$1@digitaldaemon.com...

> extern (C) void version (inout short major, inout short minor);
> short major, minor;
> version (major, minor);

Thanks a lot ! :-)) Seems like I need to RTFM once again. With this it should even be possible to write a script that converts such declarations from C to D. Robert


February 04, 2003
Hello.

In about a week i'll start writing a tool to convert C headers into D
import units. It shall be written completely in D. IMO, D has most of
the "sweet sides" of scripting languages.

First information requiered is collected by Mike Winn who was going to
write one already.
http://www.l8night.co.uk/mwynn/d/deimos.html
But i think that the whole system he proposes is too complicated. I
think mine would be more simple and straightforward, though provide a
more limited maintainance.

Grüße aus München
-i.

Robert M. Münch wrote:
> With this it should even be possible to write a script that converts
> such declarations from C to D. Robert

February 04, 2003
yes, it is, I got bogged down dealing with nested structs, and interfaces
are different you need to know which are new methods and which are
inherited, making it easier to use a few replace alls in an editor (like the
transforms I doc'd)
and then an hour tidying up (how I did the Windows and DirectX headers).
the idea had been to allow tools such as Araxis Merge/CSDiff to be modified
to handle updates to the C header
and migrate to the D module without the need to fully reconvert.
if ou want the source to the version I have party working email me, I'll see
if I can get it back to producing some output :) currently I've got a big
bug in the code where is does not pop the transfrom if there are any nested
structs,
and the comments it generates are a bit wrong. (its totally based on
regexp's which at the time I thought was an easy way to get something
working [fool])
I should update the website, as I've kind of given up development due to not
having the time at present.and getting distracted writing some D crypto libs
to see how they compare speedwise to my C++ libs.

I'll check that there are not transforms I though up that are not online.

best of luck getting it working, you have customer No. 1, I've still got C headers I want to convert :).

Mike.

"Ilya Minkov" <midiclub@8ung.at> wrote in message
news:b1p34l$1q1o$1@digitaldaemon.com...
Hello.

In about a week i'll start writing a tool to convert C headers into D import units. It shall be written completely in D. IMO, D has most of the "sweet sides" of scripting languages.

First information requiered is collected by Mike Winn who was going to
write one already.
http://www.l8night.co.uk/mwynn/d/deimos.html
But i think that the whole system he proposes is too complicated. I
think mine would be more simple and straightforward, though provide a
more limited maintainance.

Grüße aus München
-i.

Robert M. Münch wrote:
> With this it should even be possible to write a script that converts such declarations from C to D. Robert



February 05, 2003
"Ilya Minkov" <midiclub@8ung.at> schrieb im Newsbeitrag news:b1p34l$1q1o$1@digitaldaemon.com...

> In about a week i'll start writing a tool to convert C headers into D import units. It shall be written completely in D. IMO, D has most of the "sweet sides" of scripting languages.

Hi, hmmm don't know if using D for such a tool is the best idea. IMO that's something for which scripting languages are perfect. I'm going to try something done in Rebol. It has very nice parsing build in and I just want to setup a collection of rules that can be processed. This Might not lead to a perfect output but a good enough one. Robert