caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: SooHyoung Oh <shoh@compiler.kaist.ac.kr>
Cc: Caml Mailing List <caml-list@inria.fr>,
	Daan Leijen <daan@cs.uu.nl>,
	"chris.danx" <chris.danx@ntlworld.com>
Subject: Re: [Caml-list] WxWidgets?
Date: 17 Sep 2004 14:39:48 +1000	[thread overview]
Message-ID: <1095395987.2580.16.camel@pelican.wigram> (raw)
In-Reply-To: <002801c49c4a$265dc910$1501a8c0@hama>

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


  reply	other threads:[~2004-09-17  4:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-16 20:08 chris.danx
2004-09-16 20:25 ` Richard Jones
2004-09-16 21:29   ` chris.danx
2004-09-16 21:39     ` Richard Jones
2004-09-16 22:00       ` Daan Leijen
2004-09-17  0:06         ` SooHyoung Oh
2004-09-17  4:39           ` skaller [this message]
2004-09-17  7:13           ` Daan Leijen
2004-09-17  8:04             ` Jean-Marc EBER
2004-09-19 21:46         ` François-Xavier HOUARD
2004-09-16 23:58       ` chris.danx
2004-09-17  8:10         ` Richard Jones
2004-09-17 12:38     ` Olivier Andrieu
2004-09-17 13:11       ` chris.danx
2004-09-17 13:51         ` skaller
2004-09-17 18:31           ` Brian Hurt
2004-09-17  7:53   ` Benedikt Grundmann
2004-09-16 20:44 ` Micha
2004-09-16 20:56 ` Basile STARYNKEVITCH
2004-09-20  1:02 ` [Caml-list] WxWidgets? - wxcaml SooHyoung Oh
2004-09-21 23:21   ` Zeno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1095395987.2580.16.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=chris.danx@ntlworld.com \
    --cc=daan@cs.uu.nl \
    --cc=shoh@compiler.kaist.ac.kr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).