3 # Extract #define symbol information from C header files.
5 # Copyright 2002 Alexandre Julliard
8 # list of symbols (regexps) to skip for each header
11 "winnt.h" => [ "APIENTRY", "APIPRIVATE", "CALLBACK", "CONST", "EXTERN_C", "PASCAL",
12 "VOID", "DUMMY(STRUCT|UNION)NAME.*", "STDAPI.*", "STDMETHOD.*", "WINAPI.*",
13 "WINE_.*", "_*(cdecl|CDECL|pascal|export|fastcall|stdcall)",
14 "MEM_SYSTEM", "_GET_CONTEXT", "_QUAD_.*",
15 "CONTEXT_(ALPHA|R4000|SPARC|X86|i386|i486)" ],
16 "winbase.h" => [ "(Fill|Move|Zero|Copy)Memory" ],
17 "wingdi.h" => [ "PROFILE_LINKED", "PROFILE_EMBEDDED", "GetCharWidth[AW]" ],
18 "winuser.h" => [ "OemToAnsi[AW]", "OemToAnsiBuff[AW]", "AnsiToOem[AW]", "AnsiToOemBuff[AW]",
19 "Ansi(Next|Prev|Lower|Upper|LowerBuff|UpperBuff)[AW]", "GetNextWindow" ],
20 "winsock2.h" => [ "WSAEVENT", "LPWSAEVENT", "WSAOVERLAPPED", "WS_.*" ]
39 $include_dir = "../../include";
41 @list = ($#ARGV >= 0) ? @ARGV : @header_list;
43 foreach $basename (@list)
45 my $skip = $skip_list{$basename};
46 my $result = "include/" . $basename;
47 $result =~ s!\.h$!.pm!;
49 open INPUT, "$include_dir/$basename" or die "Cannot open $include_dir/$basename";
50 open OUTPUT, ">sym.c" or die "Cannot create sym.c";
51 print "Building $result\n";
58 foreach $inc (@header_list) { print OUTPUT "#include <$inc>\n"; }
63 printf( "# Automatically generated by make_symbols; DO NOT EDIT!! \\n" );
65 printf( "# Perl definitions for header file $basename\\n" );
72 # extract all #defines
73 next unless (/^\s*\#\s*define\s+([A-Za-z0-9_]+)\s+(.*)$/);
74 my ($name,$value) = ($1,$2);
76 next if ($value eq "");
77 # skip the WINELIB defines
78 next if ($value =~ /WINELIB_NAME_AW/);
79 # skip macros containing multiple values
80 next if ($value =~ /{.*}/);
81 # check against regexps to skip
82 next if (grep { $name =~ /^$_$/ } @$skip);
83 $symbols{$name} = $value;
85 foreach $sym (sort keys %symbols)
87 printf OUTPUT " printf(\"\$$sym = %%d;\\n\", (int)($sym));\n";
89 print OUTPUT " exit(0);\n}\n";
91 #print "cc -I../../include -o sym sym.c\n";
92 if (system( "cc -I../../include -o sym sym.c" )) { die "Could not compile sym.c"; }
93 #print "./sym >$result\n";
94 if (system( "./sym >$result" )) { die "Could not run ./sym\n"; }