caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Automatic wrapper generator
@ 2004-05-18  8:38 skaller
  2004-05-18  8:58 ` Richard Jones
                   ` (4 more replies)
  0 siblings, 5 replies; 29+ messages in thread
From: skaller @ 2004-05-18  8:38 UTC (permalink / raw)
  To: caml-list

This is a brief status report concerning the Felix
automatic wrapper generator (reason for posting to Caml list
explained below).

With some platform specific hackery, I am now able to 
wrap 90% of all headers in '/usr/include' and execute
a single Felix test case:

-----------------------
include "stdio_h";
C_hack::ignore(stdio_h::printf(c"%s\n", c"Hello World"));
--------------------

Line 1 includes the wrapper generated for stdio.h.
Line 2 invokes the wrapper for a popular function 'printf()'.
This program compiles and executes correctly.

C_hack::ignore is the same as Ocaml's ignore function,
it throws away the result of calling printf. 
The lexical elements c".." generate C char arrays
(instead of Felix strings which are C++ STL strings).
The include directive pulls in a precompiled header
containing a module named stdio_h, which is used
as a qualifier to the function name printf().

It isn't clear I have got everything right yet,
there is still a long way to go. However I do consider
this a reasonable "proof-of-principle" demonstration
that automatic wrapping of the complete C development
environment is possible. The wrapper generator uses the
frontc/Cil parser, and generates the wrappers for 
of /usr/include in a couple of seconds.

RELEVANCE TO OCAML.
------------------

There isn't much that I'm doing for Felix wrappers
that can't be applied to Ocaml: perhaps with some
extra work it seems possible to make an Ocaml back end
to generate Foreign Function Interfaces for the whole
C environment in a few seconds.

Felix does have a few advantages over Ocaml that may
need to be considered in adapting the code, for example,
in Felix everything is automatically mutually recursive,
and so the order of definitions of types and functions
is irrelevant. Ocaml sometimes needs sequential definitions,
and has some problems with intermodule recursion.

However, I do not see any major obstacles.
[EG: intermodule recursion is a mess to handle by hand...
but it's no problem for a mechanical wrapper generator]

Note of course the generated wrappers are,
at least currently, LOW LEVEL and thus not safe.

for some time, people have been crying for 'MORE LIBRARIES'
for Ocaml.

Here's your chance to get THE LOT in one go.

I'm willing to work on adapting the wrapper generator
so it can be used to generate Ocaml wrappers, 
provided it continues to be useful generating
Felix ones. However, I can't tackle this on my own.

The generator needs to understand a heap
of highly  platform specific details, and a thus a lot
of people need to try it on many platforms to provide
the feedback needed to make it configurable enough to
actually work on many platforms.

Any comments appreciated.


-- 
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


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2004-05-23 19:59 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-18  8:38 [Caml-list] Automatic wrapper generator skaller
2004-05-18  8:58 ` Richard Jones
2004-05-18 10:07   ` skaller
2004-05-18  9:06 ` Basile Starynkevitch local
2004-05-18 10:25   ` skaller
2004-05-18 12:11     ` Richard Jones
2004-05-18 17:21       ` Michael Hamburg
2004-05-18 18:34         ` skaller
2004-05-18 19:27           ` Richard Jones
2004-05-18 20:52             ` skaller
2004-05-18 20:02       ` Gerd Stolpmann
2004-05-18 20:10         ` [Caml-list] Functional critical section SWAMPY
2004-05-18 20:31           ` Kenneth Knowles
2004-05-18 20:39           ` Evan Martin
2004-05-19  7:35             ` thornber
2004-05-19  7:33           ` thornber
2004-05-18  9:25 ` [Caml-list] Automatic wrapper generator Olivier Andrieu
2004-05-18 10:36   ` skaller
2004-05-18  9:38 ` Fermin Reig
2004-05-18 10:42   ` skaller
2004-05-18 10:57     ` Felix Winkelmann
2004-05-18 10:58     ` John Chu
2004-05-18 11:33       ` skaller
2004-05-22 10:09 ` Marcin 'Qrczak' Kowalczyk
2004-05-22 13:13   ` skaller
2004-05-22 14:19     ` Marcin 'Qrczak' Kowalczyk
2004-05-22 16:14       ` skaller
2004-05-23 10:58         ` Marcin 'Qrczak' Kowalczyk
2004-05-23 19:59           ` skaller

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).