C to D convertor

Виталий Фадеев vital.fadeev at gmail.com
Sat Aug 21 08:14:22 UTC 2021


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 ?


More information about the Digitalmars-d-learn mailing list