]> gitweb.factorcode.org Git - factor.git/commitdiff
WSABUF struct
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Aug 2009 00:25:18 +0000 (19:25 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Aug 2009 00:25:18 +0000 (19:25 -0500)
basis/io/sockets/windows/nt/nt.factor
basis/windows/winsock/winsock.factor

index 6d082f953c0cdf614e1949fb90649eb9f300bb69..6780fdcdd6f92f93af93b7a750131a3676bb318f 100755 (executable)
@@ -2,7 +2,8 @@ USING: alien alien.accessors alien.c-types byte-arrays
 continuations destructors io.ports io.timeouts io.sockets
 io namespaces io.streams.duplex io.backend.windows
 io.sockets.windows io.backend.windows.nt windows.winsock kernel
-libc math sequences threads system combinators accessors ;
+libc math sequences threads system combinators accessors
+classes.struct ;
 IN: io.sockets.windows.nt
 
 : malloc-int ( object -- object )
@@ -127,9 +128,9 @@ TUPLE: WSARecvFrom-args port
        lpFlags lpFrom lpFromLen lpOverlapped lpCompletionRoutine ;
 
 : make-receive-buffer ( -- WSABUF )
-    "WSABUF" malloc-object &free
-    default-buffer-size get over set-WSABUF-len
-    default-buffer-size get malloc &free over set-WSABUF-buf ; inline
+    WSABUF malloc-struct &free
+        default-buffer-size get
+        [ >>len ] [ malloc &free >>buf ] bi ; inline
 
 : <WSARecvFrom-args> ( datagram -- WSARecvFrom )
     WSARecvFrom-args new
@@ -158,7 +159,7 @@ TUPLE: WSARecvFrom-args port
     } cleave WSARecvFrom socket-error* ; inline
 
 : parse-WSARecvFrom ( n WSARecvFrom -- packet sockaddr )
-    [ lpBuffers>> WSABUF-buf swap memory>byte-array ]
+    [ lpBuffers>> buf>> swap memory>byte-array ]
     [ [ lpFrom>> ] [ lpFromLen>> *int ] bi memory>byte-array ] bi ; inline
 
 M: winnt (receive) ( datagram -- packet addrspec )
@@ -175,11 +176,9 @@ TUPLE: WSASendTo-args port
        dwFlags lpTo iToLen lpOverlapped lpCompletionRoutine ;
 
 : make-send-buffer ( packet -- WSABUF )
-    "WSABUF" malloc-object &free
-    [ [ malloc-byte-array &free ] dip set-WSABUF-buf ]
-    [ [ length ] dip set-WSABUF-len ]
-    [ nip ]
-    2tri ; inline
+    [ WSABUF malloc-struct &free ] dip
+        [ malloc-byte-array &free >>buf ]
+        [ length >>len ] bi ; inline
 
 : <WSASendTo-args> ( packet addrspec datagram -- WSASendTo )
     WSASendTo-args new
index bd7304cde123da47d53fdb6e6e66d3e81ff46cb0..d19e4aca090b1f45813ac4e67b2ab1cfae10ba20 100755 (executable)
@@ -195,9 +195,9 @@ C-STRUCT: FLOWSPEC
 TYPEDEF: FLOWSPEC* PFLOWSPEC
 TYPEDEF: FLOWSPEC* LPFLOWSPEC
 
-C-STRUCT: WSABUF
-    { "ulong" "len" }
-    { "void*" "buf" } ;
+STRUCT: WSABUF
+    { len ulong }
+    { buf void* } ;
 TYPEDEF: WSABUF* LPWSABUF
 
 C-STRUCT: QOS