winapi: Fix the parse_c_declaration() prototype and remove unused variables.

Francois Gouget fgouget at free.fr
Mon Apr 20 08:08:03 CDT 2009


---

The winapi code usually use the following pattern for grabing the 
function parameters:

---
sub foo($$$$$)
{
    my $var1 = shift;
    my $var2 = shift;

    # many
    # many
    # lines

    my $var3 = shift;
---

There are some problems with this:
 * It makes it hard to check that the number of parameters we grab from 
   @_ matches the number of parameters declared in the prototype. 
   Especially when the variable assignments are scattered through the 
   code.
 * Code reorganisations may unwittingly change the parameter order.
 * It modifies the @_ array, which is a bit slower than a direct 
   assignment to the local variables, i.e.:
   my ($var1, $var2, $var3) = @_;


 tools/winapi/c_parser.pm |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/tools/winapi/c_parser.pm b/tools/winapi/c_parser.pm
index da70c83..cc6b213 100644
--- a/tools/winapi/c_parser.pm
+++ b/tools/winapi/c_parser.pm
@@ -563,16 +563,13 @@ sub parse_c_block($$$$$$$) {
 ########################################################################
 # parse_c_declaration
 
-sub parse_c_declaration($$$$$$$$$$$$) {
-    my $self = shift;
+sub parse_c_declaration($$$$)
+{
+    my ($self, $refcurrent, $refline, $refcolumn) = @_;
 
     my $found_declaration = \${$self->{FOUND_DECLARATION}};
     my $found_function = \${$self->{FOUND_FUNCTION}};
 
-    my $refcurrent = shift;
-    my $refline = shift;
-    my $refcolumn = shift;
-
     local $_ = $$refcurrent;
     my $line = $$refline;
     my $column = $$refcolumn;
@@ -591,18 +588,10 @@ sub parse_c_declaration($$$$$$$$$$$$) {
     }
 
     # Function
-    my $function = shift;
-
-    my $linkage = shift;
-    my $calling_convention = shift;
-    my $return_type = shift;
-    my $name = shift;
-    my @arguments = shift;
-    my @argument_lines = shift;
-    my @argument_columns = shift;
+    my $function;
 
     # Variable
-    my $type;
+    my ($linkage, $type, $name);
 
     if(s/^WINE_(?:DEFAULT|DECLARE)_DEBUG_CHANNEL\s*\(\s*(\w+)\s*\)\s*//s) { # FIXME: Wine specific kludge
 	$self->_update_c_position($&, \$line, \$column);
-- 
1.6.2.1




More information about the wine-patches mailing list