summaryrefslogtreecommitdiff
path: root/cpp/rubygen/templates
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/rubygen/templates')
-rwxr-xr-xcpp/rubygen/templates/MethodBodyConstVisitor.rb27
-rwxr-xr-xcpp/rubygen/templates/MethodHolder.rb37
-rwxr-xr-xcpp/rubygen/templates/Proxy.rb2
-rw-r--r--cpp/rubygen/templates/Session.rb4
-rwxr-xr-xcpp/rubygen/templates/all_method_bodies.rb21
5 files changed, 79 insertions, 12 deletions
diff --git a/cpp/rubygen/templates/MethodBodyConstVisitor.rb b/cpp/rubygen/templates/MethodBodyConstVisitor.rb
new file mode 100755
index 0000000000..6fd7fe8ead
--- /dev/null
+++ b/cpp/rubygen/templates/MethodBodyConstVisitor.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class MethodBodyConstVisitorGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @classname="MethodBodyConstVisitor"
+ @filename="qpid/framing/MethodBodyConstVisitor"
+ end
+
+ def generate()
+ h_file("#{@filename}") {
+ namespace(@namespace) {
+ @amqp.amqp_methods.each { |m| genl "class #{m.body_name};" }
+ cpp_class("MethodBodyConstVisitor") {
+ genl "public:"
+ genl "virtual ~MethodBodyConstVisitor() {}"
+ @amqp.amqp_methods.each { |m| genl "virtual void visit(const #{m.body_name}&) = 0;" }
+ }}}
+ end
+end
+
+MethodBodyConstVisitorGen.new(Outdir, Amqp).generate();
+
diff --git a/cpp/rubygen/templates/MethodHolder.rb b/cpp/rubygen/templates/MethodHolder.rb
index 65fa824fd4..39a570c982 100755
--- a/cpp/rubygen/templates/MethodHolder.rb
+++ b/cpp/rubygen/templates/MethodHolder.rb
@@ -40,23 +40,42 @@ EOS
def gen_construct
cpp_file(@filename+"_construct") {
include @filename
+ include "qpid/framing/MethodBodyConstVisitor.h"
@amqp.amqp_methods.each { |m| include "qpid/framing/#{m.body_name}" }
genl
- namespace(@namespace) {
- scope("void #{@classname}::construct(const Id& newId) {") {
- scope("switch (newId.first) {") {
+ include "qpid/Exception.h"
+ genl
+ namespace(@namespace) {
+ # construct function
+ scope("void #{@classname}::construct(ClassId c, MethodId m) {") {
+ scope("switch (c) {") {
@amqp.amqp_classes.each { |c|
- scope("case #{c.index}: switch(newId.second) {") {
+ scope("case #{c.index}: switch(m) {") {
c.amqp_methods.each { |m|
genl "case #{m.index}: blob.construct(in_place<#{m.body_name}>()); break;"
- }}
+ }
+ genl "default: throw Exception(QPID_MSG(\"Invalid method id \" << m << \" for class #{c.name} \"));"
+ }
genl "break;"
- }}
- genl "id=newId;";
- }}}
+ }
+ genl "default: throw Exception(QPID_MSG(\"Invalid class id \" << c));"
+ }
+ }
+ # CopyVisitor
+ struct("#{@classname}::CopyVisitor", "public MethodBodyConstVisitor") { genl "MethodHolder& holder;"
+ genl "CopyVisitor(MethodHolder& h) : holder(h) {}"
+ @amqp.amqp_methods.each { |m|
+ genl "void visit(const #{m.body_name}& x) { holder.blob=x; }"
+ }
+ }
+ genl
+ # operator=
+ scope("#{@classname}& MethodHolder::operator=(const AMQMethodBody& m) {") {
+ genl "CopyVisitor cv(*this); m.accept(cv); return *this;"
+ }
+ }}
end
-
def generate
gen_max_size
gen_construct
diff --git a/cpp/rubygen/templates/Proxy.rb b/cpp/rubygen/templates/Proxy.rb
index f36d6bcd99..a6c0763a8a 100755
--- a/cpp/rubygen/templates/Proxy.rb
+++ b/cpp/rubygen/templates/Proxy.rb
@@ -38,7 +38,7 @@ EOS
genl "void #{@classname}::#{cname}::#{m.cppname}(#{m.signature.join(", ")})"
scope {
params=(["channel.getVersion()"]+m.param_names).join(", ")
- genl "channel.send(make_shared_ptr(new #{m.body_name}(#{params})));"
+ genl "channel.send(#{m.body_name}(#{params}));"
}}
end
diff --git a/cpp/rubygen/templates/Session.rb b/cpp/rubygen/templates/Session.rb
index eaa4347974..4265731d32 100644
--- a/cpp/rubygen/templates/Session.rb
+++ b/cpp/rubygen/templates/Session.rb
@@ -37,7 +37,7 @@ class SessionGen < CppGen
indent { gen params.join(",\n") }
gen "){\n\n"
indent (2) {
- gen "return impl->send(AMQMethodBody::shared_ptr(new #{m.body_name}("
+ gen "return impl->send(#{m.body_name}("
params = ["version"] + m.param_names
gen params.join(", ")
other_params=[]
@@ -49,7 +49,7 @@ class SessionGen < CppGen
else
other_params << "true"
end
- gen ")), #{other_params.join(", ")});\n"
+ gen "), #{other_params.join(", ")});\n"
}
gen "}\n\n"
end
diff --git a/cpp/rubygen/templates/all_method_bodies.rb b/cpp/rubygen/templates/all_method_bodies.rb
new file mode 100755
index 0000000000..38fbc31593
--- /dev/null
+++ b/cpp/rubygen/templates/all_method_bodies.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class AllMethodBodiesGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @filename="qpid/framing/all_method_bodies"
+ end
+
+ def generate()
+ h_file(@filename) {
+ @amqp.amqp_methods.each { |m| include "qpid/framing/"+m.body_name }
+ }
+ end
+end
+
+AllMethodBodiesGen.new(Outdir, Amqp).generate();
+