From 1820dd421a096ed184a08deee9512e809312fed2 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 28 Feb 2008 17:53:47 +0000 Subject: amqp_0_10::ProxyTemplate - tested & functional. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@632075 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/rubygen/0-10/specification.rb | 40 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'cpp/rubygen/0-10') diff --git a/cpp/rubygen/0-10/specification.rb b/cpp/rubygen/0-10/specification.rb index d88b03c3c6..d4ecfe98ed 100755 --- a/cpp/rubygen/0-10/specification.rb +++ b/cpp/rubygen/0-10/specification.rb @@ -46,11 +46,9 @@ class Specification < CppGen genl "static const char* NAME;" consts.each { |c| genl "static const uint8_t #{c.upcase}=#{x.send c or 0};"} genl "static const uint8_t CLASS_CODE=#{x.containing_class.nsname}::CODE;" - genl - genl "#{x.classname}();" - scope("#{x.classname}(",");") { genl x.parameters } unless x.fields.empty? - genl - genl "void accept(Visitor&) const;" + ctor_decl(x.classname,[]) + ctor_decl(x.classname, x.parameters) unless x.fields.empty? + function_decl("void accept", ["Visitor&"], "const") genl yield if block } @@ -60,15 +58,9 @@ class Specification < CppGen genl genl "const char* #{x.classname}::NAME=\"#{x.fqname}\";" genl - genl "#{x.classname}::#{x.classname}() {}"; - genl - if not x.fields.empty? - scope("#{x.classname}::#{x.classname}(",") :") { genl x.parameters } - indent() { genl x.initializers } - genl "{}" - genl - end - scope("void #{x.classname}::accept(Visitor&) const {","}") { + ctor_defn(x.classname) {} + ctor_defn(x.classname, x.parameters, x.initializers) {} if not x.fields.empty? + function_defn("void #{x.classname}::accept", ["Visitor&"], "const") { genl "// FIXME aconway 2008-02-27: todo" } end @@ -82,11 +74,10 @@ class Specification < CppGen def action_h(a) action_struct_h(a, a.base, ["code"]) { - scope("template void invoke(T& target) {","}") { - scope("target.#{a.funcname}(", ");") { genl a.values } + function_defn("template void invoke", ["T& target"]) { + genl "target.#{a.funcname}(#{a.values.join(', ')});" } - genl - scope("template void serialize(S& s) {","}") { + function_defn("template void serialize", ["S& s"]) { gen "s" a.fields.each { |f| gen "(#{f.cppname})"} genl ";" @@ -141,19 +132,20 @@ class Specification < CppGen end def gen_proxy() - h_file("#{@dir}/Proxy.h") { + h_file("#{@dir}/ProxyTemplate.h") { include "#{@dir}/specification" namespace(@ns) { - genl "template " + genl "template " cpp_class("ProxyTemplate") { public - genl "ProxyTemplate(F f) : functor(f) {}" + genl "ProxyTemplate(F f=F()) : functor(f) {}" @amqp.classes.each { |c| c.actions.each { |a| - scope("R #{a.funcname}(", ")") { genl a.parameters } - scope() { + genl + function_defn("R #{a.funcname}", a.parameters) { var=a.name.funcname - scope("#{a.classname} #{var}(",");") { genl a.arguments } + args = a.arguments.empty? ? "" : "("+a.arguments.join(", ")+")" + genl("#{a.fqclassname} #{var}#{args};") genl "return functor(#{var});" } } -- cgit v1.2.1