Re: [Gtk2hs-devel] Question about binding gtk_main_do_event

2010-07-04 Thread Axel Simon
Hi Andy, since the marshalling of bit-fields is difficult, it might be worthwhile trying to do things completely differently. You could try to serialize an event using the following strategy: - query the size of the event - read each of the bytes in an event and serialize them (in hex or so) -

Re: [Gtk2hs-devel] Question about binding gtk_main_do_event

2010-07-04 Thread Andy Stewart
Hi Axel, Axel Simon writes: > Hi Andy, > > On Jul 4, 2010, at 16:20, Andy Stewart wrote: >>> >>> pokeSerializedEventKey ptr (SerializedEvent >>> (SerializedEventKeyValue >>> { >>> [..] >>> ,sEventString = string_ >>> }) window_) = do >>> str <- newCString string_ >>> [..] >>> #{poke GdkEventKey,

Re: [Gtk2hs-devel] Question about binding gtk_main_do_event

2010-07-04 Thread Axel Simon
Hi Andy, On Jul 4, 2010, at 16:20, Andy Stewart wrote: >> >> pokeSerializedEventKey ptr (SerializedEvent >> (SerializedEventKeyValue >> { >> [..] >> ,sEventString = string_ >> }) window_) = do >> str <- newCString string_ >> [..] >> #{poke GdkEventKey, string} ptr str >> Here, you leak the space o

Re: [Gtk2hs-devel] Question about binding gtk_main_do_event

2010-07-04 Thread Andy Stewart
Hi Axel, Axel Simon writes: > H Andy, > > a few comment: > > - you make your SerializedEvent an instance of Storable. That could work, but > you really have to > ensure that the size of the C structure you allocated is big enough. At the > moment, you have > > instance Storable SerializedEven

Re: [Gtk2hs-devel] Question about binding gtk_main_do_event

2010-07-04 Thread Axel Simon
H Andy, a few comment: - you make your SerializedEvent an instance of Storable. That could work, but you really have to ensure that the size of the C structure you allocated is big enough. At the moment, you have instance Storable SerializedEvent where sizeOf _ = #{const sizeof (GdkEventKey)