gjsify / ts-for-gir

TypeScript type definition generator for GObject introspection interfaces
https://gjsify.org/pages/projects
Apache License 2.0
236 stars 18 forks source link

Missing some async/finish functions #200

Open vixalien opened 3 weeks ago

vixalien commented 3 weeks ago

Hello.

When using types generated by ts-for-gir 4.x, I found that some functions are not being detected as async/finish functions.

Functions with a signature resembling function_name_async and then function_name_finish seem to be generated correctly, but functions with a signature resembling function_name and then function_name_finish don't seem to be generated correctly.

Some examples include:

A possible way to detect these would be to check if a function's last parameter is a Gio.AsyncReadyCallback, and then detecting if there's a similar function with _finish suffix AND which takes in a Gio.AsyncResult as only parameter.

badcel commented 3 weeks ago

Another idea would be to add annotations upstream so other bindings can benefit and do not need to add heuristics, too.

vixalien commented 3 weeks ago

Yeah. We would likely need to create an initiative to add these annotations. Would be better as a coordinated effort imo.

badcel commented 3 weeks ago

My philosophy is to do it on a case by case basis. I started adding some ref-func annotations upstream because my project would benefit from it.

If some async function annotations are missing the specifically requested ones would be added by myself. Fixing all the annotations in a big effort would probably add a lot of burden to the maintainers of the upstream libraries and on the own binding project, too.

I just wanted to mention the annotations as from my point of view they are technically the better solution to the problem of missing async functions.

At least for my C# bindings I decided to not add more heuristics but to fix upstream instead.