summaryrefslogtreecommitdiff
path: root/cpp/rubygen/templates
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/rubygen/templates')
-rwxr-xr-xcpp/rubygen/templates/Operations.rb3
-rwxr-xr-xcpp/rubygen/templates/constants.rb42
2 files changed, 42 insertions, 3 deletions
diff --git a/cpp/rubygen/templates/Operations.rb b/cpp/rubygen/templates/Operations.rb
index fff4f796c3..1002bf07a4 100755
--- a/cpp/rubygen/templates/Operations.rb
+++ b/cpp/rubygen/templates/Operations.rb
@@ -78,9 +78,6 @@ class #{@classname} {
virtual ProtocolVersion getVersion() const = 0;
- // Include framing constant declarations - why?
- //#include "qpid/framing/AMQP_Constants.h"
-
// Inner classes
EOS
indent { @amqp.classes.each { |c| handler_class(c) } }
diff --git a/cpp/rubygen/templates/constants.rb b/cpp/rubygen/templates/constants.rb
new file mode 100755
index 0000000000..7e212bd38a
--- /dev/null
+++ b/cpp/rubygen/templates/constants.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class ConstantsGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @dir="qpid/framing"
+ end
+
+ def generate()
+ h_file("#{@dir}/constants") {
+ namespace(@namespace) {
+ @amqp.constants.each { |c|
+ genl "inline const int #{c.name.shout} = #{c.value};"
+ }
+ }
+ }
+
+ h_file("#{@dir}/reply_exceptions") {
+ include "constants"
+ 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) {}"
+ }
+ end
+ }
+ }
+ }
+ end
+end
+
+ConstantsGen.new(Outdir, Amqp).generate();
+