atilaneves / dpp

Directly include C headers in D source code
Boost Software License 1.0
230 stars 31 forks source link

Made fixFields work better for C11 anon records and deal with multiple structs using the same field name which needs renaming #214

Closed cbecerescu closed 4 years ago

cbecerescu commented 4 years ago

Previously, for this case

struct A;
struct B {
    struct A* A;
};

struct C {
    struct A* A;
};

dpp would only rename one of the fields (either the one in B or in C), because the _fieldDeclarations associative array overwrites the already existing (if any) line number with a new one. So it would rename only the field which is contained in the last processed struct.

My solution is changing the value of the associative array from LineNumber to LineNumber[], so that dpp knows of all instances where the field should be renamed.

Also made fixFields correctly rename the accessor functions' name and the field that the accessor functions try to access.