! Additional special case rules for translating "winsock2.h". ! This version works with the header files from the ! MSDN "Platform SDK" of October 1997 or January 1998. ! ! $HopeName: D-win32-winsock2!more.pat(D-kan.4) $ ! $Date: 2004/03/12 00:09:30 $ @set-switch{t;1}@set-switch{w;1} \/\*\ Winsock\J*\n\G\s\*\s
\*\/=$0 \#define\ WINSOCK_API_LINKAGE DECLSPEC_IMPORT= WINSOCK_API_LINKAGE= struct \W\{\}\W\;=\N\n\ @bind{sclass;@map-name{$1}}\ @define{type\:struct\s\W$1\\=\@resolve-type\{\$1$1\}\@end}\ @define{ptr-type\:\\J@quote{$1}\=@quote{LP@upcase{@map-name{$1}}}}\ define C-struct @export{\<${sclass}\>}\n$2\N\ \ \ pointer-type-name\: @export{\}}\;\n\ end C-struct\;\N@unbind{sclass} ! ignore backward compatibility hack: fields:\#define h_addr *\n= fields:unsigned\ char \[\W\]\;=\ \ \ array slot @export{$1-array} @tab{20}\:\:\ @wrap{\ @type{unsigned char},}@wrap{\ length\: $2,}\ @ignore{@export{$1-array-setter}}\ @wrap{\ address-getter\: @export{$1-value}\;}\n ! special case because the nested unions are more trouble than they are worth. struct\ in_addr\W\{\}\;=\ define constant @export{\} \= \\;\n type:struct\s\Win_addr=\@end ! network address should always be treated as a , not . type:u_long \PWSAAPI=\@end type:unsigned\ long \PWSAAPI=\@end args:u_long hostlong=\ \ @putparm{hostlong,\} args:u_long netlong=\ \ @putparm{netlong,\} link:PASCAL\ FAR=, c-modifiers\: "__stdcall"@end link:WSAAPI=, c-modifiers\: "__stdcall"@end relevant-name:WSAAPI=@fail ! special case to use %logior instead of logior number:(IOC_IN\|IOC_OUT)=\%logior(\$IOC-IN, \$IOC-OUT)@end number:(SOCKET)= number:(u_int)= number:(INFINITE)=\$FFFFFFFF@end number:(WSAEVENT)NULL=\$NULL-HANDLE@end number:()=@map-name{$1}($2)@end type:struct\ fd_set=\@end type:u_long\ FAR\W\*=\@end type:u_short\ FAR\W\*=\@end type:struct\ sockaddr\ FAR\W\*=\@end type:struct\ sockaddr\W\*\*=\@end ! handle SOCKET as a special case - always use a typedef\ u_int SOCKET\;= type:SOCKET=\@end ! leading underscore special because Dylan doesn't allow beginning with "-". map-name:\A_\J=\% export:\A\_\J*=@map-name{$0} ! gz, Mar-10-00: No longer imported from win32-common ! ! defined in win32-common; don't re-export: !export-slot:cbSize=cbSize-value !export-slot:dwSize=dwSize-value !export-slot:Flags=Flags-value !export-slot:u=u-value !export-slot:wVersion=wVersion-value ! special case because no setter: export:Buffer-value=$0 ! C function, Dylan reserved word map-name:select=winsock-select args:IN OUT \W=\ \ \ input output parameter @cmps{$2;;$2;@argname{$1};$2} @tab{24}\:\: $1\;\n args:IN \W=\ \ \ input parameter @cmps{$2;;$2;@argname{$1};$2} @tab{24}\:\: $1\;\n args:OUT \W=\ \ \ output parameter @cmps{$2;;$2;@argname{$1};$2} @tab{24}\:\: $1\;\n typedef\ struct\ \C$1\;= typedef\ struct\ \J\C$1\;= lp:P\J=@end;LP\J=@end;=@end ! Function-like macros \L\#define \J() \n=\ \N\ndefine inline-only function @export{$1} ($2)\;\n\ \ $3\nend\;\n defexpr:\\\n\W=\S defexpr:()=@map-name{$1}($2) defexpr:=$1 defexpr:(SOCKET)= defexpr:(fd_set FAR\*)()=pointer-cast(\, $1) defexpr:\-\J\>=.@map-name{$1-value} defexpr:((long)() \& )=\%logand($1, $2) defexpr:()\W\<\<\W=ash($1,$2) defexpr:(IOC_\J)=\%logior(\$IOC-$1$2) number:_IO\J('',\W,\W)=\ @map-name{_IO$1}(as(\, '$2'), $3, $4)@end defexpr:((long)sizeof()\&)\<\<=\ ash(logand(size-of($1), $2), $3) defexpr:\=\=\W=\S\=\S defexpr:\=\W=\S\:\=\S defexpr:\J=\I$1$2 defexpr:=$1 defexpr:()=\I$1 defexpr:(#)=(#) defexpr:\/\*\*\/= ! expressions not yet handled: defexpr:\{=@fail defexpr:\?=@fail defexpr:\/=@fail defexpr:\*=@fail defexpr:\|=@fail defexpr:\&=@fail expr-list:\S=\S expr-list:=$1 expr-list:,\W=,@wrap{\s$1} expr-list:=@err{line @line failed expr-list at\: $1\n}@fail or-args:\W\|()=, $1 or-args:=@terminate \N\#if\ INCL_WINSOCK_API_TYPEDEFS=@{$3} ! symbol macro can't be translated to Dylan: relevant-constant:h_errno\I=@fail ! unused and undocumented: relevant-name:_IO\I=@fail ! undefined and undocumented: relevant-function:WSAGetAddressByName\J\I=@fail ! obsolete: relevant-function:WSACancelBlockingCall=@fail relevant-function:WSAIsBlocking=@fail relevant-function:WSAUnhookBlockingHook=@fail relevant-function:WSASetBlockingHook=@fail ! complex macros that need to be translated by hand: relevant-function:timercmp=@fail relevant-function:timerisset=@fail relevant-function:FD_CLR=@fail relevant-function:FD_SET=@fail relevant-function:FD_ZERO=@fail ! already defined in win32-common: def-flag:MAKEWORD=$0@end ! Mistake in header file -- IOC_W32 is undefined. ! SIO_QUERY_TARGET_PNP_HANDLE is undocumented anyway. \#define\ SIO_QUERY_TARGET_PNP_HANDLE _WSAIOR(IOC_W32,24)= ! type aliases \L\#define =define constant @export{\<$1\>} = \<$2\>\;\n ! Warn about macros that couldn't be handled: \L\#define \J(*\n=@err{Not translated\: $0} ! special case arguments that look like output parameters but are not: outok:lpFlags=@fail! WSARecv, WSARecvFrom - input/output parm. outok:lpdwBufferLength=@fail! WSAEnumProtocols - input/output parm.