You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/02/23 22:51:42 UTC

[35/38] qpid-proton git commit: PROTON-1415: go fix conversion of pn_seconds_t

PROTON-1415: go fix conversion of pn_seconds_t

genwrap.go: fix conversion of pn_seconds_t to time.Duration.
Exposed by adding TerminusSettings which includes a pn_seconds_t Timeout value.
This is the only place pn_seconds_t is used for a duration in proton instead of pn_millis_t.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c87b23ef
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c87b23ef
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c87b23ef

Branch: refs/heads/go1
Commit: c87b23ef7b473cd48e8775ed9c353d042d99f3ca
Parents: 38592d1
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Feb 23 15:37:24 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Feb 23 15:37:24 2017 -0500

----------------------------------------------------------------------
 proton-c/bindings/go/genwrap.go                 |  6 ++--
 .../src/qpid.apache.org/electron/link_test.go   |  3 +-
 .../src/qpid.apache.org/proton/wrappers_gen.go  | 35 +++++++++++++++++++-
 3 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87b23ef/proton-c/bindings/go/genwrap.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/genwrap.go b/proton-c/bindings/go/genwrap.go
index 7782b0b..6885b74 100644
--- a/proton-c/bindings/go/genwrap.go
+++ b/proton-c/bindings/go/genwrap.go
@@ -161,10 +161,7 @@ func panicIf(err error) {
 }
 
 func readHeader(name string) string {
-	file, err := os.Open(path.Join(includeProton, name+".h"))
-	panicIf(err)
-	defer file.Close()
-	s, err := ioutil.ReadAll(file)
+	s, err := ioutil.ReadFile(path.Join(includeProton, name+".h"))
 	panicIf(err)
 	return string(s)
 }
@@ -314,6 +311,7 @@ func mapType(ctype string) (g genType) {
 	case "C.pn_seconds_t":
 		g.Gotype = "time.Duration"
 		g.ToGo = func(v string) string { return fmt.Sprintf("(time.Duration(%s) * time.Second)", v) }
+		g.ToC = func(v string) string { return fmt.Sprintf("C.pn_seconds_t(%s/time.Second)", v) }
 	case "C.pn_millis_t":
 		g.Gotype = "time.Duration"
 		g.ToGo = func(v string) string { return fmt.Sprintf("(time.Duration(%s) * time.Millisecond)", v) }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87b23ef/proton-c/bindings/go/src/qpid.apache.org/electron/link_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/link_test.go b/proton-c/bindings/go/src/qpid.apache.org/electron/link_test.go
index eb49c47..133faad 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/link_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/link_test.go
@@ -24,13 +24,14 @@ import (
 	"net"
 	"qpid.apache.org/proton"
 	"testing"
+	"time"
 )
 
 func TestLinkSettings(t *testing.T) {
 	cConn, sConn := net.Pipe()
 	done := make(chan error)
 	// FIXME aconway 2017-02-23: bug in timeout conversion (pn_second_t)
-	settings := TerminusSettings{Durability: 1, Expiry: 2 /*, Timeout: 42 * time.Second*/, Dynamic: true}
+	settings := TerminusSettings{Durability: 1, Expiry: 2, Timeout: 42 * time.Second, Dynamic: true}
 	go func() { // Server
 		close(done)
 		defer sConn.Close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87b23ef/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go b/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
index 19bfde2..a6c6635 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers_gen.go
@@ -78,6 +78,13 @@ const (
 	ETransportHeadClosed    EventType = C.PN_TRANSPORT_HEAD_CLOSED
 	ETransportTailClosed    EventType = C.PN_TRANSPORT_TAIL_CLOSED
 	ETransportClosed        EventType = C.PN_TRANSPORT_CLOSED
+	EConnectionWake         EventType = C.PN_CONNECTION_WAKE
+	EListenerAccept         EventType = C.PN_LISTENER_ACCEPT
+	EListenerClose          EventType = C.PN_LISTENER_CLOSE
+	EProactorInterrupt      EventType = C.PN_PROACTOR_INTERRUPT
+	EProactorTimeout        EventType = C.PN_PROACTOR_TIMEOUT
+	EProactorInactive       EventType = C.PN_PROACTOR_INACTIVE
+	EListenerOpen           EventType = C.PN_LISTENER_OPEN
 )
 
 func (e EventType) String() string {
@@ -143,6 +150,20 @@ func (e EventType) String() string {
 		return "TransportTailClosed"
 	case C.PN_TRANSPORT_CLOSED:
 		return "TransportClosed"
+	case C.PN_CONNECTION_WAKE:
+		return "ConnectionWake"
+	case C.PN_LISTENER_ACCEPT:
+		return "ListenerAccept"
+	case C.PN_LISTENER_CLOSE:
+		return "ListenerClose"
+	case C.PN_PROACTOR_INTERRUPT:
+		return "ProactorInterrupt"
+	case C.PN_PROACTOR_TIMEOUT:
+		return "ProactorTimeout"
+	case C.PN_PROACTOR_INACTIVE:
+		return "ProactorInactive"
+	case C.PN_LISTENER_OPEN:
+		return "ListenerOpen"
 	}
 	return "Unknown"
 }
@@ -352,6 +373,15 @@ func (l Link) SetDrain(drain bool) {
 func (l Link) Draining() bool {
 	return bool(C.pn_link_draining(l.pn))
 }
+func (l Link) MaxMessageSize() uint64 {
+	return uint64(C.pn_link_max_message_size(l.pn))
+}
+func (l Link) SetMaxMessageSize(size uint64) {
+	C.pn_link_set_max_message_size(l.pn, C.uint64_t(size))
+}
+func (l Link) RemoteMaxMessageSize() uint64 {
+	return uint64(C.pn_link_remote_max_message_size(l.pn))
+}
 
 // Wrappers for declarations in delivery.h
 
@@ -499,6 +529,9 @@ func (c Condition) RedirectHost() string {
 func (c Condition) RedirectPort() int {
 	return int(C.pn_condition_redirect_port(c.pn))
 }
+func (c Condition) Copy(src Condition) int {
+	return int(C.pn_condition_copy(c.pn, src.pn))
+}
 
 // Wrappers for declarations in terminus.h
 
@@ -630,7 +663,7 @@ func (t Terminus) Timeout() time.Duration {
 	return (time.Duration(C.pn_terminus_get_timeout(t.pn)) * time.Second)
 }
 func (t Terminus) SetTimeout(timeout time.Duration) int {
-	return int(C.pn_terminus_set_timeout(t.pn, C.pn_seconds_t(timeout)))
+	return int(C.pn_terminus_set_timeout(t.pn, C.pn_seconds_t(timeout/time.Second)))
 }
 func (t Terminus) IsDynamic() bool {
 	return bool(C.pn_terminus_is_dynamic(t.pn))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org