summaryrefslogtreecommitdiff
path: root/cpp/rubygen/cppgen.rb
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-08-05 10:44:13 +0000
committerAlan Conway <aconway@apache.org>2007-08-05 10:44:13 +0000
commitdd3e2d4f1768abbff0a638f68f50a5ea44ed47ef (patch)
tree503b5cd9fe470cde104ebf4b0b59ed3f4cc7e983 /cpp/rubygen/cppgen.rb
parent744a9369e5e145fee41c0e2587a22882ecbbcc33 (diff)
downloadqpid-python-dd3e2d4f1768abbff0a638f68f50a5ea44ed47ef.tar.gz
* 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
Diffstat (limited to 'cpp/rubygen/cppgen.rb')
-rwxr-xr-xcpp/rubygen/cppgen.rb40
1 files changed, 29 insertions, 11 deletions
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=<<EOS
*
*/
+///
+/// This file was automatically generated from the AMQP specification.
+/// Do not edit.
+///
+
+
EOS
CppKeywords = Set.new(["and", "and_eq", "asm", "auto", "bitand",
@@ -62,16 +68,17 @@ end
# Additional methods for AmqpMethod
class AmqpMethod
- def cppname() @cache_cppname ||= name.lcaps.cppsafe; end
- def param_names() @cache_param_names ||= fields.collect { |f| f.cppname }; end
- def signature() @cache_signature ||= fields.collect { |f| f.cpptype+" "+f.cppname }; end
- def body_name() @cache_body_name ||= amqp_parent.name.caps+name.caps+"Body"; end
+ def cppname() name.lcaps.cppsafe; end
+ def param_names() fields.collect { |f| f.cppname }; end
+ def signature() fields.collect { |f| f.cpptype+" "+f.cppname }; end
+ def body_name() amqp_parent.name.caps+name.caps+"Body"; end
end
# Additional methods for AmqpClass
class AmqpClass
- def cppname() @cache_cppname ||= name.caps; end
- def body_name() @cache_body_name ||= name.caps+"Body"; end
+ def cppname() name.caps; end
+ def body_name() cppname+"Body"
+ end
end
# Additional methos for AmqpRoot
@@ -87,7 +94,9 @@ class AmqpRoot
"longstr"=>["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