mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
remote generator: Handle struct returning functions better
The position of the struct parameter in the function signature differs. Instead of hardcoding the handling for this add an annotation to the .x file to define the position.
This commit is contained in:
parent
c4bd6d96f4
commit
64000eabed
@ -95,8 +95,9 @@ while (<PROTOCOL>) {
|
|||||||
$collect_args_members = 1;
|
$collect_args_members = 1;
|
||||||
$collect_ret_members = 0;
|
$collect_ret_members = 0;
|
||||||
$last_name = $name;
|
$last_name = $name;
|
||||||
} elsif (/^struct ${structprefix}_(.*)_ret/) {
|
} elsif (/^struct ${structprefix}_(.*)_ret\s+{(.*)$/) {
|
||||||
$name = $1;
|
$name = $1;
|
||||||
|
$flags = $2;
|
||||||
$ProcName = name_to_ProcName ($name);
|
$ProcName = name_to_ProcName ($name);
|
||||||
|
|
||||||
if (exists $calls{$name}) {
|
if (exists $calls{$name}) {
|
||||||
@ -112,6 +113,14 @@ while (<PROTOCOL>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($flags ne "" and ($opt_b or $opt_k)) {
|
||||||
|
if (!($flags =~ m/^\s*\/\*\s*insert@(\d+)\s*\*\/\s*$/)) {
|
||||||
|
die "invalid generator flags for $calls{$name}->{ret}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$calls{$name}->{ret_offset} = int($1);
|
||||||
|
}
|
||||||
|
|
||||||
$collect_args_members = 0;
|
$collect_args_members = 0;
|
||||||
$collect_ret_members = 1;
|
$collect_ret_members = 1;
|
||||||
$last_name = $name;
|
$last_name = $name;
|
||||||
@ -668,29 +677,26 @@ elsif ($opt_b) {
|
|||||||
|
|
||||||
# select struct type for multi-return-value functions
|
# select struct type for multi-return-value functions
|
||||||
if ($multi_ret) {
|
if ($multi_ret) {
|
||||||
if (! @args_list) {
|
if (!(defined $call->{ret_offset})) {
|
||||||
|
die "multi-return-value without insert@<offset> annotation: $call->{ret}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!@args_list) {
|
||||||
push(@args_list, "conn");
|
push(@args_list, "conn");
|
||||||
}
|
}
|
||||||
|
|
||||||
my $struct_name = $call->{ProcName};
|
my $struct_name = $call->{ProcName};
|
||||||
$struct_name =~ s/Get//;
|
$struct_name =~ s/Get//;
|
||||||
|
|
||||||
if ($call->{ProcName} eq "DomainGetBlockInfo") {
|
splice(@args_list, $call->{ret_offset}, 0, ("&tmp"));
|
||||||
# SPECIAL: virDomainGetBlockInfo has flags parameter after
|
|
||||||
# the struct parameter in its signature
|
if ($call->{ProcName} eq "DomainBlockStats" ||
|
||||||
my $flags = pop(@args_list);
|
$call->{ProcName} eq "DomainInterfaceStats") {
|
||||||
push(@args_list, "&tmp");
|
|
||||||
push(@args_list, $flags);
|
|
||||||
} elsif ($call->{ProcName} eq "DomainBlockStats" ||
|
|
||||||
$call->{ProcName} eq "DomainInterfaceStats") {
|
|
||||||
# SPECIAL: virDomainBlockStats and virDomainInterfaceStats
|
# SPECIAL: virDomainBlockStats and virDomainInterfaceStats
|
||||||
# have a 'Struct' suffix on the actual struct name
|
# have a 'Struct' suffix on the actual struct name
|
||||||
# and take the struct size as additional argument
|
# and take the struct size as additional argument
|
||||||
$struct_name .= "Struct";
|
$struct_name .= "Struct";
|
||||||
push(@args_list, "&tmp");
|
splice(@args_list, $call->{ret_offset} + 1, 0, ("sizeof tmp"));
|
||||||
push(@args_list, "sizeof tmp");
|
|
||||||
} else {
|
|
||||||
push(@args_list, "&tmp");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
push(@vars_list, "vir$struct_name tmp");
|
push(@vars_list, "vir$struct_name tmp");
|
||||||
@ -1012,14 +1018,14 @@ elsif ($opt_k) {
|
|||||||
" xdr_free((xdrproc_t)xdr_$call->{args}, (char *)&args);\n" .
|
" xdr_free((xdrproc_t)xdr_$call->{args}, (char *)&args);\n" .
|
||||||
" goto done;\n" .
|
" goto done;\n" .
|
||||||
" }");
|
" }");
|
||||||
} elsif ($args_member =~ m/^(unsigned )?int (\S+);\s*\/\*\s*call-by-reference\s*\*\//) {
|
} elsif ($args_member =~ m/^((?:unsigned )?int) (\S+);\s*\/\*\s*call-by-reference\s*\*\//) {
|
||||||
my $type_name = $1; $type_name .= "int *";
|
my $type_name = "$1 *";
|
||||||
my $arg_name = $2;
|
my $arg_name = $2;
|
||||||
|
|
||||||
push(@args_list, "$type_name $arg_name");
|
push(@args_list, "$type_name $arg_name");
|
||||||
push(@setters_list, "args.$arg_name = *$arg_name;");
|
push(@setters_list, "args.$arg_name = *$arg_name;");
|
||||||
} elsif ($args_member =~ m/^(unsigned )?int (\S+);/) {
|
} elsif ($args_member =~ m/^((?:unsigned )?int) (\S+);/) {
|
||||||
my $type_name = $1; $type_name .= "int";
|
my $type_name = $1;
|
||||||
my $arg_name = $2;
|
my $arg_name = $2;
|
||||||
|
|
||||||
push(@args_list, "$type_name $arg_name");
|
push(@args_list, "$type_name $arg_name");
|
||||||
|
@ -352,7 +352,12 @@ struct remote_node_get_memory_stats {
|
|||||||
*
|
*
|
||||||
* 'remote_CALL_ret' members that are filled via call-by-reference must be
|
* 'remote_CALL_ret' members that are filled via call-by-reference must be
|
||||||
* annotated with a insert@<offset> comment to indicate the offset in the
|
* annotated with a insert@<offset> comment to indicate the offset in the
|
||||||
* parameter list of the function to be called. */
|
* parameter list of the function to be called.
|
||||||
|
*
|
||||||
|
* If the 'remote_CALL_ret' maps to a struct in the public API then it is
|
||||||
|
* also filled via call-by-reference and must be annotated with a
|
||||||
|
* insert@<offset> comment to indicate the offset in the parameter list of
|
||||||
|
* the function to be called. */
|
||||||
|
|
||||||
struct remote_open_args {
|
struct remote_open_args {
|
||||||
/* NB. "name" might be NULL although in practice you can't
|
/* NB. "name" might be NULL although in practice you can't
|
||||||
@ -409,7 +414,7 @@ struct remote_get_max_vcpus_ret {
|
|||||||
int max_vcpus;
|
int max_vcpus;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_node_get_info_ret {
|
struct remote_node_get_info_ret { /* insert@1 */
|
||||||
char model[32];
|
char model[32];
|
||||||
unsigned hyper memory;
|
unsigned hyper memory;
|
||||||
int cpus;
|
int cpus;
|
||||||
@ -537,7 +542,7 @@ struct remote_domain_block_stats_args {
|
|||||||
remote_nonnull_string path;
|
remote_nonnull_string path;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_domain_block_stats_ret {
|
struct remote_domain_block_stats_ret { /* insert@2 */
|
||||||
hyper rd_req;
|
hyper rd_req;
|
||||||
hyper rd_bytes;
|
hyper rd_bytes;
|
||||||
hyper wr_req;
|
hyper wr_req;
|
||||||
@ -550,7 +555,7 @@ struct remote_domain_interface_stats_args {
|
|||||||
remote_nonnull_string path;
|
remote_nonnull_string path;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_domain_interface_stats_ret {
|
struct remote_domain_interface_stats_ret { /* insert@2 */
|
||||||
hyper rx_bytes;
|
hyper rx_bytes;
|
||||||
hyper rx_packets;
|
hyper rx_packets;
|
||||||
hyper rx_errs;
|
hyper rx_errs;
|
||||||
@ -605,7 +610,7 @@ struct remote_domain_get_block_info_args {
|
|||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_domain_get_block_info_ret {
|
struct remote_domain_get_block_info_ret { /* insert@2 */
|
||||||
unsigned hyper allocation;
|
unsigned hyper allocation;
|
||||||
unsigned hyper capacity;
|
unsigned hyper capacity;
|
||||||
unsigned hyper physical;
|
unsigned hyper physical;
|
||||||
@ -713,7 +718,7 @@ struct remote_domain_get_info_args {
|
|||||||
remote_nonnull_domain dom;
|
remote_nonnull_domain dom;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_domain_get_info_ret {
|
struct remote_domain_get_info_ret { /* insert@1 */
|
||||||
unsigned char state;
|
unsigned char state;
|
||||||
unsigned hyper maxMem;
|
unsigned hyper maxMem;
|
||||||
unsigned hyper memory;
|
unsigned hyper memory;
|
||||||
@ -1400,7 +1405,7 @@ struct remote_storage_pool_get_info_args {
|
|||||||
remote_nonnull_storage_pool pool;
|
remote_nonnull_storage_pool pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_storage_pool_get_info_ret {
|
struct remote_storage_pool_get_info_ret { /* insert@1 */
|
||||||
unsigned char state;
|
unsigned char state;
|
||||||
unsigned hyper capacity;
|
unsigned hyper capacity;
|
||||||
unsigned hyper allocation;
|
unsigned hyper allocation;
|
||||||
@ -1510,7 +1515,7 @@ struct remote_storage_vol_get_info_args {
|
|||||||
remote_nonnull_storage_vol vol;
|
remote_nonnull_storage_vol vol;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_storage_vol_get_info_ret {
|
struct remote_storage_vol_get_info_ret { /* insert@1 */
|
||||||
char type;
|
char type;
|
||||||
unsigned hyper capacity;
|
unsigned hyper capacity;
|
||||||
unsigned hyper allocation;
|
unsigned hyper allocation;
|
||||||
@ -1827,7 +1832,7 @@ struct remote_domain_get_job_info_args {
|
|||||||
remote_nonnull_domain dom;
|
remote_nonnull_domain dom;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct remote_domain_get_job_info_ret {
|
struct remote_domain_get_job_info_ret { /* insert@1 */
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
unsigned hyper timeElapsed;
|
unsigned hyper timeElapsed;
|
||||||
|
Loading…
Reference in New Issue
Block a user