From dd3e2d4f1768abbff0a638f68f50a5ea44ed47ef Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Sun, 5 Aug 2007 10:44:13 +0000 Subject: * amqpgen.rb: fix sytax error. * cppgen.rb: - 0-10 types - typedef generator - automatic whitespace around classes etc. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@562845 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/rubygen/cppgen.rb | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'cpp/rubygen/cppgen.rb') diff --git a/cpp/rubygen/cppgen.rb b/cpp/rubygen/cppgen.rb index 46703588c1..f58ce3a539 100755 --- a/cpp/rubygen/cppgen.rb +++ b/cpp/rubygen/cppgen.rb @@ -27,6 +27,12 @@ Copyright=<["string", "const string&"], "shortstr"=>["string", "const string&"], "table"=>["FieldTable", "const FieldTable&", "const FieldTable&"], - "content"=>["Content", "const Content&", "const Content&"] + "content"=>["Content", "const Content&", "const Content&"], + "rfc1982-long-set"=>["SequenceNumberSet", "const SequenceNumberSet&", "const SequenceNumberSet&"], + "uuid"=>["Uuid", "const Uuid&", "const Uuid&"] } def lookup(amqptype) @@ -125,28 +134,37 @@ class CppGen < Generator end end - def include(header) genl "#include \"#{header}\""; end + def include(header) + genl /<.*>/.match(header) ? "#include #{header}" : "#include \"#{header}\"" + end def scope(open="{",close="}", &block) genl open; indent(&block); genl close end def namespace(name, &block) + genl names = name.split("::") names.each { |n| genl "namespace #{n} {" } + genl yield + genl genl('}'*names.size+" // "+name) + genl end def struct_class(type, name, *bases, &block) + genl gen "#{type} #{name}" - gen ": #{bases.join(', ')}" unless bases.empty + gen ": #{bases.join(', ')}" unless bases.empty? genl "{" yield genl "};" + genl end - def struct(name, *bases, &block) struc_class("struct", bases, &block); end - def class_(name, *bases, &block) struc_class("struct", bases, &block); end + def struct(name, *bases, &block) struct_class("struct", name, bases, &block); end + def class_(name, *bases, &block) struct_class("class", name, bases, &block); end + def typedef(type, name) genl "typedef #{type} #{name};" end end -- cgit v1.2.1