gjsify / ts-for-gir

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

Missing `cairo` types #194

Open vixalien opened 2 months ago

vixalien commented 2 months ago

Some Cairo types are missing. For example, Cairo.Surface.

It seems most of the types are defined here: https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/cairo-context.cpp#L824-921

JumpLink commented 2 months ago

@vixalien Thank you for the issue. It would be very nice if you can help to complete this types. Contributions to overrides are very simple as they are also written by hand. The hand written type definitions for 'cairo' can be found here: https://github.com/gjsify/ts-for-gir/blob/main/packages%2Fgenerator-typescript%2Ftemplates%2Fgjs%2Fcairo.d.ts

vixalien commented 2 months ago

Nice I'll take a stab at it soon

vixalien commented 2 months ago

The issue seems to stem from the fact that both cairo-1.d.ts (from cairo's GIR) and cairo.d.ts are generated.

When using a type like Gtk.DrawingArea.set_drawing_func, it uses the cairo.Context from the GIR (cairo-1.d.ts) instead of the handwritten cairo.Context (from cairo.d.ts)

vixalien commented 2 months ago

It seems @ewlsh posted the types of cairo here https://gitlab.gnome.org/GNOME/gjs/-/snippets/2990, although the origin is unclear.

JumpLink commented 3 days ago

@vixalien Yes, that's right, currently the handwritten ones are only used for import, but not for the generated types. Perhaps a special treatment can be built in for this.