You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/04/24 23:08:08 UTC
svn commit: r651423 [1/2] - in /incubator/qpid/trunk/qpid/cpp: ./ rubygen/
rubygen/framing.0-10/ src/ src/qpid/ src/qpid/broker/ src/qpid/client/
src/qpid/cluster/ src/qpid/framing/ src/tests/
Author: gsim
Date: Thu Apr 24 14:07:34 2008
New Revision: 651423
URL: http://svn.apache.org/viewvc?rev=651423&view=rev
Log:
Generate c++ code from final 0-10 spec
Added:
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodHolder.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Operations.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Proxy.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Session.rb
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/constants.rb (with props)
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Removed:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/BrokerAdapter.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DtxHandlerImpl.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/DtxHandlerImpl.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageHandlerImpl.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnection.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionCodec.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionCodec.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewConnectionHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewSessionHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewSessionHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewSessionManager.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewSessionManager.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewSessionState.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/PreviewSessionState.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FramingContent.h
Modified:
incubator/qpid/trunk/qpid/cpp/configure.ac
incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb
incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb
incubator/qpid/trunk/qpid/cpp/rubygen/generate
incubator/qpid/trunk/qpid/cpp/src/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Bridge.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionFactory.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageAdapter.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageAdapter.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageDelivery.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageDelivery.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/QueueBindings.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SaslAuthenticator.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/SessionState.h
incubator/qpid/trunk/qpid/cpp/src/qpid/client/Channel.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.h
incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/Session.h
incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionImpl.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/SessionImpl.h
incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQFrame.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/AMQHeaderBody.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHandler.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/BodyHolder.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Buffer.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldValue.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ModelMethod.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumber.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceNumber.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/SequenceSet.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Uuid.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/amqp_types_full.h
incubator/qpid/trunk/qpid/cpp/src/tests/ExchangeTest.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/exception_test.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/interop_runner.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/python_tests
Modified: incubator/qpid/trunk/qpid/cpp/configure.ac
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/configure.ac?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/configure.ac (original)
+++ incubator/qpid/trunk/qpid/cpp/configure.ac Thu Apr 24 14:07:34 2008
@@ -122,9 +122,7 @@
test -z "$RUBY" && AC_MSG_ERROR([Missing ruby installation (try "yum install ruby").])
specdir=`pwd`/$srcdir/../specs
-AMQP_PREVIEW_XML=$specdir/amqp.0-10-preview.xml
-AMQP_FINAL_XML=$specdir/amqp.0-10.xml
-AC_SUBST(AMQP_PREVIEW_XML)
+AMQP_FINAL_XML=$specdir/amqp.0-10-qpid-errata.xml
AC_SUBST(AMQP_FINAL_XML)
AM_CONDITIONAL([GENERATE], [ls $AMQP_FINAL_XML >/dev/null])
@@ -154,8 +152,8 @@
;;
*) AC_MSG_ERROR([Bad value ${withval} for --with-cpg option]) ;;
esac],
- [ # not specified - enable if libs/headers available.
- with_CPG=yes
+ [ # not specified - GS 24-APR-2008 temporarily disabled - (enable if libs/headers available).
+ with_CPG=no
AC_CHECK_HEADERS([openais/cpg.h],,[with_CPG=no])
AC_CHECK_LIB([cpg],[cpg_initialize],,[with_CPG=no])
]
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb Thu Apr 24 14:07:34 2008
@@ -26,7 +26,7 @@
def bars() tr('- .','_'); end
# Convert to ALL_UPPERCASE_FORM
- def shout() bars.upcase!; end
+ def shout() bars.upcase; end
# Convert to lowerCaseCapitalizedForm
def lcaps() gsub( /\W(\w)/ ) { |m| $1.upcase } end
@@ -89,7 +89,6 @@
end
end
-
# An AmqpElement contains an XML element and provides a convenient
# API to access AMQP data.
#
@@ -109,6 +108,7 @@
@xml, @parent=xml, parent
@children=xml.elements.map { |e| wrap e }.compact
@cache_child={}
+ @cache_child_named={}
@cache_children={}
@cache_children[nil]=@children
end
@@ -142,14 +142,15 @@
@cache_child[[elname,name]] ||= children(elname).find { |c| c.name==name }
end
+ # Look up any child with name
+ def child_named(name)
+ @cache_child_named[name] ||= @children.find { |c| c.name==name }
+ end
+
# The root <amqp> element.
def root() @root ||=parent ? parent.root : self; end
- # Are we in preview or final 0-10
- # preview - used to make some classes behave differently for preview vs. final
- def final?() root().version == "0-10"; end
-
- def to_s() "#<#{self.class}(#{name})>"; end
+ def to_s() "#<#{self.class}(#{fqname})>"; end
def inspect() to_s; end
# Text of doc child if there is one.
@@ -207,14 +208,6 @@
amqp_single_child_reader :enum
def uses() type_=="array" ? ArrayTypes[name] : type_; end
-
- def unalias()
- d=self
- while (d.type_ != d.name and root.domain(d.type_))
- d=root.domain(d.type_)
- end
- return d
- end
end
class AmqpException < AmqpElement
@@ -227,8 +220,6 @@
super;
root.used_by[type_].push(parent.fqname) if type_ and type_.index('.')
end
-
- def domain() root.domain(xml.attributes["domain"]); end
amqp_single_child_reader :struct # preview
amqp_child_reader :exception
amqp_attr_reader :type, :default, :code, :required
@@ -278,9 +269,6 @@
amqp_attr_reader :size, :code, :pack
amqp_child_reader :field
- # preview - preview code needs default "short" for pack.
- alias :raw_pack :pack
- def pack() raw_pack or (not parent.final? and "short"); end
def result?() parent.xml.name == "result"; end
def domain?() parent.xml.name == "domain"; end
end
@@ -297,6 +285,24 @@
def on_server?() on_chassis? "server"; end
end
+# preview: Map command/control to preview method.
+class AmqpFakeMethod < AmqpMethod
+ def initialize(action)
+ super(action.xml, action.parent);
+ @action=action
+ end
+
+ def content() return "1" if @action.is_a? AmqpCommand and @action.segments end
+ def index() @action.code end
+ def code() @action.code end
+ def synchronous() end # FIXME aconway 2008-04-10: ???
+ def on_chassis?(chassis)
+ @action.received_by?(chassis)
+ end
+ def pack() "2" end # Encode pack=2, size=4 struct
+ def size() "4" end
+end
+
class AmqpImplement < AmqpElement
def initialize(xml,amqp) super; end
amqp_attr_reader :handle, :send
@@ -312,6 +318,11 @@
def initialize(xml,amqp) super; end
amqp_child_reader :implement, :field, :response
amqp_attr_reader :code
+ def implement?(role) xml.elements["./implement[@role='#{role}']"] end
+ def received_by?(client_or_server)
+ return (implement?(client_or_server) or implement?("sender") or implement?("receiver"))
+ end
+ def pack() "2" end
def size() "4" end # Encoded as a size 4 Struct
end
@@ -329,26 +340,37 @@
def initialize(xml,amqp) super; end
amqp_attr_reader :index # preview
- amqp_child_reader :method # preview
- amqp_child_reader :struct, :domain, :control, :command, :role
+ amqp_child_reader :struct, :domain, :control, :command, :role, :method
amqp_attr_reader :code
+ def actions() controls+commands; end
+
+ # preview - command/control as methods
+ def methods_()
+ return (controls + commands).map { |a| AmqpFakeMethod.new(a) }
+ end
+
+ def method(name)
+ a = (command(name) or control(name))
+ return AmqpFakeMethod.new(a)
+ end
+
# chassis should be "client" or "server"
def methods_on(chassis) # preview
@methods_on ||= { }
@methods_on[chassis] ||= methods_.select { |m| m.on_chassis? chassis }
end
+ # FIXME aconway 2008-04-11:
def l4?() # preview
!["connection", "session", "execution"].include?(name) && !control?
end
+ # FIXME aconway 2008-04-11:
def control?()
- ["connection010", "session010"].include?(name)
+ ["connection", "session"].include?(name)
end
-
- def actions() controls+commands; end
end
class AmqpType < AmqpElement
@@ -388,13 +410,6 @@
def version() major + "-" + minor; end
- # preview - only struct child reader remains for new mapping
- def domain_structs() domains.map{ |d| d.struct }.compact; end
- def result_structs()
- methods_.map { |m| m.result and m.result.struct }.compact
- end
- def structs() result_structs+domain_structs; end
-
def methods_() classes.map { |c| c.methods_ }.flatten; end
#preview
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb Thu Apr 24 14:07:34 2008
@@ -71,9 +71,9 @@
def varname() lcaps.cppsafe; end
end
-# Hold information about a C++ type.
+# preview: Hold information about a C++ type.
#
-# preview - new mapping does not use CppType,
+# new mapping does not use CppType,
# Each amqp type corresponds exactly by dotted name
# to a type, domain or struct, which in turns
# corresponds by name to a C++ type or typedef.
@@ -88,12 +88,8 @@
def passcref() @param="const #{name}&"; self; end
def code(str) @code=str; self; end
def defval(str) @defval=str; self; end
- def fq(namespace)
- @param="const #{namespace}::#{name}&"
- @ret="const #{namespace}::#{name}&"
- @defval="#{namespace}::#{name}()"
- self
- end
+ def encoded() @code end
+ def ret_by_val() @name; end
def encode(value, buffer)
@code ? "#{buffer}.put#{@code}(#{value});" : "#{value}.encode(#{buffer});"
@@ -118,19 +114,86 @@
def to_s() name; end;
end
+class AmqpRoot
+ # preview; map 0-10 types to preview code generator types
+ @@typemap = {
+ "bit"=> CppType.new("bool").code("Octet").defval("false"),
+ "uint8"=>CppType.new("uint8_t").code("Octet").defval("0"),
+ "uint16"=>CppType.new("uint16_t").code("Short").defval("0"),
+ "uint32"=>CppType.new("uint32_t").code("Long").defval("0"),
+ "uint64"=>CppType.new("uint64_t").code("LongLong").defval("0"),
+ "datetime"=>CppType.new("uint64_t").code("LongLong").defval("0"),
+ "str8"=>CppType.new("string").passcref.retcref.code("ShortString"),
+ "str16"=>CppType.new("string").passcref.retcref.code("MediumString"),
+ "str32"=>CppType.new("string").passcref.retcref.code("LongString"),
+ "vbin8"=>CppType.new("string").passcref.retcref.code("ShortString"),
+ "vbin16"=>CppType.new("string").passcref.retcref.code("MediumString"),
+ "vbin32"=>CppType.new("string").passcref.retcref.code("LongString"),
+ "map"=>CppType.new("FieldTable").passcref.retcref,
+ "array"=>CppType.new("Array").passcref.retcref,
+ "sequence-no"=>CppType.new("SequenceNumber").passcref,
+ "sequence-set"=>CppType.new("SequenceSet").passcref.retcref,
+ "struct32"=>CppType.new("string").passcref.retcref.code("LongString"),
+ "uuid"=>CppType.new("Uuid").passcref.retcref,
+ "byte-ranges"=>CppType.new("ByteRanges").passcref.retcref
+ }
+
+ # preview: map amqp types to preview cpp types.
+ def lookup_cpptype(t) t = @@typemap[t] and return t end
+end
+
+
class AmqpElement
# convert my amqp type_ attribute to a C++ type.
def amqp2cpp()
return "ArrayDomain<#{ArrayTypes[name].amqp2cpp}> " if type_=="array"
return type_.amqp2cpp
end
+
+ # Does this object have a type-like child named name?
+ def typechild(name)
+ child = domain(name) if respond_to? :domain
+ child = struct(name) if not child and respond_to? :struct
+ child = type_(name) if not child and respond_to? :type_
+ child
+ end
+
+ # dotted name to a type object
+ def dotted_typechild(name)
+ names=name.split('.')
+ context = self
+ while context and names.size > 1
+ context = context.child_named(names.shift)
+ end
+ return context.typechild(names[0]) if context
+ end
+
+ # preview mapping - type_ attribute to C++ type
+ def lookup_cpptype(name)
+ if t = root.lookup_cpptype(name) then return t
+ elsif c = containing_class.typechild(name) then return c.cpptype
+ elsif c= root.dotted_typechild(name) then return c.cpptype
+ else raise "Cannot resolve type-name #{name} from #{self}"
+ end
+ end
+
+ def containing_class()
+ return self if is_a? AmqpClass
+ return parent && parent.containing_class
+ end
end
+
class AmqpField
+ def struct?()
+ c=containing_class
+ c.struct(type_)
+ end
+ def cpptype() lookup_cpptype(type_) or raise "no cpptype #{self}" end
def cppname() name.lcaps.cppsafe; end
- def cpptype() domain.cpptype; end
- def bit?() domain.type_ == "bit"; end
+ def bit?() type_ == "bit"; end
def signature() cpptype.param+" "+cppname; end
+
def fqtypename()
unless type_.index(".")
c=containing_class
@@ -149,26 +212,11 @@
def cppname() name.lcaps.cppsafe; end
def param_names() fields.map { |f| f.cppname }; end
def signature() fields.map { |f| f.signature }; end
- def classname()
- #TODO: remove name mangling after preview path is dropped
- if (parent.name.include?("010"))
- return parent.name.delete("010")
- elsif (parent.name == "cluster")
- return parent.name
- else
- return parent.name + "X"
- end
- end
+ def classname() parent.name; end
def body_name()
classname().caps+name.caps+"Body"
end
-
- def cpp_pack_type() # preview
- CppType.new("uint16_t").code("Short").defval("0");
- end
- def pack() # preview
- "short"
- end
+ def cpp_pack_type() root.lookup_cpptype("uint16") end
end
module AmqpHasFields
@@ -192,7 +240,8 @@
end
class AmqpType
- def typename() name.typename; end
+ def cpptype() root.lookup_cpptype(name) end # preview
+ def typename() name.typename; end # new mapping
def fixed?() fixed_width; end
end
@@ -210,67 +259,42 @@
end
class AmqpDomain
- @@typemap = {
- "bit"=> CppType.new("bool").code("Octet").defval("false"),
- "octet"=>CppType.new("uint8_t").code("Octet").defval("0"),
- "short"=>CppType.new("uint16_t").code("Short").defval("0"),
- "long"=>CppType.new("uint32_t").code("Long").defval("0"),
- "longlong"=>CppType.new("uint64_t").code("LongLong").defval("0"),
- "timestamp"=>CppType.new("uint64_t").code("LongLong").defval("0"),
- "longstr"=>CppType.new("string").passcref.retcref.code("LongString"),
- "shortstr"=>CppType.new("string").passcref.retcref.code("ShortString"),
- "mediumstr"=>CppType.new("string").passcref.retcref.code("MediumString"),
- "table"=>CppType.new("FieldTable").passcref.retcref,
- "array"=>CppType.new("Array").passcref.retcref,
- "content"=>CppType.new("Content").passcref.retcref,
- "rfc1982-long-set"=>CppType.new("SequenceNumberSet").passcref.retcref,
- "sequence-set"=>CppType.new("SequenceSet").passcref.retcref,
- "long-struct"=>CppType.new("string").passcref.retcref.code("LongString"),
- "uuid"=>CppType.new("Uuid").passcref.retcref
- }
-
- def cppname()
- #TODO: remove name mangling after preview path is dropped
- if (name.include?("010"))
- return name.caps.delete("010")
- elsif (name.include?("properties"))
- return "Preview" + name.caps
- else
- return name.caps
- end
- end
+ # preview
+ def cpptype() lookup_cpptype(type_) end
+ def cppname() name.caps; end
+ # new mapping
def fqtypename()
return containing_class.nsname+"::"+name.typename if containing_class
name.typename
end
-
- def cpptype()
- d=unalias
- @cpptype ||= @@typemap[d.type_] or
- CppType.new(d.cppname).fq("qpid::framing") or
- raise "Invalid type #{self}"
- end
-
- def AmqpDomain.lookup_type(t)
- @@typemap[t]
- end
end
class AmqpResult
+ # preview
def cpptype()
- @cpptype=CppType.new(parent.classname.caps+parent.name.caps+"Result").passcref
+ if type_ then lookup_cpptype(type_)
+ else CppType.new(parent.parent.name.caps+parent.name.caps+"Result").passcref
+ end
end
end
class AmqpStruct
include AmqpHasFields
+ @@pack_types={ "1"=>"uint8", "2"=>"uint16", "4"=>"uint32"}
def cpp_pack_type() # preview
- AmqpDomain.lookup_type(pack()) or CppType.new("uint16_t");
+ root.lookup_cpptype(@@pack_types[pack])
end
- def cpptype() parent.cpptype; end # preview
- def cppname() cpptype.name; end # preview
+ def cpptype() CppType.new(cppname).passcref.retcref end
+ #def cppname() containing_class.cppname+name.caps; end
+ def cppname()
+ if parent.kind_of? AmqpResult
+ parent.parent.parent.name.caps+parent.parent.name.caps+"Result"
+ else
+ name.caps
+ end
+ end
def fqclassname() containing_class.nsname+"::"+name.typename; end
def classname() name.typename; end
def full_code() (containing_class.code.hex << 8)+code.hex; end
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class MethodBodyConstVisitorGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @classname="MethodBodyConstVisitor"
+ @filename="qpid/framing/MethodBodyConstVisitor"
+ end
+
+ def generate()
+ h_file("#{@filename}") {
+ namespace(@namespace) {
+ @amqp.methods_.each { |m| genl "class #{m.body_name};" }
+ cpp_class("MethodBodyConstVisitor") {
+ genl "public:"
+ genl "virtual ~MethodBodyConstVisitor() {}"
+ @amqp.methods_.each { |m| genl "virtual void visit(const #{m.body_name}&) = 0;" }
+ }}}
+ end
+end
+
+MethodBodyConstVisitorGen.new($outdir, $amqp).generate();
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class MethodBodyDefaultVisitorGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace, @classname, @filename = parse_classname("qpid::framing::MethodBodyDefaultVisitor")
+ end
+
+ def generate()
+ h_file(@filename) {
+ include "qpid/framing/MethodBodyConstVisitor"
+ namespace(@namespace) {
+ genl "class AMQMethodBody;"
+ cpp_class(@classname, "public MethodBodyConstVisitor") {
+ genl "public:"
+ genl "virtual void defaultVisit(const AMQMethodBody&) = 0;"
+ @amqp.methods_.each { |m|
+ genl "virtual void visit(const #{m.body_name}&);" }
+ }}}
+
+ cpp_file(@filename) {
+ include(@filename)
+ include("all_method_bodies.h")
+ namespace(@namespace) {
+ @amqp.methods_.each { |m|
+ genl "void #{@classname}::visit(const #{m.body_name}& b) { defaultVisit(b); }"
+ }}}
+ end
+end
+
+MethodBodyDefaultVisitorGen.new($outdir, $amqp).generate();
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodHolder.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodHolder.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodHolder.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodHolder.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,100 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class MethodHolderGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @classname="BodyHolder"
+ @filename="qpid/framing/BodyHolder"
+ end
+
+ def gen_max_size()
+ # Generate program to generate MaxSize.h
+ cpp_file("generate_MaxMethodBodySize_h") {
+ include "qpid/framing/AMQHeaderBody"
+ include "qpid/framing/AMQContentBody"
+ include "qpid/framing/AMQHeartbeatBody"
+ @amqp.methods_.each { |m| include "qpid/framing/#{m.body_name}" }
+ genl
+ include "<algorithm>"
+ include "<fstream>"
+ genl
+ genl "using namespace std;"
+ genl "using namespace qpid::framing;"
+ genl
+ scope("int main(int, char** argv) {") {
+ genl "size_t maxSize=0;"
+ genl "maxSize=max(maxSize, sizeof(AMQHeaderBody));"
+ genl "maxSize=max(maxSize, sizeof(AMQContentBody));"
+ genl "maxSize=max(maxSize, sizeof(AMQHeartbeatBody));"
+ @amqp.methods_.each { |m|
+ genl "maxSize=max(maxSize, sizeof(#{m.body_name}));" }
+ gen <<EOS
+ofstream out("qpid/framing/MaxMethodBodySize.h");
+out << "// GENERATED CODE: generated by " << argv[0] << endl;
+out << "namespace qpid{ namespace framing { " << endl;
+out << "const size_t MAX_METHOD_BODY_SIZE=" << maxSize << ";" << endl;
+out << "}}" << endl;
+EOS
+ }
+ }
+ end
+
+ def gen_construct
+ cpp_file(@filename+"_gen") {
+ include @filename
+ include "qpid/framing/AMQHeaderBody"
+ include "qpid/framing/AMQContentBody"
+ include "qpid/framing/AMQHeartbeatBody"
+ @amqp.methods_.each { |m| include "qpid/framing/#{m.body_name}" }
+ include "qpid/framing/FrameDefaultVisitor.h"
+ include "qpid/Exception.h"
+ genl
+ namespace(@namespace) {
+ scope("void #{@classname}::setMethod(ClassId c, MethodId m) {") {
+ scope("switch (c) {") {
+ @amqp.classes.each { |c|
+ scope("case #{c.code}: switch(m) {") {
+ c.methods_.each { |m|
+ genl "case #{m.code}: blob = in_place<#{m.body_name}>(); break;"
+ }
+ genl "default: throw Exception(QPID_MSG(\"Invalid method id \" << int(m) << \" for class #{c.name} \"));"
+ }
+ genl "break;"
+ }
+ genl "default: throw Exception(QPID_MSG(\"Invalid class id \" << int(c)));"
+ }
+ }
+
+ struct("CopyVisitor", "public FrameDefaultVisitor") {
+ genl "using FrameDefaultVisitor::visit;"
+ genl "using FrameDefaultVisitor::defaultVisit;"
+ genl "BodyHolder& holder;"
+ genl "CopyVisitor(BodyHolder& h) : holder(h) {}"
+ ["Header", "Content", "Heartbeat"].each { |type|
+ genl "void visit(const AMQ#{type}Body& x) { holder=x; }"
+ }
+ @amqp.methods_.each { |m|
+ genl "void visit(const #{m.body_name}& x) { holder=x; }"
+ }
+ genl "void defaultVisit(const AMQBody&) { assert(0); }"
+ }
+ genl
+
+ scope("void BodyHolder::setBody(const AMQBody& b) {") {
+ genl "CopyVisitor cv(*this); b.accept(cv);"
+ }
+ }}
+ end
+
+ def generate
+ gen_max_size
+ gen_construct
+ end
+end
+
+MethodHolderGen.new($outdir, $amqp).generate();
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/MethodHolder.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Operations.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Operations.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Operations.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Operations.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,96 @@
+#!/usr/bin/env ruby
+# Usage: output_directory xml_spec_file [xml_spec_file...]
+#
+$: << '..'
+require 'cppgen'
+require 'fileutils'
+require 'etc'
+require 'pathname'
+
+class OperationsGen < CppGen
+
+ def initialize(chassis, outdir, amqp)
+ super(outdir, amqp)
+ @chassis=chassis
+ @classname="AMQP_#{@chassis.caps}Operations"
+ end
+
+ def handler_method (m)
+ return_type = m.result ? m.result.cpptype.ret_by_val : "void"
+ gen "\nvirtual #{return_type} #{m.cppname}("
+ gen m.signature.join(",\n")
+ gen ") = 0;\n"
+ end
+
+ def handler_classname(c) c.name.caps+"Handler"; end
+
+ def handler_class(c)
+ if (!c.methods_on(@chassis).empty?)
+ handlerclass=handler_classname c
+ gen <<EOS
+// ==================== class #{handlerclass} ====================
+class #{handlerclass} {
+ // Constructors and destructors
+ public:
+ class Invoker; // Declared in #{@chassis.caps}Invoker
+
+ #{handlerclass}(){};
+ virtual ~#{handlerclass}() {}
+ // Protocol methods
+EOS
+ c.methods_on(@chassis).each { |m| handler_method(m) if !m.content() }
+ gen <<EOS
+}; // class #{handlerclass}
+
+
+EOS
+ end
+ end
+
+ def handler_get(c)
+ if (!c.methods_on(@chassis).empty?)
+ handlerclass=handler_classname c
+ gen "virtual #{handlerclass}* get#{handlerclass}() = 0;\n"
+ end
+ end
+
+ def generate()
+ h_file("qpid/framing/#{@classname}.h") {
+ gen <<EOS
+#include <sstream>
+#include "qpid/framing/ProtocolVersion.h"
+#include "qpid/framing/amqp_structs.h"
+
+namespace qpid {
+namespace framing {
+
+class AMQMethodBody;
+
+class #{@classname} {
+ public:
+ class Invoker; // Declared in #{@chassis.caps}Invoker
+
+ virtual ~#{@classname}() {}
+
+ virtual ProtocolVersion getVersion() const = 0;
+
+ // Inner classes
+EOS
+ indent { @amqp.classes.each { |c| handler_class(c) } }
+ gen <<EOS
+
+ // Method handler get methods
+
+EOS
+ indent { @amqp.classes.each { |c| handler_get(c) } }
+ gen <<EOS
+}; /* class #{@classname} */
+}}
+EOS
+}
+ end
+end
+
+OperationsGen.new("client",ARGV[0], $amqp).generate()
+OperationsGen.new("server",ARGV[0], $amqp).generate()
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Operations.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,92 @@
+#!/usr/bin/env ruby
+# Usage: output_directory xml_spec_file [xml_spec_file...]
+#
+$: << '..'
+require 'cppgen'
+
+class OperationsInvokerGen < CppGen
+ def initialize(chassis, outdir, amqp)
+ super(outdir, amqp)
+ @chassis=chassis
+ @ops="AMQP_#{@chassis.caps}Operations"
+ @classname="#{@ops}::Invoker"
+ @filename="qpid/framing/#{@chassis.caps}Invoker"
+ end
+
+ def handler(c) "#{@ops}::#{c.cppname}Handler"; end
+ def getter(c) "get#{c.cppname}Handler"; end
+ def invoker(c) "#{handler(c)}::Invoker"; end
+ def visit_methods(c) c.methods_on(@chassis).select { |m| !m.content } end
+
+ def handler_visits_cpp(c)
+ visit_methods(c).each { |m|
+ scope("void #{invoker(c)}::visit(const #{m.body_name}& body) {") {
+ if (m.result)
+ genl "this->encode(body.invoke(target), result.result);"
+ else
+ genl "body.invoke(target);"
+ end
+ genl "result.handled=true;"
+ }
+ }
+ end
+
+ def ops_visits_cpp()
+ @amqp.classes.each { |c|
+ visit_methods(c).each { |m|
+ scope("void #{@classname}::visit(const #{m.body_name}& body) {") {
+ genl "#{handler(c)}::Invoker invoker(*target.#{getter(c)}());"
+ genl "body.accept(invoker);"
+ genl "result=invoker.getResult();"
+ }
+ }
+ }
+ end
+
+ def invoker_h(invoker, target, methods)
+ return if methods.empty?
+ genl
+ cpp_class(invoker, "public qpid::framing::Invoker") {
+ genl "#{target}& target;"
+ public
+ genl("Invoker(#{target}& target_) : target(target_) {}")
+ genl "using MethodBodyDefaultVisitor::visit;"
+ methods.each { |m| genl "void visit(const #{m.body_name}& body);" }
+ }
+ end
+
+ def generate()
+ h_file(@filename) {
+ include "qpid/framing/#{@ops}"
+ include "qpid/framing/Invoker.h"
+ namespace("qpid::framing") {
+ # AMQP_*Operations invoker.
+ methods=@amqp.classes.map { |c| visit_methods(c).to_a }.flatten
+ invoker_h(@classname, @ops, methods)
+
+ # AMQP_*Operations::*Handler invokers.
+ @amqp.classes.each { |c|
+ invoker_h(invoker(c), handler(c), visit_methods(c))
+ }
+ }
+ }
+
+ cpp_file(@filename) {
+ include @filename
+ @amqp.classes.each { |c|
+ visit_methods(c).each { |m|
+ include "qpid/framing/#{m.body_name}"
+ }}
+ namespace("qpid::framing") {
+ ops_visits_cpp
+ @amqp.classes.each { |c|
+ next if visit_methods(c).empty?
+ handler_visits_cpp(c)
+ }
+ }
+ }
+ end
+end
+
+OperationsInvokerGen.new("client",ARGV[0], $amqp).generate()
+OperationsInvokerGen.new("server",ARGV[0], $amqp).generate()
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Proxy.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Proxy.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Proxy.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Proxy.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,84 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class ProxyGen < CppGen
+
+ def initialize(chassis, outdir, amqp)
+ super(outdir, amqp)
+ @chassis=chassis
+ @classname="AMQP_#{@chassis.caps}Proxy"
+ @filename="qpid/framing/#{@classname}"
+ end
+
+ def proxy_member(c) c.name.lcaps+"Proxy"; end
+
+ def inner_class_decl(c)
+ cname=c.name.caps
+ cpp_class(cname, "Proxy") {
+ gen <<EOS
+public:
+#{cname}(FrameHandler& f) : Proxy(f) {}
+static #{cname}& get(#{@classname}& proxy) { return proxy.get#{cname}(); }
+EOS
+ c.methods_on(@chassis).each { |m|
+ genl "virtual void #{m.cppname}(#{m.signature.join(",\n ")});"
+ genl
+ }}
+ end
+
+ def inner_class_defn(c)
+ cname=c.cppname
+ c.methods_on(@chassis).each { |m|
+ genl "void #{@classname}::#{cname}::#{m.cppname}(#{m.signature.join(", ")})"
+ scope {
+ params=(["getVersion()"]+m.param_names).join(", ")
+ genl "send(#{m.body_name}(#{params}));"
+ }}
+ end
+
+ def generate
+ # .h file
+ h_file(@filename) {
+ include "qpid/framing/Proxy.h"
+ include "qpid/framing/Array.h"
+ include "qpid/framing/amqp_types.h"
+ include "qpid/framing/amqp_structs.h"
+ namespace("qpid::framing") {
+ cpp_class(@classname, "public Proxy") {
+ public
+ genl "#{@classname}(FrameHandler& out);"
+ genl
+ @amqp.classes.each { |c|
+ inner_class_decl(c)
+ genl
+ genl "#{c.cppname}& get#{c.cppname}() { return #{proxy_member(c)}; }"
+ genl
+ }
+ private
+ @amqp.classes.each{ |c| gen c.cppname+" "+proxy_member(c)+";\n" }
+ }}}
+
+ # .cpp file
+ cpp_file(@filename) {
+ include "<sstream>"
+ include "#{@classname}.h"
+ include "qpid/framing/amqp_types_full.h"
+ @amqp.methods_on(@chassis).each {
+ |m| include "qpid/framing/"+m.body_name
+ }
+ genl
+ namespace("qpid::framing") {
+ genl "#{@classname}::#{@classname}(FrameHandler& f) :"
+ gen " Proxy(f)"
+ @amqp.classes.each { |c| gen ",\n "+proxy_member(c)+"(f)" }
+ genl "{}\n"
+ @amqp.classes.each { |c| inner_class_defn(c) }
+ }}
+ end
+end
+
+
+ProxyGen.new("client", $outdir, $amqp).generate;
+ProxyGen.new("server", $outdir, $amqp).generate;
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Proxy.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Session.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Session.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Session.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/Session.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,199 @@
+#!/usr/bin/env ruby
+# Usage: output_directory xml_spec_file [xml_spec_file...]
+#
+$: << '..'
+require 'cppgen'
+
+class CppGen
+ def session_methods
+ excludes = ["connection", "session", "file", "stream"]
+ gen_methods=@amqp.methods_on(@chassis).reject { |m|
+ excludes.include? m.parent.name or m.body_name.include?("010")
+ }
+ end
+
+ def doxygen(m)
+ doxygen_comment {
+ genl m.doc
+ genl
+ m.fields_c.each { |f|
+ genl "@param #{f.cppname}"
+ genl f.doc if f.doc
+ genl
+ }
+ }
+ end
+end
+
+class ContentField # For extra content parameters
+ def cppname() "content" end
+ def signature() "const MethodContent& content" end
+ def sig_default() signature+"="+"DefaultContent(std::string())" end
+ def unpack() "p[arg::content|DefaultContent(std::string())]"; end
+ def doc() "Message content"; end
+end
+
+class AmqpField
+ def unpack() "p[arg::#{cppname}|#{cpptype.default_value}]"; end
+ def sig_default() signature+"="+cpptype.default_value; end
+end
+
+class AmqpMethod
+ def fields_c() content ? fields+[ContentField.new] : fields end
+ def param_names_c() fields_c.map { |f| f.cppname} end
+ def signature_c() fields_c.map { |f| f.signature }; end
+ def sig_c_default() fields_c.map { |f| f.sig_default }; end
+ def argpack_name() "#{parent.cppname}#{name.caps}Parameters"; end
+ def argpack_type()
+ "boost::parameter::parameters<" +
+ fields_c.map { |f| "arg::keyword_tags::"+f.cppname }.join(',') +
+ ">"
+ end
+ def return_type()
+ return "TypedResult<qpid::framing::#{result.cpptype.ret_by_val}>" if (result)
+ return "Response" if (not responses().empty?)
+ return "Completion"
+ end
+ def session_function() "#{parent.name.lcaps}#{name.caps}"; end
+end
+
+class SessionNoKeywordGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @chassis="server"
+ @namespace,@classname,@file=
+ parse_classname "qpid::client::no_keyword::Session_#{@amqp.version.bars}"
+ end
+
+ def generate()
+ h_file(@file) {
+ include "qpid/client/SessionBase.h"
+
+ namespace("qpid::client") {
+ genl "using std::string;"
+ genl "using framing::Content;"
+ genl "using framing::FieldTable;"
+ genl "using framing::MethodContent;"
+ genl "using framing::SequenceNumber;"
+ genl "using framing::SequenceSet;"
+ genl "using framing::Uuid;"
+ #the following are nasty... would be better to dynamically
+ #include such statements based on params required
+ genl "using framing::Xid;"
+ genl
+ namespace("no_keyword") {
+ doxygen_comment {
+ genl "AMQP #{@amqp.version} session API."
+ genl @amqp.class_("session").doc
+ }
+ cpp_class(@classname, "public SessionBase") {
+ public
+ genl "Session_#{@amqp.version.bars}() {}"
+ genl "Session_#{@amqp.version.bars}(shared_ptr<SessionImpl> core) : SessionBase(core) {}"
+ session_methods.each { |m|
+ genl
+ doxygen(m)
+ args=m.sig_c_default.join(", ")
+ genl "#{m.return_type} #{m.session_function}(#{args});"
+ }
+ }}}}
+
+ cpp_file(@file) {
+ include @classname
+ include "qpid/framing/all_method_bodies.h"
+ namespace(@namespace) {
+ genl "using namespace framing;"
+ session_methods.each { |m|
+ genl
+ sig=m.signature_c.join(", ")
+ func="#{@classname}::#{m.session_function}"
+ scope("#{m.return_type} #{func}(#{sig}) {") {
+ args=(["ProtocolVersion()"]+m.param_names).join(", ")
+ body="#{m.body_name}(#{args})"
+ sendargs=body
+ sendargs << ", content" if m.content
+ genl "return #{m.return_type}(impl->send(#{sendargs}), impl);"
+ }}}}
+ end
+end
+
+class SessionGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @chassis="server"
+ session="Session_#{@amqp.version.bars}"
+ @base="no_keyword::#{session}"
+ @fqclass=FqClass.new "qpid::client::#{session}"
+ @classname=@fqclass.name
+ @fqbase=FqClass.new("qpid::client::#{@base}")
+ end
+
+ def gen_keyword_decl(m, prefix)
+ return if m.fields_c.empty? # Inherited function will do.
+ scope("BOOST_PARAMETER_MEMFUN(#{m.return_type}, #{m.session_function}, 0, #{m.fields_c.size}, #{m.argpack_name}) {") {
+ scope("return #{prefix}#{m.session_function}(",");") {
+ gen m.fields_c.map { |f| f.unpack() }.join(",\n")
+ }
+ }
+ genl
+ end
+
+ def generate()
+ keyword_methods=session_methods.reject { |m| m.fields_c.empty? }
+ max_arity = keyword_methods.map{ |m| m.fields_c.size }.max
+
+ h_file(@fqclass.file) {
+ include @fqbase.file
+ genl
+ genl "#define BOOST_PARAMETER_MAX_ARITY #{max_arity}"
+ include "<boost/parameter.hpp>"
+ genl
+ namespace("qpid::client") {
+ # Generate keyword tag declarations.
+ namespace("arg") {
+ keyword_methods.map{ |m| m.param_names_c }.flatten.uniq.each { |k|
+ genl "BOOST_PARAMETER_KEYWORD(keyword_tags, #{k})"
+ }}
+ genl
+ # Doxygen comment.
+ doxygen_comment {
+ genl "AMQP #{@amqp.version} session API with keyword arguments."
+ genl <<EOS
+This class provides the same set of functions as #{@base}, but also
+allows parameters be passed using keywords. The keyword is the
+parameter name in the namespace "arg".
+
+For example given the normal function "foo(int x=0, int y=0, int z=0)"
+you could call it in either of the following ways:
+
+@code
+session.foo(1,2,3); // Normal no keywords
+session.foo(arg::z=3, arg::x=1); // Keywords and a default
+@endcode
+
+The keyword functions are easy to use but their declarations are hard
+to read. You may find it easier to read the documentation for #{@base}
+which provides the same set of functions using normal non-keyword
+declarations.
+
+\\ingroup clientapi
+EOS
+ }
+ # Session class.
+ cpp_class(@classname,"public #{@base}") {
+ private
+ genl "#{@classname}(shared_ptr<SessionImpl> core) : #{ @base}(core) {}"
+ keyword_methods.each { |m| typedef m.argpack_type, m.argpack_name }
+ genl "friend class Connection;"
+ public
+ genl "#{@classname}() {}"
+ keyword_methods.each { |m| gen_keyword_decl(m,@base+"::") }
+ }}}
+ end
+end
+
+SessionNoKeywordGen.new(ARGV[0], $amqp).generate()
+SessionGen.new(ARGV[0], $amqp).generate()
+
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class AllMethodBodiesGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @filename="qpid/framing/all_method_bodies"
+ end
+
+ def generate()
+ h_file(@filename) {
+ @amqp.methods_.each { |m| include "qpid/framing/"+m.body_name }
+ }
+ end
+end
+
+AllMethodBodiesGen.new($outdir, $amqp).generate();
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/constants.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/constants.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/constants.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/constants.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,99 @@
+#!/usr/bin/env ruby
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class ConstantsGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ @namespace="qpid::framing"
+ @dir="qpid/framing"
+ end
+
+ def constants_h()
+ h_file("#{@dir}/constants") {
+ namespace(@namespace) {
+ scope("enum AmqpConstant {","};") {
+ l=[]
+ l.concat @amqp.constants.map { |c| "#{c.name.shout}=#{c.value}" }
+ @amqp.classes.each { |c|
+ l << "#{c.name.shout}_CLASS_ID=#{c.code}"
+ l.concat c.methods_.map { |m|
+ "#{c.name.shout}_#{m.name.shout}_METHOD_ID=#{m.code}" }
+ }
+ genl l.join(",\n")
+ }
+ namespace("execution") {
+ define_constants_for(@amqp.class_("execution").domain("error-code").enum)
+ }
+ namespace("connection") {
+ define_constants_for(@amqp.class_("connection").domain("close-code").enum)
+ }
+ namespace("session") {
+ define_constants_for(@amqp.class_("session").domain("detach-code").enum)
+ }
+ define_constants_for(@amqp.class_("dtx").domain("xa-status").enum)
+ }
+ }
+ end
+
+ def define_constants_for(enum)
+ scope("enum #{enum.parent.name.caps} {","};") {
+ genl enum.choices.collect { |c| "#{c.name.shout}=#{c.value}" }.join(",\n")
+ }
+ end
+
+ def define_exception(c, base, package)
+ name=c.name.caps+"Exception"
+ genl
+ doxygen_comment { genl c.doc }
+ struct(c.name.caps+"Exception", base) {
+ genl "#{c.name.caps}Exception(const std::string& msg=std::string()) : #{base}(#{c.value}, \"#{c.name}: \"+msg) {}"
+ }
+ end
+
+ def define_exceptions_for(class_name, domain_name, base)
+ enum = @amqp.class_(class_name).domain(domain_name).enum
+ enum.choices.each { |c| define_exception(c, base, class_name) unless c.name == "normal" }
+ end
+
+ def reply_exceptions_h()
+ h_file("#{@dir}/reply_exceptions") {
+ include "qpid/Exception"
+ namespace(@namespace) {
+ define_exceptions_for("execution", "error-code", "SessionException")
+ define_exceptions_for("connection", "close-code", "ConnectionException")
+ define_exceptions_for("session", "detach-code", "ChannelException")
+ genl
+ genl "void throwExecutionException(int code, const std::string& text);"
+ }
+ }
+ end
+
+ def reply_exceptions_cpp()
+ cpp_file("#{@dir}/reply_exceptions") {
+ include "#{@dir}/reply_exceptions"
+ include "<sstream>"
+ namespace("qpid::framing") {
+ scope("void throwExecutionException(int code, const std::string& text) {"){
+ scope("switch (code) {") {
+ enum = @amqp.class_("execution").domain("error-code").enum
+ enum.choices.each { |c|
+ genl "case #{c.value}: throw #{c.name.caps}Exception(text);"
+ }
+ genl "default: break;"
+ }
+ }
+ }
+ }
+ end
+
+ def generate()
+ constants_h
+ reply_exceptions_h
+ reply_exceptions_cpp
+ end
+end
+
+ConstantsGen.new($outdir, $amqp).generate();
+
Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/constants.rb
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,31 @@
+$: << ".." # Include .. in load path
+require 'cppgen'
+
+class FrameBodyListsGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp);
+ end
+
+ def generate
+ h_file("qpid/framing/frame_body_lists.h") {
+ gen <<EOS
+/**@file
+ * Macro lists of frame body classes, used to generate Visitors
+ */
+EOS
+ gen "#define METHOD_BODIES() "
+ @amqp.methods_.each { |m| gen "\\\n (#{m.body_name}) " }
+ gen <<EOS
+
+
+#define OTHER_BODIES() (AMQContentBody)(AMQHeaderBody)(AMQHeartbeatBody))
+
+EOS
+ }
+ end
+end
+
+FrameBodyListsGen.new(ARGV[0], $amqp).generate;
+
+
Added: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb?rev=651423&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb Thu Apr 24 14:07:34 2008
@@ -0,0 +1,583 @@
+#!/usr/bin/env ruby
+# Usage: output_directory xml_spec_file [xml_spec_file...]
+#
+$: << '..'
+require 'cppgen'
+
+class StructGen < CppGen
+
+ def initialize(outdir, amqp)
+ super(outdir, amqp)
+ end
+
+ SizeMap={
+ "Octet"=>1,
+ "Short"=>2,
+ "Long"=>4,
+ "LongLong"=>8,
+ "int8"=>1,
+ "int16"=>2,
+ "int32"=>4,
+ "int64"=>8,
+ "uint8"=>1,
+ "uint16"=>2,
+ "uint32"=>4,
+ "uint64"=>8,
+ "timestamp"=>8
+ }
+
+ SizeType={
+ 1=>"Octet",
+ 2=>"Short",
+ 4=>"Long",
+ 8=>"LongLong"
+ }
+
+ ValueTypes=["uint8_t", "uint16_t", "uint32_t", "uint64_t"]
+
+ def is_packed(s) s.pack and s.pack != "0" end
+
+ def execution_header?(s)
+ s.is_a? AmqpMethod and not s.parent.control?
+ # s.kind_of? AmqpMethod and s.parent.name.include?("010") and not s.parent.control?
+ end
+
+ def has_bitfields_only(s)
+ s.fields.select {|f| f.type_ != "bit"}.empty?
+ end
+
+ def default_initialisation(s)
+ params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")}
+ strings = params.collect {|f| "#{f.cppname}(0)"}
+ strings << "flags(0)" if (is_packed(s))
+ if strings.empty?
+ return ""
+ else
+ return " : " + strings.join(", ")
+ end
+ end
+
+ def printable_form(f)
+ if (f.cpptype.name == "uint8_t")
+ return "(int) " + f.cppname
+ elsif (f.type_ == "bit")
+ return "get#{f.name.caps}()"
+ else
+ return f.cppname
+ end
+ end
+
+ def flag_mask(s, i)
+ pos = s.pack.to_i*8 - 8 - (i/8)*8 + (i % 8)
+ return "(1 << #{pos})"
+ end
+
+ def encode_packed_struct(s)
+ genl s.cpp_pack_type.encode('flags', 'buffer')
+ process_packed_fields(s) { |f, i| encode_packed_field(s, f, i) unless f.type_ == "bit" }
+ end
+
+ def decode_packed_struct(s)
+ genl "#{s.cpp_pack_type.decode('flags', 'buffer')}"
+ process_packed_fields(s) { |f, i| decode_packed_field(s, f, i) unless f.type_ == "bit" }
+ end
+
+ def size_packed_struct(s)
+ genl "total += #{s.pack};"
+ process_packed_fields(s) { |f, i| size_packed_field(s, f, i) unless f.type_ == "bit" }
+ end
+
+ def print_packed_struct(s)
+ process_packed_fields(s) { |f, i| print_packed_field(s, f, i) }
+ end
+
+ def encode_packed_field(s, f, i)
+ genl "if (flags & #{flag_mask(s, i)})"
+ indent { genl f.cpptype.encode(f.cppname,"buffer") }
+ end
+
+ def decode_packed_field(s, f, i)
+ genl "if (flags & #{flag_mask(s, i)})"
+ indent { genl f.cpptype.decode(f.cppname,"buffer") }
+ end
+
+ def size_packed_field(s, f, i)
+ genl "if (flags & #{flag_mask(s, i)})"
+ indent { generate_size(f, []) }
+ end
+
+ def print_packed_field(s, f, i)
+ genl "if (flags & #{flag_mask(s, i)})"
+ indent {
+ genl "out << \"#{f.name}=\" << #{printable_form(f)} << \"; \";"
+ }
+ end
+
+ def generate_encode(f, combined)
+ if (f.type_ == "bit")
+ genl "uint8_t #{f.cppname}_bits = #{f.cppname};"
+ count = 0
+ combined.each { |c| genl "#{f.cppname}_bits |= #{c.cppname} << #{count += 1};" }
+ genl "buffer.putOctet(#{f.cppname}_bits);"
+ else
+ genl f.cpptype.encode(f.cppname,"buffer")
+ end
+ end
+
+ def generate_decode(f, combined)
+ if (f.type_ == "bit")
+ genl "uint8_t #{f.cppname}_bits = buffer.getOctet();"
+ genl "#{f.cppname} = 1 & #{f.cppname}_bits;"
+ count = 0
+ combined.each { |c| genl "#{c.cppname} = (1 << #{count += 1}) & #{f.cppname}_bits;" }
+ else
+ genl f.cpptype.decode(f.cppname,"buffer")
+ end
+ end
+
+ def generate_size(f, combined)
+ if (f.type_ == "bit")
+ names = ([f] + combined).collect {|g| g.cppname}
+ genl "total += 1;//#{names.join(", ")}"
+ else
+ size = SizeMap[f.cpptype.encoded]
+ if (size)
+ genl "total += #{size};//#{f.cppname}"
+ elsif (f.cpptype.name == "SequenceNumberSet")
+ genl "total += #{f.cppname}.encodedSize();"
+ else
+ encoded = f.cpptype.encoded
+ gen "total += ("
+ gen "4 + " if encoded == "LongString"
+ gen "2 + " if encoded == "MediumString"
+ gen "1 + " if encoded == "ShortString"
+ genl "#{f.cppname}.size());"
+ end
+ end
+ end
+
+ def process_packed_fields(s)
+ s.fields.each { |f| yield f, s.fields.index(f) }
+ end
+
+ def process_fields(s)
+ last = nil
+ count = 0
+ bits = []
+ s.fields.each {
+ |f| if (last and last.bit? and f.bit? and count < 7)
+ count += 1
+ bits << f
+ else
+ if (last and last.bit?)
+ yield last, bits
+ count = 0
+ bits = []
+ end
+ if (not f.bit?)
+ yield f
+ end
+ last = f
+ end
+ }
+ if (last and last.bit?)
+ yield last, bits
+ end
+ end
+
+ def all_fields_via_accessors(s)
+ s.fields.collect { |f| "get#{f.name.caps}()" }.join(", ")
+ end
+
+ def methodbody_extra_defs(s)
+ if (s.parent.control?)
+ genl "virtual uint8_t type() const { return 0;/*control segment*/ }"
+ end
+
+
+ gen <<EOS
+ typedef #{s.result ? s.result.cpptype.name : 'void'} ResultType;
+
+ template <class T> ResultType invoke(T& invocable) const {
+ return invocable.#{s.cppname}(#{all_fields_via_accessors(s)});
+ }
+
+ using AMQMethodBody::accept;
+ void accept(MethodBodyConstVisitor& v) const { v.visit(*this); }
+
+ ClassId amqpClassId() const { return CLASS_ID; }
+ MethodId amqpMethodId() const { return METHOD_ID; }
+ bool isContentBearing() const { return #{s.content ? "true" : "false" }; }
+ bool resultExpected() const { return #{s.result ? "true" : "false"}; }
+ bool responseExpected() const { return #{s.responses().empty? ? "false" : "true"}; }
+EOS
+ end
+
+ def define_constructor(name, s)
+ if (s.fields.size > 0)
+ genl "#{name}("
+ if (s.kind_of? AmqpMethod)
+ indent {gen "ProtocolVersion, "}
+ end
+ indent { gen s.fields.collect { |f| "#{f.cpptype.param} _#{f.cppname}" }.join(",\n") }
+ genl ") : "
+ if (is_packed(s))
+ initialisers = s.fields.select { |f| f.type_ != "bit"}.collect { |f| "#{f.cppname}(_#{f.cppname})"}
+
+ initialisers << "flags(0)"
+ indent { gen initialisers.join(",\n") }
+ genl "{"
+ indent {
+ process_packed_fields(s) { |f, i| genl "set#{f.name.caps}(_#{f.cppname});" if f.type_ == "bit"}
+ process_packed_fields(s) { |f, i| genl "flags |= #{flag_mask(s, i)};" unless f.type_ == "bit"}
+ }
+ genl "}"
+ else
+ indent { gen s.fields.collect { |f| " #{f.cppname}(_#{f.cppname})" }.join(",\n") }
+ genl "{}"
+ end
+ end
+ #default constructors:
+ if (s.kind_of? AmqpMethod)
+ genl "#{name}(ProtocolVersion=ProtocolVersion()) #{default_initialisation(s)} {}"
+ end
+ if (s.kind_of? AmqpStruct)
+ genl "#{name}() #{default_initialisation(s)} {}"
+ end
+ end
+
+ def define_packed_field_accessors(s, f, i)
+ if (s.kind_of? AmqpMethod)
+ define_packed_field_accessors_for_method(s, f, i)
+ else
+ define_packed_field_accessors_for_struct(s, f, i)
+ end
+ end
+
+ def define_packed_field_accessors_for_struct(s, f, i)
+ if (f.type_ == "bit")
+ genl "void #{s.cppname}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {"
+ indent {
+ genl "if (_#{f.cppname}) flags |= #{flag_mask(s, i)};"
+ genl "else flags &= ~#{flag_mask(s, i)};"
+ }
+ genl "}"
+ genl "#{f.cpptype.ret} #{s.cppname}::get#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }"
+ else
+ genl "void #{s.cppname}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {"
+ indent {
+ genl "#{f.cppname} = _#{f.cppname};"
+ genl "flags |= #{flag_mask(s, i)};"
+ }
+ genl "}"
+ genl "#{f.cpptype.ret} #{s.cppname}::get#{f.name.caps}() const { return #{f.cppname}; }"
+ if (f.cpptype.name == "FieldTable")
+ genl "#{f.cpptype.name}& #{s.cppname}::get#{f.name.caps}() {"
+ indent {
+ genl "flags |= #{flag_mask(s, i)};"#treat the field table as having been 'set'
+ genl "return #{f.cppname};"
+ }
+ genl "}"
+ end
+ genl "bool #{s.cppname}::has#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }"
+ genl "void #{s.cppname}::clear#{f.name.caps}Flag() { flags &= ~#{flag_mask(s, i)}; }"
+ end
+ genl ""
+ end
+
+ def define_packed_field_accessors_for_method(s, f, i)
+ if (f.type_ == "bit")
+ genl "void #{s.body_name}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {"
+ indent {
+ genl "if (_#{f.cppname}) flags |= #{flag_mask(s, i)};"
+ genl "else flags &= ~#{flag_mask(s, i)};"
+ }
+ genl "}"
+ genl "#{f.cpptype.ret} #{s.body_name}::get#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }"
+ else
+ genl "void #{s.body_name}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {"
+ indent {
+ genl "#{f.cppname} = _#{f.cppname};"
+ genl "flags |= #{flag_mask(s, i)};"
+ }
+ genl "}"
+ genl "#{f.cpptype.ret} #{s.body_name}::get#{f.name.caps}() const { return #{f.cppname}; }"
+ if (f.cpptype.name == "FieldTable")
+ genl "#{f.cpptype.name}& #{s.body_name}::get#{f.name.caps}() {"
+ indent {
+ genl "flags |= #{flag_mask(s, i)};"#treat the field table as having been 'set'
+ genl "return #{f.cppname};"
+ }
+ genl "}"
+ end
+ genl "bool #{s.body_name}::has#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }"
+ genl "void #{s.body_name}::clear#{f.name.caps}Flag() { flags &= ~#{flag_mask(s, i)}; }"
+ end
+ genl ""
+ end
+
+ def define_packed_accessors(s)
+ process_packed_fields(s) { |f, i| define_packed_field_accessors(s, f, i) }
+ end
+
+ def declare_packed_accessors(f)
+ genl "void set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname});";
+ genl "#{f.cpptype.ret} get#{f.name.caps}() const;"
+ if (f.cpptype.name == "FieldTable")
+ genl "#{f.cpptype.name}& get#{f.name.caps}();"
+ end
+ if (f.type_ != "bit")
+ #extra 'accessors' for packed fields:
+ genl "bool has#{f.name.caps}() const;"
+ genl "void clear#{f.name.caps}Flag();"
+ end
+ end
+
+ def define_accessors(f)
+ genl "void set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) { #{f.cppname} = _#{f.cppname}; }"
+ genl "#{f.cpptype.ret} get#{f.name.caps}() const { return #{f.cppname}; }"
+ if (f.cpptype.name == "FieldTable")
+ genl "#{f.cpptype.name}& get#{f.name.caps}() { return #{f.cppname}; }"
+ end
+ end
+
+ def define_struct(s)
+ classname = s.cppname
+ inheritance = ""
+ if (s.kind_of? AmqpMethod)
+ classname = s.body_name
+ if (execution_header?(s))
+ inheritance = ": public ModelMethod"
+ else
+ inheritance = ": public AMQMethodBody"
+ end
+ end
+
+ h_file("qpid/framing/#{classname}.h") {
+ if (s.kind_of? AmqpMethod)
+ gen <<EOS
+#include "qpid/framing/AMQMethodBody.h"
+#include "qpid/framing/AMQP_ServerOperations.h"
+#include "qpid/framing/MethodBodyConstVisitor.h"
+EOS
+ end
+ include "qpid/framing/ModelMethod.h" if (execution_header?(s))
+
+ s.fields.each { |f| include "qpid/framing/#{f.cpptype.name}" if f.struct?}
+
+ gen <<EOS
+
+#include <ostream>
+#include "qpid/framing/amqp_types_full.h"
+
+namespace qpid {
+namespace framing {
+
+class #{classname} #{inheritance} {
+EOS
+ if (is_packed(s))
+ indent { s.fields.each { |f| genl "#{f.cpptype.name} #{f.cppname};" unless f.type_ == "bit"} }
+ indent {
+ genl "#{s.cpp_pack_type.name} flags;"
+ }
+ else
+ indent { s.fields.each { |f| genl "#{f.cpptype.name} #{f.cppname};" } }
+ end
+ genl "public:"
+ if (s.kind_of? AmqpMethod)
+ indent { genl "static const ClassId CLASS_ID = #{s.parent.code};" }
+ indent { genl "static const MethodId METHOD_ID = #{s.code};" }
+ end
+
+ if (s.kind_of? AmqpStruct)
+ if (s.code)
+ indent { genl "static const uint16_t TYPE = #{s.full_code};" }
+ end
+ end
+
+ indent {
+ define_constructor(classname, s)
+ genl ""
+ if (is_packed(s))
+ s.fields.each { |f| declare_packed_accessors(f) }
+ else
+ s.fields.each { |f| define_accessors(f) }
+ end
+ }
+ if (s.kind_of? AmqpMethod)
+ methodbody_extra_defs(s)
+ end
+ if (s.kind_of? AmqpStruct)
+ indent {genl "friend std::ostream& operator<<(std::ostream&, const #{classname}&);" }
+ end
+
+ gen <<EOS
+ void encode(Buffer&) const;
+ void decode(Buffer&, uint32_t=0);
+ void encodeStructBody(Buffer&) const;
+ void decodeStructBody(Buffer&, uint32_t=0);
+ uint32_t size() const;
+ uint32_t bodySize() const;
+ void print(std::ostream& out) const;
+}; /* class #{classname} */
+
+}}
+EOS
+ }
+ cpp_file("qpid/framing/#{classname}.cpp") {
+ if (is_packed(s) || s.fields.size > 0 || execution_header?(s))
+ buffer = "buffer"
+ else
+ buffer = "/*buffer*/"
+ end
+ gen <<EOS
+#include "#{classname}.h"
+
+#include "reply_exceptions.h"
+
+using namespace qpid::framing;
+
+EOS
+
+ if (is_packed(s))
+ define_packed_accessors(s)
+ end
+ gen <<EOS
+void #{classname}::encodeStructBody(Buffer& #{buffer}) const
+{
+EOS
+ if (execution_header?(s))
+ genl "encodeHeader(buffer);"
+ end
+
+ if (is_packed(s))
+ indent {encode_packed_struct(s)}
+ else
+ indent { process_fields(s) { |f, combined| generate_encode(f, combined) } }
+ end
+ gen <<EOS
+}
+
+void #{classname}::encode(Buffer& buffer) const
+{
+EOS
+ indent {
+ if (s.kind_of? AmqpStruct)
+ if (s.code)
+ genl "buffer.put#{SizeType[s.size.to_i]}(bodySize() + 2/*typecode*/);" if s.size and s.size.to_i != 0
+ genl "buffer.putShort(TYPE);"
+ else
+ genl "buffer.put#{SizeType[s.size.to_i]}(bodySize());" if s.size and s.size.to_i != 0
+ end
+ end
+ genl "encodeStructBody(buffer);"
+ }
+ gen <<EOS
+}
+
+void #{classname}::decodeStructBody(Buffer& #{buffer}, uint32_t /*size*/)
+{
+EOS
+ if (execution_header?(s))
+ genl "decodeHeader(buffer);"
+ end
+
+ if (is_packed(s))
+ indent {decode_packed_struct(s)}
+ else
+ indent { process_fields(s) { |f, combined| generate_decode(f, combined) } }
+ end
+ gen <<EOS
+}
+
+void #{classname}::decode(Buffer& buffer, uint32_t /*size*/)
+{
+EOS
+ indent {
+ if (s.kind_of? AmqpStruct)
+ genl "buffer.get#{SizeType[s.size.to_i]}();" if s.size and s.size.to_i != 0
+ genl "if (TYPE != buffer.getShort()) throw FramingErrorException(\"Bad type code for struct\");" if s.code
+ end
+ genl "decodeStructBody(buffer);"
+ }
+ gen <<EOS
+}
+
+uint32_t #{classname}::bodySize() const
+{
+ uint32_t total = 0;
+EOS
+ if (execution_header?(s))
+ genl "total += headerSize();"
+ end
+
+ if (is_packed(s))
+ indent {size_packed_struct(s)}
+ else
+ indent { process_fields(s) { |f, combined| generate_size(f, combined) } }
+ end
+ gen <<EOS
+ return total;
+}
+
+uint32_t #{classname}::size() const
+{
+ uint32_t total = bodySize();
+EOS
+ if (s.kind_of? AmqpStruct)
+ genl "total += #{s.size}/*size field*/;" if s.size
+ genl "total += 2/*typecode*/;" if s.code
+ end
+ gen <<EOS
+ return total;
+}
+
+void #{classname}::print(std::ostream& out) const
+{
+ out << "{#{classname}: ";
+EOS
+ if (is_packed(s))
+ indent {print_packed_struct(s)}
+ else
+ copy = Array.new(s.fields)
+ f = copy.shift
+
+ indent {
+ genl "out << \"#{f.name}=\" << #{printable_form(f)};" if f
+ copy.each { |f| genl "out << \"; #{f.name}=\" << #{printable_form(f)};" }
+ }
+ end
+ gen <<EOS
+ out << "}";
+}
+EOS
+
+ if (s.kind_of? AmqpStruct)
+ gen <<EOS
+namespace qpid{
+namespace framing{
+
+ std::ostream& operator<<(std::ostream& out, const #{classname}& s)
+ {
+ s.print(out);
+ return out;
+ }
+
+}
+}
+EOS
+ end
+}
+ end
+
+ def generate()
+ structs = @amqp.collect_all(AmqpStruct).select { |s| not ["command-fragment"].include?(s.name) }
+ structs.each { |s| define_struct(s) }
+ @amqp.methods_.each { |m| define_struct(m) }
+ #generate a single include file containing the list of structs for convenience
+ h_file("qpid/framing/amqp_structs.h") { structs.each { |s| genl "#include \"#{s.cppname}.h\"" } }
+ end
+end
+
+StructGen.new(ARGV[0], $amqp).generate()
+
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/generate
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/generate?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/generate (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/generate Thu Apr 24 14:07:34 2008
@@ -33,17 +33,23 @@
return specs
end
+gendir=File.dirname(__FILE__)
+
# Run selected templates
if ARGV.any? { |arg| arg=="all" }
- templates=Dir["#{File.dirname __FILE__}/*/*.rb"]
+ templates=Dir["#{gendir}/*/*.rb"]
else
templates=ARGV.grep(/\.rb$/)
+ ARGV.each { |arg|
+ d=File.join gendir,arg
+ templates += Dir["#{d}/*.rb"] if File.directory? d
+ }
end
$outdir=ARGV[0]
$models=parse_specs(ARGV.grep(/\.xml$/))
templates.each { |t|
- ver=Pathname.new(t).dirname.basename.to_s
+ ver=Pathname.new(t).dirname.basename.to_s.split('.')[-1]
$amqp=$models[ver]
if $amqp
load t
Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Thu Apr 24 14:07:34 2008
@@ -13,10 +13,9 @@
if GENERATE
-# AMQP_PREVIEW_XML and AMQP_FINAL_XML are defined in ../configure.ac
-amqp_99_0_xml=@AMQP_PREVIEW_XML@ $(top_srcdir)/xml/extra.xml $(top_srcdir)/xml/cluster.xml
+# AMQP_FINAL_XML is defined in ../configure.ac
amqp_0_10_xml=@AMQP_FINAL_XML@
-specs=$(amqp_99_0_xml) $(amqp_0_10_xml)
+specs=$(amqp_0_10_xml)
# Ruby generator.
rgen_dir=$(top_srcdir)/rubygen
@@ -152,7 +151,6 @@
qpid/framing/Buffer.cpp \
qpid/framing/FieldTable.cpp \
qpid/framing/FieldValue.cpp \
- qpid/framing/FramingContent.cpp \
qpid/framing/FrameSet.cpp \
qpid/framing/ProtocolInitiation.cpp \
qpid/framing/ProtocolVersion.cpp \
@@ -193,19 +191,11 @@
qpid/amqp_0_10/Connection.h \
qpid/amqp_0_10/Connection.cpp \
qpid/broker/Broker.cpp \
- qpid/broker/BrokerAdapter.cpp \
- qpid/broker/SessionAdapter.cpp \
qpid/broker/BrokerSingleton.cpp \
qpid/broker/Exchange.cpp \
qpid/broker/Queue.cpp \
qpid/broker/PersistableMessage.cpp \
qpid/broker/Bridge.cpp \
- qpid/broker/PreviewConnection.cpp \
- qpid/broker/PreviewConnectionCodec.cpp \
- qpid/broker/PreviewConnectionHandler.cpp \
- qpid/broker/PreviewSessionHandler.cpp \
- qpid/broker/PreviewSessionManager.cpp \
- qpid/broker/PreviewSessionState.cpp \
qpid/broker/Connection.cpp \
qpid/broker/ConnectionHandler.cpp \
qpid/broker/ConnectionFactory.cpp \
@@ -215,7 +205,6 @@
qpid/broker/DirectExchange.cpp \
qpid/broker/DtxAck.cpp \
qpid/broker/DtxBuffer.cpp \
- qpid/broker/DtxHandlerImpl.cpp \
qpid/broker/DtxManager.cpp \
qpid/broker/DtxTimeout.cpp \
qpid/broker/DtxWorkRecord.cpp \
@@ -228,7 +217,6 @@
qpid/broker/MessageAdapter.cpp \
qpid/broker/MessageBuilder.cpp \
qpid/broker/MessageDelivery.cpp \
- qpid/broker/MessageHandlerImpl.cpp \
qpid/broker/MessageStoreModule.cpp \
qpid/broker/NameGenerator.cpp \
qpid/broker/NullMessageStore.cpp \
@@ -241,6 +229,7 @@
qpid/broker/SaslAuthenticator.cpp \
qpid/broker/SemanticState.h \
qpid/broker/SemanticState.cpp \
+ qpid/broker/SessionAdapter.cpp \
qpid/broker/SessionState.h \
qpid/broker/SessionState.cpp \
qpid/broker/SessionManager.h \
@@ -248,7 +237,6 @@
qpid/broker/SessionHandler.h \
qpid/broker/SessionContext.h \
qpid/broker/SessionHandler.cpp \
- qpid/broker/SemanticHandler.cpp \
qpid/broker/System.cpp \
qpid/broker/Timer.cpp \
qpid/broker/TopicExchange.cpp \
@@ -308,18 +296,11 @@
qpid/memory.h \
qpid/shared_ptr.h \
qpid/broker/Broker.h \
- qpid/broker/BrokerAdapter.h \
qpid/broker/SessionAdapter.h \
qpid/broker/Exchange.h \
qpid/broker/Queue.h \
qpid/broker/BrokerSingleton.h \
qpid/broker/Bridge.h \
- qpid/broker/PreviewConnection.h \
- qpid/broker/PreviewConnectionCodec.h \
- qpid/broker/PreviewConnectionHandler.h \
- qpid/broker/PreviewSessionHandler.h \
- qpid/broker/PreviewSessionManager.h \
- qpid/broker/PreviewSessionState.h \
qpid/broker/Connection.h \
qpid/broker/ConnectionState.h \
qpid/broker/ConnectionFactory.h \
@@ -337,7 +318,6 @@
qpid/broker/DirectExchange.h \
qpid/broker/DtxAck.h \
qpid/broker/DtxBuffer.h \
- qpid/broker/DtxHandlerImpl.h \
qpid/broker/DtxManager.h \
qpid/broker/DtxTimeout.h \
qpid/broker/DtxWorkRecord.h \
@@ -351,7 +331,6 @@
qpid/broker/MessageAdapter.h \
qpid/broker/MessageBuilder.h \
qpid/broker/MessageDelivery.h \
- qpid/broker/MessageHandlerImpl.h \
qpid/broker/MessageStore.h \
qpid/broker/MessageStoreModule.h \
qpid/broker/NameGenerator.h \
@@ -372,8 +351,8 @@
qpid/broker/RecoveredEnqueue.h \
qpid/broker/RecoveryManager.h \
qpid/broker/RecoveryManagerImpl.h \
- qpid/broker/SemanticHandler.h \
qpid/broker/SaslAuthenticator.h \
+ qpid/broker/SessionAdapter.h \
qpid/broker/SessionManager.h \
qpid/broker/System.h \
qpid/broker/Timer.h \
@@ -434,7 +413,6 @@
qpid/framing/FrameHandler.h \
qpid/framing/FrameHandler.h \
qpid/framing/FrameSet.h \
- qpid/framing/FramingContent.h \
qpid/framing/Handler.h \
qpid/framing/HeaderProperties.h \
qpid/framing/Invoker.h \
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/Exception.h Thu Apr 24 14:07:34 2008
@@ -23,6 +23,7 @@
*/
#include "qpid/framing/amqp_types.h"
+#include "qpid/framing/constants.h"
#include "qpid/Msg.h"
#include <memory>
@@ -51,29 +52,22 @@
mutable std::string whatStr;
};
-/**
- * I have made SessionException a common base for Channel- and
- * Connection- Exceptions. This is not strictly correct but allows all
- * model layer exceptions to be handled as SessionExceptions which is
- * how they are classified in the final 0-10 specification. I.e. this
- * is a temporary hack to allow the preview and final codepaths to
- * co-exist with minimal changes.
- */
-
struct SessionException : public Exception {
const framing::ReplyCode code;
SessionException(framing::ReplyCode code_, const std::string& message)
: Exception(message), code(code_) {}
};
-struct ChannelException : public SessionException {
- ChannelException(framing::ReplyCode code, const std::string& message)
- : SessionException(code, message) {}
+struct ChannelException : public Exception {
+ const framing::ReplyCode code;
+ ChannelException(framing::ReplyCode _code, const std::string& message)
+ : Exception(message), code(_code) {}
};
-struct ConnectionException : public SessionException {
- ConnectionException(framing::ReplyCode code, const std::string& message)
- : SessionException(code, message) {}
+struct ConnectionException : public Exception {
+ const framing::ReplyCode code;
+ ConnectionException(framing::ReplyCode _code, const std::string& message)
+ : Exception(message), code(_code) {}
};
struct ClosedException : public Exception {
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Bridge.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Bridge.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Bridge.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Bridge.cpp Thu Apr 24 14:07:34 2008
@@ -46,24 +46,24 @@
void Bridge::create()
{
- framing::AMQP_ServerProxy::Session010 session(channel);
+ framing::AMQP_ServerProxy::Session session(channel);
session.attach(name, false);
if (args.i_src_is_local) {
//TODO: handle 'push' here... simplest way is to create frames and pass them to Connection::received()
} else {
if (args.i_src_is_queue) {
- peer.getMessage010().subscribe(args.i_src, args.i_dest, 0, 0, false, "", 0, FieldTable());
- peer.getMessage010().flow(args.i_dest, 0, 0xFFFFFFFF);
- peer.getMessage010().flow(args.i_dest, 1, 0xFFFFFFFF);
+ peer.getMessage().subscribe(args.i_src, args.i_dest, 0, 0, false, "", 0, FieldTable());
+ peer.getMessage().flow(args.i_dest, 0, 0xFFFFFFFF);
+ peer.getMessage().flow(args.i_dest, 1, 0xFFFFFFFF);
} else {
string queue = "bridge_queue_";
queue += Uuid(true).str();
- peer.getQueue010().declare(queue, "", false, false, true, true, FieldTable());
- peer.getExchange010().bind(queue, args.i_src, args.i_key, FieldTable());
- peer.getMessage010().subscribe(queue, args.i_dest, 0, 0, false, "", 0, FieldTable());
- peer.getMessage010().flow(args.i_dest, 0, 0xFFFFFFFF);
- peer.getMessage010().flow(args.i_dest, 1, 0xFFFFFFFF);
+ peer.getQueue().declare(queue, "", false, false, true, true, FieldTable());
+ peer.getExchange().bind(queue, args.i_src, args.i_key, FieldTable());
+ peer.getMessage().subscribe(queue, args.i_dest, 0, 0, false, "", 0, FieldTable());
+ peer.getMessage().flow(args.i_dest, 0, 0xFFFFFFFF);
+ peer.getMessage().flow(args.i_dest, 1, 0xFFFFFFFF);
}
}
@@ -71,8 +71,8 @@
void Bridge::cancel()
{
- peer.getMessage010().cancel(args.i_dest);
- peer.getSession010().detach(name);
+ peer.getMessage().cancel(args.i_dest);
+ peer.getSession().detach(name);
}
management::ManagementObject::shared_ptr Bridge::GetManagementObject (void) const
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Thu Apr 24 14:07:34 2008
@@ -131,8 +131,7 @@
store(0),
dataDir(conf.noDataDir ? std::string () : conf.dataDir),
factory(*this),
- sessionManager(conf.ack),
- previewSessionManager(conf.ack)
+ sessionManager(conf.ack)
{
if(conf.enableMgmt){
QPID_LOG(info, "Management enabled");
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h Thu Apr 24 14:07:34 2008
@@ -30,7 +30,6 @@
#include "MessageStore.h"
#include "QueueRegistry.h"
#include "SessionManager.h"
-#include "PreviewSessionManager.h"
#include "Vhost.h"
#include "System.h"
#include "qpid/management/Manageable.h"
@@ -117,7 +116,6 @@
Options& getOptions() { return config; }
SessionManager& getSessionManager() { return sessionManager; }
- PreviewSessionManager& getPreviewSessionManager() { return previewSessionManager; }
management::ManagementObject::shared_ptr GetManagementObject (void) const;
management::Manageable* GetVhostObject (void) const;
@@ -148,7 +146,6 @@
ConnectionFactory factory;
DtxManager dtxManager;
SessionManager sessionManager;
- PreviewSessionManager previewSessionManager;
management::ManagementAgent::shared_ptr managementAgent;
management::Broker::shared_ptr mgmtObject;
Vhost::shared_ptr vhostObject;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp Thu Apr 24 14:07:34 2008
@@ -20,9 +20,7 @@
*/
#include "Connection.h"
#include "SessionState.h"
-#include "BrokerAdapter.h"
#include "Bridge.h"
-#include "SemanticHandler.h"
#include "qpid/log/Statement.h"
#include "qpid/ptr_map.h"
@@ -143,7 +141,7 @@
void Connection::closed(){ // Physically closed, suspend open sessions.
try {
for (ChannelMap::iterator i = channels.begin(); i != channels.end(); ++i)
- ptr_map_ptr(i)->localSuspend();
+ ptr_map_ptr(i)->handleDetach();
while (!exclusiveQueues.empty()) {
Queue::shared_ptr q(exclusiveQueues.front());
q->releaseExclusiveOwnership();
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionFactory.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionFactory.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionFactory.cpp Thu Apr 24 14:07:34 2008
@@ -21,7 +21,6 @@
#include "ConnectionFactory.h"
#include "qpid/framing/ProtocolVersion.h"
#include "qpid/amqp_0_10/Connection.h"
-#include "PreviewConnectionCodec.h"
namespace qpid {
namespace broker {
@@ -34,8 +33,6 @@
sys::ConnectionCodec*
ConnectionFactory::create(ProtocolVersion v, sys::OutputControl& out, const std::string& id) {
- if (v == ProtocolVersion(99, 0))
- return new PreviewConnectionCodec(out, broker, id);
if (v == ProtocolVersion(0, 10))
return new amqp_0_10::Connection(out, broker, id);
return 0;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.cpp Thu Apr 24 14:07:34 2008
@@ -50,9 +50,9 @@
try{
bool handled = false;
if (handler->serverMode) {
- handled = invoke(static_cast<AMQP_ServerOperations::Connection010Handler&>(*handler.get()), *method);
+ handled = invoke(static_cast<AMQP_ServerOperations::ConnectionHandler&>(*handler.get()), *method);
} else {
- handled = invoke(static_cast<AMQP_ClientOperations::Connection010Handler&>(*handler.get()), *method);
+ handled = invoke(static_cast<AMQP_ClientOperations::ConnectionHandler&>(*handler.get()), *method);
}
if (!handled) {
handler->connection.getChannel(frame.getChannel()).in(frame);
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.h?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/ConnectionHandler.h Thu Apr 24 14:07:34 2008
@@ -41,11 +41,11 @@
class ConnectionHandler : public framing::FrameHandler
{
- struct Handler : public framing::AMQP_ServerOperations::Connection010Handler,
- public framing::AMQP_ClientOperations::Connection010Handler
+ struct Handler : public framing::AMQP_ServerOperations::ConnectionHandler,
+ public framing::AMQP_ClientOperations::ConnectionHandler
{
- framing::AMQP_ClientProxy::Connection010 client;
- framing::AMQP_ServerProxy::Connection010 server;
+ framing::AMQP_ClientProxy::Connection client;
+ framing::AMQP_ServerProxy::Connection server;
Connection& connection;
bool serverMode;
std::auto_ptr<SaslAuthenticator> authenticator;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp Thu Apr 24 14:07:34 2008
@@ -24,7 +24,6 @@
#include "qpid/framing/frame_functors.h"
#include "qpid/framing/FieldTable.h"
#include "qpid/framing/MessageTransferBody.h"
-#include "qpid/framing/MessageXTransferBody.h"
#include "qpid/framing/SendContent.h"
#include "qpid/framing/SequenceNumber.h"
#include "qpid/framing/TypeFilter.h"
@@ -36,7 +35,6 @@
using std::string;
TransferAdapter Message::TRANSFER;
-PreviewAdapter Message::TRANSFER_99_0;
Message::Message(const SequenceNumber& id) : frames(id), persistenceId(0), redelivered(false), loaded(false), staged(false), publisher(0), adapter(0) {}
@@ -225,9 +223,7 @@
MessageAdapter& Message::getAdapter() const
{
if (!adapter) {
- if(frames.isA<MessageXTransferBody>()) {
- adapter = &TRANSFER_99_0;
- } else if(frames.isA<MessageTransferBody>()) {
+ if(frames.isA<MessageTransferBody>()) {
adapter = &TRANSFER;
} else {
const AMQMethodBody* method = frames.getMethod();
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h Thu Apr 24 14:07:34 2008
@@ -136,7 +136,6 @@
mutable MessageAdapter* adapter;
static TransferAdapter TRANSFER;
- static PreviewAdapter TRANSFER_99_0;
MessageAdapter& getAdapter() const;
};
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageAdapter.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageAdapter.cpp?rev=651423&r1=651422&r2=651423&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageAdapter.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageAdapter.cpp Thu Apr 24 14:07:34 2008
@@ -24,7 +24,6 @@
#include "qpid/framing/DeliveryProperties.h"
#include "qpid/framing/MessageProperties.h"
#include "qpid/framing/MessageTransferBody.h"
-#include "qpid/framing/MessageXTransferBody.h"
namespace {
const std::string empty;
@@ -66,29 +65,6 @@
{
const framing::MessageTransferBody* b = f.as<framing::MessageTransferBody>();
return b && b->getAcceptMode() == 0/*EXPLICIT == 0*/;
- }
-
- std::string PreviewAdapter::getExchange(const framing::FrameSet& f)
- {
- return f.as<framing::MessageXTransferBody>()->getDestination();
- }
-
- std::string PreviewAdapter::getRoutingKey(const framing::FrameSet& f)
- {
- const framing::PreviewDeliveryProperties* p = f.getHeaders()->get<framing::PreviewDeliveryProperties>();
- return p ? p->getRoutingKey() : empty;
- }
-
- const framing::FieldTable* PreviewAdapter::getApplicationHeaders(const framing::FrameSet& f)
- {
- const framing::PreviewMessageProperties* p = f.getHeaders()->get<framing::PreviewMessageProperties>();
- return p ? &(p->getApplicationHeaders()) : 0;
- }
-
- bool PreviewAdapter::isPersistent(const framing::FrameSet& f)
- {
- const framing::PreviewDeliveryProperties* p = f.getHeaders()->get<framing::PreviewDeliveryProperties>();
- return p && p->getDeliveryMode() == 2;
}
}}