[libvirt] [PATCH 14/22] remote generator: Reorder into prepare and print section

Matthias Bolte matthias.bolte at googlemail.com
Sun Apr 24 09:14:01 UTC 2011


---
 daemon/remote_generator.pl |   54 ++++++++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index 1aaeaae..9fa3caa 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -293,30 +293,6 @@ elsif ($opt_b) {
             next;
         }
 
-        print "static int\n";
-        print "${structprefix}Dispatch$calls{$_}->{ProcName}(\n";
-        print "    struct qemud_server *server ATTRIBUTE_UNUSED,\n";
-        print "    struct qemud_client *client ATTRIBUTE_UNUSED,\n";
-        print "    virConnectPtr conn,\n";
-        print "    remote_message_header *hdr ATTRIBUTE_UNUSED,\n";
-        print "    remote_error *rerr,\n";
-        print "    $calls{$_}->{args} *args";
-
-        if ($calls{$_}->{args} eq "void") {
-            print " ATTRIBUTE_UNUSED"
-        }
-
-        print ",\n";
-        print "    $calls{$_}->{ret} *ret";
-
-        if ($calls{$_}->{ret} eq "void") {
-            print " ATTRIBUTE_UNUSED"
-        }
-
-        print ")\n";
-        print "{\n";
-        print "    int rv = -1;\n";
-
         my $has_node_device = 0;
         my @vars_list = ();
         my @optionals_list = ();
@@ -326,6 +302,7 @@ elsif ($opt_b) {
         my @free_list = ();
         my @free_list_on_error = ("remoteDispatchError(rerr);");
 
+        # handle arguments to the function
         if ($calls{$_}->{args} ne "void") {
             # node device is special, as it's identified by name
             if ($calls{$_}->{args} =~ m/^remote_node_device_/ and
@@ -408,6 +385,7 @@ elsif ($opt_b) {
             }
         }
 
+        # handle return values of the function
         my $single_ret_var = "undefined";
         my $single_ret_by_ref = 0;
         my $single_ret_check = " == undefined";
@@ -549,6 +527,7 @@ elsif ($opt_b) {
             }
         }
 
+        # select struct type for multi-return-value functions
         if ($multi_ret) {
             if (! @args_list) {
                 push(@args_list, "conn");
@@ -576,6 +555,33 @@ elsif ($opt_b) {
             push(@vars_list, "vir$struct_name tmp");
         }
 
+        # print functions signature
+        print "static int\n";
+        print "${structprefix}Dispatch$calls{$_}->{ProcName}(\n";
+        print "    struct qemud_server *server ATTRIBUTE_UNUSED,\n";
+        print "    struct qemud_client *client ATTRIBUTE_UNUSED,\n";
+        print "    virConnectPtr conn,\n";
+        print "    remote_message_header *hdr ATTRIBUTE_UNUSED,\n";
+        print "    remote_error *rerr,\n";
+        print "    $calls{$_}->{args} *args";
+
+        if ($calls{$_}->{args} eq "void") {
+            print " ATTRIBUTE_UNUSED"
+        }
+
+        print ",\n";
+        print "    $calls{$_}->{ret} *ret";
+
+        if ($calls{$_}->{ret} eq "void") {
+            print " ATTRIBUTE_UNUSED"
+        }
+
+        print ")\n";
+
+        # print function body
+        print "{\n";
+        print "    int rv = -1;\n";
+
         foreach my $var (@vars_list) {
             print "    $var;\n";
         }
-- 
1.7.0.4




More information about the libvir-list mailing list