caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* camlp4 question
@ 2005-09-08  8:02 Christophe Raffalli
  2005-09-08  8:16 ` Christophe Raffalli
  2005-09-08 17:41 ` [Caml-list] " Martin Jambon
  0 siblings, 2 replies; 5+ messages in thread
From: Christophe Raffalli @ 2005-09-08  8:02 UTC (permalink / raw)
  To: caml-list


I am writing a tool to facilitate the use of callback of camlfunction 
from C. I have a first prototype running for lablGlut, but I want to 
make it nicer using camlp4 (this extension should produce automatically 
the C wrapper for each callback, the user will only have to compile the 
produced C file).

The pb is that I need to retrieve information given in one module from 
another. The minimum I need to do is to search for the path given to 
ocamlc (the -I options) from camlp4 code, but I would prefer a better 
way, and I do not know how to retrive this PATH anyway.

Here is an example to illustrate what I need (the type 'a callback is a 
type to a C wrapper for a function of type 'a) :

-- file glut.ml, part of the lablGlut library --

...

let visibility_state_of_int = function
     0 ->  NOT_VISIBLE
   | 1 -> VISIBLE
   | _ -> raise (BadEnum "visibility_state")

REGISTER_CONVERSION visibility_state_of_int

external visibilityFunc :
   cb:(state:visibility_state_t->unit) callback->unit
    = "ml_glutVisibilityFunc"

...

-- file test.ml an example using lablGlut --

open Glut

...

let state_changed ~state =
   match value with
     NOT_VISIBLE -> printf "window not visible."; print_newline()
   | VISIBLE -> printf "window not visible."; print_newline()

MAKE_WRAPPER state_changed state_changed_cb
(* here I need to search for the convertion for the type 
visibility_state_of_int which was defined in glut.ml to make the
C wrapper state_changed_cb : (visibility_state_of_int -> unit) callback *)

let _ = Glut.visibilityFunc state_changed_cb

...

Can someone help ?


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

end of thread, other threads:[~2005-09-08 17:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08  8:02 camlp4 question Christophe Raffalli
2005-09-08  8:16 ` Christophe Raffalli
2005-09-08 17:36   ` [Caml-list] " Martin Jambon
2005-09-08 17:44     ` Christophe Raffalli
2005-09-08 17:41 ` [Caml-list] " Martin Jambon

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