diff options
author | Gordon Sim <gsim@apache.org> | 2007-09-06 20:27:33 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2007-09-06 20:27:33 +0000 |
commit | b33a63b36c659a894143382d0a61efe6a598fcc6 (patch) | |
tree | 0efc848ae9cc6064d615c6968b1d127e92b231d3 /cpp/rubygen | |
parent | 748698e4b8d5bd0c3ccec4ca898d334c13fc0795 (diff) | |
download | qpid-python-b33a63b36c659a894143382d0a61efe6a598fcc6.tar.gz |
Implementation of execution.result on the client side
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@573359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen')
-rw-r--r-- | cpp/rubygen/templates/Session.rb | 64 | ||||
-rw-r--r-- | cpp/rubygen/templates/structs.rb | 12 |
2 files changed, 39 insertions, 37 deletions
diff --git a/cpp/rubygen/templates/Session.rb b/cpp/rubygen/templates/Session.rb index 95b10c6dbf..4cea9f9665 100644 --- a/cpp/rubygen/templates/Session.rb +++ b/cpp/rubygen/templates/Session.rb @@ -12,8 +12,18 @@ class SessionGen < CppGen @classname="Session" end + def return_type(m) + if (m.result) + return "TypedResult<qpid::framing::#{m.result.cpptype.ret}>" + elsif (not m.responses().empty?) + return "Response" + else + return "Completion" + end + end + def declare_method (m) - gen "Response #{m.parent.name.lcaps}#{m.name.caps}(" + gen "#{return_type(m)} #{m.parent.name.lcaps}#{m.name.caps}(" if (m.content()) params=m.signature + ["const MethodContent& content"] else @@ -28,7 +38,7 @@ class SessionGen < CppGen end def define_method (m) - gen "Response Session::#{m.parent.name.lcaps}#{m.name.caps}(" + gen "#{return_type(m)} Session::#{m.parent.name.lcaps}#{m.name.caps}(" if (m.content()) params=m.signature + ["const MethodContent& content"] else @@ -37,19 +47,15 @@ class SessionGen < CppGen indent { gen params.join(",\n") } gen "){\n\n" indent (2) { - gen "return impl->send(#{m.body_name}(" + gen "return #{return_type(m)}(impl()->send(#{m.body_name}(" params = ["version"] + m.param_names gen params.join(", ") other_params=[] if (m.content()) - other_params << "content" + gen "), content), impl());\n" + else + gen ")), impl());\n" end - if m.responses().empty? - other_params << "false" - else - other_params << "true" - end - gen "), #{other_params.join(", ")});\n" } gen "}\n\n" end @@ -65,11 +71,13 @@ class SessionGen < CppGen gen <<EOS #include <sstream> #include "qpid/framing/amqp_framing.h" +#include "qpid/framing/amqp_structs.h" #include "qpid/framing/ProtocolVersion.h" #include "qpid/framing/MethodContent.h" #include "qpid/client/ConnectionImpl.h" #include "qpid/client/Response.h" -#include "qpid/client/SessionCore.h" +#include "qpid/client/ScopedAssociation.h" +#include "qpid/client/TypedResult.h" namespace qpid { namespace client { @@ -81,16 +89,20 @@ using framing::MethodContent; using framing::SequenceNumberSet; class #{@classname} { - ConnectionImpl::shared_ptr parent; - SessionCore::shared_ptr impl; + ScopedAssociation::shared_ptr assoc; framing::ProtocolVersion version; + + SessionCore::shared_ptr impl(); + public: - #{@classname}(ConnectionImpl::shared_ptr, SessionCore::shared_ptr); - ~#{@classname}(); + #{@classname}(); + #{@classname}(ScopedAssociation::shared_ptr); - framing::FrameSet::shared_ptr get() { return impl->get(); } - void setSynchronous(bool sync) { impl->setSync(sync); } + framing::FrameSet::shared_ptr get() { return impl()->get(); } + void setSynchronous(bool sync) { impl()->setSync(sync); } void close(); + Execution& execution() { return impl()->getExecution(); } + EOS indent { @amqp.classes.each { |c| declare_class(c) if !excludes.include?(c.name) } } gen <<EOS @@ -112,24 +124,18 @@ using namespace qpid::framing; namespace qpid { namespace client { -#{@classname}::#{@classname}(ConnectionImpl::shared_ptr _parent, SessionCore::shared_ptr _impl) : parent(_parent), impl(_impl) {} +#{@classname}::#{@classname}() {} +#{@classname}::#{@classname}(ScopedAssociation::shared_ptr _assoc) : assoc(_assoc) {} -#{@classname}::~#{@classname}() +SessionCore::shared_ptr #{@classname}::impl() { - impl->stop(); - if (parent) { - parent->released(impl); - parent.reset(); - } + if (!assoc) throw Exception("Uninitialised session"); + return assoc->session; } void #{@classname}::close() { - impl->close(); - if (parent) { - parent->released(impl); - parent.reset(); - } + impl()->close(); } EOS diff --git a/cpp/rubygen/templates/structs.rb b/cpp/rubygen/templates/structs.rb index fd949eb53d..363fe4ec35 100644 --- a/cpp/rubygen/templates/structs.rb +++ b/cpp/rubygen/templates/structs.rb @@ -117,19 +117,15 @@ class StructGen < CppGen end def methodbody_extra_defs(s) - if (s.content) - content = "true" - else - content = "false" - end - gen <<EOS using AMQMethodBody::accept; void accept(MethodBodyConstVisitor& v) const { v.visit(*this); } inline ClassId amqpClassId() const { return CLASS_ID; } inline MethodId amqpMethodId() const { return METHOD_ID; } - inline bool isContentBearing() const { return #{content}; } + inline bool isContentBearing() const { return #{s.content ? "true" : "false" }; } + inline bool resultExpected() const { return #{s.result ? "true" : "false"}; } + inline bool responseExpected() const { return #{s.responses().empty? ? "false" : "true"}; } EOS end @@ -201,7 +197,7 @@ EOS #as result structs have types that are only unique to the #class, they have a class dependent qualifier added to them #(this is inline with current python code but a formal - #solution is expected from the WG + #solution is expected from the WG) indent { genl "static const uint16_t TYPE = #{s.type_} + #{s.parent.parent.parent.index} * 256;" } else indent { genl "static const uint16_t TYPE = #{s.type_};" } |