[libnet-dbus-perl] 253/335: Fix handling of compound data types for properties

Intrigeri intrigeri at moszumanska.debian.org
Sat Mar 21 01:08:06 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 350d0400c9eee75e58bf895fa12cc4a9af665be0
Author: Daniel P. Berrange <berrange at redhat.com>
Date:   Fri Feb 1 13:05:46 2008 -0500

    Fix handling of compound data types for properties
---
 lib/Net/DBus/Binding/Introspector.pm | 3 ++-
 lib/Net/DBus/Exporter.pm             | 4 ++--
 t/40-introspector.t                  | 3 +++
 t/60-object-props.t                  | 8 ++++++++
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/Net/DBus/Binding/Introspector.pm b/lib/Net/DBus/Binding/Introspector.pm
index 2c3f9e3..6473863 100644
--- a/lib/Net/DBus/Binding/Introspector.pm
+++ b/lib/Net/DBus/Binding/Introspector.pm
@@ -769,8 +769,9 @@ sub _parse_property {
 	    $deprecated = 1 if lc($value) eq "true";
 	}
     }
+    my @sig = split //, $node->att("type");
     $self->{interfaces}->{$interface}->{props}->{$name} = {
-	type =>  $self->_parse_type([$node->att("type")]),
+	type =>  $self->_parse_type(\@sig),
 	access => $access,
 	deprecated => $deprecated,
     };
diff --git a/lib/Net/DBus/Exporter.pm b/lib/Net/DBus/Exporter.pm
index c9e1545..91e4623 100644
--- a/lib/Net/DBus/Exporter.pm
+++ b/lib/Net/DBus/Exporter.pm
@@ -406,7 +406,7 @@ sub dbus_property {
     my $interface = $dbus_exports{$caller}->{interface};
     my %attributes;
     
-    if (@_ && !ref($_[0])) {
+    if (@_ && (!ref($_[0]) || (ref($_[0]) eq "ARRAY"))) {
 	$type = shift;
     }
     if (@_ && !ref($_[0])) {
@@ -422,7 +422,7 @@ sub dbus_property {
     if (!$interface) {
 	die "interface not specified & no default interface defined";
     }
-    
+
     $dbus_exports{$caller}->{props}->{$name} = [$type, $access, $interface, \%attributes];
 }
 
diff --git a/t/40-introspector.t b/t/40-introspector.t
index 0a64cb9..76c31ce 100644
--- a/t/40-introspector.t
+++ b/t/40-introspector.t
@@ -33,6 +33,7 @@ TEST_ONE: {
 								"name" => { type => "string", access => "readwrite"},
 								"email" => { type => "string", access => "read"},
 								"age" => { type => "int32", access => "read"},
+								"parents" => { type => ["array", "string"], access => "readwrite" },
 							    },
 							}
 						    });
@@ -64,6 +65,7 @@ TEST_ONE: {
     <property name="age" type="i" access="read"/>
     <property name="email" type="s" access="read"/>
     <property name="name" type="s" access="readwrite"/>
+    <property name="parents" type="as" access="readwrite"/>
   </interface>
 </node>
 EOF
@@ -161,6 +163,7 @@ EOF
       <property name="age" type="i" access="read"/>
       <property name="email" type="s" access="read"/>
       <property name="name" type="s" access="readwrite"/>
+      <property name="parents" type="as" access="readwrite"/>
     </interface>
   </node>
 </node>
diff --git a/t/60-object-props.t b/t/60-object-props.t
index e3fe15f..99d5a48 100644
--- a/t/60-object-props.t
+++ b/t/60-object-props.t
@@ -36,9 +36,16 @@ sub age {
     return $self->{age};
 }
 
+sub parents {
+    my $self = shift;
+    $self->{parents} = shift if @_;
+    return $self->{parents};
+}
+
 dbus_property("name", "string");
 dbus_property("email", "string", "read");
 dbus_property("age", "int32" ,"write");
+dbus_property("parents", ["array", "string"]);
 
 package main;
 
@@ -58,6 +65,7 @@ my $xml_expect = <<EOF;
     <property name="age" type="i" access="write"/>
     <property name="email" type="s" access="read"/>
     <property name="name" type="s" access="readwrite"/>
+    <property name="parents" type="as" access="readwrite"/>
   </interface>
   <interface name="org.freedesktop.DBus.Introspectable">
     <method name="Introspect">

-- 
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