gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

Signal with non-GObject parameter #286

Closed baedert closed 4 years ago

baedert commented 4 years ago

Hey, I'm looking at binding GTK4 right now. GdkSurface has a signal called render that has a cairo_region_t* parameter, which is not a GObject.

When building the generated code, it fails with

generated/gtkd4/gobject/ObjectG.d(259): Error: constructor cairo.Region.Region.this(cairo_region_t* cairo_region) is not callable using argument types (cairo_region_t*, bool)
generated/gtkd4/gobject/ObjectG.d(259):        expected 1 argument(s), not 2
generated/gtkd4/gobject/DClosure.d-mixin-128(130): Error: template instance gobject.ObjectG.ObjectG.getDObject!(Region, Region, cairo_region_t*) error instantiating
generated/gtkd4/gobject/DClosure.d(89):        instantiated from here: d_closure_marshal!(bool delegate(Region, Surface))
generated/gtkd4/gobject/Signals.d(60):        instantiated from here: __ctor!(bool delegate(Region, Surface))
generated/gtkd4/gdk/Surface.d(1559):        instantiated from here: connect!(bool delegate(Region, Surface))

i.e. it's trying to call this line: https://github.com/gtkd-developers/GtkD/blob/master/generated/gtkd/gobject/ObjectG.d#L261 but the cairo.Region constructor does not take two arguments.

I'm a bit at a loss here, what's the solution?

baedert commented 4 years ago

Oh, is it enough to change that line to

return new T(obj);

?

MikeWey commented 4 years ago

It would be better to support both objects that track their ownership and those that don't.