[MLton-commit] r6550

Matthew Fluet fluet at mlton.org
Mon Apr 7 11:33:55 PDT 2008


Abstract Socket.SOCK.sock_type with MkAbsRepEq

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

U   mlton/trunk/basis-library/net/generic-sock.sml
U   mlton/trunk/basis-library/net/net.sig
U   mlton/trunk/basis-library/net/net.sml
U   mlton/trunk/basis-library/net/socket.sml

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

Modified: mlton/trunk/basis-library/net/generic-sock.sml
===================================================================
--- mlton/trunk/basis-library/net/generic-sock.sml	2008-04-07 18:33:51 UTC (rev 6549)
+++ mlton/trunk/basis-library/net/generic-sock.sml	2008-04-07 18:33:54 UTC (rev 6550)
@@ -13,7 +13,9 @@
 
       fun socket' (af, st, p) =
          (Net.Sock.fromRep o PESC.simpleResult)
-         (fn () => Prim.socket (Net.AddrFamily.toRep af, st, C_Int.fromInt p))
+         (fn () => Prim.socket (Net.AddrFamily.toRep af, 
+                                Net.SockType.toRep st, 
+                                C_Int.fromInt p))
 
       fun socketPair' (af, st, p) =
          let
@@ -21,8 +23,11 @@
             val get = fn i => Net.Sock.fromRep (Array.sub (a, i))
          in
             PESC.syscall
-            (fn () => (Prim.socketPair (Net.AddrFamily.toRep af, st, C_Int.fromInt p, a), fn _ => 
-                       (get 0, get 1)))
+            (fn () => (Prim.socketPair (Net.AddrFamily.toRep af, 
+                                        Net.SockType.toRep st, 
+                                        C_Int.fromInt p, 
+                                        a), 
+                       fn _ => (get 0, get 1)))
          end
 
       fun socket (af, st) = socket' (af, st, 0)

Modified: mlton/trunk/basis-library/net/net.sig
===================================================================
--- mlton/trunk/basis-library/net/net.sig	2008-04-07 18:33:51 UTC (rev 6549)
+++ mlton/trunk/basis-library/net/net.sig	2008-04-07 18:33:54 UTC (rev 6550)
@@ -9,6 +9,7 @@
    sig
       structure AddrFamily : ABS_REP_EQ where type Rep.t = C_Int.t
       structure Sock : ABS_REP where type Rep.t = C_Sock.t
+      structure SockType : ABS_REP_EQ where type Rep.t = C_Sock.t
 
       structure Word16 :
          sig

Modified: mlton/trunk/basis-library/net/net.sml
===================================================================
--- mlton/trunk/basis-library/net/net.sml	2008-04-07 18:33:51 UTC (rev 6549)
+++ mlton/trunk/basis-library/net/net.sml	2008-04-07 18:33:54 UTC (rev 6550)
@@ -9,6 +9,7 @@
    struct
       structure AddrFamily = MkAbsRepEq(type rep = C_Int.t)
       structure Sock = MkAbsRep(type rep = C_Sock.t)
+      structure SockType = MkAbsRepEq(type rep = C_Sock.t)
 
       structure Prim = PrimitiveFFI.Net
 

Modified: mlton/trunk/basis-library/net/socket.sml
===================================================================
--- mlton/trunk/basis-library/net/socket.sml	2008-04-07 18:33:51 UTC (rev 6549)
+++ mlton/trunk/basis-library/net/socket.sml	2008-04-07 18:33:54 UTC (rev 6550)
@@ -9,11 +9,11 @@
 struct
 
 structure Prim = PrimitiveFFI.Socket
-structure Sock = Net.Sock
 structure Error = Posix.Error
 structure Syscall = Error.SysCall
 structure FileSys = Posix.FileSys
 
+structure Sock = Net.Sock
 type sock = Sock.t
 val sockToWord = C_Sock.castToSysWord o Sock.toRep
 val wordToSock = Sock.fromRep o C_Sock.castFromSysWord
@@ -60,11 +60,12 @@
           | NONE => NONE
    end
 
+structure SockType = Net.SockType
 structure SOCK =
    struct
-      type sock_type = C_Int.t
-      val stream = Prim.SOCK.STREAM
-      val dgram = Prim.SOCK.DGRAM
+      type sock_type = SockType.t
+      val stream = SockType.fromRep Prim.SOCK.STREAM
+      val dgram = SockType.fromRep Prim.SOCK.DGRAM
       val names : (string * sock_type) list = 
          ("STREAM", stream) ::
          ("DGRAM", dgram) ::
@@ -330,7 +331,7 @@
       val setSNDBUF = setSockOptSize (Prim.Ctl.SOL_SOCKET, Prim.Ctl.SO_SNDBUF)
       val getRCVBUF = getSockOptSize (Prim.Ctl.SOL_SOCKET, Prim.Ctl.SO_RCVBUF)
       val setRCVBUF = setSockOptSize (Prim.Ctl.SOL_SOCKET, Prim.Ctl.SO_RCVBUF)
-      fun getTYPE s = getSockOptInt (Prim.Ctl.SOL_SOCKET, Prim.Ctl.SO_TYPE) s
+      fun getTYPE s = SockType.fromRep (getSockOptInt (Prim.Ctl.SOL_SOCKET, Prim.Ctl.SO_TYPE) s)
       fun getERROR s =
          let
             val se = getSockOptInt (Prim.Ctl.SOL_SOCKET, Prim.Ctl.SO_ERROR) s




More information about the MLton-commit mailing list