[MLton-commit] r6549
Matthew Fluet
fluet at mlton.org
Mon Apr 7 11:33:53 PDT 2008
Abstract NetHostDB.addr_family with MkAbsRepEq
----------------------------------------------------------------------
U mlton/trunk/basis-library/net/generic-sock.sml
U mlton/trunk/basis-library/net/inet-sock.sml
U mlton/trunk/basis-library/net/net-host-db.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
U mlton/trunk/basis-library/net/unix-sock.sml
----------------------------------------------------------------------
Modified: mlton/trunk/basis-library/net/generic-sock.sml
===================================================================
--- mlton/trunk/basis-library/net/generic-sock.sml 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/generic-sock.sml 2008-04-07 18:33:51 UTC (rev 6549)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2002-2006 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2002-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -13,7 +13,7 @@
fun socket' (af, st, p) =
(Net.Sock.fromRep o PESC.simpleResult)
- (fn () => Prim.socket (af, st, C_Int.fromInt p))
+ (fn () => Prim.socket (Net.AddrFamily.toRep af, st, C_Int.fromInt p))
fun socketPair' (af, st, p) =
let
@@ -21,7 +21,7 @@
val get = fn i => Net.Sock.fromRep (Array.sub (a, i))
in
PESC.syscall
- (fn () => (Prim.socketPair (af, st, C_Int.fromInt p, a), fn _ =>
+ (fn () => (Prim.socketPair (Net.AddrFamily.toRep af, st, C_Int.fromInt p, a), fn _ =>
(get 0, get 1)))
end
Modified: mlton/trunk/basis-library/net/inet-sock.sml
===================================================================
--- mlton/trunk/basis-library/net/inet-sock.sml 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/inet-sock.sml 2008-04-07 18:33:51 UTC (rev 6549)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2002-2007 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2002-2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -15,7 +15,7 @@
type dgram_sock = Socket.dgram sock
type sock_addr = inet Socket.sock_addr
- val inetAF = PrimitiveFFI.Socket.AF.INET
+ val inetAF = Net.AddrFamily.fromRep PrimitiveFFI.Socket.AF.INET
fun toAddr (in_addr, port) =
let
Modified: mlton/trunk/basis-library/net/net-host-db.sml
===================================================================
--- mlton/trunk/basis-library/net/net-host-db.sml 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/net-host-db.sml 2008-04-07 18:33:51 UTC (rev 6549)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2002-2006 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2002-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -43,7 +43,8 @@
; finish ()
end
- type addr_family = C_Int.t
+ structure AddrFamily = Net.AddrFamily
+ type addr_family = AddrFamily.t
datatype entry = T of {name: string,
aliases: string list,
@@ -93,7 +94,7 @@
in
SOME (T {name = name,
aliases = aliases,
- addrType = addrType,
+ addrType = AddrFamily.fromRep addrType,
addrs = addrs})
end
else NONE
Modified: mlton/trunk/basis-library/net/net.sig
===================================================================
--- mlton/trunk/basis-library/net/net.sig 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/net.sig 2008-04-07 18:33:51 UTC (rev 6549)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2002-2007 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2002-2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -7,6 +7,9 @@
signature NET =
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 Word16 :
sig
val hton: Word16.word -> Word16.word
@@ -17,5 +20,4 @@
val hton: C_Int.t -> C_Int.t
val ntoh: C_Int.t -> C_Int.t
end
- structure Sock : ABS_REP where type Rep.t = C_Sock.t
end
Modified: mlton/trunk/basis-library/net/net.sml
===================================================================
--- mlton/trunk/basis-library/net/net.sml 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/net.sml 2008-04-07 18:33:51 UTC (rev 6549)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2002-2006 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2002-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -7,6 +7,9 @@
structure Net : NET =
struct
+ structure AddrFamily = MkAbsRepEq(type rep = C_Int.t)
+ structure Sock = MkAbsRep(type rep = C_Sock.t)
+
structure Prim = PrimitiveFFI.Net
structure Word32 =
@@ -68,6 +71,4 @@
val ntoh = S.f
end
end
-
- structure Sock = MkAbsRep(type rep = C_Sock.t)
end
Modified: mlton/trunk/basis-library/net/socket.sml
===================================================================
--- mlton/trunk/basis-library/net/socket.sml 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/socket.sml 2008-04-07 18:33:51 UTC (rev 6549)
@@ -39,14 +39,15 @@
datatype passive = PASSIVE (* phantom *)
datatype active = ACTIVE (* phantom *)
+structure AddrFamily = Net.AddrFamily
structure AF =
struct
- type addr_family = NetHostDB.addr_family
+ type addr_family = AddrFamily.t
val names : (string * addr_family) list =
- ("UNIX", Prim.AF.UNIX) ::
- ("INET", Prim.AF.INET) ::
- ("INET6", Prim.AF.INET6) ::
- ("UNSPEC", Prim.AF.UNSPEC) ::
+ ("UNIX", AddrFamily.fromRep Prim.AF.UNIX) ::
+ ("INET", AddrFamily.fromRep Prim.AF.INET) ::
+ ("INET6", AddrFamily.fromRep Prim.AF.INET6) ::
+ ("UNSPEC", AddrFamily.fromRep Prim.AF.UNSPEC) ::
nil
fun list () = names
fun toString af' =
@@ -364,7 +365,7 @@
fun sameAddr (SA sa1, SA sa2) = sa1 = sa2
-fun familyOfAddr (SA sa) = Prim.familyOfAddr sa
+fun familyOfAddr (SA sa) = AddrFamily.fromRep (Prim.familyOfAddr sa)
fun bind (s, SA sa) =
Syscall.simple (fn () => Prim.bind (Sock.toRep s, sa, C_Socklen.fromInt (Vector.length sa)))
Modified: mlton/trunk/basis-library/net/unix-sock.sml
===================================================================
--- mlton/trunk/basis-library/net/unix-sock.sml 2008-04-07 18:33:47 UTC (rev 6548)
+++ mlton/trunk/basis-library/net/unix-sock.sml 2008-04-07 18:33:51 UTC (rev 6549)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2002-2006 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2002-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a BSD-style license.
@@ -14,7 +14,7 @@
type 'mode stream_sock = 'mode Socket.stream sock
type dgram_sock = Socket.dgram sock
type sock_addr = unix Socket.sock_addr
- val unixAF = PrimitiveFFI.Socket.AF.UNIX
+ val unixAF = Net.AddrFamily.fromRep PrimitiveFFI.Socket.AF.UNIX
fun toAddr s =
let
More information about the MLton-commit
mailing list