Strictify tools/make_requests
Francois Gouget
fgouget at free.fr
Wed Sep 29 18:54:00 CDT 2004
I'm not very familiar with this tool so all I can say is that it does
not have compilation errors at startup and seems to behave rationally.
Changelog:
* tools/make_requests
Add 'use strict'.
Add prototypes to all functions.
Move 'main' to the end so we don't have to pre-declare all the
functions.
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
Dieu dit: "M-x Lumi\xE8re". Et la lumi\xE8re fut.
-------------- next part --------------
Index: tools/make_requests
===================================================================
RCS file: /var/cvs/wine/tools/make_requests,v
retrieving revision 1.37
diff -u -r1.37 make_requests
--- tools/make_requests 1 Oct 2003 03:32:16 -0000 1.37
+++ tools/make_requests 23 Sep 2004 12:52:42 -0000
@@ -19,8 +19,9 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+use strict;
-%formats =
+my %formats =
(
"int" => "%d",
"short int" => "%d",
@@ -46,89 +47,11 @@
my @trace_lines = ();
-# Get the server protocol version
-my $protocol = &GET_PROTOCOL_VERSION;
-
-### Create server_protocol.h and print header
-
-open SERVER_PROT, ">include/wine/server_protocol.h" or die "Cannot create include/wine/server_protocol.h";
-print SERVER_PROT "/*\n * Wine server protocol definitions\n *\n";
-print SERVER_PROT " * This file is automatically generated; DO NO EDIT!\n";
-print SERVER_PROT " * Edit server/protocol.def instead and re-run tools/make_requests\n";
-print SERVER_PROT " */\n\n";
-print SERVER_PROT "#ifndef __WINE_WINE_SERVER_PROTOCOL_H\n";
-print SERVER_PROT "#define __WINE_WINE_SERVER_PROTOCOL_H\n";
-
-### Parse requests to find request/reply structure definitions
-
-&PARSE_REQUESTS;
-
-### Build the request list and structures
-
-print SERVER_PROT "\n\nenum request\n{\n";
-foreach $req (@requests) { print SERVER_PROT " REQ_$req,\n"; }
-print SERVER_PROT " REQ_NB_REQUESTS\n};\n\n";
-print SERVER_PROT "union generic_request\n{\n";
-print SERVER_PROT " struct request_max_size max_size;\n";
-print SERVER_PROT " struct request_header request_header;\n";
-foreach $req (@requests) { print SERVER_PROT " struct ${req}_request ${req}_request;\n"; }
-print SERVER_PROT "};\n";
-
-print SERVER_PROT "union generic_reply\n{\n";
-print SERVER_PROT " struct request_max_size max_size;\n";
-print SERVER_PROT " struct reply_header reply_header;\n";
-foreach $req (@requests) { print SERVER_PROT " struct ${req}_reply ${req}_reply;\n"; }
-print SERVER_PROT "};\n\n";
-
-printf SERVER_PROT "#define SERVER_PROTOCOL_VERSION %d\n\n", $protocol + 1;
-print SERVER_PROT "#endif /* __WINE_WINE_SERVER_PROTOCOL_H */\n";
-close SERVER_PROT;
-
-### Output the dumping function tables
-
-push @trace_lines, "static const dump_func req_dumpers[REQ_NB_REQUESTS] = {\n";
-foreach $req (@requests)
-{
- push @trace_lines, " (dump_func)dump_${req}_request,\n";
-}
-push @trace_lines, "};\n\n";
-
-push @trace_lines, "static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {\n";
-foreach $req (@requests)
-{
- push @trace_lines, " (dump_func)", $replies{$req} ? "dump_${req}_reply,\n" : "0,\n";
-}
-push @trace_lines, "};\n\n";
-
-push @trace_lines, "static const char * const req_names[REQ_NB_REQUESTS] = {\n";
-foreach $req (@requests)
-{
- push @trace_lines, " \"$req\",\n";
-}
-push @trace_lines, "};\n";
-
-REPLACE_IN_FILE( "server/trace.c", @trace_lines );
-
-### Output the request handlers list
-
-my @request_lines = ();
-
-foreach $req (@requests) { push @request_lines, "DECL_HANDLER($req);\n"; }
-push @request_lines, "\n#ifdef WANT_REQUEST_HANDLERS\n\n";
-push @request_lines, "typedef void (*req_handler)( const void *req, void *reply );\n";
-push @request_lines, "static const req_handler req_handlers[REQ_NB_REQUESTS] =\n{\n";
-foreach $req (@requests)
-{
- push @request_lines, " (req_handler)req_$req,\n";
-}
-push @request_lines, "};\n#endif /* WANT_REQUEST_HANDLERS */\n";
-
-REPLACE_IN_FILE( "server/request.h", @request_lines );
### Parse the request definitions
-sub PARSE_REQUESTS
+sub PARSE_REQUESTS()
{
# states: 0 = header 1 = declarations 2 = inside @REQ 3 = inside @REPLY
my $state = 0;
@@ -246,7 +169,7 @@
### Generate a dumping function
-sub DO_DUMP_FUNC
+sub DO_DUMP_FUNC($$@)
{
my $name = shift;
my $req = shift;
@@ -288,7 +211,7 @@
### Retrieve the server protocol version from the existing server_protocol.h file
-sub GET_PROTOCOL_VERSION
+sub GET_PROTOCOL_VERSION()
{
my $protocol = 0;
open SERVER_PROT, "include/wine/server_protocol.h" or return 0;
@@ -302,7 +225,7 @@
### Replace the contents of a file between ### make_requests ### marks
-sub REPLACE_IN_FILE
+sub REPLACE_IN_FILE($@)
{
my $name = shift;
my @data = @_;
@@ -323,3 +246,69 @@
print FILE @lines;
close(FILE);
}
+
+### Main
+
+# Get the server protocol version
+my $protocol = GET_PROTOCOL_VERSION();
+
+### Create server_protocol.h and print header
+
+open SERVER_PROT, ">include/wine/server_protocol.h" or die "Cannot create include/wine/server_protocol.h";
+print SERVER_PROT "/*\n * Wine server protocol definitions\n *\n";
+print SERVER_PROT " * This file is automatically generated; DO NO EDIT!\n";
+print SERVER_PROT " * Edit server/protocol.def instead and re-run tools/make_requests\n";
+print SERVER_PROT " */\n\n";
+print SERVER_PROT "#ifndef __WINE_WINE_SERVER_PROTOCOL_H\n";
+print SERVER_PROT "#define __WINE_WINE_SERVER_PROTOCOL_H\n";
+
+### Parse requests to find request/reply structure definitions
+
+PARSE_REQUESTS();
+
+### Build the request list and structures
+
+print SERVER_PROT "\n\nenum request\n{\n";
+foreach my $req (@requests) { print SERVER_PROT " REQ_$req,\n"; }
+print SERVER_PROT " REQ_NB_REQUESTS\n};\n\n";
+
+print SERVER_PROT "union generic_request\n{\n";
+print SERVER_PROT " struct request_max_size max_size;\n";
+print SERVER_PROT " struct request_header request_header;\n";
+foreach my $req (@requests) { print SERVER_PROT " struct ${req}_request ${req}_request;\n"; }
+print SERVER_PROT "};\n";
+
+print SERVER_PROT "union generic_reply\n{\n";
+print SERVER_PROT " struct request_max_size max_size;\n";
+print SERVER_PROT " struct reply_header reply_header;\n";
+foreach my $req (@requests) { print SERVER_PROT " struct ${req}_reply ${req}_reply;\n"; }
+print SERVER_PROT "};\n\n";
+
+printf SERVER_PROT "#define SERVER_PROTOCOL_VERSION %d\n\n", $protocol + 1;
+print SERVER_PROT "#endif /* __WINE_WINE_SERVER_PROTOCOL_H */\n";
+close SERVER_PROT;
+
+### Output the dumping function tables
+
+push @trace_lines, "static const dump_func req_dumpers[REQ_NB_REQUESTS] = {\n";
+foreach my $req (@requests)
+{
+ push @trace_lines, " (dump_func)dump_${req}_request,\n";
+}
+push @trace_lines, "};\n\n";
+
+push @trace_lines, "static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {\n";
+foreach my $req (@requests)
+{
+ push @trace_lines, " (dump_func)", $replies{$req} ? "dump_${req}_reply,\n" : "0,\n";
+}
+push @trace_lines, "};\n\n";
+
+push @trace_lines, "static const char * const req_names[REQ_NB_REQUESTS] = {\n";
+foreach my $req (@requests)
+{
+ push @trace_lines, " \"$req\",\n";
+}
+push @trace_lines, "};\n";
+
+REPLACE_IN_FILE( "server/trace.c", @trace_lines );
More information about the wine-patches
mailing list