[MLton] FFI: C void *
Vesa A Norrman
vnorrman@cc.hut.fi
Wed, 14 Jan 2004 18:33:47 +0200 (EET)
> I have tried both a Pointer type:
>
> ========================================================================
> C Side:
> Pointer mlton_glut_stroke_roman(void)
> {
> return ((Pointer) GLUT_STROKE_ROMAN);
> }
>
> SML side:
> type glutfont = Word32.word array
Where is this array coming from? why not Pointer.t?
> val GLUT_STROKE_ROMAN = _import "mlton_glut_stroke_roman" : glutfont;
Shouldn't this have type unit -> glutfont?
> val c_glutStrokeCharacter =
> _import "glutStrokeCharacter" stdcall: glutfont * int -> unit;
> fun glutStrokeCharacter (a:glutfont) (b:int) =
> c_glutStrokeCharacter (a,b)
> ========================================================================
>
> and a Word32.word type:
>
> ========================================================================
> C Side:
> Word32 mlton_glut_stroke_roman(void)
> {
> return ((Word32) GLUT_STROKE_ROMAN);
> }
Is this safe? Why cast to Word32 at all? I like the first code more.
> SML Side:
> type glutfont = Word32.word
> val GLUT_STROKE_ROMAN = _import "mlton_glut_stroke_roman" : glutfont;
Again not arrow type?
> val c_glutStrokeCharacter =
> _import "glutStrokeCharacter" stdcall: glutfont * int -> unit;
> fun glutStrokeCharacter (a:glutfont) (b:int) =
> c_glutStrokeCharacter
> (a,b)=======================================================================
> =
Maybe the latter is is better...
Vesa