jhass / crystal-gobject

gobject-introspection for Crystal
BSD 3-Clause "New" or "Revised" License
127 stars 13 forks source link

eventmask type conflict #9

Open aeosynth opened 8 years ago

aeosynth commented 8 years ago
Gdk::WindowAttr.new(
  event_mask: Gdk::EventMask::ZERO_NONE
  )
no overload matches 'Gdk::WindowAttr.new', event_mask: LibGdk::EventMask
Overloads are:
 - Gdk::WindowAttr.new(title : String | Nil = nil, event_mask : Int32 | Nil = nil, x : Int32 | Nil = nil, y : Int32 | Nil = nil, width : Int32 | Nil = nil, height : Int32 | Nil = nil, wclass : Gdk::WindowWindowClass | Nil = nil, visual : Gdk::Visual | Nil = nil, window_type : Gdk::WindowType | Nil = nil, cursor : Gdk::Cursor | Nil = nil, wmclass_name : String | Nil = nil, wmclass_class : String | Nil = nil, override_redirect : Bool | Nil = nil, type_hint : Gdk::WindowTypeHint | Nil = nil)
 - Gdk::WindowAttr.new(gdk_window_attr : ::Pointer(LibGdk::WindowAttr))

also the flags have type UInt32, but WindowAttr wants them as Int32

jhass commented 8 years ago

Apparently you're not supposed to set this directly but use gdk_window_set_events / Gdk::Window#events=

window.events = Gdk::EventMask::ZERO_NONE

There's no member for it in GdkWindowAttributesType, so setting it directly in the attributes passed to gdk_window_new has no effect anyway presumably.

Given the documentation of that field lists it as gint too, generating something else could probably lead to incorrect code. Unfortunately I see nothing in GIStructInfo or GIFieldInfo to determine that the field is private, worse, if that argument is generated it means it's marked as writable (as per GIFieldInfoFlags). So I currently have no idea how to hide it from the wrapper, other than starting to maintain a blacklist.

aeosynth commented 8 years ago

Apparently you're not supposed to set this directly

i imagine the docs would say so, like they do for wmclass_name:

https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkWindowAttr

gchar *wmclass_name; don’t use (see gtk_window_set_wmclass())

.

There's no member for it in GdkWindowAttributesType, so setting it directly in the attributes passed to gdk_window_new has no effect anyway presumably.

https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkWindowAttributesType:

Fields in GdkWindowAttr not covered by a bit in this enum are required; for example, the width /height , wclass , and window_type fields are required, they have no corresponding flag in GdkWindowAttributesType.

jhass commented 8 years ago

i imagine the docs would say so, like they do for wmclass_name

They do?

gint event_mask; event mask (see gdk_window_set_events())

I took the "for example" as obligatory and the list of required attributes there as actually complete. More importantly as I already said the field is a gint and GdkEventMask is a guint, but more importantly an enum type. It's impossible to generate code that handles this correctly, there's no indication whatsoever in the typelib that the as gint marked field event_mask is supposed to receive a as guint typed enum called GdkEventMask. Unless I'm overlooking something, if so please do point it out.