RainwayApp / node-clangffi

Generate Typescript FFI bindings for C/C++ libraries using libclang and ffi-napi.
MIT License
7 stars 1 forks source link

fix(struct-alias): Support struct typedef aliasing #58

Closed bengreenier closed 2 years ago

bengreenier commented 2 years ago

This adds support for

typedef struct MyStruct { int fieldA; } MyStruct;
typedef struct MyStruct AliasToMyStruct;

such that AliasToMyStruct is parsed properly.

Previously, we'd relied on elaborated type parsing for typedefs assuming that we'd process all necessary children. However, given that struct is included in the alias definition, it incorrectly triggers that assumption and is then never processed.

This fix compares a simpleDesugar-ed type name with the current cursor symbolName and if they don't align, identifies it as the alias case, and generates the alias as expected (e.g. type AliasToMyStruct = MyStruct).