qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-proton git commit: PROTON-865: Fix compile errors, tested on g++/clang++ * c+11/c++03
Date Wed, 02 Sep 2015 17:05:37 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/cjansen-cpp-client 9c25d4c21 -> 05628c064


PROTON-865: Fix compile errors, tested on g++/clang++ * c+11/c++03


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

Branch: refs/heads/cjansen-cpp-client
Commit: 05628c06457a33ddf9d71c05c1cecfd7df266d15
Parents: 9c25d4c
Author: Alan Conway <aconway@redhat.com>
Authored: Wed Sep 2 11:26:29 2015 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Wed Sep 2 12:57:29 2015 -0400

----------------------------------------------------------------------
 .../cpp/include/proton/blocking_connection.hpp      |  3 ++-
 proton-c/bindings/cpp/src/blocking_connection.cpp   |  2 ++
 proton-c/bindings/cpp/src/connection.cpp            |  2 +-
 proton-c/bindings/cpp/src/connector.cpp             |  8 ++++----
 proton-c/bindings/cpp/src/connector.hpp             |  2 +-
 proton-c/bindings/cpp/src/container_impl.cpp        | 16 ++++++++--------
 proton-c/bindings/cpp/src/contexts.cpp              |  4 ++--
 proton-c/bindings/cpp/src/contexts.hpp              |  9 ++++++---
 proton-c/bindings/cpp/src/conversion_test.cpp       |  2 --
 proton-c/bindings/cpp/src/messaging_handler.cpp     |  6 ++++--
 proton-c/bindings/cpp/src/uuid.cpp                  |  2 +-
 11 files changed, 31 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_connection.hpp b/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
