From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16054.21660.480451.538290 at akasha.ijm.jussieu.fr> Date: Mon, 5 May 2003 14:10:04 +0200 To: Richard Jones Cc: lablgtk at kaba.or.jp Subject: Re: More GtkHtml questions In-Reply-To: <20030505110949.GB10796 at redhat.com> References: <20030503100346.GE24136 at redhat.com> <16051.59001.830936.263287@karryall.dnsalias.org> <20030504141338.GA9710@redhat.com> <20030505095109.GA10796@redhat.com> <16054.16579.173448.942063@akasha.ijm.jussieu.fr> <20030505110949.GB10796@redhat.com> Richard Jones [Monday 5 May 2003] : > > * your wrapping of save functions is not GC-safe, you must register > > your stored closure as a global root. The user_data value is not > > necessary since it can be included in the closure. So I would do it > > like this : > > Yes, I suspected this was not GC-safe. > > > CAMLprim value > > ml_gtk_html_save (value html, value receiver) > > { > > value *closure = ml_global_root_new(receiver); > > > > return Val_bool (gtk_html_save (GtkHTML_val(html), > > _save_receiver, closure)); > > } > > Is it possible to release the global root just after gtk_html_save > returns? Hum, I don't know how gtk_html_save works but I suspect that the callback is stored somewhere in the object and is referenced after gtk_html_save returns. If this is indeed the case, the global root must be kept until the html object is destroyed. > Of course in Caml these are variants, not just integers, so you can't > do logical operations on them. I'm not sure if there's an easy way to > solve this in Caml - except by having some C native functions for > converting font_style to integers and/or performing logical > operations. This doesn't seem type safe to me. Do you have any > opinions on the best way to solve this? See Benjamin's reply. If wanted to add that there is a macro for generating the conversion function : Make_Flags_val(Font_style_val) which defines Flags_Font_style_val that converts a `font_style list' into an integer by or'ing the values. -- Olivier