[gnome-code-assistance] [backends/go] Update go.dbus
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-code-assistance] [backends/go] Update go.dbus
- Date: Wed, 13 Nov 2013 13:45:12 +0000 (UTC)
commit c189baa492647571f7ae8926d07dd0bbf129625a
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Wed Nov 13 14:45:01 2013 +0100
[backends/go] Update go.dbus
.../go/deps/src/github.com/guelfey/go.dbus/call.go | 21 +++++++++++++++++++
.../go/deps/src/github.com/guelfey/go.dbus/conn.go | 22 +-------------------
.../src/github.com/guelfey/go.dbus/conn_darwin.go | 3 +-
.../src/github.com/guelfey/go.dbus/conn_other.go | 2 +-
.../go/deps/src/github.com/guelfey/go.dbus/dbus.go | 2 +
.../deps/src/github.com/guelfey/go.dbus/decoder.go | 4 +++
.../deps/src/github.com/guelfey/go.dbus/export.go | 14 ++++++++----
.../deps/src/github.com/guelfey/go.dbus/message.go | 2 -
.../src/github.com/guelfey/go.dbus/proto_test.go | 10 +++++++++
.../github.com/guelfey/go.dbus/transport_darwin.go | 1 -
.../guelfey/go.dbus/transport_unixcred.go | 1 -
backends/go/transport_dbus.go | 4 +-
12 files changed, 52 insertions(+), 34 deletions(-)
---
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/call.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/call.go
index c1a9160..1d2fbc7 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/call.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/call.go
@@ -48,6 +48,27 @@ func (o *Object) Call(method string, flags Flags, args ...interface{}) *Call {
return <-o.Go(method, flags, make(chan *Call, 1), args...).Done
}
+// GetProperty calls org.freedesktop.DBus.Properties.GetProperty on the given
+// object. The property name must be given in interface.member notation.
+func (o *Object) GetProperty(p string) (Variant, error) {
+ idx := strings.LastIndex(p, ".")
+ if idx == -1 || idx+1 == len(p) {
+ return Variant{}, errors.New("dbus: invalid property " + p)
+ }
+
+ iface := p[:idx]
+ prop := p[idx+1:]
+
+ result := Variant{}
+ err := o.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result)
+
+ if err != nil {
+ return Variant{}, err
+ }
+
+ return result, nil
+}
+
// Go calls a method with the given arguments asynchronously. It returns a
// Call structure representing this method call. The passed channel will
// return the same value once the call is done. If ch is nil, a new channel
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/conn.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/conn.go
index 7349087..b38f852 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/conn.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/conn.go
@@ -96,7 +96,7 @@ func SessionBusPrivate() (*Conn, error) {
return Dial(address)
}
- return SessionBusPlatform()
+ return sessionBusPlatform()
}
// SystemBus returns a shared connection to the system bus, connecting to it if
@@ -490,26 +490,6 @@ func (conn *Conn) Signal(ch chan<- *Signal) {
conn.signalsLck.Unlock()
}
-func (obj *Object) GetProperty(p string) (Variant, error) {
-
- idx := strings.LastIndex(p, ".")
- if idx == -1 || idx+1 == len(p) {
- return Variant{}, errors.New("dbus: invalid property " + p)
- }
-
- iface := p[:idx]
- prop := p[idx+1:]
-
- result := Variant{}
- err := obj.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result)
-
- if err != nil {
- return Variant{}, err
- }
-
- return result, nil
-}
-
// SupportsUnixFDs returns whether the underlying transport supports passing of
// unix file descriptors. If this is false, method calls containing unix file
// descriptors will return an error and emitted signals containing them will
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/conn_darwin.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/conn_darwin.go
index 8114b83..b67bb1b 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/conn_darwin.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/conn_darwin.go
@@ -1,10 +1,11 @@
package dbus
import (
+ "errors"
"os/exec"
)
-func SessionBusPlatform() (*Conn, error) {
+func sessionBusPlatform() (*Conn, error) {
cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET")
b, err := cmd.CombinedOutput()
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/conn_other.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/conn_other.go
index 0d3ceaf..f74b875 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/conn_other.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/conn_other.go
@@ -8,7 +8,7 @@ import (
"os/exec"
)
-func SessionBusPlatform() (*Conn, error) {
+func sessionBusPlatform() (*Conn, error) {
cmd := exec.Command("dbus-launch")
b, err := cmd.CombinedOutput()
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/dbus.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/dbus.go
index 9696f4e..2ce6873 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/dbus.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/dbus.go
@@ -177,6 +177,8 @@ func alignment(t reflect.Type) int {
return 4
case signatureType:
return 1
+ case interfacesType: // sometimes used for structs
+ return 8
}
switch t.Kind() {
case reflect.Uint8:
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/decoder.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/decoder.go
index 2fb455f..ef50dca 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/decoder.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/decoder.go
@@ -171,6 +171,8 @@ func (dec *decoder) decode(s string, depth int) interface{} {
panic(FormatError("input exceeds container depth limit"))
}
length := dec.decode("u", depth).(uint32)
+ // Even for empty maps, the correct padding must be included
+ dec.align(8)
spos := dec.pos
for dec.pos < spos+int(length) {
dec.align(8)
@@ -188,6 +190,8 @@ func (dec *decoder) decode(s string, depth int) interface{} {
}
length := dec.decode("u", depth).(uint32)
v := reflect.MakeSlice(reflect.SliceOf(typeFor(s[1:])), 0, int(length))
+ // Even for empty arrays, the correct padding must be included
+ dec.align(alignment(typeFor(s[1:])))
spos := dec.pos
for dec.pos < spos+int(length) {
ev := dec.decode(s[1:], depth+1)
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/export.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/export.go
index 946d1ff..d95b092 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/export.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/export.go
@@ -22,6 +22,10 @@ var (
}
)
+// Sender is a type which can be used in exported methods to receive the message
+// sender.
+type Sender string
+
func exportedMethod(v interface{}, name string) reflect.Value {
if v == nil {
return reflect.Value{}
@@ -192,6 +196,11 @@ func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) erro
// *Error is not nil, it is sent back to the caller as an error.
// Otherwise, a method reply is sent with the other return values as its body.
//
+// Any parameters with the special type Sender are set to the sender of the
+// dbus message when the method is called. Parameters of this type do not
+// contribute to the dbus signature of the method (i.e. the method is exposed
+// as if the parameters of type Sender were not there).
+//
// Every method call is executed in a new goroutine, so the method may be called
// in multiple goroutines at once.
//
@@ -262,11 +271,6 @@ func (conn *Conn) RequestName(name string, flags RequestNameFlags) (RequestNameR
return RequestNameReply(r), nil
}
-func (conn *Conn) Unexport(path ObjectPath, iface string) {
- conn.handlersLck.Lock()
- conn.handlersLck.Unlock()
-}
-
// ReleaseNameReply is the reply to a ReleaseName call.
type ReleaseNameReply uint32
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/message.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/message.go
index 72e7bd0..075d6e3 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/message.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/message.go
@@ -106,8 +106,6 @@ type Message struct {
serial uint32
}
-type Sender string
-
type header struct {
Field byte
Variant
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/proto_test.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/proto_test.go
index 5d28dd8..608a770 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/proto_test.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/proto_test.go
@@ -69,6 +69,16 @@ var protoTests = []struct {
[]byte{0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 1},
[]byte{8, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 1, 0, 0, 0},
},
+ {
+ []interface{}{map[string]Variant{}, byte(42)},
+ []byte{0, 0, 0, 0, 0, 0, 0, 0, 42},
+ []byte{0, 0, 0, 0, 0, 0, 0, 0, 42},
+ },
+ {
+ []interface{}{[]uint64{}, byte(42)},
+ []byte{0, 0, 0, 0, 0, 0, 0, 0, 42},
+ []byte{0, 0, 0, 0, 0, 0, 0, 0, 42},
+ },
}
func TestProto(t *testing.T) {
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/transport_darwin.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/transport_darwin.go
index 5136fd8..1bba0d6 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/transport_darwin.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/transport_darwin.go
@@ -4,4 +4,3 @@ func (t *unixTransport) SendNullByte() error {
_, err := t.Write([]byte{0})
return err
}
-
diff --git a/backends/go/deps/src/github.com/guelfey/go.dbus/transport_unixcred.go
b/backends/go/deps/src/github.com/guelfey/go.dbus/transport_unixcred.go
index ecf9942..42a0e76 100644
--- a/backends/go/deps/src/github.com/guelfey/go.dbus/transport_unixcred.go
+++ b/backends/go/deps/src/github.com/guelfey/go.dbus/transport_unixcred.go
@@ -20,4 +20,3 @@ func (t *unixTransport) SendNullByte() error {
}
return nil
}
-
diff --git a/backends/go/transport_dbus.go b/backends/go/transport_dbus.go
index aecba21..c292972 100644
--- a/backends/go/transport_dbus.go
+++ b/backends/go/transport_dbus.go
@@ -29,10 +29,10 @@ func (t *TransportDbus) unexport(obj ObjectDbus, p dbus.ObjectPath) {
n := obj.Introspect()
for _, i := range n.Interfaces {
- t.conn.Unexport(p, i.Name)
+ t.conn.Export(nil, p, i.Name)
}
- t.conn.Unexport(p, "org.freedesktop.DBus.Introspectable")
+ t.conn.Export(nil, p, "org.freedesktop.DBus.Introspectable")
}
func (t *TransportDbus) export(obj ObjectDbus, p dbus.ObjectPath) error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]