This repository was archived by the owner on Mar 3, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,15 @@ func setDest(dest, src reflect.Value) error {
8787 }
8888 if isVariant (src .Type ()) && ! isVariant (dest .Type ()) {
8989 src = getVariantValue (src )
90+ // not quite ready to directly convert,
91+ // since we're dealing with a variant value
92+ // which may have a complex type
93+ return store (dest , src )
9094 }
95+
9196 if ! src .Type ().ConvertibleTo (dest .Type ()) {
9297 return fmt .Errorf (
93- "dbus.Store: type mismatch: cannot convert %s to %s" ,
98+ "dbus.Store: base type mismatch: cannot convert %s to %s" ,
9499 src .Type (), dest .Type ())
95100 }
96101 dest .Set (src .Convert (dest .Type ()))
Original file line number Diff line number Diff line change @@ -97,3 +97,26 @@ func TestStoreNested(t *testing.T) {
9797 dest , src )
9898 }
9999}
100+
101+ type testStruct1 struct {
102+ V0 uint32
103+ V1 bool
104+ }
105+
106+ func TestStoreVariantStruct (t * testing.T ) {
107+ src := MakeVariantWithSignature ([]interface {}{1 , true }, Signature {"(ub)" })
108+ dest := testStruct1 {}
109+ err := Store ([]interface {}{src }, & dest )
110+ if err != nil {
111+ t .Fatal (err )
112+ }
113+ if ! reflect .DeepEqual (dest .V0 , uint32 (1 )) {
114+ t .Errorf ("not equal: got '%v', want '%v'" ,
115+ dest .V0 , 1 )
116+ }
117+ if ! reflect .DeepEqual (dest .V1 , true ) {
118+ t .Errorf ("not equal: got '%v', want '%v'" ,
119+ dest .V1 , true )
120+ }
121+
122+ }
You can’t perform that action at this time.
0 commit comments