diff options
-rwxr-xr-x | qpid/cpp/rubygen/framing.0-10/constants.rb | 47 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/SessionState.cpp | 5 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/amqp_0_10/SessionHandler.cpp | 11 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/ConnectionHandler.cpp | 4 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/SessionAdapter.cpp | 25 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/client/ConnectionImpl.cpp | 11 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/client/SessionImpl.cpp | 6 |
7 files changed, 61 insertions, 48 deletions
diff --git a/qpid/cpp/rubygen/framing.0-10/constants.rb b/qpid/cpp/rubygen/framing.0-10/constants.rb index e1c255cb73..179e5f9f93 100755 --- a/qpid/cpp/rubygen/framing.0-10/constants.rb +++ b/qpid/cpp/rubygen/framing.0-10/constants.rb @@ -30,7 +30,8 @@ class ConstantsGen < CppGen def constants_h() h_file("#{@dir}/constants") { - namespace(@namespace) { + namespace(@namespace) { + # Constants for class/method names. scope("enum AmqpConstant {","};") { l=[] l.concat @amqp.constants.map { |c| "#{c.name.shout}=#{c.value}" } @@ -41,35 +42,42 @@ class ConstantsGen < CppGen } genl l.join(",\n") } - define_constants_for(@amqp.domain("segment-type").enum) - namespace("execution") { - define_constants_for(@amqp.class_("execution").domain("error-code").enum) - } - namespace("connection") { - define_constants_for(@amqp.class_("connection").domain("close-code").enum) - } - namespace("session") { - define_constants_for(@amqp.class_("session").domain("detach-code").enum) + } + } + end + + def enum_h() + h_file("#{@dir}/enum") { + # Constants for enum domains. + namespace(@namespace) { + @amqp.domains.each { |d| define_enum(d.enum) if d.enum } + @amqp.classes.each { |c| + enums=c.collect_all(AmqpEnum) + if !enums.empty? then + namespace(c.nsname) { enums.each { |e| define_enum(e) } } + end } - define_constants_for(@amqp.class_("dtx").domain("xa-status").enum) } } end - def define_constants_for(enum) - scope("enum #{enum.parent.name.caps} {","};") { - genl enum.choices.collect { |c| "#{c.name.shout}=#{c.value}" }.join(",\n") + def define_enum(enum) + # Generated like this: enum containing_class::Foo { FOO_X, FOO_Y; } + name="#{enum.parent.name.caps}" + prefix=enum.parent.name.shout+"_" + scope("enum #{name} {","};") { + genl enum.choices.collect { |c| "#{prefix}#{c.name.shout}=#{c.value}" }.join(",\n") } end def define_exception(c, base, package) - name=c.name.caps+"Exception" - genl - doxygen_comment { genl c.doc } - struct(c.name.caps+"Exception", base) { + name=c.name.caps+"Exception" + genl + doxygen_comment { genl c.doc } + struct(c.name.caps+"Exception", base) { genl "std::string getPrefix() const { return \"#{c.name}\"; }" genl "#{c.name.caps}Exception(const std::string& msg=std::string()) : #{base}(#{c.value}, \"\"+msg) {}" - } + } end def define_exceptions_for(class_name, domain_name, base) @@ -119,6 +127,7 @@ class ConstantsGen < CppGen def generate() constants_h + enum_h reply_exceptions_h reply_exceptions_cpp end diff --git a/qpid/cpp/src/qpid/SessionState.cpp b/qpid/cpp/src/qpid/SessionState.cpp index 1be0111489..52c0ca229c 100644 --- a/qpid/cpp/src/qpid/SessionState.cpp +++ b/qpid/cpp/src/qpid/SessionState.cpp @@ -22,6 +22,7 @@ #include "SessionState.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/framing/AMQMethodBody.h" +#include "qpid/framing/enum.h" #include "qpid/log/Statement.h" #include <boost/bind.hpp> #include <numeric> @@ -37,10 +38,10 @@ using framing::FramingErrorException; namespace { bool isControl(const AMQFrame& f) { - return f.getMethod() && f.getMethod()->type() == framing::CONTROL; + return f.getMethod() && f.getMethod()->type() == framing::SEGMENT_TYPE_CONTROL; } bool isCommand(const AMQFrame& f) { - return f.getMethod() && f.getMethod()->type() == framing::COMMAND; + return f.getMethod() && f.getMethod()->type() == framing::SEGMENT_TYPE_COMMAND; } } // namespace diff --git a/qpid/cpp/src/qpid/amqp_0_10/SessionHandler.cpp b/qpid/cpp/src/qpid/amqp_0_10/SessionHandler.cpp index 35587940e5..8bf12d248a 100644 --- a/qpid/cpp/src/qpid/amqp_0_10/SessionHandler.cpp +++ b/qpid/cpp/src/qpid/amqp_0_10/SessionHandler.cpp @@ -23,6 +23,7 @@ #include "qpid/SessionState.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/framing/AllInvoker.h" +#include "qpid/framing/enum.h" #include "qpid/log/Statement.h" @@ -92,16 +93,16 @@ void SessionHandler::handleIn(AMQFrame& f) { } catch(const std::exception& e) { QPID_LOG(error, "Unexpected exception: " << e.what()); - connectionException(connection::FRAMING_ERROR, e.what()); + connectionException(connection::CLOSE_CODE_FRAMING_ERROR, e.what()); } } namespace { bool isControl(const AMQFrame& f) { - return f.getMethod() && f.getMethod()->type() == framing::CONTROL; + return f.getMethod() && f.getMethod()->type() == framing::SEGMENT_TYPE_CONTROL; } bool isCommand(const AMQFrame& f) { - return f.getMethod() && f.getMethod()->type() == framing::COMMAND; + return f.getMethod() && f.getMethod()->type() == framing::SEGMENT_TYPE_COMMAND; } } // namespace @@ -146,14 +147,14 @@ void SessionHandler::attached(const std::string& name) { void SessionHandler::detach(const std::string& name) { checkName(name); - peer.detached(name, session::NORMAL); + peer.detached(name, session::DETACH_CODE_NORMAL); handleDetach(); } void SessionHandler::detached(const std::string& name, uint8_t code) { checkName(name); ignoring = false; - if (code != session::NORMAL) + if (code != session::DETACH_CODE_NORMAL) channelException(code, "session.detached from peer."); else { handleDetach(); diff --git a/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp b/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp index 77a4d1a3de..4feda3950b 100644 --- a/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp +++ b/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp @@ -26,7 +26,7 @@ #include "Connection.h" #include "qpid/framing/ClientInvoker.h" #include "qpid/framing/ServerInvoker.h" -#include "qpid/framing/constants.h" +#include "qpid/framing/enum.h" #include "qpid/log/Statement.h" using namespace qpid; @@ -125,7 +125,7 @@ void ConnectionHandler::Handler::close(uint16_t replyCode, const string& replyTe QPID_LOG(warning, "Client closed connection with " << replyCode << ": " << replyText); } - if (replyCode == framing::connection::CONNECTION_FORCED) + if (replyCode == framing::connection::CLOSE_CODE_CONNECTION_FORCED) connection.notifyConnectionForced(replyText); client.closeOk(); diff --git a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp index 9ab2c3a75e..003e206bff 100644 --- a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp +++ b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp @@ -22,7 +22,7 @@ #include "Queue.h" #include "qpid/Exception.h" #include "qpid/framing/reply_exceptions.h" -#include "qpid/framing/constants.h" +#include "qpid/framing/enum.h" #include "qpid/log/Statement.h" #include "qpid/amqp_0_10/exceptions.h" #include "qpid/framing/SequenceSet.h" @@ -35,6 +35,7 @@ namespace broker { using namespace qpid; using namespace qpid::framing; +using namespace qpid::framing::dtx; typedef std::vector<Queue::shared_ptr> QueueVector; @@ -595,7 +596,7 @@ XaResult SessionAdapter::DtxHandlerImpl::end(const Xid& xid, if (suspend) { throw CommandInvalidException(QPID_MSG("End and suspend cannot both be set.")); } else { - return XaResult(XA_RBROLLBACK); + return XaResult(XA_STATUS_XA_RBROLLBACK); } } else { if (suspend) { @@ -603,10 +604,10 @@ XaResult SessionAdapter::DtxHandlerImpl::end(const Xid& xid, } else { state.endDtx(convert(xid), false); } - return XaResult(XA_OK); + return XaResult(XA_STATUS_XA_OK); } } catch (const DtxTimeoutException& e) { - return XaResult(XA_RBTIMEOUT); + return XaResult(XA_STATUS_XA_RBTIMEOUT); } } @@ -623,9 +624,9 @@ XaResult SessionAdapter::DtxHandlerImpl::start(const Xid& xid, } else { state.startDtx(convert(xid), getBroker().getDtxManager(), join); } - return XaResult(XA_OK); + return XaResult(XA_STATUS_XA_OK); } catch (const DtxTimeoutException& e) { - return XaResult(XA_RBTIMEOUT); + return XaResult(XA_STATUS_XA_RBTIMEOUT); } } @@ -633,9 +634,9 @@ XaResult SessionAdapter::DtxHandlerImpl::prepare(const Xid& xid) { try { bool ok = getBroker().getDtxManager().prepare(convert(xid)); - return XaResult(ok ? XA_OK : XA_RBROLLBACK); + return XaResult(ok ? XA_STATUS_XA_OK : XA_STATUS_XA_RBROLLBACK); } catch (const DtxTimeoutException& e) { - return XaResult(XA_RBTIMEOUT); + return XaResult(XA_STATUS_XA_RBTIMEOUT); } } @@ -644,9 +645,9 @@ XaResult SessionAdapter::DtxHandlerImpl::commit(const Xid& xid, { try { bool ok = getBroker().getDtxManager().commit(convert(xid), onePhase); - return XaResult(ok ? XA_OK : XA_RBROLLBACK); + return XaResult(ok ? XA_STATUS_XA_OK : XA_STATUS_XA_RBROLLBACK); } catch (const DtxTimeoutException& e) { - return XaResult(XA_RBTIMEOUT); + return XaResult(XA_STATUS_XA_RBTIMEOUT); } } @@ -655,9 +656,9 @@ XaResult SessionAdapter::DtxHandlerImpl::rollback(const Xid& xid) { try { getBroker().getDtxManager().rollback(convert(xid)); - return XaResult(XA_OK); + return XaResult(XA_STATUS_XA_OK); } catch (const DtxTimeoutException& e) { - return XaResult(XA_RBTIMEOUT); + return XaResult(XA_STATUS_XA_RBTIMEOUT); } } diff --git a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp index 5e8596cacb..f623530f98 100644 --- a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp @@ -24,7 +24,7 @@ #include "SessionImpl.h" #include "qpid/log/Statement.h" -#include "qpid/framing/constants.h" +#include "qpid/framing/enum.h" #include "qpid/framing/reply_exceptions.h" #include <boost/bind.hpp> @@ -32,6 +32,7 @@ using namespace qpid::client; using namespace qpid::framing; +using namespace qpid::framing::connection; using namespace qpid::sys; using namespace qpid::framing::connection;//for connection error codes @@ -46,7 +47,7 @@ ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSetti handler.in = boost::bind(&ConnectionImpl::incoming, this, _1); handler.out = boost::bind(&Connector::send, boost::ref(connector), _1); handler.onClose = boost::bind(&ConnectionImpl::closed, this, - NORMAL, std::string()); + CLOSE_CODE_NORMAL, std::string()); connector->setInputHandler(&handler); connector->setShutdownHandler(this); @@ -115,7 +116,7 @@ void ConnectionImpl::close() { if (!handler.isOpen()) return; handler.close(); - closed(NORMAL, "Closed by client"); + closed(CLOSE_CODE_NORMAL, "Closed by client"); } @@ -139,10 +140,10 @@ static const std::string CONN_CLOSED("Connection closed by broker"); void ConnectionImpl::shutdown() { Mutex::ScopedLock l(lock); // FIXME aconway 2008-06-06: exception use, connection-forced is incorrect here. - setException(new ConnectionException(CONNECTION_FORCED, CONN_CLOSED)); + setException(new ConnectionException(CLOSE_CODE_CONNECTION_FORCED, CONN_CLOSED)); if (handler.isClosed()) return; handler.fail(CONN_CLOSED); - closeInternal(boost::bind(&SessionImpl::connectionBroke, _1, CONNECTION_FORCED, CONN_CLOSED)); + closeInternal(boost::bind(&SessionImpl::connectionBroke, _1, CLOSE_CODE_CONNECTION_FORCED, CONN_CLOSED)); } void ConnectionImpl::erase(uint16_t ch) { diff --git a/qpid/cpp/src/qpid/client/SessionImpl.cpp b/qpid/cpp/src/qpid/client/SessionImpl.cpp index 2075ed04f3..aef546c427 100644 --- a/qpid/cpp/src/qpid/client/SessionImpl.cpp +++ b/qpid/cpp/src/qpid/client/SessionImpl.cpp @@ -26,7 +26,7 @@ #include "qpid/framing/all_method_bodies.h" #include "qpid/framing/ClientInvoker.h" -#include "qpid/framing/constants.h" +#include "qpid/framing/enum.h" #include "qpid/framing/FrameSet.h" #include "qpid/framing/MethodContent.h" #include "qpid/framing/SequenceSet.h" @@ -41,7 +41,7 @@ namespace qpid { namespace client { using namespace qpid::framing; -using namespace qpid::framing::session;//for detach codes +using namespace qpid::framing::session; //for detach codes typedef sys::Monitor::ScopedLock Lock; typedef sys::Monitor::ScopedUnlock UnLock; @@ -52,7 +52,7 @@ SessionImpl::SessionImpl(const std::string& name, shared_ptr<ConnectionImpl> conn, uint16_t ch, uint64_t _maxFrameSize) : error(OK), - code(NORMAL), + code(DETACH_CODE_NORMAL), text(EMPTY), state(INACTIVE), detachedLifetime(0), |