[libnet-dbus-perl] 49/335: Incorporated patch from Carlos Garnacho to fully deal with recursive type signatures
Intrigeri
intrigeri at moszumanska.debian.org
Sat Mar 21 01:07:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch experimental
in repository libnet-dbus-perl.
commit 6c4ac3d00df18a98810757f93db864c91810f0a6
Author: Daniel P. Berrange <dan at berrange.com>
Date: Thu Apr 28 11:14:11 2005 +0000
Incorporated patch from Carlos Garnacho to fully deal with recursive type signatures
---
AUTHORS | 14 ++++++++++
lib/Net/DBus/Binding/Iterator.pm | 55 ++++++++++++++++++++++++++++++----------
lib/Net/DBus/Introspector.pm | 2 +-
3 files changed, 57 insertions(+), 14 deletions(-)
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..9e816ec
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,14 @@
+ Net::DBus - Perl APIs for DBus
+ ==============================
+
+Net::DBus is written by
+
+ Daniel Berrange <dan at berrange.com>
+
+With patches / contributions greatfully received from
+
+ Carlos Garnacho <carlosg at gnome.org>
+
+ [...send patches to get your name here!]
+
+-- End
diff --git a/lib/Net/DBus/Binding/Iterator.pm b/lib/Net/DBus/Binding/Iterator.pm
index f83662e..7d5c6da 100644
--- a/lib/Net/DBus/Binding/Iterator.pm
+++ b/lib/Net/DBus/Binding/Iterator.pm
@@ -315,6 +315,38 @@ sub append {
}
+sub get_signature {
+ my $type = shift;
+ my ($sig, $t, $i);
+
+ $sig = "";
+ $i = 0;
+
+ if (ref ($type) eq "ARRAY") {
+ while ($i <= $#{$type}) {
+ $t = $$type[$i];
+
+ if (ref ($t) eq "ARRAY") {
+ $sig .= &get_signature ($t);
+ } elsif ($t == &Net::DBus::Binding::Message::TYPE_DICT_ENTRY) {
+ $sig .= chr (&Net::DBus::Binding::Message::TYPE_ARRAY);
+ $sig .= "{" . &get_signature ($$type[++$i]) . "}";
+ } elsif ($t == &Net::DBus::Binding::Message::TYPE_STRUCT) {
+ $sig .= "(" . &get_signature ($$type[++$i]) . ")";
+ } else {
+ $sig .= chr ($t);
+ }
+
+ $i++;
+ }
+ } else {
+ $sig .= chr ($type);
+ }
+
+ return $sig;
+}
+
+
sub append_array {
my $self = shift;
my $array = shift;
@@ -323,19 +355,13 @@ sub append_array {
die "array must only have one type"
if $#{$type} > 0;
- my $sig;
- if (ref($type->[0])) {
- $sig = chr($type->[0]->[0]);
- } else {
- $sig = chr($type->[0]);
- }
-
+ my $sig = get_signature ($type);
my $iter = $self->_open_container(&Net::DBus::Binding::Message::TYPE_ARRAY, $sig);
foreach my $value (@{$array}) {
$iter->append($value, $type->[0]);
}
-
+
$self->_close_container($iter);
}
@@ -355,24 +381,27 @@ sub append_struct {
foreach my $value (@{$struct}) {
$iter->append($value, shift @type);
}
-
+
$self->_close_container($iter);
}
-
sub append_dict {
my $self = shift;
my $hash = shift;
my $type = shift;
- # XXX don't hardcode me - cf Python bindings
- my $sig = "{ss}";
+ my $sig;
+
+ $sig = "{";
+ $sig .= get_signature ($type);
+ $sig .= "}";
+
my $iter = $self->_open_container(&Net::DBus::Binding::Message::TYPE_ARRAY, $sig);
foreach my $key (keys %{$hash}) {
my $value = $hash->{$key};
-
my $entry = $iter->_open_container(&Net::DBus::Binding::Message::TYPE_DICT_ENTRY, $sig);
+
$entry->append($key, $type->[0]);
$entry->append($value, $type->[1]);
$iter->_close_container($entry);
diff --git a/lib/Net/DBus/Introspector.pm b/lib/Net/DBus/Introspector.pm
index 2540d5d..3d76079 100644
--- a/lib/Net/DBus/Introspector.pm
+++ b/lib/Net/DBus/Introspector.pm
@@ -321,7 +321,7 @@ sub to_xml {
sub to_xml_type {
my $self = shift;
my $type = shift;
-
+
my $sig = '';
if (ref($type) eq "ARRAY") {
if ($type->[0] eq "array") {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-dbus-perl.git
More information about the Pkg-perl-cvs-commits
mailing list