[MLton] Callbacks

Mike Thomas mike.thomas@brisbane.paradigmgeo.com
Thu, 15 Jan 2004 18:01:12 +1000


Hi Stephen.

I'm having trouble with callbacks of this type:

=====================================================================
C API:
GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int
x, int y));

SML Side:
fun glutSpecialFunc (kbd: int * int * int -> unit) = ( gSpecFA kbd;
callGSpecF ())

(* Keyboard function callback *)
(*val gKbdFA = _export "glutKeyboardFuncArgument": char * int * int -> unit;
  val callGKbdF = _import "callGlutKeyboardFunc": unit -> unit;*)
=====================================================================

which gives an export unification error without much explanation,

and

=====================================================================
C API:
GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned
char key, int x, int y));

SML Side:
(*fun glutKeyboardFunc (kbd: char * int * int -> unit) = ( gKbdFA kbd;
callGKbdF ())*)
(* Special function callback *)
val gSpecFA = _export "glutSpecialFuncArgument": int * int * int -> unit;
val callGSpecF = _import "callGlutSpecialFunc": unit -> unit;
=====================================================================

which generates a C header with pointer type warnings.

ALl code checked in.  Must run for the train, Sorry for the short
explanation.

Mike Thomas.