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 +++++++++++++++++++++ cpp/rubygen/samples/Proxy.rb | 153 ++++++++++++++++++++++++++++++++++++++ cpp/rubygen/samples/runme | 18 +++++ 3 files changed, 256 insertions(+) create mode 100755 cpp/rubygen/samples/Operations.rb create mode 100755 cpp/rubygen/samples/Proxy.rb create mode 100755 cpp/rubygen/samples/runme (limited to 'cpp/rubygen/samples') 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 < +#include "#{@classname}.h" +#include "qpid/framing/ChannelAdapter.h" +#include "qpid/framing/amqp_types_full.h" +EOS + @amqp.methods_on(@chassis).each { |m| include(m) } + gen < " + puts "Note: passing '-' as the output directory lists generated files." + exit 1 +end + +require 'amqpgen' +Amqp=AmqpRoot.new(*ARGV[1,ARGV.size]) + +require 'Proxy.rb' +require 'Operations.rb' + + -- cgit v1.2.1