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 2015/12/30 22:12:49 UTC

[01/50] [abbrv] qpid-proton git commit: NO-JIRA: c++: Memory leaks after object refactor.

Repository: qpid-proton
Updated Branches:
  refs/heads/go1 dfb5b06d5 -> c87499a3b


NO-JIRA: c++: Memory leaks after object refactor.

- Consistent class/struct declaration for connection_context (clang complains)
- Removed bogus 'operator delete' on reactor, left over by mistake.
- Make connection_context::default_session a pn_session_t*
  - using a proton::session was creating a refcount cycle.
- decref in reactor::create - application is taking owership.
- blocking_connection_impl: add missing reactor_.stop() in destructor.


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

Branch: refs/heads/go1
Commit: f1b484ac6c9afd030f23c20252412e64366f92ba
Parents: 1e04209
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Nov 26 17:04:32 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Nov 26 17:24:57 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/connection.hpp    | 2 +-
 proton-c/bindings/cpp/include/proton/reactor.hpp       | 2 --
 proton-c/bindings/cpp/src/blocking_connection_impl.cpp | 4 +++-
 proton-c/bindings/cpp/src/connection.cpp               | 7 +++++--
 proton-c/bindings/cpp/src/connector.cpp                | 4 +++-
 proton-c/bindings/cpp/src/contexts.hpp                 | 2 +-
 proton-c/bindings/cpp/src/reactor.cpp                  | 9 ++++-----
 7 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/proton-c/bindings/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp
index bb438ed..cc8c5ba 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -34,7 +34,7 @@ struct pn_connection_t;
 
 namespace proton {
 
-class connection_context;
+struct connection_context;
 class handler;
 class engine;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/proton-c/bindings/cpp/include/proton/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reactor.hpp b/proton-c/bindings/cpp/include/proton/reactor.hpp
index 929a24b..5f628ce 100644
--- a/proton-c/bindings/cpp/include/proton/reactor.hpp
+++ b/proton-c/bindings/cpp/include/proton/reactor.hpp
@@ -87,8 +87,6 @@ class reactor : public object<pn_reactor_t> {
     PN_CPP_EXTERN void yield();
 
     void container_context(container&);
-
-    void operator delete(void*);
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
index 7a5d882..e0b7c93 100644
--- a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
@@ -55,7 +55,9 @@ blocking_connection_impl::blocking_connection_impl(const url& url, duration time
     wait(connection_opening(connection_));
 }
 
-blocking_connection_impl::~blocking_connection_impl() {}
+blocking_connection_impl::~blocking_connection_impl() {
+    container_->reactor().stop();
+}
 
 void blocking_connection_impl::close() {
     connection_.close();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/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 5226a12..733face 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -90,8 +90,11 @@ session connection::open_session() { return pn_session(pn_object()); }
 session connection::default_session() {
     struct connection_context& ctx = connection_context::get(pn_object());
     if (!ctx.default_session) {
-        ctx.default_session = open_session();
-        ctx.default_session.open();
+        // Note we can't use a proton::session here because we don't want to own
+        // a session reference. The connection owns the session, owning it here as well
+        // would create a circular ownership.
+        ctx.default_session = pn_session(pn_object());
+        pn_session_open(ctx.default_session);
     }
     return ctx.default_session;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/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 2547ff5..90a16e6 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -60,8 +60,10 @@ void connector::reconnect_timer(const class reconnect_timer &rt) {
 void connector::connect() {
     connection_.container_id(connection_.container().id());
     connection_.host(address_.host_port());
-    transport t(pn_transport());
+    pn_transport_t *pnt = pn_transport();
+    transport t(pnt);
     t.bind(connection_);
+    pn_decref((void *)pnt);
     // Apply options to the new transport.
     options_.apply(connection_);
     transport_configured_ = true;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/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 34df0ce..a0e6cf6 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -45,7 +45,7 @@ struct connection_context : public counted {
     ~connection_context();
 
     pn_unique_ptr<class handler> handler;
-    session default_session;   // Owned by connection
+    pn_session_t *default_session;   // Owned by connection
     class container_impl* container_impl;
     message event_message;  // re-used by messaging_adapter for performance
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f1b484ac/proton-c/bindings/cpp/src/reactor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.cpp b/proton-c/bindings/cpp/src/reactor.cpp
index 31d3275..9a52d99 100644
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ b/proton-c/bindings/cpp/src/reactor.cpp
@@ -30,7 +30,10 @@
 namespace proton {
 
 reactor reactor::create() {
-    return reactor(pn_reactor());
+    pn_reactor_t *p = pn_reactor();
+    reactor r(p);
+    pn_decref(p);               // FIXME aconway 2015-11-26: take ownership
+    return r;
 }
 
 void reactor::run() { pn_reactor_run(pn_object()); }
@@ -93,8 +96,4 @@ void reactor::container_context(container& c) {
     proton::container_context(pn_object(), c);
 }
 
-void reactor::operator delete(void* p) {
-    pn_reactor_free(reinterpret_cast<pn_reactor_t*>(p));
-}
-
 }


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


[36/50] [abbrv] qpid-proton git commit: NO-JIRA: [C++ binding] Remove unecessary and unclear inheritance

Posted by ac...@apache.org.
NO-JIRA: [C++ binding] Remove unecessary and unclear inheritance


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

Branch: refs/heads/go1
Commit: 397272000a57de333d98eaaa8eea7115c7976740
Parents: 02d6ba6
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Dec 10 17:14:26 2015 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri Dec 18 13:48:23 2015 +0000

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/handler.hpp | 5 ++++-
 proton-c/bindings/cpp/src/handler.cpp            | 2 +-
 proton-c/bindings/cpp/src/messaging_event.cpp    | 2 +-
 proton-c/bindings/cpp/src/proton_event.cpp       | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/39727200/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
index 6680d70..9b8f5e9 100644
--- a/proton-c/bindings/cpp/include/proton/handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -44,7 +44,7 @@ namespace proton {
  * `on_*_closed` or `on_*_final` event that indicates the handler is no longer needed.
  *
  */
-class handler : public std::vector<handler*> {
+class handler {
   public:
     PN_CPP_EXTERN handler();
     PN_CPP_EXTERN virtual ~handler();
@@ -56,6 +56,9 @@ class handler : public std::vector<handler*> {
     /// h must not be deleted before this handler.
     PN_CPP_EXTERN virtual void add_child_handler(handler &h);
 
+  public:
+    std::vector<handler*> children_;
+    typedef std::vector<handler*>::iterator iterator;
   private:
     pn_ptr<pn_handler_t> pn_handler_;
     friend class container_impl;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/39727200/proton-c/bindings/cpp/src/handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp
index d045dbd..e73ee24 100644
--- a/proton-c/bindings/cpp/src/handler.cpp
+++ b/proton-c/bindings/cpp/src/handler.cpp
@@ -31,7 +31,7 @@ handler::~handler() {}
 void handler::on_unhandled(event &e) {}
 
 void handler::add_child_handler(handler &e) {
-    push_back(&e);
+    children_.push_back(&e);
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/39727200/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index eabacaf..4b1e781 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -147,7 +147,7 @@ void messaging_event::dispatch(handler &h) {
     }
 
     // recurse through children
-    for (handler::iterator child = h.begin(); child != h.end(); ++child) {
+    for (handler::iterator child = h.children_.begin(); child != h.children_.end(); ++child) {
         dispatch(**child);
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/39727200/proton-c/bindings/cpp/src/proton_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.cpp b/proton-c/bindings/cpp/src/proton_event.cpp
index c324985..1278d33 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -160,7 +160,7 @@ void proton_event::dispatch(handler &h) {
     }
 
     // recurse through children
-    for (handler::iterator child = h.begin(); child != h.end(); ++child) {
+    for (handler::iterator child = h.children_.begin(); child != h.children_.end(); ++child) {
         dispatch(**child);
     }
 }


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


[06/50] [abbrv] qpid-proton git commit: PROTON-1059: ruby binding broken in 0.11 release and on master

Posted by ac...@apache.org.
PROTON-1059: ruby binding broken in 0.11 release and on master

Re-organized swig binding to avoid use of the pre-processor in %inline sections.
Now works with ccache and non-ccache swig.

NOTE: According to ccache-swig man page: "Known problems are using
preprocessor directives within %inline blocks and the use of ’#pragma SWIG’."
This includes using macros in an %inline section.

Added automatic example test, needs extension to cover all examples.
Updated option and error handling in some examples to support auto-testing.


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

Branch: refs/heads/go1
Commit: eb63824fd9eb6d3b516ae68065bf05c222b49d95
Parents: 8117f18
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Nov 23 17:13:12 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 1 18:06:12 2015 -0500

----------------------------------------------------------------------
 examples/ruby/example_test.rb       | 90 ++++++++++++++++++++++++++++++++
 examples/ruby/reactor/broker.rb     |  2 +-
 examples/ruby/reactor/client.rb     | 16 +++++-
 examples/ruby/reactor/helloworld.rb |  4 ++
 examples/ruby/reactor/server.rb     | 24 ++++++---
 proton-c/CMakeLists.txt             | 26 +++++----
 proton-c/bindings/python/cproton.i  |  4 +-
 proton-c/bindings/ruby/ruby.i       | 87 ++++++++++++++++--------------
 8 files changed, 195 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/examples/ruby/example_test.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/example_test.rb b/examples/ruby/example_test.rb
new file mode 100755
index 0000000..9a01964
--- /dev/null
+++ b/examples/ruby/example_test.rb
@@ -0,0 +1,90 @@
+#!/usr/bin/enc ruby
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require 'test/unit'
+require 'qpid_proton'
+require 'socket'
+
+$port = Random.new.rand(10000) + 10000
+
+class ExampleTest < Test::Unit::TestCase
+
+  def run_script(script, port)
+    assert File.exist? script
+    cmd = [RbConfig.ruby, script]
+    cmd += ["-a", ":#{port}/examples"] if port
+    return IO.popen(cmd)
+  end
+
+
+  def assert_output(script, want, port=nil)
+    out = run_script(script, port)
+    assert_equal want, out.read.strip
+  end
+
+  def test_helloworld
+    assert_output("reactor/helloworld.rb", "Hello world!", $port)
+  end
+
+  def test_send_recv
+    assert_output("reactor/simple_send.rb", "All 100 messages confirmed!", $port)
+    want = (0..99).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
+    assert_output("reactor/simple_recv.rb", want.strip, $port)
+  end
+
+  def test_client_server
+    want =  <<EOS
+-> Twas brillig, and the slithy toves
+<- TWAS BRILLIG, AND THE SLITHY TOVES
+-> Did gire and gymble in the wabe.
+<- DID GIRE AND GYMBLE IN THE WABE.
+-> All mimsy were the borogroves,
+<- ALL MIMSY WERE THE BOROGROVES,
+-> And the mome raths outgrabe.
+<- AND THE MOME RATHS OUTGRABE.
+EOS
+    srv = run_script("reactor/server.rb", $port)
+    assert_output("reactor/client.rb", want.strip, $port)
+
+  ensure
+    Process.kill :TERM, srv.pid if srv
+  end
+end
+
+begin
+  broker = spawn("#{RbConfig.ruby} reactor/broker.rb -a :#{$port}")
+  # Wait for the broker to be listening.
+  while true
+    begin
+      s = TCPSocket.open "", $port
+      puts "Broker ready at #{$port}"
+      s.close
+      break
+    rescue Errno::ECONNREFUSED
+      puts "Retry connection to #{$port}"
+      sleep(0.1)
+    end
+  end
+
+  Test::Unit::AutoRunner.run
+
+ensure
+  Process.kill :TERM, broker if broker
+end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/examples/ruby/reactor/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/broker.rb b/examples/ruby/reactor/broker.rb
index 9d7e5be..7882d9a 100644
--- a/examples/ruby/reactor/broker.rb
+++ b/examples/ruby/reactor/broker.rb
@@ -117,7 +117,7 @@ class Broker < Qpid::Proton::Handler::MessagingHandler
     debug("link is#{event.link.sender? ? '' : ' not'} a sender") if $options[:debug]
     if event.link.sender?
       if event.link.remote_source.dynamic?
-        address = generate_uuid
+        address = SecureRandom.uuid
         event.link.source.address = address
         q = Exchange.new(true)
         @queues[address] = q

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/examples/ruby/reactor/client.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/client.rb b/examples/ruby/reactor/client.rb
index 8bb58da..8c38f38 100644
--- a/examples/ruby/reactor/client.rb
+++ b/examples/ruby/reactor/client.rb
@@ -18,6 +18,7 @@
 #++
 
 require 'qpid_proton'
+require 'optparse'
 
 class Client < Qpid::Proton::Handler::MessagingHandler
 
@@ -58,6 +59,10 @@ class Client < Qpid::Proton::Handler::MessagingHandler
     end
   end
 
+  def on_transport_error(event)
+    raise "Connection error: #{event.transport.condition}"
+  end
+
 end
 
 REQUESTS = ["Twas brillig, and the slithy toves",
@@ -65,4 +70,13 @@ REQUESTS = ["Twas brillig, and the slithy toves",
             "All mimsy were the borogroves,",
             "And the mome raths outgrabe."]
 
-Qpid::Proton::Reactor::Container.new(Client.new("0.0.0.0:5672/examples", REQUESTS)).run
+options = {
+  :address => "localhost:5672/examples",
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: client.rb [options]"
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(Client.new(options[:address], REQUESTS)).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/examples/ruby/reactor/helloworld.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/helloworld.rb b/examples/ruby/reactor/helloworld.rb
index 03eb561..9b02e8a 100644
--- a/examples/ruby/reactor/helloworld.rb
+++ b/examples/ruby/reactor/helloworld.rb
@@ -45,6 +45,10 @@ class HelloWorld < Qpid::Proton::Handler::MessagingHandler
     puts event.message.body
     event.connection.close
   end
+
+  def on_transport_error(event)
+    raise "Connection error: #{event.transport.condition}"
+  end
 end
 
 options = {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/examples/ruby/reactor/server.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/server.rb b/examples/ruby/reactor/server.rb
index e149dba..9373272 100644
--- a/examples/ruby/reactor/server.rb
+++ b/examples/ruby/reactor/server.rb
@@ -18,20 +18,20 @@
 #++
 
 require 'qpid_proton'
+require 'optparse'
 
 class Server < Qpid::Proton::Handler::MessagingHandler
 
-  def initialize(url, address)
+  def initialize(url)
     super()
-    @url = url
-    @address = address
+    @url = Qpid::Proton::URL.new url
+    @address = @url.path
     @senders = {}
   end
 
   def on_start(event)
-    puts "Listening on #{@url}"
     @container = event.container
-    @conn = @container.connect(:address => @url)
+    @conn = @container.connect(:url => @url)
     @receiver = @container.create_receiver(@conn, :source => @address)
     @relay = nil
   end
@@ -59,6 +59,18 @@ class Server < Qpid::Proton::Handler::MessagingHandler
     sender.send(reply)
   end
 
+  def on_transport_error(event)
+    raise "Connection error: #{event.transport.condition}"
+  end
 end
 
-Qpid::Proton::Reactor::Container.new(Server.new("0.0.0.0:5672", "examples")).run()
+options = {
+  :address => "localhost:5672/examples",
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: server.rb [options]"
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(Server.new(options[:address])).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index d80d60a..d897951 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -586,19 +586,25 @@ endif (BUILD_PYTHON)
 
 find_program(RUBY_EXE "ruby")
 if (RUBY_EXE AND BUILD_RUBY)
+  set (rb_root "${pn_test_root}/ruby")
+  set (rb_src "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby")
+  set (rb_lib "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby/lib")
+  set (rb_bin "${CMAKE_CURRENT_BINARY_DIR}/bindings/ruby")
+  set (rb_bld "$<TARGET_FILE_DIR:qpid-proton>")
+  set (rb_path $ENV{PATH} ${rb_bin} ${rb_bld})
+  set (rb_rubylib ${rb_root} ${rb_src} ${rb_bin} ${rb_bld} ${rb_lib})
+  to_native_path("${rb_path}" rb_path)
+  to_native_path("${rb_rubylib}" rb_rubylib)
+
+  # ruby example tests have no dependencies other than standard ruby.
+  add_test(NAME ruby-example-test
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/examples/ruby
+    COMMAND ${env_py} -- "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
+    ${RUBY_EXE} example_test.rb -v)
+
   # ruby unit tests:  tests/ruby/proton-test
   # only enable the tests if the Ruby gem dependencies were found
   if (DEFAULT_RUBY_TESTING)
-    set (rb_root "${pn_test_root}/ruby")
-    set (rb_src "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby")
-    set (rb_lib "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby/lib")
-    set (rb_bin "${CMAKE_CURRENT_BINARY_DIR}/bindings/ruby")
-    set (rb_bld "$<TARGET_FILE_DIR:qpid-proton>")
-    set (rb_path $ENV{PATH} ${rb_bin} ${rb_bld})
-    set (rb_rubylib ${rb_root} ${rb_src} ${rb_bin} ${rb_bld} ${rb_lib})
-    to_native_path("${rb_path}" rb_path)
-    to_native_path("${rb_rubylib}" rb_rubylib)
-
     add_test (NAME ruby-unit-test
               COMMAND ${env_py} "PATH=${rb_path}" "RUBYLIB=${rb_rubylib}"
                       "${rb_root}/proton-test")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/proton-c/bindings/python/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/cproton.i b/proton-c/bindings/python/cproton.i
index f7f56e3..1485801 100644
--- a/proton-c/bindings/python/cproton.i
+++ b/proton-c/bindings/python/cproton.i
@@ -37,10 +37,10 @@ NOTE: According to ccache-swig man page: "Known problems are using
 preprocessor directives within %inline blocks and the use of ’#pragma SWIG’."
 This includes using macros in an %inline section.
 
-Do any preprocessor work or macro expansions here before we get into the %inline sections.
+Keep preprocessor directives and macro expansions in the normal header section.
 */
-PN_HANDLE(PNI_PYTRACER);
 
+PN_HANDLE(PNI_PYTRACER);
 %}
 
 %include <cstring.i>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb63824f/proton-c/bindings/ruby/ruby.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i
index eddd529..9edbdb2 100644
--- a/proton-c/bindings/ruby/ruby.i
+++ b/proton-c/bindings/ruby/ruby.i
@@ -28,49 +28,16 @@
 #include <proton/url.h>
 #include <proton/reactor.h>
 #include <proton/handlers.h>
-
+%}
 
 /*
 NOTE: According to ccache-swig man page: "Known problems are using
 preprocessor directives within %inline blocks and the use of ’#pragma SWIG’."
-This includes using any macros in an %inline section.
+This includes using macros in an %inline section.
 
-Do any preprocessor work or macro expansions here before we get into the %inline sections.
+Keep preprocessor directives and macro expansions in the normal header section.
 */
 
-#define CID_Pn_rbkey CID_pn_void
-
-typedef struct {
-  void *registry;
-  char *method;
-  char *key_value;
-} Pn_rbkey_t;
-
-void Pn_rbkey_initialize(Pn_rbkey_t *rbkey) {
-  assert(rbkey);
-  rbkey->registry = NULL;
-  rbkey->method = NULL;
-  rbkey->key_value = NULL;
-}
-
-void Pn_rbkey_finalize(Pn_rbkey_t *rbkey) {
-  if(rbkey && rbkey->registry && rbkey->method && rbkey->key_value) {
-    rb_funcall((VALUE )rbkey->registry, rb_intern(rbkey->method), 1, rb_str_new2(rbkey->key_value));
-  }
-  if(rbkey->key_value) {
-    free(rbkey->key_value);
-    rbkey->key_value = NULL;
-  }
-}
-
-#define Pn_rbkey_inspect NULL
-#define Pn_rbkey_compare NULL
-#define Pn_rbkey_hashcode NULL
-
-PN_CLASSDEF(Pn_rbkey)
-
-%}
-
 %include <cstring.i>
 
 %cstring_output_withsize(char *OUTPUT, size_t *OUTPUT_SIZE)
@@ -504,8 +471,53 @@ bool pn_ssl_get_protocol_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZ
 %ignore pn_messenger_recv;
 %ignore pn_messenger_work;
 
+%{
+typedef struct Pn_rbkey_t {
+  void *registry;
+  char *method;
+  char *key_value;
+} Pn_rbkey_t;
+
+void Pn_rbkey_initialize(Pn_rbkey_t *rbkey) {
+  assert(rbkey);
+  rbkey->registry = NULL;
+  rbkey->method = NULL;
+  rbkey->key_value = NULL;
+}
+
+void Pn_rbkey_finalize(Pn_rbkey_t *rbkey) {
+  if(rbkey && rbkey->registry && rbkey->method && rbkey->key_value) {
+    rb_funcall((VALUE )rbkey->registry, rb_intern(rbkey->method), 1, rb_str_new2(rbkey->key_value));
+  }
+  if(rbkey->key_value) {
+    free(rbkey->key_value);
+    rbkey->key_value = NULL;
+  }
+}
+
+/* NOTE: no macro or preprocessor definitions in %inline sections */
+#define CID_Pn_rbkey CID_pn_void
+#define Pn_rbkey_inspect NULL
+#define Pn_rbkey_compare NULL
+#define Pn_rbkey_hashcode NULL
+
+pn_class_t* Pn_rbkey__class(void) {
+    static pn_class_t clazz = PN_CLASS(Pn_rbkey);
+    return &clazz;
+}
+
+Pn_rbkey_t *Pn_rbkey_new(void) {
+    return (Pn_rbkey_t *) pn_class_new(Pn_rbkey__class(), sizeof(Pn_rbkey_t));
+}
+%}
+
+pn_class_t* Pn_rbkey__class(void);
+Pn_rbkey_t *Pn_rbkey_new(void);
+
 %inline %{
 
+Pn_rbkey_t *Pn_rbkey_new(void);
+
 void Pn_rbkey_set_registry(Pn_rbkey_t *rbkey, void *registry) {
   assert(rbkey);
   rbkey->registry = registry;
@@ -579,8 +591,7 @@ int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
   }
 
   VALUE pni_ruby_get_from_registry(VALUE key) {
-
-      return rb_funcall(pni_ruby_get_proton_module(), rb_intern("get_from_registry"), 1, key);
+    rb_funcall(pni_ruby_get_proton_module(), rb_intern("get_from_registry"), 1, key);
   }
 
   void pni_ruby_delete_from_registry(VALUE stored_key) {


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


[41/50] [abbrv] qpid-proton git commit: PROTON-1084 [cpp binding] Add message annotation support

Posted by ac...@apache.org.
PROTON-1084 [cpp binding] Add message annotation support


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

Branch: refs/heads/go1
Commit: 12d2cd62cca1a5040c4aa091213d7415ad618b99
Parents: c41ff06
Author: Kim van der Riet <kp...@apache.org>
Authored: Tue Dec 22 10:52:42 2015 -0500
Committer: Kim van der Riet <kp...@apache.org>
Committed: Tue Dec 22 10:52:42 2015 -0500

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/message.hpp     |  7 +++
 proton-c/bindings/cpp/src/message.cpp           | 48 ++++++++++++++++++++
 2 files changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12d2cd62/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index f04ea07..b132f5f 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -132,6 +132,13 @@ class message
     /** Erase an application property. Returns false if there was no such property. */
     PN_CPP_EXTERN bool erase_property(const std::string &name);
 
+    PN_CPP_EXTERN void annotations(const value&);
+    PN_CPP_EXTERN const data annotations() const;
+    PN_CPP_EXTERN data annotations();
+    PN_CPP_EXTERN void annotation(const proton::amqp_symbol &key, const value &val);
+    PN_CPP_EXTERN value annotation(const proton::amqp_symbol &key) const;
+    PN_CPP_EXTERN bool erase_annotation(const proton::amqp_symbol &key);
+
     /** Encode into a string, growing the string if necessary. */
     PN_CPP_EXTERN void encode(std::string &bytes) const;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12d2cd62/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index dc7e50f..cb29029 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -248,6 +248,54 @@ bool message::erase_property(const std::string& name) {
     return false;
 }
 
+void message::annotations(const value& v) {
+    annotations().copy(v);
+}
+
+const data message::annotations() const {
+    return pn_message_annotations(message_);
+}
+
+data message::annotations() {
+    return pn_message_annotations(message_);
+}
+
+namespace {
+typedef std::map<proton::amqp_symbol, value> annotation_map;
+}
+
+void message::annotation(const proton::amqp_symbol &k, const value &v) {
+    annotation_map m;
+    if (!annotations().empty())
+        annotations().get(m);
+    m[k] = v;
+    annotations(m);
+}
+
+value message::annotation(const proton::amqp_symbol &k) const {
+    if (!annotations().empty()) {
+        annotation_map m;
+        annotations().get(m);
+        annotation_map::const_iterator i = m.find(k);
+        if (i != m.end())
+            return i->second;
+    }
+    return value();
+
+}
+
+bool message::erase_annotation(const proton::amqp_symbol &k) {
+    if (!annotations().empty()) {
+        annotation_map m;
+        annotations().get(m);
+        if (m.erase(k)) {
+            annotations(m);
+            return true;
+        }
+    }
+    return false;
+}
+
 void message::encode(std::string &s) const {
     size_t sz = s.capacity();
     if (sz < 512) sz = 512;


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


[29/50] [abbrv] qpid-proton git commit: PROTON-1026: Fix core dump. Code is treating cooked event as a raw one. But also doing both delegated and default actions instead of just the former (there is always a delegate).

Posted by ac...@apache.org.
PROTON-1026: Fix core dump.  Code is treating cooked event as a raw
one.  But also doing both delegated and default actions instead of
just the former (there is always a delegate).


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

Branch: refs/heads/go1
Commit: 87ece507eddc90f51561b184c080553e1eb41f1e
Parents: a8d87bb
Author: Clifford Jansen <cl...@apache.org>
Authored: Tue Dec 15 13:39:39 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Tue Dec 15 13:39:39 2015 -0800

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/messaging_adapter.cpp | 15 ---------------
 1 file changed, 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/87ece507/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index d551018..c91df35 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -328,29 +328,14 @@ void messaging_adapter::on_link_opening(event &e) {
 
 void messaging_adapter::on_connection_error(event &e) {
     delegate_.on_connection_error(e);
-    proton_event *pe = dynamic_cast<proton_event*>(&e);
-    if (pe) {
-        pn_connection_t *connection = pn_event_connection(pe->pn_event());
-        pn_connection_close(connection);
-    }
 }
 
 void messaging_adapter::on_session_error(event &e) {
     delegate_.on_session_error(e);
-    proton_event *pe = dynamic_cast<proton_event*>(&e);
-    if (pe) {
-        pn_session_t *session = pn_event_session(pe->pn_event());
-        pn_session_close(session);
-    }
 }
 
 void messaging_adapter::on_link_error(event &e) {
     delegate_.on_link_error(e);
-    proton_event *pe = dynamic_cast<proton_event*>(&e);
-    if (pe) {
-        pn_link_t *link = pn_event_link(pe->pn_event());
-        pn_link_close(link);
-    }
 }
 
 void messaging_adapter::on_connection_closed(event &e) {


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


[42/50] [abbrv] qpid-proton git commit: PROTON-973: fix javadoc errors when building with Java 8

Posted by ac...@apache.org.
PROTON-973: fix javadoc errors when building with Java 8


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

Branch: refs/heads/go1
Commit: 213eef923523cfb75cb87c5a030816abf03849f3
Parents: 12d2cd6
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Dec 22 16:34:32 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Dec 22 16:40:34 2015 +0000

----------------------------------------------------------------------
 .../qpid/proton/jms/JMSMappingOutboundTransformer.java       | 5 ++---
 .../src/main/java/org/apache/qpid/proton/driver/Driver.java  | 2 +-
 .../src/main/java/org/apache/qpid/proton/engine/Event.java   | 3 +--
 .../org/apache/qpid/proton/engine/ExtendableAccessor.java    | 2 +-
 .../src/main/java/org/apache/qpid/proton/engine/Sasl.java    | 6 +++---
 .../src/main/java/org/apache/qpid/proton/engine/Sender.java  | 2 +-
 .../main/java/org/apache/qpid/proton/engine/SslDomain.java   | 2 +-
 .../main/java/org/apache/qpid/proton/engine/Transport.java   | 8 ++++----
 .../org/apache/qpid/proton/engine/impl/ByteBufferUtils.java  | 6 +++---
 .../org/apache/qpid/proton/engine/impl/ConnectionImpl.java   | 2 +-
 .../org/apache/qpid/proton/engine/impl/FrameHandler.java     | 2 +-
 .../org/apache/qpid/proton/engine/impl/TransportImpl.java    | 8 ++++----
 .../qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java | 2 +-
 .../apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java    | 2 +-
 .../java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java | 6 +++---
 .../qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java      | 2 +-
 .../main/java/org/apache/qpid/proton/message/Message.java    | 2 +-
 .../org/apache/qpid/proton/message/impl/MessageImpl.java     | 5 +++--
 .../org/apache/qpid/proton/messenger/impl/MessengerImpl.java | 4 ++--
 19 files changed, 35 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
index ba91f0a..af27a77 100644
--- a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
+++ b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
@@ -80,9 +80,8 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer {
      * Perform the conversion between JMS Message and Proton Message without re-encoding it to array.
      * This is needed because some frameworks may elect to do this on their own way (Netty for instance using Nettybuffers)
      *
-     * @param msg
-     * @return
-     * @throws Exception
+     * @param msg the supplied JMS Message
+     * @return the converted Proton Message
      */
     public ProtonJMessage convert(Message msg)
             throws JMSException, UnsupportedEncodingException {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
index 2564f05..dd00fc5 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java
@@ -67,7 +67,7 @@ public interface Driver
      *
      * @param timeout maximum time in milliseconds to wait. -1 means wait indefinitely.
      *
-     * @param returns true if woken up
+     * @return true if woken up
      */
     boolean doWait(long timeout);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
index 1fd2f4c..5930d2c 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java
@@ -145,8 +145,7 @@ public interface Event extends Extendable
      * this method explicitly to be able to do more processing after all child
      * handlers have already processed the event. If handler does not invoke
      * this method it is invoked implicitly by {@link #dispatch(Handler)}
-     * 
-     * @param handler
+     *
      * @throws HandlerException
      */
     void delegate() throws HandlerException;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
index c30b48e..d2eee03 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/ExtendableAccessor.java
@@ -27,7 +27,7 @@ package org.apache.qpid.proton.engine;
  * so it's best instantiated as a static final member.
  * <pre><code>
  *   class Foo extends BaseHandler {
- *     private static ExtendableAccessor<Link, Bar> LINK_BAR = new ExtendableAccessor<>(Bar.class);
+ *     private static ExtendableAccessor&lt;Link, Bar&gt; LINK_BAR = new ExtendableAccessor&lt;&gt;(Bar.class);
  *     void onLinkRemoteOpen(Event e) {
  *       Bar bar = LINK_BAR.get(e.getLink());
  *       if (bar == null) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
index 16043b9..08929e8 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
@@ -126,7 +126,7 @@ public interface Sasl
      * @param bytes written with up to size bytes of inbound data.
      * @param offset the offset in the array to begin writing at
      * @param size maximum number of bytes that bytes can accept.
-     * @return The number of bytes written to bytes, or an error code if < 0.
+     * @return The number of bytes written to bytes, or an error code if {@literal < 0}.
      */
     int recv(byte[] bytes, int offset, int size);
 
@@ -136,7 +136,7 @@ public interface Sasl
      * @param bytes The challenge/response data.
      * @param offset the point within the array at which the data starts at
      * @param size The number of data octets in bytes.
-     * @return The number of octets read from bytes, or an error code if < 0
+     * @return The number of octets read from bytes, or an error code if {@literal < 0}
      */
     int send(byte[] bytes, int offset, int size);
 
@@ -146,7 +146,7 @@ public interface Sasl
      *
      * Used by the server to set the result of the negotiation process.
      *
-     * @todo
+     * @param outcome the outcome of the SASL negotiation
      */
     void done(SaslOutcome outcome);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
index c0ed5aa..b4a61c6 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sender.java
@@ -32,8 +32,8 @@ public interface Sender extends Link
      * indicates pending deliveries
      *
      * @param credits the number of pending deliveries
-     * @todo is this absolute or cumulative?
      */
+    //TODO is this absolute or cumulative?
     public void offer(int credits);
 
     /**

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
index a908824..24b101c 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/SslDomain.java
@@ -123,7 +123,7 @@ public interface SslDomain
      * In order to verify a peer, a trusted CA must be configured. See
      * {@link #setTrustedCaDb(String)}.
      *
-     * @note Servers must provide their own certificate when verifying a peer. See
+     * NOTE: Servers must provide their own certificate when verifying a peer. See
      * {@link #setCredentials(String, String, String)}).
      *
      * @param mode the level of validation to apply to the peer

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
index 0d8539f..a776970 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java
@@ -38,31 +38,31 @@ import org.apache.qpid.proton.engine.impl.TransportImpl;
  * </p>
  * <p>
  * <strong>Processing the input data received from another AMQP container.</strong>
+ * </p>
  * <ol>
  * <li>{@link #getInputBuffer()} </li>
  * <li>Write data into input buffer</li>
  * <li>{@link #processInput()}</li>
  * <li>Check the result, e.g. by calling {@link TransportResult#checkIsOk()}</li>
  * </ol>
- * </p>
  * <p>
  * <strong>Getting the output data to send to another AMQP container:</strong>
+ * </p>
  * <ol>
  * <li>{@link #getOutputBuffer()} </li>
  * <li>Read output from output buffer</li>
  * <li>{@link #outputConsumed()}</li>
  * </ol>
- * </p>
  *
  * <p>The following methods on the byte buffers returned by {@link #getInputBuffer()} and {@link #getOutputBuffer()}
  * must not be called:
+ * </p>
  * <ol>
  * <li> {@link ByteBuffer#clear()} </li>
  * <li> {@link ByteBuffer#compact()} </li>
  * <li> {@link ByteBuffer#flip()} </li>
  * <li> {@link ByteBuffer#mark()} </li>
  * </ol>
- * </p>
  */
 public interface Transport extends Endpoint
 {
@@ -226,7 +226,7 @@ public interface Transport extends Endpoint
 
     /**
      *
-     * @param local idle timeout in milliseconds
+     * @param timeout local idle timeout in milliseconds
      */
     void setIdleTimeout(int timeout);
     /**

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
index 2e34101..8616bee 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ByteBufferUtils.java
@@ -42,7 +42,7 @@ public class ByteBufferUtils
     /**
      * Assumes {@code destination} is ready to be written.
      *
-     * @returns number of bytes poured which may be fewer than {@code sizeRequested} if
+     * @return number of bytes poured which may be fewer than {@code sizeRequested} if
      * {@code destination} has insufficient remaining
      */
     public static int pourArrayToBuffer(byte[] source, int offset, int sizeRequested, ByteBuffer destination)
@@ -54,7 +54,7 @@ public class ByteBufferUtils
 
     /**
      * Pours the contents of {@code source} into {@code destinationTransportInput}, calling
-     * the TransportInput many times if necessary.  If the TransportInput returns a {@link TransportResult}
+     * the TransportInput many times if necessary.  If the TransportInput returns a {@link org.apache.qpid.proton.engine.TransportResult}
      * other than ok, data may remain in source.
      */
     public static int pourAll(ByteBuffer source, TransportInput destinationTransportInput) throws TransportException
@@ -84,7 +84,7 @@ public class ByteBufferUtils
     /**
      * Assumes {@code source} is ready to be read.
      *
-     * @returns number of bytes poured which may be fewer than {@code sizeRequested} if
+     * @return number of bytes poured which may be fewer than {@code sizeRequested} if
      * {@code source} has insufficient remaining
      */
     public static int pourBufferToArray(ByteBuffer source, byte[] destination, int offset, int sizeRequested)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
index e018d14..8b2cb49 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java
@@ -79,7 +79,7 @@ public class ConnectionImpl extends EndpointImpl implements ProtonJConnection
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link EngineFactory} instead
+     * Client code outside this module should use {@link org.apache.qpid.proton.engine.Connection.Factory#create()} instead.
      */
     @Deprecated public ConnectionImpl()
     {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
index 542466a..dfbb201 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameHandler.java
@@ -28,7 +28,7 @@ public interface FrameHandler
     /**
      * @throws IllegalStateException if I am not currently accepting input
      * @see #isHandlingFrames()
-     * @returns false on end of stream
+     * @return false on end of stream
      */
     boolean handleFrame(TransportFrame frame);
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index a98a6f1..03d4fb7 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -139,7 +139,7 @@ public class TransportImpl extends EndpointImpl
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link EngineFactory} instead
+     * Client code outside this module should use {@link org.apache.qpid.proton.engine.Transport.Factory#create()} instead
      */
     @Deprecated public TransportImpl()
     {
@@ -288,7 +288,7 @@ public class TransportImpl extends EndpointImpl
 
     /**
      * This method is public as it is used by Python layer.
-     * @see Transport#input(byte[], int, int)
+     * @see org.apache.qpid.proton.engine.Transport#input(byte[], int, int)
      */
     public TransportResult oldApiCheckStateBeforeInput(int inputLength)
     {
@@ -361,8 +361,8 @@ public class TransportImpl extends EndpointImpl
     /**
      * {@inheritDoc}
      *
-     * <p>Note that sslDomain must implement {@link ProtonSslEngineProvider}. This is not possible
-     * enforce at the API level because {@link ProtonSslEngineProvider} is not part of the
+     * <p>Note that sslDomain must implement {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider}.
+     * This is not possible enforce at the API level because {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider} is not part of the
      * public Proton API.</p>
      */
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
index 2f9a4fd..95ae337 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/ProtonSslEngineProvider.java
@@ -25,7 +25,7 @@ public interface ProtonSslEngineProvider
     /**
      * Returns an SSL engine.
      *
-     * @param sslPeerDetails the details of the remote peer. If non-null, may be used to assist SSL session resumption.
+     * @param peerDetails the details of the remote peer. If non-null, may be used to assist SSL session resumption.
      */
     public ProtonSslEngine createSslEngine(SslPeerDetails peerDetails);
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
index fbcb0f5..583e3ca 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslDomainImpl.java
@@ -37,7 +37,7 @@ public class SslDomainImpl implements SslDomain, ProtonSslEngineProvider, Proton
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link EngineFactory} instead
+     * Client code outside this module should use {@link SslDomain.Factory#create()} instead.
      */
     @Deprecated public SslDomainImpl()
     {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
index 02615cb..f726ff9 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslImpl.java
@@ -44,9 +44,9 @@ public class SslImpl implements Ssl
     private TransportException _initException;
 
     /**
-     * @param sslDomain must implement {@link ProtonSslEngineProvider}. This is not possible
-     * enforce at the API level because {@link ProtonSslEngineProvider} is not part of the
-     * public Proton API.</p>
+     * @param domain must implement {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider}. This is not possible
+     * enforce at the API level because {@link org.apache.qpid.proton.engine.impl.ssl.ProtonSslEngineProvider} is not part of the
+     * public Proton API.
      */
     public SslImpl(SslDomain domain, SslPeerDetails peerDetails)
     {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
index 87a9fe3..cbd9755 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ssl/SslPeerDetailsImpl.java
@@ -28,7 +28,7 @@ public class SslPeerDetailsImpl implements ProtonJSslPeerDetails
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link EngineFactory} instead
+     * Client code outside this module should use {@link org.apache.qpid.proton.engine.SslPeerDetails.Factory#create(String, int)} instead.
      */
     @Deprecated public SslPeerDetailsImpl(String hostname, int port)
     {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java b/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
index 4bb8fee..41945fa 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message/Message.java
@@ -33,7 +33,7 @@ import org.apache.qpid.proton.message.impl.MessageImpl;
 /**
  * Represents a Message within Proton.
  *
- * Create instances of Message using a {@link MessageFactory} implementation.
+ * Create instances of Message using {@link Message.Factory}.
  *
  */
 public interface Message

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
index 6055973..b0204f3 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
@@ -57,7 +57,7 @@ public class MessageImpl implements ProtonJMessage
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link MessageFactory} instead
+     * Client code outside this module should use {@link Message.Factory#create()} instead
      */
     @Deprecated public MessageImpl()
     {
@@ -65,7 +65,8 @@ public class MessageImpl implements ProtonJMessage
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link MessageFactory} instead
+     * Client code outside this module should instead use
+     * {@link Message.Factory#create(Header, DeliveryAnnotations, MessageAnnotations, Properties, ApplicationProperties, Section, Footer)}
      */
     @Deprecated public MessageImpl(Header header, DeliveryAnnotations deliveryAnnotations, MessageAnnotations messageAnnotations,
                        Properties properties, ApplicationProperties applicationProperties, Section body, Footer footer)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/213eef92/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
index 90f396c..b1e48d8 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
@@ -104,7 +104,7 @@ public class MessengerImpl implements Messenger
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link MessengerFactory} instead
+     * Client code outside this module should use {@link Messenger.Factory#create()} instead
      */
     @Deprecated public MessengerImpl()
     {
@@ -113,7 +113,7 @@ public class MessengerImpl implements Messenger
 
     /**
      * @deprecated This constructor's visibility will be reduced to the default scope in a future release.
-     * Client code outside this module should use a {@link MessengerFactory} instead
+     * Client code outside this module should use a {@link Messenger.Factory#create(String)} instead
      */
     @Deprecated public MessengerImpl(String name)
     {


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


[03/50] [abbrv] qpid-proton git commit: PROTON-1052: SSL support for C++ binding

Posted by ac...@apache.org.
PROTON-1052: SSL support for C++ binding


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

Branch: refs/heads/go1
Commit: cf784e2a04b56a91b13ed7346931721868aa263f
Parents: a267629
Author: Clifford Jansen <cl...@apache.org>
Authored: Sun Nov 29 23:11:11 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Mon Nov 30 08:02:29 2015 -0800

----------------------------------------------------------------------
 examples/cpp/CMakeLists.txt                     |   1 +
 examples/cpp/broker.hpp                         |   2 +-
 examples/cpp/connection_options.cpp             |   2 +-
 examples/cpp/ssl.cpp                            | 165 +++++++++++++++++++
 examples/cpp/ssl_certs/README.txt               |  24 +++
 examples/cpp/ssl_certs/tclient-certificate.p12  | Bin 0 -> 1032 bytes
 examples/cpp/ssl_certs/tclient-certificate.pem  |  19 +++
 examples/cpp/ssl_certs/tclient-full.p12         | Bin 0 -> 2476 bytes
 examples/cpp/ssl_certs/tclient-private-key.pem  |  30 ++++
 examples/cpp/ssl_certs/tserver-certificate.p12  | Bin 0 -> 1032 bytes
 examples/cpp/ssl_certs/tserver-certificate.pem  |  19 +++
 examples/cpp/ssl_certs/tserver-full.p12         | Bin 0 -> 2476 bytes
 examples/cpp/ssl_certs/tserver-private-key.pem  |  30 ++++
 proton-c/bindings/cpp/CMakeLists.txt            |   2 +
 .../bindings/cpp/include/proton/acceptor.hpp    |   3 +
 .../cpp/include/proton/connection_options.hpp   |   6 +-
 .../bindings/cpp/include/proton/reactor.hpp     |   2 +
 proton-c/bindings/cpp/include/proton/ssl.hpp    | 127 ++++++++++++++
 .../bindings/cpp/include/proton/transport.hpp   |   1 +
 .../bindings/cpp/src/connection_options.cpp     |  33 +++-
 proton-c/bindings/cpp/src/container_impl.cpp    |  17 +-
 proton-c/bindings/cpp/src/engine.cpp            |   2 +-
 proton-c/bindings/cpp/src/ssl.cpp               |  75 +++++++++
 proton-c/bindings/cpp/src/ssl_domain.cpp        | 113 +++++++++++++
 proton-c/bindings/cpp/src/transport.cpp         |   5 +
 25 files changed, 663 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 8890e2d..3858df3 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -36,6 +36,7 @@ set(examples
   server_direct
   recurring_timer
   connection_options
+  ssl
   encode_decode)
 
 if (NOT WIN32)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/broker.hpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp
index 32fd5c7..2d94b5a 100644
--- a/examples/cpp/broker.hpp
+++ b/examples/cpp/broker.hpp
@@ -162,7 +162,7 @@ class broker_handler : public proton::messaging_handler {
 
     void on_link_closing(proton::event &e) {
         proton::link lnk = e.link();
-        if (!!lnk.sender()) 
+        if (!!lnk.sender())
             unsubscribe(lnk.sender());
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/connection_options.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp
index da3c4d9..ab21f76 100644
--- a/examples/cpp/connection_options.cpp
+++ b/examples/cpp/connection_options.cpp
@@ -47,7 +47,7 @@ class main_handler : public proton::messaging_handler {
 
     void on_start(proton::event &e) {
         // Connection options for this connection.  Merged with and overriding the container's
-        // client_connection_options() settings. 
+        // client_connection_options() settings.
         e.container().connect(url, connection_options().handler(&conn_handler).max_frame_size(2468));
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
new file mode 100644
index 0000000..f81eb62
--- /dev/null
+++ b/examples/cpp/ssl.cpp
@@ -0,0 +1,165 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "proton/acceptor.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/connection_options.hpp"
+#include "proton/transport.hpp"
+#include "proton/ssl.hpp"
+
+#include <iostream>
+
+using proton::connection_options;
+using proton::client_domain;
+using proton::server_domain;
+using proton::ssl_certificate;
+
+// Helper functions defined below.
+bool using_OpenSSL();
+std::string platform_CA(const std::string &base_name);
+ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd);
+std::string cert_directory;
+
+
+struct server_handler : public proton::messaging_handler {
+    proton::acceptor acceptor;
+
+    void on_connection_opened(proton::event &e) {
+        std::cout << "Inbound server connection connected via SSL.  Protocol: " <<
+            e.connection().transport().ssl().protocol() << std::endl;
+        acceptor.close();
+    }
+
+    void on_message(proton::event &e) {
+        std::cout << e.message().body() << std::endl;
+    }
+};
+
+
+class hello_world_direct : public proton::messaging_handler {
+  private:
+    proton::url url;
+    server_handler s_handler;
+
+  public:
+    hello_world_direct(const proton::url& u) : url(u) {}
+
+    void on_start(proton::event &e) {
+        // Configure listener.  Details vary by platform.
+        ssl_certificate server_cert = platform_certificate("tserver", "tserverpw");
+        server_domain sdomain(server_cert);
+        connection_options server_opts;
+        server_opts.server_domain(sdomain).handler(&s_handler);
+        e.container().server_connection_options(server_opts);
+
+        // Configure client with a Certificate Authority database populated with the server's self signed certificate.
+        connection_options client_opts;
+        client_opts.client_domain(platform_CA("tserver"));
+        // Validate the server certificate against the known name in the certificate.
+        client_opts.peer_hostname("test_server");
+#ifdef PN_COMING_SOON
+        // Turn off unnecessary SASL processing.
+        client_opts.sasl_enabled(false);
+#endif
+        e.container().client_connection_options(client_opts);
+
+        s_handler.acceptor = e.container().listen(url);
+        e.container().open_sender(url);
+    }
+
+    void on_connection_opened(proton::event &e) {
+        std::cout << "Outgoing client connection connected via SSL.  Server certificate has subject " <<
+            e.connection().transport().ssl().remote_subject() << std::endl;
+    }
+
+    void on_sendable(proton::event &e) {
+        proton::message m;
+        m.body("Hello World!");
+        e.sender().send(m);
+        e.sender().close();
+    }
+
+    void on_accepted(proton::event &e) {
+        // All done.
+        e.connection().close();
+    }
+};
+
+int main(int argc, char **argv) {
+    try {
+        // Pick an "unusual" port since we are going to be talking to ourselves, not a broker.
+        // Note the use of "amqps" as the URL scheme to denote a TLS/SSL connection.
+        std::string url = argc > 1 ? argv[1] : "amqps://127.0.0.1:8888/examples";
+        // Location of certificates and private key information:
+        if (argc > 2) {
+            cert_directory = argv[2];
+            size_t sz = cert_directory.size();
+            if (sz && cert_directory[sz -1] != '/')
+                cert_directory.append("/");
+        }
+        else cert_directory = "ssl_certs/";
+
+        hello_world_direct hwd(url);
+        proton::container(hwd).run();
+        return 0;
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+    }
+    return 1;
+}
+
+
+bool using_OpenSSL() {
+    // Current defaults.
+#if defined(WIN32)
+    return false;
+#else
+    return true;
+#endif
+}
+
+ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd) {
+    if (using_OpenSSL()) {
+        // The first argument will be the name of the file containing the public certificate, the
+        // second argument will be the name of the file containing the private key.
+        return ssl_certificate(cert_directory + base_name + "-certificate.pem",
+                               cert_directory + base_name + "-private-key.pem", passwd);
+    }
+    else {
+        // Windows SChannel
+        // The first argument will be the database or store that contains one or more complete certificates
+        // (public and private data).  The second will be an optional name of the certificate in the store
+        // (not used in this example with one certificate per store).
+        return ssl_certificate(cert_directory + base_name + "-full.p12", "", passwd);
+    }
+}
+
+std::string platform_CA(const std::string &base_name) {
+    if (using_OpenSSL()) {
+        // In this simple example with self-signed certificates, the peer's certificate is the CA database.
+        return cert_directory + base_name + "-certificate.pem";
+    }
+    else {
+        // Windows SChannel.  Use a pkcs#12 file with just the peer's public certificate information.
+        return cert_directory + base_name + "-certificate.p12";
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/README.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/README.txt b/examples/cpp/ssl_certs/README.txt
new file mode 100644
index 0000000..9a8a4f9
--- /dev/null
+++ b/examples/cpp/ssl_certs/README.txt
@@ -0,0 +1,24 @@
+This directory contains basic self signed test certificates for use by
+proton examples.
+
+The ".pem" files are in the format expected by proton implementations
+using OpenSSL.  The ".p12" file are for Windows implementations using
+SChannel.
+
+The commands used to generate the certificates follow.
+
+
+make_pn_cert()
+{
+  name=$1
+  subject=$2
+  passwd=$3
+  # create the pem files
+  openssl req -newkey rsa:2048 -keyout $name-private-key.pem -out $name-certificate.pem -subj $subject -passout pass:$passwd -x509 -days 3650
+  # create the p12 files
+  openssl pkcs12 -export -out $name-full.p12 -passin pass:$passwd -passout pass:$passwd -inkey $name-private-key.pem -in $name-certificate.pem -name $name
+  openssl pkcs12 -export -out $name-certificate.p12 -in $name-certificate.pem -name $name -nokeys -passout pass:
+}
+
+make_pn_cert tserver /CN=test_server/OU=proton_test tserverpw
+make_pn_cert tclient /CN=test_client/OU=proton_test tclientpw

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tclient-certificate.p12
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tclient-certificate.p12 b/examples/cpp/ssl_certs/tclient-certificate.p12
new file mode 100644
index 0000000..4d0e000
Binary files /dev/null and b/examples/cpp/ssl_certs/tclient-certificate.p12 differ

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tclient-certificate.pem
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tclient-certificate.pem b/examples/cpp/ssl_certs/tclient-certificate.pem
new file mode 100644
index 0000000..8088e2e
--- /dev/null
+++ b/examples/cpp/ssl_certs/tclient-certificate.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKzCCAhOgAwIBAgIJAIV7frIjftgcMA0GCSqGSIb3DQEBCwUAMCwxFDASBgNV
+BAMMC3Rlc3RfY2xpZW50MRQwEgYDVQQLDAtwcm90b25fdGVzdDAeFw0xNTExMjcx
+ODEwMzlaFw0yNTExMjQxODEwMzlaMCwxFDASBgNVBAMMC3Rlc3RfY2xpZW50MRQw
+EgYDVQQLDAtwcm90b25fdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAPCIS4qUdOtQplUxZ6WW0LXcvosqFP6qOiCARLSEWpR3B8bq213rzefwwfcM
+4TtMr88bP+huLKmlyMfwpl8yB88eXkscPgaAce2zk24urWkFXKSQ6GPitWBLGqBa
+V+W0wJ4mfW7MwefVslWfGXI381QEUlBHjkFG30AtzMMTRj2GK2JqUlRXZPljGyB7
+WcXwxcoS+HkKV7FtHWSkLAzyXwQ9vsCUEYdWTUaGXfCUNRSRV7h1LIANbu03NxV0
+XdEl7WXcr7tuTw3axeUGhRFVhLegrxKLuZTTno4aAJnEr8uaDzjxvXnv3Ne2igvy
+gRfZgOMx+XrZEob9OpAoRghQt4cCAwEAAaNQME4wHQYDVR0OBBYEFE4vbyiM0RjG
+TLMLLGGhMZE/5x1GMB8GA1UdIwQYMBaAFE4vbyiM0RjGTLMLLGGhMZE/5x1GMAwG
+A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAErr/rvLS9Ig0UCMwh1J1lA9
+/gvXf93iIK/SjrFIAqYRmfZxg4husfoes8t2hFUeuqoH05TuSOoXG8p8DpgTSGmF
+jAFe+T90vJZTm0oqZkkkI/hdzjGQoHURRp9/O2Z/lm39KSKGVAN5pUWCUDi/G5iS
+P9LZPJN6a5syXMrR6x62IPxAXowlpXkRghKClF3zPOaOBTzT1V27EkI8IEgC+p45
+246EooLnw8ibB+ucNc3KHNzpgKGVd/622+I+Q5eg9AT9PLFttP+R2ECsrVDDPYuA
+p0qaSnwgeozj/d6K3FOgKKEKbzBmpWgkv0jdcVk18aPMHypI/RDtZ/+3ET2Ksi8=
+-----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tclient-full.p12
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tclient-full.p12 b/examples/cpp/ssl_certs/tclient-full.p12
new file mode 100644
index 0000000..ad2d7d3
Binary files /dev/null and b/examples/cpp/ssl_certs/tclient-full.p12 differ

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tclient-private-key.pem
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tclient-private-key.pem b/examples/cpp/ssl_certs/tclient-private-key.pem
new file mode 100644
index 0000000..e5c114d
--- /dev/null
+++ b/examples/cpp/ssl_certs/tclient-private-key.pem
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQICy6ghWp45z4CAggA
+MBQGCCqGSIb3DQMHBAiVdDoo4NIghQSCBMixGm1bm/omMxsaKnIPO7zm5dyLexJ+
+yTFpmh2KV7kQqmpzCyIOdoG6K8YqFnie2XdFWm3S8faRHoMq54bDmyEWIxfQPq5f
+I1iYFbIZkbnhUvK53RActsEUMf0locS4xylU7VQK3XTAwp0TVip3Lp3ehEMEdcXL
+iUWibGsoTPKcY9MIWGXZAJXsEXoeHt6k2hHo1G4E0/Bi6mLW1LY/cxZCjHTGD6qI
+Kt54SCCDvinqVa+rixw6yX9F14EA6bhALami8e+Ccd3lqHOyYlXcBaSS1ezCg6ig
+oNK97mC+gEGy1KlkZDKWXclFoOCBXRBe4DByre6Rlq3yeI9L42bvAuSBSmf5QT5g
+73Yl8vjEAKR65awBT09dPuKu7t+Fb6vkwF8/t+uyj9IuL+42UuXhMLK3ohf+6DbU
+8/zB4y3GXI80QmWM0+Wx4n6khFhPFLHt2q0Sn6V9PG1vtHyiq50oSCoyrPQLaecp
+hefnMCFBYTcT3JUwmoVGGy0boIAwL7T4aGsMt7QhwOx5tU35tKFxyY7m4fX14AKo
+2EIy+TPQwCGkGf3Puy/Pc9VA8IAxB5+WwSrjk+NeCv88eIX7gy43k4rCr+OmD9FF
+wknr3xoP3KYhNXjdZ4Ep/1UHSK+JAtzzbNLQjDcqN+gQPg/yUX6ih0j5K3Wvh9bK
+E/DvzbpJroUZPgzR+8z5O68CfsD+OIdpHBFTKqAFmzvUuqpADpr998LdCjD+lW+V
+xZZgZa8KEblwgiH3fdGbYl46Ho1zrZisf439DbqyybAuBIQB4NSZcL/MAgVGO17k
+QDpVElWZWYrFm4CFTcvS2HvIzRmbefF5m5oJedsN7Q6WQCp+3gnwYx1xIOknd7pW
+N4AHNnqjscSj9yACj/EiBVKAKNnC5H7ZGZTsaAjMETZyjLXfI2AZ3Fviz4zFR+oz
+NkAfFB6WUpRpl7H02FzrzYT7XkkLcXd6H6g+mv2iDa9uKWk/PS2QlqnJt8/dHEHD
+JKTG331yDK5GHlKAVGF3nP5BwFGgTQMuSoeiOervMXPUwDpQ8OaYkuaRej0cZLgT
+kAF9sUjqdsoYNcXDFHALp6y5g8qYkfrxrlIbKs82zIsmB5I+dtZbUaD3a0zAUrmW
+5Xm3Pc9dVP0EXKwfHz6zqPReEw2yYLisB5IoHd4M2wa3GzHBdra1ij4QTmvd3o7e
+buGFoX8KJQAcig0zpbYkoDP2gPhIh9rY4unVPQNX1Q8/wRsiJAZZsYvZY+A+SmuZ
+bwSwk+8ZJRsFzdYYYhQeRytD5cDAIQiClcI5Yj4T9dWQV/gf0N/wIBDNTMp0jJAy
+1l7PuXTfGZodNJWZH0oqsrNoWbn/k67NildvvofIKX+h09Nxszr670Pvj0qoHd5/
+CWq30lnxoJBUgbikFOz6ZuuHi/ZiCXL+haH+v8hJKN5ptRKnyYJQHchRB/IOGRoT
+5lmWxo8a7K+yXhp0VBDHJfw3685ms0xQX8Xj4X3MEuN64zd0fB1JmhtP12ydK85J
+ABawNKlRQPw5weckwtCviXQX+vX25S/xu3xA6IuqlHyqL/1t3DICzuxeOyT2mZxD
+tKQxEgNihPvu32vn9m74qA3adEaxuWPRkPZuTeITHOkMTZolvqYX/5olBsSgYwka
+7/g=
+-----END ENCRYPTED PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tserver-certificate.p12
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tserver-certificate.p12 b/examples/cpp/ssl_certs/tserver-certificate.p12
new file mode 100644
index 0000000..f38b67d
Binary files /dev/null and b/examples/cpp/ssl_certs/tserver-certificate.p12 differ

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tserver-certificate.pem
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tserver-certificate.pem b/examples/cpp/ssl_certs/tserver-certificate.pem
new file mode 100644
index 0000000..86231f3
--- /dev/null
+++ b/examples/cpp/ssl_certs/tserver-certificate.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKzCCAhOgAwIBAgIJAPnYOOQCJ3kDMA0GCSqGSIb3DQEBCwUAMCwxFDASBgNV
+BAMMC3Rlc3Rfc2VydmVyMRQwEgYDVQQLDAtwcm90b25fdGVzdDAeFw0xNTExMjcx
+ODEwMzlaFw0yNTExMjQxODEwMzlaMCwxFDASBgNVBAMMC3Rlc3Rfc2VydmVyMRQw
+EgYDVQQLDAtwcm90b25fdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAKJNB78lgw4KtXDAvXocTLud6mbn6zgfB6ETIF+kcrukOH9DnPxjLBBM4Lig
+sp1+kmeudFK5/X8riDrvIW52b/rlEBLgLB+oDtI74m6OTbBs9L+FUFYOuxApetQF
+qoJy2vf9pWfy4uku24vCpeo7eVLi6ypu4lXE3LR+Km3FruHI1NKonHBMhwXSOWqF
+pYM6/4IZJ4fbV0+eU0Jrx+05s6XHg5vone2BVJKxeSIBje+zWnNnh8+qG0Z70Jgp
+aMetME5KGnLNgD1okpH0vb3lwjvuqkkx4WswGVZGbLLkSqqBpXPyM9fCFVy5aKSL
+DBq7IABQtO67O2nBzK3OyigHrUUCAwEAAaNQME4wHQYDVR0OBBYEFGV1PY0FCFbJ
+gpcDVKI6JGiRTt3kMB8GA1UdIwQYMBaAFGV1PY0FCFbJgpcDVKI6JGiRTt3kMAwG
+A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAIx1TOTGWnnbpan4bse7wuvH
+GYSNDJhoTVS+X1TC63xukJD1JBAsCNTqg/ZV6lN3XEl7vvOXfGoCiyXM6a9XOKUo
+gSDtMrIr+wTh6Ss1yRO8QcCJmxH5JDXNu1ojtwsjFW/vneI4IL9kwpDsSlMQEX/E
+EkkQwtAx/Cvfe7pecZL4qSeykJOUMTts9H8fCAZqEiRZBA3ugJxqF8jwLP3DoFVQ
+6QZzKDY6CSPqfMnVb5i0MAIYVDpau+e3N9dgQpZD22F/zbua0OVbfAPdiRMnYxML
+FT4sxLnh+5YVqwpVWbEKp4onHe2Fq6YIvAxUYAJ3SBA2C8O2RAVKWxf1jko3jYI=
+-----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tserver-full.p12
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tserver-full.p12 b/examples/cpp/ssl_certs/tserver-full.p12
new file mode 100644
index 0000000..d4a0e40
Binary files /dev/null and b/examples/cpp/ssl_certs/tserver-full.p12 differ

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/examples/cpp/ssl_certs/tserver-private-key.pem
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_certs/tserver-private-key.pem b/examples/cpp/ssl_certs/tserver-private-key.pem
new file mode 100644
index 0000000..91dcf0e
--- /dev/null
+++ b/examples/cpp/ssl_certs/tserver-private-key.pem
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI1cT0c2J3GcQCAggA
+MBQGCCqGSIb3DQMHBAi1hxSX2LJ+EgSCBMheHJ0iXr5A36Natjk/LcAEeKUMT9s+
+sMzoQceCWe8qMlQluWksr9iDdZ4JRIE8cpK8dbmx4dLY/SShUzdlhJHCSa4zZBHq
+8cZ/jGUF/RF1rqdgjK589eUq+uOl3/gXKzG/SxBqayy6PSn12kX3qnvmlkXCmtwU
+lg+iBm5wRcJ0MyVHaJkyA8sW8gr186C/VAau6Yu0crQXN7NRo9snrd4ewuYMIEhZ
+hgaG9XsYQWB1bPhAaKj80CZGxsQbJyTwcbKKkB3IY4WXx8mmhuiNl+vKT3HBJ9Ju
+YB6tgIjs8CJ4X2P4aU3yNJwG1QldgHSqmFGQ19bcZAw3s3kzwjdzRf4H2V16XOBd
+zQ5AEs/ffVMzMIAfkb1gYwgunZ2CVwwDJ2mi1RcgkX+Og2aFQc+fxXcVOnDcGLxV
+6fuCuZ2lsXfoiIyRh9kj3L75N12GtVUvgBdnMuOc1wPw6XnGQtDwt0acJpdexLMG
+k0j57r/gcgzTcmF3qNM+y9L/HLssgrJkvVJw2Np5gmtIyfDocsDUWUbClS4dTpYf
+oTngUTU+vWtHBuaUnb+f5/WJaRS/S7mmR8usbVG3i9WnEr/vlPJpbJFSjW2S6u/H
+7cFxKUmmBZsSuEv/EKt9a+Sh62kprOChm4myqfCI1/gvNKfUZC6m0Vp8zf+2LgAq
+2RgbMuqysMjWUtV4kDRZT7oCYckUDwsCHdbLES3nmVrtBk2ShMKHBpDp8/GoRuiV
+jdV7/EjKM/M1kXtFYYe3z7Mxv++lKYIJ7bNwVrQ8nrhce/VwHw6D5emWXNCJXhKZ
+FW7EM2ZOZ9eaKOlCsIi8sbjV6Yie9IY6HJKKmi3CpO0Tv5kLBdHkru8vGCSFm3O1
+n7wz7Ys5FBSlZ19X0NwQSCQX1Q4w+tido6i1SCRX0qJEdTNGuGwVXMHCf4/1zyHV
+hj8vnxh8fzo79LFrwlTTgwLg1Mr8sEUFFDJ/raJ1AhFXi8n24trtNR8EHxRW8wtD
+CLCKaqkEqfBiFXK/Yq3RrefCayPHiD+DaNsI8BwefMGpED3vD8YYCjAzXNPh/CSF
+sc1i1jWMzbJhzOoFSPNXhlfusbUFMFQ/6olatmH47SY6HBBOL3DDP5uQ0jw8P454
+QBjlMOpEZmZxO6TcEtJwu0vzgog4rQ5g3NWy6SIpjWehNwTynLt7yM3R5WTI6cZs
+0GTv/rqo2/SUoNsFmnGIUwj/DrBe4XOAq1nS2ZlEctxKhBsKH0hMFp6D1rXOzrgl
+bwcq+oistoB0TLcThShyNgSqzW1znQ1n5SVUk9b5rRhSttJxn3yOMewH0i3v8bPo
+HOhP5kaGjblPsCYyhlL/SNVF0OXEGTwLNey7FQdWFOwVwTRRXe7k+uGZ2d5hg+Jn
+It/trDZ1RDYbVmB7/Qy73c16J4mvhOUJ2de5ZciFBjkidbiiUKLj9xnjK9k9Sauo
+MKhNnDMAEU5VDQM3xNe5BRdX8dFLwfF5H64sU3nROF83aUnDgvfFEowYPnCuPYfm
+m4aQHfoBSg4j3v1OeOwktcl+Q2TjxPHfWhbWeRBfxOTqQ/suYhnQChuFSK/qyo9K
+ccgotqghhunRsWMoZT25H7AZM6yKb1sMz/0oyMRIKeGqoYh+ULM5XLY0xNYd4/xU
+WtQ=
+-----END ENCRYPTED PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 47ca937..6bc6445 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -64,6 +64,8 @@ set(qpid-proton-cpp-source
   src/request_response.cpp
   src/sender.cpp
   src/session.cpp
+  src/ssl.cpp
+  src/ssl_domain.cpp
   src/task.cpp
   src/terminus.cpp
   src/transport.cpp

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/include/proton/acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acceptor.hpp b/proton-c/bindings/cpp/include/proton/acceptor.hpp
index cd77358..c5726aa 100644
--- a/proton-c/bindings/cpp/include/proton/acceptor.hpp
+++ b/proton-c/bindings/cpp/include/proton/acceptor.hpp
@@ -38,6 +38,9 @@ class acceptor : public object<pn_acceptor_t>
 
     /** close the acceptor */
     PN_CPP_EXTERN void close();
+#ifndef PROTON_1057_FIXED
+    friend class container_impl;
+#endif
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index 2755adf..c9701c9 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -63,7 +63,7 @@ class connection_options {
     PN_CPP_EXTERN void override(const connection_options& other);
 
     // TODO: Document options
-    
+
     PN_CPP_EXTERN connection_options& handler(class handler *);
     PN_CPP_EXTERN connection_options& max_frame_size(uint32_t max);
     PN_CPP_EXTERN connection_options& max_channels(uint16_t max);
@@ -71,11 +71,11 @@ class connection_options {
     PN_CPP_EXTERN connection_options& heartbeat(uint32_t t);
     PN_CPP_EXTERN connection_options& container_id(const std::string &id);
     PN_CPP_EXTERN connection_options& reconnect(const reconnect_timer &);
-#ifdef PN_CPP_SOON
     PN_CPP_EXTERN connection_options& client_domain(const class client_domain &);
     PN_CPP_EXTERN connection_options& server_domain(const class server_domain &);
     PN_CPP_EXTERN connection_options& peer_hostname(const std::string &name);
     PN_CPP_EXTERN connection_options& resume_id(const std::string &id);
+#ifdef PN_CPP_SOON
     PN_CPP_EXTERN connection_options& sasl_enabled(bool);
     PN_CPP_EXTERN connection_options& allow_insecure_mechs(bool);
     PN_CPP_EXTERN connection_options& allowed_mechs(const std::string &);
@@ -88,9 +88,9 @@ class connection_options {
     bool sasl_enabled() const;
     bool allow_insecure_mechs() const;
     std::string *allowed_mechs() const;
+#endif
     class client_domain &client_domain();
     class server_domain &server_domain();
-#endif
 
     class impl;
     pn_unique_ptr<impl> impl_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/include/proton/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reactor.hpp b/proton-c/bindings/cpp/include/proton/reactor.hpp
index 5f628ce..fa7d633 100644
--- a/proton-c/bindings/cpp/include/proton/reactor.hpp
+++ b/proton-c/bindings/cpp/include/proton/reactor.hpp
@@ -87,6 +87,8 @@ class reactor : public object<pn_reactor_t> {
     PN_CPP_EXTERN void yield();
 
     void container_context(container&);
+
+    friend class container_impl;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
new file mode 100644
index 0000000..d5d80d7
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -0,0 +1,127 @@
+#ifndef PROTON_CPP_SSL_H
+#define PROTON_CPP_SSL_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include "proton/export.hpp"
+#include "proton/pn_unique_ptr.hpp"
+#include "proton/counted.hpp"
+#include "proton/counted_ptr.hpp"
+
+#include "proton/ssl.h"
+
+#include <string>
+
+namespace proton {
+
+class connection_options;
+
+class ssl {
+  public:
+    enum verify_mode_t {
+        VERIFY_PEER = PN_SSL_VERIFY_PEER,
+        ANONYMOUS_PEER = PN_SSL_ANONYMOUS_PEER,
+        VERIFY_PEER_NAME = PN_SSL_VERIFY_PEER_NAME
+    };
+    /// Outcome specifier for an attempted session resume
+    enum resume_status_t {
+        UNKNOWN = PN_SSL_RESUME_UNKNOWN,    /**< Session resume state unknown/not supported */
+        NEW = PN_SSL_RESUME_NEW,            /**< Session renegotiated - not resumed */
+        REUSED = PN_SSL_RESUME_REUSED       /**< Session resumed from previous session. */
+    };
+    ssl(pn_ssl_t* s) : object_(s) {}
+    PN_CPP_EXTERN std::string cipher() const;
+    PN_CPP_EXTERN std::string protocol() const;
+    PN_CPP_EXTERN int ssf() const;
+    PN_CPP_EXTERN void peer_hostname(const std::string &);
+    PN_CPP_EXTERN std::string peer_hostname() const;
+    PN_CPP_EXTERN std::string remote_subject() const;
+    PN_CPP_EXTERN void resume_session_id(const std::string& session_id);
+    PN_CPP_EXTERN resume_status_t resume_status() const;
+
+private:
+    pn_ssl_t* object_;
+};
+
+
+class ssl_certificate {
+  public:
+    PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra = std::string());
+    PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra, const std::string &passwd);
+  private:
+    std::string certdb_main_;
+    std::string certdb_extra_;
+    std::string passwd_;
+    bool pw_set_;
+    friend class client_domain;
+    friend class server_domain;
+};
+
+class ssl_domain : public counted {
+    ssl_domain(bool server_type);
+    ~ssl_domain();
+  private:
+    pn_ssl_domain_t *impl_;
+    friend class client_domain;
+    friend class server_domain;
+};
+
+/** SSL/TLS configuration for inbound connections created from a listener */
+class server_domain {
+  public:
+    /** A server domain based on the supplied X509 certificate specifier. */
+    PN_CPP_EXTERN server_domain(ssl_certificate &cert);
+    /** A server domain requiring connecting clients to provide a client certificate. */
+    PN_CPP_EXTERN server_domain(ssl_certificate &cert, const std::string &trust_db,
+                                const std::string &advertise_db = std::string(),
+                                ssl::verify_mode_t mode = ssl::VERIFY_PEER);
+    /** A server domain restricted to available anonymous cipher suites on the platform. */
+    PN_CPP_EXTERN server_domain();
+  private:
+    pn_ssl_domain_t *pn_domain();
+    counted_ptr<ssl_domain> ssl_domain_;
+    server_domain(ssl_domain *);
+    friend class connection_options;
+    friend class container_impl;
+};
+
+
+/** SSL/TLS configuration for outgoing connections created */
+class client_domain {
+  public:
+    PN_CPP_EXTERN client_domain(const std::string &trust_db, ssl::verify_mode_t = ssl::VERIFY_PEER_NAME);
+    PN_CPP_EXTERN client_domain(ssl_certificate&, const std::string &trust_db, ssl::verify_mode_t = ssl::VERIFY_PEER_NAME);
+    /** A client domain restricted to available anonymous cipher suites on the platform. */
+    PN_CPP_EXTERN client_domain();
+  private:
+    pn_ssl_domain_t *pn_domain();
+    counted_ptr<ssl_domain> ssl_domain_;
+    client_domain(ssl_domain *);
+    friend class connection_options;
+    friend class container_impl;
+};
+
+
+
+
+}
+
+#endif  /*!PROTON_CPP_SSL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/include/proton/transport.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/transport.hpp b/proton-c/bindings/cpp/include/proton/transport.hpp
index 0b73a8c..3f664bc 100644
--- a/proton-c/bindings/cpp/include/proton/transport.hpp
+++ b/proton-c/bindings/cpp/include/proton/transport.hpp
@@ -47,6 +47,7 @@ class transport : public object<pn_transport_t>
     PN_CPP_EXTERN uint16_t remote_max_channels() const;
     PN_CPP_EXTERN uint32_t idle_timeout() const;
     PN_CPP_EXTERN uint32_t remote_idle_timeout() const;
+    PN_CPP_EXTERN class ssl ssl() const;
     friend class connection_options;
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 6d5b829..5097e42 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -21,6 +21,7 @@
 #include "proton/connection_options.hpp"
 #include "proton/reconnect_timer.hpp"
 #include "proton/transport.hpp"
+#include "proton/ssl.hpp"
 #include "contexts.hpp"
 #include "connector.hpp"
 #include "msg.hpp"
@@ -47,11 +48,11 @@ class connection_options::impl {
     option<uint32_t> heartbeat;
     option<std::string> container_id;
     option<reconnect_timer> reconnect;
-#ifdef PN_CCP_SOON
     option<class client_domain> client_domain;
     option<class server_domain> server_domain;
     option<std::string> peer_hostname;
     option<std::string> resume_id;
+#ifdef PN_CCP_SOON
     option<bool> sasl_enabled;
     option<std::string> allowed_mechs;
     option<bool> allow_insecure_mechs;
@@ -68,6 +69,26 @@ class connection_options::impl {
         // transport not yet configured.
         if (pnt && (uninit || (outbound && !outbound->transport_configured())))
         {
+            if (outbound && outbound->address().scheme() == url::AMQPS) {
+                // Configure outbound ssl options. pni_acceptor_readable handles the inbound case.
+                const char* id = resume_id.value.empty() ? NULL : resume_id.value.c_str();
+                pn_ssl_t *ssl = pn_ssl(pnt);
+                if (pn_ssl_init(ssl, client_domain.value.pn_domain(), id))
+                    throw error(MSG("client SSL/TLS initialization error"));
+                if (peer_hostname.set && !peer_hostname.value.empty())
+                    if (pn_ssl_set_peer_hostname(ssl, peer_hostname.value.c_str()))
+                        throw error(MSG("error in SSL/TLS peer hostname \"") << peer_hostname.value << '"');
+#ifdef PROTON_1054_FIXED
+            } else if (!outbound) {
+                pn_acceptor_t *pnp = pn_connection_acceptor(pn_cast(&c));
+                listener_context &lc(listener_context::get(pnp));
+                if (lc.ssl) {
+                    pn_ssl_t *ssl = pn_ssl(pnt);
+                    if (pn_ssl_init(ssl, server_domain.value.pn_domain(), NULL))
+                        throw error(MSG("server SSL/TLS initialization error"));
+                }
+#endif
+            }
             if (max_frame_size.set)
                 pn_transport_set_max_frame(pnt, max_frame_size.value);
             if (max_channels.set)
@@ -92,6 +113,10 @@ class connection_options::impl {
         heartbeat.override(x.heartbeat);
         container_id.override(x.container_id);
         reconnect.override(x.reconnect);
+        client_domain.override(x.client_domain);
+        server_domain.override(x.server_domain);
+        resume_id.override(x.resume_id);
+        peer_hostname.override(x.peer_hostname);
     }
 
 };
@@ -116,8 +141,14 @@ connection_options& connection_options::idle_timeout(uint32_t t) { impl_->idle_t
 connection_options& connection_options::heartbeat(uint32_t t) { impl_->heartbeat = t; return *this; }
 connection_options& connection_options::container_id(const std::string &id) { impl_->container_id = id; return *this; }
 connection_options& connection_options::reconnect(const reconnect_timer &rc) { impl_->reconnect = rc; return *this; }
+connection_options& connection_options::client_domain(const class client_domain &c) { impl_->client_domain = c; return *this; }
+connection_options& connection_options::server_domain(const class server_domain &c) { impl_->server_domain = c; return *this; }
+connection_options& connection_options::resume_id(const std::string &id) { impl_->resume_id = id; return *this; }
+connection_options& connection_options::peer_hostname(const std::string &name) { impl_->peer_hostname = name; return *this; }
 
 void connection_options::apply(connection& c) const { impl_->apply(c); }
+class client_domain &connection_options::client_domain() { return impl_->client_domain.value; }
+class server_domain &connection_options::server_domain() { return impl_->server_domain.value; }
 handler* connection_options::handler() const { return impl_->handler.value; }
 
 pn_connection_t* connection_options::pn_connection(connection &c) { return c.pn_object(); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/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 bb4f4c5..1ff734b 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -31,6 +31,7 @@
 #include "proton/sender.hpp"
 #include "proton/receiver.hpp"
 #include "proton/task.hpp"
+#include "proton/ssl.hpp"
 
 #include "msg.hpp"
 #include "container_impl.hpp"
@@ -186,28 +187,28 @@ receiver container_impl::open_receiver(const proton::url &url) {
 }
 
 acceptor container_impl::listen(const proton::url& url) {
-#ifdef PN_COMING_SOON
     connection_options opts = server_connection_options(); // Defaults
+#ifdef PN_COMING_SOON
     opts.override(user_opts);
+#endif
     handler *h = opts.handler();
     counted_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : counted_ptr<pn_handler_t>();
-    pn_acceptor_t *acptr = pn_reactor_acceptor(
-        pn_cast(reactor_.get()), url.host().c_str(), url.port().c_str(), chandler.get());
-#else
-    acceptor acptr = reactor_.listen(url);
-#endif
+    pn_acceptor_t *acptr = pn_reactor_acceptor(reactor_.pn_object(), url.host().c_str(), url.port().c_str(), chandler.get());
     if (!acptr)
         throw error(MSG("accept fail: " <<
                         pn_error_text(pn_io_error(reactor_.pn_io())))
                         << "(" << url << ")");
-#ifdef PN_COMING_SOON
+#ifdef PROTON_1054_FIXED
     // Do not use pn_acceptor_set_ssl_domain().  Manage the incoming connections ourselves for
     // more flexibility (i.e. ability to change the server cert for a long running listener).
     listener_context& lc(listener_context::get(acptr));
     lc.connection_options = opts;
     lc.ssl = url.scheme() == url::AMQPS;
+#else
+    if (url.scheme() == url::AMQPS)
+        pn_acceptor_set_ssl_domain(acptr, server_connection_options_.server_domain().pn_domain());
 #endif
-    return acptr;
+    return acceptor(acptr);
 }
 
 std::string container_impl::next_link_name() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/src/engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/engine.cpp b/proton-c/bindings/cpp/src/engine.cpp
index ad3d461..da3d0d9 100644
--- a/proton-c/bindings/cpp/src/engine.cpp
+++ b/proton-c/bindings/cpp/src/engine.cpp
@@ -57,7 +57,7 @@ struct engine::impl {
 };
 
 engine::engine(handler &h, const std::string& id_) : impl_(new impl(h, pn_transport())) {
-    if (!impl_->transport || !impl_->connection || !impl_->collector) 
+    if (!impl_->transport || !impl_->connection || !impl_->collector)
         throw error("engine setup failed");
     std::string id = id_.empty() ? uuid().str() : id_;
     pn_connection_set_container(impl_->connection, id.c_str());

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/src/ssl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl.cpp b/proton-c/bindings/cpp/src/ssl.cpp
new file mode 100644
index 0000000..4c9138e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ssl.cpp
@@ -0,0 +1,75 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include "proton/ssl.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+
+#include "proton/ssl.h"
+
+namespace proton {
+
+std::string ssl::cipher() const {
+    char buf[128];
+    if (pn_ssl_get_cipher_name(object_, buf, sizeof(buf)))
+        return std::string(buf);
+    return std::string();
+}
+
+int ssl::ssf() const {
+    return pn_ssl_get_ssf(object_);
+}
+
+std::string ssl::protocol() const {
+    char buf[128];
+    if (pn_ssl_get_protocol_name(object_, buf, sizeof(buf)))
+        return std::string(buf);
+    return std::string();
+}
+
+ssl::resume_status_t ssl::resume_status() const {
+    return (ssl::resume_status_t) pn_ssl_resume_status(object_);
+}
+
+void ssl::peer_hostname(const std::string &hostname) {
+    if (pn_ssl_set_peer_hostname(object_, hostname.c_str()))
+        throw error(MSG("SSL set peer hostname failure for " << hostname));
+}
+
+std::string ssl::peer_hostname() const {
+    std::string hostname;
+    size_t len = 0;
+    if (pn_ssl_get_peer_hostname(object_, NULL, &len) || len == 0)
+        return hostname;
+    hostname.reserve(len);
+    if (!pn_ssl_get_peer_hostname(object_, const_cast<char *>(hostname.data()), &len))
+        hostname.resize(len - 1);
+    else
+        hostname.resize(0);
+    return hostname;
+}
+
+std::string ssl::remote_subject() const {
+    const char *s = pn_ssl_get_remote_subject(object_);
+    return s ? std::string(s) : std::string();
+}
+
+
+} // namespace

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/src/ssl_domain.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp
new file mode 100644
index 0000000..ce50aa4
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ssl_domain.cpp
@@ -0,0 +1,113 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include "proton/ssl.hpp"
+#include "proton/error.hpp"
+#include "msg.hpp"
+
+#include "proton/ssl.h"
+
+namespace proton {
+
+ssl_domain::ssl_domain(bool server_type) {
+    impl_ = pn_ssl_domain(server_type ? PN_SSL_MODE_SERVER : PN_SSL_MODE_CLIENT);
+    if (!impl_) throw error(MSG("SSL/TLS unavailable"));
+}
+
+ssl_domain::~ssl_domain() { pn_ssl_domain_free(impl_); }
+
+namespace {
+void set_cred(pn_ssl_domain_t *dom, const std::string &main, const std::string &extra, const std::string &pass, bool pwset) {
+    const char *cred2 = extra.empty() ? NULL : extra.c_str();
+    const char *pw = pwset ? pass.c_str() : NULL;
+    if (pn_ssl_domain_set_credentials(dom, main.c_str(), cred2, pw))
+        throw error(MSG("SSL certificate initialization failure for " << main << ":" <<
+                        (cred2 ? cred2 : "NULL") << ":" << (pw ? pw : "NULL")));
+}
+}
+
+server_domain::server_domain(ssl_certificate &cert) :
+    ssl_domain_(new ssl_domain(true)) {
+    set_cred(ssl_domain_->impl_, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
+}
+
+server_domain::server_domain(ssl_certificate &cert, const std::string &trust_db, const std::string &advertise_db,
+                             ssl::verify_mode_t mode) :
+    ssl_domain_(new ssl_domain(true)) {
+    pn_ssl_domain_t *dom = ssl_domain_->impl_;
+    set_cred(dom, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
+    if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
+        throw error(MSG("SSL trust store initialization failure for " << trust_db));
+    const std::string &db = advertise_db.empty() ? trust_db : advertise_db;
+    if (pn_ssl_domain_set_peer_authentication(dom, (pn_ssl_verify_mode_t) mode, db.c_str()))
+        throw error(MSG("SSL server configuration failure requiring client certificates using " << db));
+}
+
+// Keep default constructor low overhead for default use in connection_options.
+server_domain::server_domain() : ssl_domain_(0) {}
+
+pn_ssl_domain_t* server_domain::pn_domain() {
+    if (!ssl_domain_) {
+        // Lazily create anonymous domain context (no cert).  Could make it a singleton, but rare use?
+        ssl_domain_.reset(new ssl_domain(true));
+    }
+    return ssl_domain_->impl_;
+}
+
+namespace {
+void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify_mode_t mode) {
+    if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
+        throw error(MSG("SSL trust store initialization failure for " << trust_db));
+    if (pn_ssl_domain_set_peer_authentication(dom, (pn_ssl_verify_mode_t) mode, NULL))
+        throw error(MSG("SSL client verify mode failure"));
+}
+}
+
+client_domain::client_domain(const std::string &trust_db, ssl::verify_mode_t mode) :
+    ssl_domain_(new ssl_domain(false)) {
+    client_setup(ssl_domain_->impl_, trust_db, mode);
+}
+
+client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db, ssl::verify_mode_t mode) :
+    ssl_domain_(new ssl_domain(false)) {
+    pn_ssl_domain_t *dom = ssl_domain_->impl_;
+    set_cred(dom, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
+    client_setup(dom, trust_db, mode);
+}
+
+client_domain::client_domain() : ssl_domain_(0) {}
+
+pn_ssl_domain_t* client_domain::pn_domain() {
+    if (!ssl_domain_) {
+        // Lazily create anonymous domain context (no CA).  Could make it a singleton, but rare use?
+        ssl_domain_.reset(new ssl_domain(false));
+    }
+    return ssl_domain_->impl_;
+}
+
+
+ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra)
+    : certdb_main_(main), certdb_extra_(extra), pw_set_(false) {}
+
+ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra, const std::string &pw)
+    : certdb_main_(main), certdb_extra_(extra), passwd_(pw), pw_set_(true) {}
+
+
+} // namespace

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf784e2a/proton-c/bindings/cpp/src/transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/transport.cpp b/proton-c/bindings/cpp/src/transport.cpp
index 0574663..f6ccfa0 100644
--- a/proton-c/bindings/cpp/src/transport.cpp
+++ b/proton-c/bindings/cpp/src/transport.cpp
@@ -20,6 +20,7 @@
  */
 #include "proton/transport.hpp"
 #include "proton/connection.hpp"
+#include "proton/ssl.hpp"
 #include "msg.hpp"
 #include "proton/transport.h"
 
@@ -29,6 +30,10 @@ connection transport::connection() const {
     return pn_transport_connection(pn_object());
 }
 
+class ssl transport::ssl() const {
+    return proton::ssl(pn_ssl(pn_object()));
+}
+
 void transport::unbind() {
     if (pn_transport_unbind(pn_object()))
         throw error(MSG("transport::unbind failed " << pn_error_text(pn_transport_error(pn_object()))));


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


[18/50] [abbrv] qpid-proton git commit: PROTON-1052: Make the exported API symbols more reasonable for ssl_domains.

Posted by ac...@apache.org.
PROTON-1052: Make the exported API symbols more reasonable for ssl_domains.


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

Branch: refs/heads/go1
Commit: bd9a41bf29124e8437683e1cffd1fda2aa8de902
Parents: f650d37
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Dec 10 17:01:42 2015 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Dec 10 17:01:42 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/ssl.hpp | 22 +++++++++++++++-------
 proton-c/bindings/cpp/src/ssl_domain.cpp     |  2 ++
 2 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bd9a41bf/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index d7cdfda..f1b5974 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -74,7 +74,7 @@ class ssl_certificate {
 // Base class for SSL configuration
 class ssl_domain {
   public:
-    PN_CPP_EXTERN ~ssl_domain();
+    ~ssl_domain();
 
   protected:
     ssl_domain();
@@ -83,13 +83,10 @@ class ssl_domain {
 
   private:
     pn_ssl_domain_t *impl_;
-
-  friend class connection_options;
-  friend class container_impl;
 };
 
 /** SSL/TLS configuration for inbound connections created from a listener */
-class server_domain : public ssl_domain {
+class server_domain : private ssl_domain {
   public:
     /** A server domain based on the supplied X509 certificate specifier. */
     PN_CPP_EXTERN server_domain(ssl_certificate &cert);
@@ -99,19 +96,30 @@ class server_domain : public ssl_domain {
                                 ssl::verify_mode_t mode = ssl::VERIFY_PEER);
     /** A server domain restricted to available anonymous cipher suites on the platform. */
     PN_CPP_EXTERN server_domain();
+
+    PN_CPP_EXTERN ~server_domain();
+
+  private:
+    // Bring pn_domain into scope and allow container_impl to use it
+    using ssl_domain::pn_domain;
+    friend class container_impl;
 };
 
 
 /** SSL/TLS configuration for outgoing connections created */
-class client_domain : public ssl_domain {
+class client_domain : private ssl_domain {
   public:
     PN_CPP_EXTERN client_domain(const std::string &trust_db, ssl::verify_mode_t = ssl::VERIFY_PEER_NAME);
     PN_CPP_EXTERN client_domain(ssl_certificate&, const std::string &trust_db, ssl::verify_mode_t = ssl::VERIFY_PEER_NAME);
     /** A client domain restricted to available anonymous cipher suites on the platform. */
     PN_CPP_EXTERN client_domain();
 
+    PN_CPP_EXTERN ~client_domain();
+
   private:
-    client_domain(ssl_domain);
+    // Bring pn_domain into scope and allow connection_options to use it
+    using ssl_domain::pn_domain;
+    friend class connection_options;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bd9a41bf/proton-c/bindings/cpp/src/ssl_domain.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp
index 8bb081f..2631880 100644
--- a/proton-c/bindings/cpp/src/ssl_domain.cpp
+++ b/proton-c/bindings/cpp/src/ssl_domain.cpp
@@ -71,6 +71,7 @@ server_domain::server_domain(
 }
 
 server_domain::server_domain() {}
+server_domain::~server_domain() {}
 
 namespace {
 void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify_mode_t mode) {
@@ -92,6 +93,7 @@ client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db,
 }
 
 client_domain::client_domain() {}
+client_domain::~client_domain() {}
 
 ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra)
     : certdb_main_(main), certdb_extra_(extra), pw_set_(false) {}


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


[30/50] [abbrv] qpid-proton git commit: PROTON-1049: allow username/password to be specified on conatiner or via keyword args to connect() method

Posted by ac...@apache.org.
PROTON-1049: allow username/password to be specified on conatiner or via keyword args to connect() method


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

Branch: refs/heads/go1
Commit: fefb81d2c506074cbb6d1eea9d8432ddd3e1fa53
Parents: 7ccd632
Author: Gordon Sim <gs...@redhat.com>
Authored: Tue Dec 15 21:26:50 2015 +0000
Committer: Gordon Sim <gs...@redhat.com>
Committed: Tue Dec 15 21:47:11 2015 +0000

----------------------------------------------------------------------
 proton-c/bindings/python/proton/reactor.py | 10 ++++++
 tests/python/proton_tests/reactor.py       | 41 ++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fefb81d2/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 0f59682..195ff28 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -500,6 +500,8 @@ class Connector(Handler):
         self.allow_insecure_mechs = True
         self.allowed_mechs = None
         self.sasl_enabled = True
+        self.user = None
+        self.password = None
 
     def _connect(self, connection):
         url = self.address.next()
@@ -513,8 +515,12 @@ class Connector(Handler):
             sasl.allow_insecure_mechs = self.allow_insecure_mechs
             if url.username:
                 connection.user = url.username
+            elif self.user:
+                connection.user = self.user
             if url.password:
                 connection.password = url.password
+            elif self.password:
+                connection.password = self.password
             if self.allowed_mechs:
                 sasl.allowed_mechs(self.allowed_mechs)
         transport.bind(connection)
@@ -625,6 +631,8 @@ class Container(Reactor):
             self.allow_insecure_mechs = True
             self.allowed_mechs = None
             self.sasl_enabled = True
+            self.user = None
+            self.password = None
             Wrapper.__setattr__(self, 'subclass', self.__class__)
 
     def connect(self, url=None, urls=None, address=None, handler=None, reconnect=None, heartbeat=None, ssl_domain=None, **kwargs):
@@ -668,6 +676,8 @@ class Container(Reactor):
         connector.allow_insecure_mechs = kwargs.get('allow_insecure_mechs', self.allow_insecure_mechs)
         connector.allowed_mechs = kwargs.get('allowed_mechs', self.allowed_mechs)
         connector.sasl_enabled = kwargs.get('sasl_enabled', self.sasl_enabled)
+        connector.user = kwargs.get('user', self.user)
+        connector.password = kwargs.get('password', self.password)
         conn._overrides = connector
         if url: connector.address = Urls([url])
         elif urls: connector.address = Urls(urls)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fefb81d2/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index c58530a..e8446ca 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -459,10 +459,29 @@ class ApplicationEventTest(Test):
         self._wait_for(lambda: self.goodbye_rcvd is not None)
 
 
+class AuthenticationTestHandler(MessagingHandler):
+    def __init__(self):
+        super(AuthenticationTestHandler, self).__init__()
+        port = free_tcp_port()
+        self.url = "localhost:%i" % port
+
+    def on_start(self, event):
+        self.listener = event.container.listen(self.url)
+
+    def on_connection_opened(self, event):
+        event.connection.close()
+
+    def on_connection_opening(self, event):
+        assert event.connection.transport.user == "user@proton"
+
+    def on_connection_closed(self, event):
+        event.connection.close()
+        self.listener.close()
+
 class ContainerTest(Test):
     """Test container subclass of reactor."""
 
-    def test_event_container(self):
+    def test_event_has_container_attribute(self):
         class TestHandler(MessagingHandler):
             def __init__(self):
                 super(TestHandler, self).__init__()
@@ -487,3 +506,23 @@ class ContainerTest(Test):
                 assert event.container == container
         container.connect(test_handler.url, handler=ConnectionHandler())
         container.run()
+
+    def test_authentication_via_url(self):
+        test_handler = AuthenticationTestHandler()
+        container = Container(test_handler)
+        container.connect("%s:password@%s" % ("user%40proton", test_handler.url))
+        container.run()
+
+    def test_authentication_via_container_attributes(self):
+        test_handler = AuthenticationTestHandler()
+        container = Container(test_handler)
+        container.user = "user@proton"
+        container.password = "password"
+        container.connect(test_handler.url)
+        container.run()
+
+    def test_authentication_via_kwargs(self):
+        test_handler = AuthenticationTestHandler()
+        container = Container(test_handler)
+        container.connect(test_handler.url, user="user@proton", password="password")
+        container.run()


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


[08/50] [abbrv] qpid-proton git commit: NO-JIRA: c++: remove bogus events from C++ biding.

Posted by ac...@apache.org.
NO-JIRA: c++: remove bogus events from C++ biding.


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

Branch: refs/heads/go1
Commit: 1ccaf70fbd2d10db298581ab8d885744f0b66983
Parents: 0ebf1d4
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 2 12:19:05 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 2 12:19:18 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/messaging_handler.hpp | 5 -----
 proton-c/bindings/cpp/src/messaging_event.cpp              | 7 -------
 proton-c/bindings/cpp/src/messaging_event.hpp              | 7 -------
 proton-c/bindings/cpp/src/messaging_handler.cpp            | 5 -----
 4 files changed, 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1ccaf70f/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
index e19739e..8fac665 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
@@ -58,19 +58,14 @@ class messaging_handler : public proton_handler
     PN_CPP_EXTERN virtual void on_connection_opening(event &e);
     PN_CPP_EXTERN virtual void on_connection_opened(event &e);
     PN_CPP_EXTERN virtual void on_disconnected(event &e);
-    PN_CPP_EXTERN virtual void on_id_loaded(event &e);
     PN_CPP_EXTERN virtual void on_link_closed(event &e);
     PN_CPP_EXTERN virtual void on_link_closing(event &e);
     PN_CPP_EXTERN virtual void on_link_error(event &e);
     PN_CPP_EXTERN virtual void on_link_opened(event &e);
     PN_CPP_EXTERN virtual void on_link_opening(event &e);
     PN_CPP_EXTERN virtual void on_message(event &e);
-    PN_CPP_EXTERN virtual void on_record_inserted(event &e);
-    PN_CPP_EXTERN virtual void on_records_loaded(event &e);
     PN_CPP_EXTERN virtual void on_rejected(event &e);
     PN_CPP_EXTERN virtual void on_released(event &e);
-    PN_CPP_EXTERN virtual void on_request(event &e);
-    PN_CPP_EXTERN virtual void on_response(event &e);
     PN_CPP_EXTERN virtual void on_sendable(event &e);
     PN_CPP_EXTERN virtual void on_session_closed(event &e);
     PN_CPP_EXTERN virtual void on_session_closing(event &e);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1ccaf70f/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index b1fedc3..d0ae0f8 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -155,7 +155,6 @@ void messaging_event::dispatch(handler &h) {
 std::string messaging_event::name() const {
     switch (type()) {
       case PROTON: return pn_event_type_name(pn_event_type_t(proton_event::type()));
-      case ABORT: return "ABORT";
       case ACCEPTED: return "ACCEPTED";
       case COMMIT: return "COMMIT";
       case CONNECTION_CLOSED: return "CONNECTION_CLOSED";
@@ -164,8 +163,6 @@ std::string messaging_event::name() const {
       case CONNECTION_OPENED: return "CONNECTION_OPENED";
       case CONNECTION_OPENING: return "CONNECTION_OPENING";
       case DISCONNECTED: return "DISCONNECTED";
-      case FETCH: return "FETCH";
-      case ID_LOADED: return "ID_LOADED";
       case LINK_CLOSED: return "LINK_CLOSED";
       case LINK_CLOSING: return "LINK_CLOSING";
       case LINK_OPENED: return "LINK_OPENED";
@@ -173,12 +170,8 @@ std::string messaging_event::name() const {
       case LINK_ERROR: return "LINK_ERROR";
       case MESSAGE: return "MESSAGE";
       case QUIT: return "QUIT";
-      case RECORD_INSERTED: return "RECORD_INSERTED";
-      case RECORDS_LOADED: return "RECORDS_LOADED";
       case REJECTED: return "REJECTED";
       case RELEASED: return "RELEASED";
-      case REQUEST: return "REQUEST";
-      case RESPONSE: return "RESPONSE";
       case SENDABLE: return "SENDABLE";
       case SESSION_CLOSED: return "SESSION_CLOSED";
       case SESSION_CLOSING: return "SESSION_CLOSING";

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1ccaf70f/proton-c/bindings/cpp/src/messaging_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.hpp b/proton-c/bindings/cpp/src/messaging_event.hpp
index 7d85d2b..2c90c0b 100644
--- a/proton-c/bindings/cpp/src/messaging_event.hpp
+++ b/proton-c/bindings/cpp/src/messaging_event.hpp
@@ -44,7 +44,6 @@ class messaging_event : public proton_event
     /** Event types for a messaging_handler */
     enum event_type {
         PROTON = 0,  // Wrapped pn_event_t
-        ABORT,
         ACCEPTED,
         COMMIT,
         CONNECTION_CLOSED,
@@ -53,8 +52,6 @@ class messaging_event : public proton_event
         CONNECTION_OPENED,
         CONNECTION_OPENING,
         DISCONNECTED,
-        FETCH,
-        ID_LOADED,
         LINK_CLOSED,
         LINK_CLOSING,
         LINK_OPENED,
@@ -62,12 +59,8 @@ class messaging_event : public proton_event
         LINK_ERROR,
         MESSAGE,
         QUIT,
-        RECORD_INSERTED,
-        RECORDS_LOADED,
         REJECTED,
         RELEASED,
-        REQUEST,
-        RESPONSE,
         SENDABLE,
         SESSION_CLOSED,
         SESSION_CLOSING,

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1ccaf70f/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 babe458..9496440 100644
--- a/proton-c/bindings/cpp/src/messaging_handler.cpp
+++ b/proton-c/bindings/cpp/src/messaging_handler.cpp
@@ -88,19 +88,14 @@ void messaging_handler::on_connection_error(event &e) { on_unhandled(e); }
 void messaging_handler::on_connection_opened(event &e) { on_unhandled(e); }
 void messaging_handler::on_connection_opening(event &e) { on_unhandled(e); }
 void messaging_handler::on_disconnected(event &e) { on_unhandled(e); }
-void messaging_handler::on_id_loaded(event &e) { on_unhandled(e); }
 void messaging_handler::on_link_closed(event &e) { on_unhandled(e); }
 void messaging_handler::on_link_closing(event &e) { on_unhandled(e); }
 void messaging_handler::on_link_error(event &e) { on_unhandled(e); }
 void messaging_handler::on_link_opened(event &e) { on_unhandled(e); }
 void messaging_handler::on_link_opening(event &e) { on_unhandled(e); }
 void messaging_handler::on_message(event &e) { on_unhandled(e); }
-void messaging_handler::on_record_inserted(event &e) { on_unhandled(e); }
-void messaging_handler::on_records_loaded(event &e) { on_unhandled(e); }
 void messaging_handler::on_rejected(event &e) { on_unhandled(e); }
 void messaging_handler::on_released(event &e) { on_unhandled(e); }
-void messaging_handler::on_request(event &e) { on_unhandled(e); }
-void messaging_handler::on_response(event &e) { on_unhandled(e); }
 void messaging_handler::on_sendable(event &e) { on_unhandled(e); }
 void messaging_handler::on_session_closed(event &e) { on_unhandled(e); }
 void messaging_handler::on_session_closing(event &e) { on_unhandled(e); }


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


[10/50] [abbrv] qpid-proton git commit: PROTON-1068: c++ remove counted_ptr and context types from public API

Posted by ac...@apache.org.
PROTON-1068: c++ remove counted_ptr and context types from public API

- got rid of proton::counted base class
- remove mention of internal context types and functions from public headers.
- c++ rename data::op==, = and < to avoid clashes with object<> ops.
- replace complex exteranl counted_ptr with simple, internal-only pn_ptr
- simpler pn_class for C++ contexts, holds C++ value without an extra allocation.
- removed operator bool, made op == and < operators friends
- removed owned_object<>: equivalent to "take_ownership" constructor and move operator.


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

Branch: refs/heads/go1
Commit: 5045ec0320441089fe61d4b338d3b89da77da45a
Parents: 8501509
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Nov 27 12:43:49 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 4 11:43:14 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   1 -
 .../cpp/include/proton/blocking_link.hpp        |   1 -
 .../bindings/cpp/include/proton/connection.hpp  |  12 +-
 .../bindings/cpp/include/proton/counted.hpp     |  48 --------
 .../bindings/cpp/include/proton/counted_ptr.hpp | 117 -------------------
 proton-c/bindings/cpp/include/proton/data.hpp   |  17 +--
 .../bindings/cpp/include/proton/handler.hpp     |   3 +-
 proton-c/bindings/cpp/include/proton/object.hpp | 105 ++++++-----------
 .../bindings/cpp/include/proton/reactor.hpp     |   7 +-
 proton-c/bindings/cpp/include/proton/value.hpp  |   4 +-
 proton-c/bindings/cpp/src/connection.cpp        |   9 +-
 .../bindings/cpp/src/connection_options.cpp     |   3 +-
 proton-c/bindings/cpp/src/container_impl.cpp    |  41 +++----
 proton-c/bindings/cpp/src/container_impl.hpp    |   2 +-
 proton-c/bindings/cpp/src/contexts.cpp          |  82 +++++--------
 proton-c/bindings/cpp/src/contexts.hpp          |  51 +++++---
 proton-c/bindings/cpp/src/counted_ptr.cpp       |  32 -----
 proton-c/bindings/cpp/src/data.cpp              |   8 +-
 proton-c/bindings/cpp/src/decoder.cpp           |   2 +-
 proton-c/bindings/cpp/src/encoder.cpp           |   2 +-
 proton-c/bindings/cpp/src/link.cpp              |   4 +-
 proton-c/bindings/cpp/src/message.cpp           |   8 +-
 proton-c/bindings/cpp/src/messaging_adapter.cpp |   2 +-
 proton-c/bindings/cpp/src/object.cpp            |   8 +-
 proton-c/bindings/cpp/src/reactor.cpp           |   9 +-
 proton-c/bindings/cpp/src/session.cpp           |   2 +-
 proton-c/bindings/cpp/src/value.cpp             |   8 +-
 27 files changed, 170 insertions(+), 418 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index bcdc61b..6352f66 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -37,7 +37,6 @@ set(qpid-proton-cpp-source
   src/connector.cpp
   src/container.cpp
   src/container_impl.cpp
-  src/counted_ptr.cpp
   src/contexts.cpp
   src/data.cpp
   src/decoder.cpp

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/blocking_link.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/blocking_link.hpp b/proton-c/bindings/cpp/include/proton/blocking_link.hpp
index 2b0a089..ba584af 100644
--- a/proton-c/bindings/cpp/include/proton/blocking_link.hpp
+++ b/proton-c/bindings/cpp/include/proton/blocking_link.hpp
@@ -22,7 +22,6 @@
  *
  */
 #include "proton/export.hpp"
-#include "proton/counted_ptr.hpp"
 #include "proton/duration.hpp"
 #include "proton/link.hpp"
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp
index 338e542..7a9cf74 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -34,7 +34,6 @@ struct pn_connection_t;
 
 namespace proton {
 
-struct connection_context;
 class handler;
 class engine;
 
@@ -44,9 +43,6 @@ class connection : public object<pn_connection_t>, endpoint
   public:
     connection(pn_connection_t* c=0) : object<pn_connection_t>(c) {}
 
-    /// Get the connection context object from the connection
-    PN_CPP_EXTERN connection_context& context() const;
-
     /// Get the event_loop, can be a container or an engine.
     PN_CPP_EXTERN class event_loop &event_loop() const;
 
@@ -111,10 +107,10 @@ class connection : public object<pn_connection_t>, endpoint
     PN_CPP_EXTERN void user(const std::string &);
     PN_CPP_EXTERN void password(const std::string &);
 
-    
-    friend class connection_options;
-    friend class connector;
-    friend class transport;
+  friend class connection_context;
+  friend class connection_options;
+  friend class connector;
+  friend class transport;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/counted.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/counted.hpp b/proton-c/bindings/cpp/include/proton/counted.hpp
deleted file mode 100644
index 2195d93..0000000
--- a/proton-c/bindings/cpp/include/proton/counted.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef COUNTED_HPP
-#define COUNTED_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-namespace proton {
-
-/// Base class for reference counted objects other than proton struct facade types.
-class counted {
-  protected:
-    counted() : refcount_(0) {}
-    virtual ~counted() {}
-
-  private:
-    counted(const counted&);
-    counted& operator=(const counted&);
-    mutable int refcount_;
-
-    // TODO aconway 2015-08-27: atomic operations.
-    void incref() const { ++refcount_; }
-    void decref() const { if (--refcount_ == 0) delete this; }
-
-  friend void incref(const counted*);
-  friend void decref(const counted*);
-  template <class T> friend class counted_ptr;
-};
-
-inline void incref(const counted* p) { if (p) p->incref(); }
-inline void decref(const counted* p) { if (p) p->decref(); }
-
-}
-#endif // COUNTED_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/counted_ptr.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/counted_ptr.hpp b/proton-c/bindings/cpp/include/proton/counted_ptr.hpp
deleted file mode 100644
index 0865e4a..0000000
--- a/proton-c/bindings/cpp/include/proton/counted_ptr.hpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#ifndef COUNTED_PTR_HPP
-#define COUNTED_PTR_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/config.hpp"
-#include "proton/comparable.hpp"
-
-#if PN_HAS_BOOST
-#include <boost/shared_ptr.hpp>
-#include <boost/intrusive_ptr.hpp>
-#endif
-
-#include <memory>
-
-namespace proton {
-
-///@cond INTERNAL
-
-// Default refcounting uses pn_incref, pn_decref. Other types must define
-// their own incref/decref overloads.
-PN_CPP_EXTERN void incref(const void*);
-PN_CPP_EXTERN void decref(const void*);
-
-///@endcond
-
-/**
- * Smart pointer for reference counted objects derived from `proton::counted`
- * or `proton::pn_counted`
- */
-template <class T> class counted_ptr : public proton::comparable<counted_ptr<T> > {
-  public:
-    typedef T element_type;
-
-    explicit counted_ptr(T *p = 0, bool add_ref = true) : ptr_(p) {
-        if (add_ref) incref(ptr_);
-    }
-
-    counted_ptr(const counted_ptr<T>& p) : ptr_(p.ptr_) { incref(ptr_); }
-
-    // TODO aconway 2015-08-20: C++11 move constructor
-
-    ~counted_ptr() { decref(ptr_); }
-
-    void swap(counted_ptr& x) { std::swap(ptr_, x.ptr_); }
-
-    counted_ptr<T>& operator=(const counted_ptr<T>& p) {
-        counted_ptr<T>(p.get()).swap(*this);
-        return *this;
-    }
-
-    void reset(T* p=0, bool add_ref = true) {
-        counted_ptr<T>(p, add_ref).swap(*this);
-    }
-
-    T* release() {
-        T* ret = ptr_;
-        ptr_ = 0;
-        return ret;
-    }
-
-    T* get() const { return ptr_; }
-    T* operator->() const { return ptr_; }
-    T& operator*() const { return *ptr_; }
-    operator bool() const { return !!ptr_; }
-    bool operator!() const { return !ptr_; }
-
-    template <class U> operator counted_ptr<U>() const { return counted_ptr<U>(get()); }
-    template <class U> bool operator==(const counted_ptr<U>& x) { return get() == x.get(); }
-    template <class U> bool operator<(const counted_ptr<U>& x) { return get() < x.get(); }
-
-#if PN_HAS_STD_PTR
-    // TODO aconway 2015-08-21: need weak pointer context for efficient shared_ptr
-    operator std::shared_ptr<T>() { return std::shared_ptr<T>(dup()); }
-    operator std::shared_ptr<const T>() const { return std::shared_ptr<const T>(dup()); }
-    operator std::unique_ptr<T>() { return std::unique_ptr<T>(dup()); }
-    operator std::unique_ptr<const T>() const { return std::unique_ptr<const T>(dup()); }
-#endif
-#if PN_HAS_BOOST
-    // TODO aconway 2015-08-21: need weak pointer context for efficient shared_ptr
-    operator boost::shared_ptr<T>() { return boost::shared_ptr<T>(dup()); }
-    operator boost::shared_ptr<const T>() const { return boost::shared_ptr<const T>(dup()); }
-    operator boost::intrusive_ptr<T>() { return boost::intrusive_ptr<T>(ptr_); }
-    operator boost::intrusive_ptr<const T>() const { return boost::intrusive_ptr<const T>(ptr_); }
-#endif
-
-  private:
-    T* dup() { incref(ptr_); return ptr_; }
-    const T* dup() const { incref(ptr_); return ptr_; }
-
-    T* ptr_;
-};
-
-#if PN_HAS_BOOST
-template <class T> inline void intrusive_ptr_add_ref(const T* p) { if (p) incref(p); }
-template <class T> inline void intrusive_ptr_release(const T* p) { if (p) decref(p); }
-#endif
-
-}
-
-#endif // COUNTED_PTR_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index e74b77b..c2ffd3c 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -40,15 +40,15 @@ class data;
 class data : public object<pn_data_t> {
   public:
     data(pn_data_t* d) : object<pn_data_t>(d) {}
-    data(owned_object<pn_data_t> d) : object<pn_data_t>(d) {}
 
-    PN_CPP_EXTERN static owned_object<pn_data_t> create();
+    data& operator=(const data&);      // FIXME aconway 2015-12-01:
 
-    PN_CPP_EXTERN data& operator=(const data&);
+    PN_CPP_EXTERN static data create();
 
-    template<class T> data& operator=(const T &t) {
-        clear(); encoder() << t; return *this;
-    }
+    // Copy the contents of another data object t this one.
+    PN_CPP_EXTERN data& copy(const data&);
+
+    template<class T> data& copy(T &t) { clear(); encoder() << t; return *this; }
 
     /** Clear the data. */
     PN_CPP_EXTERN void clear();
@@ -86,13 +86,14 @@ class data : public object<pn_data_t> {
 
     template<class T> T get() const { T t; get(t); return t; }
 
-    PN_CPP_EXTERN bool operator==(const data& x) const;
-    PN_CPP_EXTERN bool operator<(const data& x) const;
+    PN_CPP_EXTERN bool equal(const data& x) const;
+    PN_CPP_EXTERN bool less(const data& x) const;
 
     /** Human readable representation of data. */
   friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&);
   friend class value;
   private:
+    data(pn_ptr<pn_data_t> d) : object<pn_data_t>(d) {}
     class decoder decoder() const { return const_cast<data*>(this)->decoder(); }
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
index 70da48b..6680d70 100644
--- a/proton-c/bindings/cpp/include/proton/handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -22,7 +22,6 @@
  *
  */
 #include "proton/export.hpp"
-#include "proton/counted_ptr.hpp"
 #include "proton/event.hpp"
 #include "proton/event.h"
 #include "proton/reactor.h"
@@ -58,7 +57,7 @@ class handler : public std::vector<handler*> {
     PN_CPP_EXTERN virtual void add_child_handler(handler &h);
 
   private:
-    counted_ptr<pn_handler_t> pn_handler_;
+    pn_ptr<pn_handler_t> pn_handler_;
     friend class container_impl;
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index 118f40d..0da20ae 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -21,93 +21,64 @@
 
 #include "proton/config.hpp"
 #include "proton/export.hpp"
+#include "proton/comparable.hpp"
 
 #include <memory>
 
 namespace proton {
 
-/**
- * Base class for proton object types
- *
- * Automatically perform memory management for pn_object based types.
- *
- * Note that for the memory management to work correctly no class
- * inheriting from this should define any data members of its own.
- * 
- * This is ok because the entire purpose of this class is to provide
- * and manage the underlying pointer to the proton-c object.
- * 
- * So any class using this one needs to be merely a thin wrapping of
- * the proton-c object with no data members of it's own. Anything that internally
- * needs extra data members and a proton-c object must use an inheritor of
- * object<> as a data member - it must not inherit and add data members.
- * 
- */
-class object_base {
-  public:
-    object_base() : object_(0) {}
-    object_base(void* o) : object_(o) {}
-    object_base(const object_base& o) : object_(o.object_) { incref(); }
-
-    #ifdef PN_HAS_CPP11
-    object_base(object_base&& o) : object_base() { *this = o; }
-    #endif
+///@cond INTERNAL
+class pn_ptr_base {
+  protected:
+    static void incref(void* p);
+    static void decref(void* p);
+};
 
-    ~object_base() { decref(); };
+template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_base {
+  public:
+    pn_ptr() : ptr_(0) {}
+    pn_ptr(T* p) : ptr_(p) { incref(ptr_); }
+    pn_ptr(const pn_ptr& o) : ptr_(o.ptr_) { incref(ptr_); }
 
-    object_base& operator=(object_base o)
-    { std::swap(object_, o.object_); return *this; }
+#ifdef PN_HAS_CPP11
+    pn_ptr(pn_ptr&& o) : ptr_(0) { std::swap(ptr_, o.ptr_); }
+#endif
 
-    bool operator!() const { return !object_; }
+    ~pn_ptr() { decref(ptr_); };
 
-  private:
-    PN_CPP_EXTERN void incref() const;
-    PN_CPP_EXTERN void decref() const;
+    static pn_ptr<T> take(T* p) { return pn_ptr<T>(p, true); }
 
-    void* object_;
+    pn_ptr& operator=(pn_ptr o) { std::swap(ptr_, o.ptr_); return *this; }
 
-  template <class T>
-  friend class object;
-  template <class T>
-  friend class owned_object;
-  friend bool operator==(const object_base&, const object_base&);
-};
+    T* get() const { return ptr_; }
+    bool operator!() const { return !ptr_; }
 
-template <class T>
-class owned_object : public object_base {
-  public:
-    owned_object(T* o) : object_base(o) {};
+  friend bool operator==(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ == b.ptr_; }
+  friend bool operator<(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ < b.ptr_; }
 
-  protected:
-    T* pn_object() const { return static_cast<T*>(object_); }
-
-  template <class U>
-  friend class object;
+  private:
+    pn_ptr(T* p, bool) : ptr_(p) {}
+    T *ptr_;
 };
+///@endcond INTERNAL
 
-template <class T>
-class object : public object_base {
+/**
+ * Base class for proton object types
+ */
+template <class T> class object : public comparable<object<T> > {
   public:
-    object(T* o, bool take_own=false) : object_base(o) { if (!take_own) incref(); };
-    object(owned_object<T> o) : object_base(o.object_) { o.object_=0; };
+    bool operator!() const { return !object_; }
 
-    object& operator=(owned_object<T> o)
-    { object_ = o.object_; o = 0; return *this; }
+  friend bool operator==(const object& a, const object& b) { return a.object_ == b.object_; }
+  friend bool operator<(const object& a, const object& b) { return a.object_ < b.object_; }
 
   protected:
-    static const bool take_ownership = true;
-    T* pn_object() const { return static_cast<T*>(object_); }
-};
-
-inline
-bool operator==(const object_base& o1, const object_base& o2) {
-    return o1.object_==o2.object_;
-}
+    object(pn_ptr<T> o) : object_(o) {}
+    T* pn_object() const { return object_.get(); }
 
-inline
-bool operator!=(const object_base& o1, const object_base& o2) {
-    return !(o1==o2);
-}
+  private:
+    pn_ptr<T> object_;
+};
 
 }
 #endif // OBJECT_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reactor.hpp b/proton-c/bindings/cpp/include/proton/reactor.hpp
index fa7d633..7592a14 100644
--- a/proton-c/bindings/cpp/include/proton/reactor.hpp
+++ b/proton-c/bindings/cpp/include/proton/reactor.hpp
@@ -67,7 +67,7 @@ class reactor : public object<pn_reactor_t> {
 
     PN_CPP_EXTERN amqp_timestamp mark();
     PN_CPP_EXTERN amqp_timestamp now();
-    
+
     PN_CPP_EXTERN task schedule(int, pn_handler_t*);
 
     class connection connection(pn_handler_t*) const;
@@ -86,9 +86,8 @@ class reactor : public object<pn_reactor_t> {
     PN_CPP_EXTERN bool quiesced();
     PN_CPP_EXTERN void yield();
 
-    void container_context(container&);
-
-    friend class container_impl;
+  friend class container_impl;
+  friend class container_context;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index 661de51..c33eea1 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -46,10 +46,10 @@ class value : public comparable<value> {
     PN_CPP_EXTERN value(const value& x);
     // TODO: Should enumerate specifically all the pointer types that can convert to value
     // to avoid accidental conversions to bool this will require enable_if<> or the like
-    template <class T> value(const T& x) : data_(data::create()) { data_ = x; }
+    template <class T> value(const T& x) : data_(data::create()) { data_.copy(x); }
 
     PN_CPP_EXTERN value& operator=(const value& x);
-    template <class T> value& operator=(const T& x) { data_ = x; return *this; }
+    template <class T> value& operator=(const T& x) { data_.copy(x); return *this; }
 
     PN_CPP_EXTERN void clear();
     PN_CPP_EXTERN bool empty() const;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/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 508a013..41c56f6 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -38,14 +38,13 @@
 
 namespace proton {
 
-connection_context& connection::context() const { return connection_context::get(pn_object()); }
-
 transport connection::transport() const {
     return pn_connection_transport(pn_object());
 }
 
 void connection::open() {
-    connector *connector = dynamic_cast<class connector*>(context().handler.get());
+    connector *connector = dynamic_cast<class connector*>(
+        connection_context::get(pn_object()).handler.get());
     if (connector)
         connector->apply_options();
     // Inbound connections should already be configured.
@@ -74,7 +73,7 @@ void connection::container_id(const std::string& id) {
 }
 
 container& connection::container() const {
-    return container_context(pn_object_reactor(pn_object()));
+    return container_context::get(pn_object_reactor(pn_object()));
 }
 
 link_range connection::find_links(endpoint::state mask) const {
@@ -88,7 +87,7 @@ session_range connection::find_sessions(endpoint::state mask) const {
 session connection::open_session() { return pn_session(pn_object()); }
 
 session connection::default_session() {
-    struct connection_context& ctx = connection_context::get(pn_object());
+    connection_context& ctx = connection_context::get(pn_object());
     if (!ctx.default_session) {
         // Note we can't use a proton::session here because we don't want to own
         // a session reference. The connection owns the session, owning it here as well

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 141ffc9..6b72c9c 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -62,7 +62,8 @@ class connection_options::impl {
     void apply(connection& c) {
         pn_connection_t *pnc = connection_options::pn_connection(c);
         pn_transport_t *pnt = pn_connection_transport(pnc);
-        connector *outbound = dynamic_cast<connector*>(c.context().handler.get());
+        connector *outbound = dynamic_cast<connector*>(
+            connection_context::get(c).handler.get());
         bool uninit = (c.state() & endpoint::LOCAL_UNINIT);
 
         // pnt is NULL between reconnect attempts.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/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 7d64ebc..f83e0a6 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -81,7 +81,7 @@ struct handler_context {
 class override_handler : public handler
 {
   public:
-    counted_ptr<pn_handler_t> base_handler;
+    pn_ptr<pn_handler_t> base_handler;
     container_impl &container_impl_;
 
     override_handler(pn_handler_t *h, container_impl &c) : base_handler(h), container_impl_(c) {}
@@ -113,19 +113,17 @@ class override_handler : public handler
 
 } // namespace
 
-counted_ptr<pn_handler_t> container_impl::cpp_handler(handler *h)
-{
-    if (h->pn_handler_)
-        return h->pn_handler_;
-    counted_ptr<pn_handler_t> handler(
-        pn_handler_new(&handler_context::dispatch, sizeof(struct handler_context),
-                       &handler_context::cleanup),
-        false);
-    handler_context &hc = handler_context::get(handler.get());
-    hc.container_ = &container_;
-    hc.handler_ = h;
-    h->pn_handler_ = handler;
-    return handler;
+pn_ptr<pn_handler_t> container_impl::cpp_handler(handler *h) {
+    if (!h->pn_handler_) {
+        h->pn_handler_ = pn_ptr<pn_handler_t>::take(
+            pn_handler_new(&handler_context::dispatch,
+                           sizeof(struct handler_context),
+                           &handler_context::cleanup));
+        handler_context &hc = handler_context::get(h->pn_handler_.get());
+        hc.container_ = &container_;
+        hc.handler_ = h;
+    }
+    return h->pn_handler_;
 }
 
 container_impl::container_impl(container& c, handler *h, const std::string& id) :
@@ -133,16 +131,15 @@ container_impl::container_impl(container& c, handler *h, const std::string& id)
     link_id_(0)
 {
     if (id_.empty()) id_ = uuid().str();
-    reactor_.container_context(container_);
+    container_context::set(reactor_, container_);
 
     // Set our own global handler that "subclasses" the existing one
     pn_handler_t *global_handler = reactor_.pn_global_handler();
     override_handler_.reset(new override_handler(global_handler, *this));
-    counted_ptr<pn_handler_t> cpp_global_handler(cpp_handler(override_handler_.get()));
+    pn_ptr<pn_handler_t> cpp_global_handler(cpp_handler(override_handler_.get()));
     reactor_.pn_global_handler(cpp_global_handler.get());
     if (handler_) {
-        counted_ptr<pn_handler_t> pn_handler(cpp_handler(handler_));
-        reactor_.pn_handler(pn_handler.get());
+        reactor_.pn_handler(cpp_handler(handler_).get());
     }
 
 
@@ -159,11 +156,11 @@ connection container_impl::connect(const proton::url &url, const connection_opti
     opts.override(user_opts);
     handler *h = opts.handler();
 
-    counted_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : counted_ptr<pn_handler_t>();
+    pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : pn_ptr<pn_handler_t>();
     connection conn(reactor_.connection(chandler.get()));
     pn_unique_ptr<connector> ctor(new connector(conn, opts));
     ctor->address(url);  // TODO: url vector
-    connection_context& cc(conn.context());
+    connection_context& cc(connection_context::get(conn));
     cc.container_impl = this;
     cc.handler.reset(ctor.release());
     conn.open();
@@ -194,7 +191,7 @@ acceptor container_impl::listen(const proton::url& url) {
     opts.override(user_opts);
 #endif
     handler *h = opts.handler();
-    counted_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : counted_ptr<pn_handler_t>();
+    pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : pn_ptr<pn_handler_t>();
     pn_acceptor_t *acptr = pn_reactor_acceptor(reactor_.pn_object(), url.host().c_str(), url.port().c_str(), chandler.get());
     if (!acptr)
         throw error(MSG("accept fail: " <<
@@ -221,7 +218,7 @@ std::string container_impl::next_link_name() {
 }
 
 task container_impl::schedule(int delay, handler *h) {
-    counted_ptr<pn_handler_t> task_handler;
+    pn_ptr<pn_handler_t> task_handler;
     if (h)
         task_handler = cpp_handler(h);
     return reactor_.schedule(delay, task_handler.get());

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index d9401d0..4a89ab3 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -62,7 +62,7 @@ class container_impl
 
     void configure_server_connection(connection &c);
     task schedule(int delay, handler *h);
-    counted_ptr<pn_handler_t> cpp_handler(handler *h);
+    pn_ptr<pn_handler_t> cpp_handler(handler *h);
 
     std::string next_link_name();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/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 4d17e54..0ea4262 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -30,87 +30,63 @@
 #include "proton/session.h"
 #include "proton/link.h"
 
+#include <typeinfo>
+
 namespace proton {
 
 namespace {
-
-// A proton class for counted c++ objects used as proton attachments
-extern pn_class_t* COUNTED_CONTEXT;
-#define CID_cpp_context CID_pn_void
-static const pn_class_t *cpp_context_reify(void *object) { return COUNTED_CONTEXT; }
-#define cpp_context_new NULL
-#define cpp_context_free NULL
+void cpp_context_finalize(void* v) { reinterpret_cast<context*>(v)->~context(); }
+#define CID_cpp_context CID_pn_object
+#define cpp_context_reify pn_object_reify
 #define cpp_context_initialize NULL
-void cpp_context_incref(void* p) { proton::incref(reinterpret_cast<counted*>(p)); }
-void cpp_context_decref(void* p) { proton::decref(reinterpret_cast<counted*>(p)); }
-// Always return 1 to prevent the class finalizer logic running after we are deleted.
-int cpp_context_refcount(void* p) { return 1; }
-#define cpp_context_finalize NULL
+#define cpp_context_finalize cpp_context_finalize
 #define cpp_context_hashcode NULL
 #define cpp_context_compare NULL
 #define cpp_context_inspect NULL
+pn_class_t cpp_context_class = PN_CLASS(cpp_context);
 
-pn_class_t COUNTED_CONTEXT_ = PN_METACLASS(cpp_context);
-pn_class_t *COUNTED_CONTEXT = &COUNTED_CONTEXT_;
+// Handles
+PN_HANDLE(CONNECTION_CONTEXT)
+PN_HANDLE(CONTAINER_CONTEXT)
 }
 
+context::~context() {}
+void *context::alloc(size_t n) { return pn_object_new(&cpp_context_class, n); }
+pn_class_t* context::pn_class() { return &cpp_context_class; }
 
-void set_context(pn_record_t* record, pn_handle_t handle, counted* value)
+void set_context(pn_record_t* record, pn_handle_t handle, const pn_class_t *clazz, void* value)
 {
-    pn_record_def(record, handle, COUNTED_CONTEXT);
+    pn_record_def(record, handle, clazz);
     pn_record_set(record, handle, value);
 }
 
-counted* get_context(pn_record_t* record, pn_handle_t handle) {
-    return reinterpret_cast<counted*>(pn_record_get(record, handle));
+template <class T>
+T* get_context(pn_record_t* record, pn_handle_t handle) {
+    return reinterpret_cast<T*>(pn_record_get(record, handle));
 }
 
-// Connection context
-
-PN_HANDLE(CONNECTION_CONTEXT)
-
-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*>(
-        get_context(pn_connection_attachments(c), CONNECTION_CONTEXT));
+connection_context& connection_context::get(pn_connection_t* c) {
+    connection_context* ctx =
+        get_context<connection_context>(pn_connection_attachments(c), CONNECTION_CONTEXT);
     if (!ctx) {
-        ctx = new connection_context();
-        set_context(pn_connection_attachments(c), CONNECTION_CONTEXT, ctx);
+        ctx =  context::create<connection_context>();
+        set_context(pn_connection_attachments(c), CONNECTION_CONTEXT, context::pn_class(), ctx);
+        pn_decref(ctx);
     }
     return *ctx;
 }
 
-PN_HANDLE(CONTAINER_CONTEXT)
+connection_context& connection_context::get(const connection& c) { return get(c.pn_object()); }
 
-void container_context(pn_reactor_t *r, container& c) {
-    pn_record_t *record = pn_reactor_attachments(r);
-    pn_record_def(record, CONTAINER_CONTEXT, PN_VOID);
-    pn_record_set(record, CONTAINER_CONTEXT, &c);
+void container_context::set(const reactor& r, container& c) {
+    set_context(pn_reactor_attachments(r.pn_object()), CONTAINER_CONTEXT, PN_VOID, &c);
 }
 
-container &container_context(pn_reactor_t *pn_reactor) {
-    pn_record_t *record = pn_reactor_attachments(pn_reactor);
-    container *ctx = reinterpret_cast<container*>(pn_record_get(record, CONTAINER_CONTEXT));
+container &container_context::get(pn_reactor_t *pn_reactor) {
+    container *ctx = get_context<container>(pn_reactor_attachments(pn_reactor), CONTAINER_CONTEXT);
     if (!ctx) throw error(MSG("Reactor has no C++ container context"));
     return *ctx;
 }
 
-PN_HANDLE(EVENT_CONTEXT)
-
-void event_context(pn_event_t *pn_event, pn_message_t *m) {
-    pn_record_t *record = pn_event_attachments(pn_event);
-    pn_record_def(record, EVENT_CONTEXT, PN_OBJECT); // refcount it for life of the event
-    pn_record_set(record, EVENT_CONTEXT, m);
-}
-
-pn_message_t *event_context(pn_event_t *pn_event) {
-    if (!pn_event) return NULL;
-    pn_record_t *record = pn_event_attachments(pn_event);
-    pn_message_t *ctx = (pn_message_t *) pn_record_get(record, EVENT_CONTEXT);
-    return ctx;
-}
-
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/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 a0e6cf6..c12d8bd 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -22,27 +22,45 @@
  *
  */
 
-#include "proton/counted.hpp"
 #include "proton/pn_unique_ptr.hpp"
-#include "proton/reactor.h"
-#include "proton/session.hpp"
+#include "proton/message.hpp"
+#include "proton/connection.hpp"
+#include "proton/container.hpp"
+#include "proton/handler.hpp"
 
-#include <proton/message.h>
+struct pn_session_t;
+struct pn_event_t;
+struct pn_record_t;
 
 namespace proton {
 
-class session;
 class handler;
 class container_impl;
 
-counted* get_context(pn_record_t*, pn_handle_t handle);
-void set_context(pn_record_t*, pn_handle_t, counted* value);
+// Base class for C++ classes that are used as proton contexts.
+// contexts are pn_objects managed by pn reference counts.
+class context {
+  public:
+    // Allocate a default-constructed T as a proton object. T must be a subclass of context.
+    template <class T> static T *create() { return new(alloc(sizeof(T))) T(); }
 
-struct connection_context : public counted {
-    static connection_context& get(pn_connection_t* c);
+    // Allocate a copy-constructed T as a proton object. T must be a subclass of context.
+    template <class T> static T *create(const T& x) { return new(alloc(sizeof(T))) T(x); }
 
-    connection_context();
-    ~connection_context();
+    virtual ~context();
+
+    static pn_class_t* pn_class();
+
+  private:
+    static void *alloc(size_t n);
+};
+
+class connection_context : public context {
+  public:
+    static connection_context& get(pn_connection_t*);
+    static connection_context& get(const connection&);
+
+    connection_context() : default_session(0), container_impl(0) {}
 
     pn_unique_ptr<class handler> handler;
     pn_session_t *default_session;   // Owned by connection
@@ -50,12 +68,13 @@ struct connection_context : public counted {
     message event_message;  // re-used by messaging_adapter for performance
 };
 
-class container;
-void container_context(pn_reactor_t *, container&);
-container& container_context(pn_reactor_t *);
+void container_context(const reactor&, container&);
 
-void event_context(pn_event_t *pn_event, pn_message_t *m);
-pn_message_t *event_context(pn_event_t *pn_event);
+class container_context {
+  public:
+    static void set(const reactor& r, container& c);
+    static container& get(pn_reactor_t*);
+};
 
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/counted_ptr.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/counted_ptr.cpp b/proton-c/bindings/cpp/src/counted_ptr.cpp
deleted file mode 100644
index 261d5ec..0000000
--- a/proton-c/bindings/cpp/src/counted_ptr.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <proton/object.h>
-
-namespace proton {
-
-void incref(const void* p) {
-    if (p) ::pn_incref(const_cast<void*>(p));
-}
-
-void decref(const void* p) {
-    if (p) ::pn_decref(const_cast<void*>(p));
-}
-
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index 8a45d6b..1eb6ab8 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -26,7 +26,7 @@
 
 namespace proton {
 
-data& data::operator=(const data& x) { ::pn_data_copy(pn_object(), x.pn_object()); return *this; }
+data& data::copy(const data& x) { ::pn_data_copy(pn_object(), x.pn_object()); return *this; }
 
 void data::clear() { ::pn_data_clear(pn_object()); }
 
@@ -62,7 +62,7 @@ std::ostream& operator<<(std::ostream& o, const data& d) {
     return o << inspectable(d.pn_object());
 }
 
-owned_object<pn_data_t> data::create() { return pn_data(0); }
+data data::create() { return pn_ptr<pn_data_t>::take(pn_data(0)); }
 
 encoder data::encoder() { return proton::encoder(pn_object()); }
 decoder data::decoder() { return proton::decoder(pn_object()); }
@@ -156,10 +156,10 @@ int compare(data& a, data& b) {
 }
 } // namespace
 
-bool data::operator==(const data& x) const {
+bool data::equal(const data& x) const {
     return compare(const_cast<data&>(*this), const_cast<data&>(x)) == 0;
 }
-bool data::operator<(const data& x) const {
+bool data::less(const data& x) const {
     return compare(const_cast<data&>(*this), const_cast<data&>(x)) < 0;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index f14345d..611d275 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -156,7 +156,7 @@ decoder operator>>(decoder d, rewind) { d.rewind(); return d; }
 
 decoder operator>>(decoder d, value& v) {
     data ddata = d.data();
-    if (object_base(ddata) == v.data_) throw decode_error("extract into self");
+    if (ddata == v.data_) throw decode_error("extract into self");
     data vdata = v.encoder().data();
     {
         narrow n(ddata);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index a0b10c0..3624821 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -132,7 +132,7 @@ encoder operator<<(encoder e, amqp_binary value) { return insert(e, e.pn_object(
 
 encoder operator<<(encoder e, const value& v) {
     data edata = e.data();
-    if (object_base(edata) == v.data_) throw encode_error("cannot insert into self");
+    if (edata == v.data_) throw encode_error("cannot insert into self");
     data vdata = v.decoder().data();
     check(edata.append(vdata), e.pn_object());
     return e;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link.cpp b/proton-c/bindings/cpp/src/link.cpp
index 587dec9..cb66933 100644
--- a/proton-c/bindings/cpp/src/link.cpp
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -80,8 +80,8 @@ class session link::session() const {
 
 void link::handler(class handler &h) {
     pn_record_t *record = pn_link_attachments(pn_object());
-    connection_context& cc(connection().context());
-    counted_ptr<pn_handler_t> chandler = cc.container_impl->cpp_handler(&h);
+    connection_context& cc(connection_context::get(connection()));
+    pn_ptr<pn_handler_t> chandler = cc.container_impl->cpp_handler(&h);
     pn_record_set_handler(record, chandler.get());
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index 7c032f0..dd57606 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -66,7 +66,7 @@ void check(int err) {
 }
 } // namespace
 
-void message::id(const message_id& id) { data(pn_message_id(message_)) = id.value_; }
+void message::id(const message_id& id) { data(pn_message_id(message_)).copy(id.value_); }
 
 namespace {
 inline message_id from_pn_atom(const pn_atom_t& v) {
@@ -125,7 +125,7 @@ std::string message::reply_to() const {
 }
 
 void message::correlation_id(const message_id& id) {
-    data(pn_message_correlation_id(message_)) = id.value_;
+    data(pn_message_correlation_id(message_)).copy(id.value_);
 }
 
 message_id message::correlation_id() const {
@@ -186,7 +186,7 @@ bool message::inferred() const { return pn_message_is_inferred(message_); }
 
 void message::inferred(bool b) { pn_message_set_inferred(message_, b); }
 
-void message::body(const value& v) { body() = v; }
+void message::body(const value& v) { body().copy(v); }
 
 const data message::body() const {
     return pn_message_body(message_);
@@ -197,7 +197,7 @@ data message::body() {
 }
 
 void message::properties(const value& v) {
-    properties() = v;
+    properties().copy(v);
 }
 
 const data message::properties() const {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index e3bced8..d551018 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -75,7 +75,7 @@ void messaging_adapter::on_delivery(event &e) {
                 // generate on_message
                 messaging_event mevent(messaging_event::MESSAGE, *pe);
                 pn_connection_t *pnc = pn_session_connection(pn_link_session(lnk));
-                struct connection_context& ctx = connection_context::get(pnc);
+                connection_context& ctx = connection_context::get(pnc);
                 // Reusable per-connection message.
                 // Avoid expensive heap malloc/free overhead.
                 // See PROTON-998

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/object.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/object.cpp b/proton-c/bindings/cpp/src/object.cpp
index d5fb7ef..9fde50f 100644
--- a/proton-c/bindings/cpp/src/object.cpp
+++ b/proton-c/bindings/cpp/src/object.cpp
@@ -22,12 +22,12 @@
 
 namespace proton {
 
-void object_base::incref() const {
-    if (object_) ::pn_incref(const_cast<void*>(object_));
+void pn_ptr_base::incref(void *p) {
+    if (p) ::pn_incref(const_cast<void*>(p));
 }
 
-void object_base::decref() const {
-    if (object_) ::pn_decref(const_cast<void*>(object_));
+void pn_ptr_base::decref(void *p) {
+    if (p) ::pn_decref(const_cast<void*>(p));
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/reactor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.cpp b/proton-c/bindings/cpp/src/reactor.cpp
index 9a52d99..2a740e8 100644
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ b/proton-c/bindings/cpp/src/reactor.cpp
@@ -30,10 +30,7 @@
 namespace proton {
 
 reactor reactor::create() {
-    pn_reactor_t *p = pn_reactor();
-    reactor r(p);
-    pn_decref(p);               // FIXME aconway 2015-11-26: take ownership
-    return r;
+    return pn_ptr<pn_reactor_t>::take(pn_reactor()).get();
 }
 
 void reactor::run() { pn_reactor_run(pn_object()); }
@@ -92,8 +89,4 @@ void reactor::timeout(duration timeout) {
         pn_reactor_set_timeout(pn_object(), timeout.milliseconds);
 }
 
-void reactor::container_context(container& c) {
-    proton::container_context(pn_object(), c);
-}
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/session.cpp b/proton-c/bindings/cpp/src/session.cpp
index e903080..c6c2233 100644
--- a/proton-c/bindings/cpp/src/session.cpp
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -40,7 +40,7 @@ connection session::connection() const {
 namespace {
 std::string set_name(const std::string& name, session* s) {
     if (name.empty())
-        return s->connection().context().container_impl->next_link_name();
+        return connection_context::get(s->connection()).container_impl->next_link_name();
     return name;
 }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5045ec03/proton-c/bindings/cpp/src/value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value.cpp b/proton-c/bindings/cpp/src/value.cpp
index be5ca5e..b603bf9 100644
--- a/proton-c/bindings/cpp/src/value.cpp
+++ b/proton-c/bindings/cpp/src/value.cpp
@@ -28,9 +28,9 @@ namespace proton {
 
 value::value() : data_(data::create()) {}
 
-value::value(const value& x) : data_(data::create()) { data_ = x.data_; }
+value::value(const value& x) : data_(data::create()) { data_.copy(x.data_); }
 
-value& value::operator=(const value& x) { data_ = x.data_; return *this; }
+value& value::operator=(const value& x) { data_.copy(x.data_); return *this; }
 
 void value::clear() { data_.clear(); }
 
@@ -42,9 +42,9 @@ class decoder value::decoder() const { data_.decoder().rewind(); return data_.de
 
 type_id value::type() const { return decoder().type(); }
 
-bool value::operator==(const value& x) const { return data_ == x.data_; }
+bool value::operator==(const value& x) const { return data_.equal(x.data_); }
 
-bool value::operator<(const value& x) const { return data_ < x.data_; }
+bool value::operator<(const value& x) const { return data_.less(x.data_); }
 
 std::ostream& operator<<(std::ostream& o, const value& v) {
     // pn_inspect prints strings with quotes which is not normal in C++.


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


[40/50] [abbrv] qpid-proton git commit: NO-JIRA: c++: Fix compile error on clang++

Posted by ac...@apache.org.
NO-JIRA: c++: Fix compile error on clang++

The compile error doesn't happen on gcc, and to my eye the original code looks fine but this
version compiles on gcc/clang x 03/11 + MSVC


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

Branch: refs/heads/go1
Commit: c41ff065887d99740af31dba41cca113d67bc2e8
Parents: e9e0f31
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 21 09:59:03 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 21 14:49:59 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/object.hpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c41ff065/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index 34fc5a0..a2457bb 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -54,17 +54,17 @@ template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_
   friend bool operator==(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ == b.ptr_; }
   friend bool operator<(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ < b.ptr_; }
 
+    static pn_ptr take_ownership(T* p) { return pn_ptr<T>(p, true); }
+
   private:
     T *ptr_;
 
     // Note that it is the presence of the bool in the constructor signature that matters
     // to get the "transfer ownership" constructor: The value of the bool isn't checked.
     pn_ptr(T* p, bool) : ptr_(p) {}
-    template <class U> pn_ptr<U> take_ownership(U* p);
-    friend pn_ptr take_ownership<T>(T* p);
 };
 
-template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>(p, true); }
+template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>::take_ownership(p); }
 
 ///@endcond INTERNAL
 


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


[23/50] [abbrv] qpid-proton git commit: PROTON-1076: C++ Binding - per acceptor connection options (acceptor context)

Posted by ac...@apache.org.
PROTON-1076: C++ Binding - per acceptor connection options (acceptor context)


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

Branch: refs/heads/go1
Commit: c9158ed3ac6dd68590bddd061a7e0180d74abc90
Parents: 3f4dc74
Author: Clifford Jansen <cl...@apache.org>
Authored: Sat Dec 12 08:31:59 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Sat Dec 12 08:31:59 2015 -0800

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/acceptor.hpp     | 10 +++++++---
 .../bindings/cpp/include/proton/container.hpp    |  2 +-
 proton-c/bindings/cpp/include/proton/ssl.hpp     |  4 ++--
 proton-c/bindings/cpp/src/acceptor.cpp           |  7 +++++++
 proton-c/bindings/cpp/src/connection_options.cpp |  5 +----
 proton-c/bindings/cpp/src/container.cpp          |  4 ----
 proton-c/bindings/cpp/src/container_impl.cpp     | 19 +++----------------
 proton-c/bindings/cpp/src/container_impl.hpp     |  2 +-
 proton-c/bindings/cpp/src/contexts.cpp           | 15 +++++++++++++++
 proton-c/bindings/cpp/src/contexts.hpp           |  8 ++++++++
 10 files changed, 45 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/include/proton/acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acceptor.hpp b/proton-c/bindings/cpp/include/proton/acceptor.hpp
index c5726aa..4edcc11 100644
--- a/proton-c/bindings/cpp/include/proton/acceptor.hpp
+++ b/proton-c/bindings/cpp/include/proton/acceptor.hpp
@@ -38,9 +38,13 @@ class acceptor : public object<pn_acceptor_t>
 
     /** close the acceptor */
     PN_CPP_EXTERN void close();
-#ifndef PROTON_1057_FIXED
-    friend class container_impl;
-#endif
+
+    /** Return the current set of connection options applied to inbound connectons by the acceptor.
+     *
+     * Note that changes made to the connection options only affect connections accepted after this
+     * call returns.
+     */
+    PN_CPP_EXTERN class connection_options &connection_options();
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index 2cebcd4..fbdafb9 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -62,7 +62,7 @@ class container : public event_loop {
     /** Locally open a connection @see connection::open  */
     PN_CPP_EXTERN connection connect(const proton::url&, const connection_options &opts = connection_options());
 
-    /** Open a connection to url and create a receiver with source=url.path() */
+    /** Listen on url host and port for incoming connections. */
     PN_CPP_EXTERN acceptor listen(const proton::url&, const connection_options &opts = connection_options());
 
     /** Run the event loop, return when all connections and acceptors are closed. */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index bb78ae3..609e7e2 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -104,9 +104,9 @@ class server_domain : private ssl_domain {
     PN_CPP_EXTERN ~server_domain();
 
   private:
-    // Bring pn_domain into scope and allow container_impl to use it
+    // Bring pn_domain into scope and allow connection_options to use it
     using ssl_domain::pn_domain;
-    friend class container_impl;
+    friend class connection_options;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/src/acceptor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/acceptor.cpp b/proton-c/bindings/cpp/src/acceptor.cpp
index 279f776..8f4c722 100644
--- a/proton-c/bindings/cpp/src/acceptor.cpp
+++ b/proton-c/bindings/cpp/src/acceptor.cpp
@@ -21,10 +21,17 @@
 
 #include "proton/acceptor.hpp"
 #include "proton/error.hpp"
+#include "proton/connection_options.hpp"
 #include "msg.hpp"
+#include "contexts.hpp"
 
 namespace proton {
 
 void acceptor::close() { pn_acceptor_close(pn_object()); }
 
+class connection_options& acceptor::connection_options() {
+    listener_context& lc(listener_context::get(pn_object()));
+    return lc.connection_options;
+}
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 6b72c9c..3a3e0e1 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -73,7 +73,6 @@ class connection_options::impl {
         {
             // SSL
             if (outbound && outbound->address().scheme() == url::AMQPS) {
-                // Configure outbound ssl options. pni_acceptor_readable handles the inbound case.
                 const char* id = resume_id.value.empty() ? NULL : resume_id.value.c_str();
                 pn_ssl_t *ssl = pn_ssl(pnt);
                 if (pn_ssl_init(ssl, client_domain.value.pn_domain(), id))
@@ -81,16 +80,14 @@ class connection_options::impl {
                 if (peer_hostname.set && !peer_hostname.value.empty())
                     if (pn_ssl_set_peer_hostname(ssl, peer_hostname.value.c_str()))
                         throw error(MSG("error in SSL/TLS peer hostname \"") << peer_hostname.value << '"');
-#ifdef PROTON_1054_FIXED
             } else if (!outbound) {
-                pn_acceptor_t *pnp = pn_connection_acceptor(pn_cast(&c));
+                pn_acceptor_t *pnp = pn_connection_acceptor(pnc);
                 listener_context &lc(listener_context::get(pnp));
                 if (lc.ssl) {
                     pn_ssl_t *ssl = pn_ssl(pnt);
                     if (pn_ssl_init(ssl, server_domain.value.pn_domain(), NULL))
                         throw error(MSG("server SSL/TLS initialization error"));
                 }
-#endif
             }
 
             // SASL

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/src/container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container.cpp b/proton-c/bindings/cpp/src/container.cpp
index 34bd2a0..1924cc0 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -67,11 +67,7 @@ receiver container::open_receiver(const proton::url &url) {
 }
 
 acceptor container::listen(const proton::url &url, const connection_options &opts) {
-#ifdef PN_COMING_SOON
     return impl_->listen(url, opts);
-#else
-    return impl_->listen(url);
-#endif
 }
 
 task container::schedule(int delay, handler *h) { return impl_->schedule(delay, h); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/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 648aa56..e3c7c2c 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -185,11 +185,9 @@ receiver container_impl::open_receiver(const proton::url &url) {
     return rcv;
 }
 
-acceptor container_impl::listen(const proton::url& url) {
+acceptor container_impl::listen(const proton::url& url, const connection_options &user_opts) {
     connection_options opts = server_connection_options(); // Defaults
-#ifdef PN_COMING_SOON
     opts.override(user_opts);
-#endif
     handler *h = opts.handler();
     pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : pn_ptr<pn_handler_t>();
     pn_acceptor_t *acptr = pn_reactor_acceptor(reactor_.pn_object(), url.host().c_str(), url.port().c_str(), chandler.get());
@@ -197,16 +195,11 @@ acceptor container_impl::listen(const proton::url& url) {
         throw error(MSG("accept fail: " <<
                         pn_error_text(pn_io_error(reactor_.pn_io())))
                         << "(" << url << ")");
-#ifdef PROTON_1054_FIXED
     // Do not use pn_acceptor_set_ssl_domain().  Manage the incoming connections ourselves for
     // more flexibility (i.e. ability to change the server cert for a long running listener).
     listener_context& lc(listener_context::get(acptr));
     lc.connection_options = opts;
     lc.ssl = url.scheme() == url::AMQPS;
-#else
-    if (url.scheme() == url::AMQPS)
-        pn_acceptor_set_ssl_domain(acptr, server_connection_options_.server_domain().pn_domain());
-#endif
     return acceptor(acptr);
 }
 
@@ -233,15 +226,9 @@ void container_impl::server_connection_options(const connection_options &opts) {
 }
 
 void container_impl::configure_server_connection(connection &c) {
-#ifdef PN_1054_FIXED
-    pn_acceptor_t *pnp = pn_connection_acceptor(pn_cast(&c));
+    pn_acceptor_t *pnp = pn_connection_acceptor(connection_options::pn_connection(c));
     listener_context &lc(listener_context::get(pnp));
-    class connection_options &opts(lc.connection_options);
-#else
-    // Can't distinguish between multiple listeners yet.  See PROTON-1054
-    class connection_options &opts(server_connection_options_);
-#endif
-    opts.apply(c);
+    lc.connection_options.apply(c);
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index 4a89ab3..31ec0cf 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -52,7 +52,7 @@ class container_impl
     PN_CPP_EXTERN sender open_sender(const url&);
     PN_CPP_EXTERN receiver open_receiver(connection &connection, const std::string &addr, bool dynamic, handler *h);
     PN_CPP_EXTERN receiver open_receiver(const url&);
-    PN_CPP_EXTERN class acceptor listen(const url&);
+    PN_CPP_EXTERN class acceptor listen(const url&, const connection_options &);
     PN_CPP_EXTERN duration timeout();
     PN_CPP_EXTERN void timeout(duration timeout);
     void client_connection_options(const connection_options &);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/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 0ea4262..08187a2 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -48,6 +48,7 @@ pn_class_t cpp_context_class = PN_CLASS(cpp_context);
 // Handles
 PN_HANDLE(CONNECTION_CONTEXT)
 PN_HANDLE(CONTAINER_CONTEXT)
+PN_HANDLE(LISTENER_CONTEXT)
 }
 
 context::~context() {}
@@ -89,4 +90,18 @@ container &container_context::get(pn_reactor_t *pn_reactor) {
     return *ctx;
 }
 
+listener_context& listener_context::get(pn_acceptor_t* a) {
+    // A Proton C pn_acceptor_t is really just a selectable
+    pn_selectable_t *sel = reinterpret_cast<pn_selectable_t*>(a);
+
+    listener_context* ctx =
+        get_context<listener_context>(pn_selectable_attachments(sel), LISTENER_CONTEXT);
+    if (!ctx) {
+        ctx =  context::create<listener_context>();
+        set_context(pn_selectable_attachments(sel), LISTENER_CONTEXT, context::pn_class(), ctx);
+        pn_decref(ctx);
+    }
+    return *ctx;
+}
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c9158ed3/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 c12d8bd..9bfd2d4 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -76,6 +76,14 @@ class container_context {
     static container& get(pn_reactor_t*);
 };
 
+class listener_context : public context {
+  public:
+    static listener_context& get(pn_acceptor_t* c);
+    listener_context() : ssl(false) {}
+    class connection_options connection_options;
+    bool ssl;
+};
+
 }
 
 #endif  /*!PROTON_CPP_CONTEXTS_H*/


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


[19/50] [abbrv] qpid-proton git commit: PROTON-1068: Slightly nicer syntax at point of use for take_ownership()

Posted by ac...@apache.org.
PROTON-1068: Slightly nicer syntax at point of use for take_ownership()


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

Branch: refs/heads/go1
Commit: 595a854048093c49c5c1401202b64d957e23a7b3
Parents: bd9a41b
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Dec 10 18:05:27 2015 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Dec 10 18:05:27 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/object.hpp | 12 +++++++++---
 proton-c/bindings/cpp/src/container_impl.cpp    |  2 +-
 proton-c/bindings/cpp/src/data.cpp              |  2 +-
 proton-c/bindings/cpp/src/reactor.cpp           |  2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/595a8540/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index 6e5cef5..34fc5a0 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -46,8 +46,6 @@ template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_
 
     ~pn_ptr() { decref(ptr_); };
 
-    static pn_ptr<T> take(T* p) { return pn_ptr<T>(p, true); }
-
     pn_ptr& operator=(pn_ptr o) { std::swap(ptr_, o.ptr_); return *this; }
 
     T* get() const { return ptr_; }
@@ -57,9 +55,17 @@ template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_
   friend bool operator<(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ < b.ptr_; }
 
   private:
-    pn_ptr(T* p, bool) : ptr_(p) {}
     T *ptr_;
+
+    // Note that it is the presence of the bool in the constructor signature that matters
+    // to get the "transfer ownership" constructor: The value of the bool isn't checked.
+    pn_ptr(T* p, bool) : ptr_(p) {}
+    template <class U> pn_ptr<U> take_ownership(U* p);
+    friend pn_ptr take_ownership<T>(T* p);
 };
+
+template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>(p, true); }
+
 ///@endcond INTERNAL
 
 /**

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/595a8540/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 f83e0a6..648aa56 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -115,7 +115,7 @@ class override_handler : public handler
 
 pn_ptr<pn_handler_t> container_impl::cpp_handler(handler *h) {
     if (!h->pn_handler_) {
-        h->pn_handler_ = pn_ptr<pn_handler_t>::take(
+        h->pn_handler_ = take_ownership(
             pn_handler_new(&handler_context::dispatch,
                            sizeof(struct handler_context),
                            &handler_context::cleanup));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/595a8540/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index 1eb6ab8..70f3e8f 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -62,7 +62,7 @@ std::ostream& operator<<(std::ostream& o, const data& d) {
     return o << inspectable(d.pn_object());
 }
 
-data data::create() { return pn_ptr<pn_data_t>::take(pn_data(0)); }
+data data::create() { return take_ownership(pn_data(0)); }
 
 encoder data::encoder() { return proton::encoder(pn_object()); }
 decoder data::decoder() { return proton::decoder(pn_object()); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/595a8540/proton-c/bindings/cpp/src/reactor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.cpp b/proton-c/bindings/cpp/src/reactor.cpp
index 2a740e8..59db5e0 100644
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ b/proton-c/bindings/cpp/src/reactor.cpp
@@ -30,7 +30,7 @@
 namespace proton {
 
 reactor reactor::create() {
-    return pn_ptr<pn_reactor_t>::take(pn_reactor()).get();
+    return take_ownership(pn_reactor()).get();
 }
 
 void reactor::run() { pn_reactor_run(pn_object()); }


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


[45/50] [abbrv] qpid-proton git commit: PROTON-1085: c++: clean up access to message properties, instructions and annotations.

Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/scalar.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar.cpp b/proton-c/bindings/cpp/src/scalar.cpp
index 13daf32..9e8d124 100644
--- a/proton-c/bindings/cpp/src/scalar.cpp
+++ b/proton-c/bindings/cpp/src/scalar.cpp
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+#include "msg.hpp"
 #include "proton/scalar.hpp"
 #include "proton/type_traits.hpp"
 
@@ -25,37 +26,50 @@
 namespace proton {
 
 scalar::scalar() { atom_.type = PN_NULL; }
+scalar::scalar(const scalar& x) { set(x.atom_); }
+scalar& scalar::operator=(const scalar& x) { set(x.atom_); return *this; }
 
 type_id scalar::type() const { return type_id(atom_.type); }
 bool scalar::empty() const { return type() == NULL_TYPE; }
 
-scalar::scalar(bool x) { atom_.u.as_bool = x; atom_.type = PN_BOOL; }
-scalar::scalar(uint8_t x) { atom_.u.as_ubyte = x; atom_.type = PN_UBYTE; }
-scalar::scalar(int8_t x) { atom_.u.as_byte = x; atom_.type = PN_BYTE; }
-scalar::scalar(uint16_t x) { atom_.u.as_ushort = x; atom_.type = PN_USHORT; }
-scalar::scalar(int16_t x) { atom_.u.as_short = x; atom_.type = PN_SHORT; }
-scalar::scalar(uint32_t x) { atom_.u.as_uint = x; atom_.type = PN_UINT; }
-scalar::scalar(int32_t x) { atom_.u.as_int = x; atom_.type = PN_INT; }
-scalar::scalar(uint64_t x) { atom_.u.as_ulong = x; atom_.type = PN_ULONG; }
-scalar::scalar(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG; }
-scalar::scalar(wchar_t x) { atom_.u.as_char = pn_char_t(x); atom_.type = PN_CHAR; }
-scalar::scalar(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; }
-scalar::scalar(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; }
-scalar::scalar(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; }
-scalar::scalar(const amqp_decimal32& x) { atom_.u.as_decimal32 = x; atom_.type = PN_DECIMAL32; }
-scalar::scalar(const amqp_decimal64& x) { atom_.u.as_decimal64 = x; atom_.type = PN_DECIMAL64; }
-scalar::scalar(const amqp_decimal128& x) { atom_.u.as_decimal128 = x; atom_.type = PN_DECIMAL128; }
-scalar::scalar(const amqp_uuid& x) { atom_.u.as_uuid = x; atom_.type = PN_UUID; }
-
-void scalar::set(const std::string& x) { str_ = x; atom_.u.as_bytes = pn_bytes(str_); }
-scalar::scalar(const amqp_string& x) { set(x); atom_.type = PN_STRING; }
-scalar::scalar(const amqp_symbol& x) { set(x); atom_.type = PN_SYMBOL; }
-scalar::scalar(const amqp_binary& x) { set(x); atom_.type = PN_BINARY; }
-scalar::scalar(const std::string& x) { *this = amqp_string(x); }
-scalar::scalar(const char* x) { *this = amqp_string(x); }
+void scalar::set(const std::string& x, pn_type_t t) {
+    atom_.type = t;
+    str_ = x;
+    atom_.u.as_bytes = pn_bytes(str_);
+}
+
+void scalar::set(const pn_atom_t& atom) {
+    if (type_id_is_string_like(type_id(atom.type)))
+        set(str(atom.u.as_bytes), atom.type);
+    else
+        atom_ = atom;
+}
+
+scalar& scalar::operator=(bool x) { atom_.u.as_bool = x; atom_.type = PN_BOOL; return *this; }
+scalar& scalar::operator=(uint8_t x) { atom_.u.as_ubyte = x; atom_.type = PN_UBYTE; return *this; }
+scalar& scalar::operator=(int8_t x) { atom_.u.as_byte = x; atom_.type = PN_BYTE; return *this; }
+scalar& scalar::operator=(uint16_t x) { atom_.u.as_ushort = x; atom_.type = PN_USHORT; return *this; }
+scalar& scalar::operator=(int16_t x) { atom_.u.as_short = x; atom_.type = PN_SHORT; return *this; }
+scalar& scalar::operator=(uint32_t x) { atom_.u.as_uint = x; atom_.type = PN_UINT; return *this; }
+scalar& scalar::operator=(int32_t x) { atom_.u.as_int = x; atom_.type = PN_INT; return *this; }
+scalar& scalar::operator=(uint64_t x) { atom_.u.as_ulong = x; atom_.type = PN_ULONG; return *this; }
+scalar& scalar::operator=(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG; return *this; }
+scalar& scalar::operator=(wchar_t x) { atom_.u.as_char = x; atom_.type = PN_CHAR; return *this; }
+scalar& scalar::operator=(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; return *this; }
+scalar& scalar::operator=(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; return *this; }
+scalar& scalar::operator=(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; return *this; }
+scalar& scalar::operator=(const amqp_decimal32& x) { atom_.u.as_decimal32 = x; atom_.type = PN_DECIMAL32; return *this; }
+scalar& scalar::operator=(const amqp_decimal64& x) { atom_.u.as_decimal64 = x; atom_.type = PN_DECIMAL64; return *this; }
+scalar& scalar::operator=(const amqp_decimal128& x) { atom_.u.as_decimal128 = x; atom_.type = PN_DECIMAL128; return *this; }
+scalar& scalar::operator=(const amqp_uuid& x) { atom_.u.as_uuid = x; atom_.type = PN_UUID; return *this; }
+scalar& scalar::operator=(const amqp_string& x) { set(x, PN_STRING); return *this; }
+scalar& scalar::operator=(const amqp_symbol& x) { set(x, PN_SYMBOL); return *this; }
+scalar& scalar::operator=(const amqp_binary& x) { set(x, PN_BINARY); return *this; }
+scalar& scalar::operator=(const std::string& x) { set(x, PN_STRING); return *this; }
+scalar& scalar::operator=(const char* x) { set(x, PN_STRING); return *this; }
 
 void scalar::ok(pn_type_t t) const {
-    if (atom_.type != t) throw type_mismatch(type_id(t), type());
+    if (atom_.type != t) throw type_error(type_id(t), type());
 }
 
 void scalar::get(bool& x) const { ok(PN_BOOL); x = atom_.u.as_bool; }
@@ -75,9 +89,9 @@ void scalar::get(amqp_decimal32& x) const { ok(PN_DECIMAL32); x = atom_.u.as_dec
 void scalar::get(amqp_decimal64& x) const { ok(PN_DECIMAL64); x = atom_.u.as_decimal64; }
 void scalar::get(amqp_decimal128& x) const { ok(PN_DECIMAL128); x = atom_.u.as_decimal128; }
 void scalar::get(amqp_uuid& x) const { ok(PN_UUID); x = atom_.u.as_uuid; }
-void scalar::get(amqp_string& x) const { ok(PN_STRING); x = str_; }
-void scalar::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = str_; }
-void scalar::get(amqp_binary& x) const { ok(PN_BINARY); x = str_; }
+void scalar::get(amqp_string& x) const { ok(PN_STRING); x = amqp_string(str_); }
+void scalar::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = amqp_symbol(str_); }
+void scalar::get(amqp_binary& x) const { ok(PN_BINARY); x = amqp_binary(str_); }
 void scalar::get(std::string& x) const { x = get<amqp_string>(); }
 
 int64_t scalar::as_int() const {
@@ -94,13 +108,14 @@ int64_t scalar::as_int() const {
       case PN_CHAR: return atom_.u.as_char;
       case PN_ULONG: return int64_t(atom_.u.as_ulong);
       case PN_LONG: return atom_.u.as_long;
-      default: throw type_mismatch(LONG, type(), "cannot convert");
+      case PN_TIMESTAMP: return atom_.u.as_timestamp;
+      default: throw type_error(LONG, type(), "cannot convert");
     }
 }
 
 uint64_t scalar::as_uint() const {
     if  (!type_id_is_integral(type()))
-        throw type_mismatch(ULONG, type(), "cannot convert");
+        throw type_error(ULONG, type(), "cannot convert");
     return uint64_t(as_int());
 }
 
@@ -111,18 +126,19 @@ double scalar::as_double() const {
     switch (atom_.type) {
       case PN_DOUBLE: return atom_.u.as_double;
       case PN_FLOAT: return atom_.u.as_float;
-      default: throw type_mismatch(DOUBLE, type(), "cannot convert");
+      default: throw type_error(DOUBLE, type(), "cannot convert");
     }
 }
 
 std::string scalar::as_string() const {
     if (type_id_is_string_like(type()))
         return str_;
-    throw type_mismatch(DOUBLE, type(), "cannot convert");
+    throw type_error(STRING, type(), "cannot convert");
 }
 
-
 namespace {
+template<class T> int opaque_cmp(const T& x, const T& y) { return memcmp(&x, &y, sizeof(T)); }
+
 template <class T, class F> T type_switch(const scalar& a, F f) {
     switch(a.type()) {
       case BOOLEAN: return f(a.get<bool>());
@@ -170,16 +186,21 @@ struct ostream_op {
 
 } // namespace
 
-bool scalar::operator==(const scalar& x) const {
-    return type_switch<bool>(*this, equal_op(x));
+bool operator==(const scalar& x, const scalar& y) {
+    if (x.type() != y.type()) return false;
+    if (x.empty()) return true;
+    return type_switch<bool>(x, equal_op(y));
 }
 
-bool scalar::operator<(const scalar& x) const {
-    return type_switch<bool>(*this, less_op(x));
+bool operator<(const scalar& x, const scalar& y) {
+    if (x.type() != y.type()) return x.type() < y.type();
+    if (x.empty()) return false;
+    return type_switch<bool>(x, less_op(y));
 }
 
 std::ostream& operator<<(std::ostream& o, const scalar& a) {
+    if (a.empty()) return o << "<null>";
     return type_switch<std::ostream&>(a, ostream_op(o));
 }
 
-}
+} // namespace proton

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/scalar_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.cpp b/proton-c/bindings/cpp/src/scalar_test.cpp
index c7de785..cb66e41 100644
--- a/proton-c/bindings/cpp/src/scalar_test.cpp
+++ b/proton-c/bindings/cpp/src/scalar_test.cpp
@@ -21,51 +21,62 @@
 #include "proton/type_traits.hpp"
 
 #include <proton/scalar.hpp>
+#include <proton/value.hpp>
+#include <proton/message_id.hpp>
+#include <proton/annotation_key.hpp>
+
+#include <sstream>
 
 using namespace std;
 using namespace proton;
 
 // Inserting and extracting simple C++ values.
 template <class T> void type_test(T x, type_id tid, T y) {
-    scalar v(x);
-    ASSERT_EQUAL(tid, v.type());
-    ASSERT(!v.empty());
-    ASSERT_EQUAL(x, v.get<T>());
+    scalar s(x);
+    ASSERT_EQUAL(tid, s.type());
+    ASSERT(!s.empty());
+    ASSERT_EQUAL(x, s.get<T>());
 
     scalar v2;
     ASSERT(v2.type() == NULL_TYPE);
     v2 = x;
     ASSERT_EQUAL(tid, v2.type());
     ASSERT_EQUAL(x, v2.get<T>());
-    ASSERT_EQUAL(v, v2);
-    ASSERT_EQUAL(str(x), str(v));
+    ASSERT_EQUAL(s, v2);
+    ASSERT_EQUAL(str(x), str(s));
 
     v2 = y;
-    ASSERT(v != v2);
-    ASSERT(v < v2);
-    ASSERT(v2 > v);
+    ASSERT(s != v2);
+    ASSERT(s < v2);
+    ASSERT(v2 > s);
 }
 
-#define ASSERT_MISMATCH(EXPR) \
-    try { (void)(EXPR); FAIL("expected type_mismatch: " #EXPR); } catch (type_mismatch) {}
+#define ASSERT_MISMATCH(EXPR, WANT, GOT)                        \
+    try {                                                       \
+        (void)(EXPR);                                           \
+        FAIL("expected type_error: " #EXPR);                    \
+    } catch (const type_error& e) {                             \
+        ASSERT_EQUAL(WANT, e.want);                             \
+        ASSERT_EQUAL(GOT, e.got);                               \
+    }
 
 void convert_test() {
     scalar a;
     ASSERT_EQUAL(NULL_TYPE, a.type());
     ASSERT(a.empty());
-    ASSERT_MISMATCH(a.get<float>());
+    ASSERT_MISMATCH(a.get<float>(), FLOAT, NULL_TYPE);
 
     a = amqp_binary("foo");
-    ASSERT_MISMATCH(a.get<int16_t>());
-    ASSERT_MISMATCH(a.as_int());
-    ASSERT_MISMATCH(a.as_double());
-    ASSERT_MISMATCH(a.get<amqp_string>());           // No strict conversion
+    ASSERT_MISMATCH(a.get<int16_t>(), SHORT, BINARY);
+    ASSERT_MISMATCH(a.as_int(), LONG, BINARY);
+    ASSERT_MISMATCH(a.as_double(), DOUBLE, BINARY);
+    ASSERT_MISMATCH(a.get<amqp_string>(), STRING, BINARY); // No strict conversion
     ASSERT_EQUAL(a.as_string(), std::string("foo")); // OK string-like conversion
 
     a = int16_t(42);
-    ASSERT_MISMATCH(a.get<std::string>());
-    ASSERT_MISMATCH(a.get<amqp_timestamp>());
-    ASSERT_MISMATCH(a.as_string());
+    ASSERT_MISMATCH(a.get<std::string>(), STRING, SHORT);
+    ASSERT_MISMATCH(a.get<amqp_timestamp>(), TIMESTAMP, SHORT);
+    ASSERT_MISMATCH(a.as_string(), STRING, SHORT);
     ASSERT_EQUAL(a.as_int(), 42);
     ASSERT_EQUAL(a.as_uint(), 42);
     ASSERT_EQUAL(a.as_double(), 42);
@@ -76,6 +87,33 @@ void convert_test() {
     ASSERT_EQUAL(a.as_double(), -42);
 }
 
+void encode_decode_test() {
+    value v;
+    scalar a("foo");
+    v = a;                      // Assignment to value does encode, get<> does decode.
+    ASSERT_EQUAL(v, a);
+    ASSERT_EQUAL(std::string("foo"), v.get<std::string>());
+    scalar a2 = v.get<scalar>();
+    ASSERT_EQUAL(std::string("foo"), a2.get<std::string>());
+}
+
+void message_id_test() {
+    ASSERT_EQUAL(23, message_id(23).as_int());
+    ASSERT_EQUAL(23, message_id(23).get<uint64_t>());
+    ASSERT(message_id("foo") != message_id(amqp_binary("foo")));
+    ASSERT_EQUAL(scalar("foo"), message_id("foo"));
+    ASSERT_EQUAL("foo", message_id("foo").as_string());
+    ASSERT(message_id("a") < message_id("z"));
+    ASSERT_EQUAL(amqp_uuid(), message_id(amqp_uuid()).get<amqp_uuid>());
+}
+
+void annotation_key_test() {
+    ASSERT_EQUAL(23, annotation_key(23).as_int());
+    ASSERT_EQUAL(23, annotation_key(23).get<uint64_t>());
+    ASSERT_EQUAL("foo", annotation_key("foo").as_string());
+    ASSERT_EQUAL(scalar(amqp_symbol("foo")), annotation_key("foo"));
+}
+
 int main(int, char**) {
     int failed = 0;
     RUN_TEST(failed, type_test(false, BOOLEAN, true));
@@ -101,5 +139,9 @@ int main(int, char**) {
     RUN_TEST(failed, type_test(amqp_symbol("aaa"), SYMBOL, amqp_symbol("aaaa")));
     RUN_TEST(failed, type_test(amqp_binary("aaa"), BINARY, amqp_binary("aaaa")));
     RUN_TEST(failed, type_test(std::string("xxx"), STRING, std::string("yyy")));
+    RUN_TEST(failed, encode_decode_test());
+    RUN_TEST(failed, message_id_test());
+    RUN_TEST(failed, annotation_key_test());
+    RUN_TEST(failed, convert_test());
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp b/proton-c/bindings/cpp/src/types.cpp
index fa7b0bd..7a38f12 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -33,20 +33,18 @@ inline std::ostream& print_segment(std::ostream& o, const amqp_uuid& u, size_t b
     return o << sep;
 }
 
-std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string())
-{
+std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string()) {
     std::ostringstream s;
-    s << "type mismatch: want " << type_name(want) << " got " << type_name(got);
+    s << "want " << want << " got " << got;
     if (!msg.empty()) s << ": " << msg;
     return s.str();
 }
-}
+} // namespace
 
-type_mismatch::type_mismatch(type_id want_, type_id got_, const std::string &msg)
-    : error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
+type_error::type_error(type_id want_, type_id got_, const std::string &msg)
+    : decode_error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
 {}
 
-
 std::ostream& operator<<(std::ostream& o, const amqp_decimal32&) { return o << "<decimal32>"; }
 std::ostream& operator<<(std::ostream& o, const amqp_decimal64&) { return o << "<decimal64>"; }
 std::ostream& operator<<(std::ostream& o, const amqp_decimal128&) { return o << "<decimal128>"; }
@@ -95,9 +93,9 @@ std::string type_name(type_id t) {
     return "unknown";
 }
 
-static bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
-static bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
-bool type_id_is_integral(type_id t) { return t == BOOLEAN || t == CHAR || type_id_is_unsigned_int(t) || type_id_is_signed_int(t); }
+bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
+bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
+bool type_id_is_integral(type_id t) { return t == BOOLEAN || t == CHAR || t == TIMESTAMP || type_id_is_unsigned_int(t) || type_id_is_signed_int(t); }
 bool type_id_is_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
 bool type_id_is_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
 bool type_id_is_signed(type_id t) { return type_id_is_signed_int(t) || type_id_is_floating_point(t) || type_id_is_decimal(t); }
@@ -106,7 +104,7 @@ bool type_id_is_container(type_id t) { return t == LIST || t == MAP || t == ARRA
 bool type_id_is_scalar(type_id t) { return type_id_is_integral(t) || type_id_is_floating_point(t) || type_id_is_decimal(t) || type_id_is_string_like(t) || t == TIMESTAMP || t == UUID; }
 
 
-std::ostream& operator<<(std::ostream& o,type_id t) { return o << type_name(t); }
+std::ostream& operator<<(std::ostream& o, type_id t) { return o << type_name(t); }
 
 
 pn_bytes_t pn_bytes(const std::string& s) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value.cpp b/proton-c/bindings/cpp/src/value.cpp
index b603bf9..bf652c5 100644
--- a/proton-c/bindings/cpp/src/value.cpp
+++ b/proton-c/bindings/cpp/src/value.cpp
@@ -30,8 +30,20 @@ value::value() : data_(data::create()) {}
 
 value::value(const value& x) : data_(data::create()) { data_.copy(x.data_); }
 
+#if PN_HAS_CPP11
+value::value(value&& x) : data_(0) { swap(x); }
+#endif
+
+// Referencing an external value
+value::value(data d) : data_(d) {}
+
+// Referencing an external value
+value& value::ref(data d) { data_ = d; return *this; }
+
 value& value::operator=(const value& x) { data_.copy(x.data_); return *this; }
 
+void value::swap(value& x) { std::swap(data_, x.data_); }
+
 void value::clear() { data_.clear(); }
 
 bool value::empty() const { return data_.empty(); }
@@ -48,6 +60,8 @@ bool value::operator<(const value& x) const { return data_.less(x.data_); }
 
 std::ostream& operator<<(std::ostream& o, const value& v) {
     // pn_inspect prints strings with quotes which is not normal in C++.
+    if (v.empty())
+        return o << "<empty>";
     switch (v.type()) {
       case STRING:
       case SYMBOL:


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


[16/50] [abbrv] qpid-proton git commit: NO_JIRA: Fixed minor syntax error in proton-c/bindings/python/CMakeLists.txt:91 which was generating a warning

Posted by ac...@apache.org.
NO_JIRA: Fixed minor syntax error in proton-c/bindings/python/CMakeLists.txt:91 which was generating a warning


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

Branch: refs/heads/go1
Commit: f9569b5cc43a1d26df620e48715287b6974df6a6
Parents: d6da8eb
Author: Kim van der Riet <kp...@apache.org>
Authored: Thu Dec 10 12:53:00 2015 -0500
Committer: Kim van der Riet <kp...@apache.org>
Committed: Thu Dec 10 12:53:00 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/python/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f9569b5c/proton-c/bindings/python/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/CMakeLists.txt b/proton-c/bindings/python/CMakeLists.txt
index 9c31b61..05fe2d4 100644
--- a/proton-c/bindings/python/CMakeLists.txt
+++ b/proton-c/bindings/python/CMakeLists.txt
@@ -88,7 +88,7 @@ if (EPYDOC_EXE)
      PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}
      ${EPYDOC_EXE} -v --no-private --html -o ${CMAKE_CURRENT_BINARY_DIR}/html
      ${PY_DOC_FILES}
-     DEPENDENCIES ${SWIG_MODULE_${cproton}_REAL_NAME)
+     DEPENDENCIES ${SWIG_MODULE_${cproton}_REAL_NAME})
    add_dependencies(docs docs-py)
    install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/"
            DESTINATION "${PROTON_SHARE}/docs/api-py"


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


[44/50] [abbrv] qpid-proton git commit: PROTON-1085: c++: Rename "atom" type to "scalar".

Posted by ac...@apache.org.
PROTON-1085: c++: Rename "atom" type to "scalar".

Scalar is the term used in the AMQP standard.


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

Branch: refs/heads/go1
Commit: d2c5a5f2017ed95102b03b173ad050e616fab30b
Parents: fd52a33
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 28 15:37:23 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 29 15:55:38 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   4 +-
 proton-c/bindings/cpp/include/proton/atom.hpp   | 122 ------------
 proton-c/bindings/cpp/include/proton/scalar.hpp | 122 ++++++++++++
 proton-c/bindings/cpp/include/proton/types.hpp  |  14 +-
 proton-c/bindings/cpp/src/atom.cpp              | 185 -------------------
 proton-c/bindings/cpp/src/atom_test.cpp         | 105 -----------
 proton-c/bindings/cpp/src/scalar.cpp            | 185 +++++++++++++++++++
 proton-c/bindings/cpp/src/scalar_test.cpp       | 105 +++++++++++
 proton-c/bindings/cpp/src/types.cpp             |  18 +-
 9 files changed, 430 insertions(+), 430 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 78df0b5..10d40f8 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -26,7 +26,7 @@ include_directories(
 
 set(qpid-proton-cpp-source
   src/acceptor.cpp
-  src/atom.cpp
+  src/scalar.cpp
   src/blocking_connection.cpp
   src/blocking_connection_impl.cpp
   src/blocking_fetcher.cpp
@@ -170,4 +170,4 @@ endmacro(add_cpp_test)
 add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests)
 add_cpp_test(message_test)
 add_cpp_test(encode_decode_test)
-add_cpp_test(atom_test)
+add_cpp_test(scalar_test)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/include/proton/atom.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/atom.hpp b/proton-c/bindings/cpp/include/proton/atom.hpp
deleted file mode 100644
index ce2a385..0000000
--- a/proton-c/bindings/cpp/include/proton/atom.hpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#ifndef ATOM_HPP
-#define ATOM_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/types.hpp"
-#include <iosfwd>
-
-namespace proton {
-
-class atom;
-
-/** atom holds an instance of an atomic proton type. */
-class atom : public comparable<atom> {
-  public:
-    PN_CPP_EXTERN atom();
-    // Use default assign and copy.
-
-    /// Type for the value in the atom, NULL_TYPE if empty()
-    PN_CPP_EXTERN type_id type() const;
-    /// True if the atom is empty.
-    PN_CPP_EXTERN bool empty() const;
-
-    ///@name Create an atom, type() is deduced from the C++ type of the value.
-    ///@{
-    PN_CPP_EXTERN explicit atom(bool);
-    PN_CPP_EXTERN explicit atom(uint8_t);
-    PN_CPP_EXTERN explicit atom(int8_t);
-    PN_CPP_EXTERN explicit atom(uint16_t);
-    PN_CPP_EXTERN explicit atom(int16_t);
-    PN_CPP_EXTERN explicit atom(uint32_t);
-    PN_CPP_EXTERN explicit atom(int32_t);
-    PN_CPP_EXTERN explicit atom(uint64_t);
-    PN_CPP_EXTERN explicit atom(int64_t);
-    PN_CPP_EXTERN explicit atom(wchar_t);
-    PN_CPP_EXTERN explicit atom(float);
-    PN_CPP_EXTERN explicit atom(double);
-    PN_CPP_EXTERN explicit atom(amqp_timestamp);
-    PN_CPP_EXTERN explicit atom(const amqp_decimal32&);
-    PN_CPP_EXTERN explicit atom(const amqp_decimal64&);
-    PN_CPP_EXTERN explicit atom(const amqp_decimal128&);
-    PN_CPP_EXTERN explicit atom(const amqp_uuid&);
-    PN_CPP_EXTERN explicit atom(const amqp_string&);
-    PN_CPP_EXTERN explicit atom(const amqp_symbol&);
-    PN_CPP_EXTERN explicit atom(const amqp_binary&);
-    PN_CPP_EXTERN explicit atom(const std::string& s); ///< Treated as an AMQP string
-    PN_CPP_EXTERN explicit atom(const char* s);        ///< Treated as an AMQP string
-    ///@}
-
-    /// Assign to an atom using the same rules as construction.
-    template <class T> atom& operator=(T x) { return *this = atom(x); }
-
-    ///@name get(T&) extracts the value if the types match exactly,
-    ///i.e. if `type() == type_id_of<T>::value`
-    /// throws type_mismatch otherwise.
-    ///@{
-    PN_CPP_EXTERN void get(bool&) const;
-    PN_CPP_EXTERN void get(uint8_t&) const;
-    PN_CPP_EXTERN void get(int8_t&) const;
-    PN_CPP_EXTERN void get(uint16_t&) const;
-    PN_CPP_EXTERN void get(int16_t&) const;
-    PN_CPP_EXTERN void get(uint32_t&) const;
-    PN_CPP_EXTERN void get(int32_t&) const;
-    PN_CPP_EXTERN void get(uint64_t&) const;
-    PN_CPP_EXTERN void get(int64_t&) const;
-    PN_CPP_EXTERN void get(wchar_t&) const;
-    PN_CPP_EXTERN void get(float&) const;
-    PN_CPP_EXTERN void get(double&) const;
-    PN_CPP_EXTERN void get(amqp_timestamp&) const;
-    PN_CPP_EXTERN void get(amqp_decimal32&) const;
-    PN_CPP_EXTERN void get(amqp_decimal64&) const;
-    PN_CPP_EXTERN void get(amqp_decimal128&) const;
-    PN_CPP_EXTERN void get(amqp_uuid&) const;
-    PN_CPP_EXTERN void get(amqp_string&) const;
-    PN_CPP_EXTERN void get(amqp_symbol&) const;
-    PN_CPP_EXTERN void get(amqp_binary&) const;
-    PN_CPP_EXTERN void get(std::string&) const; ///< Treated as an AMQP string
-    ///@}
-
-    ///@ get<T>() is like get(T&) but returns the value..
-    template<class T> T get() const { T x; get(x); return x; }
-
-    ///@name as_ methods do "loose" conversion, they will convert the atom's
-    ///value to the requested type if possible, else throw type_mismatch
-    ///@{
-    PN_CPP_EXTERN int64_t as_int() const;     ///< Allowed if type_id_integral(type())
-    PN_CPP_EXTERN uint64_t as_uint() const;   ///< Allowed if type_id_integral(type())
-    PN_CPP_EXTERN double as_double() const;    ///< Allowed if type_id_floating_point(type())
-    PN_CPP_EXTERN std::string as_string() const; ///< Allowed if type_id_string_like(type())
-    ///@}
-
-    PN_CPP_EXTERN bool operator==(const atom& x) const;
-    /// Note if the values are of different type(), operator< will compare the type()
-    PN_CPP_EXTERN bool operator<(const atom& x) const;
-
-  PN_CPP_EXTERN friend std::ostream& operator<<(std::ostream&, const atom&);
-
-  private:
-    void ok(pn_type_t) const;
-    void set(const std::string&);
-    pn_atom_t atom_;
-    std::string str_;           // Owner of string-like data.
-};
-
-}
-#endif // ATOM_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
new file mode 100644
index 0000000..0745281
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -0,0 +1,122 @@
+#ifndef SCALAR_HPP
+#define SCALAR_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/types.hpp"
+#include <iosfwd>
+
+namespace proton {
+
+class scalar;
+
+/** scalar holds an instance of an atomic proton type. */
+class scalar : public comparable<scalar> {
+  public:
+    PN_CPP_EXTERN scalar();
+    // Use default assign and copy.
+
+    /// Type for the value in the scalar, NULL_TYPE if empty()
+    PN_CPP_EXTERN type_id type() const;
+    /// True if the scalar is empty.
+    PN_CPP_EXTERN bool empty() const;
+
+    ///@name Create an scalar, type() is deduced from the C++ type of the value.
+    ///@{
+    PN_CPP_EXTERN explicit scalar(bool);
+    PN_CPP_EXTERN explicit scalar(uint8_t);
+    PN_CPP_EXTERN explicit scalar(int8_t);
+    PN_CPP_EXTERN explicit scalar(uint16_t);
+    PN_CPP_EXTERN explicit scalar(int16_t);
+    PN_CPP_EXTERN explicit scalar(uint32_t);
+    PN_CPP_EXTERN explicit scalar(int32_t);
+    PN_CPP_EXTERN explicit scalar(uint64_t);
+    PN_CPP_EXTERN explicit scalar(int64_t);
+    PN_CPP_EXTERN explicit scalar(wchar_t);
+    PN_CPP_EXTERN explicit scalar(float);
+    PN_CPP_EXTERN explicit scalar(double);
+    PN_CPP_EXTERN explicit scalar(amqp_timestamp);
+    PN_CPP_EXTERN explicit scalar(const amqp_decimal32&);
+    PN_CPP_EXTERN explicit scalar(const amqp_decimal64&);
+    PN_CPP_EXTERN explicit scalar(const amqp_decimal128&);
+    PN_CPP_EXTERN explicit scalar(const amqp_uuid&);
+    PN_CPP_EXTERN explicit scalar(const amqp_string&);
+    PN_CPP_EXTERN explicit scalar(const amqp_symbol&);
+    PN_CPP_EXTERN explicit scalar(const amqp_binary&);
+    PN_CPP_EXTERN explicit scalar(const std::string& s); ///< Treated as an AMQP string
+    PN_CPP_EXTERN explicit scalar(const char* s);        ///< Treated as an AMQP string
+    ///@}
+
+    /// Assign to an scalar using the same rules as construction.
+    template <class T> scalar& operator=(T x) { return *this = scalar(x); }
+
+    ///@name get(T&) extracts the value if the types match exactly,
+    ///i.e. if `type() == type_id_of<T>::value`
+    /// throws type_mismatch otherwise.
+    ///@{
+    PN_CPP_EXTERN void get(bool&) const;
+    PN_CPP_EXTERN void get(uint8_t&) const;
+    PN_CPP_EXTERN void get(int8_t&) const;
+    PN_CPP_EXTERN void get(uint16_t&) const;
+    PN_CPP_EXTERN void get(int16_t&) const;
+    PN_CPP_EXTERN void get(uint32_t&) const;
+    PN_CPP_EXTERN void get(int32_t&) const;
+    PN_CPP_EXTERN void get(uint64_t&) const;
+    PN_CPP_EXTERN void get(int64_t&) const;
+    PN_CPP_EXTERN void get(wchar_t&) const;
+    PN_CPP_EXTERN void get(float&) const;
+    PN_CPP_EXTERN void get(double&) const;
+    PN_CPP_EXTERN void get(amqp_timestamp&) const;
+    PN_CPP_EXTERN void get(amqp_decimal32&) const;
+    PN_CPP_EXTERN void get(amqp_decimal64&) const;
+    PN_CPP_EXTERN void get(amqp_decimal128&) const;
+    PN_CPP_EXTERN void get(amqp_uuid&) const;
+    PN_CPP_EXTERN void get(amqp_string&) const;
+    PN_CPP_EXTERN void get(amqp_symbol&) const;
+    PN_CPP_EXTERN void get(amqp_binary&) const;
+    PN_CPP_EXTERN void get(std::string&) const; ///< Treated as an AMQP string
+    ///@}
+
+    ///@ get<T>() is like get(T&) but returns the value..
+    template<class T> T get() const { T x; get(x); return x; }
+
+    ///@name as_ methods do "loose" conversion, they will convert the scalar's
+    ///value to the requested type if possible, else throw type_mismatch
+    ///@{
+    PN_CPP_EXTERN int64_t as_int() const;     ///< Allowed if type_id_integral(type())
+    PN_CPP_EXTERN uint64_t as_uint() const;   ///< Allowed if type_id_integral(type())
+    PN_CPP_EXTERN double as_double() const;    ///< Allowed if type_id_floating_point(type())
+    PN_CPP_EXTERN std::string as_string() const; ///< Allowed if type_id_string_like(type())
+    ///@}
+
+    PN_CPP_EXTERN bool operator==(const scalar& x) const;
+    /// Note if the values are of different type(), operator< will compare the type()
+    PN_CPP_EXTERN bool operator<(const scalar& x) const;
+
+  PN_CPP_EXTERN friend std::ostream& operator<<(std::ostream&, const scalar&);
+
+  private:
+    void ok(pn_type_t) const;
+    void set(const std::string&);
+    pn_atom_t atom_;
+    std::string str_;           // Owner of string-like data.
+};
+
+}
+#endif // SCALAR_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index 75bb226..645d9da 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -198,13 +198,13 @@ PN_CPP_EXTERN std::string type_name(type_id);
 ///@name Attributes of a type_id value, returns same result as the
 /// corresponding std::type_traits tests for the corresponding C++ types.
 ///@{
-PN_CPP_EXTERN bool type_id_atom(type_id);
-PN_CPP_EXTERN bool type_id_integral(type_id);
-PN_CPP_EXTERN bool type_id_signed(type_id); ///< CHAR and BOOL are not signed.
-PN_CPP_EXTERN bool type_id_floating_point(type_id);
-PN_CPP_EXTERN bool type_id_decimal(type_id);
-PN_CPP_EXTERN bool type_id_string_like(type_id);   ///< STRING, SYMBOL, BINARY
-PN_CPP_EXTERN bool type_id_container(type_id);
+PN_CPP_EXTERN bool type_id_is_scalar(type_id);
+PN_CPP_EXTERN bool type_id_is_integral(type_id);
+PN_CPP_EXTERN bool type_id_is_signed(type_id); ///< CHAR and BOOL are not signed.
+PN_CPP_EXTERN bool type_id_is_floating_point(type_id);
+PN_CPP_EXTERN bool type_id_is_decimal(type_id);
+PN_CPP_EXTERN bool type_id_is_string_like(type_id);   ///< STRING, SYMBOL, BINARY
+PN_CPP_EXTERN bool type_id_is_container(type_id);
 ///@}
 
 /** Print the name of a type. */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/src/atom.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/atom.cpp b/proton-c/bindings/cpp/src/atom.cpp
deleted file mode 100644
index 034b22c..0000000
--- a/proton-c/bindings/cpp/src/atom.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "proton/atom.hpp"
-#include "proton/type_traits.hpp"
-
-#include <ostream>
-
-namespace proton {
-
-atom::atom() { atom_.type = PN_NULL; }
-
-type_id atom::type() const { return type_id(atom_.type); }
-bool atom::empty() const { return type() == NULL_TYPE; }
-
-atom::atom(bool x) { atom_.u.as_bool = x; atom_.type = PN_BOOL; }
-atom::atom(uint8_t x) { atom_.u.as_ubyte = x; atom_.type = PN_UBYTE; }
-atom::atom(int8_t x) { atom_.u.as_byte = x; atom_.type = PN_BYTE; }
-atom::atom(uint16_t x) { atom_.u.as_ushort = x; atom_.type = PN_USHORT; }
-atom::atom(int16_t x) { atom_.u.as_short = x; atom_.type = PN_SHORT; }
-atom::atom(uint32_t x) { atom_.u.as_uint = x; atom_.type = PN_UINT; }
-atom::atom(int32_t x) { atom_.u.as_int = x; atom_.type = PN_INT; }
-atom::atom(uint64_t x) { atom_.u.as_ulong = x; atom_.type = PN_ULONG; }
-atom::atom(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG; }
-atom::atom(wchar_t x) { atom_.u.as_char = pn_char_t(x); atom_.type = PN_CHAR; }
-atom::atom(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; }
-atom::atom(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; }
-atom::atom(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; }
-atom::atom(const amqp_decimal32& x) { atom_.u.as_decimal32 = x; atom_.type = PN_DECIMAL32; }
-atom::atom(const amqp_decimal64& x) { atom_.u.as_decimal64 = x; atom_.type = PN_DECIMAL64; }
-atom::atom(const amqp_decimal128& x) { atom_.u.as_decimal128 = x; atom_.type = PN_DECIMAL128; }
-atom::atom(const amqp_uuid& x) { atom_.u.as_uuid = x; atom_.type = PN_UUID; }
-
-void atom::set(const std::string& x) { str_ = x; atom_.u.as_bytes = pn_bytes(str_); }
-atom::atom(const amqp_string& x) { set(x); atom_.type = PN_STRING; }
-atom::atom(const amqp_symbol& x) { set(x); atom_.type = PN_SYMBOL; }
-atom::atom(const amqp_binary& x) { set(x); atom_.type = PN_BINARY; }
-atom::atom(const std::string& x) { *this = amqp_string(x); }
-atom::atom(const char* x) { *this = amqp_string(x); }
-
-void atom::ok(pn_type_t t) const {
-    if (atom_.type != t) throw type_mismatch(type_id(t), type());
-}
-
-void atom::get(bool& x) const { ok(PN_BOOL); x = atom_.u.as_bool; }
-void atom::get(uint8_t& x) const { ok(PN_UBYTE); x = atom_.u.as_ubyte; }
-void atom::get(int8_t& x) const { ok(PN_BYTE); x = atom_.u.as_byte; }
-void atom::get(uint16_t& x) const { ok(PN_USHORT); x = atom_.u.as_ushort; }
-void atom::get(int16_t& x) const { ok(PN_SHORT); x = atom_.u.as_short; }
-void atom::get(uint32_t& x) const { ok(PN_UINT); x = atom_.u.as_uint; }
-void atom::get(int32_t& x) const { ok(PN_INT); x = atom_.u.as_int; }
-void atom::get(wchar_t& x) const { ok(PN_CHAR); x = wchar_t(atom_.u.as_char); }
-void atom::get(uint64_t& x) const { ok(PN_ULONG); x = atom_.u.as_ulong; }
-void atom::get(int64_t& x) const { ok(PN_LONG); x = atom_.u.as_long; }
-void atom::get(amqp_timestamp& x) const { ok(PN_TIMESTAMP); x = atom_.u.as_timestamp; }
-void atom::get(float& x) const { ok(PN_FLOAT); x = atom_.u.as_float; }
-void atom::get(double& x) const { ok(PN_DOUBLE); x = atom_.u.as_double; }
-void atom::get(amqp_decimal32& x) const { ok(PN_DECIMAL32); x = atom_.u.as_decimal32; }
-void atom::get(amqp_decimal64& x) const { ok(PN_DECIMAL64); x = atom_.u.as_decimal64; }
-void atom::get(amqp_decimal128& x) const { ok(PN_DECIMAL128); x = atom_.u.as_decimal128; }
-void atom::get(amqp_uuid& x) const { ok(PN_UUID); x = atom_.u.as_uuid; }
-void atom::get(amqp_string& x) const { ok(PN_STRING); x = str_; }
-void atom::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = str_; }
-void atom::get(amqp_binary& x) const { ok(PN_BINARY); x = str_; }
-void atom::get(std::string& x) const { x = get<amqp_string>(); }
-
-int64_t atom::as_int() const {
-    if (type_id_floating_point(type()))
-        return int64_t(as_double());
-    switch (atom_.type) {
-      case PN_BOOL: return atom_.u.as_bool;
-      case PN_UBYTE: return atom_.u.as_ubyte;
-      case PN_BYTE: return atom_.u.as_byte;
-      case PN_USHORT: return atom_.u.as_ushort;
-      case PN_SHORT: return atom_.u.as_short;
-      case PN_UINT: return atom_.u.as_uint;
-      case PN_INT: return atom_.u.as_int;
-      case PN_CHAR: return atom_.u.as_char;
-      case PN_ULONG: return int64_t(atom_.u.as_ulong);
-      case PN_LONG: return atom_.u.as_long;
-      default: throw type_mismatch(LONG, type(), "cannot convert");
-    }
-}
-
-uint64_t atom::as_uint() const {
-    if  (!type_id_integral(type()))
-        throw type_mismatch(ULONG, type(), "cannot convert");
-    return uint64_t(as_int());
-}
-
-double atom::as_double() const {
-    if (type_id_integral(type())) {
-        return type_id_signed(type()) ? double(as_int()) : double(as_uint());
-    }
-    switch (atom_.type) {
-      case PN_DOUBLE: return atom_.u.as_double;
-      case PN_FLOAT: return atom_.u.as_float;
-      default: throw type_mismatch(DOUBLE, type(), "cannot convert");
-    }
-}
-
-std::string atom::as_string() const {
-    if (type_id_string_like(type()))
-        return str_;
-    throw type_mismatch(DOUBLE, type(), "cannot convert");
-}
-
-
-namespace {
-template <class T, class F> T type_switch(const atom& a, F f) {
-    switch(a.type()) {
-      case BOOLEAN: return f(a.get<bool>());
-      case UBYTE: return f(a.get<uint8_t>());
-      case BYTE: return f(a.get<int8_t>());
-      case USHORT: return f(a.get<uint16_t>());
-      case SHORT: return f(a.get<int16_t>());
-      case UINT: return f(a.get<uint32_t>());
-      case INT: return f(a.get<int32_t>());
-      case CHAR: return f(a.get<wchar_t>());
-      case ULONG: return f(a.get<uint64_t>());
-      case LONG: return f(a.get<int64_t>());
-      case TIMESTAMP: return f(a.get<amqp_timestamp>());
-      case FLOAT: return f(a.get<float>());
-      case DOUBLE: return f(a.get<double>());
-      case DECIMAL32: return f(a.get<amqp_decimal32>());
-      case DECIMAL64: return f(a.get<amqp_decimal64>());
-      case DECIMAL128: return f(a.get<amqp_decimal128>());
-      case UUID: return f(a.get<amqp_uuid>());
-      case BINARY: return f(a.get<amqp_binary>());
-      case STRING: return f(a.get<amqp_string>());
-      case SYMBOL: return f(a.get<amqp_symbol>());
-      default:
-        throw error("bad atom type");
-    }
-}
-
-struct equal_op {
-    const atom& a;
-    equal_op(const atom& a_) : a(a_) {}
-    template<class T> bool operator()(T x) { return x == a.get<T>(); }
-};
-
-struct less_op {
-    const atom& a;
-    less_op(const atom& a_) : a(a_) {}
-    template<class T> bool operator()(T x) { return x < a.get<T>(); }
-};
-
-struct ostream_op {
-    std::ostream& o;
-    ostream_op(std::ostream& o_) : o(o_) {}
-    template<class T> std::ostream& operator()(T x) { return o << x; }
-};
-
-} // namespace
-
-bool atom::operator==(const atom& x) const {
-    return type_switch<bool>(*this, equal_op(x));
-}
-
-bool atom::operator<(const atom& x) const {
-    return type_switch<bool>(*this, less_op(x));
-}
-
-std::ostream& operator<<(std::ostream& o, const atom& a) {
-    return type_switch<std::ostream&>(a, ostream_op(o));
-}
-
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/src/atom_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/atom_test.cpp b/proton-c/bindings/cpp/src/atom_test.cpp
deleted file mode 100644
index 0d85a36..0000000
--- a/proton-c/bindings/cpp/src/atom_test.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "test_bits.hpp"
-#include "proton/type_traits.hpp"
-
-#include <proton/atom.hpp>
-
-using namespace std;
-using namespace proton;
-
-// Inserting and extracting simple C++ values.
-template <class T> void type_test(T x, type_id tid, T y) {
-    atom v(x);
-    ASSERT_EQUAL(tid, v.type());
-    ASSERT(!v.empty());
-    ASSERT_EQUAL(x, v.get<T>());
-
-    atom v2;
-    ASSERT(v2.type() == NULL_TYPE);
-    v2 = x;
-    ASSERT_EQUAL(tid, v2.type());
-    ASSERT_EQUAL(x, v2.get<T>());
-    ASSERT_EQUAL(v, v2);
-    ASSERT_EQUAL(str(x), str(v));
-
-    v2 = y;
-    ASSERT(v != v2);
-    ASSERT(v < v2);
-    ASSERT(v2 > v);
-}
-
-#define ASSERT_MISMATCH(EXPR) \
-    try { (void)(EXPR); FAIL("expected type_mismatch: " #EXPR); } catch (type_mismatch) {}
-
-void convert_test() {
-    atom a;
-    ASSERT_EQUAL(NULL_TYPE, a.type());
-    ASSERT(a.empty());
-    ASSERT_MISMATCH(a.get<float>());
-
-    a = amqp_binary("foo");
-    ASSERT_MISMATCH(a.get<int16_t>());
-    ASSERT_MISMATCH(a.as_int());
-    ASSERT_MISMATCH(a.as_double());
-    ASSERT_MISMATCH(a.get<amqp_string>());           // No strict conversion
-    ASSERT_EQUAL(a.as_string(), std::string("foo")); // OK string-like conversion
-
-    a = int16_t(42);
-    ASSERT_MISMATCH(a.get<std::string>());
-    ASSERT_MISMATCH(a.get<amqp_timestamp>());
-    ASSERT_MISMATCH(a.as_string());
-    ASSERT_EQUAL(a.as_int(), 42);
-    ASSERT_EQUAL(a.as_uint(), 42);
-    ASSERT_EQUAL(a.as_double(), 42);
-
-    a = int16_t(-42);
-    ASSERT_EQUAL(a.as_int(), -42);
-    ASSERT_EQUAL(a.as_uint(), uint64_t(-42));
-    ASSERT_EQUAL(a.as_double(), -42);
-}
-
-int main(int, char**) {
-    int failed = 0;
-    RUN_TEST(failed, type_test(false, BOOLEAN, true));
-    RUN_TEST(failed, type_test(amqp_ubyte(42), UBYTE, amqp_ubyte(50)));
-    RUN_TEST(failed, type_test(amqp_byte('x'), BYTE, amqp_byte('y')));
-    RUN_TEST(failed, type_test(amqp_ushort(4242), USHORT, amqp_ushort(5252)));
-    RUN_TEST(failed, type_test(amqp_short(-4242), SHORT, amqp_short(3)));
-    RUN_TEST(failed, type_test(amqp_uint(4242), UINT, amqp_uint(5252)));
-    RUN_TEST(failed, type_test(amqp_int(-4242), INT, amqp_int(3)));
-    RUN_TEST(failed, type_test(amqp_ulong(4242), ULONG, amqp_ulong(5252)));
-    RUN_TEST(failed, type_test(amqp_long(-4242), LONG, amqp_long(3)));
-    RUN_TEST(failed, type_test(wchar_t(23), CHAR, wchar_t(24)));
-    RUN_TEST(failed, type_test(amqp_float(1.234), FLOAT, amqp_float(2.345)));
-    RUN_TEST(failed, type_test(amqp_double(11.2233), DOUBLE, amqp_double(12)));
-    RUN_TEST(failed, type_test(amqp_timestamp(0), TIMESTAMP, amqp_timestamp(1)));
-    RUN_TEST(failed, type_test(amqp_decimal32(0), DECIMAL32, amqp_decimal32(1)));
-    RUN_TEST(failed, type_test(amqp_decimal64(0), DECIMAL64, amqp_decimal64(1)));
-    pn_decimal128_t da = {0}, db = {1};
-    RUN_TEST(failed, type_test(amqp_decimal128(da), DECIMAL128, amqp_decimal128(db)));
-    pn_uuid_t ua = {0}, ub = {1};
-    RUN_TEST(failed, type_test(amqp_uuid(ua), UUID, amqp_uuid(ub)));
-    RUN_TEST(failed, type_test(amqp_string("aaa"), STRING, amqp_string("aaaa")));
-    RUN_TEST(failed, type_test(amqp_symbol("aaa"), SYMBOL, amqp_symbol("aaaa")));
-    RUN_TEST(failed, type_test(amqp_binary("aaa"), BINARY, amqp_binary("aaaa")));
-    RUN_TEST(failed, type_test(std::string("xxx"), STRING, std::string("yyy")));
-    return failed;
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/src/scalar.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar.cpp b/proton-c/bindings/cpp/src/scalar.cpp
new file mode 100644
index 0000000..13daf32
--- /dev/null
+++ b/proton-c/bindings/cpp/src/scalar.cpp
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/scalar.hpp"
+#include "proton/type_traits.hpp"
+
+#include <ostream>
+
+namespace proton {
+
+scalar::scalar() { atom_.type = PN_NULL; }
+
+type_id scalar::type() const { return type_id(atom_.type); }
+bool scalar::empty() const { return type() == NULL_TYPE; }
+
+scalar::scalar(bool x) { atom_.u.as_bool = x; atom_.type = PN_BOOL; }
+scalar::scalar(uint8_t x) { atom_.u.as_ubyte = x; atom_.type = PN_UBYTE; }
+scalar::scalar(int8_t x) { atom_.u.as_byte = x; atom_.type = PN_BYTE; }
+scalar::scalar(uint16_t x) { atom_.u.as_ushort = x; atom_.type = PN_USHORT; }
+scalar::scalar(int16_t x) { atom_.u.as_short = x; atom_.type = PN_SHORT; }
+scalar::scalar(uint32_t x) { atom_.u.as_uint = x; atom_.type = PN_UINT; }
+scalar::scalar(int32_t x) { atom_.u.as_int = x; atom_.type = PN_INT; }
+scalar::scalar(uint64_t x) { atom_.u.as_ulong = x; atom_.type = PN_ULONG; }
+scalar::scalar(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG; }
+scalar::scalar(wchar_t x) { atom_.u.as_char = pn_char_t(x); atom_.type = PN_CHAR; }
+scalar::scalar(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; }
+scalar::scalar(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; }
+scalar::scalar(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; }
+scalar::scalar(const amqp_decimal32& x) { atom_.u.as_decimal32 = x; atom_.type = PN_DECIMAL32; }
+scalar::scalar(const amqp_decimal64& x) { atom_.u.as_decimal64 = x; atom_.type = PN_DECIMAL64; }
+scalar::scalar(const amqp_decimal128& x) { atom_.u.as_decimal128 = x; atom_.type = PN_DECIMAL128; }
+scalar::scalar(const amqp_uuid& x) { atom_.u.as_uuid = x; atom_.type = PN_UUID; }
+
+void scalar::set(const std::string& x) { str_ = x; atom_.u.as_bytes = pn_bytes(str_); }
+scalar::scalar(const amqp_string& x) { set(x); atom_.type = PN_STRING; }
+scalar::scalar(const amqp_symbol& x) { set(x); atom_.type = PN_SYMBOL; }
+scalar::scalar(const amqp_binary& x) { set(x); atom_.type = PN_BINARY; }
+scalar::scalar(const std::string& x) { *this = amqp_string(x); }
+scalar::scalar(const char* x) { *this = amqp_string(x); }
+
+void scalar::ok(pn_type_t t) const {
+    if (atom_.type != t) throw type_mismatch(type_id(t), type());
+}
+
+void scalar::get(bool& x) const { ok(PN_BOOL); x = atom_.u.as_bool; }
+void scalar::get(uint8_t& x) const { ok(PN_UBYTE); x = atom_.u.as_ubyte; }
+void scalar::get(int8_t& x) const { ok(PN_BYTE); x = atom_.u.as_byte; }
+void scalar::get(uint16_t& x) const { ok(PN_USHORT); x = atom_.u.as_ushort; }
+void scalar::get(int16_t& x) const { ok(PN_SHORT); x = atom_.u.as_short; }
+void scalar::get(uint32_t& x) const { ok(PN_UINT); x = atom_.u.as_uint; }
+void scalar::get(int32_t& x) const { ok(PN_INT); x = atom_.u.as_int; }
+void scalar::get(wchar_t& x) const { ok(PN_CHAR); x = wchar_t(atom_.u.as_char); }
+void scalar::get(uint64_t& x) const { ok(PN_ULONG); x = atom_.u.as_ulong; }
+void scalar::get(int64_t& x) const { ok(PN_LONG); x = atom_.u.as_long; }
+void scalar::get(amqp_timestamp& x) const { ok(PN_TIMESTAMP); x = atom_.u.as_timestamp; }
+void scalar::get(float& x) const { ok(PN_FLOAT); x = atom_.u.as_float; }
+void scalar::get(double& x) const { ok(PN_DOUBLE); x = atom_.u.as_double; }
+void scalar::get(amqp_decimal32& x) const { ok(PN_DECIMAL32); x = atom_.u.as_decimal32; }
+void scalar::get(amqp_decimal64& x) const { ok(PN_DECIMAL64); x = atom_.u.as_decimal64; }
+void scalar::get(amqp_decimal128& x) const { ok(PN_DECIMAL128); x = atom_.u.as_decimal128; }
+void scalar::get(amqp_uuid& x) const { ok(PN_UUID); x = atom_.u.as_uuid; }
+void scalar::get(amqp_string& x) const { ok(PN_STRING); x = str_; }
+void scalar::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = str_; }
+void scalar::get(amqp_binary& x) const { ok(PN_BINARY); x = str_; }
+void scalar::get(std::string& x) const { x = get<amqp_string>(); }
+
+int64_t scalar::as_int() const {
+    if (type_id_is_floating_point(type()))
+        return int64_t(as_double());
+    switch (atom_.type) {
+      case PN_BOOL: return atom_.u.as_bool;
+      case PN_UBYTE: return atom_.u.as_ubyte;
+      case PN_BYTE: return atom_.u.as_byte;
+      case PN_USHORT: return atom_.u.as_ushort;
+      case PN_SHORT: return atom_.u.as_short;
+      case PN_UINT: return atom_.u.as_uint;
+      case PN_INT: return atom_.u.as_int;
+      case PN_CHAR: return atom_.u.as_char;
+      case PN_ULONG: return int64_t(atom_.u.as_ulong);
+      case PN_LONG: return atom_.u.as_long;
+      default: throw type_mismatch(LONG, type(), "cannot convert");
+    }
+}
+
+uint64_t scalar::as_uint() const {
+    if  (!type_id_is_integral(type()))
+        throw type_mismatch(ULONG, type(), "cannot convert");
+    return uint64_t(as_int());
+}
+
+double scalar::as_double() const {
+    if (type_id_is_integral(type())) {
+        return type_id_is_signed(type()) ? double(as_int()) : double(as_uint());
+    }
+    switch (atom_.type) {
+      case PN_DOUBLE: return atom_.u.as_double;
+      case PN_FLOAT: return atom_.u.as_float;
+      default: throw type_mismatch(DOUBLE, type(), "cannot convert");
+    }
+}
+
+std::string scalar::as_string() const {
+    if (type_id_is_string_like(type()))
+        return str_;
+    throw type_mismatch(DOUBLE, type(), "cannot convert");
+}
+
+
+namespace {
+template <class T, class F> T type_switch(const scalar& a, F f) {
+    switch(a.type()) {
+      case BOOLEAN: return f(a.get<bool>());
+      case UBYTE: return f(a.get<uint8_t>());
+      case BYTE: return f(a.get<int8_t>());
+      case USHORT: return f(a.get<uint16_t>());
+      case SHORT: return f(a.get<int16_t>());
+      case UINT: return f(a.get<uint32_t>());
+      case INT: return f(a.get<int32_t>());
+      case CHAR: return f(a.get<wchar_t>());
+      case ULONG: return f(a.get<uint64_t>());
+      case LONG: return f(a.get<int64_t>());
+      case TIMESTAMP: return f(a.get<amqp_timestamp>());
+      case FLOAT: return f(a.get<float>());
+      case DOUBLE: return f(a.get<double>());
+      case DECIMAL32: return f(a.get<amqp_decimal32>());
+      case DECIMAL64: return f(a.get<amqp_decimal64>());
+      case DECIMAL128: return f(a.get<amqp_decimal128>());
+      case UUID: return f(a.get<amqp_uuid>());
+      case BINARY: return f(a.get<amqp_binary>());
+      case STRING: return f(a.get<amqp_string>());
+      case SYMBOL: return f(a.get<amqp_symbol>());
+      default:
+        throw error("bad scalar type");
+    }
+}
+
+struct equal_op {
+    const scalar& a;
+    equal_op(const scalar& a_) : a(a_) {}
+    template<class T> bool operator()(T x) { return x == a.get<T>(); }
+};
+
+struct less_op {
+    const scalar& a;
+    less_op(const scalar& a_) : a(a_) {}
+    template<class T> bool operator()(T x) { return x < a.get<T>(); }
+};
+
+struct ostream_op {
+    std::ostream& o;
+    ostream_op(std::ostream& o_) : o(o_) {}
+    template<class T> std::ostream& operator()(T x) { return o << x; }
+};
+
+} // namespace
+
+bool scalar::operator==(const scalar& x) const {
+    return type_switch<bool>(*this, equal_op(x));
+}
+
+bool scalar::operator<(const scalar& x) const {
+    return type_switch<bool>(*this, less_op(x));
+}
+
+std::ostream& operator<<(std::ostream& o, const scalar& a) {
+    return type_switch<std::ostream&>(a, ostream_op(o));
+}
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/src/scalar_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.cpp b/proton-c/bindings/cpp/src/scalar_test.cpp
new file mode 100644
index 0000000..c7de785
--- /dev/null
+++ b/proton-c/bindings/cpp/src/scalar_test.cpp
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "test_bits.hpp"
+#include "proton/type_traits.hpp"
+
+#include <proton/scalar.hpp>
+
+using namespace std;
+using namespace proton;
+
+// Inserting and extracting simple C++ values.
+template <class T> void type_test(T x, type_id tid, T y) {
+    scalar v(x);
+    ASSERT_EQUAL(tid, v.type());
+    ASSERT(!v.empty());
+    ASSERT_EQUAL(x, v.get<T>());
+
+    scalar v2;
+    ASSERT(v2.type() == NULL_TYPE);
+    v2 = x;
+    ASSERT_EQUAL(tid, v2.type());
+    ASSERT_EQUAL(x, v2.get<T>());
+    ASSERT_EQUAL(v, v2);
+    ASSERT_EQUAL(str(x), str(v));
+
+    v2 = y;
+    ASSERT(v != v2);
+    ASSERT(v < v2);
+    ASSERT(v2 > v);
+}
+
+#define ASSERT_MISMATCH(EXPR) \
+    try { (void)(EXPR); FAIL("expected type_mismatch: " #EXPR); } catch (type_mismatch) {}
+
+void convert_test() {
+    scalar a;
+    ASSERT_EQUAL(NULL_TYPE, a.type());
+    ASSERT(a.empty());
+    ASSERT_MISMATCH(a.get<float>());
+
+    a = amqp_binary("foo");
+    ASSERT_MISMATCH(a.get<int16_t>());
+    ASSERT_MISMATCH(a.as_int());
+    ASSERT_MISMATCH(a.as_double());
+    ASSERT_MISMATCH(a.get<amqp_string>());           // No strict conversion
+    ASSERT_EQUAL(a.as_string(), std::string("foo")); // OK string-like conversion
+
+    a = int16_t(42);
+    ASSERT_MISMATCH(a.get<std::string>());
+    ASSERT_MISMATCH(a.get<amqp_timestamp>());
+    ASSERT_MISMATCH(a.as_string());
+    ASSERT_EQUAL(a.as_int(), 42);
+    ASSERT_EQUAL(a.as_uint(), 42);
+    ASSERT_EQUAL(a.as_double(), 42);
+
+    a = int16_t(-42);
+    ASSERT_EQUAL(a.as_int(), -42);
+    ASSERT_EQUAL(a.as_uint(), uint64_t(-42));
+    ASSERT_EQUAL(a.as_double(), -42);
+}
+
+int main(int, char**) {
+    int failed = 0;
+    RUN_TEST(failed, type_test(false, BOOLEAN, true));
+    RUN_TEST(failed, type_test(amqp_ubyte(42), UBYTE, amqp_ubyte(50)));
+    RUN_TEST(failed, type_test(amqp_byte('x'), BYTE, amqp_byte('y')));
+    RUN_TEST(failed, type_test(amqp_ushort(4242), USHORT, amqp_ushort(5252)));
+    RUN_TEST(failed, type_test(amqp_short(-4242), SHORT, amqp_short(3)));
+    RUN_TEST(failed, type_test(amqp_uint(4242), UINT, amqp_uint(5252)));
+    RUN_TEST(failed, type_test(amqp_int(-4242), INT, amqp_int(3)));
+    RUN_TEST(failed, type_test(amqp_ulong(4242), ULONG, amqp_ulong(5252)));
+    RUN_TEST(failed, type_test(amqp_long(-4242), LONG, amqp_long(3)));
+    RUN_TEST(failed, type_test(wchar_t(23), CHAR, wchar_t(24)));
+    RUN_TEST(failed, type_test(amqp_float(1.234), FLOAT, amqp_float(2.345)));
+    RUN_TEST(failed, type_test(amqp_double(11.2233), DOUBLE, amqp_double(12)));
+    RUN_TEST(failed, type_test(amqp_timestamp(0), TIMESTAMP, amqp_timestamp(1)));
+    RUN_TEST(failed, type_test(amqp_decimal32(0), DECIMAL32, amqp_decimal32(1)));
+    RUN_TEST(failed, type_test(amqp_decimal64(0), DECIMAL64, amqp_decimal64(1)));
+    pn_decimal128_t da = {0}, db = {1};
+    RUN_TEST(failed, type_test(amqp_decimal128(da), DECIMAL128, amqp_decimal128(db)));
+    pn_uuid_t ua = {0}, ub = {1};
+    RUN_TEST(failed, type_test(amqp_uuid(ua), UUID, amqp_uuid(ub)));
+    RUN_TEST(failed, type_test(amqp_string("aaa"), STRING, amqp_string("aaaa")));
+    RUN_TEST(failed, type_test(amqp_symbol("aaa"), SYMBOL, amqp_symbol("aaaa")));
+    RUN_TEST(failed, type_test(amqp_binary("aaa"), BINARY, amqp_binary("aaaa")));
+    RUN_TEST(failed, type_test(std::string("xxx"), STRING, std::string("yyy")));
+    return failed;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d2c5a5f2/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp b/proton-c/bindings/cpp/src/types.cpp
index d8e40ce..fa7b0bd 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -95,15 +95,15 @@ std::string type_name(type_id t) {
     return "unknown";
 }
 
-static bool type_id_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
-static bool type_id_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
-bool type_id_integral(type_id t) { return t == BOOLEAN || t == CHAR || type_id_unsigned_int(t) || type_id_signed_int(t); }
-bool type_id_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
-bool type_id_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
-bool type_id_signed(type_id t) { return type_id_signed_int(t) || type_id_floating_point(t) || type_id_decimal(t); }
-bool type_id_string_like(type_id t) { return t == BINARY || t == STRING || t == SYMBOL; }
-bool type_id_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; }
-bool type_id_atom(type_id t) { return type_id_integral(t) || type_id_floating_point(t) || type_id_decimal(t) || type_id_string_like(t) || t == TIMESTAMP || t == UUID; }
+static bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
+static bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
+bool type_id_is_integral(type_id t) { return t == BOOLEAN || t == CHAR || type_id_is_unsigned_int(t) || type_id_is_signed_int(t); }
+bool type_id_is_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
+bool type_id_is_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
+bool type_id_is_signed(type_id t) { return type_id_is_signed_int(t) || type_id_is_floating_point(t) || type_id_is_decimal(t); }
+bool type_id_is_string_like(type_id t) { return t == BINARY || t == STRING || t == SYMBOL; }
+bool type_id_is_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; }
+bool type_id_is_scalar(type_id t) { return type_id_is_integral(t) || type_id_is_floating_point(t) || type_id_is_decimal(t) || type_id_is_string_like(t) || t == TIMESTAMP || t == UUID; }
 
 
 std::ostream& operator<<(std::ostream& o,type_id t) { return o << type_name(t); }


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


[11/50] [abbrv] qpid-proton git commit: PROTON-1068: c++ remove counted_ptr use in ssl.hpp

Posted by ac...@apache.org.
PROTON-1068: c++ remove counted_ptr use in ssl.hpp

Missed by previous commit.


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

Branch: refs/heads/go1
Commit: a8e95823321acbc9b31ebc80c0fe326247a2c194
Parents: 5045ec0
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 4 13:46:32 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 4 13:46:32 2015 -0500

----------------------------------------------------------------------
 .../cpp/include/proton/connection_options.hpp   |  1 -
 proton-c/bindings/cpp/include/proton/ssl.hpp    | 36 +++++-------
 proton-c/bindings/cpp/src/ssl_domain.cpp        | 61 ++++++++------------
 3 files changed, 41 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a8e95823/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index 6c78f54..e221e5b 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -26,7 +26,6 @@
 #include "proton/pn_unique_ptr.hpp"
 #include "proton/reconnect_timer.hpp"
 #include "proton/types.hpp"
-//#include "proton/ssl.hpp"
 
 #include <vector>
 #include <string>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a8e95823/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index d5d80d7..911bbed 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -23,9 +23,6 @@
  */
 #include "proton/export.hpp"
 #include "proton/pn_unique_ptr.hpp"
-#include "proton/counted.hpp"
-#include "proton/counted_ptr.hpp"
-
 #include "proton/ssl.h"
 
 #include <string>
@@ -75,17 +72,25 @@ class ssl_certificate {
     friend class server_domain;
 };
 
-class ssl_domain : public counted {
-    ssl_domain(bool server_type);
+// Base class for SSL configuration
+class ssl_domain {
+  public:
     ~ssl_domain();
+
+  protected:
+    ssl_domain();
+    pn_ssl_domain_t *init(bool is_server);
+    pn_ssl_domain_t *pn_domain();
+
   private:
     pn_ssl_domain_t *impl_;
-    friend class client_domain;
-    friend class server_domain;
+
+  friend class connection_options;
+  friend class container_impl;
 };
 
 /** SSL/TLS configuration for inbound connections created from a listener */
-class server_domain {
+class server_domain : public ssl_domain {
   public:
     /** A server domain based on the supplied X509 certificate specifier. */
     PN_CPP_EXTERN server_domain(ssl_certificate &cert);
@@ -95,28 +100,19 @@ class server_domain {
                                 ssl::verify_mode_t mode = ssl::VERIFY_PEER);
     /** A server domain restricted to available anonymous cipher suites on the platform. */
     PN_CPP_EXTERN server_domain();
-  private:
-    pn_ssl_domain_t *pn_domain();
-    counted_ptr<ssl_domain> ssl_domain_;
-    server_domain(ssl_domain *);
-    friend class connection_options;
-    friend class container_impl;
 };
 
 
 /** SSL/TLS configuration for outgoing connections created */
-class client_domain {
+class client_domain : public ssl_domain {
   public:
     PN_CPP_EXTERN client_domain(const std::string &trust_db, ssl::verify_mode_t = ssl::VERIFY_PEER_NAME);
     PN_CPP_EXTERN client_domain(ssl_certificate&, const std::string &trust_db, ssl::verify_mode_t = ssl::VERIFY_PEER_NAME);
     /** A client domain restricted to available anonymous cipher suites on the platform. */
     PN_CPP_EXTERN client_domain();
+
   private:
-    pn_ssl_domain_t *pn_domain();
-    counted_ptr<ssl_domain> ssl_domain_;
-    client_domain(ssl_domain *);
-    friend class connection_options;
-    friend class container_impl;
+    client_domain(ssl_domain);
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a8e95823/proton-c/bindings/cpp/src/ssl_domain.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp
index ce50aa4..8bb081f 100644
--- a/proton-c/bindings/cpp/src/ssl_domain.cpp
+++ b/proton-c/bindings/cpp/src/ssl_domain.cpp
@@ -26,14 +26,22 @@
 
 namespace proton {
 
-ssl_domain::ssl_domain(bool server_type) {
+ssl_domain::ssl_domain() : impl_(0) {}
+
+// Create on demand
+pn_ssl_domain_t *ssl_domain::init(bool server_type) {
+    if (impl_) return impl_;
     impl_ = pn_ssl_domain(server_type ? PN_SSL_MODE_SERVER : PN_SSL_MODE_CLIENT);
     if (!impl_) throw error(MSG("SSL/TLS unavailable"));
+    return impl_;
 }
 
-ssl_domain::~ssl_domain() { pn_ssl_domain_free(impl_); }
+pn_ssl_domain_t *ssl_domain::pn_domain() { return impl_; }
+
+ssl_domain::~ssl_domain() { if (impl_) pn_ssl_domain_free(impl_); }
 
 namespace {
+
 void set_cred(pn_ssl_domain_t *dom, const std::string &main, const std::string &extra, const std::string &pass, bool pwset) {
     const char *cred2 = extra.empty() ? NULL : extra.c_str();
     const char *pw = pwset ? pass.c_str() : NULL;
@@ -43,15 +51,17 @@ void set_cred(pn_ssl_domain_t *dom, const std::string &main, const std::string &
 }
 }
 
-server_domain::server_domain(ssl_certificate &cert) :
-    ssl_domain_(new ssl_domain(true)) {
-    set_cred(ssl_domain_->impl_, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
+server_domain::server_domain(ssl_certificate &cert) {
+    set_cred(init(true), cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
 }
 
-server_domain::server_domain(ssl_certificate &cert, const std::string &trust_db, const std::string &advertise_db,
-                             ssl::verify_mode_t mode) :
-    ssl_domain_(new ssl_domain(true)) {
-    pn_ssl_domain_t *dom = ssl_domain_->impl_;
+server_domain::server_domain(
+    ssl_certificate &cert,
+    const std::string &trust_db,
+    const std::string &advertise_db,
+    ssl::verify_mode_t mode)
+{
+    pn_ssl_domain_t* dom = init(true);
     set_cred(dom, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
     if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
         throw error(MSG("SSL trust store initialization failure for " << trust_db));
@@ -60,16 +70,7 @@ server_domain::server_domain(ssl_certificate &cert, const std::string &trust_db,
         throw error(MSG("SSL server configuration failure requiring client certificates using " << db));
 }
 
-// Keep default constructor low overhead for default use in connection_options.
-server_domain::server_domain() : ssl_domain_(0) {}
-
-pn_ssl_domain_t* server_domain::pn_domain() {
-    if (!ssl_domain_) {
-        // Lazily create anonymous domain context (no cert).  Could make it a singleton, but rare use?
-        ssl_domain_.reset(new ssl_domain(true));
-    }
-    return ssl_domain_->impl_;
-}
+server_domain::server_domain() {}
 
 namespace {
 void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify_mode_t mode) {
@@ -80,28 +81,17 @@ void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify
 }
 }
 
-client_domain::client_domain(const std::string &trust_db, ssl::verify_mode_t mode) :
-    ssl_domain_(new ssl_domain(false)) {
-    client_setup(ssl_domain_->impl_, trust_db, mode);
+client_domain::client_domain(const std::string &trust_db, ssl::verify_mode_t mode) {
+    client_setup(init(false), trust_db, mode);
 }
 
-client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db, ssl::verify_mode_t mode) :
-    ssl_domain_(new ssl_domain(false)) {
-    pn_ssl_domain_t *dom = ssl_domain_->impl_;
+client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db, ssl::verify_mode_t mode) {
+    pn_ssl_domain_t *dom = init(false);
     set_cred(dom, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
     client_setup(dom, trust_db, mode);
 }
 
-client_domain::client_domain() : ssl_domain_(0) {}
-
-pn_ssl_domain_t* client_domain::pn_domain() {
-    if (!ssl_domain_) {
-        // Lazily create anonymous domain context (no CA).  Could make it a singleton, but rare use?
-        ssl_domain_.reset(new ssl_domain(false));
-    }
-    return ssl_domain_->impl_;
-}
-
+client_domain::client_domain() {}
 
 ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra)
     : certdb_main_(main), certdb_extra_(extra), pw_set_(false) {}
@@ -109,5 +99,4 @@ ssl_certificate::ssl_certificate(const std::string &main, const std::string &ext
 ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra, const std::string &pw)
     : certdb_main_(main), certdb_extra_(extra), passwd_(pw), pw_set_(true) {}
 
-
 } // namespace


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


[27/50] [abbrv] qpid-proton git commit: NO-JIRA: fix C++ valgrind error from d9c0ed5

Posted by ac...@apache.org.
NO-JIRA: fix C++ valgrind error from d9c0ed5


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

Branch: refs/heads/go1
Commit: a4a21be85b5a322c7e8edcf879663d5841285985
Parents: 32fa7cb
Author: Clifford Jansen <cl...@apache.org>
Authored: Mon Dec 14 16:49:09 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Mon Dec 14 16:49:09 2015 -0800

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/ssl.hpp | 1 +
 proton-c/bindings/cpp/src/ssl_domain.cpp     | 7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a4a21be8/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index 609e7e2..579a57f 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -84,6 +84,7 @@ class ssl_domain {
   protected:
     ssl_domain(bool is_server);
     pn_ssl_domain_t *pn_domain();
+    void swap(ssl_domain &);
 
   private:
     ssl_domain_impl *impl_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a4a21be8/proton-c/bindings/cpp/src/ssl_domain.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp
index 9062713..d6c427b 100644
--- a/proton-c/bindings/cpp/src/ssl_domain.cpp
+++ b/proton-c/bindings/cpp/src/ssl_domain.cpp
@@ -60,14 +60,13 @@ ssl_domain::ssl_domain(const ssl_domain &x) {
     impl_->incref();
 }
 ssl_domain& ssl_domain::operator=(const ssl_domain&x) {
-    if (this != &x) {
-        impl_ = x.impl_;
-        impl_->incref();
-    }
+    ssl_domain(x).swap(*this);
     return *this;
 }
 ssl_domain::~ssl_domain() { impl_->decref(); }
 
+void ssl_domain::swap(ssl_domain &x) { std::swap(impl_, x.impl_); }
+
 pn_ssl_domain_t *ssl_domain::pn_domain() { return impl_->pn_domain(); }
 
 


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


[50/50] [abbrv] qpid-proton git commit: Merge branch 'master' into go1 - updated to work with proton C 0.10

Posted by ac...@apache.org.
Merge branch 'master' into go1 - updated to work with proton C 0.10


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

Branch: refs/heads/go1
Commit: c87499a3bcd44c6793c9b5eaa381144a72e06e23
Parents: dfb5b06 bf7e193
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 30 16:07:26 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 30 16:07:26 2015 -0500

----------------------------------------------------------------------
 amqp/codec_shim.h      | 33 +++++++++++++++++++++++++++++++++
 amqp/marshal.go        |  2 +-
 amqp/message.go        |  2 +-
 amqp/types.go          | 11 +++--------
 amqp/unmarshal.go      |  6 +++---
 electron/connection.go |  2 ++
 electron/endpoint.go   | 11 ++++++++---
 electron/sender.go     |  9 ++++-----
 proton/engine.go       |  8 +-------
 proton/wrappers.go     |  5 ++---
 proton/wrappers_gen.go |  2 ++
 11 files changed, 60 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/amqp/codec_shim.h
----------------------------------------------------------------------
diff --cc amqp/codec_shim.h
index 0000000,0000000..b2f9f1c
new file mode 100644
--- /dev/null
+++ b/amqp/codec_shim.h
@@@ -1,0 -1,0 +1,33 @@@
++#ifndef CODEC_SHIM_H
++#define CODEC_SHIM_H
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements.  See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership.  The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License.  You may obtain a copy of the License at
++ *
++ *   http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing,
++ * software distributed under the License is distributed on an
++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++ * KIND, either express or implied.  See the License for the
++ * specific language governing permissions and limitations
++ * under the License.
++ */
++
++/** Stubs to allow the go binding to work with multiple versions of proton. */
++
++#include <proton/codec.h>
++#include <proton/version.h>
++
++#if PN_VERSION_MAJOR == 0 && PN_VERSION_MINOR <= 10
++
++#define PN_INVALID ((pn_type_t)-1)
++
++#endif
++
++#endif // CODEC_SHIM_H

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/amqp/marshal.go
----------------------------------------------------------------------
diff --cc amqp/marshal.go
index 9930e13,0000000..66e14d8
mode 100644,000000..100644
--- a/amqp/marshal.go
+++ b/amqp/marshal.go
@@@ -1,250 -1,0 +1,250 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package amqp
 +
- // #include <proton/codec.h>
++//#include "codec_shim.h"
 +import "C"
 +
 +import (
 +	"fmt"
 +	"io"
 +	"reflect"
 +	"unsafe"
 +)
 +
 +func dataError(prefix string, data *C.pn_data_t) error {
 +	err := PnError(C.pn_data_error(data))
 +	if err != nil {
 +		err = fmt.Errorf("%s: %s", prefix, err.Error())
 +	}
 +	return err
 +}
 +
 +/*
 +Marshal encodes a Go value as AMQP data in buffer.
 +If buffer is nil, or is not large enough, a new buffer  is created.
 +
 +Returns the buffer used for encoding with len() adjusted to the actual size of data.
 +
 +Go types are encoded as follows
 +
 + +-------------------------------------+--------------------------------------------+
 + |Go type                              |AMQP type                                   |
 + +-------------------------------------+--------------------------------------------+
 + |bool                                 |bool                                        |
 + +-------------------------------------+--------------------------------------------+
 + |int8, int16, int32, int64 (int)      |byte, short, int, long (int or long)        |
 + +-------------------------------------+--------------------------------------------+
 + |uint8, uint16, uint32, uint64 (uint) |ubyte, ushort, uint, ulong (uint or ulong)  |
 + +-------------------------------------+--------------------------------------------+
 + |float32, float64                     |float, double.                              |
 + +-------------------------------------+--------------------------------------------+
 + |string                               |string                                      |
 + +-------------------------------------+--------------------------------------------+
 + |[]byte, Binary                       |binary                                      |
 + +-------------------------------------+--------------------------------------------+
 + |Symbol                               |symbol                                      |
 + +-------------------------------------+--------------------------------------------+
 + |interface{}                          |the contained type                          |
 + +-------------------------------------+--------------------------------------------+
 + |nil                                  |null                                        |
 + +-------------------------------------+--------------------------------------------+
 + |map[K]T                              |map with K and T converted as above         |
 + +-------------------------------------+--------------------------------------------+
 + |Map                                  |map, may have mixed types for keys, values  |
 + +-------------------------------------+--------------------------------------------+
 + |[]T                                  |list with T converted as above              |
 + +-------------------------------------+--------------------------------------------+
 + |List                                 |list, may have mixed types  values          |
 + +-------------------------------------+--------------------------------------------+
 +
 +The following Go types cannot be marshaled: uintptr, function, interface, channel
 +
 +TODO
 +
 +Go types: array, slice, struct, complex64/128.
 +
 +AMQP types: decimal32/64/128, char, timestamp, uuid, array, multi-section message bodies.
 +
 +Described types.
 +
 +*/
 +func Marshal(v interface{}, buffer []byte) (outbuf []byte, err error) {
 +	defer doRecover(&err)
 +	data := C.pn_data(0)
 +	defer C.pn_data_free(data)
 +	marshal(v, data)
 +	encode := func(buf []byte) ([]byte, error) {
 +		n := int(C.pn_data_encode(data, cPtr(buf), cLen(buf)))
 +		switch {
 +		case n == int(C.PN_OVERFLOW):
 +			return buf, overflow
 +		case n < 0:
 +			return buf, dataError("marshal error", data)
 +		default:
 +			return buf[:n], nil
 +		}
 +	}
 +	return encodeGrow(buffer, encode)
 +}
 +
 +const minEncode = 256
 +
 +// overflow is returned when an encoding function can't fit data in the buffer.
 +var overflow = fmt.Errorf("buffer too small")
 +
 +// encodeFn encodes into buffer[0:len(buffer)].
 +// Returns buffer with length adjusted for data encoded.
 +// If buffer too small, returns overflow as error.
 +type encodeFn func(buffer []byte) ([]byte, error)
 +
 +// encodeGrow calls encode() into buffer, if it returns overflow grows the buffer.
 +// Returns the final buffer.
 +func encodeGrow(buffer []byte, encode encodeFn) ([]byte, error) {
 +	if buffer == nil || len(buffer) == 0 {
 +		buffer = make([]byte, minEncode)
 +	}
 +	var err error
 +	for buffer, err = encode(buffer); err == overflow; buffer, err = encode(buffer) {
 +		buffer = make([]byte, 2*len(buffer))
 +	}
 +	return buffer, err
 +}
 +
 +func marshal(v interface{}, data *C.pn_data_t) {
 +	switch v := v.(type) {
 +	case nil:
 +		C.pn_data_put_null(data)
 +	case bool:
 +		C.pn_data_put_bool(data, C.bool(v))
 +	case int8:
 +		C.pn_data_put_byte(data, C.int8_t(v))
 +	case int16:
 +		C.pn_data_put_short(data, C.int16_t(v))
 +	case int32:
 +		C.pn_data_put_int(data, C.int32_t(v))
 +	case int64:
 +		C.pn_data_put_long(data, C.int64_t(v))
 +	case int:
 +		if unsafe.Sizeof(0) == 8 {
 +			C.pn_data_put_long(data, C.int64_t(v))
 +		} else {
 +			C.pn_data_put_int(data, C.int32_t(v))
 +		}
 +	case uint8:
 +		C.pn_data_put_ubyte(data, C.uint8_t(v))
 +	case uint16:
 +		C.pn_data_put_ushort(data, C.uint16_t(v))
 +	case uint32:
 +		C.pn_data_put_uint(data, C.uint32_t(v))
 +	case uint64:
 +		C.pn_data_put_ulong(data, C.uint64_t(v))
 +	case uint:
 +		if unsafe.Sizeof(0) == 8 {
 +			C.pn_data_put_ulong(data, C.uint64_t(v))
 +		} else {
 +			C.pn_data_put_uint(data, C.uint32_t(v))
 +		}
 +	case float32:
 +		C.pn_data_put_float(data, C.float(v))
 +	case float64:
 +		C.pn_data_put_double(data, C.double(v))
 +	case string:
 +		C.pn_data_put_string(data, pnBytes([]byte(v)))
 +	case []byte:
 +		C.pn_data_put_binary(data, pnBytes(v))
 +	case Binary:
 +		C.pn_data_put_binary(data, pnBytes([]byte(v)))
 +	case Symbol:
 +		C.pn_data_put_symbol(data, pnBytes([]byte(v)))
 +	case Map: // Special map type
 +		C.pn_data_put_map(data)
 +		C.pn_data_enter(data)
 +		for key, val := range v {
 +			marshal(key, data)
 +			marshal(val, data)
 +		}
 +		C.pn_data_exit(data)
 +	default:
 +		switch reflect.TypeOf(v).Kind() {
 +		case reflect.Map:
 +			putMap(data, v)
 +		case reflect.Slice:
 +			putList(data, v)
 +		default:
 +			panic(fmt.Errorf("cannot marshal %s to AMQP", reflect.TypeOf(v)))
 +		}
 +	}
 +	err := dataError("marshal", data)
 +	if err != nil {
 +		panic(err)
 +	}
 +	return
 +}
 +
 +func clearMarshal(v interface{}, data *C.pn_data_t) {
 +	C.pn_data_clear(data)
 +	marshal(v, data)
 +}
 +
 +func putMap(data *C.pn_data_t, v interface{}) {
 +	mapValue := reflect.ValueOf(v)
 +	C.pn_data_put_map(data)
 +	C.pn_data_enter(data)
 +	for _, key := range mapValue.MapKeys() {
 +		marshal(key.Interface(), data)
 +		marshal(mapValue.MapIndex(key).Interface(), data)
 +	}
 +	C.pn_data_exit(data)
 +}
 +
 +func putList(data *C.pn_data_t, v interface{}) {
 +	listValue := reflect.ValueOf(v)
 +	C.pn_data_put_list(data)
 +	C.pn_data_enter(data)
 +	for i := 0; i < listValue.Len(); i++ {
 +		marshal(listValue.Index(i).Interface(), data)
 +	}
 +	C.pn_data_exit(data)
 +}
 +
 +// Encoder encodes AMQP values to an io.Writer
 +type Encoder struct {
 +	writer io.Writer
 +	buffer []byte
 +}
 +
 +// New encoder returns a new encoder that writes to w.
 +func NewEncoder(w io.Writer) *Encoder {
 +	return &Encoder{w, make([]byte, minEncode)}
 +}
 +
 +func (e *Encoder) Encode(v interface{}) (err error) {
 +	e.buffer, err = Marshal(v, e.buffer)
 +	if err == nil {
 +		e.writer.Write(e.buffer)
 +	}
 +	return err
 +}
 +
 +func replace(data *C.pn_data_t, v interface{}) {
 +	C.pn_data_clear(data)
 +	marshal(v, data)
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/amqp/message.go
----------------------------------------------------------------------
diff --cc amqp/message.go
index e36c6f2,0000000..1d1287f
mode 100644,000000..100644
--- a/amqp/message.go
+++ b/amqp/message.go
@@@ -1,346 -1,0 +1,346 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package amqp
 +
++// #include "codec_shim.h"
 +// #include <proton/types.h>
 +// #include <proton/message.h>
- // #include <proton/codec.h>
 +// #include <stdlib.h>
 +//
 +// /* Helper for setting message string fields */
 +// typedef int (*set_fn)(pn_message_t*, const char*);
 +// int msg_set_str(pn_message_t* m, char* s, set_fn set) {
 +//     int result = set(m, s);
 +//     free(s);
 +//     return result;
 +// }
 +//
 +import "C"
 +
 +import (
 +	"fmt"
 +	"runtime"
 +	"time"
 +	"unsafe"
 +)
 +
 +// Message is the interface to an AMQP message.
 +type Message interface {
 +	// Durable indicates that any parties taking responsibility
 +	// for the message must durably store the content.
 +	Durable() bool
 +	SetDurable(bool)
 +
 +	// Priority impacts ordering guarantees. Within a
 +	// given ordered context, higher priority messages may jump ahead of
 +	// lower priority messages.
 +	Priority() uint8
 +	SetPriority(uint8)
 +
 +	// TTL or Time To Live, a message it may be dropped after this duration
 +	TTL() time.Duration
 +	SetTTL(time.Duration)
 +
 +	// FirstAcquirer indicates
 +	// that the recipient of the message is the first recipient to acquire
 +	// the message, i.e. there have been no failed delivery attempts to
 +	// other acquirers. Note that this does not mean the message has not
 +	// been delivered to, but not acquired, by other recipients.
 +	FirstAcquirer() bool
 +	SetFirstAcquirer(bool)
 +
 +	// DeliveryCount tracks how many attempts have been made to
 +	// delivery a message.
 +	DeliveryCount() uint32
 +	SetDeliveryCount(uint32)
 +
 +	// MessageId provides a unique identifier for a message.
 +	// it can be an a string, an unsigned long, a uuid or a
 +	// binary value.
 +	MessageId() interface{}
 +	SetMessageId(interface{})
 +
 +	UserId() string
 +	SetUserId(string)
 +
 +	Address() string
 +	SetAddress(string)
 +
 +	Subject() string
 +	SetSubject(string)
 +
 +	ReplyTo() string
 +	SetReplyTo(string)
 +
 +	// CorrelationId is set on correlated request and response messages. It can be
 +	// an a string, an unsigned long, a uuid or a binary value.
 +	CorrelationId() interface{}
 +	SetCorrelationId(interface{})
 +
 +	ContentType() string
 +	SetContentType(string)
 +
 +	ContentEncoding() string
 +	SetContentEncoding(string)
 +
 +	// ExpiryTime indicates an absoulte time when the message may be dropped.
 +	// A Zero time (i.e. t.isZero() == true) indicates a message never expires.
 +	ExpiryTime() time.Time
 +	SetExpiryTime(time.Time)
 +
 +	CreationTime() time.Time
 +	SetCreationTime(time.Time)
 +
 +	GroupId() string
 +	SetGroupId(string)
 +
 +	GroupSequence() int32
 +	SetGroupSequence(int32)
 +
 +	ReplyToGroupId() string
 +	SetReplyToGroupId(string)
 +
 +	// Instructions - AMQP delivery instructions.
 +	Instructions() map[string]interface{}
 +	SetInstructions(v map[string]interface{})
 +
 +	// Annotations - AMQP annotations.
 +	Annotations() map[string]interface{}
 +	SetAnnotations(v map[string]interface{})
 +
 +	// Properties - Application properties.
 +	Properties() map[string]interface{}
 +	SetProperties(v map[string]interface{})
 +
 +	// Inferred indicates how the message content
 +	// is encoded into AMQP sections. If inferred is true then binary and
 +	// list values in the body of the message will be encoded as AMQP DATA
 +	// and AMQP SEQUENCE sections, respectively. If inferred is false,
 +	// then all values in the body of the message will be encoded as AMQP
 +	// VALUE sections regardless of their type.
 +	Inferred() bool
 +	SetInferred(bool)
 +
 +	// Marshal a Go value into the message body. See amqp.Marshal() for details.
 +	Marshal(interface{})
 +
 +	// Unmarshal the message body into the value pointed to by v. See amqp.Unmarshal() for details.
 +	Unmarshal(interface{})
 +
 +	// Body value resulting from the default unmarshalling of message body as interface{}
 +	Body() interface{}
 +
 +	// Encode encodes the message as AMQP data. If buffer is non-nil and is large enough
 +	// the message is encoded into it, otherwise a new buffer is created.
 +	// Returns the buffer containing the message.
 +	Encode(buffer []byte) ([]byte, error)
 +
 +	// Decode data into this message. Overwrites an existing message content.
 +	Decode(buffer []byte) error
 +
 +	// Clear the message contents.
 +	Clear()
 +
 +	// Copy the contents of another message to this one.
 +	Copy(m Message) error
 +}
 +
 +type message struct{ pn *C.pn_message_t }
 +
 +func freeMessage(m *message) {
 +	C.pn_message_free(m.pn)
 +	m.pn = nil
 +}
 +
 +// NewMessage creates a new message instance.
 +func NewMessage() Message {
 +	m := &message{C.pn_message()}
 +	runtime.SetFinalizer(m, freeMessage)
 +	return m
 +}
 +
 +// NewMessageWith creates a message with value as the body. Equivalent to
 +//     m := NewMessage(); m.Marshal(body)
 +func NewMessageWith(value interface{}) Message {
 +	m := NewMessage()
 +	m.Marshal(value)
 +	return m
 +}
 +
 +func (m *message) Clear() { C.pn_message_clear(m.pn) }
 +
 +func (m *message) Copy(x Message) error {
 +	if data, err := x.Encode(nil); err == nil {
 +		return m.Decode(data)
 +	} else {
 +		return err
 +	}
 +}
 +
 +// ==== message get functions
 +
 +func rewindGet(data *C.pn_data_t) (v interface{}) {
 +	C.pn_data_rewind(data)
 +	C.pn_data_next(data)
 +	unmarshal(&v, data)
 +	return v
 +}
 +
 +func rewindMap(data *C.pn_data_t) (v map[string]interface{}) {
 +	C.pn_data_rewind(data)
 +	C.pn_data_next(data)
 +	unmarshal(&v, data)
 +	return v
 +}
 +
 +func (m *message) Inferred() bool  { return bool(C.pn_message_is_inferred(m.pn)) }
 +func (m *message) Durable() bool   { return bool(C.pn_message_is_durable(m.pn)) }
 +func (m *message) Priority() uint8 { return uint8(C.pn_message_get_priority(m.pn)) }
 +func (m *message) TTL() time.Duration {
 +	return time.Duration(C.pn_message_get_ttl(m.pn)) * time.Millisecond
 +}
 +func (m *message) FirstAcquirer() bool        { return bool(C.pn_message_is_first_acquirer(m.pn)) }
 +func (m *message) DeliveryCount() uint32      { return uint32(C.pn_message_get_delivery_count(m.pn)) }
 +func (m *message) MessageId() interface{}     { return rewindGet(C.pn_message_id(m.pn)) }
 +func (m *message) UserId() string             { return goString(C.pn_message_get_user_id(m.pn)) }
 +func (m *message) Address() string            { return C.GoString(C.pn_message_get_address(m.pn)) }
 +func (m *message) Subject() string            { return C.GoString(C.pn_message_get_subject(m.pn)) }
 +func (m *message) ReplyTo() string            { return C.GoString(C.pn_message_get_reply_to(m.pn)) }
 +func (m *message) CorrelationId() interface{} { return rewindGet(C.pn_message_correlation_id(m.pn)) }
 +func (m *message) ContentType() string        { return C.GoString(C.pn_message_get_content_type(m.pn)) }
 +func (m *message) ContentEncoding() string    { return C.GoString(C.pn_message_get_content_encoding(m.pn)) }
 +
 +func (m *message) ExpiryTime() time.Time {
 +	return time.Unix(0, int64(time.Millisecond*time.Duration(C.pn_message_get_expiry_time(m.pn))))
 +}
 +func (m *message) CreationTime() time.Time {
 +	return time.Unix(0, int64(time.Millisecond)*int64(C.pn_message_get_creation_time(m.pn)))
 +}
 +func (m *message) GroupId() string        { return C.GoString(C.pn_message_get_group_id(m.pn)) }
 +func (m *message) GroupSequence() int32   { return int32(C.pn_message_get_group_sequence(m.pn)) }
 +func (m *message) ReplyToGroupId() string { return C.GoString(C.pn_message_get_reply_to_group_id(m.pn)) }
 +
 +func (m *message) Instructions() map[string]interface{} {
 +	return rewindMap(C.pn_message_instructions(m.pn))
 +}
 +func (m *message) Annotations() map[string]interface{} {
 +	return rewindMap(C.pn_message_annotations(m.pn))
 +}
 +func (m *message) Properties() map[string]interface{} {
 +	return rewindMap(C.pn_message_properties(m.pn))
 +}
 +
 +// ==== message set methods
 +
 +func setData(v interface{}, data *C.pn_data_t) {
 +	C.pn_data_clear(data)
 +	marshal(v, data)
 +}
 +
 +func dataString(data *C.pn_data_t) string {
 +	str := C.pn_string(C.CString(""))
 +	defer C.pn_free(unsafe.Pointer(str))
 +	C.pn_inspect(unsafe.Pointer(data), str)
 +	return C.GoString(C.pn_string_get(str))
 +}
 +
 +func (m *message) SetInferred(b bool)  { C.pn_message_set_inferred(m.pn, C.bool(m.Inferred())) }
 +func (m *message) SetDurable(b bool)   { C.pn_message_set_durable(m.pn, C.bool(b)) }
 +func (m *message) SetPriority(b uint8) { C.pn_message_set_priority(m.pn, C.uint8_t(b)) }
 +func (m *message) SetTTL(d time.Duration) {
 +	C.pn_message_set_ttl(m.pn, C.pn_millis_t(d/time.Millisecond))
 +}
 +func (m *message) SetFirstAcquirer(b bool)     { C.pn_message_set_first_acquirer(m.pn, C.bool(b)) }
 +func (m *message) SetDeliveryCount(c uint32)   { C.pn_message_set_delivery_count(m.pn, C.uint32_t(c)) }
 +func (m *message) SetMessageId(id interface{}) { setData(id, C.pn_message_id(m.pn)) }
 +func (m *message) SetUserId(s string)          { C.pn_message_set_user_id(m.pn, pnBytes(([]byte)(s))) }
 +func (m *message) SetAddress(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_address))
 +}
 +func (m *message) SetSubject(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_subject))
 +}
 +func (m *message) SetReplyTo(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_reply_to))
 +}
 +func (m *message) SetCorrelationId(c interface{}) { setData(c, C.pn_message_correlation_id(m.pn)) }
 +func (m *message) SetContentType(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_content_type))
 +}
 +func (m *message) SetContentEncoding(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_content_encoding))
 +}
 +func (m *message) SetExpiryTime(t time.Time)   { C.pn_message_set_expiry_time(m.pn, pnTime(t)) }
 +func (m *message) SetCreationTime(t time.Time) { C.pn_message_set_creation_time(m.pn, pnTime(t)) }
 +func (m *message) SetGroupId(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_group_id))
 +}
 +func (m *message) SetGroupSequence(s int32) {
 +	C.pn_message_set_group_sequence(m.pn, C.pn_sequence_t(s))
 +}
 +func (m *message) SetReplyToGroupId(s string) {
 +	C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_reply_to_group_id))
 +}
 +
 +func (m *message) SetInstructions(v map[string]interface{}) {
 +	setData(v, C.pn_message_instructions(m.pn))
 +}
 +func (m *message) SetAnnotations(v map[string]interface{}) { setData(v, C.pn_message_annotations(m.pn)) }
 +func (m *message) SetProperties(v map[string]interface{})  { setData(v, C.pn_message_properties(m.pn)) }
 +
 +// Marshal/Unmarshal body
 +func (m *message) Marshal(v interface{})   { clearMarshal(v, C.pn_message_body(m.pn)) }
 +func (m *message) Unmarshal(v interface{}) { rewindUnmarshal(v, C.pn_message_body(m.pn)) }
 +func (m *message) Body() (v interface{})   { m.Unmarshal(&v); return }
 +
 +func (m *message) Decode(data []byte) error {
 +	m.Clear()
 +	if len(data) == 0 {
 +		return fmt.Errorf("empty buffer for decode")
 +	}
 +	if C.pn_message_decode(m.pn, cPtr(data), cLen(data)) < 0 {
 +		return fmt.Errorf("decoding message: %s", PnError(C.pn_message_error(m.pn)))
 +	}
 +	return nil
 +}
 +
 +func DecodeMessage(data []byte) (m Message, err error) {
 +	m = NewMessage()
 +	err = m.Decode(data)
 +	return
 +}
 +
 +func (m *message) Encode(buffer []byte) ([]byte, error) {
 +	encode := func(buf []byte) ([]byte, error) {
 +		len := cLen(buf)
 +		result := C.pn_message_encode(m.pn, cPtr(buf), &len)
 +		switch {
 +		case result == C.PN_OVERFLOW:
 +			return buf, overflow
 +		case result < 0:
 +			return buf, fmt.Errorf("cannot encode message: %s", PnErrorCode(result))
 +		default:
 +			return buf[:len], nil
 +		}
 +	}
 +	return encodeGrow(buffer, encode)
 +}
 +
 +// TODO aconway 2015-09-14: Multi-section messages.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/amqp/types.go
----------------------------------------------------------------------
diff --cc amqp/types.go
index 697d896,0000000..d927cc5
mode 100644,000000..100644
--- a/amqp/types.go
+++ b/amqp/types.go
@@@ -1,201 -1,0 +1,196 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package amqp
 +
- // #include <proton/codec.h>
++//#include "codec_shim.h"
 +import "C"
 +
 +import (
 +	"bytes"
 +	"fmt"
 +	"reflect"
 +	"time"
 +	"unsafe"
 +)
 +
- // Older proton versions don't define C.PN_INVALID, so define it here.
- // In C it is pn_type_t(-1), in Go use the bitwise NOT operator to get the same value.
- const pnInvalid = C.pn_type_t(^0)
- 
 +func (t C.pn_type_t) String() string {
 +	switch C.pn_type_t(t) {
 +	case C.PN_NULL:
 +		return "null"
 +	case C.PN_BOOL:
 +		return "bool"
 +	case C.PN_UBYTE:
 +		return "ubyte"
 +	case C.PN_BYTE:
 +		return "byte"
 +	case C.PN_USHORT:
 +		return "ushort"
 +	case C.PN_SHORT:
 +		return "short"
 +	case C.PN_CHAR:
 +		return "char"
 +	case C.PN_UINT:
 +		return "uint"
 +	case C.PN_INT:
 +		return "int"
 +	case C.PN_ULONG:
 +		return "ulong"
 +	case C.PN_LONG:
 +		return "long"
 +	case C.PN_TIMESTAMP:
 +		return "timestamp"
 +	case C.PN_FLOAT:
 +		return "float"
 +	case C.PN_DOUBLE:
 +		return "double"
 +	case C.PN_DECIMAL32:
 +		return "decimal32"
 +	case C.PN_DECIMAL64:
 +		return "decimal64"
 +	case C.PN_DECIMAL128:
 +		return "decimal128"
 +	case C.PN_UUID:
 +		return "uuid"
 +	case C.PN_BINARY:
 +		return "binary"
 +	case C.PN_STRING:
 +		return "string"
 +	case C.PN_SYMBOL:
 +		return "symbol"
 +	case C.PN_DESCRIBED:
 +		return "described"
 +	case C.PN_ARRAY:
 +		return "array"
 +	case C.PN_LIST:
 +		return "list"
 +	case C.PN_MAP:
 +		return "map"
++	case C.PN_INVALID:
++		return "no-data"
 +	default:
- 		if t == pnInvalid {
- 			return "no-data"
- 		}
 +		return fmt.Sprintf("unknown-type(%d)", t)
 +	}
 +}
 +
 +// Go types
 +var (
 +	bytesType = reflect.TypeOf([]byte{})
 +	valueType = reflect.TypeOf(reflect.Value{})
 +)
 +
 +// TODO aconway 2015-04-08: can't handle AMQP maps with key types that are not valid Go map keys.
 +
 +// Map is a generic map that can have mixed key and value types and so can represent any AMQP map
 +type Map map[interface{}]interface{}
 +
 +// List is a generic list that can hold mixed values and can represent any AMQP list.
 +//
 +type List []interface{}
 +
 +// Symbol is a string that is encoded as an AMQP symbol
 +type Symbol string
 +
 +func (s Symbol) GoString() string { return fmt.Sprintf("s\"%s\"", s) }
 +
 +// Binary is a string that is encoded as an AMQP binary.
 +// It is a string rather than a byte[] because byte[] is not hashable and can't be used as
 +// a map key, AMQP frequently uses binary types as map keys. It can convert to and from []byte
 +type Binary string
 +
 +func (b Binary) GoString() string { return fmt.Sprintf("b\"%s\"", b) }
 +
 +// GoString for Map prints values with their types, useful for debugging.
 +func (m Map) GoString() string {
 +	out := &bytes.Buffer{}
 +	fmt.Fprintf(out, "%T{", m)
 +	i := len(m)
 +	for k, v := range m {
 +		fmt.Fprintf(out, "%T(%#v): %T(%#v)", k, k, v, v)
 +		i--
 +		if i > 0 {
 +			fmt.Fprint(out, ", ")
 +		}
 +	}
 +	fmt.Fprint(out, "}")
 +	return out.String()
 +}
 +
 +// GoString for List prints values with their types, useful for debugging.
 +func (l List) GoString() string {
 +	out := &bytes.Buffer{}
 +	fmt.Fprintf(out, "%T{", l)
 +	for i := 0; i < len(l); i++ {
 +		fmt.Fprintf(out, "%T(%#v)", l[i], l[i])
 +		if i == len(l)-1 {
 +			fmt.Fprint(out, ", ")
 +		}
 +	}
 +	fmt.Fprint(out, "}")
 +	return out.String()
 +}
 +
 +// pnTime converts Go time.Time to Proton millisecond Unix time.
 +func pnTime(t time.Time) C.pn_timestamp_t {
 +	secs := t.Unix()
 +	// Note: sub-second accuracy is not guaraunteed if the Unix time in
 +	// nanoseconds cannot be represented by an int64 (sometime around year 2260)
 +	msecs := (t.UnixNano() % int64(time.Second)) / int64(time.Millisecond)
 +	return C.pn_timestamp_t(secs*1000 + msecs)
 +}
 +
 +// goTime converts a pn_timestamp_t to a Go time.Time.
 +func goTime(t C.pn_timestamp_t) time.Time {
 +	secs := int64(t) / 1000
 +	nsecs := (int64(t) % 1000) * int64(time.Millisecond)
 +	return time.Unix(secs, nsecs)
 +}
 +
 +func goBytes(cBytes C.pn_bytes_t) (bytes []byte) {
 +	if cBytes.start != nil {
 +		bytes = C.GoBytes(unsafe.Pointer(cBytes.start), C.int(cBytes.size))
 +	}
 +	return
 +}
 +
 +func goString(cBytes C.pn_bytes_t) (str string) {
 +	if cBytes.start != nil {
 +		str = C.GoStringN(cBytes.start, C.int(cBytes.size))
 +	}
 +	return
 +}
 +
 +func pnBytes(b []byte) C.pn_bytes_t {
 +	if len(b) == 0 {
 +		return C.pn_bytes_t{0, nil}
 +	} else {
 +		return C.pn_bytes_t{C.size_t(len(b)), (*C.char)(unsafe.Pointer(&b[0]))}
 +	}
 +}
 +
 +func cPtr(b []byte) *C.char {
 +	if len(b) == 0 {
 +		return nil
 +	}
 +	return (*C.char)(unsafe.Pointer(&b[0]))
 +}
 +
 +func cLen(b []byte) C.size_t {
 +	return C.size_t(len(b))
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/amqp/unmarshal.go
----------------------------------------------------------------------
diff --cc amqp/unmarshal.go
index 05ecb8d,0000000..6942174
mode 100644,000000..100644
--- a/amqp/unmarshal.go
+++ b/amqp/unmarshal.go
@@@ -1,561 -1,0 +1,561 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +oor more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package amqp
 +
- // #include <proton/codec.h>
++// #include "codec_shim.h"
 +import "C"
 +
 +import (
 +	"bytes"
 +	"fmt"
 +	"io"
 +	"reflect"
 +	"unsafe"
 +)
 +
 +const minDecode = 1024
 +
 +// Error returned if AMQP data cannot be unmarshaled as the desired Go type.
 +type UnmarshalError struct {
 +	// The name of the AMQP type.
 +	AMQPType string
 +	// The Go type.
 +	GoType reflect.Type
 +}
 +
 +func newUnmarshalError(pnType C.pn_type_t, v interface{}) *UnmarshalError {
 +	return &UnmarshalError{C.pn_type_t(pnType).String(), reflect.TypeOf(v)}
 +}
 +
 +func (e UnmarshalError) Error() string {
 +	if e.GoType.Kind() != reflect.Ptr {
 +		return fmt.Sprintf("cannot unmarshal to type %s, not a pointer", e.GoType)
 +	} else {
 +		return fmt.Sprintf("cannot unmarshal AMQP %s to %s", e.AMQPType, e.GoType)
 +	}
 +}
 +
 +func doRecover(err *error) {
 +	r := recover()
 +	switch r := r.(type) {
 +	case nil:
 +	case *UnmarshalError:
 +		*err = r
 +	default:
 +		panic(r)
 +	}
 +}
 +
 +//
 +// Decoding from a pn_data_t
 +//
 +// NOTE: we use panic() to signal a decoding error, simplifies decoding logic.
 +// We recover() at the highest possible level - i.e. in the exported Unmarshal or Decode.
 +//
 +
 +// Decoder decodes AMQP values from an io.Reader.
 +//
 +type Decoder struct {
 +	reader io.Reader
 +	buffer bytes.Buffer
 +}
 +
 +// NewDecoder returns a new decoder that reads from r.
 +//
 +// The decoder has it's own buffer and may read more data than required for the
 +// AMQP values requested.  Use Buffered to see if there is data left in the
 +// buffer.
 +//
 +func NewDecoder(r io.Reader) *Decoder {
 +	return &Decoder{r, bytes.Buffer{}}
 +}
 +
 +// Buffered returns a reader of the data remaining in the Decoder's buffer. The
 +// reader is valid until the next call to Decode.
 +//
 +func (d *Decoder) Buffered() io.Reader {
 +	return bytes.NewReader(d.buffer.Bytes())
 +}
 +
 +// Decode reads the next AMQP value from the Reader and stores it in the value pointed to by v.
 +//
 +// See the documentation for Unmarshal for details about the conversion of AMQP into a Go value.
 +//
 +func (d *Decoder) Decode(v interface{}) (err error) {
 +	defer doRecover(&err)
 +	data := C.pn_data(0)
 +	defer C.pn_data_free(data)
 +	var n int
 +	for n == 0 {
 +		n, err = decode(data, d.buffer.Bytes())
 +		if err != nil {
 +			return err
 +		}
 +		if n == 0 { // n == 0 means not enough data, read more
 +			err = d.more()
 +		} else {
 +			unmarshal(v, data)
 +		}
 +	}
 +	d.buffer.Next(n)
 +	return
 +}
 +
 +/*
 +Unmarshal decodes AMQP-encoded bytes and stores the result in the value pointed to by v.
 +Types are converted as follows:
 +
 + +---------------------------+----------------------------------------------------------------------+
 + |To Go types                |From AMQP types                                                       |
 + +===========================+======================================================================+
 + |bool                       |bool                                                                  |
 + +---------------------------+----------------------------------------------------------------------+
 + |int, int8, int16,          |Equivalent or smaller signed integer type: byte, short, int, long.    |
 + |int32, int64               |                                                                      |
 + +---------------------------+----------------------------------------------------------------------+
 + |uint, uint8, uint16,       |Equivalent or smaller unsigned integer type: ubyte, ushort, uint,     |
 + |uint32, uint64 types       |ulong                                                                 |
 + +---------------------------+----------------------------------------------------------------------+
 + |float32, float64           |Equivalent or smaller float or double.                                |
 + +---------------------------+----------------------------------------------------------------------+
 + |string, []byte             |string, symbol or binary.                                             |
 + +---------------------------+----------------------------------------------------------------------+
 + |Symbol                     |symbol                                                                |
 + +---------------------------+----------------------------------------------------------------------+
 + |map[K]T                    |map, provided all keys and values can unmarshal to types K, T         |
 + +---------------------------+----------------------------------------------------------------------+
 + |Map                        |map, any AMQP map                                                     |
 + +---------------------------+----------------------------------------------------------------------+
 + |interface{}                |Any AMQP value can be unmarshaled to an interface{} as follows:       |
 + |                           +------------------------+---------------------------------------------+
 + |                           |AMQP Type               |Go Type in interface{}                       |
 + |                           +========================+=============================================+
 + |                           |bool                    |bool                                         |
 + |                           +------------------------+---------------------------------------------+
 + |                           |byte,short,int,long     |int8,int16,int32,int64                       |
 + |                           +------------------------+---------------------------------------------+
 + |                           |ubyte,ushort,uint,ulong |uint8,uint16,uint32,uint64                   |
 + |                           +------------------------+---------------------------------------------+
 + |                           |float, double           |float32, float64                             |
 + |                           +------------------------+---------------------------------------------+
 + |                           |string                  |string                                       |
 + |                           +------------------------+---------------------------------------------+
 + |                           |symbol                  |Symbol                                       |
 + |                           +------------------------+---------------------------------------------+
 + |                           |binary                  |Binary                                       |
 + |                           +------------------------+---------------------------------------------+
 + |                           |nulll                   |nil                                          |
 + |                           +------------------------+---------------------------------------------+
 + |                           |map                     |Map                                          |
 + |                           +------------------------+---------------------------------------------+
 + |                           |list                    |List                                         |
 + +---------------------------+------------------------+---------------------------------------------+
 +
 +The following Go types cannot be unmarshaled: uintptr, function, interface, channel.
 +
 +TODO
 +
 +Go types: array, struct.
 +
 +AMQP types: decimal32/64/128, char (round trip), timestamp, uuid, array, multi-section message bodies.
 +
 +AMQP maps with mixed/unhashable key types need an alternate representation.
 +
 +Described types.
 +*/
 +func Unmarshal(bytes []byte, v interface{}) (n int, err error) {
 +	defer doRecover(&err)
 +
 +	data := C.pn_data(0)
 +	defer C.pn_data_free(data)
 +	n, err = decode(data, bytes)
 +	if err != nil {
 +		return 0, err
 +	}
 +	if n == 0 {
 +		return 0, fmt.Errorf("not enough data")
 +	} else {
 +		unmarshal(v, data)
 +	}
 +	return n, nil
 +}
 +
 +// more reads more data when we can't parse a complete AMQP type
 +func (d *Decoder) more() error {
 +	var readSize int64 = minDecode
 +	if int64(d.buffer.Len()) > readSize { // Grow by doubling
 +		readSize = int64(d.buffer.Len())
 +	}
 +	var n int64
 +	n, err := d.buffer.ReadFrom(io.LimitReader(d.reader, readSize))
 +	if n == 0 && err == nil { // ReadFrom won't report io.EOF, just returns 0
 +		err = io.EOF
 +	}
 +	return err
 +}
 +
 +// Unmarshal from data into value pointed at by v.
 +func unmarshal(v interface{}, data *C.pn_data_t) {
 +	pnType := C.pn_data_type(data)
 +	switch v := v.(type) {
 +	case *bool:
 +		switch pnType {
 +		case C.PN_BOOL:
 +			*v = bool(C.pn_data_get_bool(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	case *int8:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = int8(C.pn_data_get_char(data))
 +		case C.PN_BYTE:
 +			*v = int8(C.pn_data_get_byte(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	case *uint8:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = uint8(C.pn_data_get_char(data))
 +		case C.PN_UBYTE:
 +			*v = uint8(C.pn_data_get_ubyte(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	case *int16:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = int16(C.pn_data_get_char(data))
 +		case C.PN_BYTE:
 +			*v = int16(C.pn_data_get_byte(data))
 +		case C.PN_SHORT:
 +			*v = int16(C.pn_data_get_short(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	case *uint16:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = uint16(C.pn_data_get_char(data))
 +		case C.PN_UBYTE:
 +			*v = uint16(C.pn_data_get_ubyte(data))
 +		case C.PN_USHORT:
 +			*v = uint16(C.pn_data_get_ushort(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	case *int32:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = int32(C.pn_data_get_char(data))
 +		case C.PN_BYTE:
 +			*v = int32(C.pn_data_get_byte(data))
 +		case C.PN_SHORT:
 +			*v = int32(C.pn_data_get_short(data))
 +		case C.PN_INT:
 +			*v = int32(C.pn_data_get_int(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	case *uint32:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = uint32(C.pn_data_get_char(data))
 +		case C.PN_UBYTE:
 +			*v = uint32(C.pn_data_get_ubyte(data))
 +		case C.PN_USHORT:
 +			*v = uint32(C.pn_data_get_ushort(data))
 +		case C.PN_UINT:
 +			*v = uint32(C.pn_data_get_uint(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *int64:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = int64(C.pn_data_get_char(data))
 +		case C.PN_BYTE:
 +			*v = int64(C.pn_data_get_byte(data))
 +		case C.PN_SHORT:
 +			*v = int64(C.pn_data_get_short(data))
 +		case C.PN_INT:
 +			*v = int64(C.pn_data_get_int(data))
 +		case C.PN_LONG:
 +			*v = int64(C.pn_data_get_long(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *uint64:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = uint64(C.pn_data_get_char(data))
 +		case C.PN_UBYTE:
 +			*v = uint64(C.pn_data_get_ubyte(data))
 +		case C.PN_USHORT:
 +			*v = uint64(C.pn_data_get_ushort(data))
 +		case C.PN_ULONG:
 +			*v = uint64(C.pn_data_get_ulong(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *int:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = int(C.pn_data_get_char(data))
 +		case C.PN_BYTE:
 +			*v = int(C.pn_data_get_byte(data))
 +		case C.PN_SHORT:
 +			*v = int(C.pn_data_get_short(data))
 +		case C.PN_INT:
 +			*v = int(C.pn_data_get_int(data))
 +		case C.PN_LONG:
 +			if unsafe.Sizeof(0) == 8 {
 +				*v = int(C.pn_data_get_long(data))
 +			} else {
 +				panic(newUnmarshalError(pnType, v))
 +			}
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *uint:
 +		switch pnType {
 +		case C.PN_CHAR:
 +			*v = uint(C.pn_data_get_char(data))
 +		case C.PN_UBYTE:
 +			*v = uint(C.pn_data_get_ubyte(data))
 +		case C.PN_USHORT:
 +			*v = uint(C.pn_data_get_ushort(data))
 +		case C.PN_UINT:
 +			*v = uint(C.pn_data_get_uint(data))
 +		case C.PN_ULONG:
 +			if unsafe.Sizeof(0) == 8 {
 +				*v = uint(C.pn_data_get_ulong(data))
 +			} else {
 +				panic(newUnmarshalError(pnType, v))
 +			}
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *float32:
 +		switch pnType {
 +		case C.PN_FLOAT:
 +			*v = float32(C.pn_data_get_float(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *float64:
 +		switch pnType {
 +		case C.PN_FLOAT:
 +			*v = float64(C.pn_data_get_float(data))
 +		case C.PN_DOUBLE:
 +			*v = float64(C.pn_data_get_double(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *string:
 +		switch pnType {
 +		case C.PN_STRING:
 +			*v = goString(C.pn_data_get_string(data))
 +		case C.PN_SYMBOL:
 +			*v = goString(C.pn_data_get_symbol(data))
 +		case C.PN_BINARY:
 +			*v = goString(C.pn_data_get_binary(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *[]byte:
 +		switch pnType {
 +		case C.PN_STRING:
 +			*v = goBytes(C.pn_data_get_string(data))
 +		case C.PN_SYMBOL:
 +			*v = goBytes(C.pn_data_get_symbol(data))
 +		case C.PN_BINARY:
 +			*v = goBytes(C.pn_data_get_binary(data))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *Binary:
 +		switch pnType {
 +		case C.PN_BINARY:
 +			*v = Binary(goBytes(C.pn_data_get_binary(data)))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *Symbol:
 +		switch pnType {
 +		case C.PN_SYMBOL:
 +			*v = Symbol(goBytes(C.pn_data_get_symbol(data)))
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +
 +	case *interface{}:
 +		getInterface(data, v)
 +
 +	default:
 +		if reflect.TypeOf(v).Kind() != reflect.Ptr {
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +		switch reflect.TypeOf(v).Elem().Kind() {
 +		case reflect.Map:
 +			getMap(data, v)
 +		case reflect.Slice:
 +			getList(data, v)
 +		default:
 +			panic(newUnmarshalError(pnType, v))
 +		}
 +	}
 +	err := dataError("unmarshaling", data)
 +	if err != nil {
 +		panic(err)
 +	}
 +	return
 +}
 +
 +func rewindUnmarshal(v interface{}, data *C.pn_data_t) {
 +	C.pn_data_rewind(data)
 +	C.pn_data_next(data)
 +	unmarshal(v, data)
 +}
 +
 +// Getting into an interface is driven completely by the AMQP type, since the interface{}
 +// target is type-neutral.
 +func getInterface(data *C.pn_data_t, v *interface{}) {
 +	pnType := C.pn_data_type(data)
 +	switch pnType {
- 	case C.PN_NULL, pnInvalid: // No data.
++	case C.PN_NULL, C.PN_INVALID: // No data.
 +		*v = nil
 +	case C.PN_BOOL:
 +		*v = bool(C.pn_data_get_bool(data))
 +	case C.PN_UBYTE:
 +		*v = uint8(C.pn_data_get_ubyte(data))
 +	case C.PN_BYTE:
 +		*v = int8(C.pn_data_get_byte(data))
 +	case C.PN_USHORT:
 +		*v = uint16(C.pn_data_get_ushort(data))
 +	case C.PN_SHORT:
 +		*v = int16(C.pn_data_get_short(data))
 +	case C.PN_UINT:
 +		*v = uint32(C.pn_data_get_uint(data))
 +	case C.PN_INT:
 +		*v = int32(C.pn_data_get_int(data))
 +	case C.PN_CHAR:
 +		*v = uint8(C.pn_data_get_char(data))
 +	case C.PN_ULONG:
 +		*v = uint64(C.pn_data_get_ulong(data))
 +	case C.PN_LONG:
 +		*v = int64(C.pn_data_get_long(data))
 +	case C.PN_FLOAT:
 +		*v = float32(C.pn_data_get_float(data))
 +	case C.PN_DOUBLE:
 +		*v = float64(C.pn_data_get_double(data))
 +	case C.PN_BINARY:
 +		*v = Binary(goBytes(C.pn_data_get_binary(data)))
 +	case C.PN_STRING:
 +		*v = goString(C.pn_data_get_string(data))
 +	case C.PN_SYMBOL:
 +		*v = Symbol(goString(C.pn_data_get_symbol(data)))
 +	case C.PN_MAP:
 +		m := make(Map)
 +		unmarshal(&m, data)
 +		*v = m
 +	case C.PN_LIST:
 +		l := make(List, 0)
 +		unmarshal(&l, data)
 +		*v = l
 +	default:
 +		panic(newUnmarshalError(pnType, v))
 +	}
 +}
 +
 +// get into map pointed at by v
 +func getMap(data *C.pn_data_t, v interface{}) {
 +	mapValue := reflect.ValueOf(v).Elem()
 +	mapValue.Set(reflect.MakeMap(mapValue.Type())) // Clear the map
 +	switch pnType := C.pn_data_type(data); pnType {
 +	case C.PN_MAP:
 +		count := int(C.pn_data_get_map(data))
 +		if bool(C.pn_data_enter(data)) {
 +			defer C.pn_data_exit(data)
 +			for i := 0; i < count/2; i++ {
 +				if bool(C.pn_data_next(data)) {
 +					key := reflect.New(mapValue.Type().Key())
 +					unmarshal(key.Interface(), data)
 +					if bool(C.pn_data_next(data)) {
 +						val := reflect.New(mapValue.Type().Elem())
 +						unmarshal(val.Interface(), data)
 +						mapValue.SetMapIndex(key.Elem(), val.Elem())
 +					}
 +				}
 +			}
 +		}
- 	case pnInvalid: // Leave the map empty
++	case C.PN_INVALID: // Leave the map empty
 +	default:
 +		panic(newUnmarshalError(pnType, v))
 +	}
 +}
 +
 +func getList(data *C.pn_data_t, v interface{}) {
 +	pnType := C.pn_data_type(data)
 +	if pnType != C.PN_LIST {
 +		panic(newUnmarshalError(pnType, v))
 +	}
 +	count := int(C.pn_data_get_list(data))
 +	listValue := reflect.MakeSlice(reflect.TypeOf(v).Elem(), count, count)
 +	if bool(C.pn_data_enter(data)) {
 +		for i := 0; i < count; i++ {
 +			if bool(C.pn_data_next(data)) {
 +				val := reflect.New(listValue.Type().Elem())
 +				unmarshal(val.Interface(), data)
 +				listValue.Index(i).Set(val.Elem())
 +			}
 +		}
 +		C.pn_data_exit(data)
 +	}
 +	reflect.ValueOf(v).Elem().Set(listValue)
 +}
 +
 +// decode from bytes.
 +// Return bytes decoded or 0 if we could not decode a complete object.
 +//
 +func decode(data *C.pn_data_t, bytes []byte) (int, error) {
 +	if len(bytes) == 0 {
 +		return 0, nil
 +	}
 +	n := int(C.pn_data_decode(data, cPtr(bytes), cLen(bytes)))
 +	if n == int(C.PN_UNDERFLOW) {
 +		C.pn_error_clear(C.pn_data_error(data))
 +		return 0, nil
 +	} else if n <= 0 {
 +		return 0, fmt.Errorf("unmarshal %s", PnErrorCode(n))
 +	}
 +	return n, nil
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/electron/connection.go
----------------------------------------------------------------------
diff --cc electron/connection.go
index 8a9e6cd,0000000..386875d
mode 100644,000000..100644
--- a/electron/connection.go
+++ b/electron/connection.go
@@@ -1,238 -1,0 +1,240 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package electron
 +
 +// #include <proton/disposition.h>
 +import "C"
 +
 +import (
++	"fmt"
 +	"net"
 +	"qpid.apache.org/proton"
 +	"sync"
 +	"time"
 +)
 +
 +// Connection is an AMQP connection, created by a Container.
 +type Connection interface {
 +	Endpoint
 +
 +	// Sender opens a new sender on the DefaultSession.
 +	Sender(...LinkOption) (Sender, error)
 +
 +	// Receiver opens a new Receiver on the DefaultSession().
 +	Receiver(...LinkOption) (Receiver, error)
 +
 +	// DefaultSession() returns a default session for the connection. It is opened
 +	// on the first call to DefaultSession and returned on subsequent calls.
 +	DefaultSession() (Session, error)
 +
 +	// Session opens a new session.
 +	Session(...SessionOption) (Session, error)
 +
 +	// Container for the connection.
 +	Container() Container
 +
 +	// Disconnect the connection abruptly with an error.
 +	Disconnect(error)
 +
 +	// Wait waits for the connection to be disconnected.
 +	Wait() error
 +
 +	// WaitTimeout is like Wait but returns Timeout if the timeout expires.
 +	WaitTimeout(time.Duration) error
 +
 +	// Incoming returns a channel for incoming endpoints opened by the remote end.
 +	//
 +	// To enable, pass AllowIncoming() when creating the Connection. Otherwise all
 +	// incoming endpoint requests are automatically rejected and Incoming()
 +	// returns nil.
 +	//
 +	// An Incoming value can be an *IncomingSession, *IncomingSender or
 +	// *IncomingReceiver.  You must call Accept() to open the endpoint or Reject()
 +	// to close it with an error. The specific Incoming types have additional
 +	// methods to configure the endpoint.
 +	//
 +	// Not receiving from Incoming() or not calling Accept/Reject will block the
 +	// electron event loop. Normally you would have a dedicated goroutine receive
 +	// from Incoming() and start new goroutines to serve each incoming endpoint.
 +	// The channel is closed when the Connection closes.
 +	//
 +	Incoming() <-chan Incoming
 +}
 +
 +// ConnectionOption can be passed when creating a connection to configure various options
 +type ConnectionOption func(*connection)
 +
 +// Server returns a ConnectionOption to put the connection in server mode.
 +//
 +// A server connection will do protocol negotiation to accept a incoming AMQP
 +// connection. Normally you would call this for a connection created by
 +// net.Listener.Accept()
 +//
 +func Server() ConnectionOption { return func(c *connection) { c.engine.Server() } }
 +
 +// AllowIncoming returns a ConnectionOption to enable incoming endpoint open requests.
 +// See Connection.Incoming()
 +func AllowIncoming() ConnectionOption {
 +	return func(c *connection) { c.incoming = make(chan Incoming) }
 +}
 +
 +type connection struct {
 +	endpoint
 +	defaultSessionOnce, closeOnce sync.Once
 +
 +	container   *container
 +	conn        net.Conn
 +	incoming    chan Incoming
 +	handler     *handler
 +	engine      *proton.Engine
 +	eConnection proton.Connection
 +
 +	defaultSession Session
 +}
 +
 +func newConnection(conn net.Conn, cont *container, setting ...ConnectionOption) (*connection, error) {
 +	c := &connection{container: cont, conn: conn}
 +	c.handler = newHandler(c)
 +	var err error
 +	c.engine, err = proton.NewEngine(c.conn, c.handler.delegator)
 +	if err != nil {
 +		return nil, err
 +	}
 +	for _, set := range setting {
 +		set(c)
 +	}
 +	c.endpoint = makeEndpoint(c.engine.String())
 +	c.eConnection = c.engine.Connection()
 +	go c.run()
 +	return c, nil
 +}
 +
 +func (c *connection) run() {
 +	c.engine.Run()
 +	if c.incoming != nil {
 +		close(c.incoming)
 +	}
 +	c.closed(Closed)
 +}
 +
 +func (c *connection) Close(err error) { c.err.Set(err); c.engine.Close(err) }
 +
 +func (c *connection) Disconnect(err error) { c.err.Set(err); c.engine.Disconnect(err) }
 +
 +func (c *connection) Session(setting ...SessionOption) (Session, error) {
 +	var s Session
 +	err := c.engine.InjectWait(func() error {
 +		if c.Error() != nil {
 +			return c.Error()
 +		}
 +		eSession, err := c.engine.Connection().Session()
 +		if err == nil {
 +			eSession.Open()
 +			if err == nil {
 +				s = newSession(c, eSession, setting...)
 +			}
 +		}
 +		return err
 +	})
 +	return s, err
 +}
 +
 +func (c *connection) Container() Container { return c.container }
 +
 +func (c *connection) DefaultSession() (s Session, err error) {
 +	c.defaultSessionOnce.Do(func() {
 +		c.defaultSession, err = c.Session()
 +	})
 +	if err == nil {
 +		err = c.Error()
 +	}
 +	return c.defaultSession, err
 +}
 +
 +func (c *connection) Sender(setting ...LinkOption) (Sender, error) {
 +	if s, err := c.DefaultSession(); err == nil {
 +		return s.Sender(setting...)
 +	} else {
 +		return nil, err
 +	}
 +}
 +
 +func (c *connection) Receiver(setting ...LinkOption) (Receiver, error) {
 +	if s, err := c.DefaultSession(); err == nil {
 +		return s.Receiver(setting...)
 +	} else {
 +		return nil, err
 +	}
 +}
 +
 +func (c *connection) Connection() Connection { return c }
 +
 +func (c *connection) Wait() error { return c.WaitTimeout(Forever) }
 +func (c *connection) WaitTimeout(timeout time.Duration) error {
 +	_, err := timedReceive(c.done, timeout)
 +	if err == Timeout {
 +		return Timeout
 +	}
 +	return c.Error()
 +}
 +
 +func (c *connection) Incoming() <-chan Incoming { return c.incoming }
 +
 +// Incoming is the interface for incoming requests to open an endpoint.
 +// Implementing types are IncomingSession, IncomingSender and IncomingReceiver.
 +type Incoming interface {
 +	// Accept and open the endpoint.
 +	Accept() Endpoint
 +
 +	// Reject the endpoint with an error
 +	Reject(error)
 +
 +	// wait for and call the accept function, call in proton goroutine.
 +	wait() error
 +	pEndpoint() proton.Endpoint
 +}
 +
 +type incoming struct {
 +	endpoint proton.Endpoint
 +	acceptCh chan func() error
 +}
 +
 +func makeIncoming(e proton.Endpoint) incoming {
 +	return incoming{endpoint: e, acceptCh: make(chan func() error)}
 +}
 +
++func (in *incoming) String() string   { return fmt.Sprintf("%s: %s", in.endpoint.Type(), in.endpoint) }
 +func (in *incoming) Reject(err error) { in.acceptCh <- func() error { return err } }
 +
 +// Call in proton goroutine, wait for and call the accept function fr
 +func (in *incoming) wait() error { return (<-in.acceptCh)() }
 +
 +func (in *incoming) pEndpoint() proton.Endpoint { return in.endpoint }
 +
 +// Called in app goroutine to send an accept function to proton and return the resulting endpoint.
 +func (in *incoming) accept(f func() Endpoint) Endpoint {
 +	done := make(chan Endpoint)
 +	in.acceptCh <- func() error {
 +		ep := f()
 +		done <- ep
 +		return nil
 +	}
 +	return <-done
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/electron/endpoint.go
----------------------------------------------------------------------
diff --cc electron/endpoint.go
index 8cbeadb,0000000..2b1f62d
mode 100644,000000..100644
--- a/electron/endpoint.go
+++ b/electron/endpoint.go
@@@ -1,94 -1,0 +1,99 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package electron
 +
 +import (
 +	"io"
 +	"qpid.apache.org/proton"
 +)
 +
 +// Closed is an alias for io.EOF. It is returned as an error when an endpoint
 +// was closed cleanly.
 +var Closed = io.EOF
 +
 +// Endpoint is the common interface for Connection, Session, Link, Sender and Receiver.
 +//
 +// Endpoints can be created locally or by the remote peer. You must Open() an
 +// endpoint before you can use it. Some endpoints have additional Set*() methods
 +// that must be called before Open() to take effect, see Connection, Session,
 +// Link, Sender and Receiver for details.
 +//
 +type Endpoint interface {
 +	// Close an endpoint and signal an error to the remote end if error != nil.
 +	Close(error)
 +
 +	// String is a human readable identifier, useful for debugging and logging.
 +	String() string
 +
 +	// Error returns nil if the endpoint is open, otherwise returns an error.
 +	// Error() == Closed means the endpoint was closed without error.
 +	Error() error
 +
 +	// Connection containing the endpoint
 +	Connection() Connection
 +
 +	// Done returns a channel that will close when the endpoint closes.
 +	// Error() will contain the reason.
 +	Done() <-chan struct{}
 +}
 +
 +// DEVELOPER NOTES
 +//
 +// An electron.Endpoint corresponds to a proton.Endpoint, which can be invalidated
 +//
 +type endpoint struct {
 +	err  proton.ErrorHolder
 +	str  string // Must be set by the value that embeds endpoint.
 +	done chan struct{}
 +}
 +
 +func makeEndpoint(s string) endpoint { return endpoint{str: s, done: make(chan struct{})} }
 +
 +// Called in handler on a Closed event. Marks the endpoint as closed and the corresponding
 +// proton.Endpoint pointer as invalid. Injected functions should check Error() to ensure
 +// the pointer has not been invalidated.
 +//
 +// Returns the error stored on the endpoint, which may not be different to err if there was
 +// already a n error
 +func (e *endpoint) closed(err error) error {
- 	e.err.Set(err)
- 	e.err.Set(Closed)
- 	close(e.done)
++	select {
++	case <-e.done:
++		// Already closed
++	default:
++		e.err.Set(err)
++		e.err.Set(Closed)
++		close(e.done)
++	}
 +	return e.err.Get()
 +}
 +
 +func (e *endpoint) String() string { return e.str }
 +
 +func (e *endpoint) Error() error { return e.err.Get() }
 +
 +func (e *endpoint) Done() <-chan struct{} { return e.done }
 +
 +// Call in proton goroutine to initiate closing an endpoint locally
 +// handler will complete the close when remote end closes.
 +func localClose(ep proton.Endpoint, err error) {
 +	if ep.State().LocalActive() {
 +		proton.CloseError(ep, err)
 +	}
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/electron/sender.go
----------------------------------------------------------------------
diff --cc electron/sender.go
index 573e9da,0000000..834eb75
mode 100644,000000..100644
--- a/electron/sender.go
+++ b/electron/sender.go
@@@ -1,274 -1,0 +1,273 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package electron
 +
 +// #include <proton/disposition.h>
 +import "C"
 +
 +import (
++	"fmt"
 +	"qpid.apache.org/amqp"
 +	"qpid.apache.org/proton"
 +	"time"
 +)
 +
 +// Sender is a Link that sends messages.
 +//
 +// The result of sending a message is provided by an Outcome value.
 +//
 +// A sender can buffer messages up to the credit limit provided by the remote receiver.
 +// Send* methods will block if the buffer is full until there is space.
 +// Send*Timeout methods will give up after the timeout and set Timeout as Outcome.Error.
 +//
 +type Sender interface {
 +	Link
 +
 +	// SendSync sends a message and blocks until the message is acknowledged by the remote receiver.
 +	// Returns an Outcome, which may contain an error if the message could not be sent.
 +	SendSync(m amqp.Message) Outcome
 +
 +	// SendWaitable puts a message in the send buffer and returns a channel that
 +	// you can use to wait for the Outcome of just that message. The channel is
 +	// buffered so you can receive from it whenever you want without blocking anything.
 +	SendWaitable(m amqp.Message) <-chan Outcome
 +
 +	// SendForget buffers a message for sending and returns, with no notification of the outcome.
 +	SendForget(m amqp.Message)
 +
 +	// SendAsync puts a message in the send buffer and returns immediately.  An
 +	// Outcome with Value = value will be sent to the ack channel when the remote
 +	// receiver has acknowledged the message or if there is an error.
 +	//
 +	// You can use the same ack channel for many calls to SendAsync(), possibly on
 +	// many Senders. The channel will receive the outcomes in the order they
 +	// become available. The channel should be buffered and/or served by dedicated
 +	// goroutines to avoid blocking the connection.
 +	//
 +	// If ack == nil no Outcome is sent.
 +	SendAsync(m amqp.Message, ack chan<- Outcome, value interface{})
 +
 +	SendAsyncTimeout(m amqp.Message, ack chan<- Outcome, value interface{}, timeout time.Duration)
 +
 +	SendWaitableTimeout(m amqp.Message, timeout time.Duration) <-chan Outcome
 +
 +	SendForgetTimeout(m amqp.Message, timeout time.Duration)
 +
 +	SendSyncTimeout(m amqp.Message, timeout time.Duration) Outcome
 +}
 +
 +// Outcome provides information about the outcome of sending a message.
 +type Outcome struct {
 +	// Status of the message: was it sent, how was it acknowledged.
 +	Status SentStatus
 +	// Error is a local error if Status is Unsent or Unacknowledged, a remote error otherwise.
 +	Error error
 +	// Value provided by the application in SendAsync()
 +	Value interface{}
 +}
 +
 +// SentStatus indicates the status of a sent message.
 +type SentStatus int
 +
 +const (
 +	// Message was never sent
 +	Unsent SentStatus = iota
 +	// Message was sent but never acknowledged. It may or may not have been received.
 +	Unacknowledged
- 	// Message was sent pre-settled, no remote outcome is available.
- 	Presettled
- 	// Message was accepted by the receiver
++	// Message was accepted by the receiver (or was sent pre-settled, accept is assumed)
 +	Accepted
 +	// Message was rejected as invalid by the receiver
 +	Rejected
 +	// Message was not processed by the receiver but may be valid for a different receiver
 +	Released
 +	// Receiver responded with an unrecognized status.
 +	Unknown
 +)
 +
 +// String human readable name for SentStatus.
 +func (s SentStatus) String() string {
 +	switch s {
 +	case Unsent:
 +		return "unsent"
 +	case Unacknowledged:
 +		return "unacknowledged"
 +	case Accepted:
 +		return "accepted"
 +	case Rejected:
 +		return "rejected"
 +	case Released:
 +		return "released"
 +	case Unknown:
 +		return "unknown"
 +	default:
- 		return "invalid"
++		return fmt.Sprintf("invalid(%d)", s)
 +	}
 +}
 +
 +// Convert proton delivery state code to SentStatus value
 +func sentStatus(d uint64) SentStatus {
 +	switch d {
 +	case proton.Accepted:
 +		return Accepted
 +	case proton.Rejected:
 +		return Rejected
 +	case proton.Released, proton.Modified:
 +		return Released
 +	default:
 +		return Unknown
 +	}
 +}
 +
 +// Sender implementation, held by handler.
 +type sender struct {
 +	link
 +	credit chan struct{} // Signal available credit.
 +}
 +
 +func (s *sender) SendAsyncTimeout(m amqp.Message, ack chan<- Outcome, v interface{}, t time.Duration) {
 +	// wait for credit
 +	if _, err := timedReceive(s.credit, t); err != nil {
 +		if err == Closed && s.Error != nil {
 +			err = s.Error()
 +		}
 +		ack <- Outcome{Unsent, err, v}
 +		return
 +	}
 +	// Send a message in handler goroutine
 +	err := s.engine().Inject(func() {
 +		if s.Error() != nil {
 +			if ack != nil {
 +				ack <- Outcome{Unsent, s.Error(), v}
 +			}
 +			return
 +		}
 +		if delivery, err := s.eLink.Send(m); err == nil {
 +			if ack != nil { // We must report an outcome
 +				if s.SndSettle() == SndSettled {
 +					delivery.Settle() // Pre-settle if required
- 					ack <- Outcome{Presettled, nil, v}
++					ack <- Outcome{Accepted, nil, v}
 +				} else {
 +					s.handler().sentMessages[delivery] = sentMessage{ack, v}
 +				}
 +			} else { // ack == nil, can't report outcome
 +				if s.SndSettle() != SndUnsettled { // Pre-settle unless we are forced not to.
 +					delivery.Settle()
 +				}
 +			}
 +		} else { // err != nil
 +			if ack != nil {
 +				ack <- Outcome{Unsent, err, v}
 +			}
 +		}
 +		if s.eLink.Credit() > 0 { // Signal there is still credit
 +			s.sendable()
 +		}
 +	})
 +	if err != nil && ack != nil {
 +		ack <- Outcome{Unsent, err, v}
 +	}
 +}
 +
 +// Set credit flag if not already set. Non-blocking, any goroutine
 +func (s *sender) sendable() {
 +	select { // Non-blocking
 +	case s.credit <- struct{}{}:
 +	default:
 +	}
 +}
 +
 +func (s *sender) SendWaitableTimeout(m amqp.Message, t time.Duration) <-chan Outcome {
 +	out := make(chan Outcome, 1)
 +	s.SendAsyncTimeout(m, out, nil, t)
 +	return out
 +}
 +
 +func (s *sender) SendForgetTimeout(m amqp.Message, t time.Duration) {
 +	s.SendAsyncTimeout(m, nil, nil, t)
 +}
 +
 +func (s *sender) SendSyncTimeout(m amqp.Message, t time.Duration) Outcome {
 +	deadline := time.Now().Add(t)
 +	ack := s.SendWaitableTimeout(m, t)
 +	t = deadline.Sub(time.Now()) // Adjust for time already spent.
 +	if t < 0 {
 +		t = 0
 +	}
 +	if out, err := timedReceive(ack, t); err == nil {
 +		return out.(Outcome)
 +	} else {
 +		if err == Closed && s.Error() != nil {
 +			err = s.Error()
 +		}
 +		return Outcome{Unacknowledged, err, nil}
 +	}
 +}
 +
 +func (s *sender) SendAsync(m amqp.Message, ack chan<- Outcome, v interface{}) {
 +	s.SendAsyncTimeout(m, ack, v, Forever)
 +}
 +
 +func (s *sender) SendWaitable(m amqp.Message) <-chan Outcome {
 +	return s.SendWaitableTimeout(m, Forever)
 +}
 +
 +func (s *sender) SendForget(m amqp.Message) {
 +	s.SendForgetTimeout(m, Forever)
 +}
 +
 +func (s *sender) SendSync(m amqp.Message) Outcome {
 +	return <-s.SendWaitable(m)
 +}
 +
 +// handler goroutine
 +func (s *sender) closed(err error) {
 +	s.link.closed(err)
 +	close(s.credit)
 +}
 +
 +func newSender(l link) *sender {
 +	s := &sender{link: l, credit: make(chan struct{}, 1)}
 +	s.handler().addLink(s.eLink, s)
 +	s.link.open()
 +	return s
 +}
 +
 +// sentMessage records a sent message on the handler.
 +type sentMessage struct {
 +	ack   chan<- Outcome
 +	value interface{}
 +}
 +
 +// IncomingSender is sent on the Connection.Incoming() channel when there is
 +// an incoming request to open a sender link.
 +type IncomingSender struct {
 +	incomingLink
 +}
 +
 +// Accept accepts an incoming sender endpoint
 +func (in *IncomingSender) Accept() Endpoint {
 +	return in.accept(func() Endpoint { return newSender(in.link) })
 +}
 +
 +// Call in injected functions to check if the sender is valid.
 +func (s *sender) valid() bool {
 +	s2, ok := s.handler().links[s.eLink].(*sender)
 +	return ok && s2 == s
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/proton/engine.go
----------------------------------------------------------------------
diff --cc proton/engine.go
index 2e67ef7,0000000..13d44b8
mode 100644,000000..100644
--- a/proton/engine.go
+++ b/proton/engine.go
@@@ -1,403 -1,0 +1,397 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +package proton
 +
 +// #include <proton/connection.h>
 +// #include <proton/event.h>
++// #include <proton/error.h>
 +// #include <proton/handlers.h>
 +// #include <proton/session.h>
 +// #include <proton/transport.h>
 +// #include <memory.h>
 +// #include <stdlib.h>
 +//
 +// PN_HANDLE(REMOTE_ADDR)
 +import "C"
 +
 +import (
 +	"fmt"
 +	"io"
 +	"net"
 +	"sync"
 +	"unsafe"
 +)
 +
 +// Injecter allows functions to be "injected" into the event-processing loop, to
 +// be called in the same goroutine as event handlers.
 +type Injecter interface {
 +	// Inject a function into the engine goroutine.
 +	//
 +	// f() will be called in the same goroutine as event handlers, so it can safely
 +	// use values belonging to event handlers without synchronization. f() should
 +	// not block, no further events or injected functions can be processed until
 +	// f() returns.
 +	//
 +	// Returns a non-nil error if the function could not be injected and will
 +	// never be called. Otherwise the function will eventually be called.
 +	//
 +	// Note that proton values (Link, Session, Connection etc.) that existed when
 +	// Inject(f) was called may have become invalid by the time f() is executed.
 +	// Handlers should handle keep track of Closed events to ensure proton values
 +	// are not used after they become invalid. One technique is to have map from
 +	// proton values to application values. Check that the map has the correct
 +	// proton/application value pair at the start of the injected function and
 +	// delete the value from the map when handling a Closed event.
 +	Inject(f func()) error
 +
 +	// InjectWait is like Inject but does not return till f() has completed.
 +	// If f() cannot be injected it returns the error from Inject(), otherwise
 +	// it returns the error from f()
 +	InjectWait(f func() error) error
 +}
 +
 +// bufferChan manages a pair of ping-pong buffers to pass bytes through a channel.
 +type bufferChan struct {
 +	buffers    chan []byte
 +	buf1, buf2 []byte
 +}
 +
 +func newBufferChan(size int) *bufferChan {
 +	return &bufferChan{make(chan []byte), make([]byte, size), make([]byte, size)}
 +}
 +
 +func (b *bufferChan) buffer() []byte {
 +	b.buf1, b.buf2 = b.buf2, b.buf1 // Alternate buffers.
 +	return b.buf1[:cap(b.buf1)]
 +}
 +
 +// Engine reads from a net.Conn, decodes AMQP events and calls the appropriate
 +// Handler functions sequentially in a single goroutine. Actions taken by
 +// Handler functions (such as sending messages) are encoded and written to the
 +// net.Conn. You can create multiple Engines to handle multiple connections
 +// concurrently.
 +//
 +// You implement the EventHandler and/or MessagingHandler interfaces and provide
 +// those values to NewEngine(). Their HandleEvent method will be called in the
 +// event-handling goroutine.
 +//
 +// Handlers can pass values from an event (Connections, Links, Deliveries etc.) to
 +// other goroutines, store them, or use them as map indexes. Effectively they are
 +// just pointers.  Other goroutines cannot call their methods directly but they can
 +// can create a function closure to call such methods and pass it to Engine.Inject()
 +// to have it evaluated in the engine goroutine.
 +//
 +// You are responsible for ensuring you don't use an event value after it is
 +// invalid. The handler methods will tell you when a value is no longer valid. For
 +// example after a LinkClosed event, that link is no longer valid. If you do
 +// Link.Close() yourself (in a handler or injected function) the link remains valid
 +// until the corresponing LinkClosed event is received by the handler.
 +//
 +// Engine.Close() will take care of cleaning up any remaining values when you are
 +// done with the Engine. All values associated with a engine become invalid when you
 +// call Engine.Close()
 +//
 +// The qpid.apache.org/proton/concurrent package will do all this for you, so it
 +// may be a better choice for some applications.
 +//
 +type Engine struct {
 +	// Error is set on exit from Run() if there was an error.
 +	err    ErrorHolder
 +	inject chan func()
 +
 +	conn       net.Conn
 +	connection Connection
 +	transport  Transport
 +	collector  *C.pn_collector_t
 +	read       *bufferChan    // Read buffers channel.
 +	write      *bufferChan    // Write buffers channel.
 +	handlers   []EventHandler // Handlers for proton events.
 +	running    chan struct{}  // This channel will be closed when the goroutines are done.
 +	closeOnce  sync.Once
 +}
 +
 +const bufferSize = 4096
 +
 +// NewEngine initializes a engine with a connection and handlers. To start it running:
 +//    eng := NewEngine(...)
 +//    go run eng.Run()
 +// The goroutine will exit when the engine is closed or disconnected.
 +// You can check for errors on Engine.Error.
 +//
 +func NewEngine(conn net.Conn, handlers ...EventHandler) (*Engine, error) {
 +	// Save the connection ID for Connection.String()
 +	eng := &Engine{
 +		inject:     make(chan func()),
 +		conn:       conn,
 +		transport:  Transport{C.pn_transport()},
 +		connection: Connection{C.pn_connection()},
 +		collector:  C.pn_collector(),
 +		handlers:   handlers,
 +		read:       newBufferChan(bufferSize),
 +		write:      newBufferChan(bufferSize),
 +		running:    make(chan struct{}),
 +	}
 +	if eng.transport.IsNil() || eng.connection.IsNil() || eng.collector == nil {
 +		return nil, fmt.Errorf("failed to allocate engine")
 +	}
 +
 +	// TODO aconway 2015-06-25: connection settings for user, password, container etc.
 +	// before transport.Bind() Set up connection before Engine, allow Engine or Reactor
 +	// to run connection.
 +
 +	// Unique container-id by default.
 +	eng.connection.SetContainer(UUID4().String())
 +	pnErr := eng.transport.Bind(eng.connection)
 +	if pnErr != 0 {
 +		return nil, fmt.Errorf("cannot setup engine: %s", PnErrorCode(pnErr))
 +	}
 +	C.pn_connection_collect(eng.connection.pn, eng.collector)
 +	eng.connection.Open()
 +	return eng, nil
 +}
 +
 +func (eng *Engine) String() string {
 +	return fmt.Sprintf("%s-%s", eng.conn.LocalAddr(), eng.conn.RemoteAddr())
 +}
 +
 +func (eng *Engine) Id() string {
 +	return fmt.Sprintf("%eng", &eng)
 +}
 +
 +func (eng *Engine) Error() error {
 +	return eng.err.Get()
 +}
 +
 +// Inject a function into the Engine's event loop.
 +//
 +// f() will be called in the same event-processing goroutine that calls Handler
 +// methods. f() can safely call methods on values that belong to this engine
 +// (Sessions, Links etc)
 +//
 +// The injected function has no parameters or return values. It is normally a
 +// closure and can use channels to communicate with the injecting goroutine if
 +// necessary.
 +//
 +// Returns a non-nil error if the engine is closed before the function could be
 +// injected.
 +func (eng *Engine) Inject(f func()) error {
 +	select {
 +	case eng.inject <- f:
 +		return nil
 +	case <-eng.running:
 +		return eng.Error()
 +	}
 +}
 +
 +// InjectWait is like Inject but does not return till f() has completed or the
 +// engine is closed, and returns an error value from f()
 +func (eng *Engine) InjectWait(f func() error) error {
 +	done := make(chan error)
 +	defer close(done)
 +	err := eng.Inject(func() { done <- f() })
 +	if err != nil {
 +		return err
 +	}
 +	select {
 +	case <-eng.running:
 +		return eng.Error()
 +	case err := <-done:
 +		return err
 +	}
 +}
 +
 +// Server puts the Engine in server mode, meaning it will auto-detect security settings on
 +// the incoming connnection such as use of SASL and SSL.
 +// Must be called before Run()
 +//
 +func (eng *Engine) Server() { eng.transport.SetServer() }
 +
 +// Close the engine's connection, returns when the engine has exited.
 +func (eng *Engine) Close(err error) {
 +	eng.err.Set(err)
 +	eng.Inject(func() {
 +		CloseError(eng.connection, err)
 +	})
 +	<-eng.running
 +}
 +
 +// Disconnect the engine's connection without and AMQP close, returns when the engine has exited.
 +func (eng *Engine) Disconnect(err error) {
 +	eng.err.Set(err)
 +	eng.conn.Close()
 +	<-eng.running
 +}
 +
 +// Run the engine. Engine.Run() will exit when the engine is closed or
 +// disconnected.  You can check for errors after exit with Engine.Error().
 +//
 +func (eng *Engine) Run() error {
 +	wait := sync.WaitGroup{}
 +	wait.Add(2) // Read and write goroutines
 +
 +	readErr := make(chan error, 1) // Don't block
 +	go func() {                    // Read goroutine
 +		defer wait.Done()
 +		for {
 +			rbuf := eng.read.buffer()
 +			n, err := eng.conn.Read(rbuf)
 +			if n > 0 {
 +				eng.read.buffers <- rbuf[:n]
 +			}
 +			if err != nil {
 +				readErr <- err
 +				close(readErr)
 +				close(eng.read.buffers)
 +				return
 +			}
 +		}
 +	}()
 +
 +	writeErr := make(chan error, 1) // Don't block
 +	go func() {                     // Write goroutine
 +		defer wait.Done()
 +		for {
 +			wbuf, ok := <-eng.write.buffers
 +			if !ok {
 +				return
 +			}
 +			_, err := eng.conn.Write(wbuf)
 +			if err != nil {
 +				writeErr <- err
 +				close(writeErr)
 +				return
 +			}
 +		}
 +	}()
 +
 +	wbuf := eng.write.buffer()[:0]
 +
 +	for eng.err.Get() == nil {
 +		if len(wbuf) == 0 {
 +			eng.pop(&wbuf)
 +		}
 +		// Don't set wchan unless there is something to write.
 +		var wchan chan []byte
 +		if len(wbuf) > 0 {
 +			wchan = eng.write.buffers
 +		}
 +
 +		select {
 +		case buf, ok := <-eng.read.buffers: // Read a buffer
 +			if ok {
 +				eng.push(buf)
 +			}
 +		case wchan <- wbuf: // Write a buffer
 +			wbuf = eng.write.buffer()[:0]
 +		case f, ok := <-eng.inject: // Function injected from another goroutine
 +			if ok {
 +				f()
 +			}
 +		case err := <-readErr:
 +			eng.netError(err)
 +		case err := <-writeErr:
 +			eng.netError(err)
 +		}
 +		eng.process()
 +	}
 +	close(eng.write.buffers)
 +	eng.conn.Close() // Make sure connection is closed
 +	wait.Wait()
 +	close(eng.running) // Signal goroutines have exited and Error is set.
 +
- 	// Execute any injected functions for side effects on application data structures.
- 	inject := eng.inject
- 	eng.inject = nil // Further calls to Inject() will return an error.
- 	for f := range inject {
- 		f()
- 	}
- 
 +	if !eng.connection.IsNil() {
 +		eng.connection.Free()
 +	}
 +	if !eng.transport.IsNil() {
 +		eng.transport.Free()
 +	}
 +	if eng.collector != nil {
 +		C.pn_collector_free(eng.collector)
 +	}
 +	for _, h := range eng.handlers {
 +		switch h := h.(type) {
 +		case cHandler:
 +			C.pn_handler_free(h.pn)
 +		}
 +	}
 +	return eng.err.Get()
 +}
 +
 +func (eng *Engine) netError(err error) {
 +	eng.err.Set(err)
 +	eng.transport.CloseHead()
 +	eng.transport.CloseTail()
 +}
 +
 +func minInt(a, b int) int {
 +	if a < b {
 +		return a
 +	} else {
 +		return b
 +	}
 +}
 +
 +func (eng *Engine) pop(buf *[]byte) {
 +	pending := int(eng.transport.Pending())
 +	switch {
 +	case pending == int(C.PN_EOS):
 +		*buf = (*buf)[:]
 +		return
 +	case pending < 0:
 +		panic(fmt.Errorf("%s", PnErrorCode(pending)))
 +	}
 +	size := minInt(pending, cap(*buf))
 +	*buf = (*buf)[:size]
 +	if size == 0 {
 +		return
 +	}
 +	C.memcpy(unsafe.Pointer(&(*buf)[0]), eng.transport.Head(), C.size_t(size))
 +	assert(size > 0)
 +	eng.transport.Pop(uint(size))
 +}
 +
 +func (eng *Engine) push(buf []byte) {
 +	buf2 := buf
 +	for len(buf2) > 0 {
 +		n := eng.transport.Push(buf2)
 +		if n <= 0 {
 +			panic(fmt.Errorf("error in transport: %s", PnErrorCode(n)))
 +		}
 +		buf2 = buf2[n:]
 +	}
 +}
 +
 +func (eng *Engine) handle(e Event) {
 +	for _, h := range eng.handlers {
 +		h.HandleEvent(e)
 +	}
 +	if e.Type() == ETransportClosed {
 +		eng.err.Set(io.EOF)
 +	}
 +}
 +
 +func (eng *Engine) process() {
 +	for ce := C.pn_collector_peek(eng.collector); ce != nil; ce = C.pn_collector_peek(eng.collector) {
 +		eng.handle(makeEvent(ce, eng))
 +		C.pn_collector_pop(eng.collector)
 +	}
 +}
 +
 +func (eng *Engine) Connection() Connection { return eng.connection }


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


[13/50] [abbrv] qpid-proton git commit: PROTON-1071: disable ApplicationEventTest temporarily on Windows until fixed.

Posted by ac...@apache.org.
PROTON-1071: disable ApplicationEventTest temporarily on Windows until fixed.


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

Branch: refs/heads/go1
Commit: 19a30357297f9d637f1d9f4e67d4de6191907771
Parents: 73aad71
Author: Clifford Jansen <cl...@apache.org>
Authored: Tue Dec 8 10:53:49 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Tue Dec 8 10:53:49 2015 -0800

----------------------------------------------------------------------
 tests/python/proton_tests/reactor.py | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/19a30357/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index c8cd894..eeddb2f 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -428,6 +428,9 @@ class ApplicationEventTest(Test):
         if not hasattr(os, 'pipe'):
           # KAG: seems like Jython doesn't have an os.pipe() method
           raise SkipTest()
+        if os.name=="nt":
+          # Correct implementation on Windows is complicated
+          raise SkipTest("PROTON-1071")
         self.server = ApplicationEventTest.MyTestServer()
         self.server.reactor.handler.add(ApplicationEventTest.MyHandler(self))
         self.event_injector = EventInjector()


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


[21/50] [abbrv] qpid-proton git commit: PROTON-1075: go: Enable -race by default for go tests, use go tools for dependency checking.

Posted by ac...@apache.org.
PROTON-1075: go: Enable -race by default for go tests, use go tools for dependency checking.

Added the -race flag by default with golang go, disabled by default for gccgo as
it does not work for me - errors about circular dependencies.

Removed cumbersome and incorrect CMake code for checking go dependencies, use
the simple go tools instead. `go install` runs each time you run make, but it
does nothing if nothing needs to be done so there is no impact on build times.


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

Branch: refs/heads/go1
Commit: 22c3ee91039d0a53730e60b94bf6cb7dddc24bce
Parents: d9c0ed5
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 11 12:11:44 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 11 13:13:29 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/go/CMakeLists.txt | 56 +++++++-------------------------
 1 file changed, 12 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/22c3ee91/proton-c/bindings/go/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/CMakeLists.txt b/proton-c/bindings/go/CMakeLists.txt
index b1ed962..cea6671 100644
--- a/proton-c/bindings/go/CMakeLists.txt
+++ b/proton-c/bindings/go/CMakeLists.txt
@@ -22,13 +22,14 @@ execute_process(COMMAND ${GO_EXE} version OUTPUT_VARIABLE go_ver OUTPUT_STRIP_TR
 message(STATUS "Found Go: ${GO_EXE} (${go_ver})")
 
 set(GO_BUILD_FLAGS "" CACHE STRING "Flags for 'go build'")
-set(GO_TEST_FLAGS "-v" CACHE STRING "Flags for 'go test'")
 
 # Flags that differ for golang go and gcc go.
-if (go_out MATCHES "gccgo")
+if (go_ver MATCHES "gccgo")
   # TODO aconway 2015-10-08: import cycles with -race under gccgo, investigate.
+  set(GO_TEST_FLAGS "-v" CACHE STRING "Flags for 'go test'")
   set(GO_RPATH_FLAGS -gccgoflags "-Wl,-rpath=${CMAKE_BINARY_DIR}/proton-c")
 else()
+  set(GO_TEST_FLAGS "-v -race" CACHE STRING "Flags for 'go test'")
   set(GO_RPATH_FLAGS -ldflags "-r ${CMAKE_BINARY_DIR}/proton-c")
 endif()
 
@@ -48,52 +49,19 @@ set(GO_BUILD ${GO} build ${GO_BUILD_FLAGS} ${GO_RPATH_FLAGS} CACHE INTERNAL "Run
 set(GO_INSTALL ${GO} install ${GO_BUILD_FLAGS} CACHE INTERNAL "Run go install" )
 set(GO_TEST ${GO} test ${GO_BUILD_FLAGS} ${GO_RPATH_FLAGS} ${GO_TEST_FLAGS} CACHE INTERNAL "Run go test")
 
-# Go build depends on the C headers
-file(GLOB cheaders ${CMAKE_SOURCE_DIR}/proton_c/include/proton/*.h)
-set(cdepends ${headers} qpid-proton)
-
 # Go tools insist on standard Go layout which puts compiled code in the source tree :(
 # Build output is all under git-ignored pkg or bin subdirectories, they are removed by make clean.
-foreach (pkg amqp proton electron)
-
-  set(package "qpid.apache.org/${pkg}")
-
-  # Get the target library location
-  macro(go_list var template)
-    execute_process(COMMAND ${GO} list -f "${template}" ${package}
-      OUTPUT_VARIABLE ${var} OUTPUT_STRIP_TRAILING_WHITESPACE)
-  endmacro()
-  go_list(lib  "{{.Target}}")
-
-  # Get package sources
-  go_list(dir "{{.Dir}}")
-  macro(go_sources field)
-    go_list(${field} "{{range .${field}}}${dir}/{{.}};{{end}}")
-  endmacro()
-  go_sources(GoFiles)
-  go_sources(CgoFiles)
-  set(sources "${GoFiles}${CgoFiles}")
-
-  # Build the package library
-  add_custom_command(
-    OUTPUT ${lib} COMMAND ${GO_INSTALL} ${package}
-    DEPENDS ${sources} ${cdepends}
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
-  set(target go-package-${pkg})
-  add_custom_target(${target} ALL DEPENDS ${lib})
 
-  # Package test
-  go_sources(TestGoFiles)
-  set(test_exe ${CMAKE_CURRENT_BINARY_DIR}/${pkg}.test)
-  add_custom_command(
-    OUTPUT ${test_exe} COMMAND ${GO_TEST} -c -o ${test_exe} ${package}
-    DEPENDS ${sources} ${cdepends} qpid-proton
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
-  add_custom_target(go-package-test-${pkg} ALL DEPENDS ${test_exe})
-  add_test(NAME go_test_${pkg} COMMAND ${test_exe} WORKING_DIRECTORY ${dir})
+# The go build tools handle dependency checks and incremental builds better than
+# CMake so just run them every time, they do nothing if nothing needs to be
+# done.
+add_custom_target(go-build ALL
+  COMMAND ${GO_INSTALL} qpid.apache.org/...
+  WORKING_DIRECTORY $ENV{PWD})  # get error filenames relative to the directory you ran 'make' in
 
-  list(APPEND targets ${target})
-endforeach()
+add_test(
+  NAME go-test COMMAND ${GO_TEST} qpid.apache.org/...
+  WORKING_DIRECTORY $ENV{PWD})
 
 # Make available to examples/go/CMakeLists
 set(GO_TARGETS ${targets} CACHE INTERNAL "Go package library targets")


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


[22/50] [abbrv] qpid-proton git commit: PROTON-1075: Data races detected in go_test_electron.

Posted by ac...@apache.org.
PROTON-1075: Data races detected in go_test_electron.

Removed un-necessary code to drain the Engine.inject channel, the channel is not
buffered so there cannot be anything to drain. Inject also selects on the done
channel so all goroutines waiting to inject will unblock.

Made endpoint.closed() idempotent, fixing the above revealed that it can be
called twice depending on timing.


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

Branch: refs/heads/go1
Commit: 3f4dc74a4bab7af639a6c8e0bfe4853fb69744dd
Parents: 22c3ee9
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 11 12:30:07 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 11 13:13:30 2015 -0500

----------------------------------------------------------------------
 .../bindings/go/src/qpid.apache.org/electron/endpoint.go | 11 ++++++++---
 .../bindings/go/src/qpid.apache.org/proton/engine.go     |  7 -------
 2 files changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3f4dc74a/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go b/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
index 8cbeadb..2b1f62d 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
@@ -73,9 +73,14 @@ func makeEndpoint(s string) endpoint { return endpoint{str: s, done: make(chan s
 // Returns the error stored on the endpoint, which may not be different to err if there was
 // already a n error
 func (e *endpoint) closed(err error) error {
-	e.err.Set(err)
-	e.err.Set(Closed)
-	close(e.done)
+	select {
+	case <-e.done:
+		// Already closed
+	default:
+		e.err.Set(err)
+		e.err.Set(Closed)
+		close(e.done)
+	}
 	return e.err.Get()
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3f4dc74a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
index 2e67ef7..95d70e9 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
@@ -315,13 +315,6 @@ func (eng *Engine) Run() error {
 	wait.Wait()
 	close(eng.running) // Signal goroutines have exited and Error is set.
 
-	// Execute any injected functions for side effects on application data structures.
-	inject := eng.inject
-	eng.inject = nil // Further calls to Inject() will return an error.
-	for f := range inject {
-		f()
-	}
-
 	if !eng.connection.IsNil() {
 		eng.connection.Free()
 	}


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


[12/50] [abbrv] qpid-proton git commit: PROTON-1068: Export encapsulated incref/decref functions - C++ Build fails on windows otherwise.

Posted by ac...@apache.org.
PROTON-1068: Export encapsulated incref/decref functions
- C++ Build fails on windows otherwise.


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

Branch: refs/heads/go1
Commit: 73aad7123a3f35785ebde0b961eda2c1c7223d94
Parents: a8e9582
Author: Andrew Stitcher <as...@apache.org>
Authored: Mon Dec 7 17:37:16 2015 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Dec 7 17:37:16 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/object.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/73aad712/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index 0da20ae..6e5cef5 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -30,8 +30,8 @@ namespace proton {
 ///@cond INTERNAL
 class pn_ptr_base {
   protected:
-    static void incref(void* p);
-    static void decref(void* p);
+    PN_CPP_EXTERN static void incref(void* p);
+    PN_CPP_EXTERN static void decref(void* p);
 };
 
 template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_base {


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


[31/50] [abbrv] qpid-proton git commit: PROTON-1080: add alias for reactor when using any Reactor subclass

Posted by ac...@apache.org.
PROTON-1080: add alias for reactor when using any Reactor subclass


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

Branch: refs/heads/go1
Commit: 7ccd632974cc643030a8580ca72da645f6a22766
Parents: 87ece50
Author: Gordon Sim <gs...@redhat.com>
Authored: Tue Dec 15 20:20:28 2015 +0000
Committer: Gordon Sim <gs...@redhat.com>
Committed: Tue Dec 15 21:47:11 2015 +0000

----------------------------------------------------------------------
 proton-c/bindings/python/proton/__init__.py |  7 +++++
 tests/python/proton_tests/reactor.py        | 36 ++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7ccd6329/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index 2a87fe7..f3a8e8d 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -3805,6 +3805,13 @@ class Event(Wrapper, EventBase):
     """Returns the reactor associated with the event."""
     return wrappers.get("pn_reactor", _none)(pn_event_reactor(self._impl))
 
+  def __getattr__(self, name):
+    r = self.reactor
+    if r and hasattr(r, 'subclass') and r.subclass.__name__.lower() == name:
+      return r
+    else:
+      return super(Event, self).__getattr__(name)
+
   @property
   def transport(self):
     """Returns the transport associated with the event, or null if none is associated with it."""

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7ccd6329/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index eeddb2f..c58530a 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -19,9 +19,9 @@ from __future__ import absolute_import
 #
 
 import time
-from .common import Test, SkipTest, TestServer
-from proton.reactor import Reactor, ApplicationEvent, EventInjector
-from proton.handlers import CHandshaker
+from .common import Test, SkipTest, TestServer, free_tcp_port
+from proton.reactor import Container, Reactor, ApplicationEvent, EventInjector
+from proton.handlers import CHandshaker, MessagingHandler
 from proton import Handler
 
 class Barf(Exception):
@@ -457,3 +457,33 @@ class ApplicationEventTest(Test):
         self._wait_for(lambda: self.hello_rcvd is not None)
         self.event_injector.trigger(self.goodbye_event)
         self._wait_for(lambda: self.goodbye_rcvd is not None)
+
+
+class ContainerTest(Test):
+    """Test container subclass of reactor."""
+
+    def test_event_container(self):
+        class TestHandler(MessagingHandler):
+            def __init__(self):
+                super(TestHandler, self).__init__()
+                port = free_tcp_port()
+                self.url = "localhost:%i" % port
+
+            def on_start(self, event):
+                self.listener = event.container.listen(self.url)
+
+            def on_connection_closing(self, event):
+                event.connection.close()
+                self.listener.close()
+        test_handler = TestHandler()
+        container = Container(test_handler)
+        class ConnectionHandler(MessagingHandler):
+            def __init__(self):
+                super(ConnectionHandler, self).__init__()
+
+            def on_connection_opened(self, event):
+                event.connection.close()
+                assert event.container == event.reactor
+                assert event.container == container
+        container.connect(test_handler.url, handler=ConnectionHandler())
+        container.run()


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


[46/50] [abbrv] qpid-proton git commit: PROTON-1085: c++: clean up access to message properties, instructions and annotations.

Posted by ac...@apache.org.
PROTON-1085: c++: clean up access to message properties, instructions and annotations.

- Use proton::value& as message::body() type.
- Create pn_message on demand for empty message.
- Use proton::scalar as basis for messsage_id and annotation_key
  - message_id restricted to be one of: uint64_t, amqp_uuid, amqp_binary or amqp_string.
  - annotation_key restricted to be on of: uint64_t or amqp_symbol.
- Decode and cache application properties, annotations and instructions on demand as std::map.
  - message::properties() returns std::map<std::string, scalar>&
  - message::instructions()/annotations() returns std::map<annotation_key, value>&


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

Branch: refs/heads/go1
Commit: 1622d0e608738da7b603b7e497bc3a8166325865
Parents: d2c5a5f
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 18 09:33:58 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 29 15:56:44 2015 -0500

----------------------------------------------------------------------
 examples/cpp/client.cpp                         |   2 +-
 examples/cpp/example_test.py                    |  18 +-
 proton-c/CMakeLists.txt                         |   2 +-
 .../cpp/include/proton/annotation_key.hpp       |  58 +++++
 proton-c/bindings/cpp/include/proton/data.hpp   |   2 -
 .../bindings/cpp/include/proton/decoder.hpp     |  27 +--
 .../bindings/cpp/include/proton/encoder.hpp     |  26 +-
 proton-c/bindings/cpp/include/proton/error.hpp  |   6 +
 .../bindings/cpp/include/proton/message.hpp     |  81 +++----
 .../bindings/cpp/include/proton/message_id.hpp  |  67 ++---
 proton-c/bindings/cpp/include/proton/scalar.hpp | 117 +++++----
 proton-c/bindings/cpp/include/proton/ssl.hpp    |   2 +-
 .../bindings/cpp/include/proton/type_traits.hpp |   2 +-
 proton-c/bindings/cpp/include/proton/types.hpp  |  77 +++---
 proton-c/bindings/cpp/include/proton/value.hpp  |  16 +-
 proton-c/bindings/cpp/src/decoder.cpp           | 138 ++++++-----
 .../bindings/cpp/src/encode_decode_test.cpp     |  39 ++-
 proton-c/bindings/cpp/src/encoder.cpp           |  56 +++--
 proton-c/bindings/cpp/src/error.cpp             |   2 +
 proton-c/bindings/cpp/src/event.cpp             |   2 +-
 proton-c/bindings/cpp/src/message.cpp           | 242 ++++++++-----------
 proton-c/bindings/cpp/src/message_test.cpp      | 102 +++++---
 proton-c/bindings/cpp/src/scalar.cpp            |  97 +++++---
 proton-c/bindings/cpp/src/scalar_test.cpp       |  80 ++++--
 proton-c/bindings/cpp/src/types.cpp             |  20 +-
 proton-c/bindings/cpp/src/value.cpp             |  14 ++
 26 files changed, 751 insertions(+), 544 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index 4dee119..3f5c4ab 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -58,7 +58,7 @@ class client : public proton::messaging_handler {
     void on_message(proton::event &e) {
         if (requests.empty()) return; // Spurious extra message!
         proton::message& response = e.message();
-        std::cout << '"' << requests.front() << '"' << " => " << response.body() << std::endl;
+        std::cout << requests.front() << " => " << response.body() << std::endl;
         requests.erase(requests.begin());
         if (!requests.empty()) {
             send_request();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 1f800c0..c1e7ac5 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -125,17 +125,17 @@ class ExampleTest(unittest.TestCase):
     def test_helloworld(self):
         b = Broker.get()
         hw = execute("helloworld", b.addr)
-        self.assertEqual('"Hello World!"\n', hw)
+        self.assertEqual('Hello World!\n', hw)
 
     def test_helloworld_blocking(self):
         b = Broker.get()
         hw = execute("helloworld_blocking", b.addr)
-        self.assertEqual('"Hello World!"\n', hw)
+        self.assertEqual('Hello World!\n', hw)
 
     def test_helloworld_direct(self):
         addr = pick_addr()
         hw = execute("helloworld_direct", addr)
-        self.assertEqual('"Hello World!"\n', hw)
+        self.assertEqual('Hello World!\n', hw)
 
     def test_simple_send_recv(self):
         b = Broker.get()
@@ -165,10 +165,10 @@ class ExampleTest(unittest.TestCase):
         send_expect = "direct_send listening on amqp://%s\nall messages confirmed\n" % (addr)
         self.assertEqual(send_expect, verify(send))
 
-    CLIENT_EXPECT=""""Twas brillig, and the slithy toves" => "TWAS BRILLIG, AND THE SLITHY TOVES"
-"Did gire and gymble in the wabe." => "DID GIRE AND GYMBLE IN THE WABE."
-"All mimsy were the borogroves," => "ALL MIMSY WERE THE BOROGROVES,"
-"And the mome raths outgrabe." => "AND THE MOME RATHS OUTGRABE."
+    CLIENT_EXPECT="""Twas brillig, and the slithy toves => TWAS BRILLIG, AND THE SLITHY TOVES
+Did gire and gymble in the wabe. => DID GIRE AND GYMBLE IN THE WABE.
+All mimsy were the borogroves, => ALL MIMSY WERE THE BOROGROVES,
+And the mome raths outgrabe. => AND THE MOME RATHS OUTGRABE.
 """
     def test_simple_recv_send(self):
         # Start receiver first, then run sender"""
@@ -247,7 +247,7 @@ Tock...
     def test_ssl(self):
         # SSL without SASL
         expect="""Outgoing client connection connected via SSL.  Server certificate identity CN=test_server
-"Hello World!"
+Hello World!
 """
         addr = "amqps://" + pick_addr() + "/examples"
         ignore_first_line, ignore_nl, ssl_hw = execute("ssl", addr, ssl_certs_dir()).partition('\n')
@@ -257,7 +257,7 @@ Tock...
         # SSL with SASL EXTERNAL
         expect="""Inbound client certificate identity CN=test_client
 Outgoing client connection connected via SSL.  Server certificate identity CN=test_server
-"Hello World!"
+Hello World!
 """
         addr = "amqps://" + pick_addr() + "/examples"
         ignore_first_line, ignore_nl, ssl_hw = execute("ssl_client_cert", addr, ssl_certs_dir()).partition('\n')

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 3d2f457..b645563 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -246,7 +246,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   if (ENABLE_WARNING_ERROR)
     set (WERROR "-Werror")
   endif (ENABLE_WARNING_ERROR)
-  set (CXX_WARNING_FLAGS "${WERROR} -pedantic -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-padded -Wno-sign-conversion -Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors -Wno-global-constructors -Wno-shorten-64-to-32")
+  set (CXX_WARNING_FLAGS "${WERROR} -pedantic -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-padded -Wno-sign-conversion -Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors -Wno-global-constructors -Wno-shorten-64-to-32 -Wno-documentation -Wno-documentation-unknown-command")
 endif()
 
 if (MSVC)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/annotation_key.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/annotation_key.hpp b/proton-c/bindings/cpp/include/proton/annotation_key.hpp
new file mode 100644
index 0000000..edd63b1
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/annotation_key.hpp
@@ -0,0 +1,58 @@
+#ifndef ANNOTATION_KEY_HPP
+#define ANNOTATION_KEY_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/types.hpp"
+#include "proton/scalar.hpp"
+
+namespace proton {
+class encoder;
+class decoder;
+
+/** An annotation_key can contain one of the following types: uint64_t or amqp_symbol. */
+class annotation_key : public restricted_scalar {
+  public:
+    annotation_key() { scalar_ = uint64_t(0); }
+
+    ///@name Assign a C++ value, deduce the AMQP type()
+    ///@{
+    annotation_key& operator=(uint64_t x) { scalar_ = x; return *this; }
+    annotation_key& operator=(const amqp_symbol& x) { scalar_ = x; return *this; }
+    /// std::string is encoded as amqp_symbol
+    annotation_key& operator=(const std::string& x) { scalar_ = amqp_symbol(x); return *this; }
+    /// char* is encoded as amqp_symbol
+    annotation_key& operator=(const char *x) { scalar_ = amqp_symbol(x); return *this; }
+    ///@}
+
+    /// Converting constructor from any type that we can assign from.
+    template <class T> annotation_key(T x) { *this = x; }
+
+    void get(uint64_t& x) const { scalar_.get(x); }
+    void get(amqp_symbol& x) const { scalar_.get(x); }
+
+    template<class T> T get() const { T x; get(x); return x; }
+
+  friend PN_CPP_EXTERN encoder operator<<(encoder, const annotation_key&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, annotation_key&);
+  friend class message;
+};
+
+}
+#endif // ANNOTATION_KEY_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index 37e1a61..7581ac7 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -39,8 +39,6 @@ class data;
 class data : public object<pn_data_t> {
   public:
     data(pn_data_t* d) : object<pn_data_t>(d) {}
-    data(const data& d) : object<pn_data_t>(d) {}
-    data& operator=(const data&);
 
     PN_CPP_EXTERN static data create();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/decoder.hpp b/proton-c/bindings/cpp/include/proton/decoder.hpp
index 3073989..5dae3c3 100644
--- a/proton-c/bindings/cpp/include/proton/decoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/decoder.hpp
@@ -44,11 +44,11 @@ struct pn_data_t;
 
 namespace proton {
 
+class scalar;
 class data;
 class message_id;
-
-/** Raised by decoder operations on error.*/
-struct decode_error : public error { PN_CPP_EXTERN explicit decode_error(const std::string&); };
+class annotation_key;
+class value;
 
 /** Skips a value with `dec >> skip()`. */
 struct skip{};
@@ -208,7 +208,9 @@ class decoder : public object<pn_data_t> {
     PN_CPP_EXTERN friend decoder operator>>(decoder, amqp_uuid&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, std::string&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, message_id&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, annotation_key&);
     PN_CPP_EXTERN friend decoder operator>>(decoder, value&);
+    PN_CPP_EXTERN friend decoder operator>>(decoder, scalar&);
     ///@}
 
     /** Extract and return a value of type T. */
@@ -256,8 +258,6 @@ class decoder : public object<pn_data_t> {
 
   private:
     PN_CPP_EXTERN void check_type(type_id);
-
-  friend class encoder;
 };
 
 /** Call decoder::start() in constructor, decoder::finish in destructor().
@@ -280,20 +280,13 @@ operator>>(decoder d, T& i)  {
 }
 
 ///@cond INTERNAL
-template <class T> struct sequence_ref {
-    sequence_ref(T& v) : value(v) {}
-    T& value;
-};
-
-template <class T> struct map_ref {
-    map_ref(T& v) : value(v) {}
-    T& value;
-};
-
-template <class T> struct pairs_ref {
-    pairs_ref(T& v) : value(v) {}
+template <class T> struct ref {
+    ref(T& v) : value(v) {}
     T& value;
 };
+template <class T> struct sequence_ref : public ref<T> { sequence_ref(T& v) : ref<T>(v) {} };
+template <class T> struct map_ref : public ref<T> { map_ref(T& v) : ref<T>(v) {} };
+template <class T> struct pairs_ref : public ref<T> { pairs_ref(T& v) : ref<T>(v) {} };
 ///@endcond
 
 /**

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/encoder.hpp b/proton-c/bindings/cpp/include/proton/encoder.hpp
index 940064d..e521922 100644
--- a/proton-c/bindings/cpp/include/proton/encoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/encoder.hpp
@@ -44,11 +44,31 @@ struct pn_data_t;
 
 namespace proton {
 
+class scalar;
 class data;
 class message_id;
+class annotation_key;
+class value;
 
-/** Raised by encoder operations on error */
-struct encode_error : public error { PN_CPP_EXTERN explicit encode_error(const std::string&); };
+///@cond INTERNAL
+template<class T, type_id A> struct cref {
+    typedef T cpp_type;
+    static const type_id type;
+
+    cref(const T& v) : value(v) {}
+    const T& value;
+};
+template <class T, type_id A> const type_id cref<T, A>::type = A;
+///@endcond INTERNAL
+
+/**
+ * Indicate the desired AMQP type to use when encoding T.
+ * For example to encode a vector as a list:
+ *
+ *     std::vector<amqp_int> v;
+ *     encoder << as<LIST>(v);
+ */
+template <type_id A, class T> cref<T, A> as(const T& value) { return cref<T, A>(value); }
 
 /**
  * Stream-like encoder from C++ values to AMQP values.
@@ -139,7 +159,9 @@ class encoder : public object<pn_data_t> {
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_symbol);
   friend PN_CPP_EXTERN encoder operator<<(encoder, amqp_binary);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const message_id&);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, const annotation_key&);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const value&);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, const scalar&);
     ///@}
 
     /**

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/error.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/error.hpp b/proton-c/bindings/cpp/include/proton/error.hpp
index d2f57c6..f3475cf 100644
--- a/proton-c/bindings/cpp/include/proton/error.hpp
+++ b/proton-c/bindings/cpp/include/proton/error.hpp
@@ -34,6 +34,12 @@ struct error : public std::runtime_error { PN_CPP_EXTERN explicit error(const st
 /** Raised if timeout expires */
 struct timeout_error : public error { PN_CPP_EXTERN explicit timeout_error(const std::string&); };
 
+/** Raised if there is an error decoding AMQP data as a C++ value. */
+struct decode_error : public error { PN_CPP_EXTERN explicit decode_error(const std::string&); };
+
+/** Raised if there is an error encoding a C++ value as AMQP data. */
+struct encode_error : public error { PN_CPP_EXTERN explicit encode_error(const std::string&); };
+
 }
 
 #endif  /*!PROTON_CPP_EXCEPTIONS_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index 52195aa..8bd1f85 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -22,9 +22,10 @@
  *
  */
 
-#include "proton/data.hpp"
 #include "proton/export.hpp"
 #include "proton/message_id.hpp"
+#include "proton/annotation_key.hpp"
+#include "proton/pn_unique_ptr.hpp"
 #include "proton/value.hpp"
 #include "proton/duration.hpp"
 
@@ -38,22 +39,28 @@ namespace proton {
 class link;
 class delivery;
 class message_id;
+class annotation_key;
 
 /** An AMQP message. Value semantics, can be copied or assigned to make a new message. */
 class message
 {
   public:
+    typedef std::map<std::string, scalar> property_map;
+    typedef std::map<annotation_key, value> annotation_map;
+
     PN_CPP_EXTERN message();
     PN_CPP_EXTERN message(const message&);
-    PN_CPP_EXTERN message(const value&);
-
 #if PN_HAS_CPP11
     PN_CPP_EXTERN message(message&&);
 #endif
+    /// Constructor that sets the body from any type that can be assigned to a value.
+    template <class T> explicit message(const T& body_) { body() = body_; }
+
     PN_CPP_EXTERN ~message();
+
     PN_CPP_EXTERN message& operator=(const message&);
 
-    void swap(message& x);
+    PN_CPP_EXTERN void swap(message& x);
 
     /** Clear the message content and properties. */
     PN_CPP_EXTERN void clear();
@@ -99,47 +106,28 @@ class message
 
     ///@}
 
-    /** Set the body. */
-    PN_CPP_EXTERN void body(const value&);
+    /** Set the body, equivalent to body() = v */
+    template<class T> void body(const T& v) { body() = v; }
 
-    /** Get the body. Note data can be copied to a proton::value */
-    PN_CPP_EXTERN const data body() const;
+    /** Get the body. */
+    PN_CPP_EXTERN const value& body() const;
 
-    /** Get a reference to the body data, can be modified in-place. */
-    PN_CPP_EXTERN data body();
+    /** Get a reference to the body that can be modified in-place. */
+    PN_CPP_EXTERN value& body();
 
-    /** Set the application properties. Must be a map with string keys or an
-     * empty value. You can assign to a proton::value from a standard C++ map
-     * of std::string to proton::value.
-     */
-    PN_CPP_EXTERN void properties(const value&);
+    /** Application properties map, can be modified in place. */
+    PN_CPP_EXTERN property_map& properties();
+    PN_CPP_EXTERN const property_map& properties() const;
 
-    /** Get the application properties, which will be a map with string keys or
-     * an empty value. You can assign proton::value containing a map to a
-     * standard C++ map of std::string to proton::value.
-     */
-    PN_CPP_EXTERN const data properties() const;
+    /** Message annotations map, can be modified in place. */
+    PN_CPP_EXTERN annotation_map& annotations();
+    PN_CPP_EXTERN const annotation_map& annotations() const;
 
-    /** Get a reference to the application properties, can be modified in-place.*/
-    PN_CPP_EXTERN data properties();
+    /** Delivery instructions map, can be modified in place. */
+    PN_CPP_EXTERN annotation_map& instructions();
+    PN_CPP_EXTERN const annotation_map& instructions() const;
 
-    /** Set an individual application property. */
-    PN_CPP_EXTERN void property(const std::string &name, const value &);
-
-    /** Get an individual application property. Returns an empty value if not found. */
-    PN_CPP_EXTERN value property(const std::string &name) const;
-
-    /** Erase an application property. Returns false if there was no such property. */
-    PN_CPP_EXTERN bool erase_property(const std::string &name);
-
-    PN_CPP_EXTERN void annotations(const value&);
-    PN_CPP_EXTERN const data annotations() const;
-    PN_CPP_EXTERN data annotations();
-    PN_CPP_EXTERN void annotation(const proton::amqp_symbol &key, const value &val);
-    PN_CPP_EXTERN value annotation(const proton::amqp_symbol &key) const;
-    PN_CPP_EXTERN bool erase_annotation(const proton::amqp_symbol &key);
-
-    /** Encode into a string, growing the string if necessary. */
+    /** Encode entire message into a string, growing the string if necessary. */
     PN_CPP_EXTERN void encode(std::string &bytes) const;
 
     /** Return encoded message as a string */
@@ -148,7 +136,7 @@ class message
     /** Decode from string data into the message. */
     PN_CPP_EXTERN void decode(const std::string &bytes);
 
-    /// Decode the message from link corresponding to delivery.
+    /** Decode the message corresponding to a delivery from a link. */
     PN_CPP_EXTERN void decode(proton::link, proton::delivery);
 
     /**
@@ -160,8 +148,6 @@ class message
      * and AMQP SEQUENCE sections, respectively. If inferred is false,
      * then all values in the body of the message will be encoded as AMQP
      * VALUE sections regardless of their type.
-     *
-     * @return the value of the inferred flag for the message
      */
     PN_CPP_EXTERN bool inferred() const;
     /** Get the inferred flag for a message. */
@@ -247,7 +233,16 @@ class message
     PN_CPP_EXTERN void sequence(int32_t);
 
   private:
-    pn_message_t *message_;
+    pn_message_t *pn_msg() const;
+    struct impl {
+        PN_CPP_EXTERN impl();
+        PN_CPP_EXTERN ~impl();
+        mutable pn_message_t *msg;
+        mutable value body;
+    } impl_;
+    mutable property_map properties_;
+    mutable annotation_map annotations_;
+    mutable annotation_map instructions_;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/message_id.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp
index 4734dff..b08482f 100644
--- a/proton-c/bindings/cpp/include/proton/message_id.hpp
+++ b/proton-c/bindings/cpp/include/proton/message_id.hpp
@@ -20,63 +20,44 @@
  */
 
 #include "proton/types.hpp"
-#include "proton/value.hpp"
+#include "proton/scalar.hpp"
 
 namespace proton {
+class encoder;
+class decoder;
+
 /** A message_id can contain one of the following types:
- * uint64_t (aka amqp_ulong), amqp_uuid, amqp_binary or amqp_string.
+ * uint64_t, amqp_uuid, amqp_binary or amqp_string.
  */
-class message_id : public comparable<message_id> {
+class message_id : public restricted_scalar {
   public:
-    message_id() {}
-    message_id(const message_id& x) : value_(x.value_) {}
-    message_id(const uint64_t& x) : value_(x) {}
-    message_id(const amqp_uuid& x) : value_(x) {}
-    message_id(const amqp_binary& x) : value_(x) {}
-    message_id(const amqp_string& x) : value_(x) {}
-    /// string is encoded as amqp_string
-    message_id(const std::string& x) : value_(x) {}
-    message_id(const char *x) : value_(x) {}
+    message_id() { scalar_ = uint64_t(0); }
 
-    message_id& operator=(const message_id& x) { value_ = x.value_; return *this; }
-    message_id& operator=(const uint64_t& x) { value_ = x; return *this; }
-    message_id& operator=(const amqp_uuid& x) { value_ = x; return *this; }
-    message_id& operator=(const amqp_binary& x) { value_ = x; return *this; }
-    message_id& operator=(const amqp_string& x) { value_ = x; return *this; }
-    /// string is encoded as amqp_string
-    message_id& operator=(const std::string& x) { value_ = x; return *this; }
-    message_id& operator=(const char *x) { value_ = x; return *this; }
+    ///@name Assign a C++ value, deduce the AMQP type()
+    ///@{
+    message_id& operator=(uint64_t x) { scalar_ = x; return *this; }
+    message_id& operator=(const amqp_uuid& x) { scalar_ = x; return *this; }
+    message_id& operator=(const amqp_binary& x) { scalar_ = x; return *this; }
+    message_id& operator=(const amqp_string& x) { scalar_ = x; return *this; }
+    /// std::string is encoded as amqp_string
+    message_id& operator=(const std::string& x) { scalar_ = amqp_string(x); return *this; }
+    /// char* is encoded as amqp_string
+    message_id& operator=(const char *x) { scalar_ = amqp_string(x); return *this; }
+    ///@}
 
-    void clear() { value_.clear(); }
-    bool empty() const { return value_.empty(); }
-    type_id type() { return value_.type(); }
+    /// Converting constructor from any type that we can assign from.
+    template <class T> message_id(T x) { *this = x; }
 
-    void get(uint64_t& x) const { value_.get(x); }
-    void get(amqp_uuid& x) const { value_.get(x); }
-    void get(amqp_binary& x) const { value_.get(x); }
-    void get(amqp_string& x) const { value_.get(x); }
-    /// Both amqp_binary and amqp_string can be converted to std::string
-    void get(std::string& x) const { value_.get(x); }
+    void get(uint64_t& x) const { scalar_.get(x); }
+    void get(amqp_uuid& x) const { scalar_.get(x); }
+    void get(amqp_binary& x) const { scalar_.get(x); }
+    void get(amqp_string& x) const { scalar_.get(x); }
 
     template<class T> T get() const { T x; get(x); return x; }
 
-    // String representation: decimal representation of uint64_t, standard text
-    // representation of UUID, amqp_string or amqp_binary are returned without
-    // modification.
-    std::string& str() const;
-
-    bool operator==(const message_id& x) const { return value_ == x.value_; }
-    bool operator<(const message_id& x) const { return value_ < x.value_; }
-
-  friend std::ostream& operator<<(std::ostream&, const message_id&);
   friend PN_CPP_EXTERN encoder operator<<(encoder, const message_id&);
   friend PN_CPP_EXTERN decoder operator>>(decoder, message_id&);
-
-  private:
-    //message_id(const data d) : value_(d) {}
-    value value_;
   friend class message;
-  friend class data;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index 0745281..6fe29fa 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -21,54 +21,56 @@
 
 #include "proton/types.hpp"
 #include <iosfwd>
+#include <string>
 
 namespace proton {
 
-class scalar;
+class encoder;
+class decoder;
 
-/** scalar holds an instance of an atomic proton type. */
+/** scalar holds an instance of any scalar AMQP type. */
 class scalar : public comparable<scalar> {
   public:
     PN_CPP_EXTERN scalar();
-    // Use default assign and copy.
+    PN_CPP_EXTERN scalar(const scalar&);
+    PN_CPP_EXTERN scalar& operator=(const scalar&);
 
     /// Type for the value in the scalar, NULL_TYPE if empty()
     PN_CPP_EXTERN type_id type() const;
+
     /// True if the scalar is empty.
     PN_CPP_EXTERN bool empty() const;
 
-    ///@name Create an scalar, type() is deduced from the C++ type of the value.
+    ///@name Assign a C++ value, deduce the AMQP type()
     ///@{
-    PN_CPP_EXTERN explicit scalar(bool);
-    PN_CPP_EXTERN explicit scalar(uint8_t);
-    PN_CPP_EXTERN explicit scalar(int8_t);
-    PN_CPP_EXTERN explicit scalar(uint16_t);
-    PN_CPP_EXTERN explicit scalar(int16_t);
-    PN_CPP_EXTERN explicit scalar(uint32_t);
-    PN_CPP_EXTERN explicit scalar(int32_t);
-    PN_CPP_EXTERN explicit scalar(uint64_t);
-    PN_CPP_EXTERN explicit scalar(int64_t);
-    PN_CPP_EXTERN explicit scalar(wchar_t);
-    PN_CPP_EXTERN explicit scalar(float);
-    PN_CPP_EXTERN explicit scalar(double);
-    PN_CPP_EXTERN explicit scalar(amqp_timestamp);
-    PN_CPP_EXTERN explicit scalar(const amqp_decimal32&);
-    PN_CPP_EXTERN explicit scalar(const amqp_decimal64&);
-    PN_CPP_EXTERN explicit scalar(const amqp_decimal128&);
-    PN_CPP_EXTERN explicit scalar(const amqp_uuid&);
-    PN_CPP_EXTERN explicit scalar(const amqp_string&);
-    PN_CPP_EXTERN explicit scalar(const amqp_symbol&);
-    PN_CPP_EXTERN explicit scalar(const amqp_binary&);
-    PN_CPP_EXTERN explicit scalar(const std::string& s); ///< Treated as an AMQP string
-    PN_CPP_EXTERN explicit scalar(const char* s);        ///< Treated as an AMQP string
+    PN_CPP_EXTERN scalar& operator=(bool);
+    PN_CPP_EXTERN scalar& operator=(uint8_t);
+    PN_CPP_EXTERN scalar& operator=(int8_t);
+    PN_CPP_EXTERN scalar& operator=(uint16_t);
+    PN_CPP_EXTERN scalar& operator=(int16_t);
+    PN_CPP_EXTERN scalar& operator=(uint32_t);
+    PN_CPP_EXTERN scalar& operator=(int32_t);
+    PN_CPP_EXTERN scalar& operator=(uint64_t);
+    PN_CPP_EXTERN scalar& operator=(int64_t);
+    PN_CPP_EXTERN scalar& operator=(wchar_t);
+    PN_CPP_EXTERN scalar& operator=(float);
+    PN_CPP_EXTERN scalar& operator=(double);
+    PN_CPP_EXTERN scalar& operator=(amqp_timestamp);
+    PN_CPP_EXTERN scalar& operator=(const amqp_decimal32&);
+    PN_CPP_EXTERN scalar& operator=(const amqp_decimal64&);
+    PN_CPP_EXTERN scalar& operator=(const amqp_decimal128&);
+    PN_CPP_EXTERN scalar& operator=(const amqp_uuid&);
+    PN_CPP_EXTERN scalar& operator=(const amqp_string&);
+    PN_CPP_EXTERN scalar& operator=(const amqp_symbol&);
+    PN_CPP_EXTERN scalar& operator=(const amqp_binary&);
+    PN_CPP_EXTERN scalar& operator=(const std::string& s); ///< Treated as an AMQP string
+    PN_CPP_EXTERN scalar& operator=(const char* s);        ///< Treated as an AMQP string
     ///@}
 
-    /// Assign to an scalar using the same rules as construction.
-    template <class T> scalar& operator=(T x) { return *this = scalar(x); }
+    /// Construct from any type that we can assign from.
+    template <class T> explicit scalar(T x) { *this = x; }
 
-    ///@name get(T&) extracts the value if the types match exactly,
-    ///i.e. if `type() == type_id_of<T>::value`
-    /// throws type_mismatch otherwise.
+    ///@name get(T&) extracts the value if the types match exactly, throws type_error otherwise.
     ///@{
     PN_CPP_EXTERN void get(bool&) const;
     PN_CPP_EXTERN void get(uint8_t&) const;
@@ -97,25 +99,58 @@ class scalar : public comparable<scalar> {
     template<class T> T get() const { T x; get(x); return x; }
 
     ///@name as_ methods do "loose" conversion, they will convert the scalar's
-    ///value to the requested type if possible, else throw type_mismatch
+    ///value to the requested type if possible, else throw type_error
     ///@{
-    PN_CPP_EXTERN int64_t as_int() const;     ///< Allowed if type_id_integral(type())
-    PN_CPP_EXTERN uint64_t as_uint() const;   ///< Allowed if type_id_integral(type())
-    PN_CPP_EXTERN double as_double() const;    ///< Allowed if type_id_floating_point(type())
-    PN_CPP_EXTERN std::string as_string() const; ///< Allowed if type_id_string_like(type())
+    PN_CPP_EXTERN int64_t as_int() const;     ///< Allowed if type_id_is_integral(type())
+    PN_CPP_EXTERN uint64_t as_uint() const;   ///< Allowed if type_id_is_integral(type())
+    PN_CPP_EXTERN double as_double() const;    ///< Allowed if type_id_is_floating_point(type())
+    PN_CPP_EXTERN std::string as_string() const; ///< Allowed if type_id_is_string_like(type())
     ///@}
 
-    PN_CPP_EXTERN bool operator==(const scalar& x) const;
-    /// Note if the values are of different type(), operator< will compare the type()
-    PN_CPP_EXTERN bool operator<(const scalar& x) const;
+  friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const scalar&);
+  friend PN_CPP_EXTERN encoder operator<<(encoder, const scalar&);
+  friend PN_CPP_EXTERN decoder operator>>(decoder, scalar&);
+
 
-  PN_CPP_EXTERN friend std::ostream& operator<<(std::ostream&, const scalar&);
+    /// Scalars with different type() are considered unequal even if the values
+    /// are equal as numbers or strings.
+  friend PN_CPP_EXTERN bool operator==(const scalar& x, const scalar& y);
+
+    /// For scalars of different type(), operator< sorts by order of type().
+  friend PN_CPP_EXTERN bool operator<(const scalar& x, const scalar& y);
 
   private:
     void ok(pn_type_t) const;
-    void set(const std::string&);
+    void set(const std::string&, pn_type_t);
+    void set(const pn_atom_t&);
     pn_atom_t atom_;
     std::string str_;           // Owner of string-like data.
+
+  friend class message;
+};
+
+///@internal base for restricted scalar types
+class restricted_scalar : public comparable<restricted_scalar> {
+  public:
+    operator scalar() const { return scalar_; }
+    type_id type() const { return scalar_.type(); }
+
+    ///@name as_ methods do "loose" conversion, they will convert the scalar's
+    ///value to the requested type if possible, else throw type_error
+    ///@{
+    int64_t as_int() const { return scalar_.as_int(); }
+    uint64_t as_uint() const { return scalar_.as_uint(); }
+    double as_double() const { return scalar_.as_double();  }
+    std::string as_string() const { return scalar_.as_string(); }
+    ///@}
+
+  friend std::ostream& operator<<(std::ostream& o, const restricted_scalar& x)  { return o << x.scalar_; }
+  friend bool operator<(const restricted_scalar& x, const restricted_scalar& y)  { return x.scalar_ < y.scalar_; }
+  friend bool operator==(const restricted_scalar& x, const restricted_scalar& y)  { return x.scalar_ == y.scalar_; }
+
+  protected:
+    restricted_scalar() {}
+    scalar scalar_;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index b3757dc..0518dc6 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -79,7 +79,7 @@ class ssl_domain {
   public:
     PN_CPP_EXTERN ssl_domain(const ssl_domain&);
     PN_CPP_EXTERN ssl_domain& operator=(const ssl_domain&);
-    ~ssl_domain();
+    PN_CPP_EXTERN ~ssl_domain();
 
   protected:
     ssl_domain(bool is_server);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/type_traits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/type_traits.hpp b/proton-c/bindings/cpp/include/proton/type_traits.hpp
index 494f7db..8f502a3 100644
--- a/proton-c/bindings/cpp/include/proton/type_traits.hpp
+++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp
@@ -76,7 +76,7 @@ template <class T> struct is_same<T,T> { static const bool value=true; };
 template< class T > struct remove_const          { typedef T type; };
 template< class T > struct remove_const<const T> { typedef T type; };
 
-// Metafunction returning AMQP type for atomic C++ types
+// Metafunction returning AMQP type for scalar C++ types
 template <class T, class Enable=void> struct type_id_of;
 template<> struct type_id_of<amqp_null> { static const type_id value=NULL_TYPE; };
 template<> struct type_id_of<amqp_boolean> { static const type_id value=BOOLEAN; };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index 645d9da..db5989b 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -67,12 +67,26 @@ enum type_id {
     MAP=PN_MAP                  ///< A sequence of key:value pairs, may be of mixed types.
 };
 
+/// Name of the AMQP type
+PN_CPP_EXTERN std::string type_name(type_id);
+
+/// Print the type_name
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
+
 /// Raised when there is a type mismatch, with the expected and actual type ID.
-struct type_mismatch : public error {
-    PN_CPP_EXTERN explicit type_mismatch(type_id want, type_id got, const std::string& =std::string());
+struct type_error : public decode_error {
+    PN_CPP_EXTERN explicit type_error(type_id want, type_id got, const std::string& =std::string());
     type_id want; ///< Expected type_id
     type_id got;  ///< Actual type_id
 };
+ 
+
+///@cond INTERNAL
+/// Provide a full set of comparison operators for proton:: types that have < and ==.
+template <class T> bool operator>(const T &a, const T &b) { return b < a; }
+template <class T> bool operator<=(const T &a, const T &b) { return !(a > b); }
+template <class T> bool operator>=(const T &a, const T &b) { return !(a < b); }
+template <class T> bool operator!=(const T &a, const T &b) { return !(a == b); }
 
 PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
 PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
@@ -107,26 +121,23 @@ typedef double amqp_double;
 
 /// AMQP UTF-8 encoded string.
 struct amqp_string : public std::string {
-    amqp_string(const std::string& s=std::string()) : std::string(s) {}
-    amqp_string(const char* s) : std::string(s) {}
-    amqp_string(const pn_bytes_t& b) : std::string(b.start, b.size) {}
-    operator pn_bytes_t() const { return pn_bytes(*this); }
+    explicit amqp_string(const std::string& s=std::string()) : std::string(s) {}
+    explicit amqp_string(const char* s) : std::string(s) {}
+    explicit amqp_string(const pn_bytes_t& b) : std::string(b.start, b.size) {}
 };
 
 /// AMQP ASCII encoded symbolic name.
 struct amqp_symbol : public std::string {
-    amqp_symbol(const std::string& s=std::string()) : std::string(s) {}
-    amqp_symbol(const char* s) : std::string(s) {}
-    amqp_symbol(const pn_bytes_t& b) : std::string(b.start, b.size) {}
-    operator pn_bytes_t() const { return pn_bytes(*this); }
+    explicit amqp_symbol(const std::string& s=std::string()) : std::string(s) {}
+    explicit amqp_symbol(const char* s) : std::string(s) {}
+    explicit amqp_symbol(const pn_bytes_t& b) : std::string(b.start, b.size) {}
 };
 
 /// AMQP variable-length binary data.
 struct amqp_binary : public std::string {
-    amqp_binary(const std::string& s=std::string()) : std::string(s) {}
-    amqp_binary(const char* s) : std::string(s) {}
-    amqp_binary(const pn_bytes_t& b) : std::string(b.start, b.size) {}
-    operator pn_bytes_t() const { return pn_bytes(*this); }
+    explicit amqp_binary(const std::string& s=std::string()) : std::string(s) {}
+    explicit amqp_binary(const char* s) : std::string(s) {}
+    explicit amqp_binary(const pn_bytes_t& b) : std::string(b.start, b.size) {}
 };
 
 /// Template for opaque proton proton types that can be treated as byte arrays.
@@ -170,40 +181,28 @@ struct amqp_timestamp : public comparable<amqp_timestamp> {
 };
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_timestamp&);
 
-///@cond INTERNAL
-template<class T, type_id A> struct cref {
-    typedef T cpp_type;
-    static const type_id type;
-
-    cref(const T& v) : value(v) {}
-    const T& value;
-};
-template <class T, type_id A> const type_id cref<T, A>::type = A;
-///@endcond INTERNAL
-
-/**
- * Indicate the desired AMQP type to use when encoding T.
- * For example to encode a vector as a list:
- *
- *     std::vector<amqp_int> v;
- *     encoder << as<LIST>(v);
- */
-template <type_id A, class T> cref<T, A> as(const T& value) { return cref<T, A>(value); }
-
 // TODO aconway 2015-06-16: described types.
 
-/// Name of the AMQP type
-PN_CPP_EXTERN std::string type_name(type_id);
-
 ///@name Attributes of a type_id value, returns same result as the
 /// corresponding std::type_traits tests for the corresponding C++ types.
 ///@{
+/// Any scalar type
 PN_CPP_EXTERN bool type_id_is_scalar(type_id);
+/// One of the signed integer types: BYTE, SHORT, INT or LONG
+PN_CPP_EXTERN bool type_id_is_signed_int(type_id);
+/// One of the unsigned integer types: UBYTE, USHORT, UINT or ULONG
+PN_CPP_EXTERN bool type_id_is_unsigned_int(type_id);
+/// Any of the signed or unsigned integers, BOOL, CHAR or TIMESTAMP.
 PN_CPP_EXTERN bool type_id_is_integral(type_id);
-PN_CPP_EXTERN bool type_id_is_signed(type_id); ///< CHAR and BOOL are not signed.
+/// A floating point type, float or double
 PN_CPP_EXTERN bool type_id_is_floating_point(type_id);
+/// Any signed integer, float or double. BOOL, CHAR and TIMESTAMP are not signed.
+PN_CPP_EXTERN bool type_id_is_signed(type_id);
+/// Any DECIMAL type.
 PN_CPP_EXTERN bool type_id_is_decimal(type_id);
-PN_CPP_EXTERN bool type_id_is_string_like(type_id);   ///< STRING, SYMBOL, BINARY
+/// STRING, SYMBOL or BINARY
+PN_CPP_EXTERN bool type_id_is_string_like(type_id);
+/// Container types: MAP, LIST, ARRAY or DESCRIBED.
 PN_CPP_EXTERN bool type_id_is_container(type_id);
 ///@}
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index c33eea1..dedcadd 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -43,9 +43,10 @@ class decoder;
 class value : public comparable<value> {
   public:
     PN_CPP_EXTERN value();
-    PN_CPP_EXTERN value(const value& x);
-    // TODO: Should enumerate specifically all the pointer types that can convert to value
-    // to avoid accidental conversions to bool this will require enable_if<> or the like
+    PN_CPP_EXTERN value(const value&);
+#if PN_HAS_CPP11
+    PN_CPP_EXTERN value(value&&);
+#endif
     template <class T> value(const T& x) : data_(data::create()) { data_.copy(x); }
 
     PN_CPP_EXTERN value& operator=(const value& x);
@@ -65,18 +66,27 @@ class value : public comparable<value> {
 
     /** Get the value. */
     template<class T> void get(T &t) const { decoder() >> t; }
+    template<class T> void get(map_ref<T> t) const { decoder() >> t; }
+    template<class T> void get(pairs_ref<T> t) const { decoder() >> t; }
+    template<class T> void get(sequence_ref<T> t) const { decoder() >> t; }
 
     /** Get the value. */
     template<class T> T get() const { T t; get(t); return t; }
 
+    // FIXME aconway 2015-12-28: friend ops.
     PN_CPP_EXTERN bool operator==(const value& x) const;
     PN_CPP_EXTERN bool operator<(const value& x) const;
 
+    PN_CPP_EXTERN void swap(value& v);
+
   friend PN_CPP_EXTERN class encoder operator<<(class encoder e, const value& dv);
   friend PN_CPP_EXTERN class decoder operator>>(class decoder d, value& dv);
   friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream& o, const value& dv);
 
   private:
+    value(data d);
+    value& ref(data d);
+
     data data_;
   friend class message;
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index 20d0461..4639683 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -21,6 +21,7 @@
 #include "proton/decoder.hpp"
 #include "proton/value.hpp"
 #include "proton/message_id.hpp"
+#include "proton/annotation_key.hpp"
 #include "proton_bits.hpp"
 #include "msg.hpp"
 
@@ -34,8 +35,6 @@ namespace proton {
  * to be returned by the decoder.
  *
  */
-decode_error::decode_error(const std::string& msg) : error("decode: "+msg) {}
-
 namespace {
 struct save_state {
     pn_data_t* data;
@@ -87,8 +86,7 @@ data decoder::data() { return proton::data(pn_object()); }
 namespace {
 
 void bad_type(type_id want, type_id got) {
-    if (want != got)
-        throw decode_error("expected "+type_name(want)+" found "+type_name(got));
+    if (want != got) throw type_error(want, got);
 }
 
 type_id pre_get(pn_data_t* data) {
@@ -99,10 +97,10 @@ type_id pre_get(pn_data_t* data) {
 }
 
 // Simple extract with no type conversion.
-template <class T, class U> void extract(pn_data_t* data, T& value, U (*get)(pn_data_t*)) {
+template <class T, class U> void extract(pn_data_t* data, T& x, U (*get)(pn_data_t*)) {
     save_state ss(data);
     bad_type(type_id_of<T>::value, pre_get(data));
-    value = T(get(data));
+    x = T(get(data));
     ss.cancel();                // No error, no rewind
 }
 
@@ -165,191 +163,211 @@ decoder operator>>(decoder d, value& v) {
     return d;
 }
 
-decoder operator>>(decoder d, message_id& id) {
+decoder operator>>(decoder d, message_id& x) {
     switch (d.type()) {
       case ULONG:
       case UUID:
       case BINARY:
       case STRING:
-        return d >> id.value_;
+        return d >> x.scalar_;
       default:
         throw decode_error("expected one of ulong, uuid, binary or string but found " +
                            type_name(d.type()));
     };
 }
 
+decoder operator>>(decoder d, annotation_key& x) {
+    switch (d.type()) {
+      case ULONG:
+      case SYMBOL:
+        return d >> x.scalar_;
+      default:
+        throw decode_error("expected one of ulong or symbol but found " + type_name(d.type()));
+    };
+}
+
 decoder operator>>(decoder d, amqp_null) {
     save_state ss(d.pn_object());
     bad_type(NULL_TYPE, pre_get(d.pn_object()));
     return d;
 }
 
-decoder operator>>(decoder d, amqp_boolean& value) {
-    extract(d.pn_object(), value, pn_data_get_bool);
+decoder operator>>(decoder d, scalar& x) {
+    save_state ss(d.pn_object());
+    type_id got = pre_get(d.pn_object());
+    if (!type_id_is_scalar(got))
+        throw decode_error("expected scalar, found "+type_name(got));
+    x.set(pn_data_get_atom(d.pn_object()));
+    ss.cancel();                // No error, no rewind
+    return d;
+}
+
+decoder operator>>(decoder d, amqp_boolean &x) {
+    extract(d.pn_object(), x, pn_data_get_bool);
     return d;
 }
 
-decoder operator>>(decoder d0, amqp_ubyte& value) {
+decoder operator>>(decoder d0, amqp_ubyte &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case UBYTE: value = pn_data_get_ubyte(d); break;
+      case UBYTE: x = pn_data_get_ubyte(d); break;
       default: bad_type(UBYTE, type_id(type_id(pn_data_type(d))));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_byte& value) {
+decoder operator>>(decoder d0, amqp_byte &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case BYTE: value = pn_data_get_byte(d); break;
+      case BYTE: x = pn_data_get_byte(d); break;
       default: bad_type(BYTE, type_id(type_id(pn_data_type(d))));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_ushort& value) {
+decoder operator>>(decoder d0, amqp_ushort &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case UBYTE: value = pn_data_get_ubyte(d); break;
-      case USHORT: value = pn_data_get_ushort(d); break;
+      case UBYTE: x = pn_data_get_ubyte(d); break;
+      case USHORT: x = pn_data_get_ushort(d); break;
       default: bad_type(USHORT, type_id(type_id(pn_data_type(d))));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_short& value) {
+decoder operator>>(decoder d0, amqp_short &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case BYTE: value = pn_data_get_byte(d); break;
-      case SHORT: value = pn_data_get_short(d); break;
+      case BYTE: x = pn_data_get_byte(d); break;
+      case SHORT: x = pn_data_get_short(d); break;
       default: bad_type(SHORT, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_uint& value) {
+decoder operator>>(decoder d0, amqp_uint &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case UBYTE: value = pn_data_get_ubyte(d); break;
-      case USHORT: value = pn_data_get_ushort(d); break;
-      case UINT: value = pn_data_get_uint(d); break;
+      case UBYTE: x = pn_data_get_ubyte(d); break;
+      case USHORT: x = pn_data_get_ushort(d); break;
+      case UINT: x = pn_data_get_uint(d); break;
       default: bad_type(UINT, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_int& value) {
+decoder operator>>(decoder d0, amqp_int &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case BYTE: value = pn_data_get_byte(d); break;
-      case SHORT: value = pn_data_get_short(d); break;
-      case INT: value = pn_data_get_int(d); break;
+      case BYTE: x = pn_data_get_byte(d); break;
+      case SHORT: x = pn_data_get_short(d); break;
+      case INT: x = pn_data_get_int(d); break;
       default: bad_type(INT, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_ulong& value) {
+decoder operator>>(decoder d0, amqp_ulong &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case UBYTE: value = pn_data_get_ubyte(d); break;
-      case USHORT: value = pn_data_get_ushort(d); break;
-      case UINT: value = pn_data_get_uint(d); break;
-      case ULONG: value = pn_data_get_ulong(d); break;
+      case UBYTE: x = pn_data_get_ubyte(d); break;
+      case USHORT: x = pn_data_get_ushort(d); break;
+      case UINT: x = pn_data_get_uint(d); break;
+      case ULONG: x = pn_data_get_ulong(d); break;
       default: bad_type(ULONG, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_long& value) {
+decoder operator>>(decoder d0, amqp_long &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case BYTE: value = pn_data_get_byte(d); break;
-      case SHORT: value = pn_data_get_short(d); break;
-      case INT: value = pn_data_get_int(d); break;
-      case LONG: value = pn_data_get_long(d); break;
+      case BYTE: x = pn_data_get_byte(d); break;
+      case SHORT: x = pn_data_get_short(d); break;
+      case INT: x = pn_data_get_int(d); break;
+      case LONG: x = pn_data_get_long(d); break;
       default: bad_type(LONG, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d, amqp_char& value) {
-    extract(d.pn_object(), value, pn_data_get_char);
+decoder operator>>(decoder d, amqp_char &x) {
+    extract(d.pn_object(), x, pn_data_get_char);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_timestamp& value) {
-    extract(d.pn_object(), value, pn_data_get_timestamp);
+decoder operator>>(decoder d, amqp_timestamp &x) {
+    extract(d.pn_object(), x, pn_data_get_timestamp);
     return d;
 }
 
-decoder operator>>(decoder d0, amqp_float& value) {
+decoder operator>>(decoder d0, amqp_float &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case FLOAT: value = pn_data_get_float(d); break;
-      case DOUBLE: value = float(pn_data_get_double(d)); break;
+      case FLOAT: x = pn_data_get_float(d); break;
+      case DOUBLE: x = float(pn_data_get_double(d)); break;
       default: bad_type(FLOAT, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d0, amqp_double& value) {
+decoder operator>>(decoder d0, amqp_double &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case FLOAT: value = pn_data_get_float(d); break;
-      case DOUBLE: value = pn_data_get_double(d); break;
+      case FLOAT: x = pn_data_get_float(d); break;
+      case DOUBLE: x = pn_data_get_double(d); break;
       default: bad_type(DOUBLE, type_id(pn_data_type(d)));
     }
     ss.cancel();
     return d0;
 }
 
-decoder operator>>(decoder d, amqp_decimal32& value) {
-    extract(d.pn_object(), value, pn_data_get_decimal32);
+decoder operator>>(decoder d, amqp_decimal32 &x) {
+    extract(d.pn_object(), x, pn_data_get_decimal32);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_decimal64& value) {
-    extract(d.pn_object(), value, pn_data_get_decimal64);
+decoder operator>>(decoder d, amqp_decimal64 &x) {
+    extract(d.pn_object(), x, pn_data_get_decimal64);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_decimal128& value)  {
-    extract(d.pn_object(), value, pn_data_get_decimal128);
+decoder operator>>(decoder d, amqp_decimal128 &x)  {
+    extract(d.pn_object(), x, pn_data_get_decimal128);
     return d;
 }
 
-decoder operator>>(decoder d, amqp_uuid& value)  {
-    extract(d.pn_object(), value, pn_data_get_uuid);
+decoder operator>>(decoder d, amqp_uuid &x)  {
+    extract(d.pn_object(), x, pn_data_get_uuid);
     return d;
 }
 
-decoder operator>>(decoder d0, std::string& value) {
+decoder operator>>(decoder d0, std::string &x) {
     pn_data_t* d = d0.pn_object();
     save_state ss(d);
     switch (pre_get(d)) {
-      case STRING: value = str(pn_data_get_string(d)); break;
-      case BINARY: value = str(pn_data_get_binary(d)); break;
-      case SYMBOL: value = str(pn_data_get_symbol(d)); break;
+      case STRING: x = str(pn_data_get_string(d)); break;
+      case BINARY: x = str(pn_data_get_binary(d)); break;
+      case SYMBOL: x = str(pn_data_get_symbol(d)); break;
       default: bad_type(STRING, type_id(pn_data_type(d)));
     }
     ss.cancel();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/encode_decode_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encode_decode_test.cpp b/proton-c/bindings/cpp/src/encode_decode_test.cpp
index 3e15a58..8c285ac 100644
--- a/proton-c/bindings/cpp/src/encode_decode_test.cpp
+++ b/proton-c/bindings/cpp/src/encode_decode_test.cpp
@@ -48,31 +48,13 @@ template <class T> void value_test(T x, type_id tid, const std::string& s, T y)
     ASSERT(y > x);
 }
 
-void value_tests() {
-    value_test(false, BOOLEAN, "false", true);
-    value_test(amqp_ubyte(42), UBYTE, "42", amqp_ubyte(50));
-    value_test(amqp_byte(-42), BYTE, "-42", amqp_byte(-40));
-    value_test(amqp_ushort(4242), USHORT, "4242", amqp_ushort(5252));
-    value_test(amqp_short(-4242), SHORT, "-4242", amqp_short(3));
-    value_test(amqp_uint(4242), UINT, "4242", amqp_uint(5252));
-    value_test(amqp_int(-4242), INT, "-4242", amqp_int(3));
-    value_test(amqp_ulong(4242), ULONG, "4242", amqp_ulong(5252));
-    value_test(amqp_long(-4242), LONG, "-4242", amqp_long(3));
-    value_test(amqp_float(1.234), FLOAT, "1.234", amqp_float(2.345));
-    value_test(amqp_double(11.2233), DOUBLE, "11.2233", amqp_double(12));
-    value_test(amqp_string("aaa"), STRING, "aaa", amqp_string("aaaa"));
-    value_test(std::string("xxx"), STRING, "xxx", std::string("yyy"));
-    value_test(amqp_symbol("aaa"), SYMBOL, "aaa", amqp_symbol("aaaa"));
-    value_test(amqp_binary("aaa"), BINARY, "b\"aaa\"", amqp_binary("aaaa"));
-}
-
 // Map values
 void map_test() {
     std::map<string, int> m;
     m["a"] = 1;
     m["b"] = 2;
     m["c"] = 3;
-    proton::value v = m;
+    value v = m;
     ASSERT_EQUAL("{\"a\"=1, \"b\"=2, \"c\"=3}",  str(v));
     std::map<value, value> mv;
     v.get(mv);
@@ -81,8 +63,9 @@ void map_test() {
     mv.erase("c");
     v = value(mv);
     ASSERT_EQUAL("{\"a\"=1, \"b\"=b\"xyz\"}",  str(v));
+
     std::vector<std::pair<string, value> > vec;
-    v.decoder() >> to_pairs(vec);       // FIXME aconway 2015-11-17: get doesn't work with pairs.
+    v.get(to_pairs(vec));
     ASSERT_EQUAL(2, vec.size());
     ASSERT_EQUAL(std::make_pair(std::string("a"), value(1)), vec[0]);
     ASSERT_EQUAL(std::make_pair(std::string("b"), value(amqp_binary("xyz"))), vec[1]);
@@ -90,7 +73,21 @@ void map_test() {
 
 int main(int, char**) {
     int failed = 0;
+    RUN_TEST(failed, value_test(false, BOOLEAN, "false", true));
+    RUN_TEST(failed, value_test(amqp_ubyte(42), UBYTE, "42", amqp_ubyte(50)));
+    RUN_TEST(failed, value_test(amqp_byte(-42), BYTE, "-42", amqp_byte(-40)));
+    RUN_TEST(failed, value_test(amqp_ushort(4242), USHORT, "4242", amqp_ushort(5252)));
+    RUN_TEST(failed, value_test(amqp_short(-4242), SHORT, "-4242", amqp_short(3)));
+    RUN_TEST(failed, value_test(amqp_uint(4242), UINT, "4242", amqp_uint(5252)));
+    RUN_TEST(failed, value_test(amqp_int(-4242), INT, "-4242", amqp_int(3)));
+    RUN_TEST(failed, value_test(amqp_ulong(4242), ULONG, "4242", amqp_ulong(5252)));
+    RUN_TEST(failed, value_test(amqp_long(-4242), LONG, "-4242", amqp_long(3)));
+    RUN_TEST(failed, value_test(amqp_float(1.234), FLOAT, "1.234", amqp_float(2.345)));
+    RUN_TEST(failed, value_test(amqp_double(11.2233), DOUBLE, "11.2233", amqp_double(12)));
+    RUN_TEST(failed, value_test(amqp_string("aaa"), STRING, "aaa", amqp_string("aaaa")));
+    RUN_TEST(failed, value_test(std::string("xxx"), STRING, "xxx", std::string("yyy")));
+    RUN_TEST(failed, value_test(amqp_symbol("aaa"), SYMBOL, "aaa", amqp_symbol("aaaa")));
+    RUN_TEST(failed, value_test(amqp_binary("aaa"), BINARY, "b\"aaa\"", amqp_binary("aaaa")));
     RUN_TEST(failed, map_test());
-    RUN_TEST(failed, value_tests());
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index 327426a..109b290 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -20,6 +20,7 @@
 #include "proton/data.hpp"
 #include "proton/encoder.hpp"
 #include "proton/message_id.hpp"
+#include "proton/annotation_key.hpp"
 #include "proton/value.hpp"
 
 #include "proton_bits.hpp"
@@ -100,35 +101,39 @@ encoder operator<<(encoder e, finish) {
 
 namespace {
 template <class T, class U>
-encoder insert(encoder e, pn_data_t* data, T& value, int (*put)(pn_data_t*, U)) {
+encoder insert(encoder e, pn_data_t* data, T& x, int (*put)(pn_data_t*, U)) {
     save_state ss(data);         // Save state in case of error.
-    check(put(data, value), data);
+    check(put(data, x), data);
     ss.cancel();                // Don't restore state, all is good.
     return e;
 }
+
+int pn_data_put_amqp_string(pn_data_t *d, const amqp_string& x) { return pn_data_put_string(d, pn_bytes(x)); }
+int pn_data_put_amqp_binary(pn_data_t *d, const amqp_binary& x) { return pn_data_put_binary(d, pn_bytes(x)); }
+int pn_data_put_amqp_symbol(pn_data_t *d, const amqp_symbol& x) { return pn_data_put_symbol(d, pn_bytes(x)); }
 }
 
 encoder operator<<(encoder e, amqp_null) { pn_data_put_null(e.pn_object()); return e; }
-encoder operator<<(encoder e, amqp_boolean value) { return insert(e, e.pn_object(), value, pn_data_put_bool); }
-encoder operator<<(encoder e, amqp_ubyte value) { return insert(e, e.pn_object(), value, pn_data_put_ubyte); }
-encoder operator<<(encoder e, amqp_byte value) { return insert(e, e.pn_object(), value, pn_data_put_byte); }
-encoder operator<<(encoder e, amqp_ushort value) { return insert(e, e.pn_object(), value, pn_data_put_ushort); }
-encoder operator<<(encoder e, amqp_short value) { return insert(e, e.pn_object(), value, pn_data_put_short); }
-encoder operator<<(encoder e, amqp_uint value) { return insert(e, e.pn_object(), value, pn_data_put_uint); }
-encoder operator<<(encoder e, amqp_int value) { return insert(e, e.pn_object(), value, pn_data_put_int); }
-encoder operator<<(encoder e, amqp_char value) { return insert(e, e.pn_object(), value, pn_data_put_char); }
-encoder operator<<(encoder e, amqp_ulong value) { return insert(e, e.pn_object(), value, pn_data_put_ulong); }
-encoder operator<<(encoder e, amqp_long value) { return insert(e, e.pn_object(), value, pn_data_put_long); }
-encoder operator<<(encoder e, amqp_timestamp value) { return insert(e, e.pn_object(), value, pn_data_put_timestamp); }
-encoder operator<<(encoder e, amqp_float value) { return insert(e, e.pn_object(), value, pn_data_put_float); }
-encoder operator<<(encoder e, amqp_double value) { return insert(e, e.pn_object(), value, pn_data_put_double); }
-encoder operator<<(encoder e, amqp_decimal32 value) { return insert(e, e.pn_object(), value, pn_data_put_decimal32); }
-encoder operator<<(encoder e, amqp_decimal64 value) { return insert(e, e.pn_object(), value, pn_data_put_decimal64); }
-encoder operator<<(encoder e, amqp_decimal128 value) { return insert(e, e.pn_object(), value, pn_data_put_decimal128); }
-encoder operator<<(encoder e, amqp_uuid value) { return insert(e, e.pn_object(), value, pn_data_put_uuid); }
-encoder operator<<(encoder e, amqp_string value) { return insert(e, e.pn_object(), value, pn_data_put_string); }
-encoder operator<<(encoder e, amqp_symbol value) { return insert(e, e.pn_object(), value, pn_data_put_symbol); }
-encoder operator<<(encoder e, amqp_binary value) { return insert(e, e.pn_object(), value, pn_data_put_binary); }
+encoder operator<<(encoder e, amqp_boolean x) { return insert(e, e.pn_object(), x, pn_data_put_bool); }
+encoder operator<<(encoder e, amqp_ubyte x) { return insert(e, e.pn_object(), x, pn_data_put_ubyte); }
+encoder operator<<(encoder e, amqp_byte x) { return insert(e, e.pn_object(), x, pn_data_put_byte); }
+encoder operator<<(encoder e, amqp_ushort x) { return insert(e, e.pn_object(), x, pn_data_put_ushort); }
+encoder operator<<(encoder e, amqp_short x) { return insert(e, e.pn_object(), x, pn_data_put_short); }
+encoder operator<<(encoder e, amqp_uint x) { return insert(e, e.pn_object(), x, pn_data_put_uint); }
+encoder operator<<(encoder e, amqp_int x) { return insert(e, e.pn_object(), x, pn_data_put_int); }
+encoder operator<<(encoder e, amqp_char x) { return insert(e, e.pn_object(), x, pn_data_put_char); }
+encoder operator<<(encoder e, amqp_ulong x) { return insert(e, e.pn_object(), x, pn_data_put_ulong); }
+encoder operator<<(encoder e, amqp_long x) { return insert(e, e.pn_object(), x, pn_data_put_long); }
+encoder operator<<(encoder e, amqp_timestamp x) { return insert(e, e.pn_object(), x, pn_data_put_timestamp); }
+encoder operator<<(encoder e, amqp_float x) { return insert(e, e.pn_object(), x, pn_data_put_float); }
+encoder operator<<(encoder e, amqp_double x) { return insert(e, e.pn_object(), x, pn_data_put_double); }
+encoder operator<<(encoder e, amqp_decimal32 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal32); }
+encoder operator<<(encoder e, amqp_decimal64 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal64); }
+encoder operator<<(encoder e, amqp_decimal128 x) { return insert(e, e.pn_object(), x, pn_data_put_decimal128); }
+encoder operator<<(encoder e, amqp_uuid x) { return insert(e, e.pn_object(), x, pn_data_put_uuid); }
+encoder operator<<(encoder e, amqp_string x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_string); }
+encoder operator<<(encoder e, amqp_symbol x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_symbol); }
+encoder operator<<(encoder e, amqp_binary x) { return insert(e, e.pn_object(), x, pn_data_put_amqp_binary); }
 
 encoder operator<<(encoder e, const value& v) {
     data edata = e.data();
@@ -138,6 +143,11 @@ encoder operator<<(encoder e, const value& v) {
     return e;
 }
 
-encoder operator<<(encoder e, const message_id& v) { return e << v.value_; }
+encoder operator<<(encoder e, const scalar& x) {
+    return insert(e, e.pn_object(), x.atom_, pn_data_put_atom);
+}
+
+encoder operator<<(encoder e, const message_id& x) { return e << x.scalar_; }
+encoder operator<<(encoder e, const annotation_key& x) { return e << x.scalar_; }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/error.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/error.cpp b/proton-c/bindings/cpp/src/error.cpp
index 980d6c0..8382a70 100644
--- a/proton-c/bindings/cpp/src/error.cpp
+++ b/proton-c/bindings/cpp/src/error.cpp
@@ -27,4 +27,6 @@ error::error(const std::string& msg) : std::runtime_error(prefix+msg) {}
 
 timeout_error::timeout_error(const std::string& msg) : error(msg) {}
 
+decode_error::decode_error(const std::string& msg) : error("decode: "+msg) {}
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/event.cpp b/proton-c/bindings/cpp/src/event.cpp
index 2a35ee8..b3e93d8 100644
--- a/proton-c/bindings/cpp/src/event.cpp
+++ b/proton-c/bindings/cpp/src/event.cpp
@@ -77,5 +77,5 @@ class message &event::message() const {
     throw error(MSG("No message associated with event"));
 }
 
-event_loop::~event_loop() {}    // FIXME aconway 2015-12-28: move
+event_loop::~event_loop() {}
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index c2fcd00..c7ee1f6 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "proton/data.hpp"
 #include "proton/message.hpp"
 #include "proton/error.hpp"
 #include "proton/link.hpp"
@@ -31,24 +32,39 @@
 #include "msg.hpp"
 #include "proton_bits.hpp"
 
-#include <cstring>
+#include <string>
 #include <assert.h>
 
 namespace proton {
 
-message::message() : message_(::pn_message()) {}
+// impl exists so body is pre-constructed in reference mode (prevent it creating its own data)
+// for all message ctors.
+message::impl::impl() : msg(0), body(0) {}
 
-message::message(const message &m) : message_(::pn_message()) { *this = m; }
+message::impl::~impl() {
+    if (msg) {
+        body.ref(0);            // Clear the reference.
+        pn_message_free(msg);
+    }
+}
 
-#if defined(PN_HAS_CPP11) && PN_HAS_CPP11
-message::message(message &&m) : message_(::pn_message()) { swap(m); }
-#endif
+// Lazy construct the message.
+pn_message_t* message::pn_msg() const {
+    if (!impl_.msg) impl_.msg = pn_message();
+    return impl_.msg;
+}
+
+message::message() {}
+
+message::message(const message &m) { *this = m; }
 
-message::message(const value& v) : message_(::pn_message()) { body(v); }
+#if PN_HAS_CPP11
+message::message(message &&m) { swap(m); }
+#endif
 
-message::~message() { ::pn_message_free(message_); }
+message::~message() {}
 
-void message::swap(message& m) { std::swap(message_, m.message_); }
+void message::swap(message& m) { std::swap(impl_.msg, m.impl_.msg); }
 
 message& message::operator=(const message& m) {
     // TODO aconway 2015-08-10: more efficient pn_message_copy function
@@ -58,7 +74,7 @@ message& message::operator=(const message& m) {
     return *this;
 }
 
-void message::clear() { pn_message_clear(message_); }
+void message::clear() { if (impl_.msg) pn_message_clear(impl_.msg); }
 
 namespace {
 void check(int err) {
@@ -66,7 +82,7 @@ void check(int err) {
 }
 } // namespace
 
-void message::id(const message_id& id) { data(pn_message_id(message_)).copy(id.value_); }
+void message::id(const message_id& id) { pn_message_set_id(pn_msg(), id.scalar_.atom_); }
 
 namespace {
 inline message_id from_pn_atom(const pn_atom_t& v) {
@@ -86,222 +102,169 @@ inline message_id from_pn_atom(const pn_atom_t& v) {
 }
 
 message_id message::id() const {
-    return from_pn_atom(pn_message_get_id(message_));
+    return from_pn_atom(pn_message_get_id(pn_msg()));
 }
 
 void message::user_id(const std::string &id) {
-    check(pn_message_set_user_id(message_, pn_bytes(id)));
+    check(pn_message_set_user_id(pn_msg(), pn_bytes(id)));
 }
 
 std::string message::user_id() const {
-    return str(pn_message_get_user_id(message_));
+    return str(pn_message_get_user_id(pn_msg()));
 }
 
 void message::address(const std::string &addr) {
-    check(pn_message_set_address(message_, addr.c_str()));
+    check(pn_message_set_address(pn_msg(), addr.c_str()));
 }
 
 std::string message::address() const {
-    const char* addr = pn_message_get_address(message_);
+    const char* addr = pn_message_get_address(pn_msg());
     return addr ? std::string(addr) : std::string();
 }
 
 void message::subject(const std::string &s) {
-    check(pn_message_set_subject(message_, s.c_str()));
+    check(pn_message_set_subject(pn_msg(), s.c_str()));
 }
 
 std::string message::subject() const {
-    const char* s = pn_message_get_subject(message_);
+    const char* s = pn_message_get_subject(pn_msg());
     return s ? std::string(s) : std::string();
 }
 
 void message::reply_to(const std::string &s) {
-    check(pn_message_set_reply_to(message_, s.c_str()));
+    check(pn_message_set_reply_to(pn_msg(), s.c_str()));
 }
 
 std::string message::reply_to() const {
-    const char* s = pn_message_get_reply_to(message_);
+    const char* s = pn_message_get_reply_to(pn_msg());
     return s ? std::string(s) : std::string();
 }
 
 void message::correlation_id(const message_id& id) {
-    data(pn_message_correlation_id(message_)).copy(id.value_);
+    data(pn_message_correlation_id(pn_msg())).copy(id.scalar_);
 }
 
 message_id message::correlation_id() const {
-    return from_pn_atom(pn_message_get_correlation_id(message_));
+    return from_pn_atom(pn_message_get_correlation_id(pn_msg()));
 }
 
 void message::content_type(const std::string &s) {
-    check(pn_message_set_content_type(message_, s.c_str()));
+    check(pn_message_set_content_type(pn_msg(), s.c_str()));
 }
 
 std::string message::content_type() const {
-    const char* s = pn_message_get_content_type(message_);
+    const char* s = pn_message_get_content_type(pn_msg());
     return s ? std::string(s) : std::string();
 }
 
 void message::content_encoding(const std::string &s) {
-    check(pn_message_set_content_encoding(message_, s.c_str()));
+    check(pn_message_set_content_encoding(pn_msg(), s.c_str()));
 }
 
 std::string message::content_encoding() const {
-    const char* s = pn_message_get_content_encoding(message_);
+    const char* s = pn_message_get_content_encoding(pn_msg());
     return s ? std::string(s) : std::string();
 }
 
 void message::expiry_time(amqp_timestamp t) {
-    pn_message_set_expiry_time(message_, t.milliseconds);
+    pn_message_set_expiry_time(pn_msg(), t.milliseconds);
 }
 amqp_timestamp message::expiry_time() const {
-    return amqp_timestamp(pn_message_get_expiry_time(message_));
+    return amqp_timestamp(pn_message_get_expiry_time(pn_msg()));
 }
 
 void message::creation_time(amqp_timestamp t) {
-    pn_message_set_creation_time(message_, t);
+    pn_message_set_creation_time(pn_msg(), t);
 }
 amqp_timestamp message::creation_time() const {
-    return pn_message_get_creation_time(message_);
+    return pn_message_get_creation_time(pn_msg());
 }
 
 void message::group_id(const std::string &s) {
-    check(pn_message_set_group_id(message_, s.c_str()));
+    check(pn_message_set_group_id(pn_msg(), s.c_str()));
 }
 
 std::string message::group_id() const {
-    const char* s = pn_message_get_group_id(message_);
+    const char* s = pn_message_get_group_id(pn_msg());
     return s ? std::string(s) : std::string();
 }
 
 void message::reply_to_group_id(const std::string &s) {
-    check(pn_message_set_reply_to_group_id(message_, s.c_str()));
+    check(pn_message_set_reply_to_group_id(pn_msg(), s.c_str()));
 }
 
 std::string message::reply_to_group_id() const {
-    const char* s = pn_message_get_reply_to_group_id(message_);
+    const char* s = pn_message_get_reply_to_group_id(pn_msg());
     return s ? std::string(s) : std::string();
 }
 
-bool message::inferred() const { return pn_message_is_inferred(message_); }
-
-void message::inferred(bool b) { pn_message_set_inferred(message_, b); }
-
-void message::body(const value& v) { body().copy(v); }
+bool message::inferred() const { return pn_message_is_inferred(pn_msg()); }
 
-const data message::body() const {
-    return pn_message_body(message_);
-}
+void message::inferred(bool b) { pn_message_set_inferred(pn_msg(), b); }
 
-data message::body() {
-    return pn_message_body(message_);
-}
+const value& message::body() const { return impl_.body.ref(pn_message_body(pn_msg())); }
+value& message::body() { return impl_.body.ref(pn_message_body(pn_msg())); }
 
-void message::properties(const value& v) {
-    properties().copy(v);
-}
+// MAP CACHING: the properties, annotations and instructions maps can either be
+// encoded in the pn_message pn_data_t structures OR decoded as C++ map members
+// of the message but not both. At least one of the pn_data_t or the map member
+// is always empty, the non-empty one is the authority.
 
-const data message::properties() const {
-    return pn_message_properties(message_);
-}
-
-data message::properties() {
-    return pn_message_properties(message_);
-}
-
-namespace {
-typedef std::map<std::string, value> props_map;
-}
-
-void message::property(const std::string& name, const value &v) {
-    // TODO aconway 2015-11-17: not efficient but avoids cache consistency problems.
-    // Could avoid full encode/decode with linear scan of names. Need
-    // better codec suport for in-place modification of data.
-    props_map m;
-    if (!properties().empty())
-        properties().get(m);
-    m[name] = v;
-    properties(m);
-}
-
-value message::property(const std::string& name) const {
-    // TODO aconway 2015-11-17: not efficient but avoids cache consistency problems.
-    if (!properties().empty()) {
-        props_map m;
-        properties().get(m);
-        props_map::const_iterator i = m.find(name);
-        if (i != m.end())
-            return i->second;
+// Decode a map on demand
+template<class M> M& get_map(pn_message_t* msg, pn_data_t* (*get)(pn_message_t*), M& map) {
+    data d(get(msg));
+    if (map.empty() && !d.empty()) {
+        d.decoder() >> rewind() >> map;
+        d.clear();              // The map member is now the authority.
     }
-    return value();
+    return map;
 }
 
-bool message::erase_property(const std::string& name) {
-    // TODO aconway 2015-11-17: not efficient but avoids cache consistency problems.
-    if (!properties().empty()) {
-        props_map m;
-        properties().get(m);
-        if (m.erase(name)) {
-            properties(m);
-            return true;
-        }
+// Encode a map if necessary.
+template<class M> M& put_map(pn_message_t* msg, pn_data_t* (*get)(pn_message_t*), M& map) {
+    data d(get(msg));
+    if (d.empty() && !map.empty()) {
+        d.encoder() << map;
+        map.clear();        // The encoded pn_data_t  is now the authority.
     }
-    return false;
+    return map;
 }
 
-void message::annotations(const value& v) {
-    annotations().copy(v);
+message::property_map& message::properties() {
+    return get_map(pn_msg(), pn_message_properties, properties_);
 }
 
-const data message::annotations() const {
-    return pn_message_annotations(message_);
+const message::property_map& message::properties() const {
+    return get_map(pn_msg(), pn_message_properties, properties_);
 }
 
-data message::annotations() {
-    return pn_message_annotations(message_);
-}
 
-namespace {
-typedef std::map<proton::amqp_symbol, value> annotation_map;
+message::annotation_map& message::annotations() {
+    return get_map(pn_msg(), pn_message_annotations, annotations_);
 }
 
-void message::annotation(const proton::amqp_symbol &k, const value &v) {
-    annotation_map m;
-    if (!annotations().empty())
-        annotations().get(m);
-    m[k] = v;
-    annotations(m);
+const message::annotation_map& message::annotations() const {
+    return get_map(pn_msg(), pn_message_annotations, annotations_);
 }
 
-value message::annotation(const proton::amqp_symbol &k) const {
-    if (!annotations().empty()) {
-        annotation_map m;
-        annotations().get(m);
-        annotation_map::const_iterator i = m.find(k);
-        if (i != m.end())
-            return i->second;
-    }
-    return value();
 
+message::annotation_map& message::instructions() {
+    return get_map(pn_msg(), pn_message_instructions, instructions_);
 }
 
-bool message::erase_annotation(const proton::amqp_symbol &k) {
-    if (!annotations().empty()) {
-        annotation_map m;
-        annotations().get(m);
-        if (m.erase(k)) {
-            annotations(m);
-            return true;
-        }
-    }
-    return false;
+const message::annotation_map& message::instructions() const {
+    return get_map(pn_msg(), pn_message_instructions, instructions_);
 }
 
 void message::encode(std::string &s) const {
+    put_map(pn_msg(), pn_message_properties, properties_);
+    put_map(pn_msg(), pn_message_annotations, annotations_);
+    put_map(pn_msg(), pn_message_instructions, instructions_);
     size_t sz = s.capacity();
     if (sz < 512) sz = 512;
     while (true) {
         s.resize(sz);
-        int err = pn_message_encode(message_, const_cast<char*>(s.data()), &sz);
+        int err = pn_message_encode(pn_msg(), const_cast<char*>(s.data()), &sz);
         if (err) {
             if (err != PN_OVERFLOW)
                 check(err);
@@ -320,7 +283,10 @@ std::string message::encode() const {
 }
 
 void message::decode(const std::string &s) {
-    check(pn_message_decode(message_, s.data(), s.size()));
+    properties_.clear();
+    annotations_.clear();
+    instructions_.clear();
+    check(pn_message_decode(pn_msg(), s.data(), s.size()));
 }
 
 void message::decode(proton::link link, proton::delivery delivery) {
@@ -333,22 +299,22 @@ void message::decode(proton::link link, proton::delivery delivery) {
     link.advance();
 }
 
-bool message::durable() const { return pn_message_is_durable(message_); }
-void message::durable(bool b) { pn_message_set_durable(message_, b); }
+bool message::durable() const { return pn_message_is_durable(pn_msg()); }
+void message::durable(bool b) { pn_message_set_durable(pn_msg(), b); }
 
-duration message::ttl() const { return duration(pn_message_get_ttl(message_)); }
-void message::ttl(duration d) { pn_message_set_ttl(message_, d.milliseconds); }
+duration message::ttl() const { return duration(pn_message_get_ttl(pn_msg())); }
+void message::ttl(duration d) { pn_message_set_ttl(pn_msg(), d.milliseconds); }
 
-uint8_t message::priority() const { return pn_message_get_priority(message_); }
-void message::priority(uint8_t d) { pn_message_set_priority(message_, d); }
+uint8_t message::priority() const { return pn_message_get_priority(pn_msg()); }
+void message::priority(uint8_t d) { pn_message_set_priority(pn_msg(), d); }
 
-bool message::first_acquirer() const { return pn_message_is_first_acquirer(message_); }
-void message::first_acquirer(bool b) { pn_message_set_first_acquirer(message_, b); }
+bool message::first_acquirer() const { return pn_message_is_first_acquirer(pn_msg()); }
+void message::first_acquirer(bool b) { pn_message_set_first_acquirer(pn_msg(), b); }
 
-uint32_t message::delivery_count() const { return pn_message_get_delivery_count(message_); }
-void message::delivery_count(uint32_t d) { pn_message_set_delivery_count(message_, d); }
+uint32_t message::delivery_count() const { return pn_message_get_delivery_count(pn_msg()); }
+void message::delivery_count(uint32_t d) { pn_message_set_delivery_count(pn_msg(), d); }
 
-int32_t message::sequence() const { return pn_message_get_group_sequence(message_); }
-void message::sequence(int32_t d) { pn_message_set_group_sequence(message_, d); }
+int32_t message::sequence() const { return pn_message_get_group_sequence(pn_msg()); }
+void message::sequence(int32_t d) { pn_message_set_group_sequence(pn_msg(), d); }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1622d0e6/proton-c/bindings/cpp/src/message_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message_test.cpp b/proton-c/bindings/cpp/src/message_test.cpp
index 54995c0..9f05d1c 100644
--- a/proton-c/bindings/cpp/src/message_test.cpp
+++ b/proton-c/bindings/cpp/src/message_test.cpp
@@ -18,6 +18,7 @@
  */
 
 #include "proton/message.hpp"
+#include "proton/scalar.hpp"
 #include "test_bits.hpp"
 #include <string>
 #include <fstream>
@@ -32,58 +33,99 @@ using namespace proton;
     m.ATTR(#ATTR); \
     ASSERT_EQUAL(std::string(#ATTR), m.ATTR())
 
-#define CHECK_STR_VALUE(ATTR) \
+#define CHECK_MESSAGE_ID(ATTR) \
     m.ATTR(#ATTR); \
-    ASSERT_EQUAL(std::string(#ATTR), m.ATTR().get<std::string>())
+    ASSERT_EQUAL(scalar(#ATTR), m.ATTR())
 
-void test_message() {
+void test_message_properties() {
     message m("hello");
     std::string s = m.body().get<std::string>();
     ASSERT_EQUAL("hello", s);
 
-    CHECK_STR_VALUE(id);
+    CHECK_MESSAGE_ID(id);
     CHECK_STR(user_id);
     CHECK_STR(address);
     CHECK_STR(subject);
     CHECK_STR(reply_to);
-    CHECK_STR_VALUE(correlation_id);
+    CHECK_MESSAGE_ID(correlation_id);
     CHECK_STR(content_type);
     CHECK_STR(content_encoding);
     CHECK_STR(group_id);
     CHECK_STR(reply_to_group_id);
-
     m.expiry_time(42);
     ASSERT_EQUAL(m.expiry_time().milliseconds, 42);
     m.creation_time(4242);
     ASSERT_EQUAL(m.creation_time().milliseconds, 4242);
 
-    m.property("foo", 12);
-    ASSERT_EQUAL(m.property("foo"), value(12));
-    m.property("xxx", false);
-    ASSERT_EQUAL(m.property("xxx"), value(false));
-    ASSERT(m.erase_property("xxx"));
-    ASSERT(m.property("xxx").empty());
-    ASSERT(!m.erase_property("yyy"));
-
-    std::map<std::string, proton::value> props;
-    m.properties().get(props);
-    ASSERT_EQUAL(props.size(), 1);
-    ASSERT_EQUAL(props["foo"], value(12));
-    props["bar"] = amqp_symbol("xyz");
-    props["foo"] = true;
-    m.properties(props);
-    ASSERT_EQUAL(m.property("foo"), value(true));
-    ASSERT_EQUAL(m.property("bar"), value(amqp_symbol("xyz")));
-    m.property("bar", amqp_binary("bar"));
-    std::map<std::string, proton::value> props2;
-    m.properties().get(props2);
-    ASSERT_EQUAL(2, props2.size());
-    ASSERT_EQUAL(props2["foo"], value(true));
-    ASSERT_EQUAL(props2["bar"], value(amqp_binary("bar")));
+    message m2(m);
+    ASSERT_EQUAL("hello", m2.body().get<std::string>());
+    ASSERT_EQUAL(message_id("id"), m2.id());
+    ASSERT_EQUAL("user_id", m2.user_id());
+    ASSERT_EQUAL("address", m2.address());
+    ASSERT_EQUAL("subject", m2.subject());
+    ASSERT_EQUAL("reply_to", m2.reply_to());
+    ASSERT_EQUAL(message_id("correlation_id"), m2.correlation_id());
+    ASSERT_EQUAL("content_type", m2.content_type());
+    ASSERT_EQUAL("content_encoding", m2.content_encoding());
+    ASSERT_EQUAL("group_id", m2.group_id());
+    ASSERT_EQUAL("reply_to_group_id", m2.reply_to_group_id());
+    ASSERT_EQUAL(42, m2.expiry_time().milliseconds);
+    ASSERT_EQUAL(4242, m.creation_time().milliseconds);
+
+    m2 = m;
+    ASSERT_EQUAL("hello", m2.body().get<std::string>());
+    ASSERT_EQUAL(message_id("id"), m2.id());
+    ASSERT_EQUAL("user_id", m2.user_id());
+    ASSERT_EQUAL("address", m2.address());
+    ASSERT_EQUAL("subject", m2.subject());
+    ASSERT_EQUAL("reply_to", m2.reply_to());
+    ASSERT_EQUAL(message_id("correlation_id"), m2.correlation_id());
+    ASSERT_EQUAL("content_type", m2.content_type());
+    ASSERT_EQUAL("content_encoding", m2.content_encoding());
+    ASSERT_EQUAL("group_id", m2.group_id());
+    ASSERT_EQUAL("reply_to_group_id", m2.reply_to_group_id());
+    ASSERT_EQUAL(42, m2.expiry_time().milliseconds);
+    ASSERT_EQUAL(4242, m.creation_time().milliseconds);
+}
+
+void test_message_maps() {
+    message m;
+
+    ASSERT(m.properties().empty());
+    ASSERT(m.annotations().empty());
+    ASSERT(m.instructions().empty());
+
+    m.properties()["foo"] = 12;
+    m.instructions()["bar"] = "xyz";
+    m.annotations()[23] = "23";
+
+    ASSERT_EQUAL(m.properties()["foo"], scalar(12));
+    ASSERT_EQUAL(m.instructions()["bar"], scalar("xyz"));
+    ASSERT_EQUAL(m.annotations()[23], scalar("23"));
+
+    message m2(m);
+    message::annotation_map& amap = m2.instructions();
+
+    ASSERT_EQUAL(m2.properties()["foo"], scalar(12));
+    ASSERT_EQUAL(m2.instructions()["bar"], scalar("xyz"));
+    ASSERT_EQUAL(m2.annotations()[23], scalar("23"));
+
+    m.properties()["foo"] = "newfoo";
+    m.instructions()[24] = 1000;
+    m.annotations().erase(23);
+
+    m2 = m;
+    ASSERT_EQUAL(1, m2.properties().size());
+    ASSERT_EQUAL(m2.properties()["foo"], scalar("newfoo"));
+    ASSERT_EQUAL(2, m2.instructions().size());
+    ASSERT_EQUAL(m2.instructions()["bar"], scalar("xyz"));
+    ASSERT_EQUAL(m2.instructions()[24], scalar(1000));
+    ASSERT(m2.annotations().empty());
 }
 
 int main(int argc, char** argv) {
     int failed = 0;
-    RUN_TEST(failed, test_message());
+    RUN_TEST(failed, test_message_properties());
+    RUN_TEST(failed, test_message_maps());
     return failed;
 }


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


[04/50] [abbrv] qpid-proton git commit: NO-JIRA: cpp binding: Fix printing of UUID using operator<<()

Posted by ac...@apache.org.
NO-JIRA: cpp binding: Fix printing of UUID using operator<<()


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

Branch: refs/heads/go1
Commit: fdbba6973e2615824328f2e2a094337b4a4153bf
Parents: cf784e2
Author: Kim van der Riet <kp...@apache.org>
Authored: Mon Nov 30 14:31:51 2015 -0500
Committer: Kim van der Riet <kp...@apache.org>
Committed: Mon Nov 30 14:31:51 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/types.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fdbba697/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp b/proton-c/bindings/cpp/src/types.cpp
index 0964699..4b1d21d 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -20,13 +20,14 @@
 #include "proton/types.hpp"
 #include <proton/codec.h>
 #include <ostream>
+#include <iomanip>
 #include <algorithm>
 
 namespace proton {
 
 namespace {
 inline std::ostream& print_segment(std::ostream& o, const amqp_uuid& u, size_t begin, size_t end, const char* sep="") {
-    for (const char* p = &u[begin]; p < &u[end]; ++p) o << *p;
+    for (const char* p = &u[begin]; p < &u[end]; ++p) o << std::setw(2) << std::setfill('0') << ((int)*p & 0xff);
     return o << sep;
 }
 }


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


[34/50] [abbrv] qpid-proton git commit: PROTON-1049: check sasl setup before running tests (commit ff13d7699 missed this one)

Posted by ac...@apache.org.
PROTON-1049: check sasl setup before running tests (commit ff13d7699 missed this one)


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

Branch: refs/heads/go1
Commit: d3fe232c95a09bb791e3878a7770f51d26caac6e
Parents: c6439c7
Author: Chuck Rolke <cr...@redhat.com>
Authored: Wed Dec 16 15:36:04 2015 -0500
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Wed Dec 16 15:36:04 2015 -0500

----------------------------------------------------------------------
 tests/python/proton_tests/reactor.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d3fe232c/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index c7d6dd8..6ee107d 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -488,6 +488,7 @@ class ContainerTest(Test):
     """Test container subclass of reactor."""
 
     def test_event_has_container_attribute(self):
+        ensureCanTestExtendedSASL()
         class TestHandler(MessagingHandler):
             def __init__(self):
                 super(TestHandler, self).__init__()


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


[24/50] [abbrv] qpid-proton git commit: PROTON-1020: fix typos in error messages

Posted by ac...@apache.org.
PROTON-1020: fix typos in error messages


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

Branch: refs/heads/go1
Commit: 95eece73007dbb18c8920735a0a00c4b621093d7
Parents: c9158ed
Author: Clifford Jansen <cl...@apache.org>
Authored: Mon Dec 14 08:35:50 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Mon Dec 14 08:35:50 2015 -0800

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/messaging_event.cpp | 2 +-
 proton-c/bindings/cpp/src/proton_bits.cpp     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/95eece73/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index d0ae0f8..eabacaf 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -139,7 +139,7 @@ void messaging_event::dispatch(handler &h) {
 
         case messaging_event::TRANSPORT_CLOSED:       handler->on_transport_closed(*this); break;
         default:
-            throw error(MSG("Unkown messaging event type " << type_));
+            throw error(MSG("Unknown messaging event type " << type_));
             break;
         }
     } else {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/95eece73/proton-c/bindings/cpp/src/proton_bits.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.cpp b/proton-c/bindings/cpp/src/proton_bits.cpp
index 3b522bf..269b7d6 100644
--- a/proton-c/bindings/cpp/src/proton_bits.cpp
+++ b/proton-c/bindings/cpp/src/proton_bits.cpp
@@ -32,7 +32,7 @@ std::string error_str(int code) {
   case PN_OVERFLOW: return "overflow";
   case PN_UNDERFLOW: return "underflow";
   case PN_STATE_ERR: return "invalid state";
-  case PN_ARG_ERR: return "invalud argument";
+  case PN_ARG_ERR: return "invalid argument";
   case PN_TIMEOUT: return "timeout";
   case PN_INTR: return "interrupt";
   default: return "unknown error code";


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


[48/50] [abbrv] qpid-proton git commit: NO-JIRA: Update go-get repo to work with 0.10, 0.11 and master proton C libraries.

Posted by ac...@apache.org.
NO-JIRA: Update go-get repo to work with 0.10, 0.11 and master proton C libraries.


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

Branch: refs/heads/go1
Commit: bf7e19309c1ee0f6fdac058ce998cdd2a1ee403d
Parents: 117bb7c
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 30 15:58:26 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 30 15:58:26 2015 -0500

----------------------------------------------------------------------
 examples/go/README.md                           | 23 +++++++-------
 examples/go/example_test.go                     |  2 +-
 proton-c/bindings/go/genwrap.go                 |  2 ++
 .../go/src/qpid.apache.org/amqp/codec_shim.h    | 33 ++++++++++++++++++++
 .../go/src/qpid.apache.org/amqp/marshal.go      |  2 +-
 .../go/src/qpid.apache.org/amqp/message.go      |  2 +-
 .../go/src/qpid.apache.org/amqp/types.go        | 11 ++-----
 .../go/src/qpid.apache.org/amqp/unmarshal.go    |  6 ++--
 .../go/src/qpid.apache.org/proton/engine.go     |  1 +
 .../src/qpid.apache.org/proton/wrappers_gen.go  |  2 ++
 10 files changed, 58 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/examples/go/README.md
----------------------------------------------------------------------
diff --git a/examples/go/README.md b/examples/go/README.md
index ce9206b..9ba497b 100644
--- a/examples/go/README.md
+++ b/examples/go/README.md
@@ -24,23 +24,22 @@ proton
 
 ## Using the Go packages
 
-Use `go get qpid.apache.org/electron` or check out the proton repository and set
-your GOPATH environment variable to include
-`/<path-to-proton>/proton-c/bindings/go`
+If you have the proton C library and headers installed you can get the latest go
+packages with
 
-The proton Go packages include C code so the cgo compiler needs to be able to
-find the proton library and include files.  There are a couple of ways to do
-this:
+    go get qpid.apache.org/electron
 
-1. Build proton in directory `$BUILD`. Source the script `$BUILD/config.sh` to set your environment.
+If proton is installed in a non-standard place (other than /usr or /usr/local) you
+can set these environment variables before `go get`, for example:
 
-2. Install proton to a standard prefix such as `/usr` or `/usr/local`. No need for further settings.
+    export CGO_LDFLAGS="-L/<my-proton>/lib[64]"
+    export CGO_CFLAGS="-I/<my-proton>/include"
+    go get qpid.apache.org/electron
 
-3. Install proton to a non-standard prefix `$PREFIX`. Set the following:
+If you have a proton build you don't need to `go get`, you can set your GOPATH
+to use the binding from the checkout with:
 
-        export LIBRARY_PATH=$PREFIX/lib:$LIBRARY_PATH
-        export C_INCLUDE_PATH=$PREFIX/include:$C_INCLUDE_PATH
-        export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
+    source <path-to-proton>/config.sh
 
 Once you are set up, the go tools will work as normal. You can see documentation
 in your web browser at `localhost:6060` by running:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/examples/go/example_test.go
----------------------------------------------------------------------
diff --git a/examples/go/example_test.go b/examples/go/example_test.go
index 006e17c..6de309e 100644
--- a/examples/go/example_test.go
+++ b/examples/go/example_test.go
@@ -258,7 +258,7 @@ var debug = flag.Bool("debug", false, "Debugging output from examples")
 var brokerName = flag.String("broker", "broker", "Name of broker executable to run")
 var count = flag.Int("count", 3, "Count of messages to send in tests")
 var connections = flag.Int("connections", 3, "Number of connections to make in tests")
-var dir = flag.String("dir", "", "Directory containing example sources or binaries")
+var dir = flag.String("dir", "electron", "Directory containing example sources or binaries")
 var expected int
 
 func TestMain(m *testing.M) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/genwrap.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/genwrap.go b/proton-c/bindings/go/genwrap.go
index fe383a9..c904638 100644
--- a/proton-c/bindings/go/genwrap.go
+++ b/proton-c/bindings/go/genwrap.go
@@ -55,6 +55,8 @@ import (
 )
 
 // #include <proton/types.h>
+// #include <proton/error.h>
+// #include <proton/condition.h>
 // #include <proton/event.h>
 // #include <stdlib.h>
 `)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h b/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h
new file mode 100644
index 0000000..b2f9f1c
--- /dev/null
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/codec_shim.h
@@ -0,0 +1,33 @@
+#ifndef CODEC_SHIM_H
+#define CODEC_SHIM_H
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/** Stubs to allow the go binding to work with multiple versions of proton. */
+
+#include <proton/codec.h>
+#include <proton/version.h>
+
+#if PN_VERSION_MAJOR == 0 && PN_VERSION_MINOR <= 10
+
+#define PN_INVALID ((pn_type_t)-1)
+
+#endif
+
+#endif // CODEC_SHIM_H

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
index 9930e13..66e14d8 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/marshal.go
@@ -19,7 +19,7 @@ under the License.
 
 package amqp
 
-// #include <proton/codec.h>
+//#include "codec_shim.h"
 import "C"
 
 import (

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
index e36c6f2..1d1287f 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
@@ -19,9 +19,9 @@ under the License.
 
 package amqp
 
+// #include "codec_shim.h"
 // #include <proton/types.h>
 // #include <proton/message.h>
-// #include <proton/codec.h>
 // #include <stdlib.h>
 //
 // /* Helper for setting message string fields */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
index 697d896..d927cc5 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
@@ -19,7 +19,7 @@ under the License.
 
 package amqp
 
-// #include <proton/codec.h>
+//#include "codec_shim.h"
 import "C"
 
 import (
@@ -30,10 +30,6 @@ import (
 	"unsafe"
 )
 
-// Older proton versions don't define C.PN_INVALID, so define it here.
-// In C it is pn_type_t(-1), in Go use the bitwise NOT operator to get the same value.
-const pnInvalid = C.pn_type_t(^0)
-
 func (t C.pn_type_t) String() string {
 	switch C.pn_type_t(t) {
 	case C.PN_NULL:
@@ -86,10 +82,9 @@ func (t C.pn_type_t) String() string {
 		return "list"
 	case C.PN_MAP:
 		return "map"
+	case C.PN_INVALID:
+		return "no-data"
 	default:
-		if t == pnInvalid {
-			return "no-data"
-		}
 		return fmt.Sprintf("unknown-type(%d)", t)
 	}
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
index 05ecb8d..6942174 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
@@ -19,7 +19,7 @@ under the License.
 
 package amqp
 
-// #include <proton/codec.h>
+// #include "codec_shim.h"
 import "C"
 
 import (
@@ -451,7 +451,7 @@ func rewindUnmarshal(v interface{}, data *C.pn_data_t) {
 func getInterface(data *C.pn_data_t, v *interface{}) {
 	pnType := C.pn_data_type(data)
 	switch pnType {
-	case C.PN_NULL, pnInvalid: // No data.
+	case C.PN_NULL, C.PN_INVALID: // No data.
 		*v = nil
 	case C.PN_BOOL:
 		*v = bool(C.pn_data_get_bool(data))
@@ -517,7 +517,7 @@ func getMap(data *C.pn_data_t, v interface{}) {
 				}
 			}
 		}
-	case pnInvalid: // Leave the map empty
+	case C.PN_INVALID: // Leave the map empty
 	default:
 		panic(newUnmarshalError(pnType, v))
 	}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
index 95d70e9..13d44b8 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
@@ -21,6 +21,7 @@ package proton
 
 // #include <proton/connection.h>
 // #include <proton/event.h>
+// #include <proton/error.h>
 // #include <proton/handlers.h>
 // #include <proton/session.h>
 // #include <proton/transport.h>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf7e1930/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 c69b2a8..183d6ec 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
@@ -30,6 +30,8 @@ import (
 )
 
 // #include <proton/types.h>
+// #include <proton/error.h>
+// #include <proton/condition.h>
 // #include <proton/event.h>
 // #include <stdlib.h>
 // #include <proton/session.h>


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


[33/50] [abbrv] qpid-proton git commit: PROTON-1049: disable reconnect and handle connection error

Posted by ac...@apache.org.
PROTON-1049: disable reconnect and handle connection error


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

Branch: refs/heads/go1
Commit: c6439c749b8fe51349e352f45f30acd9381be9cc
Parents: ff13d76
Author: Gordon Sim <gs...@redhat.com>
Authored: Wed Dec 16 14:08:08 2015 +0000
Committer: Gordon Sim <gs...@redhat.com>
Committed: Wed Dec 16 14:08:08 2015 +0000

----------------------------------------------------------------------
 tests/python/proton_tests/reactor.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c6439c74/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index beff329..c7d6dd8 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -464,6 +464,7 @@ class AuthenticationTestHandler(MessagingHandler):
         super(AuthenticationTestHandler, self).__init__()
         port = free_tcp_port()
         self.url = "localhost:%i" % port
+        self.verified = False
 
     def on_start(self, event):
         self.listener = event.container.listen(self.url)
@@ -473,11 +474,16 @@ class AuthenticationTestHandler(MessagingHandler):
 
     def on_connection_opening(self, event):
         assert event.connection.transport.user == "user@proton"
+        self.verified = True
 
     def on_connection_closed(self, event):
         event.connection.close()
         self.listener.close()
 
+    def on_connection_error(self, event):
+        event.connection.close()
+        self.listener.close()
+
 class ContainerTest(Test):
     """Test container subclass of reactor."""
 
@@ -511,8 +517,9 @@ class ContainerTest(Test):
         ensureCanTestExtendedSASL()
         test_handler = AuthenticationTestHandler()
         container = Container(test_handler)
-        container.connect("%s:password@%s" % ("user%40proton", test_handler.url))
+        container.connect("%s:password@%s" % ("user%40proton", test_handler.url), reconnect=False)
         container.run()
+        assert test_handler.verified
 
     def test_authentication_via_container_attributes(self):
         ensureCanTestExtendedSASL()
@@ -520,12 +527,14 @@ class ContainerTest(Test):
         container = Container(test_handler)
         container.user = "user@proton"
         container.password = "password"
-        container.connect(test_handler.url)
+        container.connect(test_handler.url, reconnect=False)
         container.run()
+        assert test_handler.verified
 
     def test_authentication_via_kwargs(self):
         ensureCanTestExtendedSASL()
         test_handler = AuthenticationTestHandler()
         container = Container(test_handler)
-        container.connect(test_handler.url, user="user@proton", password="password")
+        container.connect(test_handler.url, user="user@proton", password="password", reconnect=False)
         container.run()
+        assert test_handler.verified


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


[38/50] [abbrv] qpid-proton git commit: PROTON-1039: C++ binding message transport headers

Posted by ac...@apache.org.
PROTON-1039: C++ binding message transport headers


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

Branch: refs/heads/go1
Commit: 0a6e0e7a1adb74e4fd81d12c5b251411f2772a85
Parents: c12eae1
Author: Clifford Jansen <cl...@apache.org>
Authored: Fri Dec 18 09:19:25 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Fri Dec 18 09:23:46 2015 -0800

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/message.hpp     | 85 +++++++++++++++++++-
 proton-c/bindings/cpp/src/message.cpp           | 17 +++-
 2 files changed, 98 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a6e0e7a/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index aa7b9f8..f04ea07 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -26,6 +26,7 @@
 #include "proton/export.hpp"
 #include "proton/message_id.hpp"
 #include "proton/value.hpp"
+#include "proton/duration.hpp"
 
 #include <string>
 #include <utility>
@@ -151,15 +152,93 @@ class message
      * list values in the body of the message will be encoded as AMQP DATA
      * and AMQP SEQUENCE sections, respectively. If inferred is false,
      * then all values in the body of the message will be encoded as AMQP
-     * VALUE sections regardless of their type. Use
-     * ::pn_message_set_inferred to set the value.
+     * VALUE sections regardless of their type.
      *
-     * @param[in] msg a message object
      * @return the value of the inferred flag for the message
      */
     PN_CPP_EXTERN bool inferred() const;
+    /** Get the inferred flag for a message. */
     PN_CPP_EXTERN void inferred(bool);
 
+    /**
+     * Get the durable flag for a message.
+     *
+     * The durable flag indicates that any parties taking responsibility
+     * for the message must durably store the content.
+     *
+     * @return the value of the durable flag
+     */
+    PN_CPP_EXTERN bool durable() const;
+    /** Get the durable flag for a message. */
+    PN_CPP_EXTERN void durable(bool);
+
+    /**
+     * Get the ttl for a message.
+     *
+     * The ttl for a message determines how long a message is considered
+     * live. When a message is held for retransmit, the ttl is
+     * decremented. Once the ttl reaches zero, the message is considered
+     * dead. Once a message is considered dead it may be dropped.
+     *
+     * @return the ttl in milliseconds
+     */
+    PN_CPP_EXTERN duration ttl() const;
+    /** Set the ttl for a message */
+    PN_CPP_EXTERN void ttl(duration);
+
+    /**
+     * Get the priority for a message.
+     *
+     * The priority of a message impacts ordering guarantees. Within a
+     * given ordered context, higher priority messages may jump ahead of
+     * lower priority messages.
+     *
+     * @return the message priority
+     */
+    PN_CPP_EXTERN uint8_t priority() const;
+    /** Get the priority for a message. */
+    PN_CPP_EXTERN void priority(uint8_t);
+
+    /**
+     * Get the first acquirer flag for a message.
+     *
+     * When set to true, the first acquirer flag for a message indicates
+     * that the recipient of the message is the first recipient to acquire
+     * the message, i.e. there have been no failed delivery attempts to
+     * other acquirers. Note that this does not mean the message has not
+     * been delivered to, but not acquired, by other recipients.
+     *
+     * @return the first acquirer flag for the message
+     */
+    PN_CPP_EXTERN bool first_acquirer() const;
+    /** Get the first acquirer flag for a message. */
+    PN_CPP_EXTERN void first_acquirer(bool);
+
+    /**
+     * Get the delivery count for a message.
+     *
+     * The delivery count field tracks how many attempts have been made to
+     * delivery a message.
+     *
+     * @return the delivery count for the message
+     */
+    PN_CPP_EXTERN uint32_t delivery_count() const;
+    /** Get the delivery count for a message. */
+    PN_CPP_EXTERN void delivery_count(uint32_t);
+
+    /**
+     * Get the group sequence for a message.
+     *
+     * The group sequence of a message identifies the relative ordering of
+     * messages within a group. The default value for the group sequence
+     * of a message is zero.
+     *
+     * @return the group sequence for the message
+     */
+    PN_CPP_EXTERN uint32_t sequence() const;
+    /** Get the group sequence for a message. */
+    PN_CPP_EXTERN void sequence(uint32_t);
+
   private:
     pn_message_t *message_;
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0a6e0e7a/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index dd57606..dc7e50f 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -285,7 +285,22 @@ void message::decode(proton::link link, proton::delivery delivery) {
     link.advance();
 }
 
-}
+bool message::durable() const { return pn_message_is_durable(message_); }
+void message::durable(bool b) { pn_message_set_durable(message_, b); }
+
+duration message::ttl() const { return duration(pn_message_get_ttl(message_)); }
+void message::ttl(duration d) { pn_message_set_ttl(message_, d.milliseconds); }
+
+uint8_t message::priority() const { return pn_message_get_priority(message_); }
+void message::priority(uint8_t d) { pn_message_set_priority(message_, d); }
 
+bool message::first_acquirer() const { return pn_message_is_first_acquirer(message_); }
+void message::first_acquirer(bool b) { pn_message_set_first_acquirer(message_, b); }
 
+uint32_t message::delivery_count() const { return pn_message_get_delivery_count(message_); }
+void message::delivery_count(uint32_t d) { pn_message_set_delivery_count(message_, d); }
 
+uint32_t message::sequence() const { return pn_message_get_group_sequence(message_); }
+void message::sequence(uint32_t d) { pn_message_set_group_sequence(message_, d); }
+
+}


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


[49/50] [abbrv] qpid-proton git commit: Merge branch 'master' into go1 - updated to work with proton C 0.10

Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/proton/wrappers.go
----------------------------------------------------------------------
diff --cc proton/wrappers.go
index a48aeab,0000000..cd547ed
mode 100644,000000..100644
--- a/proton/wrappers.go
+++ b/proton/wrappers.go
@@@ -1,387 -1,0 +1,386 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +// This file contains special-case wrapper functions or wrappers that don't follow
 +// the pattern of genwrap.go.
 +
 +package proton
 +
 +//#include <proton/codec.h>
 +//#include <proton/connection.h>
 +//#include <proton/delivery.h>
 +//#include <proton/event.h>
 +//#include <proton/link.h>
 +//#include <proton/link.h>
 +//#include <proton/object.h>
 +//#include <proton/session.h>
 +//#include <proton/transport.h>
 +//#include <stdlib.h>
 +import "C"
 +
 +import (
 +	"fmt"
 +	"qpid.apache.org/amqp"
 +	"reflect"
 +	"time"
 +	"unsafe"
 +)
 +
 +// TODO aconway 2015-05-05: Documentation for generated types.
 +
 +// CHandle holds an unsafe.Pointer to a proton C struct, the C type depends on the
 +// Go type implementing this interface. For low level, at-your-own-risk use only.
 +type CHandle interface {
 +	// CPtr returns the unsafe C pointer, equivalent to a C void*.
 +	CPtr() unsafe.Pointer
 +}
 +
 +// Incref increases the refcount of a proton value, which prevents the
 +// underlying C struct being freed until you call Decref().
 +//
 +// It can be useful to "pin" a proton value in memory while it is in use by
 +// goroutines other than the event loop goroutine. For example if you Incref() a
 +// Link, the underlying object is not freed when the link is closed, so means
 +// other goroutines can continue to safely use it as an index in a map or inject
 +// it into the event loop goroutine. There will of course be an error if you try
 +// to use a link after it is closed, but not a segmentation fault.
 +func Incref(c CHandle) {
 +	if p := c.CPtr(); p != nil {
 +		C.pn_incref(p)
 +	}
 +}
 +
 +// Decref decreases the refcount of a proton value, freeing the underlying C
 +// struct if this is the last reference.  Only call this if you previously
 +// called Incref() for this value.
 +func Decref(c CHandle) {
 +	if p := c.CPtr(); p != nil {
 +		C.pn_decref(p)
 +	}
 +}
 +
 +// Event is an AMQP protocol event.
 +type Event struct {
 +	pn         *C.pn_event_t
 +	eventType  EventType
 +	connection Connection
 +	transport  Transport
 +	session    Session
 +	link       Link
 +	delivery   Delivery
 +	injecter   Injecter
 +}
 +
 +func makeEvent(pn *C.pn_event_t, injecter Injecter) Event {
 +	return Event{
 +		pn:         pn,
 +		eventType:  EventType(C.pn_event_type(pn)),
 +		connection: Connection{C.pn_event_connection(pn)},
 +		transport:  Transport{C.pn_event_transport(pn)},
 +		session:    Session{C.pn_event_session(pn)},
 +		link:       Link{C.pn_event_link(pn)},
 +		delivery:   Delivery{C.pn_event_delivery(pn)},
 +		injecter:   injecter,
 +	}
 +}
 +func (e Event) IsNil() bool            { return e.eventType == EventType(0) }
 +func (e Event) Type() EventType        { return e.eventType }
 +func (e Event) Connection() Connection { return e.connection }
 +func (e Event) Transport() Transport   { return e.transport }
 +func (e Event) Session() Session       { return e.session }
 +func (e Event) Link() Link             { return e.link }
 +func (e Event) Delivery() Delivery     { return e.delivery }
 +func (e Event) String() string         { return e.Type().String() }
 +
 +// Injecter should not be used in a handler function, but it can be passed to
 +// other goroutines (via a channel or to a goroutine started by handler
 +// functions) to let them inject functions back into the handlers goroutine.
 +func (e Event) Injecter() Injecter { return e.injecter }
 +
 +// Data holds a pointer to decoded AMQP data.
 +// Use amqp.marshal/unmarshal to access it as Go data types.
 +//
 +type Data struct{ pn *C.pn_data_t }
 +
 +func NewData(p unsafe.Pointer) Data { return Data{(*C.pn_data_t)(p)} }
 +
 +func (d Data) Free()                   { C.pn_data_free(d.pn) }
 +func (d Data) Pointer() unsafe.Pointer { return unsafe.Pointer(d.pn) }
 +func (d Data) Clear()                  { C.pn_data_clear(d.pn) }
 +func (d Data) Rewind()                 { C.pn_data_rewind(d.pn) }
 +func (d Data) Error() error            { return PnError(C.pn_data_error(d.pn)) }
 +
 +// State holds the state flags for an AMQP endpoint.
 +type State byte
 +
 +const (
 +	SLocalUninit  State = C.PN_LOCAL_UNINIT
 +	SLocalActive        = C.PN_LOCAL_ACTIVE
 +	SLocalClosed        = C.PN_LOCAL_CLOSED
 +	SRemoteUninit       = C.PN_REMOTE_UNINIT
 +	SRemoteActive       = C.PN_REMOTE_ACTIVE
 +	SRemoteClosed       = C.PN_REMOTE_CLOSED
 +)
 +
 +// Has is True if bits & state is non 0.
 +func (s State) Has(bits State) bool { return s&bits != 0 }
 +
 +func (s State) LocalUninit() bool  { return s.Has(SLocalUninit) }
 +func (s State) LocalActive() bool  { return s.Has(SLocalActive) }
 +func (s State) LocalClosed() bool  { return s.Has(SLocalClosed) }
 +func (s State) RemoteUninit() bool { return s.Has(SRemoteUninit) }
 +func (s State) RemoteActive() bool { return s.Has(SRemoteActive) }
 +func (s State) RemoteClosed() bool { return s.Has(SRemoteClosed) }
 +
 +// Return a State containig just the local flags
 +func (s State) Local() State { return State(s & C.PN_LOCAL_MASK) }
 +
 +// Return a State containig just the remote flags
 +func (s State) Remote() State { return State(s & C.PN_REMOTE_MASK) }
 +
 +// Endpoint is the common interface for Connection, Link and Session.
 +type Endpoint interface {
 +	// State is the open/closed state.
 +	State() State
 +	// Open an endpoint.
 +	Open()
 +	// Close an endpoint.
 +	Close()
 +	// Condition holds a local error condition.
 +	Condition() Condition
 +	// RemoteCondition holds a remote error condition.
 +	RemoteCondition() Condition
 +	// Human readable name
 +	String() string
 +	// Human readable endpoint type "link", "session" etc.
 +	Type() string
 +}
 +
 +// CloseError sets an error condition (if err != nil) on an endpoint and closes
 +// the endpoint if not already closed
 +func CloseError(e Endpoint, err error) {
 +	if err != nil {
 +		e.Condition().SetError(err)
 +	}
 +	e.Close()
 +}
 +
 +// EndpointError returns the remote error if there is one, the local error if not
 +// nil if there is no error.
 +func EndpointError(e Endpoint) error {
 +	err := e.RemoteCondition().Error()
 +	if err == nil {
 +		err = e.Condition().Error()
 +	}
 +	return err
 +}
 +
 +const (
 +	Received uint64 = C.PN_RECEIVED
 +	Accepted        = C.PN_ACCEPTED
 +	Rejected        = C.PN_REJECTED
 +	Released        = C.PN_RELEASED
 +	Modified        = C.PN_MODIFIED
 +)
 +
 +// SettleAs is equivalent to d.Update(disposition); d.Settle()
 +func (d Delivery) SettleAs(disposition uint64) {
 +	d.Update(disposition)
 +	d.Settle()
 +}
 +
 +// Accept accepts and settles a delivery.
 +func (d Delivery) Accept() { d.SettleAs(Accepted) }
 +
 +// Reject rejects and settles a delivery
 +func (d Delivery) Reject() { d.SettleAs(Rejected) }
 +
 +// Release releases and settles a delivery
 +// If delivered is true the delivery count for the message will be increased.
 +func (d Delivery) Release(delivered bool) {
 +	if delivered {
 +		d.SettleAs(Modified)
 +	} else {
 +		d.SettleAs(Released)
 +	}
 +}
 +
 +type DeliveryTag struct{ pn C.pn_delivery_tag_t }
 +
 +func (t DeliveryTag) String() string { return C.GoStringN(t.pn.start, C.int(t.pn.size)) }
 +
 +func (l Link) Recv(buf []byte) int {
 +	if len(buf) == 0 {
 +		return 0
 +	}
 +	return int(C.pn_link_recv(l.pn, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))))
 +}
 +
 +func (l Link) SendBytes(bytes []byte) int {
 +	return int(C.pn_link_send(l.pn, cPtr(bytes), cLen(bytes)))
 +}
 +
 +func pnTag(tag string) C.pn_delivery_tag_t {
 +	bytes := []byte(tag)
 +	return C.pn_dtag(cPtr(bytes), cLen(bytes))
 +}
 +
 +func (l Link) Delivery(tag string) Delivery {
 +	return Delivery{C.pn_delivery(l.pn, pnTag(tag))}
 +}
 +
 +func (l Link) Connection() Connection { return l.Session().Connection() }
 +
 +// Human-readable link description including name, source, target and direction.
 +func (l Link) String() string {
 +	switch {
 +	case l.IsNil():
 +		return fmt.Sprintf("<nil-link>")
 +	case l.IsSender():
 +		return fmt.Sprintf("%s(%s->%s)", l.Name(), l.Source().Address(), l.Target().Address())
 +	default:
 +		return fmt.Sprintf("%s(%s<-%s)", l.Name(), l.Target().Address(), l.Source().Address())
 +	}
 +}
 +
 +func (l Link) Type() string {
 +	if l.IsSender() {
- 		return "sender-link"
++		return "link(sender)"
 +	} else {
- 		return "receiver-link"
++		return "link(receiver)"
 +	}
- 
 +}
 +
 +func cPtr(b []byte) *C.char {
 +	if len(b) == 0 {
 +		return nil
 +	}
 +	return (*C.char)(unsafe.Pointer(&b[0]))
 +}
 +
 +func cLen(b []byte) C.size_t {
 +	return C.size_t(len(b))
 +}
 +
 +func (s Session) Sender(name string) Link {
 +	cname := C.CString(name)
 +	defer C.free(unsafe.Pointer(cname))
 +	return Link{C.pn_sender(s.pn, cname)}
 +}
 +
 +func (s Session) Receiver(name string) Link {
 +	cname := C.CString(name)
 +	defer C.free(unsafe.Pointer(cname))
 +	return Link{C.pn_receiver(s.pn, cname)}
 +}
 +
 +// Unique (per process) string identifier for a connection, useful for debugging.
 +func (c Connection) String() string {
 +	return fmt.Sprintf("%x", c.pn)
 +}
 +
 +func (c Connection) Type() string {
 +	return "connection"
 +}
 +
 +// Head functions don't follow the normal naming conventions so missed by the generator.
 +
 +func (c Connection) LinkHead(s State) Link {
 +	return Link{C.pn_link_head(c.pn, C.pn_state_t(s))}
 +}
 +
 +func (c Connection) SessionHead(s State) Session {
 +	return Session{C.pn_session_head(c.pn, C.pn_state_t(s))}
 +}
 +
 +func (c Connection) Links(state State) (links []Link) {
 +	for l := c.LinkHead(state); !l.IsNil(); l = l.Next(state) {
 +		links = append(links, l)
 +	}
 +	return
 +}
 +
 +func (c Connection) Sessions(state State) (sessions []Session) {
 +	for s := c.SessionHead(state); !s.IsNil(); s = s.Next(state) {
 +		sessions = append(sessions, s)
 +	}
 +	return
 +}
 +
 +func (s Session) String() string {
 +	return fmt.Sprintf("%s/%p", s.Connection(), s.pn)
 +}
 +
 +func (s Session) Type() string { return "session" }
 +
 +// Error returns an instance of amqp.Error or nil.
 +func (c Condition) Error() error {
 +	if c.IsNil() || !c.IsSet() {
 +		return nil
 +	}
 +	return amqp.Error{c.Name(), c.Description()}
 +}
 +
 +// Set a Go error into a condition.
 +// If it is not an amqp.Condition use the error type as name, error string as description.
 +func (c Condition) SetError(err error) {
 +	if err != nil {
 +		if cond, ok := err.(amqp.Error); ok {
 +			c.SetName(cond.Name)
 +			c.SetDescription(cond.Description)
 +		} else {
 +			c.SetName(reflect.TypeOf(err).Name())
 +			c.SetDescription(err.Error())
 +		}
 +	}
 +}
 +
 +func (c Connection) Session() (Session, error) {
 +	s := Session{C.pn_session(c.pn)}
 +	if s.IsNil() {
 +		return s, Connection(c).Error()
 +	}
 +	return s, nil
 +}
 +
 +// pnTime converts Go time.Time to Proton millisecond Unix time.
 +func pnTime(t time.Time) C.pn_timestamp_t {
 +	secs := t.Unix()
 +	// Note: sub-second accuracy is not guaraunteed if the Unix time in
 +	// nanoseconds cannot be represented by an int64 (sometime around year 2260)
 +	msecs := (t.UnixNano() % int64(time.Second)) / int64(time.Millisecond)
 +	return C.pn_timestamp_t(secs*1000 + msecs)
 +}
 +
 +// goTime converts a pn_timestamp_t to a Go time.Time.
 +func goTime(t C.pn_timestamp_t) time.Time {
 +	secs := int64(t) / 1000
 +	nsecs := (int64(t) % 1000) * int64(time.Millisecond)
 +	return time.Unix(secs, nsecs)
 +}
 +
 +// Special treatment for Transport.Head, return value is unsafe.Pointer not string
 +func (t Transport) Head() unsafe.Pointer {
 +	return unsafe.Pointer(C.pn_transport_head(t.pn))
 +}
 +
 +// Special treatment for Transport.Push, takes []byte instead of char*, size
 +func (t Transport) Push(bytes []byte) int {
 +	return int(C.pn_transport_push(t.pn, (*C.char)(unsafe.Pointer(&bytes[0])), C.size_t(len(bytes))))
 +}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c87499a3/proton/wrappers_gen.go
----------------------------------------------------------------------
diff --cc proton/wrappers_gen.go
index c69b2a8,0000000..183d6ec
mode 100644,000000..100644
--- a/proton/wrappers_gen.go
+++ b/proton/wrappers_gen.go
@@@ -1,873 -1,0 +1,875 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +//
 +// NOTE: DO NOT EDIT. This file was generated by genwrap.go from the proton header files.
 +// Update the generator and re-run if you need to modify this code.
 +//
 +
 +package proton
 +
 +import (
 +	"time"
 +	"unsafe"
 +)
 +
 +// #include <proton/types.h>
++// #include <proton/error.h>
++// #include <proton/condition.h>
 +// #include <proton/event.h>
 +// #include <stdlib.h>
 +// #include <proton/session.h>
 +// #include <proton/link.h>
 +// #include <proton/delivery.h>
 +// #include <proton/disposition.h>
 +// #include <proton/condition.h>
 +// #include <proton/terminus.h>
 +// #include <proton/connection.h>
 +// #include <proton/transport.h>
 +import "C"
 +
 +type EventType int
 +
 +const (
 +	EConnectionInit         EventType = C.PN_CONNECTION_INIT
 +	EConnectionBound        EventType = C.PN_CONNECTION_BOUND
 +	EConnectionUnbound      EventType = C.PN_CONNECTION_UNBOUND
 +	EConnectionLocalOpen    EventType = C.PN_CONNECTION_LOCAL_OPEN
 +	EConnectionRemoteOpen   EventType = C.PN_CONNECTION_REMOTE_OPEN
 +	EConnectionLocalClose   EventType = C.PN_CONNECTION_LOCAL_CLOSE
 +	EConnectionRemoteClose  EventType = C.PN_CONNECTION_REMOTE_CLOSE
 +	EConnectionFinal        EventType = C.PN_CONNECTION_FINAL
 +	ESessionInit            EventType = C.PN_SESSION_INIT
 +	ESessionLocalOpen       EventType = C.PN_SESSION_LOCAL_OPEN
 +	ESessionRemoteOpen      EventType = C.PN_SESSION_REMOTE_OPEN
 +	ESessionLocalClose      EventType = C.PN_SESSION_LOCAL_CLOSE
 +	ESessionRemoteClose     EventType = C.PN_SESSION_REMOTE_CLOSE
 +	ESessionFinal           EventType = C.PN_SESSION_FINAL
 +	ELinkInit               EventType = C.PN_LINK_INIT
 +	ELinkLocalOpen          EventType = C.PN_LINK_LOCAL_OPEN
 +	ELinkRemoteOpen         EventType = C.PN_LINK_REMOTE_OPEN
 +	ELinkLocalClose         EventType = C.PN_LINK_LOCAL_CLOSE
 +	ELinkRemoteClose        EventType = C.PN_LINK_REMOTE_CLOSE
 +	ELinkLocalDetach        EventType = C.PN_LINK_LOCAL_DETACH
 +	ELinkRemoteDetach       EventType = C.PN_LINK_REMOTE_DETACH
 +	ELinkFlow               EventType = C.PN_LINK_FLOW
 +	ELinkFinal              EventType = C.PN_LINK_FINAL
 +	EDelivery               EventType = C.PN_DELIVERY
 +	ETransport              EventType = C.PN_TRANSPORT
 +	ETransportAuthenticated EventType = C.PN_TRANSPORT_AUTHENTICATED
 +	ETransportError         EventType = C.PN_TRANSPORT_ERROR
 +	ETransportHeadClosed    EventType = C.PN_TRANSPORT_HEAD_CLOSED
 +	ETransportTailClosed    EventType = C.PN_TRANSPORT_TAIL_CLOSED
 +	ETransportClosed        EventType = C.PN_TRANSPORT_CLOSED
 +)
 +
 +func (e EventType) String() string {
 +	switch e {
 +
 +	case C.PN_CONNECTION_INIT:
 +		return "ConnectionInit"
 +	case C.PN_CONNECTION_BOUND:
 +		return "ConnectionBound"
 +	case C.PN_CONNECTION_UNBOUND:
 +		return "ConnectionUnbound"
 +	case C.PN_CONNECTION_LOCAL_OPEN:
 +		return "ConnectionLocalOpen"
 +	case C.PN_CONNECTION_REMOTE_OPEN:
 +		return "ConnectionRemoteOpen"
 +	case C.PN_CONNECTION_LOCAL_CLOSE:
 +		return "ConnectionLocalClose"
 +	case C.PN_CONNECTION_REMOTE_CLOSE:
 +		return "ConnectionRemoteClose"
 +	case C.PN_CONNECTION_FINAL:
 +		return "ConnectionFinal"
 +	case C.PN_SESSION_INIT:
 +		return "SessionInit"
 +	case C.PN_SESSION_LOCAL_OPEN:
 +		return "SessionLocalOpen"
 +	case C.PN_SESSION_REMOTE_OPEN:
 +		return "SessionRemoteOpen"
 +	case C.PN_SESSION_LOCAL_CLOSE:
 +		return "SessionLocalClose"
 +	case C.PN_SESSION_REMOTE_CLOSE:
 +		return "SessionRemoteClose"
 +	case C.PN_SESSION_FINAL:
 +		return "SessionFinal"
 +	case C.PN_LINK_INIT:
 +		return "LinkInit"
 +	case C.PN_LINK_LOCAL_OPEN:
 +		return "LinkLocalOpen"
 +	case C.PN_LINK_REMOTE_OPEN:
 +		return "LinkRemoteOpen"
 +	case C.PN_LINK_LOCAL_CLOSE:
 +		return "LinkLocalClose"
 +	case C.PN_LINK_REMOTE_CLOSE:
 +		return "LinkRemoteClose"
 +	case C.PN_LINK_LOCAL_DETACH:
 +		return "LinkLocalDetach"
 +	case C.PN_LINK_REMOTE_DETACH:
 +		return "LinkRemoteDetach"
 +	case C.PN_LINK_FLOW:
 +		return "LinkFlow"
 +	case C.PN_LINK_FINAL:
 +		return "LinkFinal"
 +	case C.PN_DELIVERY:
 +		return "Delivery"
 +	case C.PN_TRANSPORT:
 +		return "Transport"
 +	case C.PN_TRANSPORT_AUTHENTICATED:
 +		return "TransportAuthenticated"
 +	case C.PN_TRANSPORT_ERROR:
 +		return "TransportError"
 +	case C.PN_TRANSPORT_HEAD_CLOSED:
 +		return "TransportHeadClosed"
 +	case C.PN_TRANSPORT_TAIL_CLOSED:
 +		return "TransportTailClosed"
 +	case C.PN_TRANSPORT_CLOSED:
 +		return "TransportClosed"
 +	}
 +	return "Unknown"
 +}
 +
 +// Wrappers for declarations in session.h
 +
 +type Session struct{ pn *C.pn_session_t }
 +
 +func (s Session) IsNil() bool          { return s.pn == nil }
 +func (s Session) CPtr() unsafe.Pointer { return unsafe.Pointer(s.pn) }
 +func (s Session) Free() {
 +	C.pn_session_free(s.pn)
 +}
 +func (s Session) State() State {
 +	return State(C.pn_session_state(s.pn))
 +}
 +func (s Session) Error() error {
 +	return PnError(C.pn_session_error(s.pn))
 +}
 +func (s Session) Condition() Condition {
 +	return Condition{C.pn_session_condition(s.pn)}
 +}
 +func (s Session) RemoteCondition() Condition {
 +	return Condition{C.pn_session_remote_condition(s.pn)}
 +}
 +func (s Session) Connection() Connection {
 +	return Connection{C.pn_session_connection(s.pn)}
 +}
 +func (s Session) Open() {
 +	C.pn_session_open(s.pn)
 +}
 +func (s Session) Close() {
 +	C.pn_session_close(s.pn)
 +}
 +func (s Session) IncomingCapacity() uint {
 +	return uint(C.pn_session_get_incoming_capacity(s.pn))
 +}
 +func (s Session) SetIncomingCapacity(capacity uint) {
 +	C.pn_session_set_incoming_capacity(s.pn, C.size_t(capacity))
 +}
 +func (s Session) OutgoingWindow() uint {
 +	return uint(C.pn_session_get_outgoing_window(s.pn))
 +}
 +func (s Session) SetOutgoingWindow(window uint) {
 +	C.pn_session_set_outgoing_window(s.pn, C.size_t(window))
 +}
 +func (s Session) OutgoingBytes() uint {
 +	return uint(C.pn_session_outgoing_bytes(s.pn))
 +}
 +func (s Session) IncomingBytes() uint {
 +	return uint(C.pn_session_incoming_bytes(s.pn))
 +}
 +func (s Session) Next(state State) Session {
 +	return Session{C.pn_session_next(s.pn, C.pn_state_t(state))}
 +}
 +
 +// Wrappers for declarations in link.h
 +
 +type SndSettleMode C.pn_snd_settle_mode_t
 +
 +const (
 +	SndUnsettled SndSettleMode = C.PN_SND_UNSETTLED
 +	SndSettled   SndSettleMode = C.PN_SND_SETTLED
 +	SndMixed     SndSettleMode = C.PN_SND_MIXED
 +)
 +
 +func (e SndSettleMode) String() string {
 +	switch e {
 +
 +	case C.PN_SND_UNSETTLED:
 +		return "SndUnsettled"
 +	case C.PN_SND_SETTLED:
 +		return "SndSettled"
 +	case C.PN_SND_MIXED:
 +		return "SndMixed"
 +	}
 +	return "unknown"
 +}
 +
 +type RcvSettleMode C.pn_rcv_settle_mode_t
 +
 +const (
 +	RcvFirst  RcvSettleMode = C.PN_RCV_FIRST
 +	RcvSecond RcvSettleMode = C.PN_RCV_SECOND
 +)
 +
 +func (e RcvSettleMode) String() string {
 +	switch e {
 +
 +	case C.PN_RCV_FIRST:
 +		return "RcvFirst"
 +	case C.PN_RCV_SECOND:
 +		return "RcvSecond"
 +	}
 +	return "unknown"
 +}
 +
 +type Link struct{ pn *C.pn_link_t }
 +
 +func (l Link) IsNil() bool          { return l.pn == nil }
 +func (l Link) CPtr() unsafe.Pointer { return unsafe.Pointer(l.pn) }
 +func (l Link) Free() {
 +	C.pn_link_free(l.pn)
 +}
 +func (l Link) Name() string {
 +	return C.GoString(C.pn_link_name(l.pn))
 +}
 +func (l Link) IsSender() bool {
 +	return bool(C.pn_link_is_sender(l.pn))
 +}
 +func (l Link) IsReceiver() bool {
 +	return bool(C.pn_link_is_receiver(l.pn))
 +}
 +func (l Link) State() State {
 +	return State(C.pn_link_state(l.pn))
 +}
 +func (l Link) Error() error {
 +	return PnError(C.pn_link_error(l.pn))
 +}
 +func (l Link) Condition() Condition {
 +	return Condition{C.pn_link_condition(l.pn)}
 +}
 +func (l Link) RemoteCondition() Condition {
 +	return Condition{C.pn_link_remote_condition(l.pn)}
 +}
 +func (l Link) Session() Session {
 +	return Session{C.pn_link_session(l.pn)}
 +}
 +func (l Link) Next(state State) Link {
 +	return Link{C.pn_link_next(l.pn, C.pn_state_t(state))}
 +}
 +func (l Link) Open() {
 +	C.pn_link_open(l.pn)
 +}
 +func (l Link) Close() {
 +	C.pn_link_close(l.pn)
 +}
 +func (l Link) Detach() {
 +	C.pn_link_detach(l.pn)
 +}
 +func (l Link) Source() Terminus {
 +	return Terminus{C.pn_link_source(l.pn)}
 +}
 +func (l Link) Target() Terminus {
 +	return Terminus{C.pn_link_target(l.pn)}
 +}
 +func (l Link) RemoteSource() Terminus {
 +	return Terminus{C.pn_link_remote_source(l.pn)}
 +}
 +func (l Link) RemoteTarget() Terminus {
 +	return Terminus{C.pn_link_remote_target(l.pn)}
 +}
 +func (l Link) Current() Delivery {
 +	return Delivery{C.pn_link_current(l.pn)}
 +}
 +func (l Link) Advance() bool {
 +	return bool(C.pn_link_advance(l.pn))
 +}
 +func (l Link) Credit() int {
 +	return int(C.pn_link_credit(l.pn))
 +}
 +func (l Link) Queued() int {
 +	return int(C.pn_link_queued(l.pn))
 +}
 +func (l Link) RemoteCredit() int {
 +	return int(C.pn_link_remote_credit(l.pn))
 +}
 +func (l Link) IsDrain() bool {
 +	return bool(C.pn_link_get_drain(l.pn))
 +}
 +func (l Link) Drained() int {
 +	return int(C.pn_link_drained(l.pn))
 +}
 +func (l Link) Available() int {
 +	return int(C.pn_link_available(l.pn))
 +}
 +func (l Link) SndSettleMode() SndSettleMode {
 +	return SndSettleMode(C.pn_link_snd_settle_mode(l.pn))
 +}
 +func (l Link) RcvSettleMode() RcvSettleMode {
 +	return RcvSettleMode(C.pn_link_rcv_settle_mode(l.pn))
 +}
 +func (l Link) SetSndSettleMode(mode SndSettleMode) {
 +	C.pn_link_set_snd_settle_mode(l.pn, C.pn_snd_settle_mode_t(mode))
 +}
 +func (l Link) SetRcvSettleMode(mode RcvSettleMode) {
 +	C.pn_link_set_rcv_settle_mode(l.pn, C.pn_rcv_settle_mode_t(mode))
 +}
 +func (l Link) RemoteSndSettleMode() SndSettleMode {
 +	return SndSettleMode(C.pn_link_remote_snd_settle_mode(l.pn))
 +}
 +func (l Link) RemoteRcvSettleMode() RcvSettleMode {
 +	return RcvSettleMode(C.pn_link_remote_rcv_settle_mode(l.pn))
 +}
 +func (l Link) Unsettled() int {
 +	return int(C.pn_link_unsettled(l.pn))
 +}
 +func (l Link) Offered(credit int) {
 +	C.pn_link_offered(l.pn, C.int(credit))
 +}
 +func (l Link) Flow(credit int) {
 +	C.pn_link_flow(l.pn, C.int(credit))
 +}
 +func (l Link) Drain(credit int) {
 +	C.pn_link_drain(l.pn, C.int(credit))
 +}
 +func (l Link) SetDrain(drain bool) {
 +	C.pn_link_set_drain(l.pn, C.bool(drain))
 +}
 +func (l Link) Draining() bool {
 +	return bool(C.pn_link_draining(l.pn))
 +}
 +
 +// Wrappers for declarations in delivery.h
 +
 +type Delivery struct{ pn *C.pn_delivery_t }
 +
 +func (d Delivery) IsNil() bool          { return d.pn == nil }
 +func (d Delivery) CPtr() unsafe.Pointer { return unsafe.Pointer(d.pn) }
 +func (d Delivery) Tag() DeliveryTag {
 +	return DeliveryTag{C.pn_delivery_tag(d.pn)}
 +}
 +func (d Delivery) Link() Link {
 +	return Link{C.pn_delivery_link(d.pn)}
 +}
 +func (d Delivery) Local() Disposition {
 +	return Disposition{C.pn_delivery_local(d.pn)}
 +}
 +func (d Delivery) LocalState() uint64 {
 +	return uint64(C.pn_delivery_local_state(d.pn))
 +}
 +func (d Delivery) Remote() Disposition {
 +	return Disposition{C.pn_delivery_remote(d.pn)}
 +}
 +func (d Delivery) RemoteState() uint64 {
 +	return uint64(C.pn_delivery_remote_state(d.pn))
 +}
 +func (d Delivery) Settled() bool {
 +	return bool(C.pn_delivery_settled(d.pn))
 +}
 +func (d Delivery) Pending() uint {
 +	return uint(C.pn_delivery_pending(d.pn))
 +}
 +func (d Delivery) Partial() bool {
 +	return bool(C.pn_delivery_partial(d.pn))
 +}
 +func (d Delivery) Writable() bool {
 +	return bool(C.pn_delivery_writable(d.pn))
 +}
 +func (d Delivery) Readable() bool {
 +	return bool(C.pn_delivery_readable(d.pn))
 +}
 +func (d Delivery) Updated() bool {
 +	return bool(C.pn_delivery_updated(d.pn))
 +}
 +func (d Delivery) Update(state uint64) {
 +	C.pn_delivery_update(d.pn, C.uint64_t(state))
 +}
 +func (d Delivery) Clear() {
 +	C.pn_delivery_clear(d.pn)
 +}
 +func (d Delivery) Current() bool {
 +	return bool(C.pn_delivery_current(d.pn))
 +}
 +func (d Delivery) Settle() {
 +	C.pn_delivery_settle(d.pn)
 +}
 +func (d Delivery) Dump() {
 +	C.pn_delivery_dump(d.pn)
 +}
 +func (d Delivery) Buffered() bool {
 +	return bool(C.pn_delivery_buffered(d.pn))
 +}
 +
 +// Wrappers for declarations in disposition.h
 +
 +type Disposition struct{ pn *C.pn_disposition_t }
 +
 +func (d Disposition) IsNil() bool          { return d.pn == nil }
 +func (d Disposition) CPtr() unsafe.Pointer { return unsafe.Pointer(d.pn) }
 +func (d Disposition) Type() uint64 {
 +	return uint64(C.pn_disposition_type(d.pn))
 +}
 +func (d Disposition) Condition() Condition {
 +	return Condition{C.pn_disposition_condition(d.pn)}
 +}
 +func (d Disposition) Data() Data {
 +	return Data{C.pn_disposition_data(d.pn)}
 +}
 +func (d Disposition) SectionNumber() uint16 {
 +	return uint16(C.pn_disposition_get_section_number(d.pn))
 +}
 +func (d Disposition) SetSectionNumber(section_number uint16) {
 +	C.pn_disposition_set_section_number(d.pn, C.uint32_t(section_number))
 +}
 +func (d Disposition) SectionOffset() uint64 {
 +	return uint64(C.pn_disposition_get_section_offset(d.pn))
 +}
 +func (d Disposition) SetSectionOffset(section_offset uint64) {
 +	C.pn_disposition_set_section_offset(d.pn, C.uint64_t(section_offset))
 +}
 +func (d Disposition) IsFailed() bool {
 +	return bool(C.pn_disposition_is_failed(d.pn))
 +}
 +func (d Disposition) SetFailed(failed bool) {
 +	C.pn_disposition_set_failed(d.pn, C.bool(failed))
 +}
 +func (d Disposition) IsUndeliverable() bool {
 +	return bool(C.pn_disposition_is_undeliverable(d.pn))
 +}
 +func (d Disposition) SetUndeliverable(undeliverable bool) {
 +	C.pn_disposition_set_undeliverable(d.pn, C.bool(undeliverable))
 +}
 +func (d Disposition) Annotations() Data {
 +	return Data{C.pn_disposition_annotations(d.pn)}
 +}
 +
 +// Wrappers for declarations in condition.h
 +
 +type Condition struct{ pn *C.pn_condition_t }
 +
 +func (c Condition) IsNil() bool          { return c.pn == nil }
 +func (c Condition) CPtr() unsafe.Pointer { return unsafe.Pointer(c.pn) }
 +func (c Condition) IsSet() bool {
 +	return bool(C.pn_condition_is_set(c.pn))
 +}
 +func (c Condition) Clear() {
 +	C.pn_condition_clear(c.pn)
 +}
 +func (c Condition) Name() string {
 +	return C.GoString(C.pn_condition_get_name(c.pn))
 +}
 +func (c Condition) SetName(name string) int {
 +	nameC := C.CString(name)
 +	defer C.free(unsafe.Pointer(nameC))
 +
 +	return int(C.pn_condition_set_name(c.pn, nameC))
 +}
 +func (c Condition) Description() string {
 +	return C.GoString(C.pn_condition_get_description(c.pn))
 +}
 +func (c Condition) SetDescription(description string) int {
 +	descriptionC := C.CString(description)
 +	defer C.free(unsafe.Pointer(descriptionC))
 +
 +	return int(C.pn_condition_set_description(c.pn, descriptionC))
 +}
 +func (c Condition) Info() Data {
 +	return Data{C.pn_condition_info(c.pn)}
 +}
 +func (c Condition) IsRedirect() bool {
 +	return bool(C.pn_condition_is_redirect(c.pn))
 +}
 +func (c Condition) RedirectHost() string {
 +	return C.GoString(C.pn_condition_redirect_host(c.pn))
 +}
 +func (c Condition) RedirectPort() int {
 +	return int(C.pn_condition_redirect_port(c.pn))
 +}
 +
 +// Wrappers for declarations in terminus.h
 +
 +type TerminusType C.pn_terminus_type_t
 +
 +const (
 +	Unspecified TerminusType = C.PN_UNSPECIFIED
 +	Source      TerminusType = C.PN_SOURCE
 +	Target      TerminusType = C.PN_TARGET
 +	Coordinator TerminusType = C.PN_COORDINATOR
 +)
 +
 +func (e TerminusType) String() string {
 +	switch e {
 +
 +	case C.PN_UNSPECIFIED:
 +		return "Unspecified"
 +	case C.PN_SOURCE:
 +		return "Source"
 +	case C.PN_TARGET:
 +		return "Target"
 +	case C.PN_COORDINATOR:
 +		return "Coordinator"
 +	}
 +	return "unknown"
 +}
 +
 +type Durability C.pn_durability_t
 +
 +const (
 +	Nondurable    Durability = C.PN_NONDURABLE
 +	Configuration Durability = C.PN_CONFIGURATION
 +	Deliveries    Durability = C.PN_DELIVERIES
 +)
 +
 +func (e Durability) String() string {
 +	switch e {
 +
 +	case C.PN_NONDURABLE:
 +		return "Nondurable"
 +	case C.PN_CONFIGURATION:
 +		return "Configuration"
 +	case C.PN_DELIVERIES:
 +		return "Deliveries"
 +	}
 +	return "unknown"
 +}
 +
 +type ExpiryPolicy C.pn_expiry_policy_t
 +
 +const (
 +	ExpireWithLink       ExpiryPolicy = C.PN_EXPIRE_WITH_LINK
 +	ExpireWithSession    ExpiryPolicy = C.PN_EXPIRE_WITH_SESSION
 +	ExpireWithConnection ExpiryPolicy = C.PN_EXPIRE_WITH_CONNECTION
 +	ExpireNever          ExpiryPolicy = C.PN_EXPIRE_NEVER
 +)
 +
 +func (e ExpiryPolicy) String() string {
 +	switch e {
 +
 +	case C.PN_EXPIRE_WITH_LINK:
 +		return "ExpireWithLink"
 +	case C.PN_EXPIRE_WITH_SESSION:
 +		return "ExpireWithSession"
 +	case C.PN_EXPIRE_WITH_CONNECTION:
 +		return "ExpireWithConnection"
 +	case C.PN_EXPIRE_NEVER:
 +		return "ExpireNever"
 +	}
 +	return "unknown"
 +}
 +
 +type DistributionMode C.pn_distribution_mode_t
 +
 +const (
 +	DistModeUnspecified DistributionMode = C.PN_DIST_MODE_UNSPECIFIED
 +	DistModeCopy        DistributionMode = C.PN_DIST_MODE_COPY
 +	DistModeMove        DistributionMode = C.PN_DIST_MODE_MOVE
 +)
 +
 +func (e DistributionMode) String() string {
 +	switch e {
 +
 +	case C.PN_DIST_MODE_UNSPECIFIED:
 +		return "DistModeUnspecified"
 +	case C.PN_DIST_MODE_COPY:
 +		return "DistModeCopy"
 +	case C.PN_DIST_MODE_MOVE:
 +		return "DistModeMove"
 +	}
 +	return "unknown"
 +}
 +
 +type Terminus struct{ pn *C.pn_terminus_t }
 +
 +func (t Terminus) IsNil() bool          { return t.pn == nil }
 +func (t Terminus) CPtr() unsafe.Pointer { return unsafe.Pointer(t.pn) }
 +func (t Terminus) Type() TerminusType {
 +	return TerminusType(C.pn_terminus_get_type(t.pn))
 +}
 +func (t Terminus) SetType(type_ TerminusType) int {
 +	return int(C.pn_terminus_set_type(t.pn, C.pn_terminus_type_t(type_)))
 +}
 +func (t Terminus) Address() string {
 +	return C.GoString(C.pn_terminus_get_address(t.pn))
 +}
 +func (t Terminus) SetAddress(address string) int {
 +	addressC := C.CString(address)
 +	defer C.free(unsafe.Pointer(addressC))
 +
 +	return int(C.pn_terminus_set_address(t.pn, addressC))
 +}
 +func (t Terminus) SetDistributionMode(mode DistributionMode) int {
 +	return int(C.pn_terminus_set_distribution_mode(t.pn, C.pn_distribution_mode_t(mode)))
 +}
 +func (t Terminus) Durability() Durability {
 +	return Durability(C.pn_terminus_get_durability(t.pn))
 +}
 +func (t Terminus) SetDurability(durability Durability) int {
 +	return int(C.pn_terminus_set_durability(t.pn, C.pn_durability_t(durability)))
 +}
 +func (t Terminus) ExpiryPolicy() ExpiryPolicy {
 +	return ExpiryPolicy(C.pn_terminus_get_expiry_policy(t.pn))
 +}
 +func (t Terminus) SetExpiryPolicy(policy ExpiryPolicy) int {
 +	return int(C.pn_terminus_set_expiry_policy(t.pn, C.pn_expiry_policy_t(policy)))
 +}
 +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)))
 +}
 +func (t Terminus) IsDynamic() bool {
 +	return bool(C.pn_terminus_is_dynamic(t.pn))
 +}
 +func (t Terminus) SetDynamic(dynamic bool) int {
 +	return int(C.pn_terminus_set_dynamic(t.pn, C.bool(dynamic)))
 +}
 +func (t Terminus) Properties() Data {
 +	return Data{C.pn_terminus_properties(t.pn)}
 +}
 +func (t Terminus) Capabilities() Data {
 +	return Data{C.pn_terminus_capabilities(t.pn)}
 +}
 +func (t Terminus) Outcomes() Data {
 +	return Data{C.pn_terminus_outcomes(t.pn)}
 +}
 +func (t Terminus) Filter() Data {
 +	return Data{C.pn_terminus_filter(t.pn)}
 +}
 +func (t Terminus) Copy(src Terminus) int {
 +	return int(C.pn_terminus_copy(t.pn, src.pn))
 +}
 +
 +// Wrappers for declarations in connection.h
 +
 +type Connection struct{ pn *C.pn_connection_t }
 +
 +func (c Connection) IsNil() bool          { return c.pn == nil }
 +func (c Connection) CPtr() unsafe.Pointer { return unsafe.Pointer(c.pn) }
 +func (c Connection) Free() {
 +	C.pn_connection_free(c.pn)
 +}
 +func (c Connection) Release() {
 +	C.pn_connection_release(c.pn)
 +}
 +func (c Connection) Error() error {
 +	return PnError(C.pn_connection_error(c.pn))
 +}
 +func (c Connection) State() State {
 +	return State(C.pn_connection_state(c.pn))
 +}
 +func (c Connection) Open() {
 +	C.pn_connection_open(c.pn)
 +}
 +func (c Connection) Close() {
 +	C.pn_connection_close(c.pn)
 +}
 +func (c Connection) Reset() {
 +	C.pn_connection_reset(c.pn)
 +}
 +func (c Connection) Condition() Condition {
 +	return Condition{C.pn_connection_condition(c.pn)}
 +}
 +func (c Connection) RemoteCondition() Condition {
 +	return Condition{C.pn_connection_remote_condition(c.pn)}
 +}
 +func (c Connection) Container() string {
 +	return C.GoString(C.pn_connection_get_container(c.pn))
 +}
 +func (c Connection) SetContainer(container string) {
 +	containerC := C.CString(container)
 +	defer C.free(unsafe.Pointer(containerC))
 +
 +	C.pn_connection_set_container(c.pn, containerC)
 +}
 +func (c Connection) SetUser(user string) {
 +	userC := C.CString(user)
 +	defer C.free(unsafe.Pointer(userC))
 +
 +	C.pn_connection_set_user(c.pn, userC)
 +}
 +func (c Connection) SetPassword(password string) {
 +	passwordC := C.CString(password)
 +	defer C.free(unsafe.Pointer(passwordC))
 +
 +	C.pn_connection_set_password(c.pn, passwordC)
 +}
 +func (c Connection) User() string {
 +	return C.GoString(C.pn_connection_get_user(c.pn))
 +}
 +func (c Connection) Hostname() string {
 +	return C.GoString(C.pn_connection_get_hostname(c.pn))
 +}
 +func (c Connection) SetHostname(hostname string) {
 +	hostnameC := C.CString(hostname)
 +	defer C.free(unsafe.Pointer(hostnameC))
 +
 +	C.pn_connection_set_hostname(c.pn, hostnameC)
 +}
 +func (c Connection) RemoteContainer() string {
 +	return C.GoString(C.pn_connection_remote_container(c.pn))
 +}
 +func (c Connection) RemoteHostname() string {
 +	return C.GoString(C.pn_connection_remote_hostname(c.pn))
 +}
 +func (c Connection) OfferedCapabilities() Data {
 +	return Data{C.pn_connection_offered_capabilities(c.pn)}
 +}
 +func (c Connection) DesiredCapabilities() Data {
 +	return Data{C.pn_connection_desired_capabilities(c.pn)}
 +}
 +func (c Connection) Properties() Data {
 +	return Data{C.pn_connection_properties(c.pn)}
 +}
 +func (c Connection) RemoteOfferedCapabilities() Data {
 +	return Data{C.pn_connection_remote_offered_capabilities(c.pn)}
 +}
 +func (c Connection) RemoteDesiredCapabilities() Data {
 +	return Data{C.pn_connection_remote_desired_capabilities(c.pn)}
 +}
 +func (c Connection) RemoteProperties() Data {
 +	return Data{C.pn_connection_remote_properties(c.pn)}
 +}
 +func (c Connection) Transport() Transport {
 +	return Transport{C.pn_connection_transport(c.pn)}
 +}
 +
 +// Wrappers for declarations in transport.h
 +
 +type Transport struct{ pn *C.pn_transport_t }
 +
 +func (t Transport) IsNil() bool          { return t.pn == nil }
 +func (t Transport) CPtr() unsafe.Pointer { return unsafe.Pointer(t.pn) }
 +func (t Transport) SetServer() {
 +	C.pn_transport_set_server(t.pn)
 +}
 +func (t Transport) Free() {
 +	C.pn_transport_free(t.pn)
 +}
 +func (t Transport) User() string {
 +	return C.GoString(C.pn_transport_get_user(t.pn))
 +}
 +func (t Transport) RequireAuth(required bool) {
 +	C.pn_transport_require_auth(t.pn, C.bool(required))
 +}
 +func (t Transport) IsAuthenticated() bool {
 +	return bool(C.pn_transport_is_authenticated(t.pn))
 +}
 +func (t Transport) RequireEncryption(required bool) {
 +	C.pn_transport_require_encryption(t.pn, C.bool(required))
 +}
 +func (t Transport) IsEncrypted() bool {
 +	return bool(C.pn_transport_is_encrypted(t.pn))
 +}
 +func (t Transport) Condition() Condition {
 +	return Condition{C.pn_transport_condition(t.pn)}
 +}
 +func (t Transport) Error() error {
 +	return PnError(C.pn_transport_error(t.pn))
 +}
 +func (t Transport) Bind(connection Connection) int {
 +	return int(C.pn_transport_bind(t.pn, connection.pn))
 +}
 +func (t Transport) Unbind() int {
 +	return int(C.pn_transport_unbind(t.pn))
 +}
 +func (t Transport) Log(message string) {
 +	messageC := C.CString(message)
 +	defer C.free(unsafe.Pointer(messageC))
 +
 +	C.pn_transport_log(t.pn, messageC)
 +}
 +func (t Transport) ChannelMax() uint32 {
 +	return uint32(C.pn_transport_get_channel_max(t.pn))
 +}
 +func (t Transport) SetChannelMax(channel_max uint32) int {
 +	return int(C.pn_transport_set_channel_max(t.pn, C.uint16_t(channel_max)))
 +}
 +func (t Transport) RemoteChannelMax() uint32 {
 +	return uint32(C.pn_transport_remote_channel_max(t.pn))
 +}
 +func (t Transport) MaxFrame() uint16 {
 +	return uint16(C.pn_transport_get_max_frame(t.pn))
 +}
 +func (t Transport) SetMaxFrame(size uint16) {
 +	C.pn_transport_set_max_frame(t.pn, C.uint32_t(size))
 +}
 +func (t Transport) RemoteMaxFrame() uint16 {
 +	return uint16(C.pn_transport_get_remote_max_frame(t.pn))
 +}
 +func (t Transport) IdleTimeout() time.Duration {
 +	return (time.Duration(C.pn_transport_get_idle_timeout(t.pn)) * time.Millisecond)
 +}
 +func (t Transport) SetIdleTimeout(timeout time.Duration) {
 +	C.pn_transport_set_idle_timeout(t.pn, C.pn_millis_t(timeout))
 +}
 +func (t Transport) RemoteIdleTimeout() time.Duration {
 +	return (time.Duration(C.pn_transport_get_remote_idle_timeout(t.pn)) * time.Millisecond)
 +}
 +func (t Transport) Input(bytes string, available uint) int {
 +	bytesC := C.CString(bytes)
 +	defer C.free(unsafe.Pointer(bytesC))
 +
 +	return int(C.pn_transport_input(t.pn, bytesC, C.size_t(available)))
 +}
 +func (t Transport) Output(bytes string, size uint) int {
 +	bytesC := C.CString(bytes)
 +	defer C.free(unsafe.Pointer(bytesC))
 +
 +	return int(C.pn_transport_output(t.pn, bytesC, C.size_t(size)))
 +}
 +func (t Transport) Capacity() int {
 +	return int(C.pn_transport_capacity(t.pn))
 +}
 +func (t Transport) Tail() string {
 +	return C.GoString(C.pn_transport_tail(t.pn))
 +}
 +func (t Transport) Process(size uint) int {
 +	return int(C.pn_transport_process(t.pn, C.size_t(size)))
 +}
 +func (t Transport) CloseTail() int {
 +	return int(C.pn_transport_close_tail(t.pn))
 +}
 +func (t Transport) Pending() int {
 +	return int(C.pn_transport_pending(t.pn))
 +}
 +func (t Transport) Peek(dst string, size uint) int {
 +	dstC := C.CString(dst)
 +	defer C.free(unsafe.Pointer(dstC))
 +
 +	return int(C.pn_transport_peek(t.pn, dstC, C.size_t(size)))
 +}
 +func (t Transport) Pop(size uint) {
 +	C.pn_transport_pop(t.pn, C.size_t(size))
 +}
 +func (t Transport) CloseHead() int {
 +	return int(C.pn_transport_close_head(t.pn))
 +}
 +func (t Transport) Quiesced() bool {
 +	return bool(C.pn_transport_quiesced(t.pn))
 +}
 +func (t Transport) Closed() bool {
 +	return bool(C.pn_transport_closed(t.pn))
 +}
 +func (t Transport) Tick(now time.Time) time.Time {
 +	return goTime(C.pn_transport_tick(t.pn, pnTime(now)))
 +}
 +func (t Transport) Connection() Connection {
 +	return Connection{C.pn_transport_connection(t.pn)}
 +}


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


[37/50] [abbrv] qpid-proton git commit: PROTON-1083: [C++ binding] Simplify messaging_handler and messaging_event - Consistently name events with a noun form eg OPEN/CLOSE (rather than opened/closed). - Only have endpoint events corresponding to remote

Posted by ac...@apache.org.
PROTON-1083: [C++ binding] Simplify messaging_handler and messaging_event
- Consistently name events with a noun form
  eg OPEN/CLOSE (rather than opened/closed).
- Only have endpoint events corresponding to remote open etc.
  This removes opening/closing events - as we are doing the local
  operations we should already know about them and not need events.
- Fill in missing event dispatches.


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

Branch: refs/heads/go1
Commit: c12eae180ab79982e6c2024f58f0c28001f84315
Parents: 3972720
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Dec 15 15:20:31 2015 +0000
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri Dec 18 13:48:38 2015 +0000

----------------------------------------------------------------------
 examples/cpp/broker.hpp                         |   8 +-
 examples/cpp/client.cpp                         |   2 +-
 examples/cpp/connection_options.cpp             |   4 +-
 examples/cpp/direct_send.cpp                    |   4 +-
 examples/cpp/helloworld_direct.cpp              |   4 +-
 examples/cpp/server_direct.cpp                  |   2 +-
 examples/cpp/simple_send.cpp                    |   4 +-
 examples/cpp/ssl.cpp                            |   6 +-
 examples/cpp/ssl_client_cert.cpp                |   6 +-
 .../cpp/include/proton/messaging_adapter.hpp    |  28 ++-
 .../cpp/include/proton/messaging_handler.hpp    |  47 +++--
 proton-c/bindings/cpp/src/messaging_adapter.cpp | 170 +++++--------------
 proton-c/bindings/cpp/src/messaging_event.cpp   | 104 ++++++------
 proton-c/bindings/cpp/src/messaging_event.hpp   |  45 ++---
 proton-c/bindings/cpp/src/messaging_handler.cpp |  35 ++--
 15 files changed, 172 insertions(+), 297 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/broker.hpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp
index 2d94b5a..4cd4f4b 100644
--- a/examples/cpp/broker.hpp
+++ b/examples/cpp/broker.hpp
@@ -135,7 +135,7 @@ class broker_handler : public proton::messaging_handler {
   public:
     broker_handler(queues& qs) : queues_(qs) {}
 
-    void on_link_opening(proton::event &e) {
+    void on_link_open(proton::event &e) {
         proton::link lnk = e.link();
         if (!!lnk.sender()) {
             proton::terminus remote_source(lnk.remote_source());
@@ -160,17 +160,17 @@ class broker_handler : public proton::messaging_handler {
             queues_.erase(address);
     }
 
-    void on_link_closing(proton::event &e) {
+    void on_link_close(proton::event &e) {
         proton::link lnk = e.link();
         if (!!lnk.sender())
             unsubscribe(lnk.sender());
     }
 
-    void on_connection_closing(proton::event &e) {
+    void on_connection_close(proton::event &e) {
         remove_stale_consumers(e.connection());
     }
 
-    void on_disconnected(proton::event &e) {
+    void on_disconnect(proton::event &e) {
         remove_stale_consumers(e.connection());
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index 7e576b1..4dee119 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -50,7 +50,7 @@ class client : public proton::messaging_handler {
         sender.send(req);
     }
 
-    void on_link_opened(proton::event &e) {
+    void on_link_open(proton::event &e) {
         if (e.link() == receiver)
             send_request();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/connection_options.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp
index ab21f76..6a79224 100644
--- a/examples/cpp/connection_options.cpp
+++ b/examples/cpp/connection_options.cpp
@@ -29,7 +29,7 @@
 using proton::connection_options;
 
 class handler_2 : public proton::messaging_handler {
-    void on_connection_opened(proton::event &e) {
+    void on_connection_open(proton::event &e) {
         std::cout << "connection events going to handler_2" << std::endl;
         std::cout << "connection max_frame_size: " << e.connection().transport().max_frame_size() <<
             ", idle timeout: " << e.connection().transport().idle_timeout() << std::endl;
@@ -51,7 +51,7 @@ class main_handler : public proton::messaging_handler {
         e.container().connect(url, connection_options().handler(&conn_handler).max_frame_size(2468));
     }
 
-    void on_connection_opened(proton::event &e) {
+    void on_connection_open(proton::event &e) {
         std::cout << "unexpected connection event on main handler" << std::endl;
         e.connection().close();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/direct_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp
index 909ef3f..0b7095e 100644
--- a/examples/cpp/direct_send.cpp
+++ b/examples/cpp/direct_send.cpp
@@ -59,7 +59,7 @@ class simple_send : public proton::messaging_handler {
         }
     }
 
-    void on_accepted(proton::event &e) {
+    void on_delivery_accept(proton::event &e) {
         confirmed++;
         if (confirmed == total) {
             std::cout << "all messages confirmed" << std::endl;
@@ -68,7 +68,7 @@ class simple_send : public proton::messaging_handler {
         }
     }
 
-    void on_disconnected(proton::event &e) {
+    void on_disconnect(proton::event &e) {
         sent = confirmed;
     }
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index 826b371..5e4c316 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -48,11 +48,11 @@ class hello_world_direct : public proton::messaging_handler {
         std::cout << e.message().body() << std::endl;
     }
 
-    void on_accepted(proton::event &e) {
+    void on_delivery_accept(proton::event &e) {
         e.connection().close();
     }
 
-    void on_connection_closed(proton::event &e) {
+    void on_connection_close(proton::event &e) {
         acceptor.close();
     }
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/server_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp
index 8bbcefe..7ad5889 100644
--- a/examples/cpp/server_direct.cpp
+++ b/examples/cpp/server_direct.cpp
@@ -61,7 +61,7 @@ class server : public proton::messaging_handler {
         return addr.str();
     }
 
-    void on_link_opening(proton::event& e) {
+    void on_link_open(proton::event& e) {
         proton::link link = e.link();
         if (!!link.sender() && link.remote_source().dynamic()) {
             link.source().address(generate_address());

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index 4d056fc..64c34bf 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -57,7 +57,7 @@ class simple_send : public proton::messaging_handler {
         }
     }
 
-    void on_accepted(proton::event &e) {
+    void on_delivery_accept(proton::event &e) {
         confirmed++;
         if (confirmed == total) {
             std::cout << "all messages confirmed" << std::endl;
@@ -65,7 +65,7 @@ class simple_send : public proton::messaging_handler {
         }
     }
 
-    void on_disconnected(proton::event &e) {
+    void on_disconnect(proton::event &e) {
         sent = confirmed;
     }
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index 5e670c2..568e223 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -44,7 +44,7 @@ std::string find_CN(const std::string &);
 struct server_handler : public proton::messaging_handler {
     proton::acceptor acceptor;
 
-    void on_connection_opened(proton::event &e) {
+    void on_connection_open(proton::event &e) {
         std::cout << "Inbound server connection connected via SSL.  Protocol: " <<
             e.connection().transport().ssl().protocol() << std::endl;
         acceptor.close();
@@ -83,7 +83,7 @@ class hello_world_direct : public proton::messaging_handler {
         e.container().open_sender(url);
     }
 
-    void on_connection_opened(proton::event &e) {
+    void on_connection_open(proton::event &e) {
         std::string subject = e.connection().transport().ssl().remote_subject();
         std::cout << "Outgoing client connection connected via SSL.  Server certificate identity " <<
             find_CN(subject) << std::endl;
@@ -96,7 +96,7 @@ class hello_world_direct : public proton::messaging_handler {
         e.sender().close();
     }
 
-    void on_accepted(proton::event &e) {
+    void on_delivery_accept(proton::event &e) {
         // All done.
         e.connection().close();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
index 0be0c32..7a9f411 100644
--- a/examples/cpp/ssl_client_cert.cpp
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -46,7 +46,7 @@ std::string find_CN(const std::string &);
 struct server_handler : public proton::messaging_handler {
     proton::acceptor inbound_listener;
 
-    void on_connection_opened(proton::event &e) {
+    void on_connection_open(proton::event &e) {
         std::cout << "Inbound server connection connected via SSL.  Protocol: " <<
             e.connection().transport().ssl().protocol() << std::endl;
         if (e.connection().transport().sasl().outcome() == sasl::OK) {
@@ -99,7 +99,7 @@ class hello_world_direct : public proton::messaging_handler {
         e.container().open_sender(url);
     }
 
-    void on_connection_opened(proton::event &e) {
+    void on_connection_open(proton::event &e) {
         std::string subject = e.connection().transport().ssl().remote_subject();
         std::cout << "Outgoing client connection connected via SSL.  Server certificate identity " <<
             find_CN(subject) << std::endl;
@@ -112,7 +112,7 @@ class hello_world_direct : public proton::messaging_handler {
         e.sender().close();
     }
 
-    void on_accepted(proton::event &e) {
+    void on_delivery_accept(proton::event &e) {
         // All done.
         e.connection().close();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
index 6e4342d..4e765e2 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
@@ -42,31 +42,23 @@ class messaging_adapter : public messaging_handler
     PN_CPP_EXTERN virtual void on_link_flow(event &e);
     PN_CPP_EXTERN virtual void on_delivery(event &e);
     PN_CPP_EXTERN virtual void on_unhandled(event &e);
-    PN_CPP_EXTERN virtual void on_connection_closed(event &e);
-    PN_CPP_EXTERN virtual void on_connection_closing(event &e);
-    PN_CPP_EXTERN virtual void on_connection_error(event &e);
-    PN_CPP_EXTERN virtual void on_connection_local_open(event &e);
     PN_CPP_EXTERN virtual void on_connection_remote_open(event &e);
     PN_CPP_EXTERN virtual void on_connection_remote_close(event &e);
-    PN_CPP_EXTERN virtual void on_connection_opened(event &e);
-    PN_CPP_EXTERN virtual void on_connection_opening(event &e);
-    PN_CPP_EXTERN virtual void on_session_closed(event &e);
-    PN_CPP_EXTERN virtual void on_session_closing(event &e);
-    PN_CPP_EXTERN virtual void on_session_error(event &e);
-    PN_CPP_EXTERN virtual void on_session_local_open(event &e);
     PN_CPP_EXTERN virtual void on_session_remote_open(event &e);
     PN_CPP_EXTERN virtual void on_session_remote_close(event &e);
-    PN_CPP_EXTERN virtual void on_session_opened(event &e);
-    PN_CPP_EXTERN virtual void on_session_opening(event &e);
-    PN_CPP_EXTERN virtual void on_link_closed(event &e);
-    PN_CPP_EXTERN virtual void on_link_closing(event &e);
-    PN_CPP_EXTERN virtual void on_link_error(event &e);
-    PN_CPP_EXTERN virtual void on_link_local_open(event &e);
     PN_CPP_EXTERN virtual void on_link_remote_open(event &e);
     PN_CPP_EXTERN virtual void on_link_remote_close(event &e);
-    PN_CPP_EXTERN virtual void on_link_opened(event &e);
-    PN_CPP_EXTERN virtual void on_link_opening(event &e);
     PN_CPP_EXTERN virtual void on_transport_tail_closed(event &e);
+
+    PN_CPP_EXTERN virtual void on_connection_close(event &e);
+    PN_CPP_EXTERN virtual void on_connection_error(event &e);
+    PN_CPP_EXTERN virtual void on_connection_open(event &e);
+    PN_CPP_EXTERN virtual void on_session_close(event &e);
+    PN_CPP_EXTERN virtual void on_session_error(event &e);
+    PN_CPP_EXTERN virtual void on_session_open(event &e);
+    PN_CPP_EXTERN virtual void on_link_close(event &e);
+    PN_CPP_EXTERN virtual void on_link_error(event &e);
+    PN_CPP_EXTERN virtual void on_link_open(event &e);
   private:
     messaging_handler &delegate_;  // The handler for generated messaging_event's
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
index 8fac665..9ec0f0d 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
@@ -51,34 +51,33 @@ class messaging_handler : public proton_handler
 
     ///@name Over-ride these member functions to handle events
     ///@{
-    PN_CPP_EXTERN virtual void on_accepted(event &e);
-    PN_CPP_EXTERN virtual void on_connection_closed(event &e);
-    PN_CPP_EXTERN virtual void on_connection_closing(event &e);
-    PN_CPP_EXTERN virtual void on_connection_error(event &e);
-    PN_CPP_EXTERN virtual void on_connection_opening(event &e);
-    PN_CPP_EXTERN virtual void on_connection_opened(event &e);
-    PN_CPP_EXTERN virtual void on_disconnected(event &e);
-    PN_CPP_EXTERN virtual void on_link_closed(event &e);
-    PN_CPP_EXTERN virtual void on_link_closing(event &e);
-    PN_CPP_EXTERN virtual void on_link_error(event &e);
-    PN_CPP_EXTERN virtual void on_link_opened(event &e);
-    PN_CPP_EXTERN virtual void on_link_opening(event &e);
+    PN_CPP_EXTERN virtual void on_start(event &e);
     PN_CPP_EXTERN virtual void on_message(event &e);
-    PN_CPP_EXTERN virtual void on_rejected(event &e);
-    PN_CPP_EXTERN virtual void on_released(event &e);
     PN_CPP_EXTERN virtual void on_sendable(event &e);
-    PN_CPP_EXTERN virtual void on_session_closed(event &e);
-    PN_CPP_EXTERN virtual void on_session_closing(event &e);
+    PN_CPP_EXTERN virtual void on_disconnect(event &e);
+
+    PN_CPP_EXTERN virtual void on_connection_open(event &e);
+    PN_CPP_EXTERN virtual void on_connection_close(event &e);
+    PN_CPP_EXTERN virtual void on_connection_error(event &e);
+
+    PN_CPP_EXTERN virtual void on_session_open(event &e);
+    PN_CPP_EXTERN virtual void on_session_close(event &e);
     PN_CPP_EXTERN virtual void on_session_error(event &e);
-    PN_CPP_EXTERN virtual void on_session_opened(event &e);
-    PN_CPP_EXTERN virtual void on_session_opening(event &e);
-    PN_CPP_EXTERN virtual void on_settled(event &e);
-    PN_CPP_EXTERN virtual void on_start(event &e);
+
+    PN_CPP_EXTERN virtual void on_link_open(event &e);
+    PN_CPP_EXTERN virtual void on_link_close(event &e);
+    PN_CPP_EXTERN virtual void on_link_error(event &e);
+
+    PN_CPP_EXTERN virtual void on_delivery_accept(event &e);
+    PN_CPP_EXTERN virtual void on_delivery_reject(event &e);
+    PN_CPP_EXTERN virtual void on_delivery_release(event &e);
+    PN_CPP_EXTERN virtual void on_delivery_settle(event &e);
+
+    PN_CPP_EXTERN virtual void on_transaction_declare(event &e);
+    PN_CPP_EXTERN virtual void on_transaction_commit(event &e);
+    PN_CPP_EXTERN virtual void on_transaction_abort(event &e);
+
     PN_CPP_EXTERN virtual void on_timer(event &e);
-    PN_CPP_EXTERN virtual void on_transaction_aborted(event &e);
-    PN_CPP_EXTERN virtual void on_transaction_committed(event &e);
-    PN_CPP_EXTERN virtual void on_transaction_declared(event &e);
-    PN_CPP_EXTERN virtual void on_transport_closed(event &e);
     ///@}
 
   private:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index c91df35..cf90754 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -92,29 +92,29 @@ void messaging_adapter::on_delivery(event &e) {
                 }
             }
             else if (dlv.updated() && dlv.settled()) {
-                messaging_event mevent(messaging_event::SETTLED, *pe);
-                delegate_.on_settled(mevent);
+                messaging_event mevent(messaging_event::DELIVERY_SETTLE, *pe);
+                delegate_.on_delivery_settle(mevent);
             }
         } else {
             // sender
             if (dlv.updated()) {
                 amqp_ulong rstate = dlv.remote_state();
                 if (rstate == PN_ACCEPTED) {
-                    messaging_event mevent(messaging_event::ACCEPTED, *pe);
-                    delegate_.on_accepted(mevent);
+                    messaging_event mevent(messaging_event::DELIVERY_ACCEPT, *pe);
+                    delegate_.on_delivery_accept(mevent);
                 }
                 else if (rstate == PN_REJECTED) {
-                    messaging_event mevent(messaging_event::REJECTED, *pe);
-                    delegate_.on_rejected(mevent);
+                    messaging_event mevent(messaging_event::DELIVERY_REJECT, *pe);
+                    delegate_.on_delivery_reject(mevent);
                 }
                 else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
-                    messaging_event mevent(messaging_event::RELEASED, *pe);
-                    delegate_.on_released(mevent);
+                    messaging_event mevent(messaging_event::DELIVERY_RELEASE, *pe);
+                    delegate_.on_delivery_release(mevent);
                 }
 
                 if (dlv.settled()) {
-                    messaging_event mevent(messaging_event::SETTLED, *pe);
-                    delegate_.on_settled(mevent);
+                    messaging_event mevent(messaging_event::DELIVERY_SETTLE, *pe);
+                    delegate_.on_delivery_settle(mevent);
                 }
                 if (auto_settle_)
                     dlv.settle();
@@ -133,14 +133,6 @@ bool is_local_unititialised(pn_state_t state) {
     return state & PN_LOCAL_UNINIT;
 }
 
-bool is_local_closed(pn_state_t state) {
-    return state & PN_LOCAL_CLOSED;
-}
-
-bool is_remote_open(pn_state_t state) {
-    return state & PN_REMOTE_ACTIVE;
-}
-
 } // namespace
 
 void messaging_adapter::on_link_remote_close(event &e) {
@@ -148,18 +140,13 @@ void messaging_adapter::on_link_remote_close(event &e) {
     if (pe) {
         pn_event_t *cevent = pe->pn_event();
         pn_link_t *lnk = pn_event_link(cevent);
-        pn_state_t state = pn_link_state(lnk);
         if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
             messaging_event mevent(messaging_event::LINK_ERROR, *pe);
             on_link_error(mevent);
         }
-        else if (is_local_closed(state)) {
-            messaging_event mevent(messaging_event::LINK_CLOSED, *pe);
-            on_link_closed(mevent);
-        }
         else {
-            messaging_event mevent(messaging_event::LINK_CLOSING, *pe);
-            on_link_closing(mevent);
+            messaging_event mevent(messaging_event::LINK_CLOSE, *pe);
+            on_link_close(mevent);
         }
         pn_link_close(lnk);
     }
@@ -170,18 +157,13 @@ void messaging_adapter::on_session_remote_close(event &e) {
     if (pe) {
         pn_event_t *cevent = pe->pn_event();
         pn_session_t *session = pn_event_session(cevent);
-        pn_state_t state = pn_session_state(session);
         if (pn_condition_is_set(pn_session_remote_condition(session))) {
             messaging_event mevent(messaging_event::SESSION_ERROR, *pe);
             on_session_error(mevent);
         }
-        else if (is_local_closed(state)) {
-            messaging_event mevent(messaging_event::SESSION_CLOSED, *pe);
-            on_session_closed(mevent);
-        }
         else {
-            messaging_event mevent(messaging_event::SESSION_CLOSING, *pe);
-            on_session_closing(mevent);
+            messaging_event mevent(messaging_event::SESSION_CLOSE, *pe);
+            on_session_close(mevent);
         }
         pn_session_close(session);
     }
@@ -192,99 +174,49 @@ void messaging_adapter::on_connection_remote_close(event &e) {
     if (pe) {
         pn_event_t *cevent = pe->pn_event();
         pn_connection_t *connection = pn_event_connection(cevent);
-        pn_state_t state = pn_connection_state(connection);
         if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
             messaging_event mevent(messaging_event::CONNECTION_ERROR, *pe);
             on_connection_error(mevent);
         }
-        else if (is_local_closed(state)) {
-            messaging_event mevent(messaging_event::CONNECTION_CLOSED, *pe);
-            on_connection_closed(mevent);
-        }
         else {
-            messaging_event mevent(messaging_event::CONNECTION_CLOSING, *pe);
-            on_connection_closing(mevent);
+            messaging_event mevent(messaging_event::CONNECTION_CLOSE, *pe);
+            on_connection_close(mevent);
         }
         pn_connection_close(connection);
     }
 }
 
-void messaging_adapter::on_connection_local_open(event &e) {
-    proton_event *pe = dynamic_cast<proton_event*>(&e);
-    if (pe) {
-        pn_connection_t *connection = pn_event_connection(pe->pn_event());
-        if (is_remote_open(pn_connection_state(connection))) {
-            messaging_event mevent(messaging_event::CONNECTION_OPENED, *pe);
-            on_connection_opened(mevent);
-        }
-    }
-}
-
 void messaging_adapter::on_connection_remote_open(event &e) {
     proton_event *pe = dynamic_cast<proton_event*>(&e);
     if (pe) {
+        messaging_event mevent(messaging_event::CONNECTION_OPEN, *pe);
+        on_connection_open(mevent);
         pn_connection_t *connection = pn_event_connection(pe->pn_event());
-        if (is_local_open(pn_connection_state(connection))) {
-            messaging_event mevent(messaging_event::CONNECTION_OPENED, *pe);
-            on_connection_opened(mevent);
-        }
-        else if (is_local_unititialised(pn_connection_state(connection))) {
-            messaging_event mevent(messaging_event::CONNECTION_OPENING, *pe);
-            on_connection_opening(mevent);
+        if (!is_local_open(pn_connection_state(connection)) && is_local_unititialised(pn_connection_state(connection))) {
             pn_connection_open(connection);
         }
     }
 }
 
-void messaging_adapter::on_session_local_open(event &e) {
-    proton_event *pe = dynamic_cast<proton_event*>(&e);
-    if (pe) {
-        pn_session_t *session = pn_event_session(pe->pn_event());
-        if (is_remote_open(pn_session_state(session))) {
-            messaging_event mevent(messaging_event::SESSION_OPENED, *pe);
-            on_session_opened(mevent);
-        }
-    }
-}
-
 void messaging_adapter::on_session_remote_open(event &e) {
     proton_event *pe = dynamic_cast<proton_event*>(&e);
     if (pe) {
+        messaging_event mevent(messaging_event::SESSION_OPEN, *pe);
+        on_session_open(mevent);
         pn_session_t *session = pn_event_session(pe->pn_event());
-        if (is_local_open(pn_session_state(session))) {
-            messaging_event mevent(messaging_event::SESSION_OPENED, *pe);
-            on_session_opened(mevent);
-        }
-        else if (is_local_unititialised(pn_session_state(session))) {
-            messaging_event mevent(messaging_event::SESSION_OPENING, *pe);
-            on_session_opening(mevent);
+        if (!is_local_open(pn_session_state(session)) && is_local_unititialised(pn_session_state(session))) {
             pn_session_open(session);
         }
     }
 }
 
-void messaging_adapter::on_link_local_open(event &e) {
-    proton_event *pe = dynamic_cast<proton_event*>(&e);
-    if (pe) {
-        pn_link_t *link = pn_event_link(pe->pn_event());
-        if (is_remote_open(pn_link_state(link))) {
-            messaging_event mevent(messaging_event::LINK_OPENED, *pe);
-            on_link_opened(mevent);
-        }
-    }
-}
-
 void messaging_adapter::on_link_remote_open(event &e) {
     proton_event *pe = dynamic_cast<proton_event*>(&e);
     if (pe) {
+        messaging_event mevent(messaging_event::LINK_OPEN, *pe);
+        on_link_open(mevent);
         pn_link_t *link = pn_event_link(pe->pn_event());
-        if (is_local_open(pn_link_state(link))) {
-            messaging_event mevent(messaging_event::LINK_OPENED, *pe);
-            on_link_opened(mevent);
-        }
-        else if (is_local_unititialised(pn_link_state(link))) {
-            messaging_event mevent(messaging_event::LINK_OPENING, *pe);
-            on_link_opening(mevent);
+        if (!is_local_open(pn_link_state(link)) && is_local_unititialised(pn_link_state(link))) {
             pn_link_open(link);
         }
     }
@@ -295,35 +227,23 @@ void messaging_adapter::on_transport_tail_closed(event &e) {
     if (pe) {
         pn_connection_t *conn = pn_event_connection(pe->pn_event());
         if (conn && is_local_open(pn_connection_state(conn))) {
-            messaging_event mevent(messaging_event::DISCONNECTED, *pe);
-            delegate_.on_disconnected(mevent);
+            messaging_event mevent(messaging_event::DISCONNECT, *pe);
+            delegate_.on_disconnect(mevent);
         }
     }
 }
 
 
-void messaging_adapter::on_connection_opened(event &e) {
-    delegate_.on_connection_opened(e);
-}
-
-void messaging_adapter::on_session_opened(event &e) {
-    delegate_.on_session_opened(e);
+void messaging_adapter::on_connection_open(event &e) {
+    delegate_.on_connection_open(e);
 }
 
-void messaging_adapter::on_link_opened(event &e) {
-    delegate_.on_link_opened(e);
+void messaging_adapter::on_session_open(event &e) {
+    delegate_.on_session_open(e);
 }
 
-void messaging_adapter::on_connection_opening(event &e) {
-    delegate_.on_connection_opening(e);
-}
-
-void messaging_adapter::on_session_opening(event &e) {
-    delegate_.on_session_opening(e);
-}
-
-void messaging_adapter::on_link_opening(event &e) {
-    delegate_.on_link_opening(e);
+void messaging_adapter::on_link_open(event &e) {
+    delegate_.on_link_open(e);
 }
 
 void messaging_adapter::on_connection_error(event &e) {
@@ -338,32 +258,20 @@ void messaging_adapter::on_link_error(event &e) {
     delegate_.on_link_error(e);
 }
 
-void messaging_adapter::on_connection_closed(event &e) {
-    delegate_.on_connection_closed(e);
-}
-
-void messaging_adapter::on_session_closed(event &e) {
-    delegate_.on_session_closed(e);
-}
-
-void messaging_adapter::on_link_closed(event &e) {
-    delegate_.on_link_closed(e);
-}
-
-void messaging_adapter::on_connection_closing(event &e) {
-    delegate_.on_connection_closing(e);
+void messaging_adapter::on_connection_close(event &e) {
+    delegate_.on_connection_close(e);
     if (peer_close_iserror_)
         on_connection_error(e);
 }
 
-void messaging_adapter::on_session_closing(event &e) {
-    delegate_.on_session_closing(e);
+void messaging_adapter::on_session_close(event &e) {
+    delegate_.on_session_close(e);
     if (peer_close_iserror_)
         on_session_error(e);
 }
 
-void messaging_adapter::on_link_closing(event &e) {
-    delegate_.on_link_closing(e);
+void messaging_adapter::on_link_close(event &e) {
+    delegate_.on_link_close(e);
     if (peer_close_iserror_)
         on_link_error(e);
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index 4b1e781..b360299 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -111,33 +111,34 @@ void messaging_event::dispatch(handler &h) {
     if (handler) {
         switch(type_) {
 
-        case messaging_event::START:       handler->on_start(*this); break;
-        case messaging_event::SENDABLE:    handler->on_sendable(*this); break;
-        case messaging_event::MESSAGE:     handler->on_message(*this); break;
-        case messaging_event::ACCEPTED:    handler->on_accepted(*this); break;
-        case messaging_event::REJECTED:    handler->on_rejected(*this); break;
-        case messaging_event::RELEASED:    handler->on_released(*this); break;
-        case messaging_event::SETTLED:     handler->on_settled(*this); break;
-
-        case messaging_event::CONNECTION_CLOSING:     handler->on_connection_closing(*this); break;
-        case messaging_event::CONNECTION_CLOSED:      handler->on_connection_closed(*this); break;
-        case messaging_event::CONNECTION_ERROR:       handler->on_connection_error(*this); break;
-        case messaging_event::CONNECTION_OPENING:     handler->on_connection_opening(*this); break;
-        case messaging_event::CONNECTION_OPENED:      handler->on_connection_opened(*this); break;
-
-        case messaging_event::LINK_CLOSED:            handler->on_link_closed(*this); break;
-        case messaging_event::LINK_CLOSING:           handler->on_link_closing(*this); break;
-        case messaging_event::LINK_ERROR:             handler->on_link_error(*this); break;
-        case messaging_event::LINK_OPENING:           handler->on_link_opening(*this); break;
-        case messaging_event::LINK_OPENED:            handler->on_link_opened(*this); break;
-
-        case messaging_event::SESSION_CLOSED:         handler->on_session_closed(*this); break;
-        case messaging_event::SESSION_CLOSING:        handler->on_session_closing(*this); break;
-        case messaging_event::SESSION_ERROR:          handler->on_session_error(*this); break;
-        case messaging_event::SESSION_OPENING:        handler->on_session_opening(*this); break;
-        case messaging_event::SESSION_OPENED:         handler->on_session_opened(*this); break;
-
-        case messaging_event::TRANSPORT_CLOSED:       handler->on_transport_closed(*this); break;
+        case messaging_event::START:            handler->on_start(*this); break;
+        case messaging_event::SENDABLE:         handler->on_sendable(*this); break;
+        case messaging_event::MESSAGE:          handler->on_message(*this); break;
+        case messaging_event::DISCONNECT:       handler->on_disconnect(*this); break;
+
+        case messaging_event::CONNECTION_CLOSE: handler->on_connection_close(*this); break;
+        case messaging_event::CONNECTION_ERROR: handler->on_connection_error(*this); break;
+        case messaging_event::CONNECTION_OPEN:  handler->on_connection_open(*this); break;
+
+        case messaging_event::SESSION_CLOSE:    handler->on_session_close(*this); break;
+        case messaging_event::SESSION_ERROR:    handler->on_session_error(*this); break;
+        case messaging_event::SESSION_OPEN:     handler->on_session_open(*this); break;
+
+        case messaging_event::LINK_CLOSE:       handler->on_link_close(*this); break;
+        case messaging_event::LINK_ERROR:       handler->on_link_error(*this); break;
+        case messaging_event::LINK_OPEN:        handler->on_link_open(*this); break;
+
+        case messaging_event::DELIVERY_ACCEPT:  handler->on_delivery_accept(*this); break;
+        case messaging_event::DELIVERY_REJECT:  handler->on_delivery_reject(*this); break;
+        case messaging_event::DELIVERY_RELEASE: handler->on_delivery_release(*this); break;
+        case messaging_event::DELIVERY_SETTLE:  handler->on_delivery_settle(*this); break;
+
+        case messaging_event::TRANSACTION_DECLARE: handler->on_transaction_declare(*this); break;
+        case messaging_event::TRANSACTION_COMMIT:  handler->on_transaction_commit(*this); break;
+        case messaging_event::TRANSACTION_ABORT:   handler->on_transaction_abort(*this); break;
+
+        case messaging_event::TIMER:            handler->on_timer(*this); break;
+
         default:
             throw error(MSG("Unknown messaging event type " << type_));
             break;
@@ -155,36 +156,27 @@ void messaging_event::dispatch(handler &h) {
 std::string messaging_event::name() const {
     switch (type()) {
       case PROTON: return pn_event_type_name(pn_event_type_t(proton_event::type()));
-      case ACCEPTED: return "ACCEPTED";
-      case COMMIT: return "COMMIT";
-      case CONNECTION_CLOSED: return "CONNECTION_CLOSED";
-      case CONNECTION_CLOSING: return "CONNECTION_CLOSING";
+      case START:            return "START";
+      case MESSAGE:          return "MESSAGE";
+      case SENDABLE:         return "SENDABLE";
+      case DISCONNECT:       return "DISCONNECT";
+      case DELIVERY_ACCEPT:  return "DELIVERY_ACCEPT";
+      case DELIVERY_REJECT:  return "DELIVERY_REJECT";
+      case DELIVERY_RELEASE: return "DELIVERY_RELEASE";
+      case DELIVERY_SETTLE:  return "DELIVERY_SETTLE";
+      case CONNECTION_CLOSE: return "CONNECTION_CLOSE";
       case CONNECTION_ERROR: return "CONNECTION_ERROR";
-      case CONNECTION_OPENED: return "CONNECTION_OPENED";
-      case CONNECTION_OPENING: return "CONNECTION_OPENING";
-      case DISCONNECTED: return "DISCONNECTED";
-      case LINK_CLOSED: return "LINK_CLOSED";
-      case LINK_CLOSING: return "LINK_CLOSING";
-      case LINK_OPENED: return "LINK_OPENED";
-      case LINK_OPENING: return "LINK_OPENING";
-      case LINK_ERROR: return "LINK_ERROR";
-      case MESSAGE: return "MESSAGE";
-      case QUIT: return "QUIT";
-      case REJECTED: return "REJECTED";
-      case RELEASED: return "RELEASED";
-      case SENDABLE: return "SENDABLE";
-      case SESSION_CLOSED: return "SESSION_CLOSED";
-      case SESSION_CLOSING: return "SESSION_CLOSING";
-      case SESSION_OPENED: return "SESSION_OPENED";
-      case SESSION_OPENING: return "SESSION_OPENING";
-      case SESSION_ERROR: return "SESSION_ERROR";
-      case SETTLED: return "SETTLED";
-      case START: return "START";
-      case TIMER: return "TIMER";
-      case TRANSACTION_ABORTED: return "TRANSACTION_ABORTED";
-      case TRANSACTION_COMMITTED: return "TRANSACTION_COMMITTED";
-      case TRANSACTION_DECLARED: return "TRANSACTION_DECLARED";
-      case TRANSPORT_CLOSED: return "TRANSPORT_CLOSED";
+      case CONNECTION_OPEN:  return "CONNECTION_OPEN";
+      case LINK_CLOSE:       return "LINK_CLOSE";
+      case LINK_OPEN:        return "LINK_OPEN";
+      case LINK_ERROR:       return "LINK_ERROR";
+      case SESSION_CLOSE:    return "SESSION_CLOSE";
+      case SESSION_OPEN:     return "SESSION_OPEN";
+      case SESSION_ERROR:    return "SESSION_ERROR";
+      case TRANSACTION_ABORT:   return "TRANSACTION_ABORT";
+      case TRANSACTION_COMMIT:  return "TRANSACTION_COMMIT";
+      case TRANSACTION_DECLARE: return "TRANSACTION_DECLARE";
+      case TIMER:            return "TIMER";
       default: return "UNKNOWN";
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.hpp b/proton-c/bindings/cpp/src/messaging_event.hpp
index 2c90c0b..13d2da3 100644
--- a/proton-c/bindings/cpp/src/messaging_event.hpp
+++ b/proton-c/bindings/cpp/src/messaging_event.hpp
@@ -44,36 +44,27 @@ class messaging_event : public proton_event
     /** Event types for a messaging_handler */
     enum event_type {
         PROTON = 0,  // Wrapped pn_event_t
-        ACCEPTED,
-        COMMIT,
-        CONNECTION_CLOSED,
-        CONNECTION_CLOSING,
-        CONNECTION_ERROR,
-        CONNECTION_OPENED,
-        CONNECTION_OPENING,
-        DISCONNECTED,
-        LINK_CLOSED,
-        LINK_CLOSING,
-        LINK_OPENED,
-        LINK_OPENING,
-        LINK_ERROR,
+        START,
         MESSAGE,
-        QUIT,
-        REJECTED,
-        RELEASED,
         SENDABLE,
-        SESSION_CLOSED,
-        SESSION_CLOSING,
-        SESSION_OPENED,
-        SESSION_OPENING,
+        DISCONNECT,
+        CONNECTION_OPEN,
+        CONNECTION_CLOSE,
+        CONNECTION_ERROR,
+        LINK_OPEN,
+        LINK_CLOSE,
+        LINK_ERROR,
+        SESSION_OPEN,
+        SESSION_CLOSE,
         SESSION_ERROR,
-        SETTLED,
-        START,
-        TIMER,
-        TRANSACTION_ABORTED,
-        TRANSACTION_COMMITTED,
-        TRANSACTION_DECLARED,
-        TRANSPORT_CLOSED
+        DELIVERY_ACCEPT,
+        DELIVERY_REJECT,
+        DELIVERY_RELEASE,
+        DELIVERY_SETTLE,
+        TRANSACTION_DECLARE,
+        TRANSACTION_COMMIT,
+        TRANSACTION_ABORT,
+        TIMER
     };
 
     messaging_event(pn_event_t *, proton_event::event_type, class event_loop *);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/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 9496440..2f7383f 100644
--- a/proton-c/bindings/cpp/src/messaging_handler.cpp
+++ b/proton-c/bindings/cpp/src/messaging_handler.cpp
@@ -81,33 +81,26 @@ void messaging_handler::create_helpers() {
 
 messaging_handler::~messaging_handler(){}
 
-void messaging_handler::on_accepted(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_closed(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_closing(event &e) { on_unhandled(e); }
+void messaging_handler::on_delivery_accept(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_close(event &e) { on_unhandled(e); }
 void messaging_handler::on_connection_error(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_opened(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_opening(event &e) { on_unhandled(e); }
-void messaging_handler::on_disconnected(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_closed(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_closing(event &e) { on_unhandled(e); }
+void messaging_handler::on_connection_open(event &e) { on_unhandled(e); }
+void messaging_handler::on_disconnect(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_close(event &e) { on_unhandled(e); }
 void messaging_handler::on_link_error(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_opened(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_opening(event &e) { on_unhandled(e); }
+void messaging_handler::on_link_open(event &e) { on_unhandled(e); }
 void messaging_handler::on_message(event &e) { on_unhandled(e); }
-void messaging_handler::on_rejected(event &e) { on_unhandled(e); }
-void messaging_handler::on_released(event &e) { on_unhandled(e); }
+void messaging_handler::on_delivery_reject(event &e) { on_unhandled(e); }
+void messaging_handler::on_delivery_release(event &e) { on_unhandled(e); }
 void messaging_handler::on_sendable(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_closed(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_closing(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_close(event &e) { on_unhandled(e); }
 void messaging_handler::on_session_error(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_opened(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_opening(event &e) { on_unhandled(e); }
-void messaging_handler::on_settled(event &e) { on_unhandled(e); }
+void messaging_handler::on_session_open(event &e) { on_unhandled(e); }
+void messaging_handler::on_delivery_settle(event &e) { on_unhandled(e); }
 void messaging_handler::on_start(event &e) { on_unhandled(e); }
 void messaging_handler::on_timer(event &e) { on_unhandled(e); }
-void messaging_handler::on_transaction_aborted(event &e) { on_unhandled(e); }
-void messaging_handler::on_transaction_committed(event &e) { on_unhandled(e); }
-void messaging_handler::on_transaction_declared(event &e) { on_unhandled(e); }
-void messaging_handler::on_transport_closed(event &e) { on_unhandled(e); }
+void messaging_handler::on_transaction_abort(event &e) { on_unhandled(e); }
+void messaging_handler::on_transaction_commit(event &e) { on_unhandled(e); }
+void messaging_handler::on_transaction_declare(event &e) { on_unhandled(e); }
 
 }


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


[39/50] [abbrv] qpid-proton git commit: PROTON-1082: add support for setting and inspecting link properties conveyed during link attach

Posted by ac...@apache.org.
PROTON-1082: add support for setting and inspecting link properties conveyed during link attach

This closes #52


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

Branch: refs/heads/go1
Commit: e9e0f31c6894736e54d7d5b624bf3245f704d9af
Parents: 0a6e0e7
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Dec 21 17:26:49 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Dec 21 17:35:23 2015 +0000

----------------------------------------------------------------------
 .../org/apache/qpid/proton/engine/Link.java     |  25 +++
 .../qpid/proton/engine/impl/LinkImpl.java       |  27 +++
 .../qpid/proton/engine/impl/TransportImpl.java  |   7 +
 .../qpid/proton/systemtests/LinkTest.java       | 165 +++++++++++++++++++
 4 files changed, 224 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e9e0f31c/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
index 0ea0e74..1b214bc 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Link.java
@@ -21,7 +21,9 @@
 package org.apache.qpid.proton.engine;
 
 import java.util.EnumSet;
+import java.util.Map;
 
+import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
 import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
 import org.apache.qpid.proton.amqp.transport.Source;
@@ -180,6 +182,29 @@ public interface Link extends Endpoint
     @Deprecated
     void setRemoteSenderSettleMode(SenderSettleMode remoteSenderSettleMode);
 
+    /**
+     * Gets the local link properties.
+     *
+     * @see #setProperties(Map)
+     */
+    Map<Symbol, Object> getProperties();
+
+    /**
+     * Sets the local link properties, to be conveyed to the peer via the Attach frame when
+     * attaching the link to the session.
+     *
+     * Must be called during link setup, i.e. before calling the {@link #open()} method.
+     */
+    void setProperties(Map<Symbol, Object> properties);
+
+    /**
+     * Gets the remote link properties, as conveyed from the peer via the Attach frame
+     * when attaching the link to the session.
+     *
+     * @return the properties Map conveyed by the peer, or null if there was none.
+     */
+    Map<Symbol, Object> getRemoteProperties();
+
     public int drained();
 
     public int getRemoteCredit();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e9e0f31c/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
index 6b63b9a..8a2acf0 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
@@ -21,7 +21,9 @@
 package org.apache.qpid.proton.engine.impl;
 
 import java.util.EnumSet;
+import java.util.Map;
 
+import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
 import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
 import org.apache.qpid.proton.amqp.transport.Source;
@@ -57,6 +59,8 @@ public abstract class LinkImpl extends EndpointImpl implements Link
     private LinkNode<LinkImpl> _node;
     private boolean _drain;
     private boolean _detached;
+    private Map<Symbol, Object> _properties;
+    private Map<Symbol, Object> _remoteProperties;
 
     LinkImpl(SessionImpl session, String name)
     {
@@ -373,6 +377,29 @@ public abstract class LinkImpl extends EndpointImpl implements Link
     }
 
     @Override
+    public Map<Symbol, Object> getProperties()
+    {
+        return _properties;
+    }
+
+    @Override
+    public void setProperties(Map<Symbol, Object> properties)
+    {
+        _properties = properties;
+    }
+
+    @Override
+    public Map<Symbol, Object> getRemoteProperties()
+    {
+        return _remoteProperties;
+    }
+
+    void setRemoteProperties(Map<Symbol, Object> remoteProperties)
+    {
+        _remoteProperties = remoteProperties;
+    }
+
+    @Override
     public int drained()
     {
         int drained = 0;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e9e0f31c/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index f318319..a98a6f1 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -769,6 +769,11 @@ public class TransportImpl extends EndpointImpl
                                 attach.setTarget(link.getTarget());
                             }
 
+                            if(link.getProperties() != null)
+                            {
+                                attach.setProperties(link.getProperties());
+                            }
+
                             attach.setRole(endpoint instanceof ReceiverImpl ? Role.RECEIVER : Role.SENDER);
 
                             if(link instanceof SenderImpl)
@@ -1168,6 +1173,8 @@ public class TransportImpl extends EndpointImpl
                 link.setRemoteReceiverSettleMode(attach.getRcvSettleMode());
                 link.setRemoteSenderSettleMode(attach.getSndSettleMode());
 
+                link.setRemoteProperties(attach.getProperties());
+
                 transportLink.setName(attach.getName());
                 transportLink.setRemoteHandle(handle);
                 transportSession.addLinkRemoteHandle(transportLink, handle);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e9e0f31c/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java
new file mode 100644
index 0000000..0811f16
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/LinkTest.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.proton.systemtests;
+
+import static java.util.EnumSet.of;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
+import static org.apache.qpid.proton.engine.EndpointState.UNINITIALIZED;
+import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.qpid.proton.Proton;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.messaging.Source;
+import org.apache.qpid.proton.amqp.messaging.Target;
+import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
+import org.apache.qpid.proton.amqp.transport.SenderSettleMode;
+import org.apache.qpid.proton.engine.Sender;
+import org.junit.Test;
+
+public class LinkTest extends EngineTestBase
+{
+    private static final Logger LOGGER = Logger.getLogger(LinkTest.class.getName());
+
+    private static final Symbol RCV_PROP = Symbol.valueOf("ReceiverPropName");
+    private static final Integer RCV_PROP_VAL = 1234;
+    private static final Symbol SND_PROP = Symbol.valueOf("SenderPropName");
+    private static final Integer SND_PROP_VAL = 5678;
+
+    private final String _sourceAddress = getServer().containerId + "-link1-source";
+
+    @Test
+    public void testProperties() throws Exception
+    {
+        Map<Symbol, Object> receiverProps = new HashMap<>();
+        receiverProps.put(RCV_PROP, RCV_PROP_VAL);
+
+        Map<Symbol, Object> senderProps = new HashMap<>();
+        senderProps.put(SND_PROP, SND_PROP_VAL);
+
+
+        LOGGER.fine(bold("======== About to create transports"));
+
+        getClient().transport = Proton.transport();
+        ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
+
+        getServer().transport = Proton.transport();
+        ProtocolTracerEnabler.setProtocolTracer(getServer().transport, "            " + TestLoggingHelper.SERVER_PREFIX);
+
+        doOutputInputCycle();
+
+        getClient().connection = Proton.connection();
+        getClient().transport.bind(getClient().connection);
+
+        getServer().connection = Proton.connection();
+        getServer().transport.bind(getServer().connection);
+
+
+        LOGGER.fine(bold("======== About to open connections"));
+        getClient().connection.open();
+        getServer().connection.open();
+
+        doOutputInputCycle();
+
+
+        LOGGER.fine(bold("======== About to open sessions"));
+        getClient().session = getClient().connection.session();
+        getClient().session.open();
+
+        pumpClientToServer();
+
+        getServer().session = getServer().connection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
+        assertEndpointState(getServer().session, UNINITIALIZED, ACTIVE);
+
+        getServer().session.open();
+        assertEndpointState(getServer().session, ACTIVE, ACTIVE);
+
+        pumpServerToClient();
+        assertEndpointState(getClient().session, ACTIVE, ACTIVE);
+
+
+        LOGGER.fine(bold("======== About to create reciever"));
+
+        getClient().source = new Source();
+        getClient().source.setAddress(_sourceAddress);
+
+        getClient().target = new Target();
+        getClient().target.setAddress(null);
+
+        getClient().receiver = getClient().session.receiver("link1");
+        getClient().receiver.setTarget(getClient().target);
+        getClient().receiver.setSource(getClient().source);
+
+        getClient().receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
+        getClient().receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
+
+        // Set the recievers properties
+        getClient().receiver.setProperties(receiverProps);
+
+        assertEndpointState(getClient().receiver, UNINITIALIZED, UNINITIALIZED);
+
+        getClient().receiver.open();
+        assertEndpointState(getClient().receiver, ACTIVE, UNINITIALIZED);
+
+        pumpClientToServer();
+
+
+        LOGGER.fine(bold("======== About to set up implicitly created sender"));
+
+        getServer().sender = (Sender) getServer().connection.linkHead(of(UNINITIALIZED), of(ACTIVE));
+
+        getServer().sender.setReceiverSettleMode(getServer().sender.getRemoteReceiverSettleMode());
+        getServer().sender.setSenderSettleMode(getServer().sender.getRemoteSenderSettleMode());
+
+        org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = getServer().sender.getRemoteSource();
+        getServer().sender.setSource(serverRemoteSource);
+
+        // Set the senders properties
+        getServer().sender.setProperties(senderProps);
+
+        assertEndpointState(getServer().sender, UNINITIALIZED, ACTIVE);
+        getServer().sender.open();
+
+        assertEndpointState(getServer().sender, ACTIVE, ACTIVE);
+
+        pumpServerToClient();
+
+        assertEndpointState(getClient().receiver, ACTIVE, ACTIVE);
+
+        // Verify server side got the clients receiver properties as expected
+        Map<Symbol, Object> serverRemoteProperties = getServer().sender.getRemoteProperties();
+        assertNotNull("Server had no remote properties", serverRemoteProperties);
+        assertEquals("Server remote properties not expected size", 1, serverRemoteProperties.size());
+        assertTrue("Server remote properties lack expected key: " + RCV_PROP, serverRemoteProperties.containsKey(RCV_PROP));
+        assertEquals("Server remote properties contain unexpected value for key: " + RCV_PROP, RCV_PROP_VAL, serverRemoteProperties.get(RCV_PROP));
+
+        // Verify the client side got the servers sender properties as expected
+        Map<Symbol, Object> clientRemoteProperties = getClient().receiver.getRemoteProperties();
+        assertNotNull("Client had no remote properties", clientRemoteProperties);
+        assertEquals("Client remote properties not expected size", 1, clientRemoteProperties.size());
+        assertTrue("Client remote properties lack expected key: " + SND_PROP, clientRemoteProperties.containsKey(SND_PROP));
+        assertEquals("Client remote properties contain unexpected value for key: " + SND_PROP, SND_PROP_VAL, clientRemoteProperties.get(SND_PROP));
+    }
+}
\ No newline at end of file


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


[25/50] [abbrv] qpid-proton git commit: PROTON-1067: python messenger: cannot acknowledge messages, messenger forces auto-ack or pre-settled.

Posted by ac...@apache.org.
PROTON-1067: python messenger: cannot acknowledge messages, messenger forces auto-ack or pre-settled.

Change send-settle-mode defaults on outgoing links (but respect user settings if
there are any)

- sender: if outgoing_window, default to PN_SND_MIXED - let the application decide.
- reciever: if incoming_window, default to PN_SND_UNSETTLED - let the app settle.

Clearly if the app sets an incoming window, they want to settle messages
manually so requesting "UNSETTLED" by default makes no sense. It works with
existing messenger tests and examples because links are always established from
the sending end, but making a receiving (subscribing) link to a broker such as
qpidd shows the problem: messenger always requests SND_SETTLED, the broker
obliges, so it is impossible for the receiver to control settlement.


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

Branch: refs/heads/go1
Commit: 1da4b120121463170030ab762ff52815657dd152
Parents: 95eece7
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 14 10:55:47 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 14 12:09:01 2015 -0500

----------------------------------------------------------------------
 proton-c/src/messenger/messenger.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1da4b120/proton-c/src/messenger/messenger.c
----------------------------------------------------------------------
diff --git a/proton-c/src/messenger/messenger.c b/proton-c/src/messenger/messenger.c
index 277642f..b08e00a 100644
--- a/proton-c/src/messenger/messenger.c
+++ b/proton-c/src/messenger/messenger.c
@@ -106,7 +106,7 @@ struct pn_messenger_t {
   int draining;      // # links in drain state
   int connection_error;
   int flags;
-  pn_snd_settle_mode_t snd_settle_mode;
+  int snd_settle_mode;          /* pn_snd_settle_mode_t or -1 for unset */
   pn_rcv_settle_mode_t rcv_settle_mode;
   pn_tracer_t tracer;
   pn_ssl_verify_mode_t ssl_peer_authentication_mode;
@@ -665,7 +665,7 @@ pn_messenger_t *pn_messenger(const char *name)
     m->domain = pn_string(NULL);
     m->connection_error = 0;
     m->flags = PN_FLAGS_ALLOW_INSECURE_MECHS; // TODO: Change this back to 0 for the Proton 0.11 release
-    m->snd_settle_mode = PN_SND_SETTLED;
+    m->snd_settle_mode = -1;    /* Default depends on sender/receiver */
     m->rcv_settle_mode = PN_RCV_FIRST;
     m->tracer = NULL;
     m->ssl_peer_authentication_mode = PN_SSL_VERIFY_PEER_NAME;
@@ -1748,11 +1748,17 @@ pn_link_t *pn_messenger_link(pn_messenger_t *messenger, const char *address,
 
   if ((sender && pn_messenger_get_outgoing_window(messenger)) ||
       (!sender && pn_messenger_get_incoming_window(messenger))) {
-    // use required settlement (defaults to sending pre-settled messages)
-    pn_link_set_snd_settle_mode(link, messenger->snd_settle_mode);
+    if (messenger->snd_settle_mode == -1) { /* Choose default based on sender/receiver */
+      /* For a sender use MIXED so the application can decide whether each
+         message is settled or not. For a receiver request UNSETTLED, since the
+         user set an incoming_window which means they want to decide settlement.
+      */
+      pn_link_set_snd_settle_mode(link, sender ? PN_SND_MIXED : PN_SND_UNSETTLED);
+    } else {                    /* Respect user setting */
+      pn_link_set_snd_settle_mode(link, (pn_snd_settle_mode_t)messenger->snd_settle_mode);
+    }
     pn_link_set_rcv_settle_mode(link, messenger->rcv_settle_mode);
   }
-  // XXX
   if (pn_streq(name, "#")) {
     if (pn_link_is_sender(link)) {
       pn_terminus_set_dynamic(pn_link_target(link), true);


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


[47/50] [abbrv] qpid-proton git commit: PROTON-1085: c++: Replace all operator== and < members with free functions, drop comparable template.

Posted by ac...@apache.org.
PROTON-1085: c++: Replace all operator== and < members with free functions, drop comparable template.


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

Branch: refs/heads/go1
Commit: 117bb7cb0bcb588f91c8a2a6a45b0cb9d211d7d6
Parents: 1622d0e
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 29 13:54:02 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 29 15:56:44 2015 -0500

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/comparable.hpp  | 38 --------------------
 .../bindings/cpp/include/proton/duration.hpp    |  8 ++---
 proton-c/bindings/cpp/include/proton/object.hpp |  5 ++-
 proton-c/bindings/cpp/include/proton/scalar.hpp |  6 ++--
 proton-c/bindings/cpp/include/proton/types.hpp  | 15 ++++----
 proton-c/bindings/cpp/include/proton/value.hpp  |  8 ++---
 proton-c/bindings/cpp/src/scalar.cpp            |  1 -
 proton-c/bindings/cpp/src/value.cpp             |  4 +--
 8 files changed, 21 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/include/proton/comparable.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/comparable.hpp b/proton-c/bindings/cpp/include/proton/comparable.hpp
deleted file mode 100644
index 2649a8d..0000000
--- a/proton-c/bindings/cpp/include/proton/comparable.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef COMPARABLE_HPP
-#define COMPARABLE_HPP
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-namespace proton {
-
-///@cond INTERNAL
-
-/// Internal base class to provide comparison operators. T must provide < and ==.
-template <class T> struct comparable {
-  friend bool operator>(const T &a, const T &b) { return b < a; }
-  friend bool operator<=(const T &a, const T &b) { return !(a > b); }
-  friend bool operator>=(const T &a, const T &b) { return !(a < b); }
-  friend bool operator!=(const T &a, const T &b) { return !(a == b); }
-};
-
-///@endcond
-
-}
-
-#endif // COMPARABLE_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/include/proton/duration.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/duration.hpp b/proton-c/bindings/cpp/include/proton/duration.hpp
index e562c47..cea785f 100644
--- a/proton-c/bindings/cpp/include/proton/duration.hpp
+++ b/proton-c/bindings/cpp/include/proton/duration.hpp
@@ -28,21 +28,21 @@
 namespace proton {
 
 /** Duration in milliseconds. */
-class duration : public comparable<duration>
+class duration
 {
   public:
     amqp_ulong milliseconds;
     explicit duration(amqp_ulong ms = 0) : milliseconds(ms) {}
 
-    bool operator<(duration d) { return milliseconds < d.milliseconds; }
-    bool operator==(duration d) { return milliseconds == d.milliseconds; }
-
     PN_CPP_EXTERN static const duration FOREVER; ///< Wait for ever
     PN_CPP_EXTERN static const duration IMMEDIATE; ///< Don't wait at all
     PN_CPP_EXTERN static const duration SECOND; ///< One second
     PN_CPP_EXTERN static const duration MINUTE; ///< One minute
 };
 
+inline bool operator<(duration x, duration y) { return x.milliseconds < y.milliseconds; }
+inline bool operator==(duration x, duration y) { return x.milliseconds == y.milliseconds; }
+
 inline duration operator*(duration d, amqp_ulong n) { return duration(d.milliseconds*n); }
 inline duration operator*(amqp_ulong n, duration d) { return d * n; }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index e98a956..32bc086 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -21,7 +21,6 @@
 
 #include "proton/config.hpp"
 #include "proton/export.hpp"
-#include "proton/comparable.hpp"
 
 #include <memory>
 
@@ -34,7 +33,7 @@ class pn_ptr_base {
     PN_CPP_EXTERN static void decref(void* p);
 };
 
-template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_base {
+template <class T> class pn_ptr : private pn_ptr_base {
   public:
     pn_ptr() : ptr_(0) {}
     pn_ptr(T* p) : ptr_(p) { incref(ptr_); }
@@ -71,7 +70,7 @@ template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>::take_owner
 /**
  * Base class for proton object types
  */
-template <class T> class object : public comparable<object<T> > {
+template <class T> class object {
   public:
     bool operator!() const { return !object_; }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp
index 6fe29fa..d135ab6 100644
--- a/proton-c/bindings/cpp/include/proton/scalar.hpp
+++ b/proton-c/bindings/cpp/include/proton/scalar.hpp
@@ -29,7 +29,7 @@ class encoder;
 class decoder;
 
 /** scalar holds an instance of any scalar AMQP type. */
-class scalar : public comparable<scalar> {
+class scalar {
   public:
     PN_CPP_EXTERN scalar();
     PN_CPP_EXTERN scalar(const scalar&);
@@ -130,9 +130,9 @@ class scalar : public comparable<scalar> {
 };
 
 ///@internal base for restricted scalar types
-class restricted_scalar : public comparable<restricted_scalar> {
+class restricted_scalar {
   public:
-    operator scalar() const { return scalar_; }
+    operator const scalar&() const { return scalar_; }
     type_id type() const { return scalar_.type(); }
 
     ///@name as_ methods do "loose" conversion, they will convert the scalar's

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index db5989b..062566a 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -25,7 +25,6 @@
 
 #include "proton/export.hpp"
 #include "proton/error.hpp"
-#include "proton/comparable.hpp"
 
 #include <proton/codec.h>
 #include <proton/type_compat.h>
@@ -141,7 +140,7 @@ struct amqp_binary : public std::string {
 };
 
 /// Template for opaque proton proton types that can be treated as byte arrays.
-template <class P> struct opaque: public comparable<opaque<P> > {
+template <class P> struct opaque {
     P value;
     opaque(const P& p=P()) : value(p) {}
     operator P() const { return value; }
@@ -153,11 +152,11 @@ template <class P> struct opaque: public comparable<opaque<P> > {
     const char* end() const { return reinterpret_cast<const char*>(&value)+size(); }
     char& operator[](size_t i) { return *(begin()+i); }
     const char& operator[](size_t i) const { return *(begin()+i); }
-
-    bool operator==(const opaque& x) const { return std::equal(begin(), end(), x.begin()); }
-    bool operator<(const opaque& x) const { return std::lexicographical_compare(begin(), end(), x.begin(), x.end()); }
 };
 
+template <class T> bool operator==(const opaque<T>& x, const opaque<T>& y) { return std::equal(x.begin(), x.end(), y.begin()); }
+template <class T> bool operator<(const opaque<T>& x, const opaque<T>& y) { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
+
 /// AMQP 16-byte UUID.
 typedef opaque<pn_uuid_t> amqp_uuid;
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_uuid&);
@@ -172,13 +171,13 @@ typedef opaque<pn_decimal128_t> amqp_decimal128;
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal128&);
 
 /// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
-struct amqp_timestamp : public comparable<amqp_timestamp> {
+struct amqp_timestamp {
     pn_timestamp_t milliseconds;
     amqp_timestamp(::int64_t ms=0) : milliseconds(ms) {}
     operator pn_timestamp_t() const { return milliseconds; }
-    bool operator==(const amqp_timestamp& x) { return milliseconds == x.milliseconds; }
-    bool operator<(const amqp_timestamp& x) { return milliseconds < x.milliseconds; }
 };
+inline bool operator==(amqp_timestamp x, amqp_timestamp y) { return x.milliseconds == y.milliseconds; }
+inline bool operator<(amqp_timestamp x, amqp_timestamp y) { return x.milliseconds < y.milliseconds; }
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_timestamp&);
 
 // TODO aconway 2015-06-16: described types.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index dedcadd..1ecaaa5 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -40,7 +40,7 @@ class decoder;
  * Assigning to a proton::value follows the encoder rules, converting from a
  * proton::value (or calling proton::value::get) follows the decoder rules.
  */
-class value : public comparable<value> {
+class value {
   public:
     PN_CPP_EXTERN value();
     PN_CPP_EXTERN value(const value&);
@@ -73,12 +73,10 @@ class value : public comparable<value> {
     /** Get the value. */
     template<class T> T get() const { T t; get(t); return t; }
 
-    // FIXME aconway 2015-12-28: friend ops.
-    PN_CPP_EXTERN bool operator==(const value& x) const;
-    PN_CPP_EXTERN bool operator<(const value& x) const;
-
     PN_CPP_EXTERN void swap(value& v);
 
+  friend PN_CPP_EXTERN bool operator==(const value& x, const value& y);
+  friend PN_CPP_EXTERN bool operator<(const value& x, const value& y);
   friend PN_CPP_EXTERN class encoder operator<<(class encoder e, const value& dv);
   friend PN_CPP_EXTERN class decoder operator>>(class decoder d, value& dv);
   friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream& o, const value& dv);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/src/scalar.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar.cpp b/proton-c/bindings/cpp/src/scalar.cpp
index 9e8d124..d52c8eb 100644
--- a/proton-c/bindings/cpp/src/scalar.cpp
+++ b/proton-c/bindings/cpp/src/scalar.cpp
@@ -137,7 +137,6 @@ std::string scalar::as_string() const {
 }
 
 namespace {
-template<class T> int opaque_cmp(const T& x, const T& y) { return memcmp(&x, &y, sizeof(T)); }
 
 template <class T, class F> T type_switch(const scalar& a, F f) {
     switch(a.type()) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/117bb7cb/proton-c/bindings/cpp/src/value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value.cpp b/proton-c/bindings/cpp/src/value.cpp
index bf652c5..9e8448c 100644
--- a/proton-c/bindings/cpp/src/value.cpp
+++ b/proton-c/bindings/cpp/src/value.cpp
@@ -54,9 +54,9 @@ class decoder value::decoder() const { data_.decoder().rewind(); return data_.de
 
 type_id value::type() const { return decoder().type(); }
 
-bool value::operator==(const value& x) const { return data_.equal(x.data_); }
+bool operator==(const value& x, const value& y) { return x.data_.equal(y.data_); }
 
-bool value::operator<(const value& x) const { return data_.less(x.data_); }
+bool operator<(const value& x, const value& y) { return x.data_.less(y.data_); }
 
 std::ostream& operator<<(std::ostream& o, const value& v) {
     // pn_inspect prints strings with quotes which is not normal in C++.


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


[28/50] [abbrv] qpid-proton git commit: PROTON-1077: adjust the receivers transport credit state by the same delta as the link credit state when deliveryCount advances to keep them in sync

Posted by ac...@apache.org.
PROTON-1077: adjust the receivers transport credit state by the same delta as the link credit state when deliveryCount advances to keep them in sync


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

Branch: refs/heads/go1
Commit: a8d87bb3c6d54458d7041d38374feb8b7cf30667
Parents: a4a21be
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Dec 15 13:00:41 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Dec 15 15:21:21 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/qpid/proton/engine/impl/TransportReceiver.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a8d87bb3/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
index fcaec28..29d97c4 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportReceiver.java
@@ -48,7 +48,7 @@ class TransportReceiver extends TransportLink<ReceiverImpl>
         if(delta > 0)
         {
             getLink().addCredit(-delta);
-            setLinkCredit(getRemoteLinkCredit());
+            addCredit(-delta);
             setDeliveryCount(getRemoteDeliveryCount());
             getLink().setDrained(getLink().getDrained() + delta);
         }


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


[35/50] [abbrv] qpid-proton git commit: NO-JIRA: cpp: Add proton::atom type to efficiently represent arbitrary atomic types.

Posted by ac...@apache.org.
NO-JIRA: cpp: Add proton::atom type to efficiently represent arbitrary atomic types.

The type is not yet used but is unit tested.
This type will be used for message maps that are restricted to have atomic types.


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

Branch: refs/heads/go1
Commit: 02d6ba686dba7f29f98d2f52503ca820b9b9cac9
Parents: d3fe232
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 16 17:46:27 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Dec 17 15:33:52 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   2 +
 proton-c/bindings/cpp/include/proton/atom.hpp   | 122 ++++++++++++
 proton-c/bindings/cpp/include/proton/data.hpp   |   2 +-
 .../bindings/cpp/include/proton/type_traits.hpp |   9 +-
 proton-c/bindings/cpp/include/proton/types.hpp  |  30 ++-
 proton-c/bindings/cpp/src/atom.cpp              | 184 +++++++++++++++++++
 proton-c/bindings/cpp/src/atom_test.cpp         | 105 +++++++++++
 proton-c/bindings/cpp/src/data.cpp              |   2 +-
 proton-c/bindings/cpp/src/decoder.cpp           |   2 +-
 .../bindings/cpp/src/encode_decode_test.cpp     |   4 +-
 proton-c/bindings/cpp/src/interop_test.cpp      |   8 +-
 proton-c/bindings/cpp/src/message_test.cpp      |   2 +-
 proton-c/bindings/cpp/src/test_bits.hpp         |  25 ++-
 proton-c/bindings/cpp/src/types.cpp             |  37 +++-
 14 files changed, 499 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 6352f66..78df0b5 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -26,6 +26,7 @@ include_directories(
 
 set(qpid-proton-cpp-source
   src/acceptor.cpp
+  src/atom.cpp
   src/blocking_connection.cpp
   src/blocking_connection_impl.cpp
   src/blocking_fetcher.cpp
@@ -169,3 +170,4 @@ endmacro(add_cpp_test)
 add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests)
 add_cpp_test(message_test)
 add_cpp_test(encode_decode_test)
+add_cpp_test(atom_test)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/include/proton/atom.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/atom.hpp b/proton-c/bindings/cpp/include/proton/atom.hpp
new file mode 100644
index 0000000..ce2a385
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/atom.hpp
@@ -0,0 +1,122 @@
+#ifndef ATOM_HPP
+#define ATOM_HPP
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/types.hpp"
+#include <iosfwd>
+
+namespace proton {
+
+class atom;
+
+/** atom holds an instance of an atomic proton type. */
+class atom : public comparable<atom> {
+  public:
+    PN_CPP_EXTERN atom();
+    // Use default assign and copy.
+
+    /// Type for the value in the atom, NULL_TYPE if empty()
+    PN_CPP_EXTERN type_id type() const;
+    /// True if the atom is empty.
+    PN_CPP_EXTERN bool empty() const;
+
+    ///@name Create an atom, type() is deduced from the C++ type of the value.
+    ///@{
+    PN_CPP_EXTERN explicit atom(bool);
+    PN_CPP_EXTERN explicit atom(uint8_t);
+    PN_CPP_EXTERN explicit atom(int8_t);
+    PN_CPP_EXTERN explicit atom(uint16_t);
+    PN_CPP_EXTERN explicit atom(int16_t);
+    PN_CPP_EXTERN explicit atom(uint32_t);
+    PN_CPP_EXTERN explicit atom(int32_t);
+    PN_CPP_EXTERN explicit atom(uint64_t);
+    PN_CPP_EXTERN explicit atom(int64_t);
+    PN_CPP_EXTERN explicit atom(wchar_t);
+    PN_CPP_EXTERN explicit atom(float);
+    PN_CPP_EXTERN explicit atom(double);
+    PN_CPP_EXTERN explicit atom(amqp_timestamp);
+    PN_CPP_EXTERN explicit atom(const amqp_decimal32&);
+    PN_CPP_EXTERN explicit atom(const amqp_decimal64&);
+    PN_CPP_EXTERN explicit atom(const amqp_decimal128&);
+    PN_CPP_EXTERN explicit atom(const amqp_uuid&);
+    PN_CPP_EXTERN explicit atom(const amqp_string&);
+    PN_CPP_EXTERN explicit atom(const amqp_symbol&);
+    PN_CPP_EXTERN explicit atom(const amqp_binary&);
+    PN_CPP_EXTERN explicit atom(const std::string& s); ///< Treated as an AMQP string
+    PN_CPP_EXTERN explicit atom(const char* s);        ///< Treated as an AMQP string
+    ///@}
+
+    /// Assign to an atom using the same rules as construction.
+    template <class T> atom& operator=(T x) { return *this = atom(x); }
+
+    ///@name get(T&) extracts the value if the types match exactly,
+    ///i.e. if `type() == type_id_of<T>::value`
+    /// throws type_mismatch otherwise.
+    ///@{
+    PN_CPP_EXTERN void get(bool&) const;
+    PN_CPP_EXTERN void get(uint8_t&) const;
+    PN_CPP_EXTERN void get(int8_t&) const;
+    PN_CPP_EXTERN void get(uint16_t&) const;
+    PN_CPP_EXTERN void get(int16_t&) const;
+    PN_CPP_EXTERN void get(uint32_t&) const;
+    PN_CPP_EXTERN void get(int32_t&) const;
+    PN_CPP_EXTERN void get(uint64_t&) const;
+    PN_CPP_EXTERN void get(int64_t&) const;
+    PN_CPP_EXTERN void get(wchar_t&) const;
+    PN_CPP_EXTERN void get(float&) const;
+    PN_CPP_EXTERN void get(double&) const;
+    PN_CPP_EXTERN void get(amqp_timestamp&) const;
+    PN_CPP_EXTERN void get(amqp_decimal32&) const;
+    PN_CPP_EXTERN void get(amqp_decimal64&) const;
+    PN_CPP_EXTERN void get(amqp_decimal128&) const;
+    PN_CPP_EXTERN void get(amqp_uuid&) const;
+    PN_CPP_EXTERN void get(amqp_string&) const;
+    PN_CPP_EXTERN void get(amqp_symbol&) const;
+    PN_CPP_EXTERN void get(amqp_binary&) const;
+    PN_CPP_EXTERN void get(std::string&) const; ///< Treated as an AMQP string
+    ///@}
+
+    ///@ get<T>() is like get(T&) but returns the value..
+    template<class T> T get() const { T x; get(x); return x; }
+
+    ///@name as_ methods do "loose" conversion, they will convert the atom's
+    ///value to the requested type if possible, else throw type_mismatch
+    ///@{
+    PN_CPP_EXTERN int64_t as_int() const;     ///< Allowed if type_id_integral(type())
+    PN_CPP_EXTERN uint64_t as_uint() const;   ///< Allowed if type_id_integral(type())
+    PN_CPP_EXTERN double as_double() const;    ///< Allowed if type_id_floating_point(type())
+    PN_CPP_EXTERN std::string as_string() const; ///< Allowed if type_id_string_like(type())
+    ///@}
+
+    PN_CPP_EXTERN bool operator==(const atom& x) const;
+    /// Note if the values are of different type(), operator< will compare the type()
+    PN_CPP_EXTERN bool operator<(const atom& x) const;
+
+  PN_CPP_EXTERN friend std::ostream& operator<<(std::ostream&, const atom&);
+
+  private:
+    void ok(pn_type_t) const;
+    void set(const std::string&);
+    pn_atom_t atom_;
+    std::string str_;           // Owner of string-like data.
+};
+
+}
+#endif // ATOM_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index 84d5ee4..5ffd93d 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -40,7 +40,7 @@ class data : public object<pn_data_t> {
   public:
     data(pn_data_t* d) : object<pn_data_t>(d) {}
 
-    data& operator=(const data&);      // FIXME aconway 2015-12-01:
+    data& operator=(const data&);
 
     PN_CPP_EXTERN static data create();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/include/proton/type_traits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/type_traits.hpp b/proton-c/bindings/cpp/include/proton/type_traits.hpp
index d12e0ed..494f7db 100644
--- a/proton-c/bindings/cpp/include/proton/type_traits.hpp
+++ b/proton-c/bindings/cpp/include/proton/type_traits.hpp
@@ -76,9 +76,9 @@ template <class T> struct is_same<T,T> { static const bool value=true; };
 template< class T > struct remove_const          { typedef T type; };
 template< class T > struct remove_const<const T> { typedef T type; };
 
-// Metafunction returning AMQP type for basic C++ types
+// Metafunction returning AMQP type for atomic C++ types
 template <class T, class Enable=void> struct type_id_of;
-template<> struct type_id_of<amqp_null> { static const type_id value=NULL_; };
+template<> struct type_id_of<amqp_null> { static const type_id value=NULL_TYPE; };
 template<> struct type_id_of<amqp_boolean> { static const type_id value=BOOLEAN; };
 template<> struct type_id_of<amqp_ubyte> { static const type_id value=UBYTE; };
 template<> struct type_id_of<amqp_byte> { static const type_id value=BYTE; };
@@ -105,8 +105,8 @@ template <class T> struct has_type_id<T, typename enable_if<!!type_id_of<T>::val
     static const bool value = true;
 };
 
-// Map arbitrary integral types to know AMQP integral types.
-template<size_t N, bool S> struct integer_type;
+// Map arbitrary integral types to known AMQP integral types.
+template<size_t SIZE, bool IS_SIGNED> struct integer_type;
 template<> struct integer_type<1, true> { typedef amqp_byte type; };
 template<> struct integer_type<2, true> { typedef amqp_short type; };
 template<> struct integer_type<4, true> { typedef amqp_int type; };
@@ -121,6 +121,7 @@ template <class T> struct is_unknown_integer {
     static const bool value = !has_type_id<T>::value && is_integral<T>::value;
 };
 
+
 }
 ///@endcond
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index b9fedd1..262f352 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -24,6 +24,7 @@
  */
 
 #include "proton/export.hpp"
+#include "proton/error.hpp"
 #include "proton/comparable.hpp"
 
 #include <proton/codec.h>
@@ -39,7 +40,7 @@ namespace proton {
 
 /** type_id identifies an AMQP type. */
 enum type_id {
-    NULL_=PN_NULL,              ///< The null type, contains no data.
+    NULL_TYPE=PN_NULL,          ///< The null type, contains no data.
     BOOLEAN=PN_BOOL,            ///< Boolean true or false.
     UBYTE=PN_UBYTE,             ///< Unsigned 8 bit integer.
     BYTE=PN_BYTE,               ///< Signed 8 bit integer.
@@ -66,6 +67,13 @@ enum type_id {
     MAP=PN_MAP                  ///< A sequence of key:value pairs, may be of mixed types.
 };
 
+/// Raised when there is a type mismatch, with the expected and actual type ID.
+struct type_mismatch : public error {
+    PN_CPP_EXTERN explicit type_mismatch(type_id want, type_id got, const std::string& =std::string()) throw();
+    type_id want; ///< Expected type_id
+    type_id got;  ///< Actual type_id
+};
+
 PN_CPP_EXTERN pn_bytes_t pn_bytes(const std::string&);
 PN_CPP_EXTERN std::string str(const pn_bytes_t& b);
 ///@endcond
@@ -144,10 +152,13 @@ typedef opaque<pn_uuid_t> amqp_uuid;
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_uuid&);
 /// AMQP 32-bit decimal floating point (IEEE 854).
 typedef opaque<pn_decimal32_t> amqp_decimal32;
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal32&);
 /// AMQP 64-bit decimal floating point (IEEE 854).
 typedef opaque<pn_decimal64_t> amqp_decimal64;
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal64&);
 /// AMQP 128-bit decimal floating point (IEEE 854).
 typedef opaque<pn_decimal128_t> amqp_decimal128;
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_decimal128&);
 
 /// AMQP timestamp, milliseconds since the epoch 00:00:00 (UTC), 1 January 1970.
 struct amqp_timestamp : public comparable<amqp_timestamp> {
@@ -157,6 +168,7 @@ struct amqp_timestamp : public comparable<amqp_timestamp> {
     bool operator==(const amqp_timestamp& x) { return milliseconds == x.milliseconds; }
     bool operator<(const amqp_timestamp& x) { return milliseconds < x.milliseconds; }
 };
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const amqp_timestamp&);
 
 ///@cond INTERNAL
 template<class T, type_id A> struct cref {
@@ -180,9 +192,21 @@ template <type_id A, class T> cref<T, A> as(const T& value) { return cref<T, A>(
 
 // TODO aconway 2015-06-16: described types.
 
-/** Return the name of a type. */
+/// Name of the AMQP type
 PN_CPP_EXTERN std::string type_name(type_id);
 
+///@name Attributes of a type_id value, returns same result as the
+/// corresponding std::type_traits tests for the corresponding C++ types.
+///@{
+PN_CPP_EXTERN bool type_id_atom(type_id);
+PN_CPP_EXTERN bool type_id_integral(type_id);
+PN_CPP_EXTERN bool type_id_signed(type_id); ///< CHAR and BOOL are not signed.
+PN_CPP_EXTERN bool type_id_floating_point(type_id);
+PN_CPP_EXTERN bool type_id_decimal(type_id);
+PN_CPP_EXTERN bool type_id_string_like(type_id);   ///< STRING, SYMBOL, BINARY
+PN_CPP_EXTERN bool type_id_container(type_id);
+///@}
+
 /** Print the name of a type. */
 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
 
@@ -192,7 +216,7 @@ PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
  * for examples of use.
  */
 struct start {
-    PN_CPP_EXTERN start(type_id type=NULL_, type_id element=NULL_, bool described=false, size_t size=0);
+    PN_CPP_EXTERN start(type_id type=NULL_TYPE, type_id element=NULL_TYPE, bool described=false, size_t size=0);
     type_id type;            ///< The container type: ARRAY, LIST, MAP or DESCRIBED.
     type_id element;         ///< the element type for array only.
     bool is_described;       ///< true if first value is a descriptor.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/atom.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/atom.cpp b/proton-c/bindings/cpp/src/atom.cpp
new file mode 100644
index 0000000..64d3c88
--- /dev/null
+++ b/proton-c/bindings/cpp/src/atom.cpp
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "proton/atom.hpp"
+#include "proton/type_traits.hpp"
+
+#include <ostream>
+
+namespace proton {
+
+atom::atom() { atom_.type = PN_NULL; }
+
+type_id atom::type() const { return type_id(atom_.type); }
+bool atom::empty() const { return type() == NULL_TYPE; }
+
+atom::atom(bool x) { atom_.u.as_bool = x; atom_.type = PN_BOOL; }
+atom::atom(uint8_t x) { atom_.u.as_ubyte = x; atom_.type = PN_UBYTE; }
+atom::atom(int8_t x) { atom_.u.as_byte = x; atom_.type = PN_BYTE; }
+atom::atom(uint16_t x) { atom_.u.as_ushort = x; atom_.type = PN_USHORT; }
+atom::atom(int16_t x) { atom_.u.as_short = x; atom_.type = PN_SHORT; }
+atom::atom(uint32_t x) { atom_.u.as_uint = x; atom_.type = PN_UINT; }
+atom::atom(int32_t x) { atom_.u.as_int = x; atom_.type = PN_INT; }
+atom::atom(uint64_t x) { atom_.u.as_ulong = x; atom_.type = PN_ULONG; }
+atom::atom(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG; }
+atom::atom(wchar_t x) { atom_.u.as_char = x; atom_.type = PN_CHAR; }
+atom::atom(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; }
+atom::atom(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; }
+atom::atom(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; }
+atom::atom(const amqp_decimal32& x) { atom_.u.as_decimal32 = x; atom_.type = PN_DECIMAL32; }
+atom::atom(const amqp_decimal64& x) { atom_.u.as_decimal64 = x; atom_.type = PN_DECIMAL64; }
+atom::atom(const amqp_decimal128& x) { atom_.u.as_decimal128 = x; atom_.type = PN_DECIMAL128; }
+atom::atom(const amqp_uuid& x) { atom_.u.as_uuid = x; atom_.type = PN_UUID; }
+
+void atom::set(const std::string& x) { str_ = x; atom_.u.as_bytes = pn_bytes(str_); }
+atom::atom(const amqp_string& x) { set(x); atom_.type = PN_STRING; }
+atom::atom(const amqp_symbol& x) { set(x); atom_.type = PN_SYMBOL; }
+atom::atom(const amqp_binary& x) { set(x); atom_.type = PN_BINARY; }
+atom::atom(const std::string& x) { *this = amqp_string(x); }
+atom::atom(const char* x) { *this = amqp_string(x); }
+
+void atom::ok(pn_type_t t) const {
+    if (atom_.type != t) throw type_mismatch(type_id(t), type());
+}
+
+void atom::get(bool& x) const { ok(PN_BOOL); x = atom_.u.as_bool; }
+void atom::get(uint8_t& x) const { ok(PN_UBYTE); x = atom_.u.as_ubyte; }
+void atom::get(int8_t& x) const { ok(PN_BYTE); x = atom_.u.as_byte; }
+void atom::get(uint16_t& x) const { ok(PN_USHORT); x = atom_.u.as_ushort; }
+void atom::get(int16_t& x) const { ok(PN_SHORT); x = atom_.u.as_short; }
+void atom::get(uint32_t& x) const { ok(PN_UINT); x = atom_.u.as_uint; }
+void atom::get(int32_t& x) const { ok(PN_INT); x = atom_.u.as_int; }
+void atom::get(wchar_t& x) const { ok(PN_CHAR); x = atom_.u.as_char; }
+void atom::get(uint64_t& x) const { ok(PN_ULONG); x = atom_.u.as_ulong; }
+void atom::get(int64_t& x) const { ok(PN_LONG); x = atom_.u.as_long; }
+void atom::get(amqp_timestamp& x) const { ok(PN_TIMESTAMP); x = atom_.u.as_timestamp; }
+void atom::get(float& x) const { ok(PN_FLOAT); x = atom_.u.as_float; }
+void atom::get(double& x) const { ok(PN_DOUBLE); x = atom_.u.as_double; }
+void atom::get(amqp_decimal32& x) const { ok(PN_DECIMAL32); x = atom_.u.as_decimal32; }
+void atom::get(amqp_decimal64& x) const { ok(PN_DECIMAL64); x = atom_.u.as_decimal64; }
+void atom::get(amqp_decimal128& x) const { ok(PN_DECIMAL128); x = atom_.u.as_decimal128; }
+void atom::get(amqp_uuid& x) const { ok(PN_UUID); x = atom_.u.as_uuid; }
+void atom::get(amqp_string& x) const { ok(PN_STRING); x = str_; }
+void atom::get(amqp_symbol& x) const { ok(PN_SYMBOL); x = str_; }
+void atom::get(amqp_binary& x) const { ok(PN_BINARY); x = str_; }
+void atom::get(std::string& x) const { x = get<amqp_string>(); }
+
+int64_t atom::as_int() const {
+    if (type_id_floating_point(type())) return as_double();
+    switch (atom_.type) {
+      case PN_BOOL: return atom_.u.as_bool;
+      case PN_UBYTE: return atom_.u.as_ubyte;
+      case PN_BYTE: return atom_.u.as_byte;
+      case PN_USHORT: return atom_.u.as_ushort;
+      case PN_SHORT: return atom_.u.as_short;
+      case PN_UINT: return atom_.u.as_uint;
+      case PN_INT: return atom_.u.as_int;
+      case PN_CHAR: return atom_.u.as_char;
+      case PN_ULONG: return atom_.u.as_ulong;
+      case PN_LONG: return atom_.u.as_long;
+      default: throw type_mismatch(LONG, type(), "cannot convert");
+    }
+}
+
+uint64_t atom::as_uint() const {
+    if  (!type_id_integral(type()))
+        throw type_mismatch(ULONG, type(), "cannot convert");
+    return uint64_t(as_int());
+}
+
+double atom::as_double() const {
+    if (type_id_integral(type())) {
+        return type_id_signed(type()) ? double(as_int()) : double(as_uint());
+    }
+    switch (atom_.type) {
+      case PN_DOUBLE: return atom_.u.as_double;
+      case PN_FLOAT: return atom_.u.as_float;
+      default: throw type_mismatch(DOUBLE, type(), "cannot convert");
+    }
+}
+
+std::string atom::as_string() const {
+    if (type_id_string_like(type()))
+        return str_;
+    throw type_mismatch(DOUBLE, type(), "cannot convert");
+}
+
+
+namespace {
+template <class T, class F> T type_switch(const atom& a, F f) {
+    switch(a.type()) {
+      case BOOLEAN: return f(a.get<bool>());
+      case UBYTE: return f(a.get<uint8_t>());
+      case BYTE: return f(a.get<int8_t>());
+      case USHORT: return f(a.get<uint16_t>());
+      case SHORT: return f(a.get<int16_t>());
+      case UINT: return f(a.get<uint32_t>());
+      case INT: return f(a.get<int32_t>());
+      case CHAR: return f(a.get<wchar_t>());
+      case ULONG: return f(a.get<uint64_t>());
+      case LONG: return f(a.get<int64_t>());
+      case TIMESTAMP: return f(a.get<amqp_timestamp>());
+      case FLOAT: return f(a.get<float>());
+      case DOUBLE: return f(a.get<double>());
+      case DECIMAL32: return f(a.get<amqp_decimal32>());
+      case DECIMAL64: return f(a.get<amqp_decimal64>());
+      case DECIMAL128: return f(a.get<amqp_decimal128>());
+      case UUID: return f(a.get<amqp_uuid>());
+      case BINARY: return f(a.get<amqp_binary>());
+      case STRING: return f(a.get<amqp_string>());
+      case SYMBOL: return f(a.get<amqp_symbol>());
+      default:
+        throw error("bad atom type");
+    }
+}
+
+struct equal_op {
+    const atom& a;
+    equal_op(const atom& a_) : a(a_) {}
+    template<class T> bool operator()(T x) { return x == a.get<T>(); }
+};
+
+struct less_op {
+    const atom& a;
+    less_op(const atom& a_) : a(a_) {}
+    template<class T> bool operator()(T x) { return x < a.get<T>(); }
+};
+
+struct ostream_op {
+    std::ostream& o;
+    ostream_op(std::ostream& o_) : o(o_) {}
+    template<class T> std::ostream& operator()(T x) { return o << x; }
+};
+
+} // namespace
+
+bool atom::operator==(const atom& x) const {
+    return type_switch<bool>(*this, equal_op(x));
+}
+
+bool atom::operator<(const atom& x) const {
+    return type_switch<bool>(*this, less_op(x));
+}
+
+std::ostream& operator<<(std::ostream& o, const atom& a) {
+    return type_switch<std::ostream&>(a, ostream_op(o));
+}
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/atom_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/atom_test.cpp b/proton-c/bindings/cpp/src/atom_test.cpp
new file mode 100644
index 0000000..0d85a36
--- /dev/null
+++ b/proton-c/bindings/cpp/src/atom_test.cpp
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "test_bits.hpp"
+#include "proton/type_traits.hpp"
+
+#include <proton/atom.hpp>
+
+using namespace std;
+using namespace proton;
+
+// Inserting and extracting simple C++ values.
+template <class T> void type_test(T x, type_id tid, T y) {
+    atom v(x);
+    ASSERT_EQUAL(tid, v.type());
+    ASSERT(!v.empty());
+    ASSERT_EQUAL(x, v.get<T>());
+
+    atom v2;
+    ASSERT(v2.type() == NULL_TYPE);
+    v2 = x;
+    ASSERT_EQUAL(tid, v2.type());
+    ASSERT_EQUAL(x, v2.get<T>());
+    ASSERT_EQUAL(v, v2);
+    ASSERT_EQUAL(str(x), str(v));
+
+    v2 = y;
+    ASSERT(v != v2);
+    ASSERT(v < v2);
+    ASSERT(v2 > v);
+}
+
+#define ASSERT_MISMATCH(EXPR) \
+    try { (void)(EXPR); FAIL("expected type_mismatch: " #EXPR); } catch (type_mismatch) {}
+
+void convert_test() {
+    atom a;
+    ASSERT_EQUAL(NULL_TYPE, a.type());
+    ASSERT(a.empty());
+    ASSERT_MISMATCH(a.get<float>());
+
+    a = amqp_binary("foo");
+    ASSERT_MISMATCH(a.get<int16_t>());
+    ASSERT_MISMATCH(a.as_int());
+    ASSERT_MISMATCH(a.as_double());
+    ASSERT_MISMATCH(a.get<amqp_string>());           // No strict conversion
+    ASSERT_EQUAL(a.as_string(), std::string("foo")); // OK string-like conversion
+
+    a = int16_t(42);
+    ASSERT_MISMATCH(a.get<std::string>());
+    ASSERT_MISMATCH(a.get<amqp_timestamp>());
+    ASSERT_MISMATCH(a.as_string());
+    ASSERT_EQUAL(a.as_int(), 42);
+    ASSERT_EQUAL(a.as_uint(), 42);
+    ASSERT_EQUAL(a.as_double(), 42);
+
+    a = int16_t(-42);
+    ASSERT_EQUAL(a.as_int(), -42);
+    ASSERT_EQUAL(a.as_uint(), uint64_t(-42));
+    ASSERT_EQUAL(a.as_double(), -42);
+}
+
+int main(int, char**) {
+    int failed = 0;
+    RUN_TEST(failed, type_test(false, BOOLEAN, true));
+    RUN_TEST(failed, type_test(amqp_ubyte(42), UBYTE, amqp_ubyte(50)));
+    RUN_TEST(failed, type_test(amqp_byte('x'), BYTE, amqp_byte('y')));
+    RUN_TEST(failed, type_test(amqp_ushort(4242), USHORT, amqp_ushort(5252)));
+    RUN_TEST(failed, type_test(amqp_short(-4242), SHORT, amqp_short(3)));
+    RUN_TEST(failed, type_test(amqp_uint(4242), UINT, amqp_uint(5252)));
+    RUN_TEST(failed, type_test(amqp_int(-4242), INT, amqp_int(3)));
+    RUN_TEST(failed, type_test(amqp_ulong(4242), ULONG, amqp_ulong(5252)));
+    RUN_TEST(failed, type_test(amqp_long(-4242), LONG, amqp_long(3)));
+    RUN_TEST(failed, type_test(wchar_t(23), CHAR, wchar_t(24)));
+    RUN_TEST(failed, type_test(amqp_float(1.234), FLOAT, amqp_float(2.345)));
+    RUN_TEST(failed, type_test(amqp_double(11.2233), DOUBLE, amqp_double(12)));
+    RUN_TEST(failed, type_test(amqp_timestamp(0), TIMESTAMP, amqp_timestamp(1)));
+    RUN_TEST(failed, type_test(amqp_decimal32(0), DECIMAL32, amqp_decimal32(1)));
+    RUN_TEST(failed, type_test(amqp_decimal64(0), DECIMAL64, amqp_decimal64(1)));
+    pn_decimal128_t da = {0}, db = {1};
+    RUN_TEST(failed, type_test(amqp_decimal128(da), DECIMAL128, amqp_decimal128(db)));
+    pn_uuid_t ua = {0}, ub = {1};
+    RUN_TEST(failed, type_test(amqp_uuid(ua), UUID, amqp_uuid(ub)));
+    RUN_TEST(failed, type_test(amqp_string("aaa"), STRING, amqp_string("aaaa")));
+    RUN_TEST(failed, type_test(amqp_symbol("aaa"), SYMBOL, amqp_symbol("aaaa")));
+    RUN_TEST(failed, type_test(amqp_binary("aaa"), BINARY, amqp_binary("aaaa")));
+    RUN_TEST(failed, type_test(std::string("xxx"), STRING, std::string("yyy")));
+    return failed;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index 70f3e8f..e0ae9bc 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -110,7 +110,7 @@ int compare_next(data& a, data& b) {
     if (cmp) return cmp;
 
     switch (ta) {
-      case NULL_: return 0;
+      case NULL_TYPE: return 0;
       case ARRAY:
       case LIST:
       case MAP:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index 611d275..0c6a464 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -181,7 +181,7 @@ decoder operator>>(decoder d, message_id& id) {
 
 decoder operator>>(decoder d, amqp_null) {
     save_state ss(d.pn_object());
-    bad_type(NULL_, pre_get(d.pn_object()));
+    bad_type(NULL_TYPE, pre_get(d.pn_object()));
     return d;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/encode_decode_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encode_decode_test.cpp b/proton-c/bindings/cpp/src/encode_decode_test.cpp
index 6f5eb88..3e15a58 100644
--- a/proton-c/bindings/cpp/src/encode_decode_test.cpp
+++ b/proton-c/bindings/cpp/src/encode_decode_test.cpp
@@ -90,7 +90,7 @@ void map_test() {
 
 int main(int, char**) {
     int failed = 0;
-    failed += RUN_TEST(map_test);
-    failed += RUN_TEST(value_tests);
+    RUN_TEST(failed, map_test());
+    RUN_TEST(failed, value_tests());
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/interop_test.cpp b/proton-c/bindings/cpp/src/interop_test.cpp
index b7d6c5b..69a098d 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -113,9 +113,9 @@ int main(int argc, char** argv) {
     if (argc != 2) FAIL("Usage: " << argv[0] << " tests-dir");
     tests_dir = argv[1];
 
-    failed += RUN_TEST(test_data_ostream);
-    failed += RUN_TEST(test_decoder_primitves_exact);
-    failed += RUN_TEST(test_encoder_primitives);
-    failed += RUN_TEST(test_value_conversions);
+    RUN_TEST(failed, test_data_ostream());
+    RUN_TEST(failed, test_decoder_primitves_exact());
+    RUN_TEST(failed, test_encoder_primitives());
+    RUN_TEST(failed, test_value_conversions());
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/message_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message_test.cpp b/proton-c/bindings/cpp/src/message_test.cpp
index 928e5a6..ecdea75 100644
--- a/proton-c/bindings/cpp/src/message_test.cpp
+++ b/proton-c/bindings/cpp/src/message_test.cpp
@@ -84,6 +84,6 @@ void test_message() {
 
 int main(int argc, char** argv) {
     int failed = 0;
-    failed += RUN_TEST(test_message);
+    RUN_TEST(failed, test_message);
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/test_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_bits.hpp b/proton-c/bindings/cpp/src/test_bits.hpp
index 674ac22..49b67e9 100644
--- a/proton-c/bindings/cpp/src/test_bits.hpp
+++ b/proton-c/bindings/cpp/src/test_bits.hpp
@@ -32,19 +32,18 @@ struct fail : public std::logic_error { fail(const std::string& what) : logic_er
 #define ASSERT_EQUAL(WANT, GOT) if (!((WANT) == (GOT))) \
         FAIL(#WANT << " !=  " << #GOT << ": " << WANT << " != " << GOT)
 
-int run_test(void (*testfn)(), const char* name) {
-    try {
-        testfn();
-        return 0;
-    } catch(const fail& e) {
-        std::cout << "FAIL " << name << std::endl << e.what();
-    } catch(const std::exception& e) {
-        std::cout << "ERROR " << name << std::endl << e.what();
-    }
-    return 1;
-}
-
-#define RUN_TEST(TEST) run_test(TEST, #TEST)
+#define RUN_TEST(BAD_COUNT, TEST)                                       \
+    do {                                                                \
+        try {                                                           \
+            TEST;                                                       \
+            break;                                                      \
+        } catch(const fail& e) {                                        \
+            std::cout << "FAIL " << #TEST << std::endl << e.what() << std::endl; \
+        } catch(const std::exception& e) {                              \
+            std::cout << "ERROR " << #TEST << std::endl << __FILE__ << ":" << __LINE__ << ": " << e.what() << std::endl; \
+        }                                                               \
+            ++BAD_COUNT;                                                \
+    } while(0)
 
 template<class T> std::string str(const T& x) { std::ostringstream s; s << x; return s.str(); }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02d6ba68/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp b/proton-c/bindings/cpp/src/types.cpp
index 4b1d21d..713f15d 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -22,6 +22,7 @@
 #include <ostream>
 #include <iomanip>
 #include <algorithm>
+#include <sstream>
 
 namespace proton {
 
@@ -30,8 +31,26 @@ inline std::ostream& print_segment(std::ostream& o, const amqp_uuid& u, size_t b
     for (const char* p = &u[begin]; p < &u[end]; ++p) o << std::setw(2) << std::setfill('0') << ((int)*p & 0xff);
     return o << sep;
 }
+
+std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string()) throw()
+{
+    std::ostringstream s;
+    s << "type mismatch: want " << type_name(want) << " got " << type_name(got);
+    if (!msg.empty()) s << ": " << msg;
+    return s.str();
+}
 }
 
+type_mismatch::type_mismatch(type_id want_, type_id got_, const std::string &msg)
+    throw() : error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
+{}
+
+
+std::ostream& operator<<(std::ostream& o, const amqp_decimal32&) { return o << "<decimal32>"; }
+std::ostream& operator<<(std::ostream& o, const amqp_decimal64&) { return o << "<decimal64>"; }
+std::ostream& operator<<(std::ostream& o, const amqp_decimal128&) { return o << "<decimal128>"; }
+std::ostream& operator<<(std::ostream& o, const amqp_timestamp& ts) { return o << "timestamp:" << ts.milliseconds; }
+
 std::ostream& operator<<(std::ostream& o, const amqp_uuid& u) {
     std::ios_base::fmtflags ff = o.flags();
     o.flags(std::ios_base::hex);
@@ -46,7 +65,7 @@ std::ostream& operator<<(std::ostream& o, const amqp_uuid& u) {
 
 std::string type_name(type_id t) {
     switch (t) {
-      case NULL_: return "null";
+      case NULL_TYPE: return "null";
       case BOOLEAN: return "boolean";
       case UBYTE: return "ubyte";
       case BYTE: return "byte";
@@ -75,11 +94,19 @@ std::string type_name(type_id t) {
     }
 }
 
+bool type_id_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
+bool type_id_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
+bool type_id_integral(type_id t) { return t == BOOLEAN || t == CHAR || type_id_unsigned_int(t) || type_id_signed_int(t); }
+bool type_id_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
+bool type_id_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
+bool type_id_signed(type_id t) { return type_id_signed_int(t) || type_id_floating_point(t) || type_id_decimal(t); }
+bool type_id_string_like(type_id t) { return t == BINARY || t == STRING || t == SYMBOL; }
+bool type_id_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; }
+bool type_id_atom(type_id t) { return type_id_integral(t) || type_id_floating_point(t) || type_id_decimal(t) || type_id_string_like(t) || t == TIMESTAMP || t == UUID; }
+
+
 std::ostream& operator<<(std::ostream& o,type_id t) { return o << type_name(t); }
 
-PN_CPP_EXTERN bool is_container(type_id t) {
-    return (t == LIST || t == MAP || t == ARRAY || t == DESCRIBED);
-}
 
 pn_bytes_t pn_bytes(const std::string& s) {
     pn_bytes_t b = { s.size(), const_cast<char*>(&s[0]) };
@@ -92,6 +119,6 @@ start::start(type_id t, type_id e, bool d, size_t s) : type(t), element(e), is_d
 start start::array(type_id element, bool described) { return start(ARRAY, element, described); }
 start start::list() { return start(LIST); }
 start start::map() { return start(MAP); }
-start start::described() { return start(DESCRIBED, NULL_, true); }
+start start::described() { return start(DESCRIBED, NULL_TYPE, true); }
 
 }


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


[17/50] [abbrv] qpid-proton git commit: NO-JIRA: Removed unnecessary includes

Posted by ac...@apache.org.
NO-JIRA: Removed unnecessary includes


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

Branch: refs/heads/go1
Commit: f650d374f7da8e35e03c8d8017077e2121ce1088
Parents: f9569b5
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Dec 10 16:26:15 2015 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Dec 10 16:27:29 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/data.hpp    | 1 -
 proton-c/bindings/cpp/include/proton/message.hpp | 1 -
 proton-c/bindings/cpp/include/proton/ssl.hpp     | 1 -
 3 files changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f650d374/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index c2ffd3c..84d5ee4 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -23,7 +23,6 @@
 #include "proton/encoder.hpp"
 #include "proton/export.hpp"
 #include "proton/object.hpp"
-#include "proton/pn_unique_ptr.hpp"
 
 #include <iosfwd>
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f650d374/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index 0954b49..aa7b9f8 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -25,7 +25,6 @@
 #include "proton/data.hpp"
 #include "proton/export.hpp"
 #include "proton/message_id.hpp"
-#include "proton/pn_unique_ptr.hpp"
 #include "proton/value.hpp"
 
 #include <string>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f650d374/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index 437b8e2..d7cdfda 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -22,7 +22,6 @@
  *
  */
 #include "proton/export.hpp"
-#include "proton/pn_unique_ptr.hpp"
 #include "proton/ssl.h"
 
 #include <string>


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


[09/50] [abbrv] qpid-proton git commit: NO-JIRA: python doc generator: add dependency on swig module for parallel builds.

Posted by ac...@apache.org.
NO-JIRA: python doc generator: add dependency on swig module for parallel builds.


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

Branch: refs/heads/go1
Commit: 85015094edf2ed86bebf44f93d5eaa750b4f7d29
Parents: 1ccaf70
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 4 10:45:59 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 4 10:45:59 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/python/CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85015094/proton-c/bindings/python/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/CMakeLists.txt b/proton-c/bindings/python/CMakeLists.txt
index 18fbbd6..9c31b61 100644
--- a/proton-c/bindings/python/CMakeLists.txt
+++ b/proton-c/bindings/python/CMakeLists.txt
@@ -87,7 +87,8 @@ if (EPYDOC_EXE)
    add_custom_target(docs-py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../env.py --
      PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}
      ${EPYDOC_EXE} -v --no-private --html -o ${CMAKE_CURRENT_BINARY_DIR}/html
-     ${PY_DOC_FILES})
+     ${PY_DOC_FILES}
+     DEPENDENCIES ${SWIG_MODULE_${cproton}_REAL_NAME)
    add_dependencies(docs docs-py)
    install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/"
            DESTINATION "${PROTON_SHARE}/docs/api-py"


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


[15/50] [abbrv] qpid-proton git commit: PROTON-1054: add acceptor context to incoming reactor connections.

Posted by ac...@apache.org.
PROTON-1054: add acceptor context to incoming reactor connections.


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

Branch: refs/heads/go1
Commit: d6da8eb1c534a5432fcf1b16db7e034f81db3314
Parents: f160ada
Author: Clifford Jansen <cl...@apache.org>
Authored: Wed Dec 9 10:25:53 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Wed Dec 9 10:25:53 2015 -0800

----------------------------------------------------------------------
 proton-c/include/proton/reactor.h |  1 +
 proton-c/src/reactor/acceptor.c   | 12 ++++++++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d6da8eb1/proton-c/include/proton/reactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/reactor.h b/proton-c/include/proton/reactor.h
index 0ac6f32..e91b169 100644
--- a/proton-c/include/proton/reactor.h
+++ b/proton-c/include/proton/reactor.h
@@ -86,6 +86,7 @@ PN_EXTERN pn_task_t *pn_reactor_schedule(pn_reactor_t *reactor, int delay, pn_ha
 
 PN_EXTERN void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain);
 PN_EXTERN void pn_acceptor_close(pn_acceptor_t *acceptor);
+PN_EXTERN pn_acceptor_t *pn_connection_acceptor(pn_connection_t *connection);
 
 PN_EXTERN pn_timer_t *pn_timer(pn_collector_t *collector);
 PN_EXTERN pn_timestamp_t pn_timer_deadline(pn_timer_t *timer);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d6da8eb1/proton-c/src/reactor/acceptor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/acceptor.c b/proton-c/src/reactor/acceptor.c
index 819af8e..8f0e99b 100644
--- a/proton-c/src/reactor/acceptor.c
+++ b/proton-c/src/reactor/acceptor.c
@@ -23,6 +23,7 @@
 #include <proton/sasl.h>
 #include <proton/selector.h>
 #include <proton/transport.h>
+#include <proton/connection.h>
 #include "reactor.h"
 #include "selectable.h"
 
@@ -30,6 +31,7 @@ pn_selectable_t *pn_reactor_selectable_transport(pn_reactor_t *reactor, pn_socke
 
 PN_HANDLE(PNI_ACCEPTOR_HANDLER)
 PN_HANDLE(PNI_ACCEPTOR_SSL_DOMAIN)
+PN_HANDLE(PNI_ACCEPTOR_CONNECTION)
 
 void pni_acceptor_readable(pn_selectable_t *sel) {
   pn_reactor_t *reactor = (pn_reactor_t *) pni_selectable_get_context(sel);
@@ -49,6 +51,10 @@ void pni_acceptor_readable(pn_selectable_t *sel) {
   pn_transport_bind(trans, conn);
   pn_decref(trans);
   pn_reactor_selectable_transport(reactor, sock, trans);
+  record = pn_connection_attachments(conn);
+  pn_record_def(record, PNI_ACCEPTOR_CONNECTION, PN_OBJECT);
+  pn_record_set(record, PNI_ACCEPTOR_CONNECTION, sel);
+
 }
 
 void pni_acceptor_finalize(pn_selectable_t *sel) {
@@ -95,3 +101,9 @@ void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain
   pn_record_def(record, PNI_ACCEPTOR_SSL_DOMAIN, PN_VOID);
   pn_record_set(record, PNI_ACCEPTOR_SSL_DOMAIN, domain);
 }
+
+pn_acceptor_t *pn_connection_acceptor(pn_connection_t *conn) {
+  // Return the acceptor that created the connection or NULL if an outbound connection
+  pn_record_t *record = pn_connection_attachments(conn);
+  return (pn_acceptor_t *) pn_record_get(record, PNI_ACCEPTOR_CONNECTION);
+}


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


[05/50] [abbrv] qpid-proton git commit: PROTON-1056: Fix the ApplicationEvent string conversion

Posted by ac...@apache.org.
PROTON-1056: Fix the ApplicationEvent string conversion

Also add test coverage of ApplicationEvents.  There was no coverage,
and that made me feel sad.


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

Branch: refs/heads/go1
Commit: 8117f18e330acb0b34391e19fcc28ed85bbde166
Parents: fdbba69
Author: Ken Giusti <kg...@apache.org>
Authored: Tue Dec 1 10:24:31 2015 -0500
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue Dec 1 10:24:31 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/python/proton/reactor.py |  2 +-
 tests/python/proton_tests/reactor.py       | 58 ++++++++++++++++++++++++-
 2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8117f18e/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 8eaee5c..0f59682 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -275,7 +275,7 @@ class ApplicationEvent(EventBase):
 
     def __repr__(self):
         objects = [self.connection, self.session, self.link, self.delivery, self.subject]
-        return "%s(%s)" % (typename, ", ".join([str(o) for o in objects if o is not None]))
+        return "%s(%s)" % (self.type, ", ".join([str(o) for o in objects if o is not None]))
 
 class Transaction(object):
     """

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8117f18e/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index 890f4b0..c8cd894 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -18,9 +18,11 @@ from __future__ import absolute_import
 # under the License.
 #
 
-from .common import Test, SkipTest
-from proton.reactor import Reactor
+import time
+from .common import Test, SkipTest, TestServer
+from proton.reactor import Reactor, ApplicationEvent, EventInjector
 from proton.handlers import CHandshaker
+from proton import Handler
 
 class Barf(Exception):
     pass
@@ -400,3 +402,55 @@ class HandlerDerivationTest(Test):
             assert False, "expected to barf"
         except:
             assert h.init, "excpected the init"
+
+
+class ApplicationEventTest(Test):
+    """Test application defined events and handlers."""
+
+    class MyTestServer(TestServer):
+        def __init__(self):
+            super(ApplicationEventTest.MyTestServer, self).__init__()
+
+    class MyHandler(Handler):
+        def __init__(self, test):
+            super(ApplicationEventTest.MyHandler, self).__init__()
+            self._test = test
+
+        def on_hello(self, event):
+            # verify PROTON-1056
+            self._test.hello_rcvd = str(event)
+
+        def on_goodbye(self, event):
+            self._test.goodbye_rcvd = str(event)
+
+    def setUp(self):
+        import os
+        if not hasattr(os, 'pipe'):
+          # KAG: seems like Jython doesn't have an os.pipe() method
+          raise SkipTest()
+        self.server = ApplicationEventTest.MyTestServer()
+        self.server.reactor.handler.add(ApplicationEventTest.MyHandler(self))
+        self.event_injector = EventInjector()
+        self.hello_event = ApplicationEvent("hello")
+        self.goodbye_event = ApplicationEvent("goodbye")
+        self.server.reactor.selectable(self.event_injector)
+        self.hello_rcvd = None
+        self.goodbye_rcvd = None
+        self.server.start()
+
+    def tearDown(self):
+        self.server.stop()
+
+    def _wait_for(self, predicate, timeout=10.0):
+        deadline = time.time() + timeout
+        while time.time() < deadline:
+            if predicate():
+                break
+            time.sleep(0.1)
+        assert predicate()
+
+    def test_application_events(self):
+        self.event_injector.trigger(self.hello_event)
+        self._wait_for(lambda: self.hello_rcvd is not None)
+        self.event_injector.trigger(self.goodbye_event)
+        self._wait_for(lambda: self.goodbye_rcvd is not None)


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


[43/50] [abbrv] qpid-proton git commit: NO-JIRA: c++: Enable -Werror -pedantic -Weverything for clang++ compiler, fix warnings.

Posted by ac...@apache.org.
NO-JIRA: c++: Enable -Werror -pedantic -Weverything for clang++ compiler, fix warnings.

- #if with undefined macro
- old style casts (converted to enum conversions and const_cast)
- sign/precision in implicit conversions
- unused parameters
- redundant default and break statements.
- drop noexcept/throw()

Following warnings are disabled, some may be worth enabling: -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-padded -Wno-sign-conversion -Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors -Wno-global-constructors -Wno-shorten-64-to-32


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

Branch: refs/heads/go1
Commit: fd52a332f5392d64dec66fee9cbe4accc798a84d
Parents: 213eef9
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 28 14:48:32 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 28 15:10:11 2015 -0500

----------------------------------------------------------------------
 cpp.cmake                                       |  6 ----
 proton-c/CMakeLists.txt                         |  3 +-
 proton-c/bindings/cpp/include/proton/config.hpp | 34 ++++++--------------
 proton-c/bindings/cpp/include/proton/data.hpp   |  2 +-
 .../bindings/cpp/include/proton/decoder.hpp     |  2 +-
 .../bindings/cpp/include/proton/encoder.hpp     |  2 +-
 proton-c/bindings/cpp/include/proton/error.hpp  |  5 +--
 .../bindings/cpp/include/proton/event_loop.hpp  |  2 +-
 .../bindings/cpp/include/proton/message.hpp     |  4 +--
 .../bindings/cpp/include/proton/message_id.hpp  |  1 +
 proton-c/bindings/cpp/include/proton/object.hpp |  4 +--
 proton-c/bindings/cpp/include/proton/ssl.hpp    |  4 ---
 proton-c/bindings/cpp/include/proton/types.hpp  |  2 +-
 proton-c/bindings/cpp/include/proton/url.hpp    |  2 +-
 proton-c/bindings/cpp/src/atom.cpp              |  9 +++---
 proton-c/bindings/cpp/src/connector.cpp         | 10 +++---
 proton-c/bindings/cpp/src/container_impl.cpp    |  2 +-
 proton-c/bindings/cpp/src/contexts.cpp          | 12 +++----
 proton-c/bindings/cpp/src/contexts.hpp          |  4 +--
 proton-c/bindings/cpp/src/data.cpp              |  2 +-
 proton-c/bindings/cpp/src/decoder.cpp           |  9 +++---
 proton-c/bindings/cpp/src/encoder.cpp           |  8 ++---
 proton-c/bindings/cpp/src/engine.cpp            |  4 +--
 proton-c/bindings/cpp/src/error.cpp             |  4 +--
 proton-c/bindings/cpp/src/event.cpp             |  1 +
 proton-c/bindings/cpp/src/handler.cpp           |  2 +-
 proton-c/bindings/cpp/src/message.cpp           | 12 +++----
 proton-c/bindings/cpp/src/message_test.cpp      |  2 +-
 proton-c/bindings/cpp/src/messaging_adapter.cpp |  8 ++---
 proton-c/bindings/cpp/src/messaging_event.cpp   |  3 +-
 proton-c/bindings/cpp/src/messaging_handler.cpp |  2 +-
 proton-c/bindings/cpp/src/proton_bits.cpp       |  4 +--
 proton-c/bindings/cpp/src/proton_bits.hpp       |  4 +--
 proton-c/bindings/cpp/src/proton_event.cpp      |  1 -
 proton-c/bindings/cpp/src/proton_handler.cpp    |  2 +-
 proton-c/bindings/cpp/src/ssl.cpp               |  2 +-
 proton-c/bindings/cpp/src/ssl_domain.cpp        |  7 ++--
 proton-c/bindings/cpp/src/terminus.cpp          | 14 ++++----
 proton-c/bindings/cpp/src/types.cpp             | 13 ++++----
 proton-c/bindings/cpp/src/url.cpp               |  2 +-
 40 files changed, 95 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/cpp.cmake
----------------------------------------------------------------------
diff --git a/cpp.cmake b/cpp.cmake
index 09d1e98..0998546 100644
--- a/cpp.cmake
+++ b/cpp.cmake
@@ -31,10 +31,4 @@ if (CMAKE_CXX_COMPILER)
   if (HAS_STD_PTR)
     add_definitions(-DPN_HAS_STD_PTR=1)
   endif()
-
-  # Check for boost
-  find_path(BOOST_INCLUDE_DIR boost/shared_ptr.hpp PATH_SUFFIXES include)
-  if (BOOST_INCLUDE_DIR)
-    add_definitions(-DPN_HAS_BOOST=1)
-  endif()
 endif()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index d897951..3d2f457 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -218,7 +218,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
   endif (ENABLE_WARNING_ERROR)
   set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors")
   # C++ allow "%z" format specifier and variadic macros
-  set (CXX_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wno-format -Wno-variadic-macros" CACHE STRING "C++ warning flags")
+  set (CXX_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wno-format -Wno-variadic-macros")
   if (NOT BUILD_WITH_CXX)
     set (COMPILE_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wstrict-prototypes")
     set (COMPILE_LANGUAGE_FLAGS "-std=c99")
@@ -246,6 +246,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   if (ENABLE_WARNING_ERROR)
     set (WERROR "-Werror")
   endif (ENABLE_WARNING_ERROR)
+  set (CXX_WARNING_FLAGS "${WERROR} -pedantic -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-float-equal -Wno-padded -Wno-sign-conversion -Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors -Wno-global-constructors -Wno-shorten-64-to-32")
 endif()
 
 if (MSVC)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/config.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/config.hpp b/proton-c/bindings/cpp/include/proton/config.hpp
index 9237138..4d3dff9 100644
--- a/proton-c/bindings/cpp/include/proton/config.hpp
+++ b/proton-c/bindings/cpp/include/proton/config.hpp
@@ -27,40 +27,24 @@
  * Otherwise they can be enabled or disabled separately with -D on the compile line.
  */
 
-#if ((defined(__cplusplus) && __cplusplus >= 201100))
-
+#ifndef PN_HAS_CPP11
+#if (defined(__cplusplus) && __cplusplus >= 201100)
 #define PN_HAS_CPP11 1
+#else
+#define PN_HAS_CPP11 0
+#endif
+#endif
 
 #ifndef PN_HAS_STD_PTR
-#define PN_HAS_STD_PTR 1
+#define PN_HAS_STD_PTR PN_HAS_CPP11
 #endif
 
 #ifndef PN_HAS_LONG_LONG
-#define PN_HAS_LONG_LONG 1
+#define PN_HAS_LONG_LONG PN_HAS_CPP11
 #endif
 
 #ifndef PN_HAS_STATIC_ASSERT
-#define PN_HAS_STATIC_ASSERT 1
-#endif
-
-#ifndef PN_NOEXCEPT
-#define PN_NOEXCEPT noexcept
-#endif
-
-#else  // C++11
-
-#ifndef PN_NOEXCEPT
-#define PN_NOEXCEPT
-#endif
-
-#endif // C++11
-
-#if defined(BOOST_VERSION)
-
-#ifndef PN_HAS_BOOST
-#define PN_HAS_BOOST 1
-#endif
-
+#define PN_HAS_STATIC_ASSERT PN_HAS_CPP11
 #endif
 
 #endif // CONFIG_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/data.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/data.hpp b/proton-c/bindings/cpp/include/proton/data.hpp
index 5ffd93d..37e1a61 100644
--- a/proton-c/bindings/cpp/include/proton/data.hpp
+++ b/proton-c/bindings/cpp/include/proton/data.hpp
@@ -39,7 +39,7 @@ class data;
 class data : public object<pn_data_t> {
   public:
     data(pn_data_t* d) : object<pn_data_t>(d) {}
-
+    data(const data& d) : object<pn_data_t>(d) {}
     data& operator=(const data&);
 
     PN_CPP_EXTERN static data create();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/decoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/decoder.hpp b/proton-c/bindings/cpp/include/proton/decoder.hpp
index a4d9a11..3073989 100644
--- a/proton-c/bindings/cpp/include/proton/decoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/decoder.hpp
@@ -48,7 +48,7 @@ class data;
 class message_id;
 
 /** Raised by decoder operations on error.*/
-struct decode_error : public error { PN_CPP_EXTERN explicit decode_error(const std::string&) throw(); };
+struct decode_error : public error { PN_CPP_EXTERN explicit decode_error(const std::string&); };
 
 /** Skips a value with `dec >> skip()`. */
 struct skip{};

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/encoder.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/encoder.hpp b/proton-c/bindings/cpp/include/proton/encoder.hpp
index c5eb064..940064d 100644
--- a/proton-c/bindings/cpp/include/proton/encoder.hpp
+++ b/proton-c/bindings/cpp/include/proton/encoder.hpp
@@ -48,7 +48,7 @@ class data;
 class message_id;
 
 /** Raised by encoder operations on error */
-struct encode_error : public error { PN_CPP_EXTERN explicit encode_error(const std::string&) throw(); };
+struct encode_error : public error { PN_CPP_EXTERN explicit encode_error(const std::string&); };
 
 /**
  * Stream-like encoder from C++ values to AMQP values.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/error.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/error.hpp b/proton-c/bindings/cpp/include/proton/error.hpp
index 001cbc6..d2f57c6 100644
--- a/proton-c/bindings/cpp/include/proton/error.hpp
+++ b/proton-c/bindings/cpp/include/proton/error.hpp
@@ -23,15 +23,16 @@
  */
 #include <stdexcept>
 #include <string>
+#include "proton/config.hpp"
 #include "proton/export.hpp"
 
 namespace proton {
 
 /** Functions in the proton namespace throw a subclass of proton::error on error. */
-struct error : public std::runtime_error { PN_CPP_EXTERN explicit error(const std::string&) throw(); };
+struct error : public std::runtime_error { PN_CPP_EXTERN explicit error(const std::string&); };
 
 /** Raised if timeout expires */
-struct timeout_error : public error { PN_CPP_EXTERN explicit timeout_error(const std::string&) throw(); };
+struct timeout_error : public error { PN_CPP_EXTERN explicit timeout_error(const std::string&); };
 
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/event_loop.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/event_loop.hpp b/proton-c/bindings/cpp/include/proton/event_loop.hpp
index fcc83d8..dcf9670 100644
--- a/proton-c/bindings/cpp/include/proton/event_loop.hpp
+++ b/proton-c/bindings/cpp/include/proton/event_loop.hpp
@@ -31,7 +31,7 @@ namespace proton {
  */
 class event_loop {
   public:
-    PN_CPP_EXTERN virtual ~event_loop() {}
+    PN_CPP_EXTERN virtual ~event_loop();
 
     /// The AMQP container-id associated with this event loop.
     /// Any connections managed by this event loop will have this container id.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index b132f5f..52195aa 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -242,9 +242,9 @@ class message
      *
      * @return the group sequence for the message
      */
-    PN_CPP_EXTERN uint32_t sequence() const;
+    PN_CPP_EXTERN int32_t sequence() const;
     /** Get the group sequence for a message. */
-    PN_CPP_EXTERN void sequence(uint32_t);
+    PN_CPP_EXTERN void sequence(int32_t);
 
   private:
     pn_message_t *message_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/message_id.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp
index 8e0adf1..4734dff 100644
--- a/proton-c/bindings/cpp/include/proton/message_id.hpp
+++ b/proton-c/bindings/cpp/include/proton/message_id.hpp
@@ -29,6 +29,7 @@ namespace proton {
 class message_id : public comparable<message_id> {
   public:
     message_id() {}
+    message_id(const message_id& x) : value_(x.value_) {}
     message_id(const uint64_t& x) : value_(x) {}
     message_id(const amqp_uuid& x) : value_(x) {}
     message_id(const amqp_binary& x) : value_(x) {}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index a2457bb..e98a956 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -40,11 +40,11 @@ template <class T> class pn_ptr : public comparable<pn_ptr<T> >, private pn_ptr_
     pn_ptr(T* p) : ptr_(p) { incref(ptr_); }
     pn_ptr(const pn_ptr& o) : ptr_(o.ptr_) { incref(ptr_); }
 
-#ifdef PN_HAS_CPP11
+#if PN_HAS_CPP11
     pn_ptr(pn_ptr&& o) : ptr_(0) { std::swap(ptr_, o.ptr_); }
 #endif
 
-    ~pn_ptr() { decref(ptr_); };
+    ~pn_ptr() { decref(ptr_); }
 
     pn_ptr& operator=(pn_ptr o) { std::swap(ptr_, o.ptr_); return *this; }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index 579a57f..b3757dc 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -102,8 +102,6 @@ class server_domain : private ssl_domain {
     /** A server domain restricted to available anonymous cipher suites on the platform. */
     PN_CPP_EXTERN server_domain();
 
-    PN_CPP_EXTERN ~server_domain();
-
   private:
     // Bring pn_domain into scope and allow connection_options to use it
     using ssl_domain::pn_domain;
@@ -119,8 +117,6 @@ class client_domain : private ssl_domain {
     /** A client domain restricted to available anonymous cipher suites on the platform. */
     PN_CPP_EXTERN client_domain();
 
-    PN_CPP_EXTERN ~client_domain();
-
   private:
     // Bring pn_domain into scope and allow connection_options to use it
     using ssl_domain::pn_domain;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index 262f352..75bb226 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -69,7 +69,7 @@ enum type_id {
 
 /// Raised when there is a type mismatch, with the expected and actual type ID.
 struct type_mismatch : public error {
-    PN_CPP_EXTERN explicit type_mismatch(type_id want, type_id got, const std::string& =std::string()) throw();
+    PN_CPP_EXTERN explicit type_mismatch(type_id want, type_id got, const std::string& =std::string());
     type_id want; ///< Expected type_id
     type_id got;  ///< Actual type_id
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/include/proton/url.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/url.hpp b/proton-c/bindings/cpp/include/proton/url.hpp
index 4f586cb..c2d273b 100644
--- a/proton-c/bindings/cpp/include/proton/url.hpp
+++ b/proton-c/bindings/cpp/include/proton/url.hpp
@@ -29,7 +29,7 @@ namespace proton {
 
 /// Thrown if URL parsing fails.
 struct url_error : public error {
-    PN_CPP_EXTERN explicit url_error(const std::string&) throw();
+    PN_CPP_EXTERN explicit url_error(const std::string&);
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/atom.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/atom.cpp b/proton-c/bindings/cpp/src/atom.cpp
index 64d3c88..034b22c 100644
--- a/proton-c/bindings/cpp/src/atom.cpp
+++ b/proton-c/bindings/cpp/src/atom.cpp
@@ -38,7 +38,7 @@ atom::atom(uint32_t x) { atom_.u.as_uint = x; atom_.type = PN_UINT; }
 atom::atom(int32_t x) { atom_.u.as_int = x; atom_.type = PN_INT; }
 atom::atom(uint64_t x) { atom_.u.as_ulong = x; atom_.type = PN_ULONG; }
 atom::atom(int64_t x) { atom_.u.as_long = x; atom_.type = PN_LONG; }
-atom::atom(wchar_t x) { atom_.u.as_char = x; atom_.type = PN_CHAR; }
+atom::atom(wchar_t x) { atom_.u.as_char = pn_char_t(x); atom_.type = PN_CHAR; }
 atom::atom(float x) { atom_.u.as_float = x; atom_.type = PN_FLOAT; }
 atom::atom(double x) { atom_.u.as_double = x; atom_.type = PN_DOUBLE; }
 atom::atom(amqp_timestamp x) { atom_.u.as_timestamp = x; atom_.type = PN_TIMESTAMP; }
@@ -65,7 +65,7 @@ void atom::get(uint16_t& x) const { ok(PN_USHORT); x = atom_.u.as_ushort; }
 void atom::get(int16_t& x) const { ok(PN_SHORT); x = atom_.u.as_short; }
 void atom::get(uint32_t& x) const { ok(PN_UINT); x = atom_.u.as_uint; }
 void atom::get(int32_t& x) const { ok(PN_INT); x = atom_.u.as_int; }
-void atom::get(wchar_t& x) const { ok(PN_CHAR); x = atom_.u.as_char; }
+void atom::get(wchar_t& x) const { ok(PN_CHAR); x = wchar_t(atom_.u.as_char); }
 void atom::get(uint64_t& x) const { ok(PN_ULONG); x = atom_.u.as_ulong; }
 void atom::get(int64_t& x) const { ok(PN_LONG); x = atom_.u.as_long; }
 void atom::get(amqp_timestamp& x) const { ok(PN_TIMESTAMP); x = atom_.u.as_timestamp; }
@@ -81,7 +81,8 @@ void atom::get(amqp_binary& x) const { ok(PN_BINARY); x = str_; }
 void atom::get(std::string& x) const { x = get<amqp_string>(); }
 
 int64_t atom::as_int() const {
-    if (type_id_floating_point(type())) return as_double();
+    if (type_id_floating_point(type()))
+        return int64_t(as_double());
     switch (atom_.type) {
       case PN_BOOL: return atom_.u.as_bool;
       case PN_UBYTE: return atom_.u.as_ubyte;
@@ -91,7 +92,7 @@ int64_t atom::as_int() const {
       case PN_UINT: return atom_.u.as_uint;
       case PN_INT: return atom_.u.as_int;
       case PN_CHAR: return atom_.u.as_char;
-      case PN_ULONG: return atom_.u.as_ulong;
+      case PN_ULONG: return int64_t(atom_.u.as_ulong);
       case PN_LONG: return atom_.u.as_long;
       default: throw type_mismatch(LONG, type(), "cannot convert");
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/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 e2bb802..9469496 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -68,23 +68,23 @@ void connector::connect() {
     if (!address_.password().empty())
         connection_.password(address_.password());
     t.bind(connection_);
-    pn_decref((void *)pnt);
+    pn_decref(pnt);
     // Apply options to the new transport.
     options_.apply(connection_);
     transport_configured_ = true;
 }
 
-void connector::on_connection_local_open(event &e) {
+void connector::on_connection_local_open(event &) {
     connect();
 }
 
-void connector::on_connection_remote_open(event &e) {
+void connector::on_connection_remote_open(event &) {
     if (reconnect_timer_) {
         reconnect_timer_->reset();
     }
 }
 
-void connector::on_connection_init(event &e) {
+void connector::on_connection_init(event &) {
 }
 
 void connector::on_transport_tail_closed(event &e) {
@@ -116,7 +116,7 @@ void connector::on_transport_closed(event &e) {
     connection_  = 0;
 }
 
-void connector::on_timer_task(event &e) {
+void connector::on_timer_task(event &) {
     connect();
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/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 e3c7c2c..b6e057e 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -107,7 +107,7 @@ class override_handler : public handler
                 container_impl_.configure_server_connection(c);
             }
         }
-        pn_handler_dispatch(base_handler.get(), cevent, (pn_event_type_t) type);
+        pn_handler_dispatch(base_handler.get(), cevent, pn_event_type_t(type));
     }
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/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 08187a2..0d48aa6 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -37,7 +37,6 @@ namespace proton {
 namespace {
 void cpp_context_finalize(void* v) { reinterpret_cast<context*>(v)->~context(); }
 #define CID_cpp_context CID_pn_object
-#define cpp_context_reify pn_object_reify
 #define cpp_context_initialize NULL
 #define cpp_context_finalize cpp_context_finalize
 #define cpp_context_hashcode NULL
@@ -46,14 +45,10 @@ void cpp_context_finalize(void* v) { reinterpret_cast<context*>(v)->~context();
 pn_class_t cpp_context_class = PN_CLASS(cpp_context);
 
 // Handles
+#pragma GCC diagnostic ignored "-Wold-style-cast"
 PN_HANDLE(CONNECTION_CONTEXT)
 PN_HANDLE(CONTAINER_CONTEXT)
 PN_HANDLE(LISTENER_CONTEXT)
-}
-
-context::~context() {}
-void *context::alloc(size_t n) { return pn_object_new(&cpp_context_class, n); }
-pn_class_t* context::pn_class() { return &cpp_context_class; }
 
 void set_context(pn_record_t* record, pn_handle_t handle, const pn_class_t *clazz, void* value)
 {
@@ -66,6 +61,11 @@ T* get_context(pn_record_t* record, pn_handle_t handle) {
     return reinterpret_cast<T*>(pn_record_get(record, handle));
 }
 
+}
+
+context::~context() {}
+void *context::alloc(size_t n) { return pn_object_new(&cpp_context_class, n); }
+pn_class_t* context::pn_class() { return &cpp_context_class; }
 
 connection_context& connection_context::get(pn_connection_t* c) {
     connection_context* ctx =

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/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 9bfd2d4..bb35bdf 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -41,14 +41,14 @@ class container_impl;
 // contexts are pn_objects managed by pn reference counts.
 class context {
   public:
+    virtual ~context();
+
     // Allocate a default-constructed T as a proton object. T must be a subclass of context.
     template <class T> static T *create() { return new(alloc(sizeof(T))) T(); }
 
     // Allocate a copy-constructed T as a proton object. T must be a subclass of context.
     template <class T> static T *create(const T& x) { return new(alloc(sizeof(T))) T(x); }
 
-    virtual ~context();
-
     static pn_class_t* pn_class();
 
   private:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/data.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/data.cpp b/proton-c/bindings/cpp/src/data.cpp
index e0ae9bc..7b6aad0 100644
--- a/proton-c/bindings/cpp/src/data.cpp
+++ b/proton-c/bindings/cpp/src/data.cpp
@@ -87,7 +87,7 @@ int compare_container(data& a, data& b) {
     int cmp = compare(sa.is_described, sb.is_described);
     if (cmp) return cmp;
     // Lexical sort (including descriptor if there is one)
-    size_t min_size = std::min(sa.size, sb.size) + int(sa.is_described);
+    size_t min_size = std::min(sa.size, sb.size) + size_t(sa.is_described);
     for (size_t i = 0; i < min_size; ++i) {
         cmp = compare_next(a, b);
         if (cmp) return cmp;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/decoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/decoder.cpp b/proton-c/bindings/cpp/src/decoder.cpp
index 0c6a464..20d0461 100644
--- a/proton-c/bindings/cpp/src/decoder.cpp
+++ b/proton-c/bindings/cpp/src/decoder.cpp
@@ -34,8 +34,7 @@ namespace proton {
  * to be returned by the decoder.
  *
  */
-static const std::string prefix("decode: ");
-decode_error::decode_error(const std::string& msg) throw() : error(prefix+msg) {}
+decode_error::decode_error(const std::string& msg) : error("decode: "+msg) {}
 
 namespace {
 struct save_state {
@@ -64,7 +63,7 @@ void decoder::decode(const char* i, size_t size) {
     save_state ss(pn_object());
     const char* end = i + size;
     while (i < end) {
-        i += check(pn_data_decode(pn_object(), i, end - i));
+        i += check(pn_data_decode(pn_object(), i, size_t(end - i)));
     }
 }
 
@@ -103,7 +102,7 @@ type_id pre_get(pn_data_t* data) {
 template <class T, class U> void extract(pn_data_t* data, T& value, U (*get)(pn_data_t*)) {
     save_state ss(data);
     bad_type(type_id_of<T>::value, pre_get(data));
-    value = get(data);
+    value = T(get(data));
     ss.cancel();                // No error, no rewind
 }
 
@@ -305,7 +304,7 @@ decoder operator>>(decoder d0, amqp_float& value) {
     save_state ss(d);
     switch (pre_get(d)) {
       case FLOAT: value = pn_data_get_float(d); break;
-      case DOUBLE: value = pn_data_get_double(d); break;
+      case DOUBLE: value = float(pn_data_get_double(d)); break;
       default: bad_type(FLOAT, type_id(pn_data_type(d)));
     }
     ss.cancel();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/encoder.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/encoder.cpp b/proton-c/bindings/cpp/src/encoder.cpp
index 3624821..327426a 100644
--- a/proton-c/bindings/cpp/src/encoder.cpp
+++ b/proton-c/bindings/cpp/src/encoder.cpp
@@ -30,7 +30,7 @@
 namespace proton {
 
 static const std::string prefix("encode: ");
-encode_error::encode_error(const std::string& msg) throw() : error(prefix+msg) {}
+encode_error::encode_error(const std::string& msg) : error(prefix+msg) {}
 
 namespace {
 struct save_state {
@@ -41,7 +41,7 @@ struct save_state {
     void cancel() { data = 0; }
 };
 
-void check(int result, pn_data_t* data) {
+void check(long result, pn_data_t* data) {
     if (result < 0)
         throw encode_error(error_str(pn_data_error(data), result));
 }
@@ -53,12 +53,12 @@ bool encoder::encode(char* buffer, size_t& size) {
     if (result == PN_OVERFLOW) {
         result = pn_data_encoded_size(pn_object());
         if (result >= 0) {
-            size = result;
+            size = size_t(result);
             return false;
         }
     }
     check(result, pn_object());
-    size = result;
+    size = size_t(result);
     ss.cancel();                // Don't restore state, all is well.
     pn_data_clear(pn_object());
     return true;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/engine.cpp b/proton-c/bindings/cpp/src/engine.cpp
index da3d0d9..14d3ba1 100644
--- a/proton-c/bindings/cpp/src/engine.cpp
+++ b/proton-c/bindings/cpp/src/engine.cpp
@@ -71,7 +71,7 @@ buffer<char> engine::input() {
     ssize_t n = pn_transport_capacity(impl_->transport);
     if (n <= 0)
         return buffer<char>();
-    return buffer<char>(pn_transport_tail(impl_->transport), n);
+    return buffer<char>(pn_transport_tail(impl_->transport), size_t(n));
 }
 
 void engine::close_input() {
@@ -106,7 +106,7 @@ buffer<const char> engine::output() {
     ssize_t n = pn_transport_pending(impl_->transport);
     if (n <= 0)
         return buffer<const char>();
-    return buffer<const char>(pn_transport_head(impl_->transport), n);
+    return buffer<const char>(pn_transport_head(impl_->transport), size_t(n));
 }
 
 void engine::sent(size_t n) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/error.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/error.cpp b/proton-c/bindings/cpp/src/error.cpp
index 615c22c..980d6c0 100644
--- a/proton-c/bindings/cpp/src/error.cpp
+++ b/proton-c/bindings/cpp/src/error.cpp
@@ -23,8 +23,8 @@ namespace proton {
 
 static const std::string prefix("proton: ");
 
-error::error(const std::string& msg) throw() : std::runtime_error(prefix+msg) {}
+error::error(const std::string& msg) : std::runtime_error(prefix+msg) {}
 
-timeout_error::timeout_error(const std::string& msg) throw() : error(msg) {}
+timeout_error::timeout_error(const std::string& msg) : error(msg) {}
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/event.cpp b/proton-c/bindings/cpp/src/event.cpp
index 54cbbc7..2a35ee8 100644
--- a/proton-c/bindings/cpp/src/event.cpp
+++ b/proton-c/bindings/cpp/src/event.cpp
@@ -77,4 +77,5 @@ class message &event::message() const {
     throw error(MSG("No message associated with event"));
 }
 
+event_loop::~event_loop() {}    // FIXME aconway 2015-12-28: move
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp
index e73ee24..f40ee1f 100644
--- a/proton-c/bindings/cpp/src/handler.cpp
+++ b/proton-c/bindings/cpp/src/handler.cpp
@@ -28,7 +28,7 @@ namespace proton {
 handler::handler() {}
 handler::~handler() {}
 
-void handler::on_unhandled(event &e) {}
+void handler::on_unhandled(event &) {}
 
 void handler::add_child_handler(handler &e) {
     children_.push_back(&e);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index cb29029..c2fcd00 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -40,7 +40,7 @@ message::message() : message_(::pn_message()) {}
 
 message::message(const message &m) : message_(::pn_message()) { *this = m; }
 
-#if PN_HAS_CPP11
+#if defined(PN_HAS_CPP11) && PN_HAS_CPP11
 message::message(message &&m) : message_(::pn_message()) { swap(m); }
 #endif
 
@@ -301,7 +301,7 @@ void message::encode(std::string &s) const {
     if (sz < 512) sz = 512;
     while (true) {
         s.resize(sz);
-        int err = pn_message_encode(message_, (char *) s.data(), &sz);
+        int err = pn_message_encode(message_, const_cast<char*>(s.data()), &sz);
         if (err) {
             if (err != PN_OVERFLOW)
                 check(err);
@@ -326,8 +326,8 @@ void message::decode(const std::string &s) {
 void message::decode(proton::link link, proton::delivery delivery) {
     std::string buf;
     buf.resize(delivery.pending());
-    ssize_t n = link.recv((char *) buf.data(), buf.size());
-    if (n != (ssize_t) buf.size()) throw error(MSG("link read failure"));
+    ssize_t n = link.recv(const_cast<char *>(buf.data()), buf.size());
+    if (n != ssize_t(buf.size())) throw error(MSG("link read failure"));
     clear();
     decode(buf);
     link.advance();
@@ -348,7 +348,7 @@ void message::first_acquirer(bool b) { pn_message_set_first_acquirer(message_, b
 uint32_t message::delivery_count() const { return pn_message_get_delivery_count(message_); }
 void message::delivery_count(uint32_t d) { pn_message_set_delivery_count(message_, d); }
 
-uint32_t message::sequence() const { return pn_message_get_group_sequence(message_); }
-void message::sequence(uint32_t d) { pn_message_set_group_sequence(message_, d); }
+int32_t message::sequence() const { return pn_message_get_group_sequence(message_); }
+void message::sequence(int32_t d) { pn_message_set_group_sequence(message_, d); }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/message_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message_test.cpp b/proton-c/bindings/cpp/src/message_test.cpp
index ecdea75..54995c0 100644
--- a/proton-c/bindings/cpp/src/message_test.cpp
+++ b/proton-c/bindings/cpp/src/message_test.cpp
@@ -84,6 +84,6 @@ void test_message() {
 
 int main(int argc, char** argv) {
     int failed = 0;
-    RUN_TEST(failed, test_message);
+    RUN_TEST(failed, test_message());
     return failed;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index cf90754..d66189c 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -33,9 +33,9 @@
 #include "proton/message.h"
 
 namespace proton {
-messaging_adapter::messaging_adapter(messaging_handler &delegate_) :
-    messaging_handler(true, delegate_.prefetch_, delegate_.auto_settle_, delegate_.auto_accept_, delegate_.peer_close_iserror_),
-    delegate_(delegate_)
+messaging_adapter::messaging_adapter(messaging_handler &delegate) :
+    messaging_handler(true, delegate.prefetch_, delegate.auto_settle_, delegate.auto_accept_, delegate.peer_close_iserror_),
+    delegate_(delegate)
 {}
 
 
@@ -276,7 +276,7 @@ void messaging_adapter::on_link_close(event &e) {
         on_link_error(e);
 }
 
-void messaging_adapter::on_unhandled(event &e) {
+void messaging_adapter::on_unhandled(event &) {
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index b360299..6574a55 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -141,7 +141,6 @@ void messaging_event::dispatch(handler &h) {
 
         default:
             throw error(MSG("Unknown messaging event type " << type_));
-            break;
         }
     } else {
         h.on_unhandled(*this);
@@ -177,8 +176,8 @@ std::string messaging_event::name() const {
       case TRANSACTION_COMMIT:  return "TRANSACTION_COMMIT";
       case TRANSACTION_DECLARE: return "TRANSACTION_DECLARE";
       case TIMER:            return "TIMER";
-      default: return "UNKNOWN";
     }
+    return "unknown";
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/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 2f7383f..b68ece5 100644
--- a/proton-c/bindings/cpp/src/messaging_handler.cpp
+++ b/proton-c/bindings/cpp/src/messaging_handler.cpp
@@ -40,7 +40,7 @@ class c_flow_controller : public proton_handler
 
     void redirect(event &e) {
         proton_event *pne = dynamic_cast<proton_event *>(&e);
-        pn_handler_dispatch(flowcontroller, pne->pn_event(), (pn_event_type_t) pne->type());
+        pn_handler_dispatch(flowcontroller, pne->pn_event(), pn_event_type_t(pne->type()));
     }
 
     virtual void on_link_local_open(event &e) { redirect(e); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/proton_bits.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.cpp b/proton-c/bindings/cpp/src/proton_bits.cpp
index 269b7d6..0d41da8 100644
--- a/proton-c/bindings/cpp/src/proton_bits.cpp
+++ b/proton-c/bindings/cpp/src/proton_bits.cpp
@@ -23,7 +23,7 @@
 #include <proton/object.h>
 #include "proton_bits.hpp"
 
-std::string error_str(int code) {
+std::string error_str(long code) {
   switch (code)
   {
   case 0: return "ok";
@@ -39,7 +39,7 @@ std::string error_str(int code) {
   }
 }
 
-std::string error_str(pn_error_t* err, int code) {
+std::string error_str(pn_error_t* err, long code) {
     if (err && pn_error_code(err)) {
         const char* text = pn_error_text(err);
         return text ? std::string(text) : error_str(pn_error_code(err));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp b/proton-c/bindings/cpp/src/proton_bits.hpp
index d615c0f..6ba0848 100644
--- a/proton-c/bindings/cpp/src/proton_bits.hpp
+++ b/proton-c/bindings/cpp/src/proton_bits.hpp
@@ -28,10 +28,10 @@
  * Assorted internal proton utilities.
  */
 
-std::string error_str(int code);
+std::string error_str(long code);
 
 /** Print the error string from pn_error_t, or from code if pn_error_t has no error. */
-std::string error_str(pn_error_t*, int code=0);
+std::string error_str(pn_error_t*, long code=0);
 
 /** Make a void* inspectable via operator <<. */
 struct inspectable { void* value; inspectable(void* o) : value(o) {} };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/proton_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.cpp b/proton-c/bindings/cpp/src/proton_event.cpp
index 1278d33..ce61921 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -153,7 +153,6 @@ void proton_event::dispatch(handler &h) {
           case PN_SELECTABLE_FINAL: handler->on_selectable_final(*this); break;
           default:
             throw error(MSG("Invalid Proton event type " << type_));
-            break;
         }
     } else {
         h.on_unhandled(*this);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/proton_handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_handler.cpp b/proton-c/bindings/cpp/src/proton_handler.cpp
index 7080d39..37030c9 100644
--- a/proton-c/bindings/cpp/src/proton_handler.cpp
+++ b/proton-c/bindings/cpp/src/proton_handler.cpp
@@ -68,6 +68,6 @@ void proton_handler::on_selectable_expired(event &e) { on_unhandled(e); }
 void proton_handler::on_selectable_error(event &e) { on_unhandled(e); }
 void proton_handler::on_selectable_final(event &e) { on_unhandled(e); }
 
-void proton_handler::on_unhandled(event &e) {}
+void proton_handler::on_unhandled(event &) {}
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/ssl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl.cpp b/proton-c/bindings/cpp/src/ssl.cpp
index 4c9138e..1596e38 100644
--- a/proton-c/bindings/cpp/src/ssl.cpp
+++ b/proton-c/bindings/cpp/src/ssl.cpp
@@ -45,7 +45,7 @@ std::string ssl::protocol() const {
 }
 
 ssl::resume_status_t ssl::resume_status() const {
-    return (ssl::resume_status_t) pn_ssl_resume_status(object_);
+    return ssl::resume_status_t(pn_ssl_resume_status(object_));
 }
 
 void ssl::peer_hostname(const std::string &hostname) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/ssl_domain.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp
index d6c427b..95fc552 100644
--- a/proton-c/bindings/cpp/src/ssl_domain.cpp
+++ b/proton-c/bindings/cpp/src/ssl_domain.cpp
@@ -96,19 +96,17 @@ server_domain::server_domain(
     if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
         throw error(MSG("SSL trust store initialization failure for " << trust_db));
     const std::string &db = advertise_db.empty() ? trust_db : advertise_db;
-    if (pn_ssl_domain_set_peer_authentication(dom, (pn_ssl_verify_mode_t) mode, db.c_str()))
+    if (pn_ssl_domain_set_peer_authentication(dom, pn_ssl_verify_mode_t(mode), db.c_str()))
         throw error(MSG("SSL server configuration failure requiring client certificates using " << db));
 }
 
 server_domain::server_domain() : ssl_domain(true) {}
-server_domain::~server_domain() {}
-
 
 namespace {
 void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify_mode_t mode) {
     if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
         throw error(MSG("SSL trust store initialization failure for " << trust_db));
-    if (pn_ssl_domain_set_peer_authentication(dom, (pn_ssl_verify_mode_t) mode, NULL))
+    if (pn_ssl_domain_set_peer_authentication(dom, pn_ssl_verify_mode_t(mode), NULL))
         throw error(MSG("SSL client verify mode failure"));
 }
 }
@@ -124,7 +122,6 @@ client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db,
 }
 
 client_domain::client_domain() : ssl_domain(false) {}
-client_domain::~client_domain() {}
 
 ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra)
     : certdb_main_(main), certdb_extra_(extra), pw_set_(false) {}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/terminus.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/terminus.cpp b/proton-c/bindings/cpp/src/terminus.cpp
index def6aa9..1a8ed8a 100644
--- a/proton-c/bindings/cpp/src/terminus.cpp
+++ b/proton-c/bindings/cpp/src/terminus.cpp
@@ -25,27 +25,27 @@
 namespace proton {
 
 terminus::type_t terminus::type() const {
-    return (type_t) pn_terminus_get_type(object_);
+    return type_t(pn_terminus_get_type(object_));
 }
 
 void terminus::type(type_t type) {
-    pn_terminus_set_type(object_, (pn_terminus_type_t) type);
+    pn_terminus_set_type(object_, pn_terminus_type_t(type));
 }
 
 terminus::expiry_policy_t terminus::expiry_policy() const {
-    return (expiry_policy_t) pn_terminus_get_type(object_);
+    return expiry_policy_t(pn_terminus_get_type(object_));
 }
 
 void terminus::expiry_policy(expiry_policy_t policy) {
-    pn_terminus_set_expiry_policy(object_, (pn_expiry_policy_t) policy);
+    pn_terminus_set_expiry_policy(object_, pn_expiry_policy_t(policy));
 }
 
 terminus::distribution_mode_t terminus::distribution_mode() const {
-    return (distribution_mode_t) pn_terminus_get_type(object_);
+    return distribution_mode_t(pn_terminus_get_type(object_));
 }
 
 void terminus::distribution_mode(distribution_mode_t mode) {
-    pn_terminus_set_distribution_mode(object_, (pn_distribution_mode_t) mode);
+    pn_terminus_set_distribution_mode(object_, pn_distribution_mode_t(mode));
 }
 
 std::string terminus::address() const {
@@ -58,7 +58,7 @@ void terminus::address(const std::string &addr) {
 }
 
 bool terminus::dynamic() const {
-    return (type_t) pn_terminus_is_dynamic(object_);
+    return type_t(pn_terminus_is_dynamic(object_));
 }
 
 void terminus::dynamic(bool d) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/types.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types.cpp b/proton-c/bindings/cpp/src/types.cpp
index 713f15d..d8e40ce 100644
--- a/proton-c/bindings/cpp/src/types.cpp
+++ b/proton-c/bindings/cpp/src/types.cpp
@@ -28,11 +28,12 @@ namespace proton {
 
 namespace {
 inline std::ostream& print_segment(std::ostream& o, const amqp_uuid& u, size_t begin, size_t end, const char* sep="") {
-    for (const char* p = &u[begin]; p < &u[end]; ++p) o << std::setw(2) << std::setfill('0') << ((int)*p & 0xff);
+    for (const char* p = &u[begin]; p < &u[end]; ++p)
+        o << std::setw(2) << std::setfill('0') << (int(*p) & 0xff);
     return o << sep;
 }
 
-std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string()) throw()
+std::string mismatch_message(type_id want, type_id got, const std::string& msg=std::string())
 {
     std::ostringstream s;
     s << "type mismatch: want " << type_name(want) << " got " << type_name(got);
@@ -42,7 +43,7 @@ std::string mismatch_message(type_id want, type_id got, const std::string& msg=s
 }
 
 type_mismatch::type_mismatch(type_id want_, type_id got_, const std::string &msg)
-    throw() : error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
+    : error(mismatch_message(want_, got_, msg)), want(want_), got(got_)
 {}
 
 
@@ -90,12 +91,12 @@ std::string type_name(type_id t) {
       case ARRAY: return "array";
       case LIST: return "list";
       case  MAP: return "map";
-      default: return "unknown";
     }
+    return "unknown";
 }
 
-bool type_id_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
-bool type_id_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
+static bool type_id_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
+static bool type_id_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
 bool type_id_integral(type_id t) { return t == BOOLEAN || t == CHAR || type_id_unsigned_int(t) || type_id_signed_int(t); }
 bool type_id_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
 bool type_id_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fd52a332/proton-c/bindings/cpp/src/url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/url.cpp b/proton-c/bindings/cpp/src/url.cpp
index ec02e53..f6158dd 100644
--- a/proton-c/bindings/cpp/src/url.cpp
+++ b/proton-c/bindings/cpp/src/url.cpp
@@ -26,7 +26,7 @@
 
 namespace proton {
 
-url_error::url_error(const std::string& s) throw() : error(s) {}
+url_error::url_error(const std::string& s) : error(s) {}
 
 namespace {
 


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


[02/50] [abbrv] qpid-proton git commit: PROTON-1069: Windows SChannel: tell transport application input closed or ssl input closed sooner

Posted by ac...@apache.org.
PROTON-1069: Windows SChannel: tell transport application input closed or ssl input closed sooner


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

Branch: refs/heads/go1
Commit: a267629f97c9f088ad4d818079c38461dc79d48d
Parents: f1b484a
Author: Clifford Jansen <cl...@apache.org>
Authored: Sun Nov 29 18:06:15 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Sun Nov 29 18:06:15 2015 -0800

----------------------------------------------------------------------
 proton-c/src/windows/schannel.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a267629f/proton-c/src/windows/schannel.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/schannel.c b/proton-c/src/windows/schannel.c
index 57345d7..7de629f 100644
--- a/proton-c/src/windows/schannel.c
+++ b/proton-c/src/windows/schannel.c
@@ -1523,9 +1523,9 @@ static ssize_t process_input_ssl(pn_transport_t *transport, unsigned int layer,
 
   do {
     if (ssl->sc_input_shutdown) {
-      // TLS protocol shutdown detected on input
+      // TLS protocol shutdown detected on input, so we are done.
       read_closed(transport, layer, 0);
-      return consumed;
+      return PN_EOS;
     }
 
     // sc_inbuf should be ready for new or additional network encrypted bytes.
@@ -1596,7 +1596,7 @@ static ssize_t process_input_ssl(pn_transport_t *transport, unsigned int layer,
         start_ssl_shutdown(transport);
       }
     } else if (ssl->state == SSL_CLOSED) {
-      return consumed ? consumed : -1;
+      return PN_EOS;
     }
 
     // Consume or discard the decrypted bytes
@@ -1632,12 +1632,16 @@ static ssize_t process_input_ssl(pn_transport_t *transport, unsigned int layer,
     }
   } while (available || (ssl->sc_in_count && !ssl->sc_in_incomplete));
 
-  if (ssl->app_input_closed && ssl->state >= SHUTTING_DOWN) {
-    consumed = ssl->app_input_closed;
-    if (transport->io_layers[layer]==&ssl_output_closed_layer) {
-      transport->io_layers[layer] = &ssl_closed_layer;
-    } else {
-      transport->io_layers[layer] = &ssl_input_closed_layer;
+  if (ssl->state >= SHUTTING_DOWN) {
+    if (ssl->app_input_closed || ssl->sc_input_shutdown) {
+      // Next layer doesn't want more bytes, or it can't process without more data than it has seen so far
+      // but the ssl stream has ended
+      consumed = ssl->app_input_closed ? ssl->app_input_closed : PN_EOS;
+      if (transport->io_layers[layer]==&ssl_output_closed_layer) {
+        transport->io_layers[layer] = &ssl_closed_layer;
+      } else {
+        transport->io_layers[layer] = &ssl_input_closed_layer;
+      }
     }
   }
   ssl_log(transport, "process_input_ssl() returning %d, forwarded %d\n", (int) consumed, (int) forwarded);


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


[07/50] [abbrv] qpid-proton git commit: PROTON-1053: sasl support for C++ binding

Posted by ac...@apache.org.
PROTON-1053: sasl support for C++ binding


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

Branch: refs/heads/go1
Commit: 0ebf1d40e49ac95915c47ffc7901e29febb4c739
Parents: eb63824
Author: Clifford Jansen <cl...@apache.org>
Authored: Tue Dec 1 23:55:10 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Tue Dec 1 23:55:49 2015 -0800

----------------------------------------------------------------------
 examples/cpp/CMakeLists.txt                     |   1 +
 examples/cpp/ssl.cpp                            |   4 -
 examples/cpp/ssl_client_cert.cpp                | 176 +++++++++++++++++++
 proton-c/bindings/cpp/CMakeLists.txt            |   1 +
 .../bindings/cpp/include/proton/connection.hpp  |   5 +
 .../cpp/include/proton/connection_options.hpp   |  10 +-
 proton-c/bindings/cpp/include/proton/sasl.hpp   |  60 +++++++
 .../bindings/cpp/include/proton/transport.hpp   |   4 +-
 proton-c/bindings/cpp/src/connection.cpp        |   4 +
 .../bindings/cpp/src/connection_options.cpp     |  33 +++-
 proton-c/bindings/cpp/src/connector.cpp         |   5 +
 proton-c/bindings/cpp/src/container_impl.cpp    |  14 +-
 proton-c/bindings/cpp/src/sasl.cpp              |  47 +++++
 proton-c/bindings/cpp/src/transport.cpp         |   6 +-
 14 files changed, 345 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 3858df3..903294c 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -37,6 +37,7 @@ set(examples
   recurring_timer
   connection_options
   ssl
+  ssl_client_cert
   encode_decode)
 
 if (NOT WIN32)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index f81eb62..13ad76f 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -76,10 +76,6 @@ class hello_world_direct : public proton::messaging_handler {
         client_opts.client_domain(platform_CA("tserver"));
         // Validate the server certificate against the known name in the certificate.
         client_opts.peer_hostname("test_server");
-#ifdef PN_COMING_SOON
-        // Turn off unnecessary SASL processing.
-        client_opts.sasl_enabled(false);
-#endif
         e.container().client_connection_options(client_opts);
 
         s_handler.acceptor = e.container().listen(url);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
new file mode 100644
index 0000000..412162a
--- /dev/null
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -0,0 +1,176 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "proton/acceptor.hpp"
+#include "proton/container.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/connection_options.hpp"
+#include "proton/transport.hpp"
+#include "proton/ssl.hpp"
+#include "proton/sasl.hpp"
+
+#include <iostream>
+
+using proton::connection_options;
+using proton::client_domain;
+using proton::server_domain;
+using proton::ssl_certificate;
+using proton::sasl;
+
+// Helper functions defined below.
+bool using_OpenSSL();
+std::string platform_CA(const std::string &base_name);
+ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd);
+std::string cert_directory;
+
+
+struct server_handler : public proton::messaging_handler {
+    proton::acceptor inbound_listener;
+
+    void on_connection_opened(proton::event &e) {
+        std::cout << "Inbound server connection connected via SSL.  Protocol: " << 
+            e.connection().transport().ssl().protocol() << std::endl;
+        if (e.connection().transport().sasl().outcome() == sasl::OK)
+            std::cout << "Inbound client certificate subject is " << 
+                e.connection().transport().ssl().remote_subject() << std::endl;
+        else {
+            std::cout << "Inbound client authentication failed" <<std::endl;
+            e.connection().close();
+        }
+	inbound_listener.close();
+    }
+
+    void on_message(proton::event &e) {
+        std::cout << e.message().body() << std::endl;
+    }
+};
+
+
+class hello_world_direct : public proton::messaging_handler {
+  private:
+    proton::url url;
+    server_handler s_handler;
+
+  public:
+    hello_world_direct(const proton::url& u) : url(u) {}
+
+    void on_start(proton::event &e) {
+        // Configure listener.  Details vary by platform.
+        ssl_certificate server_cert = platform_certificate("tserver", "tserverpw");
+	std::string client_CA = platform_CA("tclient");
+        // Specify an SSL domain with CA's for client certificate verification.
+        server_domain sdomain(server_cert, client_CA);
+        connection_options server_opts;
+        server_opts.server_domain(sdomain).handler(&s_handler);
+	server_opts.allowed_mechs("EXTERNAL");
+        e.container().server_connection_options(server_opts);
+
+        // Configure client.
+	ssl_certificate client_cert = platform_certificate("tclient", "tclientpw");
+	std::string server_CA = platform_CA("tserver");
+	client_domain cdomain(client_cert, server_CA);
+        connection_options client_opts;
+        client_opts.client_domain(cdomain).allowed_mechs("EXTERNAL");
+        // Validate the server certificate against this name:
+        client_opts.peer_hostname("test_server");
+        e.container().client_connection_options(client_opts);
+
+        s_handler.inbound_listener = e.container().listen(url);
+        e.container().open_sender(url);
+    }
+
+    void on_connection_opened(proton::event &e) {
+        std::cout << "Outgoing client connection connected via SSL.  Server certificate has subject " << 
+            e.connection().transport().ssl().remote_subject() << std::endl;
+    }
+
+    void on_sendable(proton::event &e) {
+        proton::message m;
+        m.body("Hello World!");
+        e.sender().send(m);
+        e.sender().close();
+    }
+
+    void on_accepted(proton::event &e) {
+	// All done.
+        e.connection().close();
+    }
+};
+
+int main(int argc, char **argv) {
+    try {
+        // Pick an "unusual" port since we are going to be talking to ourselves, not a broker.
+	// Note the use of "amqps" as the URL scheme to denote a TLS/SSL connection.
+        std::string url = argc > 1 ? argv[1] : "amqps://127.0.0.1:8888/examples";
+	// Location of certificates and private key information:
+	if (argc > 2) {
+	    cert_directory = argv[2];
+	    size_t sz = cert_directory.size();
+	    if (sz && cert_directory[sz -1] != '/')
+		cert_directory.append("/");
+	}
+	else cert_directory = "ssl_certs/";
+
+        hello_world_direct hwd(url);
+        proton::container(hwd).run();
+        return 0;
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+    }
+    return 1;
+}
+
+
+bool using_OpenSSL() { 
+    // Current defaults.
+#if defined(WIN32)
+    return false;
+#else
+    return true;
+#endif
+}
+
+ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd) {
+    if (using_OpenSSL()) {
+	// The first argument will be the name of the file containing the public certificate, the
+	// second argument will be the name of the file containing the private key.
+	return ssl_certificate(cert_directory + base_name + "-certificate.pem",
+			       cert_directory + base_name + "-private-key.pem", passwd);
+    }
+    else {
+	// Windows SChannel
+	// The first argument will be the database or store that contains one or more complete certificates
+	// (public and private data).  The second will be an optional name of the certificate in the store
+	// (not used in this example with one certificate per store).
+	return ssl_certificate(cert_directory + base_name + "-full.p12", "", passwd);
+    }
+}
+
+std::string platform_CA(const std::string &base_name) {
+    if (using_OpenSSL()) {
+	// In this simple example with self-signed certificates, the peer's certificate is the CA database.
+	return cert_directory + base_name + "-certificate.pem";
+    }
+    else {
+	// Windows SChannel.  Use a pkcs#12 file with just the peer's public certificate information.
+	return cert_directory + base_name + "-certificate.p12";
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 6bc6445..bcdc61b 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -62,6 +62,7 @@ set(qpid-proton-cpp-source
   src/receiver.cpp
   src/reconnect_timer.cpp
   src/request_response.cpp
+  src/sasl.cpp
   src/sender.cpp
   src/session.cpp
   src/ssl.cpp

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp
index cc8c5ba..338e542 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -107,6 +107,11 @@ class connection : public object<pn_connection_t>, endpoint
     /** Get the endpoint state */
     PN_CPP_EXTERN endpoint::state state() const;
 
+  private:
+    PN_CPP_EXTERN void user(const std::string &);
+    PN_CPP_EXTERN void password(const std::string &);
+
+    
     friend class connection_options;
     friend class connector;
     friend class transport;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index c9701c9..6c78f54 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -75,20 +75,16 @@ class connection_options {
     PN_CPP_EXTERN connection_options& server_domain(const class server_domain &);
     PN_CPP_EXTERN connection_options& peer_hostname(const std::string &name);
     PN_CPP_EXTERN connection_options& resume_id(const std::string &id);
-#ifdef PN_CPP_SOON
     PN_CPP_EXTERN connection_options& sasl_enabled(bool);
     PN_CPP_EXTERN connection_options& allow_insecure_mechs(bool);
     PN_CPP_EXTERN connection_options& allowed_mechs(const std::string &);
-#endif
+    PN_CPP_EXTERN connection_options& sasl_config_name(const std::string &);
+    PN_CPP_EXTERN connection_options& sasl_config_path(const std::string &);
+
   private:
     void apply(connection&) const;
     class handler* handler() const;
     static pn_connection_t *pn_connection(connection &);
-#ifdef PN_CPP_SOON
-    bool sasl_enabled() const;
-    bool allow_insecure_mechs() const;
-    std::string *allowed_mechs() const;
-#endif
     class client_domain &client_domain();
     class server_domain &server_domain();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/include/proton/sasl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sasl.hpp b/proton-c/bindings/cpp/include/proton/sasl.hpp
new file mode 100644
index 0000000..4432d8d
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/sasl.hpp
@@ -0,0 +1,60 @@
+#ifndef PROTON_CPP_SASL_H
+#define PROTON_CPP_SASL_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include "proton/export.hpp"
+#include "proton/sasl.h"
+#include <string>
+
+namespace proton {
+
+class sasl {
+  public:
+    /** The result of the SASL negotiation */
+    enum outcome_t {
+        NONE = PN_SASL_NONE,   /** negotiation not completed */
+        OK = PN_SASL_OK,       /** authentication succeeded */
+        AUTH = PN_SASL_AUTH,   /** failed due to bad credentials */
+        SYS = PN_SASL_SYS,     /** failed due to a system error */
+        PERM = PN_SASL_PERM,   /** failed due to unrecoverable error */
+        TEMP = PN_SASL_TEMP    /** failed due to transient error */
+    };
+
+    sasl(pn_sasl_t* s) : object_(s) {}
+    PN_CPP_EXTERN static bool extended();
+    PN_CPP_EXTERN void done(outcome_t);
+    PN_CPP_EXTERN outcome_t outcome() const;
+    PN_CPP_EXTERN std::string user() const;
+    PN_CPP_EXTERN std::string mech() const;
+
+    PN_CPP_EXTERN void allow_insecure_mechs(bool);
+    PN_CPP_EXTERN bool allow_insecure_mechs();
+    PN_CPP_EXTERN void allowed_mechs(const std::string &);
+    PN_CPP_EXTERN void config_name(const std::string&);
+    PN_CPP_EXTERN void config_path(const std::string&);
+private:
+    pn_sasl_t* object_;
+};
+
+}
+
+#endif  /*!PROTON_CPP_SASL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/include/proton/transport.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/transport.hpp b/proton-c/bindings/cpp/include/proton/transport.hpp
index 3f664bc..971913b 100644
--- a/proton-c/bindings/cpp/include/proton/transport.hpp
+++ b/proton-c/bindings/cpp/include/proton/transport.hpp
@@ -31,6 +31,7 @@ struct pn_transport_t;
 namespace proton {
 
 class connection;
+class sasl;
 
 /** Represents a connection transport */
 class transport : public object<pn_transport_t>
@@ -39,6 +40,8 @@ class transport : public object<pn_transport_t>
     transport(pn_transport_t* t) : object<pn_transport_t>(t) {}
 
     PN_CPP_EXTERN class connection connection() const;
+    PN_CPP_EXTERN class ssl ssl() const;
+    PN_CPP_EXTERN class sasl sasl() const;
     PN_CPP_EXTERN void unbind();
     PN_CPP_EXTERN void bind(class connection &);
     PN_CPP_EXTERN uint32_t max_frame_size() const;
@@ -47,7 +50,6 @@ class transport : public object<pn_transport_t>
     PN_CPP_EXTERN uint16_t remote_max_channels() const;
     PN_CPP_EXTERN uint32_t idle_timeout() const;
     PN_CPP_EXTERN uint32_t remote_idle_timeout() const;
-    PN_CPP_EXTERN class ssl ssl() const;
     friend class connection_options;
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/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 733face..508a013 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -110,4 +110,8 @@ receiver connection::open_receiver(const std::string &addr, bool dynamic, handle
 
 endpoint::state connection::state() const { return pn_connection_state(pn_object()); }
 
+void connection::user(const std::string &name) { pn_connection_set_user(pn_object(), name.c_str()); }
+
+void connection::password(const std::string &pass) { pn_connection_set_password(pn_object(), pass.c_str()); }
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 5097e42..141ffc9 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -22,6 +22,7 @@
 #include "proton/reconnect_timer.hpp"
 #include "proton/transport.hpp"
 #include "proton/ssl.hpp"
+#include "proton/sasl.hpp"
 #include "contexts.hpp"
 #include "connector.hpp"
 #include "msg.hpp"
@@ -52,11 +53,11 @@ class connection_options::impl {
     option<class server_domain> server_domain;
     option<std::string> peer_hostname;
     option<std::string> resume_id;
-#ifdef PN_CCP_SOON
     option<bool> sasl_enabled;
     option<std::string> allowed_mechs;
     option<bool> allow_insecure_mechs;
-#endif
+    option<std::string> sasl_config_name;
+    option<std::string> sasl_config_path;
 
     void apply(connection& c) {
         pn_connection_t *pnc = connection_options::pn_connection(c);
@@ -69,6 +70,7 @@ class connection_options::impl {
         // transport not yet configured.
         if (pnt && (uninit || (outbound && !outbound->transport_configured())))
         {
+            // SSL
             if (outbound && outbound->address().scheme() == url::AMQPS) {
                 // Configure outbound ssl options. pni_acceptor_readable handles the inbound case.
                 const char* id = resume_id.value.empty() ? NULL : resume_id.value.c_str();
@@ -89,6 +91,22 @@ class connection_options::impl {
                 }
 #endif
             }
+
+            // SASL
+            transport t = c.transport();
+            if (!sasl_enabled.set || sasl_enabled.value) {
+                if (sasl_enabled.set)  // Explicitly set, not just default behaviour.
+                    t.sasl();          // Force a sasl instance.  Lazily create one otherwise.
+                if (allow_insecure_mechs.set)
+                    t.sasl().allow_insecure_mechs(allow_insecure_mechs.value);
+                if (allowed_mechs.set)
+                    t.sasl().allowed_mechs(allowed_mechs.value);
+                if (sasl_config_name.set)
+                    t.sasl().config_name(sasl_config_name.value);
+                if (sasl_config_path.set)
+                    t.sasl().config_path(sasl_config_path.value);
+            }
+
             if (max_frame_size.set)
                 pn_transport_set_max_frame(pnt, max_frame_size.value);
             if (max_channels.set)
@@ -117,6 +135,11 @@ class connection_options::impl {
         server_domain.override(x.server_domain);
         resume_id.override(x.resume_id);
         peer_hostname.override(x.peer_hostname);
+        sasl_enabled.override(x.sasl_enabled);
+        allow_insecure_mechs.override(x.allow_insecure_mechs);
+        allowed_mechs.override(x.allowed_mechs);
+        sasl_config_name.override(x.sasl_config_name);
+        sasl_config_path.override(x.sasl_config_path);
     }
 
 };
@@ -145,11 +168,15 @@ connection_options& connection_options::client_domain(const class client_domain
 connection_options& connection_options::server_domain(const class server_domain &c) { impl_->server_domain = c; return *this; }
 connection_options& connection_options::resume_id(const std::string &id) { impl_->resume_id = id; return *this; }
 connection_options& connection_options::peer_hostname(const std::string &name) { impl_->peer_hostname = name; return *this; }
+connection_options& connection_options::sasl_enabled(bool b) { impl_->sasl_enabled = b; return *this; }
+connection_options& connection_options::allow_insecure_mechs(bool b) { impl_->allow_insecure_mechs = b; return *this; }
+connection_options& connection_options::allowed_mechs(const std::string &s) { impl_->allowed_mechs = s; return *this; }
+connection_options& connection_options::sasl_config_name(const std::string &n) { impl_->sasl_config_name = n; return *this; }
+connection_options& connection_options::sasl_config_path(const std::string &p) { impl_->sasl_config_path = p; return *this; }
 
 void connection_options::apply(connection& c) const { impl_->apply(c); }
 class client_domain &connection_options::client_domain() { return impl_->client_domain.value; }
 class server_domain &connection_options::server_domain() { return impl_->server_domain.value; }
 handler* connection_options::handler() const { return impl_->handler.value; }
-
 pn_connection_t* connection_options::pn_connection(connection &c) { return c.pn_object(); }
 } // namespace proton

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/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 90a16e6..e2bb802 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -27,6 +27,7 @@
 #include "proton/url.hpp"
 #include "proton/reconnect_timer.hpp"
 #include "proton/task.hpp"
+#include "proton/sasl.hpp"
 #include "container_impl.hpp"
 
 #include "proton/connection.h"
@@ -62,6 +63,10 @@ void connector::connect() {
     connection_.host(address_.host_port());
     pn_transport_t *pnt = pn_transport();
     transport t(pnt);
+    if (!address_.username().empty())
+        connection_.user(address_.username());
+    if (!address_.password().empty())
+        connection_.password(address_.password());
     t.bind(connection_);
     pn_decref((void *)pnt);
     // Apply options to the new transport.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/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 1ff734b..7d64ebc 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -32,6 +32,8 @@
 #include "proton/receiver.hpp"
 #include "proton/task.hpp"
 #include "proton/ssl.hpp"
+#include "proton/sasl.hpp"
+#include "proton/transport.hpp"
 
 #include "msg.hpp"
 #include "container_impl.hpp"
@@ -234,21 +236,15 @@ void container_impl::server_connection_options(const connection_options &opts) {
 }
 
 void container_impl::configure_server_connection(connection &c) {
-#ifdef PN_COMING_SOON
+#ifdef PN_1054_FIXED
     pn_acceptor_t *pnp = pn_connection_acceptor(pn_cast(&c));
     listener_context &lc(listener_context::get(pnp));
     class connection_options &opts(lc.connection_options);
-    if (opts.sasl_enabled()) {
-        sasl &s(c.transport().sasl());
-        s.allow_insecure_mechs(opts.allow_insecure_mechs());
-        if (opts.allowed_mechs())
-            s.allowed_mechs(*opts.allowed_mechs());
-    }
-    opts.apply(c);
 #else
     // Can't distinguish between multiple listeners yet.  See PROTON-1054
-    server_connection_options_.apply(c);
+    class connection_options &opts(server_connection_options_);
 #endif
+    opts.apply(c);
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/src/sasl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/sasl.cpp b/proton-c/bindings/cpp/src/sasl.cpp
new file mode 100644
index 0000000..9638a52
--- /dev/null
+++ b/proton-c/bindings/cpp/src/sasl.cpp
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "proton/sasl.hpp"
+
+namespace proton {
+
+bool sasl::extended() { return pn_sasl_extended(); }
+void sasl::done(outcome_t outcome) { pn_sasl_done(object_, static_cast<pn_sasl_outcome_t>(outcome)); }
+sasl::outcome_t sasl::outcome() const { return static_cast<outcome_t>(pn_sasl_outcome(object_)); }
+
+std::string sasl::user() const {
+    const char *name = pn_sasl_get_user(object_);
+    return name ? std::string(name) : std::string();
+}
+
+std::string sasl::mech() const {
+    const char *m = pn_sasl_get_mech(object_);
+    return m ? std::string(m) : std::string();
+}
+
+void sasl::allow_insecure_mechs(bool allowed) { pn_sasl_set_allow_insecure_mechs(object_, allowed); }
+bool sasl::allow_insecure_mechs() { return pn_sasl_get_allow_insecure_mechs(object_); }
+void sasl::allowed_mechs(const std::string &mechs) { pn_sasl_allowed_mechs(object_, mechs.c_str()); }
+void sasl::config_name(const std::string &name) { pn_sasl_config_name(object_, name.c_str()); }
+void sasl::config_path(const std::string &path) { pn_sasl_config_path(object_, path.c_str()); }
+
+
+} // namespace

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0ebf1d40/proton-c/bindings/cpp/src/transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/transport.cpp b/proton-c/bindings/cpp/src/transport.cpp
index f6ccfa0..4db78d0 100644
--- a/proton-c/bindings/cpp/src/transport.cpp
+++ b/proton-c/bindings/cpp/src/transport.cpp
@@ -21,6 +21,7 @@
 #include "proton/transport.hpp"
 #include "proton/connection.hpp"
 #include "proton/ssl.hpp"
+#include "proton/sasl.hpp"
 #include "msg.hpp"
 #include "proton/transport.h"
 
@@ -34,13 +35,16 @@ class ssl transport::ssl() const {
     return proton::ssl(pn_ssl(pn_object()));
 }
 
+class sasl transport::sasl() const {
+    return proton::sasl(pn_sasl(pn_object()));
+}
+
 void transport::unbind() {
     if (pn_transport_unbind(pn_object()))
         throw error(MSG("transport::unbind failed " << pn_error_text(pn_transport_error(pn_object()))));
 }
 
 void transport::bind(class connection &conn) {
-//    pn_connection_t *c = static_cast<pn_connection_t*>(conn.object_);
     if (pn_transport_bind(pn_object(), conn.pn_object()))
         throw error(MSG("transport::bind failed " << pn_error_text(pn_transport_error(pn_object()))));
 }


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


[26/50] [abbrv] qpid-proton git commit: NO-JIRA: cpp: Add correct valgrind flags to example_test.py script.

Posted by ac...@apache.org.
NO-JIRA: cpp: Add correct valgrind flags to example_test.py script.


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

Branch: refs/heads/go1
Commit: 32fa7cb0597af84b1843cd9bb7a6088b5d7d52d0
Parents: 1da4b12
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 14 13:03:42 2015 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 14 13:03:42 2015 -0500

----------------------------------------------------------------------
 examples/cpp/example_test.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/32fa7cb0/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 3ea0c28..1f800c0 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -33,7 +33,8 @@ def cmdline(*args):
     if platform.system() == "Windows":
         args[0] += ".exe"
     if "VALGRIND" in os.environ and os.environ["VALGRIND"]:
-        args = [os.environ["VALGRIND"], "-q"] + args
+        args = [os.environ["VALGRIND"], "--error-exitcode=42", "--quiet",
+                "--leak-check=full"] + args
     return args
 
 def background(*args):


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


[32/50] [abbrv] qpid-proton git commit: PROTON-1049: check sasl setup before running tests

Posted by ac...@apache.org.
PROTON-1049: check sasl setup before running tests


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

Branch: refs/heads/go1
Commit: ff13d7699647b0453d324fe6431827a55fd8deb8
Parents: fefb81d
Author: Gordon Sim <gs...@redhat.com>
Authored: Wed Dec 16 09:27:54 2015 +0000
Committer: Gordon Sim <gs...@redhat.com>
Committed: Wed Dec 16 09:27:54 2015 +0000

----------------------------------------------------------------------
 tests/python/proton_tests/reactor.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ff13d769/tests/python/proton_tests/reactor.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py
index e8446ca..beff329 100644
--- a/tests/python/proton_tests/reactor.py
+++ b/tests/python/proton_tests/reactor.py
@@ -19,7 +19,7 @@ from __future__ import absolute_import
 #
 
 import time
-from .common import Test, SkipTest, TestServer, free_tcp_port
+from .common import Test, SkipTest, TestServer, free_tcp_port, ensureCanTestExtendedSASL
 from proton.reactor import Container, Reactor, ApplicationEvent, EventInjector
 from proton.handlers import CHandshaker, MessagingHandler
 from proton import Handler
@@ -508,12 +508,14 @@ class ContainerTest(Test):
         container.run()
 
     def test_authentication_via_url(self):
+        ensureCanTestExtendedSASL()
         test_handler = AuthenticationTestHandler()
         container = Container(test_handler)
         container.connect("%s:password@%s" % ("user%40proton", test_handler.url))
         container.run()
 
     def test_authentication_via_container_attributes(self):
+        ensureCanTestExtendedSASL()
         test_handler = AuthenticationTestHandler()
         container = Container(test_handler)
         container.user = "user@proton"
@@ -522,6 +524,7 @@ class ContainerTest(Test):
         container.run()
 
     def test_authentication_via_kwargs(self):
+        ensureCanTestExtendedSASL()
         test_handler = AuthenticationTestHandler()
         container = Container(test_handler)
         container.connect(test_handler.url, user="user@proton", password="password")


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


[20/50] [abbrv] qpid-proton git commit: PROTON-1074: C++ ssl_domain: restore removed ref counting; add test

Posted by ac...@apache.org.
PROTON-1074: C++ ssl_domain: restore removed ref counting; add test


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

Branch: refs/heads/go1
Commit: d9c0ed5a4087b621af13c2f395afba91f2bd9063
Parents: 595a854
Author: Clifford Jansen <cl...@apache.org>
Authored: Fri Dec 11 09:25:46 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Fri Dec 11 09:57:04 2015 -0800

----------------------------------------------------------------------
 examples/cpp/example_test.py                 | 25 +++++++
 examples/cpp/ssl.cpp                         | 17 ++++-
 examples/cpp/ssl_client_cert.cpp             | 86 +++++++++++++----------
 proton-c/bindings/cpp/include/proton/ssl.hpp | 13 ++--
 proton-c/bindings/cpp/src/ssl_domain.cpp     | 72 +++++++++++++------
 5 files changed, 149 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9c0ed5a/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 2f8b08c..3ea0c28 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -25,6 +25,7 @@ from  random import randrange
 from subprocess import Popen, PIPE, STDOUT
 from copy import copy
 import platform
+from os.path import dirname as dirname
 
 def cmdline(*args):
     """Adjust executable name args[0] for windows and/or valgrind"""
@@ -82,6 +83,11 @@ def pick_addr():
     p =  randrange(10000, 20000)
     return "127.0.0.1:%s" % p
 
+def ssl_certs_dir():
+    """Absolute path to the test SSL certificates"""
+    pn_root = dirname(dirname(dirname(sys.argv[0])))
+    return os.path.join(pn_root, "examples/cpp/ssl_certs")
+
 class Broker(object):
     """Run the test broker"""
 
@@ -237,5 +243,24 @@ Tock...
         finally:
             os.environ = env    # Restore environment
 
+    def test_ssl(self):
+        # SSL without SASL
+        expect="""Outgoing client connection connected via SSL.  Server certificate identity CN=test_server
+"Hello World!"
+"""
+        addr = "amqps://" + pick_addr() + "/examples"
+        ignore_first_line, ignore_nl, ssl_hw = execute("ssl", addr, ssl_certs_dir()).partition('\n')
+        self.assertEqual(expect, ssl_hw)
+
+    def test_ssl_client_cert(self):
+        # SSL with SASL EXTERNAL
+        expect="""Inbound client certificate identity CN=test_client
+Outgoing client connection connected via SSL.  Server certificate identity CN=test_server
+"Hello World!"
+"""
+        addr = "amqps://" + pick_addr() + "/examples"
+        ignore_first_line, ignore_nl, ssl_hw = execute("ssl_client_cert", addr, ssl_certs_dir()).partition('\n')
+        self.assertEqual(expect, ssl_hw)
+
 if __name__ == "__main__":
     unittest.main()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9c0ed5a/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index 13ad76f..5e670c2 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -38,6 +38,7 @@ bool using_OpenSSL();
 std::string platform_CA(const std::string &base_name);
 ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd);
 std::string cert_directory;
+std::string find_CN(const std::string &);
 
 
 struct server_handler : public proton::messaging_handler {
@@ -83,8 +84,9 @@ class hello_world_direct : public proton::messaging_handler {
     }
 
     void on_connection_opened(proton::event &e) {
-        std::cout << "Outgoing client connection connected via SSL.  Server certificate has subject " <<
-            e.connection().transport().ssl().remote_subject() << std::endl;
+        std::string subject = e.connection().transport().ssl().remote_subject();
+        std::cout << "Outgoing client connection connected via SSL.  Server certificate identity " <<
+            find_CN(subject) << std::endl;
     }
 
     void on_sendable(proton::event &e) {
@@ -159,3 +161,14 @@ std::string platform_CA(const std::string &base_name) {
         return cert_directory + base_name + "-certificate.p12";
     }
 }
+
+std::string find_CN(const std::string &subject) {
+    // The subject string is returned with different whitespace and component ordering between platforms.
+    // Here we just return the common name by searching for "CN=...." in the subject, knowing that
+    // the test certificates do not contain any escaped characters.
+    size_t pos = subject.find("CN=");
+    if (pos == std::string::npos) throw std::runtime_error("No common name in certificate subject");
+    std::string cn = subject.substr(pos);
+    pos = cn.find(',');
+    return pos == std::string::npos ? cn : cn.substr(0, pos);
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9c0ed5a/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
index 412162a..0be0c32 100644
--- a/examples/cpp/ssl_client_cert.cpp
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -40,22 +40,24 @@ bool using_OpenSSL();
 std::string platform_CA(const std::string &base_name);
 ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd);
 std::string cert_directory;
+std::string find_CN(const std::string &);
 
 
 struct server_handler : public proton::messaging_handler {
     proton::acceptor inbound_listener;
 
     void on_connection_opened(proton::event &e) {
-        std::cout << "Inbound server connection connected via SSL.  Protocol: " << 
+        std::cout << "Inbound server connection connected via SSL.  Protocol: " <<
             e.connection().transport().ssl().protocol() << std::endl;
-        if (e.connection().transport().sasl().outcome() == sasl::OK)
-            std::cout << "Inbound client certificate subject is " << 
-                e.connection().transport().ssl().remote_subject() << std::endl;
+        if (e.connection().transport().sasl().outcome() == sasl::OK) {
+            std::string subject = e.connection().transport().ssl().remote_subject();
+            std::cout << "Inbound client certificate identity " << find_CN(subject) << std::endl;
+        }
         else {
             std::cout << "Inbound client authentication failed" <<std::endl;
             e.connection().close();
         }
-	inbound_listener.close();
+        inbound_listener.close();
     }
 
     void on_message(proton::event &e) {
@@ -75,18 +77,18 @@ class hello_world_direct : public proton::messaging_handler {
     void on_start(proton::event &e) {
         // Configure listener.  Details vary by platform.
         ssl_certificate server_cert = platform_certificate("tserver", "tserverpw");
-	std::string client_CA = platform_CA("tclient");
+        std::string client_CA = platform_CA("tclient");
         // Specify an SSL domain with CA's for client certificate verification.
         server_domain sdomain(server_cert, client_CA);
         connection_options server_opts;
         server_opts.server_domain(sdomain).handler(&s_handler);
-	server_opts.allowed_mechs("EXTERNAL");
+        server_opts.allowed_mechs("EXTERNAL");
         e.container().server_connection_options(server_opts);
 
         // Configure client.
-	ssl_certificate client_cert = platform_certificate("tclient", "tclientpw");
-	std::string server_CA = platform_CA("tserver");
-	client_domain cdomain(client_cert, server_CA);
+        ssl_certificate client_cert = platform_certificate("tclient", "tclientpw");
+        std::string server_CA = platform_CA("tserver");
+        client_domain cdomain(client_cert, server_CA);
         connection_options client_opts;
         client_opts.client_domain(cdomain).allowed_mechs("EXTERNAL");
         // Validate the server certificate against this name:
@@ -98,8 +100,9 @@ class hello_world_direct : public proton::messaging_handler {
     }
 
     void on_connection_opened(proton::event &e) {
-        std::cout << "Outgoing client connection connected via SSL.  Server certificate has subject " << 
-            e.connection().transport().ssl().remote_subject() << std::endl;
+        std::string subject = e.connection().transport().ssl().remote_subject();
+        std::cout << "Outgoing client connection connected via SSL.  Server certificate identity " <<
+            find_CN(subject) << std::endl;
     }
 
     void on_sendable(proton::event &e) {
@@ -110,7 +113,7 @@ class hello_world_direct : public proton::messaging_handler {
     }
 
     void on_accepted(proton::event &e) {
-	// All done.
+        // All done.
         e.connection().close();
     }
 };
@@ -118,16 +121,16 @@ class hello_world_direct : public proton::messaging_handler {
 int main(int argc, char **argv) {
     try {
         // Pick an "unusual" port since we are going to be talking to ourselves, not a broker.
-	// Note the use of "amqps" as the URL scheme to denote a TLS/SSL connection.
+        // Note the use of "amqps" as the URL scheme to denote a TLS/SSL connection.
         std::string url = argc > 1 ? argv[1] : "amqps://127.0.0.1:8888/examples";
-	// Location of certificates and private key information:
-	if (argc > 2) {
-	    cert_directory = argv[2];
-	    size_t sz = cert_directory.size();
-	    if (sz && cert_directory[sz -1] != '/')
-		cert_directory.append("/");
-	}
-	else cert_directory = "ssl_certs/";
+        // Location of certificates and private key information:
+        if (argc > 2) {
+            cert_directory = argv[2];
+            size_t sz = cert_directory.size();
+            if (sz && cert_directory[sz -1] != '/')
+                cert_directory.append("/");
+        }
+        else cert_directory = "ssl_certs/";
 
         hello_world_direct hwd(url);
         proton::container(hwd).run();
@@ -139,7 +142,7 @@ int main(int argc, char **argv) {
 }
 
 
-bool using_OpenSSL() { 
+bool using_OpenSSL() {
     // Current defaults.
 #if defined(WIN32)
     return false;
@@ -150,27 +153,38 @@ bool using_OpenSSL() {
 
 ssl_certificate platform_certificate(const std::string &base_name, const std::string &passwd) {
     if (using_OpenSSL()) {
-	// The first argument will be the name of the file containing the public certificate, the
-	// second argument will be the name of the file containing the private key.
-	return ssl_certificate(cert_directory + base_name + "-certificate.pem",
-			       cert_directory + base_name + "-private-key.pem", passwd);
+        // The first argument will be the name of the file containing the public certificate, the
+        // second argument will be the name of the file containing the private key.
+        return ssl_certificate(cert_directory + base_name + "-certificate.pem",
+                               cert_directory + base_name + "-private-key.pem", passwd);
     }
     else {
-	// Windows SChannel
-	// The first argument will be the database or store that contains one or more complete certificates
-	// (public and private data).  The second will be an optional name of the certificate in the store
-	// (not used in this example with one certificate per store).
-	return ssl_certificate(cert_directory + base_name + "-full.p12", "", passwd);
+        // Windows SChannel
+        // The first argument will be the database or store that contains one or more complete certificates
+        // (public and private data).  The second will be an optional name of the certificate in the store
+        // (not used in this example with one certificate per store).
+        return ssl_certificate(cert_directory + base_name + "-full.p12", "", passwd);
     }
 }
 
 std::string platform_CA(const std::string &base_name) {
     if (using_OpenSSL()) {
-	// In this simple example with self-signed certificates, the peer's certificate is the CA database.
-	return cert_directory + base_name + "-certificate.pem";
+        // In this simple example with self-signed certificates, the peer's certificate is the CA database.
+        return cert_directory + base_name + "-certificate.pem";
     }
     else {
-	// Windows SChannel.  Use a pkcs#12 file with just the peer's public certificate information.
-	return cert_directory + base_name + "-certificate.p12";
+        // Windows SChannel.  Use a pkcs#12 file with just the peer's public certificate information.
+        return cert_directory + base_name + "-certificate.p12";
     }
 }
+
+std::string find_CN(const std::string &subject) {
+    // The subject string is returned with different whitespace and component ordering between platforms.
+    // Here we just return the common name by searching for "CN=...." in the subject, knowing that
+    // the test certificates do not contain any escaped characters.
+    size_t pos = subject.find("CN=");
+    if (pos == std::string::npos) throw std::runtime_error("No common name in certificate subject");
+    std::string cn = subject.substr(pos);
+    pos = cn.find(',');
+    return pos == std::string::npos ? cn : cn.substr(0, pos);
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9c0ed5a/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index f1b5974..bb78ae3 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -71,18 +71,22 @@ class ssl_certificate {
     friend class server_domain;
 };
 
+
+class ssl_domain_impl;
+
 // Base class for SSL configuration
 class ssl_domain {
   public:
+    PN_CPP_EXTERN ssl_domain(const ssl_domain&);
+    PN_CPP_EXTERN ssl_domain& operator=(const ssl_domain&);
     ~ssl_domain();
 
   protected:
-    ssl_domain();
-    pn_ssl_domain_t *init(bool is_server);
+    ssl_domain(bool is_server);
     pn_ssl_domain_t *pn_domain();
 
   private:
-    pn_ssl_domain_t *impl_;
+    ssl_domain_impl *impl_;
 };
 
 /** SSL/TLS configuration for inbound connections created from a listener */
@@ -122,9 +126,6 @@ class client_domain : private ssl_domain {
     friend class connection_options;
 };
 
-
-
-
 }
 
 #endif  /*!PROTON_CPP_SSL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d9c0ed5a/proton-c/bindings/cpp/src/ssl_domain.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp
index 2631880..9062713 100644
--- a/proton-c/bindings/cpp/src/ssl_domain.cpp
+++ b/proton-c/bindings/cpp/src/ssl_domain.cpp
@@ -26,19 +26,50 @@
 
 namespace proton {
 
-ssl_domain::ssl_domain() : impl_(0) {}
-
-// Create on demand
-pn_ssl_domain_t *ssl_domain::init(bool server_type) {
-    if (impl_) return impl_;
-    impl_ = pn_ssl_domain(server_type ? PN_SSL_MODE_SERVER : PN_SSL_MODE_CLIENT);
-    if (!impl_) throw error(MSG("SSL/TLS unavailable"));
-    return impl_;
+class ssl_domain_impl {
+  public:
+    ssl_domain_impl(bool is_server) : refcount_(1), server_type_(is_server), pn_domain_(0) {}
+    void incref() { refcount_++; }
+    void decref() {
+        if (--refcount_ == 0) {
+            if (pn_domain_) pn_ssl_domain_free(pn_domain_);
+            delete this;
+        }
+    }
+    pn_ssl_domain_t *pn_domain();
+  private:
+    int refcount_;
+    bool server_type_;
+    pn_ssl_domain_t *pn_domain_;
+    ssl_domain_impl(const ssl_domain_impl&);
+    ssl_domain_impl& operator=(const ssl_domain_impl&);
+};
+
+pn_ssl_domain_t *ssl_domain_impl::pn_domain() {
+    if (pn_domain_) return pn_domain_;
+    // Lazily create in case never actually used or configured.
+    pn_domain_ = pn_ssl_domain(server_type_ ? PN_SSL_MODE_SERVER : PN_SSL_MODE_CLIENT);
+    if (!pn_domain_) throw error(MSG("SSL/TLS unavailable"));
+    return pn_domain_;
 }
 
-pn_ssl_domain_t *ssl_domain::pn_domain() { return impl_; }
+ssl_domain::ssl_domain(bool is_server) : impl_(new ssl_domain_impl(is_server)) {}
+
+ssl_domain::ssl_domain(const ssl_domain &x) {
+    impl_ = x.impl_;
+    impl_->incref();
+}
+ssl_domain& ssl_domain::operator=(const ssl_domain&x) {
+    if (this != &x) {
+        impl_ = x.impl_;
+        impl_->incref();
+    }
+    return *this;
+}
+ssl_domain::~ssl_domain() { impl_->decref(); }
+
+pn_ssl_domain_t *ssl_domain::pn_domain() { return impl_->pn_domain(); }
 
-ssl_domain::~ssl_domain() { if (impl_) pn_ssl_domain_free(impl_); }
 
 namespace {
 
@@ -51,17 +82,17 @@ void set_cred(pn_ssl_domain_t *dom, const std::string &main, const std::string &
 }
 }
 
-server_domain::server_domain(ssl_certificate &cert) {
-    set_cred(init(true), cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
+server_domain::server_domain(ssl_certificate &cert) : ssl_domain(true) {
+    set_cred(pn_domain(), cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
 }
 
 server_domain::server_domain(
     ssl_certificate &cert,
     const std::string &trust_db,
     const std::string &advertise_db,
-    ssl::verify_mode_t mode)
+    ssl::verify_mode_t mode) : ssl_domain(true)
 {
-    pn_ssl_domain_t* dom = init(true);
+    pn_ssl_domain_t* dom = pn_domain();
     set_cred(dom, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
     if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
         throw error(MSG("SSL trust store initialization failure for " << trust_db));
@@ -70,9 +101,10 @@ server_domain::server_domain(
         throw error(MSG("SSL server configuration failure requiring client certificates using " << db));
 }
 
-server_domain::server_domain() {}
+server_domain::server_domain() : ssl_domain(true) {}
 server_domain::~server_domain() {}
 
+
 namespace {
 void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify_mode_t mode) {
     if (pn_ssl_domain_set_trusted_ca_db(dom, trust_db.c_str()))
@@ -82,17 +114,17 @@ void client_setup(pn_ssl_domain_t *dom, const std::string &trust_db, ssl::verify
 }
 }
 
-client_domain::client_domain(const std::string &trust_db, ssl::verify_mode_t mode) {
-    client_setup(init(false), trust_db, mode);
+client_domain::client_domain(const std::string &trust_db, ssl::verify_mode_t mode) : ssl_domain(false) {
+    client_setup(pn_domain(), trust_db, mode);
 }
 
-client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db, ssl::verify_mode_t mode) {
-    pn_ssl_domain_t *dom = init(false);
+client_domain::client_domain(ssl_certificate &cert, const std::string &trust_db, ssl::verify_mode_t mode) : ssl_domain(false) {
+    pn_ssl_domain_t *dom = pn_domain();
     set_cred(dom, cert.certdb_main_, cert.certdb_extra_, cert.passwd_, cert.pw_set_);
     client_setup(dom, trust_db, mode);
 }
 
-client_domain::client_domain() {}
+client_domain::client_domain() : ssl_domain(false) {}
 client_domain::~client_domain() {}
 
 ssl_certificate::ssl_certificate(const std::string &main, const std::string &extra)


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


[14/50] [abbrv] qpid-proton git commit: NO-JIRA: Windows C++ jenkins failure: missing extern

Posted by ac...@apache.org.
NO-JIRA: Windows C++ jenkins failure: missing extern


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

Branch: refs/heads/go1
Commit: f160ada85748bfd0813c69f56160f322d40570f3
Parents: 19a3035
Author: Clifford Jansen <cl...@apache.org>
Authored: Tue Dec 8 22:45:15 2015 -0800
Committer: Clifford Jansen <cl...@apache.org>
Committed: Tue Dec 8 22:45:15 2015 -0800

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/ssl.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f160ada8/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index 911bbed..437b8e2 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -75,7 +75,7 @@ class ssl_certificate {
 // Base class for SSL configuration
 class ssl_domain {
   public:
-    ~ssl_domain();
+    PN_CPP_EXTERN ~ssl_domain();
 
   protected:
     ssl_domain();


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