From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id GAA29245; Fri, 17 Sep 2004 06:40:06 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA28334 for ; Fri, 17 Sep 2004 06:40:03 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8H4e1cq026223 for ; Fri, 17 Sep 2004 06:40:02 +0200 Received: from [192.168.1.200] (ppp202-133.lns1.syd3.internode.on.net [203.122.202.133]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i8H4dmOU075638; Fri, 17 Sep 2004 14:09:49 +0930 (CST) Subject: Re: [Caml-list] WxWidgets? From: skaller Reply-To: skaller@users.sourceforge.net To: SooHyoung Oh Cc: Caml Mailing List , Daan Leijen , "chris.danx" In-Reply-To: <002801c49c4a$265dc910$1501a8c0@hama> References: <4149F2D0.7040408@ntlworld.com> <20040916202511.GA24789@annexia.org> <414A05A5.7080603@ntlworld.com> <20040916213937.GA25981@annexia.org> <414A0CED.5070502@cs.uu.nl> <002801c49c4a$265dc910$1501a8c0@hama> Content-Type: text/plain Message-Id: <1095395987.2580.16.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 17 Sep 2004 14:39:48 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 414A6AA1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 implemented:01 widgets:01 widgets:01 systematic:01 frontc:01 wrappers:01 namespaces:01 callbacks:01 usr:01 python:01 mli:01 glue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 2004-09-17 at 10:06, SooHyoung Oh wrote: > I've followed wxHaskell method and implemented some of widgets > with Ocaml. > Implementing all of widgets of wxEiffel C wrapper requires much time, > so I'm finding more systematic method. > > Can you give me more hints about your comments about > how to generate Ocaml binding using wxDirect? The program 'flxcc' contained in my Felix package contains a wrapper generator which generates Felix bindings from C header files. Perhaps it can be modified to create Ocaml bindings. Flxcc uses the Frontc/Cil parser to parse C header files, and tries to generate a set of wrappers for each file (including any #include files encountered). It handles namespaces, overloading, and classes but not class constructors (can't figure how to mod the parser to get that right), and cheats on variadic functions. It detects most sane callbacks automatically. The process generates bindings for hundreds of files in the /usr/include tree on my box including the C standard library, Python, and GTK. I have no idea if they all work though :) Flxcc treats enountered types as abstract, so you will still need to provide typemapping functions. An excerpt from the binding generated for gtkstatusbar is given below. It should be fairly easy to modify the output to produce Ocaml mli and C glue. An alternative would be to generate IDL files and run them through ocamlidl. module gtk_2_0_gtk_gtkstatusbar_h { open C_hack; open glib_2_0_glib_gmem_h; open glib_2_0_glib_gslist_h; open glib_2_0_glib_gtypes_h; open glib_2_0_gobject_gtype_h; open gtk_2_0_gdk_gdktypes_h; open gtk_2_0_gtk_gtkhbox_h; open gtk_2_0_gtk_gtkstyle_h; //ABSTRACT TYPES type _struct__GtkStatusbar = 'struct _GtkStatusbar'; type _struct__GtkStatusbarClass = 'struct _GtkStatusbarClass'; //C FUNCTION POINTER TYPES header '''typedef void (*gtk_2_0_gtk_gtkstatusbar_h_cft_1)(GtkStatusbar *, guint, gchar const *);'''; type gtk_2_0_gtk_gtkstatusbar_h_cft_1 = 'gtk_2_0_gtk_gtkstatusbar_h_cft_1'; header '''typedef void (*gtk_2_0_gtk_gtkstatusbar_h_cft_2)(void);'''; type gtk_2_0_gtk_gtkstatusbar_h_cft_2 = 'gtk_2_0_gtk_gtkstatusbar_h_cft_2'; //STRUCT or UNION ALIASES typedef GtkStatusbarClass = _struct__GtkStatusbarClass; typedef GtkStatusbar = _struct__GtkStatusbar; //PROCEDURES proc gtk_statusbar_pop: ptr[GtkStatusbar] * guint = 'gtk_statusbar_pop($a);'; proc gtk_statusbar_remove: ptr[GtkStatusbar] * guint * guint = 'gtk_statusbar_remove($a);'; proc gtk_statusbar_set_has_resize_grip: ptr[GtkStatusbar] * gboolean = 'gtk_statusbar_set_has_resize_grip($a);'; //FUNCTIONS fun gtk_statusbar_get_context_id: ptr[GtkStatusbar] * cptr[gchar] -> guint = 'gtk_statusbar_get_context_id($a)'; fun gtk_statusbar_get_has_resize_grip: ptr[GtkStatusbar] -> gboolean = 'gtk_statusbar_get_has_resize_grip($a)'; fun gtk_statusbar_get_type: 1 -> GType = 'gtk_statusbar_get_type($a)'; fun gtk_statusbar_new: 1 -> ptr[GtkWidget] = 'gtk_statusbar_new($a)'; fun gtk_statusbar_push: ptr[GtkStatusbar] * guint * cptr[gchar] -> guint = 'gtk_statusbar_push($a)'; ..... -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners