From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> Tested-by: Jim Fehlig <jfehlig@xxxxxxxxxx> Matthias provided this patch to fix an issue I encountered in the generator with APIs containing call-by-ref long type, e.g. int virDomainMigrateGetMaxSpeed(virDomainPtr domain, unsigned long *bandwidth, unsigned int flags); --- src/rpc/gendispatch.pl | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 0d344e8..f671ff0 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -640,10 +640,11 @@ elsif ($opt_b) { } elsif ($ret_member =~ m/^(?:unsigned )?hyper (\S+)<\S+>;/) { # error out on unannotated arrays die "hyper array without insert@<offset> annotation: $ret_member"; - } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);/) { + } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);(?:\s*\/\*\s*insert@(\d+)\s*\*\/)?/) { my $type_name = $1; my $ret_name = $2; my $ret_assign; + my $insert = $3; if (hyper_to_long($call->{ProcName}, "ret", $ret_name)) { my $sign = ""; $sign = "U" if ($1); @@ -657,7 +658,13 @@ elsif ($opt_b) { push(@vars_list, "$type_name $ret_name"); push(@ret_list, $ret_assign); - $single_ret_var = $ret_name; + + if ($insert) { + splice(@args_list, int($insert), 0, "&$ret_name"); + $single_ret_var = undef; + } else { + $single_ret_var = $ret_name; + } if ($call->{ProcName} eq "DomainGetMaxMemory" or $call->{ProcName} eq "NodeGetFreeMemory") { @@ -1285,6 +1292,24 @@ elsif ($opt_k) { $single_ret_var = "int rv = -1"; $single_ret_type = "int"; + } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);\s*\/\*\s*insert@(\d+)\s*\*\//) { + my $type_name = $1; + my $sign = ""; $sign = "U" if ($1); + my $ret_name = $2; + my $insert = $3; + + if (hyper_to_long($call->{ProcName}, "ret", $ret_name)) { + $type_name .= "long"; + push(@ret_list, "if ($ret_name) HYPER_TO_${sign}LONG(*$ret_name, ret.$ret_name);"); + } else { + $type_name .= "long long"; + push(@ret_list, "if ($ret_name) *$ret_name = ret.$ret_name;"); + } + + splice(@args_list, int($insert), 0, ("$type_name *$ret_name")); + push(@ret_list, "rv = 0;"); + $single_ret_var = "int rv = -1"; + $single_ret_type = "int"; } elsif ($ret_member =~ m/^unsigned hyper (\S+);/) { my $ret_name = $1; -- 1.7.5.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list