PMunch / futhark

Automatic wrapping of C headers in Nim
MIT License
394 stars 22 forks source link

Hide aliased types #120

Closed AmjadHD closed 3 months ago

AmjadHD commented 3 months ago
typedef struct Point {
    int x;
    int y;
} Point;

translates to:

type
  struct_Point* = object
    x*: cint
    y*: cint
  Point* = struct_Point

struct_Point is exported, when arguably it shouldn't be.

PMunch commented 3 months ago

Futhark tries to emulate C, and in C when you import a module with a typedef'ed struct you get both the original and the typedef'ed version. So this works as intended.

Besides the output of nim doc suffers greatly if these aren't exported.

AmjadHD commented 3 months ago

These clutter the autocompletion suggestions, bloat the API and pollute the documentation. What I had in mind is an option to generate:

type
  Point* = object
    x*: cint
    y*: cint

and if there is a reference to struct Point replace it with the alias.

PMunch commented 2 months ago

C interoperability is still more important. And detecting struct Point across the entire output is harder than it sounds.