www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C to D convertor

reply =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
I know, i know... It not possible, but part of the C code we can 
to convert to the D.
Show me, please, solutions, projects, tools, scripts, docs.
Can you give the link ?

Examples of what the wanted:

         // C
         typedef struct {
             uint32_t version; /* 0x5000 */
             uint16_t num_glyphs;
         } MaxProTable;
         // D
         struct MaxProTable {
             uint32_t version; /* 0x5000 */
             uint16_t num_glyphs;
         }


         // C
         #define ENABLE_SUBDIV 0
         // D
         enum ENABLE_SUBDIV = 0;


         // C
         #include "triangulate.h"
         // D
         import triangulate;


         // C
         #include <string.h>
         // D
         import core.stdc.string;


         // C
         #define cross2(a,b) ((a)[0]*(b)[1]-(a)[1]*(b)[0])
         // D
         pragma( inline, true )
         auto cross2( T1, T2 )( T1 a, T2 b ) { return 
((a)[0]*(b)[1]-(a)[1]*(b)[0]); }


         // C
         double ab[2];
         // D
         double[2] ab;

         // C
         trgu = calloc( 1, sizeof(*trgu) );
         // D
         trgu = calloc( 1, (*trgu).sizeof );


         // C
         PointFlag *point_flags = gt->flags;
         // D
         PointFlag *point_flags = gt.flags;

`htod` is 1.
Any more ?
Aug 21 2021
next sibling parent reply evilrat <evilrat666 gmail.com> writes:
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote:
 I know, i know... It not possible, but part of the C code we 
 can to convert to the D.
 Show me, please, solutions, projects, tools, scripts, docs.
 Can you give the link ?

 `htod` is 1.
 Any more ?
dstep https://code.dlang.org/packages/dstep dpp https://code.dlang.org/packages/dpp ohmygentool https://github.com/Superbelko/ohmygentool
Aug 21 2021
parent =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
On Saturday, 21 August 2021 at 08:59:55 UTC, evilrat wrote:
 On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев 
 wrote:
 I know, i know... It not possible, but part of the C code we 
 can to convert to the D.
 Show me, please, solutions, projects, tools, scripts, docs.
 Can you give the link ?

 `htod` is 1.
 Any more ?
dstep https://code.dlang.org/packages/dstep dpp https://code.dlang.org/packages/dpp ohmygentool https://github.com/Superbelko/ohmygentool
evilrat, thank you!
Aug 21 2021
prev sibling parent reply Dennis <dkorpel gmail.com> writes:
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote:
 Any more ?
CPP2D https://github.com/lhamot/CPP2D
Aug 24 2021
parent =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
On Tuesday, 24 August 2021 at 11:52:45 UTC, Dennis wrote:
 On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев 
 wrote:
 Any more ?
CPP2D https://github.com/lhamot/CPP2D
Dennis, thank!
Aug 24 2021