On Monday, 9 July 2012 at 06:30:39 UTC, Jacob Carlborg wrote:
On 2012-07-08 23:22, Jonathan Andrew wrote:

Jacob,

The only disadvantage to the single-file limitation is that in the case of GTK at least, it has preprocessor directives to keep you from just #include-ing the single file you want to convert, so I just used sed to strip out all the #error directives that come up and force it to do my bidding. I understand DStep doesn't deal with preprocessor yet, but as far as the CLang front-end it uses goes, it might be helpful to find a
way to turn off #error-s.

I had no idea about that.

sed -i 's/#error/\/\//g' *.h

The next step was to rename all the D reserved words that GTK used as function arguments - in, out, function, and align are the only ones I can think of off the top of my head. Easy fix for the user (by no means am I complaining), but if you want to streamline the conversion, automatically renaming these kinds of arguments might be a helpful option.

I thought the tool did that already.

Then, renaming all the duplicate empty struct{} entries in some of the files. You already know about this, but it was probably the most time-consuming part of the process for converting GTK, at least. I couldn't think of an easy way to automate this on my end, because some
of the empty structs were necessary to get it to compile.

I thought I had fixed this too. I'll have to take a look.

Finally, putting import statements in all the .d files after I was done.
Still a long way to go on this (500 files).

Sorry for the long post, this is probably obvious stuff to everybody else, but I was really impressed with DStep - thank you for creating it!

No it's good, this is just what I wanted people to do. It would be great if you could report these issues:

https://github.com/jacob-carlborg/dstep/issues

If you have a simple test case or a header I can try that would be great.

OK, as far as the empty struct-s, it looks like it has to do with typedef struct.
-------------------------------------------------------
//Test.h:

typedef struct _Booger Booger;

//Results in:

-------------------------------------------------------
//Test.d:

extern (C):

alias _Booger Booger;

struct _Booger
{
}

-------------------------------------------------------

If the .h has:

typedef struct _Booger Booger;

struct Booger
{
   int a;
};

The .d will have both the incorrect empty struct and the correct one with the "int a;" declaration.
extern (C):

alias _Booger Booger;

struct _Booger
{
}

struct _Booger
{
   int a;
}

Thanks,
   Jon

Reply via email to