mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Fix generator to cope with call-by-ref long types
From: Matthias Bolte <matthias.bolte@googlemail.com> Tested-by: Jim Fehlig <jfehlig@novell.com> 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);
This commit is contained in:
parent
2137cb1911
commit
7e5f6a516c
@ -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") {
|
||||
@ -1283,6 +1290,24 @@ elsif ($opt_k) {
|
||||
push(@ret_list, "rv = ret.$arg_name;");
|
||||
}
|
||||
|
||||
$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+);/) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user