index 87710a0..f9e2a99 100644
--- a/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/blocking_connection.hpp
@@ -40,9 +40,10 @@ class blocking_connection
 {
   public:
     PN_CPP_EXTERN blocking_connection(const proton::url &url, duration timeout = duration::FOREVER);
+    PN_CPP_EXTERN ~blocking_connection();
     PN_CPP_EXTERN void close();
     PN_CPP_EXTERN duration timeout();
-    class connection& connection();
+    PN_CPP_EXTERN class connection& connection();
 
   private:
     blocking_connection(const blocking_connection&);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/blocking_connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection.cpp b/proton-c/bindings/cpp/src/blocking_connection.cpp
index 5be59c8..6b0308c 100644
--- a/proton-c/bindings/cpp/src/blocking_connection.cpp
+++ b/proton-c/bindings/cpp/src/blocking_connection.cpp
@@ -28,6 +28,8 @@ blocking_connection::blocking_connection(const proton::url &url, duration
timeou
     impl_(new blocking_connection_impl(url, timeout))
 {}
 
+blocking_connection::~blocking_connection() {}
+
 void blocking_connection::close() { impl_->close(); }
 
 duration blocking_connection::timeout() { return impl_->container_->reactor().timeout();
}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection.cpp b/proton-c/bindings/cpp/src/connection.cpp
index 8948bd9..84c79a6 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -62,7 +62,7 @@ session& connection::create_session() { return *session::cast(pn_session(pn_cast
 session& connection::default_session() {
     struct connection_context& ctx = connection_context::get(pn_cast(this));
     if (!ctx.default_session) {
-        ctx.default_session = &create_session(); 
+        ctx.default_session = &create_session();
         ctx.default_session->open();
     }
     return *ctx.default_session;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.cpp b/proton-c/bindings/cpp/src/connector.cpp
index 75760d9..3c7c970 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -30,7 +30,7 @@
 
 namespace proton {
 
-connector::connector(connection &c) : connection_(c) {}
+connector::connector(connection &c) : connection_(&c) {}
 
 connector::~connector() {}
 
@@ -39,7 +39,7 @@ void connector::address(const url &a) {
 }
 
 void connector::connect() {
-    pn_connection_t *conn = pn_cast(connection_.get());
+    pn_connection_t *conn = pn_cast(connection_);
     pn_connection_set_container(conn, connection_->container().container_id().c_str());
     pn_connection_set_hostname(conn, address_.host_port().c_str());
 }
@@ -55,8 +55,8 @@ void connector::on_connection_init(event &e) {
 
 void connector::on_transport_closed(event &e) {
     // TODO: prepend with reconnect logic
-    pn_connection_release(pn_cast(connection_.get()));
-    connection_.reset();
+    pn_connection_release(pn_cast(connection_));
+    connection_  = 0;
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/connector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.hpp b/proton-c/bindings/cpp/src/connector.hpp
index b97be53..b311cc9 100644
--- a/proton-c/bindings/cpp/src/connector.hpp
+++ b/proton-c/bindings/cpp/src/connector.hpp
@@ -48,7 +48,7 @@ class connector : public proton_handler
     virtual void on_transport_closed(event &e);
 
   private:
-    counted_ptr<connection> connection_;
+    connection* connection_;
     url address_;
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
index b565210..75293f1 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -82,7 +82,7 @@ class override_handler : public handler
         pn_event_t *cevent = pne->pn_event();
         pn_connection_t *conn = pn_event_connection(cevent);
         if (conn && type != PN_CONNECTION_INIT) {
-            handler *override = connection_context::get(conn).handler;
+            handler *override = connection_context::get(conn).handler.get();
             if (override) e.dispatch(*override);
         }
         pn_handler_dispatch(base_handler.get(), cevent, (pn_event_type_t) type);
@@ -131,15 +131,15 @@ container_impl::~container_impl() {}
 
 connection& container_impl::connect(const proton::url &url, handler *h) {
     counted_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : counted_ptr<pn_handler_t>();
-    connection* conn =
-        connection::cast(pn_reactor_connection(pn_cast(reactor_.get()), chandler.get()));
-    connector *ctor = new connector(*conn); // Will be deleted by connection_context
+    connection& conn(           // Reactor owns the reference.
+        *connection::cast(pn_reactor_connection(pn_cast(reactor_.get()), chandler.get())));
+    PN_UNIQUE_PTR<connector> ctor(new connector(conn));
     ctor->address(url);  // TODO: url vector
-    connection_context& cc(connection_context::get(pn_cast(conn)));
+    connection_context& cc(connection_context::get(pn_cast(&conn)));
     cc.container_impl = this;
-    cc.handler = ctor;
-    conn->open();
-    return *conn;
+    cc.handler.reset(ctor.release());
+    conn.open();
+    return conn;
 }
 
 sender& container_impl::create_sender(const proton::url &url) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp b/proton-c/bindings/cpp/src/contexts.cpp
index a43ba5e..4d17e54 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -69,8 +69,8 @@ counted* get_context(pn_record_t* record, pn_handle_t handle) {
 
 PN_HANDLE(CONNECTION_CONTEXT)
 
-connection_context::connection_context() : handler(0), default_session(0), container_impl(0)
{}
-connection_context::~connection_context() { delete handler; }
+connection_context::connection_context() : default_session(), container_impl() {}
+connection_context::~connection_context() {}
 
 struct connection_context& connection_context::get(pn_connection_t* c) {
     connection_context* ctx = reinterpret_cast<connection_context*>(

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp
index 209c7a2..2285245 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -24,7 +24,10 @@
 
 #include "proton/counted.hpp"
 #include "proton/reactor.h"
-#include "proton/message.h"
+#include "proton/memory.hpp"
+#include "proton/session.hpp"
+
+#include <proton/message.h>
 
 namespace proton {
 
@@ -41,8 +44,8 @@ struct connection_context : public counted {
     connection_context();
     ~connection_context();
 
-    class handler* handler;
-    session* default_session;
+    PN_UNIQUE_PTR<class handler> handler;
+    session* default_session;   // Owned by connection
     class container_impl* container_impl;
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/conversion_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/conversion_test.cpp b/proton-c/bindings/cpp/src/conversion_test.cpp
index a13d016..f9d9588 100644
--- a/proton-c/bindings/cpp/src/conversion_test.cpp
+++ b/proton-c/bindings/cpp/src/conversion_test.cpp
@@ -23,8 +23,6 @@
 
 #include "test_bits.hpp"
 #include "proton/connection.hpp"
-#include "proton/connection.hpp"
-#include "proton/session.hpp"
 #include "proton/session.hpp"
 
 using namespace std;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/messaging_handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_handler.cpp b/proton-c/bindings/cpp/src/messaging_handler.cpp
index 01226f7..578fefd 100644
--- a/proton-c/bindings/cpp/src/messaging_handler.cpp
+++ b/proton-c/bindings/cpp/src/messaging_handler.cpp
@@ -55,13 +55,15 @@ class c_flow_controller : public proton_handler
 
 
 messaging_handler::messaging_handler(int prefetch0, bool auto_accept0, bool auto_settle0,
bool peer_close_is_error0) :
-    prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0), peer_close_iserror_(peer_close_is_error0),
messaging_adapter_(0), flow_controller_(0)
+    prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0),
+    peer_close_iserror_(peer_close_is_error0)
 {
     create_helpers();
 }
 
 messaging_handler::messaging_handler(bool raw_handler, int prefetch0, bool auto_accept0,
bool auto_settle0, bool peer_close_is_error0) :
-    prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0), peer_close_iserror_(peer_close_is_error0),
messaging_adapter_(0), flow_controller_(0)
+    prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0),
+    peer_close_iserror_(peer_close_is_error0)
 {
     if (!raw_handler) {
         create_helpers();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/05628c06/proton-c/bindings/cpp/src/uuid.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/uuid.cpp b/proton-c/bindings/cpp/src/uuid.cpp
index d1bb10e..ca6dec9 100644
--- a/proton-c/bindings/cpp/src/uuid.cpp
+++ b/proton-c/bindings/cpp/src/uuid.cpp
@@ -33,7 +33,7 @@ uuid::uuid() {
         seeded = true;
     }
     int r = std::rand();
-    for (int i = 0; i < sizeof(bytes); ++i ) {
+    for (size_t i = 0; i < sizeof(bytes); ++i ) {
         bytes[i] = r & 0xFF;
         r >>= 8;
         if (!r) r = std::rand();


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


Mime
View raw message