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

[libvirt] [PATCH 04/13] remote_generator: support general dynamic array



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 <laijs fujitsu com>
---
 daemon/remote_generator.pl |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index d21f959..6905ff3 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -343,6 +343,12 @@ elsif ($opt_b) {
                     }
 
                     push(@args_list, "args->$2.$2_len");
+                } elsif ($args_member =~ m/^(\S+_DABT) (\S+)<\S+>;/) { # normal dynamic array
+                    if (! @args_list) {
+                        push(@args_list, "conn");
+                    }
+                    push(@args_list, "args->$2.$2_len");
+                    push(@args_list, "($1 *)args->$2.$2_val");
                 } 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";
@@ -838,6 +844,18 @@ 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/^(\S+_DABT) (\S+)<(\S+)>;/) { # normal dynamic array
+                    my $type_name = $1;
+                    my $arg_name = $2;
+                    my $limit = $3;
+
+                    push(@args_list, "unsigned int n${arg_name}");
+                    push(@args_list, "${type_name} *$arg_name");
+
+                    push(@setters_list, "args.$arg_name.${arg_name}_len = n${arg_name};");
+                    push(@setters_list, "args.$arg_name.${arg_name}_val = (${type_name} *)$arg_name;");
+
+                    push(@args_check_list, { name => "\"$arg_name\"", arg => "n${arg_name}", limit => $limit });
                 } elsif ($args_member =~ m/^(unsigned )?(int|hyper) (\S+);/) {
                     my $type_name;
                     my $arg_name = $3;
-- 
1.7.4.4


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