Show: Automated conversion of C code to .pas (Island)

Recently I started working on an automated conversion tool of C code to Elements. The tool is called “foxy” and is part of the HeaderImporter command line tool.

The tool is meant to output code that works (but usually isn’t pretty) opposed to Oxidizer which tries to create nicer looking code. It takes a json file like:

{
  "files": [ "nuklear.h"], // Input file(s)
  "outpath": ".", // Output path
  "language":  "oxygene", // Oxygene and Hydrogene are suppoted.
  "namespace": "Nuklear",
  "defines": [  "NK_IMPLEMENTATION","NK_INCLUDE_FIXED_TYPES","NK_INCLUDE_DEFAULT_ALLOCATOR", "NK_INCLUDE_FONT_BAKING", "NK_INCLUDE_DEFAULT_FONT", "uintptr_t=UIntPtr", "intptr_t=IntPtr" ,"NK_API=extern", "NK_GDI_IMPLEMENTATION", "NULL=nil", "NK_MEMSET=memset", "NK_MEMCPY=memcpy"],
  "uses":  ["rtl"],
"knowntypes": ["LPSTR", "GRADIENT_RECT", "GRADIENT_TRIANGLE", "TRIVERTEX", "POINT"],
  "includes": {
    "stddef.h": "", 
"stdint.h": "", 
"stdlib.h":"",
"assert.h":"",
"windows.h":"#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))\r\n#define FALSE 0\r\n#define TRUE 1\r\n#define LOWORD(a) ((WORD)(a))\r\n#define HIWORD(a) ((WORD)(((DWORD)(a) >> 16) & 0xFFFF))\r\n",
"malloc.h":""
  },
  "includePaths": ["." ]
}

The first results of this tool are shown here:

(The nuklear.h file was converted to .pas there; no changes were done to the file after that)

The conversion of the Nuklear toolkit (https://github.com/vurtun/nuklear) to Elements/Island:

Note this tool is currently experimental.

1 Like

Linux version (running in Ubuntu on Windows):