summaryrefslogtreecommitdiff
path: root/qpid/cpp/rubygen/0-10/specification.rb
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-04-10 12:36:58 +0000
committerAlan Conway <aconway@apache.org>2008-04-10 12:36:58 +0000
commitefd3e09ea939ee627d13e8f33b9b814caf23cd50 (patch)
tree8abd1007db7cf7fa3e0bc9e2bcd5b69e1c957d14 /qpid/cpp/rubygen/0-10/specification.rb
parent3b8a50cf443a5e20f1c151e3d6709cf3a86d13db (diff)
downloadqpid-python-efd3e09ea939ee627d13e8f33b9b814caf23cd50.tar.gz
Invocation handlers, see src/tests/amqp_0_10/handlers.cpp for example.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@646778 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/rubygen/0-10/specification.rb')
-rwxr-xr-xqpid/cpp/rubygen/0-10/specification.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/qpid/cpp/rubygen/0-10/specification.rb b/qpid/cpp/rubygen/0-10/specification.rb
index abc754d1ef..020cb63c89 100755
--- a/qpid/cpp/rubygen/0-10/specification.rb
+++ b/qpid/cpp/rubygen/0-10/specification.rb
@@ -69,7 +69,7 @@ class Specification < CppGen
genl "bool operator==(const #{x.classname}&, const #{x.classname}&);"
end
- def action_struct_cpp(x)
+ def action_struct_cpp(x, &block)
genl
genl "const char* #{x.classname}::NAME=\"#{x.fqname}\";"
genl "const char* #{x.classname}::CLASS_NAME=#{x.containing_class.nsname}::NAME;"
@@ -92,6 +92,7 @@ class Specification < CppGen
genl "o << \"]\";"
genl "return o;"
}
+ yield if block
end
# structs
@@ -103,13 +104,28 @@ class Specification < CppGen
def action_h(a)
action_struct_h(a, a.base, ["code"]) {
- function_defn("template <class T> void invoke", ["T& target"]) {
- genl "target.#{a.funcname}(#{a.values.join(', ')});"
+ struct("Handler") {
+ scope("void #{a.funcname}(", ");") {
+ genl a.parameters.join(",\n")
+ }
+ }
+ function_defn("template <class T> void invoke", ["T& target"], "const") {
+ genl "target.#{a.funcname}(#{a.values.join(', ')} );"
}
}
end
- def action_cpp(a) action_struct_cpp(a); end
+ def action_cpp(a)
+ action_struct_cpp(a) {
+ scope("void #{a.classname}::Handler::#{a.funcname}(", ")") {
+ genl a.unused_parameters.join(",\n")
+ }
+ scope {
+ genl "assert(0);"
+ genl "throw NotImplementedException(QPID_MSG(\"#{a.fqname} not implemented.\"));"
+ }
+ }
+ end
# Types that must be generated early because they are used by other types.
def pregenerate?(x) not @amqp.used_by[x.fqname].empty?; end
@@ -172,6 +188,7 @@ class Specification < CppGen
cpp_file("#{@dir}/specification") {
include "#{@dir}/specification"
+ include "#{@dir}/exceptions"
include "<iostream>"
# FIXME aconway 2008-03-04: add Struct visitors.
["Command","Control"].each { |x| include "#{@dir}/Apply#{x}" }