All MCI functions are now cleanly separated.
[wine/multimedia.git] / programs / winetest / make_symbols
blob29217aaff2fc5edd87e7baf139f87724da193241
1 #!/usr/bin/perl -w
3 # Extract #define symbol information from C header files.
5 # Copyright 2002 Alexandre Julliard
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # list of symbols (regexps) to skip for each header
23 %skip_list =
25 "winnt.h" => [ "APIENTRY", "APIPRIVATE", "CALLBACK", "CONST", "EXTERN_C", "PASCAL",
26 "VOID", "DUMMY(STRUCT|UNION)NAME.*", "STDAPI.*", "STDMETHOD.*", "WINAPI.*",
27 "WINE_.*", "_*(cdecl|CDECL|pascal|export|fastcall|stdcall)",
28 "MEM_SYSTEM", "_GET_CONTEXT", "_QUAD_.*",
29 "CONTEXT_(ALPHA|R4000|SPARC|X86|i386|i486)" ],
30 "winbase.h" => [ "(Fill|Move|Zero|Copy)Memory" ],
31 "wingdi.h" => [ "PROFILE_LINKED", "PROFILE_EMBEDDED", "GetCharWidth[AW]" ],
32 "winuser.h" => [ "OemToAnsi[AW]", "OemToAnsiBuff[AW]", "AnsiToOem[AW]", "AnsiToOemBuff[AW]",
33 "Ansi(Next|Prev|Lower|Upper|LowerBuff|UpperBuff)[AW]", "GetNextWindow" ],
34 "winsock2.h" => [ "WSAEVENT", "LPWSAEVENT", "WSAOVERLAPPED", "WS_.*" ]
37 %header_list =
39 "windef.h" => "windef.pm",
40 "winnt.h" => "winnt.pm",
41 "winbase.h" => "winbase.pm",
42 "wingdi.h" => "wingdi.pm",
43 "winuser.h" => "winuser.pm",
44 "winerror.h" => "winerror.pm",
45 "winnls.h" => "winnls.pm",
46 "winreg.h" => "winreg.pm",
47 "winsock2.h" => "winsock2.pm",
48 "winspool.h" => "winspool.pm",
49 "winver.h" => "winver.pm",
50 "wincon.h" => "wincon.pm",
51 "setupapi.h" => "setupapi_h.pm",
54 $include_dir = "../../include";
56 @list = ($#ARGV >= 0) ? @ARGV : keys %header_list;
58 foreach $basename (@list)
60 my $skip = $skip_list{$basename};
61 my $result = "include/" . $header_list{$basename};
62 my $package = $header_list{$basename};
63 $package =~ s/\.pm$//;
65 open INPUT, "$include_dir/$basename" or die "Cannot open $include_dir/$basename";
66 open OUTPUT, ">sym.c" or die "Cannot create sym.c";
67 print "Building $result\n";
69 print OUTPUT <<EOF;
70 #include <stdio.h>
71 #include <stdlib.h>
72 #include <limits.h>
73 #include "windef.h"
74 #include "winnt.h"
75 #include "winbase.h"
76 #include "wingdi.h"
77 #include "winuser.h"
78 #include "winerror.h"
79 #include "winnls.h"
80 #include "winreg.h"
81 #include "winsock2.h"
82 #include "winspool.h"
83 #include "winver.h"
84 #include "wincon.h"
85 #include "setupapi.h"
86 EOF
88 print OUTPUT <<EOF;
89 int main()
91 printf( "# Automatically generated by make_symbols; DO NOT EDIT!! \\n" );
92 printf( "#\\n" );
93 printf( "# Perl definitions for header file $basename\\n" );
94 printf( "#\\n\\n" );
95 printf( "\\n" );
96 printf( "package $package;\\n" );
97 printf( "\\n" );
98 printf( "use strict;\\n" );
99 printf( "\\n" );
100 printf( "use vars qw(\$VERSION \@ISA \@EXPORT \@EXPORT_OK);\\n" );
101 printf( "\\n" );
102 printf( "require Exporter;\\n" );
103 printf( "\\n" );
104 printf( "\@ISA = qw(Exporter);\\n" );
105 printf( "\@EXPORT = qw(\\n" );
108 my %symbols = ();
109 while (<INPUT>)
111 # extract all #defines
112 next unless (/^\s*\#\s*define\s+([A-Za-z0-9_]+)\s+(.*)$/);
113 my ($name,$value) = ($1,$2);
114 # skip empty value
115 next if ($value eq "");
116 # skip the WINELIB defines
117 next if ($value =~ /WINELIB_NAME_AW/);
118 # skip macros containing multiple values
119 next if ($value =~ /{.*}/);
120 # check against regexps to skip
121 next if (grep { $name =~ /^$_$/ } @$skip);
122 $symbols{$name} = $value;
124 foreach $sym (sort keys %symbols)
126 printf OUTPUT " printf(\" $sym\\n\");\n";
128 printf OUTPUT " printf(\");\\n\");\n";
129 printf OUTPUT " printf(\"\@EXPORT_OK = qw();\\n\");\n";
130 printf OUTPUT " printf(\"\\n\");\n";
132 foreach $sym (sort keys %symbols)
134 printf OUTPUT " printf(\"use constant $sym => %%d;\\n\", (int)($sym));\n";
136 printf OUTPUT " printf(\"\\n\");\n";
137 printf OUTPUT " printf(\"1;\\n\");\n";
138 print OUTPUT " exit(0);\n}\n";
139 close OUTPUT;
140 #print "cc -I../../include -o sym sym.c\n";
141 if (system( "cc -I../../include -o sym sym.c" )) { die "Could not compile sym.c"; }
142 #print "./sym >$result\n";
143 if (system( "./sym >$result" )) { die "Could not run ./sym\n"; }
144 unlink "sym","sym.c";
147 chdir "../..";
148 exec "tools/winapi/winapi_extract", "--no-progress", "--no-verbose";