Browse thread
[Caml-list] WxWidgets?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-09-17 (04:40) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] WxWidgets? |
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