Changes by: Jason Hickey (jyh at cs.caltech.edu)
Date: 2005-08-19 16:20:32 -0700 (Fri, 19 Aug 2005)
Revision: 1403
Log message:
This is some exploration into dynamic linking. It contains:
- a parser for C code parse/C/{Parse,Lex}.om
- a stub code generator parse/C/Dll.om
The contrib/gtk directory gives an demo for Gtk (I chose Gtk
because it has nice header files, and it is sufficiently
complicated).
I'll write up some docs at some point, but here is the basic idea
of how a DLL is generated.
1. Parse the C header files.
2. Extract the declarations.
3. Generate C stubs for each of the declarations.
4. Produce a (large) C file that can be compiled
and then dynamically linked into your OCaml process.
Doing this all from your OMakefile is pretty simple. Mainly
you need to specify which functions you want to include
in your DLL.
This is reasonably independent from omake, so you can use it as
a generic way to generate wrappers around C functions.
Note that the C file for GTK is perhaps 120k lines of code, so
you get to stress your C compiler too.