[MLton-commit] r5460

Matthew Fluet fluet at mlton.org
Wed Mar 21 08:23:05 PST 2007


Restore and export {get,set}Bool for exported functions with boolean args/results.
----------------------------------------------------------------------

U   mlton/trunk/basis-library/mlton/ffi.sig
U   mlton/trunk/basis-library/mlton/ffi.sml

----------------------------------------------------------------------

Modified: mlton/trunk/basis-library/mlton/ffi.sig
===================================================================
--- mlton/trunk/basis-library/mlton/ffi.sig	2007-03-21 16:07:38 UTC (rev 5459)
+++ mlton/trunk/basis-library/mlton/ffi.sig	2007-03-21 16:23:04 UTC (rev 5460)
@@ -9,6 +9,7 @@
    sig
       val atomicBegin: unit -> unit
       val atomicEnd: unit -> unit
+      val getBool: int -> bool
       val getChar8: int -> Char.char
 (*
       val getChar16: int -> Char16.char
@@ -26,6 +27,7 @@
       val getWord32: int -> Word32.word
       val getWord64: int -> Word64.word
       val register: int * (unit -> unit) -> unit
+      val setBool: bool -> unit
       val setChar8: Char.char -> unit
 (*
       val setChar16: Char16.char -> unit

Modified: mlton/trunk/basis-library/mlton/ffi.sml
===================================================================
--- mlton/trunk/basis-library/mlton/ffi.sml	2007-03-21 16:07:38 UTC (rev 5459)
+++ mlton/trunk/basis-library/mlton/ffi.sml	2007-03-21 16:23:04 UTC (rev 5460)
@@ -54,4 +54,10 @@
 val setChar16 = setInt16 o Primitive.Char16.idToInt16
 val setChar32 = setInt32 o Primitive.Char32.idToInt32
 
+(* To the C-world, booleans are 32-bit integers. *)
+fun intToBool (i: Int32.int): bool = i <> 0
+val getBool = intToBool o getInt32
+fun boolToInt (b: bool): Int32.int = if b then 1 else 0
+val setBool = setInt32 o boolToInt
+
 end




More information about the MLton-commit mailing list