summaryrefslogtreecommitdiff
path: root/cpp/rubygen/templates
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-10-26 19:48:31 +0000
committerAlan Conway <aconway@apache.org>2007-10-26 19:48:31 +0000
commitf61e1ef7589da893b9b54448224dc0961515eb40 (patch)
tree258ac1fd99ac122b105ad90ad4394d8d544c5cbf /cpp/rubygen/templates
parentc5294d471ade7a18c52ca7d4028a494011c82293 (diff)
downloadqpid-python-f61e1ef7589da893b9b54448224dc0961515eb40.tar.gz
Session resume support in client & broker: Client can resume a session
after voluntary suspend() or network failure. Frames lost in network failure are automatically re-transmitted for transparent re-connection. client::Session improvements: - Locking to avoid races between network & user threads. - Replaced client::StateManager with sys::StateMonitor - avoid heap allocation. qpid::Exception clean up: - use QPID_MSG consistently to format exception messages. - throw typed exceptions (in reply_exceptions.h) for AMQP exceptions. - re-throw correct typed exception on client for exceptions from broker. - Removed QpidError.h rubygen/templates/constants.rb: - constants.h: Added FOO_CLASS_ID and FOO_BAR_METHOD_ID constants. - reply_constants.h: Added throwReplyException(code, text) log::Logger: - Fixed shutdown race in Statement::~Initializer() git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@588761 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen/templates')
-rwxr-xr-xcpp/rubygen/templates/constants.rb68
1 files changed, 54 insertions, 14 deletions
diff --git a/cpp/rubygen/templates/constants.rb b/cpp/rubygen/templates/constants.rb
index 2ef6502772..5fbbefe218 100755
--- a/cpp/rubygen/templates/constants.rb
+++ b/cpp/rubygen/templates/constants.rb
@@ -10,31 +10,71 @@ class ConstantsGen < CppGen
@dir="qpid/framing"
end
- def generate()
+ def constants_h()
h_file("#{@dir}/constants") {
namespace(@namespace) {
- scope("enum AmqpConstant {","};") {
- genl @amqp.constants.map { |c| "#{c.name.shout}=#{c.value}" }.join(",\n")
- }
- }
- }
-
+ scope("enum AmqpConstant {","};") {
+ l=[]
+ l.concat @amqp.constants.map { |c| "#{c.name.shout}=#{c.value}" }
+ @amqp.classes.each { |c|
+ l << "#{c.name.shout}_CLASS_ID=#{c.index}"
+ l.concat c.methods_.map { |m|
+ "#{c.name.shout}_#{m.name.shout}_METHOD_ID=#{m.index}" }
+ }
+ genl l.join(",\n")
+ }}}
+ end
+
+ def exbase(c)
+ case c.class_
+ when "soft-error" then "ChannelException"
+ when "hard-error" then "ConnectionException"
+ end
+ end
+
+ def reply_exceptions_h()
h_file("#{@dir}/reply_exceptions") {
include "qpid/Exception"
namespace(@namespace) {
@amqp.constants.each { |c|
- if c.class_
- exname=c.name.caps+"Exception"
- base = c.class_=="soft-error" ? "ChannelException" : "ConnectionException"
- text=(c.doc or c.name).tr_s!(" \t\n"," ")
- struct(exname, base) {
- genl "#{exname}(const std::string& msg=\"#{text})\") : #{base}(#{c.value}, msg) {}"
+ base = exbase c
+ if base
+ genl
+ struct(c.name.caps+"Exception", base) {
+ genl "#{c.name.caps}Exception(const std::string& msg=std::string()) : #{base}(#{c.value}, \"#{c.name}: \"+msg) {}"
}
end
}
+ genl
+ genl "void throwReplyException(int code, const std::string& text);"
}
}
-
+ end
+
+ def reply_exceptions_cpp()
+ cpp_file("#{@dir}/reply_exceptions") {
+ include "#{@dir}/reply_exceptions"
+ include "<sstream>"
+ namespace("qpid::framing") {
+ scope("void throwReplyException(int code, const std::string& text) {"){
+ scope("switch (code) {") {
+ genl "case 200: break; // No exception"
+ @amqp.constants.each { |c|
+ if exbase c
+ genl "case #{c.value}: throw #{c.name.caps}Exception(text);"
+ end
+ }
+ scope("default:","") {
+ genl "std::ostringstream msg;"
+ genl 'msg << "Invalid reply code " << code << ": " << text;'
+ genl 'throw InvalidArgumentException(msg.str());'
+ }}}}}
+ end
+
+ def generate()
+ constants_h
+ reply_exceptions_h
+ reply_exceptions_cpp
end
end