2011/5/25 Daniel P. Berrange <berra...@redhat.com>: > On Wed, May 25, 2011 at 05:37:46PM +0800, Lai Jiangshan wrote: >> It will allow us use "dynamic_array_basic_type member_name<MAX>" >> for remote protocol and avoid so many manual coding. >> >> For avoiding ambiguity, dynamic_array_basic_type must have a "_DABT" suffix. >> >> Signed-off-by: Lai Jiangshan <la...@fujitsu.com> > > A good idea to make the generator support more, but rather > than requiring a magic name for the data type, add an > annotation to the data type > > eg, kind of like Matthias has done to annotate 'hyper' > > http://www.redhat.com/archives/libvir-list/2011-May/msg01434.html
Actually there is not need for this _DABT suffix nor for any other annotation. unsigned int keycodes<REMOTE_SEND_KEY_MAX> is just a common pattern and the generator already deals with such arrays. I propose the attached patch as a v2 of this patch. It doesn't try to cover the generic array case at that isn't useful, it just deals with [unsigned] int arrays. This patch assumes that keycodes and keycodeslen are reordered to the common pattern. Matthias
From b48bfdf41e8b164877869e8590b60e8549bb53fd Mon Sep 17 00:00:00 2001 From: Matthias Bolte <matthias.bo...@googlemail.com> Date: Wed, 25 May 2011 17:37:46 +0800 Subject: [PATCH] remote generator: Handle (unsigned) int arrays --- daemon/remote_generator.pl | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index f34f420..cd51c9a 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -411,6 +411,13 @@ elsif ($opt_b) { } push(@args_list, "args->$2.$2_len"); + } elsif ($args_member =~ m/^(?:unsigned )?int (\S+)<\S+>;/) { + if (! @args_list) { + push(@args_list, "conn"); + } + + push(@args_list, "args->$1.$1_val"); + push(@args_list, "args->$1.$1_len"); } elsif ($args_member =~ m/<\S+>;/ or $args_member =~ m/\[\S+\];/) { # just make all other array types fail die "unhandled type for argument value: $args_member"; @@ -1000,6 +1007,19 @@ elsif ($opt_k) { push(@setters_list, "args.$arg_name.${arg_name}_val = (char *)$arg_name;"); push(@setters_list, "args.$arg_name.${arg_name}_len = ${arg_name}len;"); push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $limit }); + } elsif ($args_member =~ m/^(unsigned )?int (\S+)<(\S+)>;/) { + my $type_name; + my $arg_name = $2; + my $limit = $3; + + $type_name = $1 if ($1); + $type_name .= "int"; + + push(@args_list, "${type_name} *$arg_name"); + push(@args_list, "unsigned int ${arg_name}len"); + push(@setters_list, "args.$arg_name.${arg_name}_val = $arg_name;"); + push(@setters_list, "args.$arg_name.${arg_name}_len = ${arg_name}len;"); + push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $limit }); } elsif ($args_member =~ m/^(unsigned )?int (\S+);/) { my $type_name; my $arg_name = $2; -- 1.7.0.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list