Date: Mon, 5 May 2003 12:09:49 +0100 Cc: lablgtk at kaba.or.jp Subject: Re: More GtkHtml questions Message-ID: <20030505110949.GB10796 at redhat.com> References: <20030503100346.GE24136 at redhat.com> <16051.59001.830936.263287 at karryall.dnsalias.org> <20030504141338.GA9710 at redhat.com> <20030505095109.GA10796 at redhat.com> <16054.16579.173448.942063 at akasha.ijm.jussieu.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16054.16579.173448.942063 at akasha.ijm.jussieu.fr> From: Richard Jones On Mon, May 05, 2003 at 12:45:23PM +0200, Olivier Andrieu wrote: > some comments: > > * about gtk_html_new_from_string, the int argument is not needed since > it is the length of the string : > > CAMLprim value ml_gtk_html_new_from_string(value s) > { > return Val_GtkAny_sink(gtk_html_new_from_string(String_val(s), > string_length(s))); > } OK, I fixed that. I was being extra paranoid about strings containing '\0', but I see that your method works even with those. > * 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? > * Also, in gHtml.ml, I think most of the methods should take an extra > unit argument. For instance : > method cut () = cut obj > that way, you could use html#cut as a callback. I'm not sure exactly what the difference is between: method cut = cut obj and method cut () = cut obj Doesn't the first define a partial function requiring one additional argument (the unit) before it is called? I have another question. I've defined a "font_style" type as: type font_style = [ | `DEFAULT | `SIZE_1 | `SIZE_2 | `SIZE_3 | `SIZE_4 | `SIZE_5 | `SIZE_6 | `SIZE_7 | `SIZE_MASK | `BOLD | `ITALIC | `UNDERLINE | `STRIKEOUT | `FIXED | `SUBSCRIPT | `SUPERSCRIPT ] (also in the *_tags.var file). So far so good, but now the set_font_style method takes two arguments, an "and mask" and an "or mask". So in C you would call this method as so: gtk_html_set_font_style (html, GTK_HTML_FONT_STYLE_SIZE_MASK| // and mask GTK_HTML_FONT_STYLE_BOLD| GTK_HTML_FONT_STYLE_ITALIC| GTK_HTML_FONT_STYLE_UNDERLINE| GTK_HTML_FONT_STYLE_STRIKEOUT| GTK_HTML_FONT_STYLE_FIXED| GTK_HTML_FONT_STYLE_SUBSCRIPT| GTK_HTML_FONT_STYLE_SUPERSCRIPT, GTK_HTML_FONT_STYLE_BOLD); // or mask (which, if I've got that right, would enable BOLD, leaving all other styles unchanged). 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? Cheers, Rich. -- Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/ http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/