You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2007/08/05 12:44:15 UTC
svn commit: r562845 - in /incubator/qpid/trunk/qpid/cpp/rubygen: amqpgen.rb
cppgen.rb
Author: aconway
Date: Sun Aug 5 03:44:13 2007
New Revision: 562845
URL: http://svn.apache.org/viewvc?view=rev&rev=562845
Log:
* amqpgen.rb: fix sytax error.
* cppgen.rb:
- 0-10 types
- typedef generator
- automatic whitespace around classes etc.
Modified:
incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb
incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb?view=diff&rev=562845&r1=562844&r2=562845
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb Sun Aug 5 03:44:13 2007
@@ -76,7 +76,7 @@
class AmqpMethod < AmqpElement
def initialize(xml, amqp) super; end
- def index attr["index"]; end
+ def index() attributes["index"]; end
def fields()
@cache_fields ||= elements.collect("field") { |f| AmqpField.new(f,self); }
@@ -101,7 +101,7 @@
# AMQP class element.
class AmqpClass < AmqpElement
def initialize(xml,amqp) super; end
- def index attr["index"]; end
+ def index() attributes["index"]; end
def methods()
@cache_methods ||= elements.collect("method") { |el|
AmqpMethod.new(el,self)
@@ -173,16 +173,12 @@
end
# Create a new file, set @out.
- def file(file, &block)
+ def file(file)
puts file
if (@outdir != "-")
path=Pathname.new "#{@outdir}/#{file}"
path.parent.mkpath
- if &block
path.open('w') { |@out| yield }
- else
- path.open('w')
- end
end
end
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb?view=diff&rev=562845&r1=562844&r2=562845
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb Sun Aug 5 03:44:13 2007
@@ -27,6 +27,12 @@
*
*/
+///
+/// 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 @@
# 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 @@
"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 @@
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