makefiles: Automatically add missing source variables in make_makefiles.
[wine] / tools / winapi / winapi_module_user.pm
1 #
2 # Copyright 1999, 2000, 2001 Patrik Stridvall
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 #
18
19 package winapi_module_user;
20
21 use strict;
22
23 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
24 require Exporter;
25
26 @ISA = qw(Exporter);
27 @EXPORT = qw();
28 @EXPORT_OK = qw(
29     is_user_function
30     get_message_result_type
31     get_message_result_kind
32     get_message_wparam_type
33     get_message_wparam_kind
34     get_message_lparam_type
35     get_message_lparam_kind
36 );
37
38 use config qw($wine_dir);
39 use options qw($options);
40 use output qw($output);
41
42 use c_parser;
43
44 ########################################################################
45
46 my $message;
47
48 ########################################################################
49 # is_user_function
50
51 sub is_user_function($) {
52     my $name = shift;
53     if($name =~ /^(?:DefWindowProc|SendMessage)[AW]?$/) {
54     }
55 }
56
57 ########################################################################
58 # $message
59
60 $message = {
61     WM_ACTIVATE => {
62         id => 0x0006, result => "void", wparam => ["", ""], lparam => "HWND" },
63     WM_ACTIVATEAPP => {
64         id => 0x001c, result => "void", wparam => "BOOL", lparam => "DWORD" },
65     WM_ACTIVATESHELLWINDOW => {
66         id => 0x003e, result => "", wparam => "", lparam => "" },
67     WM_ACTIVATETOPLEVEL => {
68         id => 0x036e, result => "", wparam => "", lparam => "" },
69     WM_ALTTABACTIVE => {
70         id => 0x0029, result => "", wparam => "", lparam => "" },
71     WM_APP => {
72         id => 0x8000, result => "", wparam => "", lparam => "" },
73     WM_ASKCBFORMATNAME => {
74         id => 0x030c, result => "void", wparam => "int", lparam => "LPTSTR" },
75
76     WM_BEGINDRAG => {
77         id => 0x022c, result => "", wparam => "", lparam => "" },
78
79     WM_CANCELMODE => {
80         id => 0x001f, result => "void", wparam => "void", lparam => "void" },
81     WM_CANCELJOURNAL => {
82         id => 0x004b, result => "", wparam => "", lparam => "" },
83     WM_CAPTURECHANGED => {
84         id => 0x0215, result => "void", wparam => "void", lparam => "HWND" },
85     WM_CHANGECBCHAIN => {
86         id => 0x030d, result => "void", wparam => "HWND", lparam => "HWND" },
87     WM_CHILDACTIVATE => {
88         id => 0x0022, result => "void", wparam => "void", lparam => "void" },
89     WM_CLEAR => {
90         id => 0x0303, result => "void", wparam => "void", lparam => "void" },
91     WM_CHAR => {
92         id => 0x0102, result => "void", wparam => "TCHAR", lparam => ["", ""] },
93     WM_CHARTOITEM => {
94         id => 0x002f, result => "int", wparam => ["UINT", "UINT"], lparam => "HWND" },
95     WM_CLOSE => {
96         id => 0x0010, result => "void", wparam => "void", lparam => "void" },
97     WM_COALESCE_FIRST => {
98         id => 0x0390, result => "", wparam => "", lparam => "" },
99     WM_COALESCE_LAST => {
100         id => 0x039f, result => "", wparam => "", lparam => "" },
101     WM_COMMAND => {
102         id => 0x0111, result => "void", wparam => ["UINT", "UINT"], lparam => "HWND" },
103     WM_COMMANDHELP => {
104         id => 0x0365, result => "", wparam => "", lparam => "" },
105     WM_COMMNOTIFY => {
106         id => 0x0044, result => "void", wparam => "int", lparam => ["", ""] },
107     WM_CONTEXTMENU => {
108         id => 0x007b, result => "void", wparam => "HWND", lparam => ["UINT", "UINT"] },
109     WM_COPY => {
110         id => 0x0301, result => "void", wparam => "void", lparam => "void" },
111     WM_COPYDATA => {
112         id => 0x004a, result => "", wparam => "", lparam => "" },
113     WM_COMPACTING => {
114         id => 0x0041, result => "void", wparam => "UINT", lparam => "void" },
115     WM_COMPAREITEM => {
116         id => 0x0039, result => "int", wparam => "UINT", lparam => "const COMPAREITEMSTRUCT *" },
117     WM_CREATE => {
118         id => 0x0001, result => "BOOL", wparam => "void", lparam => "LPCREATESTRUCT" },
119     WM_CTLCOLOR => {
120         id => 0x0019, result => "", wparam => "", lparam => "" },
121     WM_CTLCOLORBTN => {
122         id => 0x0135, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
123     WM_CTLCOLORDLG => {
124         id => 0x136, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
125     WM_CTLCOLOREDIT => {
126         id => 0x133, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
127     WM_CTLCOLORLISTBOX => {
128         id => 0x134, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
129     WM_CTLCOLORMSGBOX => {
130         id => 0x132, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
131     WM_CTLCOLORSCROLLBAR => {
132         id => 0x137, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
133     WM_CTLCOLORSTATIC => {
134         id => 0x138, result => "HBRUSH", wparam => "HDC", lparam => "HWND" },
135     WM_CUT => {
136         id => 0x0300, result => "void", wparam => "void", lparam => "void" },
137
138     WM_DDE_ACK => { # FIXME: Only correct if replying to WM_DDE_INITIATE
139         id => 0x03E4, result => "void", wparam => "HWND", lparam => ["ATOM", "ATOM"] },
140     WM_DDE_INITIATE => {
141         id => 0x03E0, result => "void", wparam => "HWND", lparam => ["ATOM", "ATOM"] },
142     WM_DEADCHAR => {
143         id => 0x0103, result => "void", wparam => "TCHAR", lparam => ["", ""] },
144     WM_DEVICECHANGE => {
145         id => 0x0219, result => "BOOL", wparam => "UINT", lparam => "DWORD" },
146     WM_DELETEITEM => {
147         id => 0x002d, result => "void", wparam => "UINT", lparam => "const DELETEITEMSTRUCT *" },
148     WM_DEVMODECHANGE => {
149         id => 0x001b, result => "void", wparam => "void", lparam => "LPCTSTR" },
150     WM_DESTROY => {
151         id => 0x0002, result => "void", wparam => "void", lparam => "void" },
152     WM_DESTROYCLIPBOARD => {
153         id => 0x0307, result => "void", wparam => "void", lparam => "void" },
154     WM_DISABLEMODAL => {
155         id => 0x036c, result => "", wparam => "", lparam => "" },
156     WM_DISPLAYCHANGE => {
157         id => 0x007e, result => "void", wparam => "UINT", lparam => ["UINT", "UINT"] },
158     WM_DRAGLOOP => {
159         id => 0x022d, result => "", wparam => "", lparam => "" },
160     WM_DRAGMOVE => {
161         id => 0x022f, result => "", wparam => "", lparam => "" },
162     WM_DRAGSELECT => {
163         id => 0x022e, result => "", wparam => "", lparam => "" },
164     WM_DRAWCLIPBOARD => {
165         id => 0x0308, result => "void", wparam => "void", lparam => "void" },
166     WM_DRAWITEM => {
167         id => 0x002b, result => "void", wparam => "UINT", lparam => "const DRAWITEMSTRUCT *" },
168     WM_DROPFILES => {
169         id => 0x0233, result => "void", wparam => "HDROP", lparam => "void" },
170     WM_DROPOBJECT => {
171         id => 0x022a, result => "", wparam => "", lparam => "" },
172
173     WM_ENABLE => {
174         id => 0x000a, result => "void", wparam => "BOOL", lparam => "void" },
175     WM_ENDSESSION => {
176         id => 0x0016, result => "void", wparam => "BOOL", lparam => "void" },
177     WM_ENTERIDLE => {
178         id => 0x0121, result => "void", wparam => "UINT", lparam => "HWND" },
179     WM_ENTERSIZEMOVE => {
180         id => 0x0231, result => "", wparam => "", lparam => "" },
181     WM_ENTERMENULOOP => {
182         id => 0x0211, result => "", wparam => "", lparam => "" },
183     WM_ERASEBKGND => {
184         id => 0x0014, result => "BOOL", wparam => "HDC", lparam => "void" },
185     WM_EXITHELPMODE => {
186         id => 0x0367, result => "", wparam => "", lparam => "" },
187     WM_EXITMENULOOP => {
188         id => 0x0212, result => "", wparam => "", lparam => "" },
189     WM_EXITSIZEMOVE => {
190         id => 0x0232, result => "", wparam => "", lparam => "" },
191
192     WM_FILESYSCHANGE => {
193         id => 0x0034, result => "", wparam => "", lparam => "" },
194     WM_FLOATSTATUS => {
195         id => 0x036d, result => "", wparam => "", lparam => "" },
196     WM_FONTCHANGE => {
197         id => 0x001d, result => "void", wparam => "void", lparam => "void" },
198
199     WM_GETDLGCODE => {
200         id => 0x0087, result => "UINT", wparam => "WPARAM", lparam => "LPMSG" },
201     WM_GETFONT => {
202         id => 0x0031, result => "HFONT", wparam => "void", lparam => "void" },
203     WM_GETHOTKEY => {
204         id => 0x0033, result => "", wparam => "", lparam => "" },
205     WM_GETICON => {
206         id => 0x007f, result => "", wparam => "", lparam => "" },
207     WM_GETMINMAXINFO => {
208         id => 0x0024, result => "void", wparam => "void", lparam => "LPMINMAXINFO" },
209     WM_GETTEXT => {
210         id => 0x000d, result => "int", wparam => "int", lparam => "LPTSTR" },
211     WM_GETTEXTLENGTH => {
212         id => 0x000e, result => "int", wparam => "void", lparam => "void" },
213
214     WM_HELP => {
215         id => 0x0053, result => "void", wparam => "void", lparam => "LPHELPINFO" },
216     WM_HELPHITTEST => {
217         id => 0x0366, result => "", wparam => "", lparam => "" },
218     WM_HOTKEY => {
219         id => 0x0312, result => "", wparam => "", lparam => "" },
220     WM_HSCROLL => {
221         id => 0x0114, result => "void", wparam => ["int", "int"], lparam => "HWND" },
222     WM_HSCROLLCLIPBOARD => {
223         id => 0x030e, result => "void", wparam => "HWND", lparam => "" },
224
225     WM_ICONERASEBKGND => {
226         id => 0x0027, result => "BOOL", wparam => "HDC", lparam => "void" },
227     WM_IME_CHAR => {
228         id => 0x0286, result => "", wparam => "", lparam => "" },
229     WM_IME_COMPOSITION => {
230         id => 0x010f, result => "", wparam => "", lparam => "" },
231     WM_IME_COMPOSITIONFULL => {
232         id => 0x0284, result => "", wparam => "", lparam => "" },
233     WM_IME_CONTROL => {
234         id => 0x0283, result => "", wparam => "", lparam => "" },
235     WM_IME_ENDCOMPOSITION => {
236         id => 0x010e, result => "", wparam => "", lparam => "" },
237     WM_IME_KEYDOWN => {
238         id => 0x0290, result => "void", wparam => "UINT", lparam => ["int", "UINT"] },
239     WM_IME_KEYLAST => {
240         id => 0x010f, result => "", wparam => "", lparam => "" },
241     WM_IME_KEYUP => {
242         id => 0x0291, result => "void", wparam => "UINT", lparam => ["int", "UINT"] },
243     WM_IME_NOTIFY => {
244         id => 0x0282, result => "", wparam => "", lparam => "" },
245     WM_IME_REQUEST => {
246         id => 0x0288, result => "", wparam => "", lparam => "" },
247     WM_IME_SELECT => {
248         id => 0x0285, result => "", wparam => "", lparam => "" },
249     WM_IME_SETCONTEXT => {
250         id => 0x0281, result => "", wparam => "", lparam => "" },
251     WM_IME_STARTCOMPOSITION => {
252         id => 0x010d, result => "", wparam => "", lparam => "" },
253     WM_IDLEUPDATECMDUI => {
254         id => 0x0363, result => "", wparam => "", lparam => "" },
255     WM_INITDIALOG => {
256         id => 0x0110, result => "BOOL", wparam => "HWND", lparam => "LPARAM" },
257     WM_INITIALUPDATE => {
258         id => 0x0364, result => "", wparam => "", lparam => "" },
259     WM_INITMENU => {
260         id => 0x0116, result => "void", wparam => "HMENU", lparam => "void" },
261     WM_INITMENUPOPUP => {
262         id => 0x0117, result => "void", wparam => "HMENU", lparam => ["UINT", "BOOL"] },
263     WM_INPUTLANGCHANGE => {
264         id => 0x0051, result => "", wparam => "", lparam => "" },
265     WM_INPUTLANGCHANGEREQUEST => {
266         id => 0x0050, result => "", wparam => "", lparam => "" },
267     WM_ISACTIVEICON => {
268         id => 0x0035, result => "", wparam => "", lparam => "" },
269
270     WM_KEYDOWN => {
271         id => 0x0100, result => "void", wparam => "UINT", lparam => ["int", "UINT"] },
272     WM_KEYLAST => {
273         id => 0x0108, result => "", wparam => "", lparam => "" },
274     WM_KICKIDLE => {
275         id => 0x036a, result => "", wparam => "", lparam => "" },
276     WM_KEYUP => {
277         id => 0x0101, result => "void", wparam => "UINT", lparam => ["", ""] },
278     WM_KILLFOCUS => {
279         id => 0x0008, result => "void", wparam => "HWND", lparam => "void" },
280
281     WM_LBTRACKPOINT => {
282         id => 0x0131, result => "", wparam => "", lparam => "" },
283     WM_LBUTTONDBLCLK => {
284         id => 0x0203, result => "void", wparam => "UINT", lparam => ["", ""] },
285     WM_LBUTTONDOWN => {
286         id => 0x0201, result => "void", wparam => "UINT", lparam => ["", ""] },
287     WM_LBUTTONUP => {
288         id => 0x0202, result => "void", wparam => "UINT", lparam => ["", ""] },
289
290     WM_MBUTTONDBLCLK => {
291         id => 0x0209, result => "void", wparam => "UINT", lparam => ["", ""] },
292     WM_MBUTTONDOWN => {
293         id => 0x0207, result => "void", wparam => "UINT", lparam => ["", ""] },
294     WM_MBUTTONUP => {
295         id => 0x0208, result => "void", wparam => "UINT", lparam => ["", ""] },
296     WM_MDIACTIVATE => {
297         id => 0x0222, result => "void", wparam => "HWND", lparam => "HWND" },
298     WM_MDICASCADE => {
299         id => 0x0227, result => "BOOL", wparam => "UINT", lparam => "void" },
300     WM_MDICREATE => {
301         id => 0x0220, result => "HWND", wparam => "void", lparam => "const LPMDICREATESTRUCT" },
302     WM_MDIDESTROY => {
303         id => 0x0221, result => "void", wparam => "HWND", lparam => "void" },
304     WM_MDIGETACTIVE => {
305         id => 0x0229, result => "HWND", wparam => "void", lparam => "void" },
306     WM_MDIICONARRANGE => {
307         id => 0x0228, result => "void", wparam => "void", lparam => "void" },
308     WM_MDIMAXIMIZE => {
309         id => 0x0225, result => "void", wparam => "HWND", lparam => "void" },
310     WM_MDINEXT => {
311         id => 0x0224, result => "HWND", wparam => "HWND", lparam => "BOOL" },
312     WM_MDIREFRESHMENU => {
313         id => 0x0234, result => "", wparam => "", lparam => "" },
314     WM_MDIRESTORE => {
315         id => 0x0223, result => "void", wparam => "HWND", lparam => "void" },
316     WM_MDISETMENU => {
317         id => 0x0230, result => "HMENU", wparam => "BOOL", lparam => "HMENU" },
318     WM_MDITILE => {
319         id => 0x0226, result => "BOOL", wparam => "UINT", lparam => "void" },
320     WM_MEASUREITEM => {
321         id => 0x002c, result => "void", wparam => "UINT", lparam => "MEASUREITEMSTRUCT *" },
322     WM_MENUSELECT => {
323         id => 0x011f, result => "void", wparam => ["", ""], lparam => "HMENU" },
324     WM_MENUCHAR => {
325         id => 0x0120, result => "DWORD", wparam => ["", "WORD"], lparam => "HMENU" },
326     WM_MOUSEACTIVATE => {
327         id => 0x0021, result => "int", wparam => "HWND", lparam => ["", ""] },
328     WM_MOUSEMOVE => {
329         id => 0x0200, result => "void", wparam => "UINT", lparam => ["", ""] },
330     WM_MOUSEWHEEL => {
331         id => 0x020a, result => "void", wparam => ["DWORD", "int"], lparam => ["UINT", "UINT"] },
332     WM_MOVE => {
333         id => 0x0003, result => "void", wparam => "void", lparam => ["", ""] },
334     WM_MOVING => {
335         id => 0x0216, result => "", wparam => "", lparam => "" },
336
337     WM_NCACTIVATE => {
338         id => 0x0086, result => "BOOL", wparam => "BOOL", lparam => "void" },
339     WM_NCLBUTTONDBLCLK => {
340         id => 0x00a3, result => "void", wparam => "UINT", lparam => ["", ""] },
341     WM_NCLBUTTONDOWN => {
342         id => 0x00a1, result => "void", wparam => "UINT", lparam => ["", ""] },
343     WM_NCLBUTTONUP => {
344         id => 0x00a2, result => "void", wparam => "UINT", lparam => ["", ""] },
345     WM_NCMOUSEMOVE => {
346         id => 0x00a0, result => "void", wparam => "UINT", lparam => ["", ""] },
347     WM_NCMBUTTONDBLCLK => {
348         id => 0x00a9, result => "void", wparam => "UINT", lparam => ["", ""] },
349     WM_NCMBUTTONDOWN => {
350         id => 0x00a7, result => "void", wparam => "UINT", lparam => ["", ""] },
351     WM_NCMBUTTONUP => {
352         id => 0x00a8, result => "void", wparam => "UINT", lparam => ["", ""] },
353     WM_NCRBUTTONDBLCLK => {
354         id => 0x00a6, result => "void", wparam => "UINT", lparam => ["", ""] },
355     WM_NCRBUTTONDOWN => {
356         id => 0x00a4, result => "void", wparam => "UINT", lparam => ["", ""] },
357     WM_NCRBUTTONUP => {
358         id => 0x00a5, result => "void", wparam => "UINT", lparam => ["", ""] },
359     WM_NCCALCSIZE => {
360         id => 0x0083, result => "UINT", wparam => "void", lparam => "NCCALCSIZE_PARAMS *" },
361     WM_NCCREATE => {
362         id => 0x0081, result => "BOOL", wparam => "void", lparam => "LPCREATESTRUCT" },
363     WM_NCDESTROY => {
364         id => 0x0082, result => "void", wparam => "void", lparam => "void" },
365     WM_NCHITTEST => {
366         id => 0x0084, result => "UINT", wparam => "void", lparam => ["int", "int"] },
367     WM_NCPAINT => {
368         id => 0x0085, result => "void", wparam => "HRGN", lparam => "void" },
369     WM_NEXTDLGCTL => {
370         id => 0x0028, result => "HWND", wparam => "HWND", lparam => "BOOL" },
371     WM_NEXTMENU => {
372         id => 0x0213, result => "void", wparam => "UINT", lparam => "LPMDINEXTMENU" },
373     WM_NOTIFY => {
374         id => 0x004e, result => "LRESULT", wparam => "int", lparam => "NMHDR *" },
375     WM_NOTIFYFORMAT => {
376         id => 0x0055, result => "", wparam => "", lparam => "" },
377     WM_NULL => {
378         id => 0x0000, result => "", wparam => "", lparam => "" },
379
380     WM_OCC_INITNEW => {
381         id => 0x0378, result => "", wparam => "", lparam => "" },
382     WM_OCC_LOADFROMSTORAGE => {
383         id => 0x0377, result => "", wparam => "", lparam => "" },
384     WM_OCC_LOADFROMSTORAGE_EX => {
385         id => 0x037b, result => "", wparam => "", lparam => "" },
386     WM_OCC_LOADFROMSTREAM => {
387         id => 0x0376, result => "", wparam => "", lparam => "" },
388     WM_OCC_LOADFROMSTREAM_EX => {
389         id => 0x037a, result => "", wparam => "", lparam => "" },
390     WM_OTHERWINDOWCREATED => {
391         id => 0x003c, result => "", wparam => "", lparam => "" },
392     WM_OTHERWINDOWDESTROYED => {
393         id => 0x003d, result => "", wparam => "", lparam => "" },
394
395     WM_PAINT => {
396         id => 0x000f, result => "void", wparam => "void", lparam => "void" },
397     WM_PAINTCLIPBOARD => {
398         id => 0x0309, result => "void", wparam => "HWND", lparam => "const LPPAINTSTRUCT" },
399     WM_PAINTICON => {
400         id => 0x0026, result => "", wparam => "", lparam => "" },
401     WM_PALETTEISCHANGING => {
402         id => 0x0310, result => "void", wparam => "HWND", lparam => "void" },
403     WM_PALETTECHANGED => {
404         id => 0x0311, result => "void", wparam => "HWND", lparam => "void" },
405     WM_PARENTNOTIFY => {
406         id => 0x0210, result => "void", wparam => ["UINT", "int"], lparam => "HWND" },
407     WM_PASTE => {
408         id => 0x0302, result => "void", wparam => "void", lparam => "void" },
409     WM_PENWINFIRST => {
410         id => 0x0380, result => "", wparam => "", lparam => "" },
411     WM_PENWINLAST => {
412         id => 0x038f, result => "", wparam => "", lparam => "" },
413     WM_POPMESSAGESTRING => {
414         id => 0x0375, result => "", wparam => "", lparam => "" },
415     WM_POWER => {
416         id => 0x0048, result => "void", wparam => "int", lparam => "void" },
417     WM_POWERBROADCAST => {
418         id => 0x0218, result => "", wparam => "", lparam => "" },
419     WM_PRINT => {
420         id => 0x0317, result => "", wparam => "", lparam => "" },
421     WM_PRINTCLIENT => {
422         id => 0x0318, result => "void", wparam => "HDC", lparam => "DWORD" },
423
424     WM_QUERY3DCONTROLS => {
425         id => 0x036f, result => "", wparam => "", lparam => "" },
426     WM_QUERYAFXWNDPROC => {
427         id => 0x0360, result => "", wparam => "", lparam => "" },
428     WM_QUERYCENTERWND => {
429         id => 0x036b, result => "", wparam => "", lparam => "" },
430     WM_QUERYDRAGICON => {
431         id => 0x0037, result => "HICON", wparam => "void", lparam => "void" },
432     WM_QUERYDROPOBJECT => {
433         id => 0x022b, result => "", wparam => "", lparam => "" },
434     WM_QUERYENDSESSION => {
435         id => 0x0011, result => "BOOL", wparam => "void", lparam => "void" },
436     WM_QUERYNEWPALETTE => {
437         id => 0x030f, result => "BOOL", wparam => "void", lparam => "void" },
438     WM_QUERYOPEN => {
439         id => 0x0013, result => "BOOL", wparam => "void", lparam => "void" },
440     WM_QUERYPARKICON => {
441         id => 0x0036, result => "", wparam => "", lparam => "" },
442     WM_QUERYSAVESTATE => {
443         id => 0x0038, result => "", wparam => "", lparam => "" },
444     WM_QUEUESYNC => {
445         id => 0x0023, result => "void", wparam => "void", lparam => "void" },
446     WM_QUEUE_SENTINEL => {
447         id => 0x0379, result => "", wparam => "", lparam => "" },
448     WM_QUIT => {
449         id => 0x0012, result => "void", wparam => "int", lparam => "void" },
450
451     WM_RBUTTONDBLCLK => {
452         id => 0x0206, result => "void", wparam => "UINT", lparam => ["", ""] },
453     WM_RBUTTONDOWN => {
454         id => 0x0204, result => "void", wparam => "UINT", lparam => ["", ""] },
455     WM_RBUTTONUP => {
456         id => 0x0205, result => "void", wparam => "UINT", lparam => ["", ""] },
457     WM_RECALCPARENT => {
458         id => 0x0368, result => "", wparam => "", lparam => "" },
459     WM_RENDERALLFORMATS => {
460         id => 0x0306, result => "void", wparam => "void", lparam => "void" },
461     WM_RENDERFORMAT => {
462         id => 0x0305, result => "HANDLE", wparam => "UINT", lparam => "void" },
463
464     WM_SETCURSOR => {
465         id => 0x0020, result => "BOOL", wparam => "HWND", lparam => ["UINT", "UINT"] },
466     WM_SETFOCUS => {
467         id => 0x0007, result => "void", wparam => "HWND", lparam => "void" },
468     WM_SETFONT => {
469         id => 0x0030, result => "void", wparam => "HFONT", lparam => "BOOL" },
470     WM_SETHOTKEY => {
471         id => 0x0032, result => "", wparam => "", lparam => "" },
472     WM_SETICON => {
473         id => 0x0080, result => "HICON", wparam => "DWORD", lparam => "HICON" },
474     WM_SETMESSAGESTRING => {
475         id => 0x0362, result => "", wparam => "", lparam => "" },
476     WM_SETREDRAW => {
477         id => 0x000b, result => "void", wparam => "BOOL", lparam => "void" },
478     WM_SETTEXT => {
479         id => 0x000c, result => "void", wparam => "void", lparam => "LPCTSTR" },
480     WM_SETVISIBLE => {
481         id => 0x0009, result => "", wparam => "", lparam => "" },
482     WM_SHOWWINDOW => {
483         id => 0x0018, result => "void", wparam => "BOOL", lparam => "UINT" },
484     WM_SIZE => {
485         id => 0x0005, result => "void", wparam => "UINT", lparam => ["", ""] },
486     WM_SIZECHILD => {
487         id => 0x0369, result => "", wparam => "", lparam => "" },
488     WM_SIZECLIPBOARD => {
489         id => 0x030b, result => "void", wparam => "HWND", lparam => "const LPRECT" },
490     WM_SIZEPARENT => {
491         id => 0x0361, result => "", wparam => "", lparam => "" },
492     WM_SIZEWAIT => {
493         id => 0x0004, result => "", wparam => "", lparam => "" },
494     WM_SIZING => {
495         id => 0x0214, result => "", wparam => "", lparam => "" },
496     WM_SOCKET_DEAD => {
497         id => 0x0374, result => "", wparam => "", lparam => "" },
498     WM_SOCKET_NOTIFY => {
499         id => 0x0373, result => "", wparam => "", lparam => "" },
500     WM_SPOOLERSTATUS => {
501         id => 0x002a, result => "void", wparam => "UINT", lparam => ["", ""] },
502     WM_STYLECHANGED => {
503         id => 0x007d, result => "void", wparam => "DWORD", lparam => "LPSTYLESTRUCT" },
504     WM_STYLECHANGING => {
505         id => 0x007c, result => "void", wparam => "DWORD", lparam => "LPSTYLESTRUCT" },
506     WM_SYNCPAINT => {
507         id => 0x0088, result => "", wparam => "", lparam => "" },
508     WM_SYNCTASK => {
509         id => 0x0089, result => "", wparam => "", lparam => "" },
510     WM_SYSCHAR => {
511         id => 0x0106, result => "void", wparam => "TCHAR", lparam => ["", ""] },
512     WM_SYSCOLORCHANGE => {
513         id => 0x0015, result => "void", wparam => "void", lparam => "void" },
514     WM_SYSCOMMAND => {
515         id => 0x0112, result => "void", wparam => "UINT", lparam => "int" },
516     WM_SYSDEADCHAR => {
517         id => 0x0107, result => "void", wparam => "TCHAR", lparam => ["", ""] },
518     WM_SYSKEYDOWN => {
519         id => 0x0104, result => "void", wparam => "UINT", lparam => ["", ""] },
520     WM_SYSKEYUP => {
521         id => 0x0105, result => "void", wparam => "UINT", lparam => ["", ""] },
522     WM_SYSTEMERROR => {
523         id => 0x0017, result => "", wparam => "", lparam => "" },
524     WM_SYSTIMER => {
525         id => 0x0118, result => "", wparam => "", lparam => "" },
526
527     WM_TCARD => {
528         id => 0x0052, result => "", wparam => "", lparam => "" },
529     WM_TESTING => {
530         id => 0x003a, result => "", wparam => "", lparam => "" },
531     WM_TIMECHANGE => {
532         id => 0x001e, result => "void", wparam => "void", lparam => "void" },
533     WM_TIMER => {
534         id => 0x0113, result => "void", wparam => "UINT", lparam => "void" },
535
536     WM_UNDO => {
537         id => 0x0304, result => "void", wparam => "void", lparam => "void" },
538     WM_USER => {
539         id => 0x0400, result => "", wparam => "", lparam => "" },
540     WM_USERCHANGED => {
541         id => 0x0054, result => "", wparam => "", lparam => "" },
542
543     WM_VKEYTOITEM => {
544         id => 0x002e, result => "int", wparam => ["UINT", "int"], lparam => "HWND" },
545     WM_VSCROLL => {
546         id => 0x0115, result => "void", wparam => ["int", "int"], lparam => "HWND" },
547     WM_VSCROLLCLIPBOARD => {
548         id => 0x030a, result => "void", wparam => "HWND", lparam => ["", ""] },
549
550     WM_WINDOWPOSCHANGING => {
551         id => 0x0046, result => "BOOL", wparam => "void", lparam => "LPWINDOWPOS" },
552     WM_WINDOWPOSCHANGED => {
553         id => 0x0047, result => "void", wparam => "void", lparam => "const LPWINDOWPOS" },
554     WM_WININICHANGE => {
555         id => 0x001a, result => "void", wparam => "void", lparam => "LPCTSTR" }
556 };
557
558 ########################################################################
559 # _get_kind
560
561 sub _get_kind($) {
562     local $_ = shift;
563
564     if(!$_) {
565         return undef;
566     } elsif(/^(?:HBRUSH|HDC|HFONT|HMENU|HRGN|HWND)$/ || /\*$/ ||
567             /^LP(?!ARAM)/)
568     {
569         return "ptr";
570     } else {
571         return "long";
572     }
573 }
574
575 ########################################################################
576 # get_message_result_type
577
578 sub get_message_result_type($) {
579     my $name = shift;
580     return $$message{$name}{result};
581 }
582
583 ########################################################################
584 # get_message_result_kind
585
586 sub get_message_result_kind(@) {
587     return _get_kind(get_message_result_type(@_));
588 }
589
590 ########################################################################
591 # get_message_wparam_type
592
593 sub get_message_wparam_type($) {
594     my $name = shift;
595     return $$message{$name}{wparam};
596 }
597
598 ########################################################################
599 # get_message_wparam_kind
600
601 sub get_message_wparam_kind(@) {
602     return _get_kind(get_message_wparam_type(@_));
603 }
604
605 ########################################################################
606 # get_message_lparam_type
607
608 sub get_message_lparam_type($) {
609     my $name = shift;
610     return $$message{$name}{lparam};
611 }
612
613 ########################################################################
614 # get_message_lparam_kind
615
616 sub get_message_lparam_kind(@) {
617     return _get_kind(get_message_lparam_type(@_));
618 }
619
620 ########################################################################
621 # _parse_file
622
623 sub _parse_file($$$) {
624     my $file = shift;
625     my $found_preprocessor = shift;
626     my $found_comment = shift;
627
628     {
629         open(IN, "< $file") || die "Error: Can't open $file: $!\n";
630         local $/ = undef;
631         $_ = <IN>;
632         close(IN);
633     }
634
635     my @lines = split(/\n/, $_);
636     my $max_line = scalar(@lines);
637
638     my $parser = new c_parser($file);
639
640     $parser->set_found_preprocessor_callback($found_preprocessor);
641     $parser->set_found_comment_callback($found_comment);
642
643     my $found_line = sub {
644         my $line = shift;
645         local $_ = shift;
646
647         $output->progress("$file: line $line of $max_line");
648     };
649
650     $parser->set_found_line_callback($found_line);
651
652     my $line = 1;
653     my $column = 0;
654
655     my $old_prefix = $output->prefix;
656     $output->progress("$file");
657     $output->prefix("$file: ");
658
659     if(!$parser->parse_c_file(\$_, \$line, \$column)) {
660         $output->write("can't parse file\n");
661     }
662
663     $output->prefix($old_prefix);
664 }
665
666 ########################################################################
667 # _get_tuple_arguments
668
669 sub _get_tuple_arguments($) {
670     local $_ = shift;
671
672     my $parser = new c_parser;
673
674     my $line = 1;
675     my $column = 0;
676
677     my @arguments;
678     my @argument_lines;
679     my @argument_columns;
680     if(!$parser->parse_c_tuple(\$_, \$line, \$column, \@arguments, \@argument_lines, \@argument_columns)) {
681         return undef;
682     }
683
684     return @arguments;
685 }
686
687 ########################################################################
688 # _parse_windowsx_h
689
690
691 sub _parse_windowsx_h($$$) {
692     my $last_comment;
693
694     my $found_preprocessor = sub {
695         my $begin_line = shift;
696         my $begin_column = shift;
697         local $_ = shift;
698
699         if(!s/^\#\s*define\s*// || !/^FORWARD_WM_/) {
700             return 1;
701         }
702
703         my $name;
704         if(s/^FORWARD_(\w+)\([^\)]*\)\s*(.*?)\s*$/$2/s) {
705             $name = $1;
706         }
707
708         if($name eq "WM_SYSTEMERROR") {
709             return 1;
710         }
711
712         my $result;
713         if(s/^\(\s*(\w+)\s*\)(?:\(\s*\w+\s*\))*\(\s*\w+\s*\)//) {
714             $result = $1;
715         } else {
716             die "$name: '$_'";
717         }
718
719         (undef, $_, my $wparam, my $lparam) = _get_tuple_arguments($_);
720
721         my @names = ();
722         if(/^$name$/) {
723             @names = $name;
724         } elsif(/^\(\w+\)\s*\?\s*(\w+)\s*:\s*(\w+)$/) {
725             @names = ($1, $2);
726         } else {
727             die "$name: '$_'";
728         }
729
730         local $_ = $last_comment;
731         s%^/\*\s*(.*?)\s*\*/$%$1%;
732
733         my %arguments;
734         if(s/^(\w+)\s+\w+\s*\(\s*(.*?)\s*\)$/$2/) {
735             my $result2 = $1;
736             if($result2 eq "INT") { $result2 = "int"; }
737             if($result ne $result2) {
738                 $output->write("message $name: result type mismatch '$result' != '$result2'\n");
739             }
740             foreach (split(/\s*,\s*/)) {
741                 if(/^((?:const\s+|volatile\s+)?\w+(?:\s*\*\s*|\s+)?)(\w+)$/) {
742                     my $type = $1;
743                     my $name = $2;
744
745                     $type =~ s/^\s*(.*?)\s*$/$1/;
746
747                     $arguments{$name} = $type;
748                 } else {
749                     die "$name: '$_'";
750                 }
751             }
752             # $output->write("$1: $_\n");
753         } else {
754             die "$name: '$_'";
755         }
756
757         my $find_inner_cast = sub {
758             local $_ = shift;
759             if(/^(?:\(\s*((?:const\s+|volatile\s+)?\w+(?:\s*\*)?)\s*\))*\(.*?\)$/) {
760                 if(defined($1)) {
761                     return $1;
762                 } else {
763                     return "";
764                 }
765             }
766
767         };
768
769         my @entries = (
770             [ \$wparam, "W", "w" ],
771             [ \$lparam, "L", "l" ]
772         );
773         foreach my $entry (@entries) {
774             (my $refparam, my $upper, my $lower) = @$entry;
775
776             local $_ = $$refparam;
777             if(s/^\(\s*$upper(?:)PARAM\s*\)\s*(?:\(\s*((?:const\s+|volatile\s+)?\w+(?:\s*\*)?)\s*\))*\(\s*(.*?)\s*\)$/$2/) {
778                 if(defined($1)) {
779                     $$refparam = $1;
780                 } else {
781                     $$refparam = "";
782                 }
783
784                 if(/^\w+$/) {
785                     if(exists($arguments{$_})) {
786                         $$refparam = $arguments{$_};
787                     }
788                 } elsif(/^\(\s*(\w+)\s*\)\s*\?\s*\(\s*(\w+)\s*\)\s*:\s*(?:\(\s*(\w+)\s*\)|0)$/) {
789                     foreach ($1, $2, $3) {
790                         if(exists($arguments{$_})) {
791                             $$refparam = $arguments{$_};
792                             last;
793                         }
794                     }
795                 } elsif(/^\(\((?:const\s+|volatile\s+)?\w+\s*(?:\*\s*)?\)\s*(?:\(\s*\w+\s*\)|\w+)\s*\)\s*\->\s*\w+$/) {
796                     $$refparam = "UINT";
797                 } else {
798                     die "$name: '$_'";
799                 }
800             } elsif(s/^(?:\(\s*$upper(?:)PARAM\s*\)\s*)?MAKE$upper(?:)PARAM\s*//) {
801                 (my $low, my $high) = _get_tuple_arguments($_);
802
803                 $low = &$find_inner_cast($low);
804                 $high = &$find_inner_cast($high);
805
806                 $$refparam = "($low,$high)";
807             } elsif(s/^\(.*?$lower(?:)Param.*?\)$//) {
808                 $$refparam = $upper . "PARAM";
809             } elsif(s/^\(\s*(.*?)\s*\)$//) {
810                 $$refparam = "$1";
811             } elsif(s/^0L$//) {
812                 $$refparam = "void";
813             } else {
814                 die "$name: '$_'";
815             }
816         }
817
818         # $output->write("$result: '@names', '$wparam', '$lparam'\n");
819
820         foreach my $name (@names) {
821             my $result2 = $$message{$name}{result};
822             my $wparam2 = $$message{$name}{wparam};
823             my $lparam2 = $$message{$name}{lparam};
824
825             if(ref($wparam2)) {
826                 $wparam2 = "(" . join(",", @$wparam2) . ")";
827             }
828
829             if(ref($lparam2)) {
830                 $lparam2 = "(" . join(",", @$lparam2) . ")";
831             }
832
833             if($result ne $result2) {
834                 $output->write("message $name: wrong result type '$result2' should be '$result'\n");
835             }
836
837             if($wparam ne $wparam2) {
838                 # if($wparam ne "WPARAM" && $wparam ne "(,)") {
839                     $output->write("message $name: wrong wparam type '$wparam2' should be '$wparam'\n");
840                 # }
841             }
842
843             if($lparam ne $lparam2) {
844                 # if($lparam ne "LPARAM" && $lparam ne "(,)") {
845                     $output->write("message $name: wrong lparam type '$lparam2' should be '$lparam'\n");
846                 # }
847             }
848         }
849
850         return 1;
851     };
852
853     my $found_comment = sub {
854         my $begin_line = shift;
855         my $begin_column = shift;
856         my $comment = shift;
857
858         $last_comment = $comment;
859
860         return 1;
861     };
862
863     _parse_file("$wine_dir/include/windowsx.h", $found_preprocessor, $found_comment);
864 }
865
866
867 ########################################################################
868 # _parse_winuser_h
869
870 sub _parse_winuser_h($$$) {
871     my %not_found = ();
872
873     my $found_preprocessor = sub {
874         my $begin_line = shift;
875         my $begin_column = shift;
876         local $_ = shift;
877
878         if(/^\#\s*define\s+(WM_\w+)\s+(0x[0-9a-fA-F]+)\s*$/) {
879             my $name = $1;
880             my $id = lc($2);
881
882             if(exists($$message{$name})) {
883                 my $id2 = sprintf("0x%04x", $$message{$name}{id});
884                 if($id ne $id2) {
885                     $output->write("message $name: wrong value ($id2) should be $id\n");
886                 }
887             } else {
888                 $output->write("message $name: exists but is not supported\n");
889                 $not_found{$name} = $id;
890             }
891         }
892
893         return 1;
894     };
895
896     _parse_file("$wine_dir/include/winuser.h", $found_preprocessor);
897
898     foreach my $name (sort(keys(%not_found))) {
899         my $id = $not_found{$name};
900
901         print "    $name => {\n";
902         print "\tid => $id, result => \"\", wparam => \"\", lparam => \"\" },\n";
903     }
904 }
905
906 # _parse_windowsx_h;
907 # _parse_winuser_h;
908
909 1;