From c11f9a79eec63da7aa6e6dac248a689a9d461beb Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 31 Jul 2007 20:00:10 +0000 Subject: Ruby code generator for C++. Not yet in active use yet but two sample templates are provided. Note: same dependency story as java codegen: distribution has pre-generated code so ruby not required to build a distro. Only required for svn working copy builds. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@561468 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/rubygen/samples/Operations.rb | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 cpp/rubygen/samples/Operations.rb (limited to 'cpp/rubygen/samples/Operations.rb') diff --git a/cpp/rubygen/samples/Operations.rb b/cpp/rubygen/samples/Operations.rb new file mode 100755 index 0000000000..1c245ca188 --- /dev/null +++ b/cpp/rubygen/samples/Operations.rb @@ -0,0 +1,85 @@ +#!/usr/bin/env ruby +# Usage: output_directory xml_spec_file [xml_spec_file...] +# +$: << '..' +require 'cppgen' + +class OperationsGen < CppGen + + def initialize(chassis, outdir, amqp) + super(outdir, amqp) + @chassis=chassis + @classname="AMQP_#{@chassis.caps}Operations" + end + + def handler_method (m) + gen "\nvirtual void #{m.cppname}(" + gen m.signature.join(",\n") + gen ") = 0;\n" + end + + def handler_classname(c) c.name.caps+"Handler"; end + + def handler_class(c) + handlerclass=handler_classname c + gen < +#include "qpid/framing/ProtocolVersion.h" + +namespace qpid { +namespace framing { + +class #{@classname} { + + public: + virtual ~#{@classname}() {} + + virtual ProtocolVersion getVersion() const = 0; + + // Include framing constant declarations + #include "AMQP_Constants.h" + + // Inner classes +EOS + indent { @amqp.classes.each { |c| handler_class(c) } } + gen <