Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4 question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe Raffalli <christophe.raffalli@u...>
Subject: camlp4 question

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 ?