charto / nbind

:sparkles: Magical headers that make your C++ library accessible from JavaScript :rocket:
MIT License
1.98k stars 120 forks source link

Can ndts support better identifier names #92

Open Place1 opened 7 years ago

Place1 commented 7 years ago

Currently it looks like ndts generates names for method params:

e.g.

export class Widget extends NBindBase {
    /** Widget(); */
    constructor();

    /** void set_size_request(int32_t, int32_t); */
    set_size_request(p0: number, p1: number): void;
}

The original c++ method was set_size_request(int width, int height). Is it possible for ndts to use the same identifier names width and height?

I plan to use the automatically generated typescript definitions to create some basic documentation site so having the actual identifier names would make a big difference to the usefulness of such a site.

Similarly, editor intelisense often shows the identifier names. In this example (a common one) the identifier names are very important because without them people won't know the order (width, height or height, width)???

jjrv commented 7 years ago

ndts doesn't look at the original source code, but instead type information exposed during compilation by using templates. The compiled code has no access to the original variable names. The only solution would be to manually add annotations inside the NBIND_CLASS block using some new syntax.

A new tool to extract both variable names and JSDoc style comments from C++ header and source files would be nice and probably doable using clang libraries.

Place1 commented 7 years ago

hmm, so no easy solution. i'm currently hacking on https://github.com/Place1/react-native-gtk so I don't have time. Otherwise I'd love to look at spending time on a PR :D