caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* announce: callbacks-0.1
@ 2005-09-08 16:31 Christophe Raffalli
       [not found] ` <4320A68E.1060608@xs4all.nl>
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Raffalli @ 2005-09-08 16:31 UTC (permalink / raw)
  To: caml-list

link: third item of:

http://www.lama.univ-savoie.fr/~raffalli/?page=soft&lang=en

comment and idea are welcome !

-----------
MOTIVATION
-----------

callbacks are problematic when writting OCaml bindings for C
library. Indeed, a C function waits for a function respecting C
calling conventions as argument, and OCaml functions do not respect the
C conventions.

Then in a library you only have a limited number of the C functions and
in fact ideally, it is the user of the library that should often write 
the C function that needs to be passed in arguments to other C functions.

This is too hard for the average user ... this is why I wrote this package


Here is an example on how to use it (see the README file for a more 
detailled doc)

--------------
in glut.mli:
--------------

open Direct_callback
...
val reshapeFunc: cb:(w:int->h:int->unit) callback->unit
...

-------------
in a programm using lablGlut
-------------

let doReshape ~w ~h =
   ...

c_wrapper doReshape_cb for  doReshape : w:int->h:int->unit
...

ReshapeFunc doReshape_cb
...


-------------
in glut.ml
-------------

open Direct_callback
...
external reshapeFunc : cb:(w:int->h:int->unit) callback->unit = 
"ml_glutReshapeFunc"
...

-------------
in wrapglut.c
-------------

...
ML_1(glutReshapeFunc,Callback2)
...

which expends to

...
CAMLprim value ml_glutReshapeFunc (value arg1) \
{ glutReshapeFunc ((void (*)(int,int))(arg1)); return Val_unit; }
...



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

end of thread, other threads:[~2005-09-10 21:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08 16:31 announce: callbacks-0.1 Christophe Raffalli
     [not found] ` <4320A68E.1060608@xs4all.nl>
2005-09-08 21:24   ` [Caml-list] " Christophe Raffalli
2005-09-08 23:31     ` Bardur Arantsson
2005-09-09  6:30       ` Bardur Arantsson
2005-09-10  7:04         ` [Caml-list] " Xavier Leroy
2005-09-10  7:31           ` Bardur Arantsson
2005-09-10 13:04           ` [Caml-list] " Yaron Minsky
2005-09-10 21:02           ` caml_register_unmutable_global_root Christophe Raffalli

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