Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | |
| 3 | # Create threads safe wrappers around X11 calls. |
| 4 | # |
| 5 | # Copyright 1998 Kristian Nielsen. |
| 6 | # |
| 7 | |
| 8 | # FIXME: This does not do full C prototype parsing, but relies on |
| 9 | # knowledge on how the X11 include files are formatted. It will |
| 10 | # probably need to be modified for new include files. It also fails |
| 11 | # for certain prototypes (notably those with function pointer |
| 12 | # arguments or results), so these must be added manually. And it |
| 13 | # relies on a fixed location of X11 includes (/usr/X11R6/include/). |
| 14 | # |
| 15 | # This program expects to be run from Wine's main directory. |
| 16 | |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 17 | $X11_include_dir = "/usr/X11/include"; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 18 | $outdir = "tsx11"; |
| 19 | $wantfile = "$outdir/X11_calls"; |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 20 | @dolist = ("Xlib", "Xresource", "Xutil", "xpm", "XShm", "xf86dga", "xf86dga2", "xf86vmode"); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 21 | |
| 22 | # First read list of wanted function names. |
| 23 | |
| 24 | open(WANT, $wantfile) || die "open"; |
| 25 | while(<WANT>) { |
| 26 | next if /^\s*\#/; # Skip comment lines. |
| 27 | next if /^\s*$/; # Skip empty lines. |
| 28 | if(/^\s*([a-zA-Z0-9_]+)\s*$/) { |
| 29 | $want{$1} = 1; |
| 30 | } else { |
| 31 | die "syntax error in file '$wantfile', in line '$_'"; |
| 32 | } |
| 33 | } |
| 34 | close(WANT); |
| 35 | |
| 36 | foreach $name (@dolist) { |
| 37 | |
| 38 | $ucname = uc $name; |
| 39 | $lcname = lc $name; |
| 40 | |
| 41 | $outfile = "/ts_$lcname"; |
| 42 | open(OUTC, ">$outdir/$outfile.c") || die "open"; |
| 43 | open(OUTH, ">include/$outfile.h") || die "open"; |
| 44 | |
| 45 | $x11_incl = ""; |
| 46 | $extensions_dir = ""; |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 47 | $pre_file = ""; |
| 48 | $post_file = ""; |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 49 | $inc_name = $name; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 50 | if($name eq "Xutil" || $name eq "Xresource" || $name eq "XShm") { |
| 51 | $x11_incl = "#include <X11/Xlib.h>\n"; |
| 52 | # For Xutil, we need X11/Xresource.h for XUniqueContext(). |
| 53 | $x11_incl .= "#include <X11/Xresource.h>\n" if $name eq "Xutil"; |
| 54 | } |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 55 | if($name eq "xf86dga") { |
| 56 | $x11_incl = "#include <X11/Xlib.h>\n"; |
| 57 | $extensions_dir = "extensions/"; |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 58 | $pre_file = "#ifdef HAVE_LIBXXF86DGA\n"; |
| 59 | $post_file = "#endif /* defined(HAVE_LIBXXF86DGA) */\n"; |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 60 | } |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 61 | if($name eq "xf86dga2") { |
| 62 | $x11_incl = "#include <X11/Xlib.h>\n"; |
| 63 | $extensions_dir = "extensions/"; |
| 64 | $pre_file = "#ifdef HAVE_LIBXXF86DGA2\n"; |
| 65 | $post_file = "#endif /* defined(HAVE_LIBXXF86DGA2) */\n"; |
| 66 | $inc_name = "xf86dga"; |
| 67 | } |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 68 | if($name eq "XShm") { |
| 69 | $extensions_dir = "extensions/"; |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 70 | $pre_file = "#ifdef HAVE_LIBXXSHM\n"; |
| 71 | $post_file = "#endif /* defined(HAVE_LIBXXSHM) */\n"; |
| 72 | } |
| 73 | if($name eq "xpm") { |
| 74 | $pre_file = "#ifdef HAVE_LIBXXPM\n"; |
| 75 | $post_file = "#endif /* defined(HAVE_LIBXXPM) */\n"; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 76 | } |
Stephen Crowley | 399931a | 1998-12-08 13:10:56 +0000 | [diff] [blame] | 77 | if($name eq "xf86vmode") { |
| 78 | $x11_incl = "#include <X11/Xlib.h>\n"; |
| 79 | $extensions_dir = "extensions/"; |
Patrik Stridvall | 2d0bb2a | 1999-07-04 15:56:03 +0000 | [diff] [blame] | 80 | $pre_file = "#include \"windef.h\"\n#ifdef HAVE_LIBXXF86VM\n#define XMD_H\n#include \"basetsd.h\"\n"; |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 81 | $post_file = "#endif /* defined(HAVE_LIBXXF86VM) */\n"; |
Stephen Crowley | 399931a | 1998-12-08 13:10:56 +0000 | [diff] [blame] | 82 | } |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 83 | |
| 84 | print OUTH <<END; |
| 85 | /* |
| 86 | * Thread safe wrappers around $name calls. |
| 87 | * Always include this file instead of <X11/$name.h>. |
| 88 | * This file was generated automatically by tools/make_X11wrappers |
| 89 | * |
| 90 | * Copyright 1998 Kristian Nielsen |
| 91 | */ |
| 92 | |
Patrik Stridvall | 857eb39 | 1999-06-12 18:36:54 +0000 | [diff] [blame] | 93 | #ifndef __WINE_TS_$ucname\_H |
| 94 | #define __WINE_TS_$ucname\_H |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 95 | |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 96 | #include "config.h" |
| 97 | |
| 98 | #ifndef X_DISPLAY_MISSING |
| 99 | |
| 100 | $pre_file |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 101 | $x11_incl#include <X11/$extensions_dir$inc_name.h> |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 102 | |
| 103 | END |
| 104 | |
| 105 | print OUTC <<END; |
| 106 | /* |
| 107 | * Thread safe wrappers around $name calls. |
| 108 | * This file was generated automatically by tools/make_X11wrappers |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 109 | * DO NOT EDIT! |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 110 | */ |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 111 | |
| 112 | #include "config.h" |
| 113 | |
| 114 | #ifndef X_DISPLAY_MISSING |
| 115 | |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 116 | $pre_file |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 117 | $x11_incl#include <X11/$extensions_dir$inc_name.h> |
Patrik Stridvall | 109767a | 1999-07-31 14:38:31 +0000 | [diff] [blame] | 118 | |
Alexandre Julliard | ded196c | 1999-05-14 08:11:40 +0000 | [diff] [blame] | 119 | #include "debugtools.h" |
Patrik Stridvall | 109767a | 1999-07-31 14:38:31 +0000 | [diff] [blame] | 120 | #include "ts_$lcname.h" |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 121 | #include "x11drv.h" |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 122 | |
| 123 | DEFAULT_DEBUG_CHANNEL(x11) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 124 | END |
| 125 | |
| 126 | if($name eq "xpm") { # Handle as special case. |
| 127 | output_fn("XpmCreatePixmapFromData", "int", |
| 128 | "Display *, Drawable, char **, Pixmap *, Pixmap *, XpmAttributes *", |
| 129 | "Display *a0, Drawable a1, char **a2, Pixmap *a3, Pixmap *a4, XpmAttributes *a5", |
| 130 | "a0, a1, a2, a3, a4, a5"); |
| 131 | output_fn("XpmAttributesSize", "int", "void", "void", ""); |
| 132 | } elsif($name eq "XShm") { |
| 133 | output_fn("XShmQueryExtension", "Bool", |
| 134 | "Display *", "Display *a0", "a0"); |
Lionel Ulmer | 16704da | 1998-11-15 16:43:32 +0000 | [diff] [blame] | 135 | output_fn("XShmQueryVersion", "Bool", |
| 136 | "Display *, int *, int *, Bool *", |
| 137 | "Display *a0, int *a1, int *a2, Bool *a3", "a0, a1, a2, a3"); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 138 | output_fn("XShmPixmapFormat", "int", |
| 139 | "Display *", "Display *a0", "a0"); |
Lionel Ulmer | 16704da | 1998-11-15 16:43:32 +0000 | [diff] [blame] | 140 | output_fn("XShmAttach", Status, |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 141 | "Display *, XShmSegmentInfo *", |
| 142 | "Display *a0, XShmSegmentInfo *a1", "a0, a1"); |
Lionel Ulmer | 16704da | 1998-11-15 16:43:32 +0000 | [diff] [blame] | 143 | output_fn("XShmDetach", Status, |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 144 | "Display *, XShmSegmentInfo *", |
| 145 | "Display *a0, XShmSegmentInfo *a1", "a0, a1"); |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 146 | output_fn("XShmPutImage", Status, |
| 147 | "Display *, Drawable, GC, XImage *, int, int, int, int, unsigned int, unsigned int, Bool", |
| 148 | "Display *a0, Drawable a1, GC a2, XImage *a3, int a4, int a5, int a6, int a7, unsigned int a8, unsigned int a9, Bool a10", "a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10"); |
Lionel Ulmer | 16704da | 1998-11-15 16:43:32 +0000 | [diff] [blame] | 149 | output_fn("XShmGetImage", Status, |
| 150 | "Display *, Drawable, XImage *, int, int, unsigned long", |
| 151 | "Display *a0, Drawable a1, XImage *a2, int a3, int a4, unsigned long a5", |
| 152 | "a0, a1, a2, a3, a4, a5"); |
| 153 | output_fn("XShmCreateImage", "XImage *", |
| 154 | "Display *, Visual *, unsigned int, int, char *, XShmSegmentInfo *, unsigned int, unsigned int", |
| 155 | "Display *a0, Visual *a1, unsigned int a2, int a3, char *a4, XShmSegmentInfo *a5, unsigned int a6, unsigned int a7", |
| 156 | "a0, a1, a2, a3, a4, a5, a6, a7"); |
| 157 | output_fn("XShmCreatePixmap", "Pixmap", |
| 158 | "Display *, Drawable, char *, XShmSegmentInfo *, unsigned int, unsigned int, unsigned int", |
| 159 | "Display *a0, Drawable a1, char *a2, XShmSegmentInfo *a3, unsigned int a4, unsigned int a5, unsigned int a6", |
| 160 | "a0, a1, a2, a3, a4, a5, a6"); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 161 | } elsif($name eq "xf86dga") { |
| 162 | output_fn("XF86DGAQueryVersion",Bool, |
| 163 | "Display*,int*,int*", |
| 164 | "Display*a0,int*a1,int*a2", |
| 165 | "a0,a1,a2" |
| 166 | ); |
| 167 | output_fn("XF86DGAQueryExtension",Bool, |
| 168 | "Display*,int*,int*", |
| 169 | "Display*a0,int*a1,int*a2", |
| 170 | "a0,a1,a2" |
| 171 | ); |
| 172 | output_fn("XF86DGAGetVideo",Status, |
| 173 | "Display*,int,char**,int*,int*,int*", |
| 174 | "Display*a0,int a1,char**a2,int*a3,int*a4,int*a5", |
| 175 | "a0,a1,a2,a3,a4,a5" |
| 176 | ); |
| 177 | output_fn("XF86DGADirectVideo",Status, |
| 178 | "Display*,int,int", |
| 179 | "Display*a0,int a1,int a2", |
| 180 | "a0,a1,a2" |
| 181 | ); |
| 182 | output_fn("XF86DGAGetViewPortSize",Status, |
| 183 | "Display*,int,int*,int*", |
| 184 | "Display*a0,int a1,int *a2,int *a3", |
| 185 | "a0,a1,a2,a3" |
| 186 | ); |
| 187 | output_fn("XF86DGASetViewPort",Status, |
| 188 | "Display*,int,int,int", |
| 189 | "Display*a0,int a1,int a2,int a3", |
| 190 | "a0,a1,a2,a3" |
| 191 | ); |
| 192 | output_fn("XF86DGAInstallColormap",Status, |
| 193 | "Display*,int,Colormap", |
| 194 | "Display*a0,int a1,Colormap a2", |
| 195 | "a0,a1,a2" |
| 196 | ); |
| 197 | output_fn("XF86DGAQueryDirectVideo",Status, |
| 198 | "Display*,int,int*", |
| 199 | "Display*a0,int a1,int *a2", |
| 200 | "a0,a1,a2" |
| 201 | ); |
| 202 | output_fn("XF86DGAViewPortChanged",Status, |
| 203 | "Display*,int,int", |
| 204 | "Display*a0,int a1,int a2", |
| 205 | "a0,a1,a2" |
| 206 | ); |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 207 | } elsif($name eq "xf86dga2") { |
| 208 | output_fn_short("Bool", "XDGAQueryVersion", "Display*" ,"int*","int*"); |
| 209 | output_fn_short("Bool", "XDGAQueryExtension", "Display*" ,"int*","int*"); |
| 210 | output_fn_short("XDGAMode*", "XDGAQueryModes", "Display*" ,"int", "int*"); |
| 211 | output_fn_short("XDGADevice*", "XDGASetMode", "Display*" ,"int","int"); |
| 212 | output_fn_short("Bool", "XDGAOpenFramebuffer", "Display*" ,"int"); |
| 213 | output_fn_short("void", "XDGACloseFramebuffer", "Display*" ,"int"); |
| 214 | output_fn_short("void", "XDGASetViewport", "Display*" ,"int", "int", "int", "int"); |
| 215 | output_fn_short("void", "XDGAInstallColormap", "Display*" , "int", "Colormap"); |
| 216 | output_fn_short("Colormap", "XDGACreateColormap", "Display*" ,"int", "XDGADevice*", "int"); |
| 217 | output_fn_short("void", "XDGASelectInput", "Display*" ,"int", "long"); |
| 218 | output_fn_short("void", "XDGAFillRectangle", "Display*" ,"int", "int", "int", "unsigned int", "unsigned int", "unsigned long"); |
| 219 | output_fn_short("void", "XDGACopyArea", "Display*" ,"int", "int", "int", "unsigned int", "unsigned int", "int", "int"); |
| 220 | output_fn_short("void", "XDGACopyTransparentArea", "Display*" ,"int", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned long"); |
| 221 | output_fn_short("int", "XDGAGetViewportStatus", "Display*" ,"int"); |
| 222 | output_fn_short("void", "XDGASync", "Display*" ,"int"); |
| 223 | output_fn_short("Bool", "XDGASetClientVersion", "Display*"); |
| 224 | output_fn_short("void", "XDGAChangePixmapMode", "Display*" ,"int", "int*", "int*", "int"); |
| 225 | output_fn_short("void", "XDGAKeyEventToXKeyEvent", "XDGAKeyEvent*" ,"XKeyEvent*"); |
Stephen Crowley | 399931a | 1998-12-08 13:10:56 +0000 | [diff] [blame] | 226 | } elsif($name eq "xf86vmode") { |
| 227 | output_fn("XF86VidModeQueryVersion",Bool, |
| 228 | "Display*,int*,int*", |
| 229 | "Display*a0,int*a1,int*a2", |
| 230 | "a0,a1,a2" |
| 231 | ); |
| 232 | output_fn("XF86VidModeQueryExtension",Bool, |
| 233 | "Display*,int*,int*", |
| 234 | "Display*a0,int*a1,int*a2", |
| 235 | "a0,a2,a2" |
| 236 | ); |
| 237 | output_fn("XF86VidModeGetModeLine",Bool, |
| 238 | "Display*,int,int*,XF86VidModeModeLine*", |
| 239 | "Display*a0,int a1,int*a2,XF86VidModeModeLine*a3", |
| 240 | "a0,a1,a2,a3" |
| 241 | ); |
| 242 | output_fn("XF86VidModeGetAllModeLines",Bool, |
| 243 | "Display*,int,int*,XF86VidModeModeInfo***", |
| 244 | "Display*a0,int a1,int*a2,XF86VidModeModeInfo***a3", |
| 245 | "a0,a1,a2,a3" |
| 246 | ); |
| 247 | output_fn("XF86VidModeAddModeLine",Bool, |
| 248 | "Display*,int,XF86VidModeModeInfo*,XF86VidModeModeInfo*", |
| 249 | "Display*a0,int a1,XF86VidModeModeInfo*a2,XF86VidModeModeInfo*a3", |
| 250 | "a0,a1,a2,a3" |
| 251 | ); |
| 252 | output_fn("XF86VidModeDeleteModeLine",Bool, |
| 253 | "Display*,int,XF86VidModeModeInfo*", |
| 254 | "Display*a0,int a1,XF86VidModeModeInfo*a2", |
| 255 | "a0,a1,a2" |
| 256 | ); |
| 257 | output_fn("XF86VidModeModModeLine",Bool, |
| 258 | "Display*,int,XF86VidModeModeLine*", |
| 259 | "Display*a0,int a1,XF86VidModeModeLine*a2", |
| 260 | "a0,a1,a2" |
| 261 | ); |
| 262 | output_fn("XF86VidModeValidateModeLine",Status, |
| 263 | "Display*,int,XF86VidModeModeInfo*", |
| 264 | "Display*a0,int a1,XF86VidModeModeInfo*a2", |
| 265 | "a0,a1,a2" |
| 266 | ); |
| 267 | output_fn("XF86VidModeSwitchMode",Bool, |
| 268 | "Display*,int,int", |
| 269 | "Display*a0,int a1,int a2", |
| 270 | "a0,a1,a2" |
| 271 | ); |
| 272 | output_fn("XF86VidModeSwitchToMode",Bool, |
| 273 | "Display*,int,XF86VidModeModeInfo*", |
| 274 | "Display*a0,int a1,XF86VidModeModeInfo*a2", |
| 275 | "a0,a1,a2" |
| 276 | ); |
| 277 | output_fn("XF86VidModeLockModeSwitch",Bool, |
| 278 | "Display*,int,int", |
| 279 | "Display*a0,int a1,int a2", |
| 280 | "a0,a1,a2" |
| 281 | ); |
| 282 | output_fn("XF86VidModeGetMonitor",Bool, |
| 283 | "Display*,int,XF86VidModeMonitor*", |
| 284 | "Display*a0,int a1,XF86VidModeMonitor*a2", |
| 285 | "a0,a1,a2" |
| 286 | ); |
| 287 | output_fn("XF86VidModeGetViewPort",Bool, |
| 288 | "Display*,int,int*,int*", |
| 289 | "Display*a0,int a1,int*a2,int*a3", |
| 290 | "a0,a1,a2,a3" |
| 291 | ); |
| 292 | output_fn("XF86VidModeSetViewPort",Bool, |
| 293 | "Display*,int,int,int", |
| 294 | "Display*a0,int a1,int a2,int a3", |
| 295 | "a0,a1,a2,a3" |
| 296 | ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 297 | } else { |
Patrik Stridvall | 109767a | 1999-07-31 14:38:31 +0000 | [diff] [blame] | 298 | open(IN, |
| 299 | "echo \"$x11_incl#include <X11/$extensions_dir$name.h>\" | " . |
| 300 | "gcc -L$X11_include_dir -DNeedFunctionPrototypes -E - | " . |
| 301 | "grep -v '^[ \t]*\$)' |" |
| 302 | ) || die "open"; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 303 | |
| 304 | PROTO: while(<IN>) { |
| 305 | if(m'extern\s+([^()]*)\b([a-zA-Z0-9_]+)\s*\(') { |
| 306 | $result_type = $1; |
| 307 | $fn_name = $2; |
| 308 | $result_type = "int" if $result_type =~ /^\s*$/; |
| 309 | @args = (); |
| 310 | while(<IN>) { |
| 311 | last if m'\)\s*;'; |
| 312 | # Give up on vararg functions and function pointer args. |
| 313 | if(m'\.\.\.|\(\*\)') { |
| 314 | undef $fn_name; |
| 315 | last; |
| 316 | } |
| 317 | if(m'\s*([^,]*[^, \t])\s*(,?\n)') { |
| 318 | $args[$#args+1] = $1; |
Marcus Meissner | 96dad15 | 1998-10-22 07:55:33 +0000 | [diff] [blame] | 319 | if ($1 =~ /char\s*\[/) { # small hack for XQueryKeymap |
| 320 | $args[$#args] = "char*"; |
| 321 | } |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | # Skip if vararg, function pointer arg, or not needed. |
| 325 | next unless $fn_name; |
| 326 | next unless $want{$fn_name} && $want{$fn_name} == 1; |
| 327 | |
| 328 | # Special case for no arguments (which is specified as "void"). |
| 329 | if($#args == 0 && $args[0] eq "void") { |
| 330 | @args = (); |
| 331 | } |
| 332 | $proto = ""; |
| 333 | $formals = ""; |
| 334 | $actuals = ""; |
| 335 | for($i = 0; $i <= $#args; $i++) { |
| 336 | $comma = $i < $#args ? ", " : ""; |
| 337 | $proto .= "$args[$i]$comma"; |
| 338 | $formals .= "$args[$i] a$i$comma"; |
| 339 | $actuals .= "a$i$comma"; |
| 340 | } |
| 341 | $proto = $formals = "void" if $#args == -1; |
| 342 | output_fn($fn_name, $result_type, $proto, $formals, $actuals); |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | if($name eq "Xlib") { |
| 348 | raw_output_fn("XSynchronize", "int (*r)(Display *)", |
| 349 | "int (*TSXSynchronize(Display *, Bool))(Display *)", |
| 350 | "int (*TSXSynchronize(Display *a0, Bool a1))(Display *)", |
| 351 | "a0, a1"); |
| 352 | print OUTC "\nextern void _XInitImageFuncPtrs(XImage *);\n"; |
| 353 | output_fn("_XInitImageFuncPtrs", "void", "XImage *", "XImage *a0", "a0"); |
| 354 | } elsif($name eq "Xutil") { |
| 355 | output_fn("XDestroyImage", "int", |
| 356 | "struct _XImage *", "struct _XImage *a0", "a0"); |
| 357 | output_fn("XGetPixel", "unsigned long", |
| 358 | "struct _XImage *, int, int", |
| 359 | "struct _XImage *a0, int a1, int a2", |
| 360 | "a0, a1, a2"); |
| 361 | output_fn("XPutPixel", "int", |
| 362 | "struct _XImage *, int, int, unsigned long", |
| 363 | "struct _XImage *a0, int a1, int a2, unsigned long a3", |
| 364 | "a0, a1, a2, a3"); |
| 365 | output_fn("XSubImage", "struct _XImage *", |
| 366 | "struct _XImage *, int, int, unsigned int, unsigned int", |
| 367 | "struct _XImage *a0, int a1, int a2, unsigned int a3, unsigned int a4", |
| 368 | "a0, a1, a2, a3, a4"); |
| 369 | output_fn("XAddPixel", "int", |
| 370 | "struct _XImage *, long", |
| 371 | "struct _XImage *a0, long a1", "a0, a1"); |
| 372 | output_fn("XUniqueContext", "XContext", "void", "void", ""); |
| 373 | } |
| 374 | |
| 375 | print OUTH <<END; |
| 376 | |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 377 | $post_file |
| 378 | #endif /* !defined(X_DISPLAY_MISSING) */ |
| 379 | |
Patrik Stridvall | 857eb39 | 1999-06-12 18:36:54 +0000 | [diff] [blame] | 380 | #endif /* __WINE_TS_$ucname\_H */ |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 381 | END |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 382 | print OUTC <<END; |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 383 | |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 384 | $post_file |
Patrik Stridvall | 48b5de8 | 1999-02-04 10:51:35 +0000 | [diff] [blame] | 385 | #endif /* !defined(X_DISPLAY_MISSING) */ |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 386 | END |
| 387 | |
| 388 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 389 | |
| 390 | } |
| 391 | |
| 392 | foreach $i (keys %want) { |
| 393 | if($want{$i} == 1) { |
| 394 | print "Unresolved: $i\n"; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | |
| 399 | sub output_fn { |
| 400 | # Example call: |
| 401 | # output_fn("main", "int", "int, char **", "int a0, char **a1", "a0, a1") |
| 402 | # |
| 403 | |
| 404 | my ($fn_name, $result_type, $protos, $formals, $actuals) = @_; |
| 405 | |
| 406 | return raw_output_fn($fn_name, |
| 407 | $result_type =~ /^\s*void\s*$/ ? "" : "$result_type r", |
| 408 | "$result_type TS$fn_name($protos)", |
| 409 | "$result_type TS$fn_name($formals)", |
| 410 | $actuals); |
| 411 | } |
| 412 | |
Lionel Ulmer | d94475b | 1999-09-20 18:42:46 +0000 | [diff] [blame] | 413 | sub output_fn_short { |
| 414 | # Example call: |
| 415 | # output_fn_sort("Bool", "XDGAQueryExtension", "Display *", "int *", "int *"); |
| 416 | # |
| 417 | my ($result_type, $fn_name, @args) = @_; |
| 418 | |
| 419 | my ($i, $proto, $formals, $actuals) = (0, |
| 420 | "$result_type TS$fn_name(", |
| 421 | "$result_type TS$fn_name(", |
| 422 | ""); |
| 423 | while ($val = shift @args) { |
| 424 | $proto = $proto . $val; |
| 425 | $formals = $formals . $val . " a$i"; |
| 426 | $actuals = $actuals . " a$i"; |
| 427 | $i++; |
| 428 | if (@args) { |
| 429 | $proto = $proto . ", "; |
| 430 | $formals = $formals . ", "; |
| 431 | $actuals = $actuals . ", "; |
| 432 | } |
| 433 | } |
| 434 | $proto = $proto . ")"; |
| 435 | $formals = $formals . ")"; |
| 436 | |
| 437 | |
| 438 | raw_output_fn($fn_name, |
| 439 | $result_type =~ /^\s*void\s*$/ ? "" : "$result_type r", |
| 440 | $proto, |
| 441 | $formals, |
| 442 | $actuals); |
| 443 | } |
| 444 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 445 | sub raw_output_fn { |
| 446 | # Example call: |
| 447 | # output_fn("main", "int r", "int main(int, char **)", "int main(int a0, char **a1)", "a0, a1") |
| 448 | # |
| 449 | |
| 450 | my ($fn_name, $resultdecl, $protodecl, $defdecl, $actuals) = @_; |
| 451 | |
| 452 | return undef unless $want{$fn_name} && $want{$fn_name} == 1; |
| 453 | |
| 454 | print OUTC "\n$defdecl\n"; |
| 455 | print OUTH "extern $protodecl;\n"; |
| 456 | # print OUTH "#define $fn_name TS$fn_name\n"; |
| 457 | print OUTC "{\n"; |
| 458 | print OUTC " $resultdecl;\n" if $resultdecl; |
Alexandre Julliard | ded196c | 1999-05-14 08:11:40 +0000 | [diff] [blame] | 459 | print OUTC " TRACE(\"Call $fn_name\\n\");\n"; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 460 | print OUTC " EnterCriticalSection( &X11DRV_CritSection );\n"; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 461 | print OUTC " "; |
| 462 | print OUTC "r = " if $resultdecl; |
| 463 | print OUTC "$fn_name($actuals);\n"; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 464 | print OUTC " LeaveCriticalSection( &X11DRV_CritSection );\n"; |
Alexandre Julliard | ded196c | 1999-05-14 08:11:40 +0000 | [diff] [blame] | 465 | print OUTC " TRACE(\"Ret $fn_name\\n\");\n"; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 466 | print OUTC " return r;\n" if $resultdecl; |
| 467 | print OUTC "}\n"; |
| 468 | $want{$fn_name} = 2; |
| 469 | return 1; |
| 470 | } |