From a81c78e4851cc3a7f5028e952b7c46ec2801e525 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 29 Aug 2009 19:25:18 -0500 Subject: [PATCH] WSABUF struct --- basis/io/sockets/windows/nt/nt.factor | 19 +++++++++---------- basis/windows/winsock/winsock.factor | 6 +++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/basis/io/sockets/windows/nt/nt.factor b/basis/io/sockets/windows/nt/nt.factor index 6d082f953c..6780fdcdd6 100755 --- a/basis/io/sockets/windows/nt/nt.factor +++ b/basis/io/sockets/windows/nt/nt.factor @@ -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 : ( 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 : ( packet addrspec datagram -- WSASendTo ) WSASendTo-args new diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index bd7304cde1..d19e4aca09 100755 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -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 -- 2.34.1