Re: [PATCH 15/21] gendispatch: Be able to generate multi-return values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 10, 2016 at 05:54:04AM +0100, Martin Kletzander wrote:
> Let's call it modern_ret_as_list as opposed to single_ret_as_list.  The
> latter was able to return list of things.  However the new, more modern,
> version came and it is used since listAllDomains till nowadays in
> ListServers.
> 
> Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
> ---
>  src/rpc/gendispatch.pl | 200 ++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 172 insertions(+), 28 deletions(-)
> 

> @@ -1277,6 +1348,9 @@ elsif ($mode eq "client") {
>          my $single_ret_list_max_define = "undefined";
>          my $single_ret_cleanup = 0;
>          my $multi_ret = 0;
> +        my $modern_ret_as_list = 0;

> +        my $modern_ret_struct_name = 0;

The other strings use "undefined" as the initializer.

> +        my $modern_ret_var_type = "undefined";
> 
>          if ($rettype ne "void" and
>              scalar(@{$call->{ret_members}}) > 1) {
> @@ -1296,6 +1370,20 @@ elsif ($mode eq "client") {
>                          }
> 
>                          push(@ret_list, "memcpy(result->$3, ret.$3, sizeof(result->$3));");
> +                    } elsif ($ret_member =~ m/admin_nonnull_(server) (\S+)<(\S+)>;/) {
> +                        my $proc_name = name_to_TypeName($1);
> +
> +                        if ($structprefix eq "admin") {
> +                            $modern_ret_var_type = "virAdm${proc_name}Ptr";
> +                        } else {
> +                            $modern_ret_var_type = "vir${proc_name}Ptr";
> +                        }
> +
> +                        $modern_ret_struct_name = $1;

This should also set:
  $single_ret_list_error_msg_type = $1;

Otherwise the commit after this generates a funny error in remoteAdminConnectListServers:

+    if (ret.servers.servers_len > ADMIN_SERVER_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("too many remote undefineds: %d > %d"),
+                       ret.servers.servers_len, ADMIN_SERVER_LIST_MAX);
+        goto cleanup;
+    }

> +                        $single_ret_list_name = $2;
> +                        $single_ret_list_max_var = $3;
> +
> +                        $modern_ret_as_list = 1;
>                      } elsif ($ret_member =~ m/<\S+>;/ or $ret_member =~ m/\[\S+\];/) {
>                          # just make all other array types fail
>                          die "unhandled type for multi-return-value for " .

> -            my $struct_name = $call->{ProcName};
> -            $struct_name =~ s/Get//;
> +            if ($modern_ret_as_list) {
> +                $struct_name = name_to_TypeName($modern_ret_struct_name);
> +
> +                $struct_name .= "Ptr **";
> +                if ($structprefix eq "admin") {
> +                    $struct_name = "Adm${struct_name}";
> +                }
> +            } else {
> +                $struct_name = $call->{ProcName};
> 
> -            splice(@args_list, $call->{ret_offset}, 0, ("vir${struct_name}Ptr result"));
> +                $struct_name =~ s/Get//;
> +                $struct_name = "${struct_name}Ptr "
> +            }
> +            splice(@args_list, $call->{ret_offset}, 0, ("vir$struct_name result"));

There's an extra space between ${struct_name} and result.

>          }
> 
>          if ($call->{streamflag} ne "none") {
> @@ -1482,7 +1594,8 @@ elsif ($mode eq "client") {
>              print "    $var;\n";
>          }
> 
> -        if ($single_ret_as_list) {
> +        if ($single_ret_as_list or
> +            $modern_ret_as_list) {
>              print "    size_t i;\n";
>          }
> 

ACK with the nits fixed.

Jan

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]