October 03, 2013
On 2013-10-03 12:54, simendsjo wrote:

> * https://github.com/jacob-carlborg/dstep?source=cc

OT: what does ?source=cc do?

-- 
/Jacob Carlborg
October 03, 2013
On 2013-10-03 13:01, simendsjo wrote:

> Ah, you're probably right.
> Another link then :)
> http://dlang.org/cpp_interface.html

And it's only for creating bindings for headers.

-- 
/Jacob Carlborg
October 03, 2013
On Thursday, 3 October 2013 at 11:49:42 UTC, Jacob Carlborg wrote:
> On 2013-10-03 12:54, simendsjo wrote:
>
>> * https://github.com/jacob-carlborg/dstep?source=cc
>
> OT: what does ?source=cc do?

Hmm. No idea. I just searched for the github repo and copied the link.
October 03, 2013
On Thursday, 3 October 2013 at 11:31:51 UTC, Tourist wrote:

> An official reply from Daniel ;)
> https://github.com/D-Programming-Language/dmd/pull/1980#issuecomment-19539800

Still, there is some hope :P
October 03, 2013
On Thursday, 3 October 2013 at 10:42:32 UTC, Szymon Gatner wrote:
> Andrei's AMA has interesting answer:
>
> "One of the main D(md) contributors, Daniel Murphy is working on automatic conversion tool that eventually will convert DMD's C++ codebase to D."
>
> Is this tool already available? Are there any guidelines about how to code in C++ to ease the conversion preocess (or even make it possible). I would be VERY interested in such a tool when the time comes so in the mean time I could slowly "fix" existing C++ codebase for future conversion.

1st of all, Daniel Murphy vel yebblies rox.
2nd, I was the one who responded at Andrei's AMA thread :p
3rd, Andrei's response is the killer one, http://www.reddit.com/r/IAmA/comments/1nl9at/i_am_a_member_of_facebooks_hhvm_team_a_c_and_d/ccjusx7
October 03, 2013
On 10/03/2013 12:52 PM, simendsjo wrote:
>
> I think Daniel Murphys tool is aimed directly at the DMD codebase.

That's it's key feature, any attempt to first come up with a generic tool would be doomed to fail. Also DMD's code base uses only a limited subset of C++ which makes it more amenable to automatic translation.
October 04, 2013
On 2013-10-04 01:24, Martin Nowak wrote:

> That's it's key feature, any attempt to first come up with a generic
> tool would be doomed to fail. Also DMD's code base uses only a limited
> subset of C++ which makes it more amenable to automatic translation.

Having #ifdef inside declarations must be a nightmare for a tool like this. Making that properly work on generic code bases sound impossible to me.

-- 
/Jacob Carlborg
October 04, 2013
On Friday, 4 October 2013 at 06:33:10 UTC, Jacob Carlborg wrote:
> On 2013-10-04 01:24, Martin Nowak wrote:
>
>> That's it's key feature, any attempt to first come up with a generic
>> tool would be doomed to fail. Also DMD's code base uses only a limited
>> subset of C++ which makes it more amenable to automatic translation.
>
> Having #ifdef inside declarations must be a nightmare for a tool like this. Making that properly work on generic code bases sound impossible to me.

Well, that is nothing Clang can't handle. The subset is what I was asking for -  there has to be something that tool handles correctly, right?
October 04, 2013
On 2013-10-04 08:37, Szymon Gatner wrote:

> Well, that is nothing Clang can't handle. The subset is what I was
> asking for -  there has to be something that tool handles correctly, right?

Of course Clang will be able to lex and parse it. But how should it be translated?

void foo (int a
#if BAR
,
int b
#endif
)
{ ... }

You cannot do the exact same thing in D:

void foo (int a
version (BAR)
{
    ,
    int b
}
)
{ ... }

Doing these crazy things are only possible with a preprocessor.

Then you need to duplicate the function, use a string mixin or something else that's ugly.

We can take a simpler example:

#if _WIN32
void foo (int);
#elif __APPLE__
void foo (long long);
#elif linux
void foo (long long);
#endif

Translating this manually it would look like this:

version (Windows)
    void foo (int);
else version (OSX)
    void foo (long);
else version (linux)
    void foo (long);

But how could this be translated automatically? In this case you would want to have all the above preprocessor macros enabled, at the same time. Or somehow run it multiple times with different macros enabled and merge them.

I don't know how the preprocessor API looks like in Clang. If you could search for hard coded identifiers or something similar.

-- 
/Jacob Carlborg
October 04, 2013
"Szymon Gatner" <noemail@gmail.com> wrote in message news:jqvduhyvfufpzovpyqbj@forum.dlang.org...
> Andrei's AMA has interesting answer:
>
> "One of the main D(md) contributors, Daniel Murphy is working on automatic conversion tool that eventually will convert DMD's C++ codebase to D."
>
> Is this tool already available? Are there any guidelines about how to code in C++ to ease the conversion preocess (or even make it possible). I would be VERY interested in such a tool when the time comes so in the mean time I could slowly "fix" existing C++ codebase for future conversion.

The tool is available here: https://github.com/yebblies/magicport2

But as others have said, it is not meant to be a general purpose tool.  The same approach could easily be applied to another large and consistent project, but not without adapting the tool to your needs.

DMD uses a very nice subset of C++ (very few templates, no stl, no MI, etc) so most of the things I've needed to clean up were actually C-isms.

You can get a comprehensive list of changes by looking at past commits with [DDMD] in the title, along with the un-merged ones here: https://github.com/D-Programming-Language/dmd/pull/1980