Drawtext tidying up ready for the next big change:
[wine/wine-kai.git] / tools / make_X11wrappers
blob1fc5967ed3a02137d805c82415d0d509b9bbc60e
1 #!/usr/bin/perl -w
3 # Create threads safe wrappers around X11 calls.
5 # Copyright 1998 Kristian Nielsen.
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/).
15 # This program expects to be run from Wine's main directory.
17 $X11_include_dir = "/usr/X11/include";
18 $outdir = "tsx11";
19 $wantfile = "$outdir/X11_calls";
20 @dolist = ("Xlib", "Xresource", "Xutil", "XShm", "xf86dga", "xf86dga2", "xf86vmode", "shape", "xvideo", "Xrender");
22 # First read list of wanted function names.
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 '$_'";
34 close(WANT);
36 foreach $name (@dolist) {
38 $ucname = uc $name;
39 $lcname = lc $name;
41 $outfile = "/ts_$lcname";
42 open(OUTC, ">$outdir/$outfile.c") || die "open";
43 open(OUTH, ">include/$outfile.h") || die "open";
45 $x11_incl = "";
46 $extensions_dir = "";
47 $pre_file = "";
48 $post_file = "";
49 $inc_name = $name;
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";
55 if($name eq "xf86dga") {
56 $x11_incl = "#include <X11/Xlib.h>\n";
57 $extensions_dir = "extensions/";
58 $pre_file = "#ifdef HAVE_LIBXXF86DGA\n";
59 $post_file = "#endif /* defined(HAVE_LIBXXF86DGA) */\n";
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";
68 if($name eq "XShm") {
69 $extensions_dir = "extensions/";
70 $pre_file = "#ifdef HAVE_LIBXXSHM\n";
71 $post_file = "#endif /* defined(HAVE_LIBXXSHM) */\n";
73 if($name eq "xf86vmode") {
74 $x11_incl = "#include <X11/Xlib.h>\n";
75 $extensions_dir = "extensions/";
76 $pre_file = "#include \"windef.h\"\n#ifdef HAVE_LIBXXF86VM\n#define XMD_H\n#include \"basetsd.h\"\n";
77 $post_file = "#endif /* defined(HAVE_LIBXXF86VM) */\n";
79 if($name eq "shape") {
80 $extensions_dir = "extensions/";
81 $pre_file = "#ifdef HAVE_LIBXSHAPE\n#include <X11/IntrinsicP.h>\n";
82 $post_file = "#endif /* defined(HAVE_LIBXSHAPE) */\n";
83 $inc_name = "shape";
85 if($name eq "xvideo") {
86 $x11_incl = "#include <X11/Xlib.h>\n#include <X11/extensions/Xv.h>\n#include <X11/extensions/XShm.h>\n";
87 $extensions_dir = "extensions/";
88 $pre_file = "#ifdef HAVE_XVIDEO\n";
89 $post_file = "#endif /* defined(HAVE_XVIDEO) */\n";
90 $inc_name = "Xvlib";
92 if($name eq "Xrender") {
93 $x11_incl = "#include <X11/Xlib.h>\n";
94 $extensions_dir = "extensions/";
95 $pre_file = "#ifdef HAVE_LIBXRENDER\n";
96 $post_file = "#endif /* defined(HAVE_LIBXRENDER) */\n";
100 print OUTH <<END;
102 * Thread safe wrappers around $name calls.
103 * Always include this file instead of <X11/$name.h>.
104 * This file was generated automatically by tools/make_X11wrappers
105 * DO NOT EDIT!
108 #ifndef __WINE_TS_$ucname\_H
109 #define __WINE_TS_$ucname\_H
111 #ifndef __WINE_CONFIG_H
112 # error You must include config.h to use this header
113 #endif
115 $pre_file
116 $x11_incl#include <X11/$extensions_dir$inc_name.h>
118 extern void (*wine_tsx11_lock)(void);
119 extern void (*wine_tsx11_unlock)(void);
123 print OUTC <<END;
125 * Thread safe wrappers around $name calls.
126 * This file was generated automatically by tools/make_X11wrappers
127 * DO NOT EDIT!
130 #include "config.h"
132 $pre_file
133 $x11_incl#include <X11/$extensions_dir$inc_name.h>
135 #include "ts_$lcname.h"
139 if ($name eq "XShm") {
140 output_fn("XShmQueryExtension", "Bool",
141 "Display *", "Display *a0", "a0");
142 output_fn("XShmQueryVersion", "Bool",
143 "Display *, int *, int *, Bool *",
144 "Display *a0, int *a1, int *a2, Bool *a3", "a0, a1, a2, a3");
145 output_fn("XShmPixmapFormat", "int",
146 "Display *", "Display *a0", "a0");
147 output_fn("XShmAttach", Status,
148 "Display *, XShmSegmentInfo *",
149 "Display *a0, XShmSegmentInfo *a1", "a0, a1");
150 output_fn("XShmDetach", Status,
151 "Display *, XShmSegmentInfo *",
152 "Display *a0, XShmSegmentInfo *a1", "a0, a1");
153 output_fn("XShmPutImage", Status,
154 "Display *, Drawable, GC, XImage *, int, int, int, int, unsigned int, unsigned int, Bool",
155 "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");
156 output_fn("XShmGetImage", Status,
157 "Display *, Drawable, XImage *, int, int, unsigned long",
158 "Display *a0, Drawable a1, XImage *a2, int a3, int a4, unsigned long a5",
159 "a0, a1, a2, a3, a4, a5");
160 output_fn("XShmCreateImage", "XImage *",
161 "Display *, Visual *, unsigned int, int, char *, XShmSegmentInfo *, unsigned int, unsigned int",
162 "Display *a0, Visual *a1, unsigned int a2, int a3, char *a4, XShmSegmentInfo *a5, unsigned int a6, unsigned int a7",
163 "a0, a1, a2, a3, a4, a5, a6, a7");
164 output_fn("XShmCreatePixmap", "Pixmap",
165 "Display *, Drawable, char *, XShmSegmentInfo *, unsigned int, unsigned int, unsigned int",
166 "Display *a0, Drawable a1, char *a2, XShmSegmentInfo *a3, unsigned int a4, unsigned int a5, unsigned int a6",
167 "a0, a1, a2, a3, a4, a5, a6");
168 } elsif($name eq "xf86dga") {
169 output_fn("XF86DGAQueryVersion",Bool,
170 "Display*,int*,int*",
171 "Display*a0,int*a1,int*a2",
172 "a0,a1,a2"
174 output_fn("XF86DGAQueryExtension",Bool,
175 "Display*,int*,int*",
176 "Display*a0,int*a1,int*a2",
177 "a0,a1,a2"
179 output_fn("XF86DGAGetVideo",Status,
180 "Display*,int,char**,int*,int*,int*",
181 "Display*a0,int a1,char**a2,int*a3,int*a4,int*a5",
182 "a0,a1,a2,a3,a4,a5"
184 output_fn("XF86DGADirectVideo",Status,
185 "Display*,int,int",
186 "Display*a0,int a1,int a2",
187 "a0,a1,a2"
189 output_fn("XF86DGAGetViewPortSize",Status,
190 "Display*,int,int*,int*",
191 "Display*a0,int a1,int *a2,int *a3",
192 "a0,a1,a2,a3"
194 output_fn("XF86DGASetViewPort",Status,
195 "Display*,int,int,int",
196 "Display*a0,int a1,int a2,int a3",
197 "a0,a1,a2,a3"
199 output_fn("XF86DGAInstallColormap",Status,
200 "Display*,int,Colormap",
201 "Display*a0,int a1,Colormap a2",
202 "a0,a1,a2"
204 output_fn("XF86DGAQueryDirectVideo",Status,
205 "Display*,int,int*",
206 "Display*a0,int a1,int *a2",
207 "a0,a1,a2"
209 output_fn("XF86DGAViewPortChanged",Status,
210 "Display*,int,int",
211 "Display*a0,int a1,int a2",
212 "a0,a1,a2"
214 } elsif($name eq "xf86dga2") {
215 output_fn_short("Bool", "XDGAQueryVersion", "Display*" ,"int*","int*");
216 output_fn_short("Bool", "XDGAQueryExtension", "Display*" ,"int*","int*");
217 output_fn_short("XDGAMode*", "XDGAQueryModes", "Display*" ,"int", "int*");
218 output_fn_short("XDGADevice*", "XDGASetMode", "Display*" ,"int","int");
219 output_fn_short("Bool", "XDGAOpenFramebuffer", "Display*" ,"int");
220 output_fn_short("void", "XDGACloseFramebuffer", "Display*" ,"int");
221 output_fn_short("void", "XDGASetViewport", "Display*" ,"int", "int", "int", "int");
222 output_fn_short("void", "XDGAInstallColormap", "Display*" , "int", "Colormap");
223 output_fn_short("Colormap", "XDGACreateColormap", "Display*" ,"int", "XDGADevice*", "int");
224 output_fn_short("void", "XDGASelectInput", "Display*" ,"int", "long");
225 output_fn_short("void", "XDGAFillRectangle", "Display*" ,"int", "int", "int", "unsigned int", "unsigned int", "unsigned long");
226 output_fn_short("void", "XDGACopyArea", "Display*" ,"int", "int", "int", "unsigned int", "unsigned int", "int", "int");
227 output_fn_short("void", "XDGACopyTransparentArea", "Display*" ,"int", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned long");
228 output_fn_short("int", "XDGAGetViewportStatus", "Display*" ,"int");
229 output_fn_short("void", "XDGASync", "Display*" ,"int");
230 output_fn_short("Bool", "XDGASetClientVersion", "Display*");
231 output_fn_short("void", "XDGAChangePixmapMode", "Display*" ,"int", "int*", "int*", "int");
232 output_fn_short("void", "XDGAKeyEventToXKeyEvent", "XDGAKeyEvent*" ,"XKeyEvent*");
233 } elsif ($name eq "xvideo") {
234 output_fn_short("int", "XvQueryExtension", "Display*", "unsigned int*", "unsigned int*", "unsigned int*", "unsigned int*", "unsigned int*");
235 output_fn_short("int", "XvQueryAdaptors", "Display*", "Window", "unsigned int*", "XvAdaptorInfo**");
236 output_fn_short("int", "XvQueryEncodings", "Display*", "XvPortID", "unsigned int*", "XvEncodingInfo**");
237 output_fn_short("int", "XvPutVideo", "Display*", "XvPortID", "Drawable", "GC", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned int", "unsigned int");
238 output_fn_short("int", "XvPutStill", "Display*", "XvPortID", "Drawable", "GC", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned int", "unsigned int");
239 output_fn_short("int", "XvGetVideo", "Display*", "XvPortID", "Drawable", "GC", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned int", "unsigned int");
240 output_fn_short("int", "XvGetStill", "Display*", "XvPortID", "Drawable", "GC", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned int", "unsigned int");
241 output_fn_short("int", "XvStopVideo", "Display*", "XvPortID", "Drawable");
242 output_fn_short("int", "XvGrabPort", "Display*", "XvPortID", "Time");
243 output_fn_short("int", "XvUngrabPort", "Display*", "XvPortID", "Time");
244 output_fn_short("int", "XvSelectVideoNotify", "Display*", "Drawable", "Bool");
245 output_fn_short("int", "XvSelectPortNotify", "Display*", "XvPortID", "Bool");
246 output_fn_short("int", "XvSetPortAttribute", "Display*", "XvPortID", "Atom", "int");
247 output_fn_short("int", "XvGetPortAttribute", "Display*", "XvPortID", "Atom", "int*");
248 output_fn_short("int", "XvQueryBestSize", "Display*", "XvPortID", "Bool", "unsigned int", "unsigned int", "unsigned int", "unsigned int", "unsigned int*", "unsigned int*");
249 output_fn_short("XvAttribute*", "XvQueryPortAttributes", "Display*", "XvPortID", "int*");
250 output_fn_short("void", "XvFreeAdaptorInfo", "XvAdaptorInfo*");
251 output_fn_short("void", "XvFreeEncodingInfo", "XvEncodingInfo*");
252 output_fn_short("XvImageFormatValues *", "XvListImageFormats", "Display*", "XvPortID", "int*");
253 output_fn_short("XvImage *", "XvCreateImage", "Display*", "XvPortID", "int", "char*", "int", "int");
254 output_fn_short("int", "XvPutImage", "Display*", "XvPortID", "Drawable", "GC", "XvImage*", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned int", "unsigned int");
255 output_fn_short("int", "XvShmPutImage", "Display*", "XvPortID", "Drawable", "GC", "XvImage*", "int", "int", "unsigned int", "unsigned int", "int", "int", "unsigned int", "unsigned int", "Bool");
256 output_fn_short("XvImage *", "XvShmCreateImage", "Display*", "XvPortID", "int", "char*", "int", "int", "XShmSegmentInfo*");
257 } elsif($name eq "xf86vmode") {
258 output_fn("XF86VidModeQueryVersion",Bool,
259 "Display*,int*,int*",
260 "Display*a0,int*a1,int*a2",
261 "a0,a1,a2"
263 output_fn("XF86VidModeQueryExtension",Bool,
264 "Display*,int*,int*",
265 "Display*a0,int*a1,int*a2",
266 "a0,a2,a2"
268 output_fn("XF86VidModeGetModeLine",Bool,
269 "Display*,int,int*,XF86VidModeModeLine*",
270 "Display*a0,int a1,int*a2,XF86VidModeModeLine*a3",
271 "a0,a1,a2,a3"
273 output_fn("XF86VidModeGetAllModeLines",Bool,
274 "Display*,int,int*,XF86VidModeModeInfo***",
275 "Display*a0,int a1,int*a2,XF86VidModeModeInfo***a3",
276 "a0,a1,a2,a3"
278 output_fn("XF86VidModeAddModeLine",Bool,
279 "Display*,int,XF86VidModeModeInfo*,XF86VidModeModeInfo*",
280 "Display*a0,int a1,XF86VidModeModeInfo*a2,XF86VidModeModeInfo*a3",
281 "a0,a1,a2,a3"
283 output_fn("XF86VidModeDeleteModeLine",Bool,
284 "Display*,int,XF86VidModeModeInfo*",
285 "Display*a0,int a1,XF86VidModeModeInfo*a2",
286 "a0,a1,a2"
288 output_fn("XF86VidModeModModeLine",Bool,
289 "Display*,int,XF86VidModeModeLine*",
290 "Display*a0,int a1,XF86VidModeModeLine*a2",
291 "a0,a1,a2"
293 output_fn("XF86VidModeValidateModeLine",Status,
294 "Display*,int,XF86VidModeModeInfo*",
295 "Display*a0,int a1,XF86VidModeModeInfo*a2",
296 "a0,a1,a2"
298 output_fn("XF86VidModeSwitchMode",Bool,
299 "Display*,int,int",
300 "Display*a0,int a1,int a2",
301 "a0,a1,a2"
303 output_fn("XF86VidModeSwitchToMode",Bool,
304 "Display*,int,XF86VidModeModeInfo*",
305 "Display*a0,int a1,XF86VidModeModeInfo*a2",
306 "a0,a1,a2"
308 output_fn("XF86VidModeLockModeSwitch",Bool,
309 "Display*,int,int",
310 "Display*a0,int a1,int a2",
311 "a0,a1,a2"
313 output_fn("XF86VidModeGetMonitor",Bool,
314 "Display*,int,XF86VidModeMonitor*",
315 "Display*a0,int a1,XF86VidModeMonitor*a2",
316 "a0,a1,a2"
318 output_fn("XF86VidModeGetViewPort",Bool,
319 "Display*,int,int*,int*",
320 "Display*a0,int a1,int*a2,int*a3",
321 "a0,a1,a2,a3"
323 output_fn("XF86VidModeSetViewPort",Bool,
324 "Display*,int,int,int",
325 "Display*a0,int a1,int a2,int a3",
326 "a0,a1,a2,a3"
328 } elsif($name eq "Xrender") {
329 output_fn("XRenderAddGlyphs","void",
330 "Display*,GlyphSet,Glyph*,XGlyphInfo*,int,char*,int",
331 "Display*a0,GlyphSet a1,Glyph*a2,XGlyphInfo*a3,int a4,char*a5,int a6",
332 "a0,a1,a2,a3,a4,a5,a6"
334 output_fn("XRenderCompositeString8","void",
335 "Display*,int,Picture,Picture,XRenderPictFormat*,GlyphSet,int,int,int,int,char*,int",
336 "Display*a0,int a1,Picture a2,Picture a3,XRenderPictFormat*a4,GlyphSet a5,int a6,int a7,int a8,int a9,char*a10,int a11",
337 "a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11"
339 output_fn("XRenderCompositeString16","void",
340 "Display*,int,Picture,Picture,XRenderPictFormat*,GlyphSet,int,int,int,int,unsigned short*,int",
341 "Display*a0,int a1,Picture a2,Picture a3,XRenderPictFormat*a4,GlyphSet a5,int a6,int a7,int a8,int a9,unsigned short*a10,int a11",
342 "a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11"
344 output_fn("XRenderCompositeString32","void",
345 "Display*,int,Picture,Picture,XRenderPictFormat*,GlyphSet,int,int,int,int,unsigned int*,int",
346 "Display*a0,int a1,Picture a2,Picture a3,XRenderPictFormat*a4,GlyphSet a5,int a6,int a7,int a8,int a9,unsigned int*a10,int a11",
347 "a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11"
349 output_fn("XRenderCreateGlyphSet",GlyphSet,
350 "Display*,XRenderPictFormat*",
351 "Display*a0,XRenderPictFormat*a1",
352 "a0,a1"
354 output_fn("XRenderCreatePicture",Picture,
355 "Display*,Drawable,XRenderPictFormat*,unsigned long,XRenderPictureAttributes*",
356 "Display*a0,Drawable a1,XRenderPictFormat*a2,unsigned long a3,XRenderPictureAttributes*a4",
357 "a0,a1,a2,a3,a4"
359 output_fn("XRenderFillRectangle","void",
360 "Display*,int,Picture,XRenderColor*,int,int,unsigned int, unsigned int",
361 "Display*a0,int a1,Picture a2,XRenderColor*a3,int a4,int a5,unsigned int a6,unsigned int a7",
362 "a0,a1,a2,a3,a4,a5,a6,a7"
364 output_fn("XRenderFindFormat","XRenderPictFormat*",
365 "Display*,unsigned long,XRenderPictFormat*,int",
366 "Display*a0,unsigned long a1,XRenderPictFormat*a2,int a3",
367 "a0,a1,a2,a3"
369 output_fn("XRenderFindVisualFormat","XRenderPictFormat*",
370 "Display*,Visual*",
371 "Display*a0,Visual*a1",
372 "a0,a1"
374 output_fn("XRenderFreeGlyphSet","void",
375 "Display*,GlyphSet",
376 "Display*a0,GlyphSet a1",
377 "a0,a1"
379 output_fn("XRenderFreePicture","void",
380 "Display*,Picture",
381 "Display*a0,Picture a1",
382 "a0,a1"
384 output_fn("XRenderSetPictureClipRectangles","void",
385 "Display*,Picture,int,int,XRectangle*,int",
386 "Display*a0,Picture a1,int a2,int a3,XRectangle* a4,int a5",
387 "a0,a1,a2,a3,a4,a5"
389 output_fn("XRenderQueryExtension",Bool,
390 "Display*,int*,int*",
391 "Display*a0,int*a1,int*a2",
392 "a0,a1,a2"
395 } else {
396 open(IN,
397 "echo \"$x11_incl#include <X11/$extensions_dir$name.h>\" | " .
398 "gcc -L$X11_include_dir -DNeedFunctionPrototypes -E - | " .
399 "grep -v '^[ \t]*\$)' |"
400 ) || die "open";
402 PROTO: while(<IN>) {
403 if(m'extern\s+([^()]*)\b([a-zA-Z0-9_]+)\s*\(') {
404 $result_type = $1;
405 $fn_name = $2;
406 $result_type = "int" if $result_type =~ /^\s*$/;
407 @args = ();
408 while(<IN>) {
409 last if m'\)\s*;';
410 # Give up on vararg functions and function pointer args.
411 if(m'\.\.\.|\(\*\)') {
412 undef $fn_name;
413 last;
415 if(m'\s*([^,]*[^, \t])\s*(,?\n)') {
416 $args[$#args+1] = $1;
417 if ($1 =~ /char\s*\[/) { # small hack for XQueryKeymap
418 $args[$#args] = "char*";
422 # Skip if vararg, function pointer arg, or not needed.
423 next unless $fn_name;
424 next unless $want{$fn_name} && $want{$fn_name} == 1;
426 # Special case for no arguments (which is specified as "void").
427 if($#args == 0 && $args[0] eq "void") {
428 @args = ();
430 $proto = "";
431 $formals = "";
432 $actuals = "";
433 for($i = 0; $i <= $#args; $i++) {
434 $comma = $i < $#args ? ", " : "";
435 $proto .= "$args[$i]$comma";
436 $formals .= "$args[$i] a$i$comma";
437 $actuals .= "a$i$comma";
439 $proto = $formals = "void" if $#args == -1;
440 output_fn($fn_name, $result_type, $proto, $formals, $actuals);
445 if($name eq "Xlib") {
446 raw_output_fn("XSynchronize", "int (*r)(Display *)",
447 "int (*TSXSynchronize(Display *, Bool))(Display *)",
448 "int (*TSXSynchronize(Display *a0, Bool a1))(Display *)",
449 "a0, a1");
450 print OUTC "\nextern void _XInitImageFuncPtrs(XImage *);\n";
451 output_fn("_XInitImageFuncPtrs", "void", "XImage *", "XImage *a0", "a0");
452 } elsif($name eq "Xutil") {
453 output_fn("XDestroyImage", "int",
454 "struct _XImage *", "struct _XImage *a0", "a0");
455 output_fn("XGetPixel", "unsigned long",
456 "struct _XImage *, int, int",
457 "struct _XImage *a0, int a1, int a2",
458 "a0, a1, a2");
459 output_fn("XPutPixel", "int",
460 "struct _XImage *, int, int, unsigned long",
461 "struct _XImage *a0, int a1, int a2, unsigned long a3",
462 "a0, a1, a2, a3");
463 output_fn("XSubImage", "struct _XImage *",
464 "struct _XImage *, int, int, unsigned int, unsigned int",
465 "struct _XImage *a0, int a1, int a2, unsigned int a3, unsigned int a4",
466 "a0, a1, a2, a3, a4");
467 output_fn("XAddPixel", "int",
468 "struct _XImage *, long",
469 "struct _XImage *a0, long a1", "a0, a1");
470 output_fn("XUniqueContext", "XContext", "void", "void", "");
471 output_fn("XDeleteContext", "int",
472 "Display*,XID,XContext",
473 "Display*a0,XID a1,XContext a2",
474 "a0,a1,a2");
477 print OUTH <<END;
479 $post_file
480 #endif /* __WINE_TS_$ucname\_H */
482 print OUTC <<END;
484 $post_file
491 foreach $i (keys %want) {
492 if($want{$i} == 1) {
493 print "Unresolved: $i\n";
498 sub output_fn {
499 # Example call:
500 # output_fn("main", "int", "int, char **", "int a0, char **a1", "a0, a1")
503 my ($fn_name, $result_type, $protos, $formals, $actuals) = @_;
505 return raw_output_fn($fn_name,
506 $result_type =~ /^\s*void\s*$/ ? "" : "$result_type r",
507 "$result_type TS$fn_name($protos)",
508 "$result_type TS$fn_name($formals)",
509 $actuals);
512 sub output_fn_short {
513 # Example call:
514 # output_fn_sort("Bool", "XDGAQueryExtension", "Display *", "int *", "int *");
516 my ($result_type, $fn_name, @args) = @_;
518 my ($i, $proto, $formals, $actuals) = (0,
519 "$result_type TS$fn_name(",
520 "$result_type TS$fn_name(",
521 "");
522 while ($val = shift @args) {
523 $proto = $proto . $val;
524 $formals = $formals . $val . " a$i";
525 $actuals = $actuals . " a$i";
526 $i++;
527 if (@args) {
528 $proto = $proto . ", ";
529 $formals = $formals . ", ";
530 $actuals = $actuals . ", ";
533 $proto = $proto . ")";
534 $formals = $formals . ")";
537 raw_output_fn($fn_name,
538 $result_type =~ /^\s*void\s*$/ ? "" : "$result_type r",
539 $proto,
540 $formals,
541 $actuals);
544 sub raw_output_fn {
545 # Example call:
546 # output_fn("main", "int r", "int main(int, char **)", "int main(int a0, char **a1)", "a0, a1")
549 my ($fn_name, $resultdecl, $protodecl, $defdecl, $actuals) = @_;
551 return undef unless $want{$fn_name} && $want{$fn_name} == 1;
553 print OUTC "\n$defdecl\n";
554 print OUTH "extern $protodecl;\n";
555 # print OUTH "#define $fn_name TS$fn_name\n";
556 print OUTC "{\n";
557 print OUTC " $resultdecl;\n" if $resultdecl;
558 print OUTC " wine_tsx11_lock();\n";
559 print OUTC " ";
560 print OUTC "r = " if $resultdecl;
561 print OUTC "$fn_name($actuals);\n";
562 print OUTC " wine_tsx11_unlock();\n";
563 print OUTC " return r;\n" if $resultdecl;
564 print OUTC "}\n";
565 $want{$fn_name} = 2;
566 return 1;