diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-02-07 14:26:23 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-02-07 14:26:23 +0000 |
commit | 3d5721d40940b2361d0708b81c390f490e5e06b3 (patch) | |
tree | 0c82879298a1b197c85a885332849d4c2072bda8 /cpp | |
parent | Fixed windows build of custom AMD server (diff) | |
download | ice-3d5721d40940b2361d0708b81c390f490e5e06b3.tar.bz2 ice-3d5721d40940b2361d0708b81c390f490e5e06b3.tar.xz ice-3d5721d40940b2361d0708b81c390f490e5e06b3.zip |
Fixed sequences of classes
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/BasicStream.h | 21 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 20 | ||||
-rw-r--r-- | cpp/test/Ice/custom/AllTests.cpp | 132 | ||||
-rw-r--r-- | cpp/test/Ice/custom/Test.ice | 12 | ||||
-rw-r--r-- | cpp/test/Ice/custom/TestAMD.ice | 12 | ||||
-rw-r--r-- | cpp/test/Ice/custom/TestAMDI.cpp | 18 | ||||
-rw-r--r-- | cpp/test/Ice/custom/TestAMDI.h | 8 | ||||
-rw-r--r-- | cpp/test/Ice/custom/TestI.cpp | 18 | ||||
-rw-r--r-- | cpp/test/Ice/custom/TestI.h | 8 |
9 files changed, 249 insertions, 0 deletions
diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index 1a8be26512f..efd7944e17f 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -515,6 +515,27 @@ readSequence5(::IceInternal::BasicStream* __is, T& seq, void (*func)(::IceIntern } } +// Sequences of Classes +template<typename T> void +readSequence6(::IceInternal::BasicStream* __is, T& seq, int elemSize, void (*func)(void*, ::Ice::ObjectPtr&)) +{ + ::Ice::Int size; + __is->readSize(size); + T(size).swap(seq); + if(size > 0) + { + __is->startSeq(size, elemSize); + typedef typename T::iterator I; + for(I p = seq.begin(); p != seq.end(); ++p) + { + __is->read(*func, &(*p)); + __is->checkSeq(); + __is->endElement(); + } + __is->endSeq(size); + } +} + } // End namespace IceInternal #endif diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 841e26d48ad..a3ec06913c4 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -730,9 +730,19 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& << typeToString(innerProxy) << ">(" << stream << ", " << fixedParam << ", " << innerScope << "__write);"; return; + } + ClassDeclPtr innerClass = ClassDeclPtr::dynamicCast(seq->type()); + if(innerClass) + { + string innerScope = fixKwd(innerClass->scope()); + out << nl << "::IceInternal::writeSequence7<" << typeStr << ", " + << typeToString(innerClass) << ">(" << stream << ", " << fixedParam << ", " + << innerScope << "__write);"; + return; } + out << nl << "::IceInternal::writeSequence2<" << typeStr << ">(" << stream << ", " << fixedParam << ");"; } @@ -926,6 +936,16 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& return; } + ClassDeclPtr innerClass = ClassDeclPtr::dynamicCast(seq->type()); + if(innerClass) + { + string innerScope = fixKwd(innerClass->scope()); + out << nl << "::IceInternal::readSequence6<" << typeStr << ">(" << stream << ", " + << fixedParam << ", " << innerClass->minWireSize() << ", " + << innerScope << "__patch__" << innerClass->name() << "Ptr);"; + return; + } + TypePtr elemType = seq->type(); out << nl << "::IceInternal::readSequence2<" << typeStr << ">(" << stream << ", " << fixedParam << ", " << elemType->minWireSize() << ", " diff --git a/cpp/test/Ice/custom/AllTests.cpp b/cpp/test/Ice/custom/AllTests.cpp index 3c16807e646..fd9e3fea43c 100644 --- a/cpp/test/Ice/custom/AllTests.cpp +++ b/cpp/test/Ice/custom/AllTests.cpp @@ -786,6 +786,73 @@ private: typedef IceUtil::Handle<AMI_TestIntf_opCPrxListI> AMI_TestIntf_opCPrxListIPtr; +class AMI_TestIntf_opCSeqI : public Test::AMI_TestIntf_opCSeq, public CallbackBase +{ +public: + + AMI_TestIntf_opCSeqI(deque<Test::CPtr> in) + : _in(in) + { + } + + virtual void ice_response(const deque<Test::CPtr>& out, const deque<Test::CPtr>& ret) + { + test(out.size() == _in.size()); + test(ret.size() == _in.size()); + for(unsigned int i = 1; i < _in.size(); ++i) + { + test(out[i] == out[0]); + test(ret[i] == out[i]); + } + called(); + } + + virtual void ice_exception(const ::Ice::Exception&) + { + test(false); + } + +private: + + deque<Test::CPtr> _in; +}; + +typedef IceUtil::Handle<AMI_TestIntf_opCSeqI> AMI_TestIntf_opCSeqIPtr; + +class AMI_TestIntf_opCListI : public Test::AMI_TestIntf_opCList, public CallbackBase +{ +public: + + AMI_TestIntf_opCListI(list<Test::CPtr> in) + : _in(in) + { + } + + virtual void ice_response(const list<Test::CPtr>& out, const list<Test::CPtr>& ret) + { + test(out.size() == _in.size()); + test(ret.size() == _in.size()); + list<Test::CPtr>::const_iterator p1; + list<Test::CPtr>::const_iterator p2; + for(p1 = out.begin(), p2 = ret.begin(); p1 != out.end(); ++p1, ++p2) + { + test(*p1 == *p2); + } + called(); + } + + virtual void ice_exception(const ::Ice::Exception&) + { + test(false); + } + +private: + + list<Test::CPtr> _in; +}; + +typedef IceUtil::Handle<AMI_TestIntf_opCListI> AMI_TestIntf_opCListIPtr; + Test::TestIntfPrx allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { @@ -1233,6 +1300,45 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(ret == in); } + { + deque<Test::CPtr> in(5); + in[0] = new Test::C(); + in[1] = in[0]; + in[2] = in[0]; + in[3] = in[0]; + in[4] = in[0]; + + deque<Test::CPtr> out; + deque<Test::CPtr> ret = t->opCSeq(in, out); + test(out.size() == in.size()); + test(ret.size() == in.size()); + for(unsigned int i = 1; i < in.size(); ++i) + { + test(out[i] == out[0]); + test(ret[i] == out[i]); + } + } + + { + list<Test::CPtr> in; + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + + list<Test::CPtr> out; + list<Test::CPtr> ret = t->opCList(in, out); + test(out.size() == in.size()); + test(ret.size() == in.size()); + list<Test::CPtr>::const_iterator p1; + list<Test::CPtr>::const_iterator p2; + for(p1 = out.begin(), p2 = ret.begin(); p1 != out.end(); ++p1, ++p2) + { + test(*p1 == *p2); + } + } + cout << "ok" << endl; if(!collocated) @@ -1642,6 +1748,32 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) test(cb->check()); } + { + deque<Test::CPtr> in(5); + in[0] = new Test::C(); + in[1] = in[0]; + in[2] = in[0]; + in[3] = in[0]; + in[4] = in[0]; + + AMI_TestIntf_opCSeqIPtr cb = new AMI_TestIntf_opCSeqI(in); + t->opCSeq_async(cb, in); + test(cb->check()); + } + + { + list<Test::CPtr> in; + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + + AMI_TestIntf_opCListIPtr cb = new AMI_TestIntf_opCListI(in); + t->opCList_async(cb, in); + test(cb->check()); + } + cout << "ok" << endl; } diff --git a/cpp/test/Ice/custom/Test.ice b/cpp/test/Ice/custom/Test.ice index 14057ccd09c..d2a6193cc3f 100644 --- a/cpp/test/Ice/custom/Test.ice +++ b/cpp/test/Ice/custom/Test.ice @@ -77,6 +77,13 @@ sequence<EList> EListSeq; ["cpp:type:std::list< ::Test::ESeq>"] sequence<ESeq> ESeqList; class C {}; +sequence<C> CSeq; +["cpp:type:std::list< ::Test::CPtr>"] sequence<C> CList; + +["cpp:type:std::list< ::Test::CList>"] sequence<CList> CListList; +sequence<CList> CListSeq; +["cpp:type:std::list< ::Test::CSeq>"] sequence<CSeq> CSeqList; + sequence<C*> CPrxSeq; ["cpp:type:std::list< ::Test::CPrx>"] sequence<C*> CPrxList; @@ -154,6 +161,11 @@ sequence<CPrxList> CPrxListSeq; CPrxList opCPrxList(CPrxList inSeq, out CPrxList outSeq); + ["cpp:type:std::deque< ::Test::CPtr>"] CSeq + opCSeq(["cpp:type:std::deque< ::Test::CPtr>"] CSeq inSeq, out ["cpp:type:std::deque< ::Test::CPtr>"] CSeq outSeq); + + CList opCList(CList inSeq, out CList outSeq); + void shutdown(); }; diff --git a/cpp/test/Ice/custom/TestAMD.ice b/cpp/test/Ice/custom/TestAMD.ice index 17e58a43188..848ea5b4b44 100644 --- a/cpp/test/Ice/custom/TestAMD.ice +++ b/cpp/test/Ice/custom/TestAMD.ice @@ -77,6 +77,13 @@ sequence<EList> EListSeq; ["cpp:type:std::list< ::Test::ESeq>"] sequence<ESeq> ESeqList; class C {}; +sequence<C> CSeq; +["cpp:type:std::list< ::Test::CPtr>"] sequence<C> CList; + +["cpp:type:std::list< ::Test::CList>"] sequence<CList> CListList; +sequence<CList> CListSeq; +["cpp:type:std::list< ::Test::CSeq>"] sequence<CSeq> CSeqList; + sequence<C*> CPrxSeq; ["cpp:type:std::list< ::Test::CPrx>"] sequence<C*> CPrxList; @@ -154,6 +161,11 @@ sequence<CPrxList> CPrxListSeq; CPrxList opCPrxList(CPrxList inSeq, out CPrxList outSeq); + ["cpp:type:std::deque< ::Test::CPtr>"] CSeq + opCSeq(["cpp:type:std::deque< ::Test::CPtr>"] CSeq inSeq, out ["cpp:type:std::deque< ::Test::CPtr>"] CSeq outSeq); + + CList opCList(CList inSeq, out CList outSeq); + void shutdown(); }; diff --git a/cpp/test/Ice/custom/TestAMDI.cpp b/cpp/test/Ice/custom/TestAMDI.cpp index de79699ce97..9df910944a7 100644 --- a/cpp/test/Ice/custom/TestAMDI.cpp +++ b/cpp/test/Ice/custom/TestAMDI.cpp @@ -255,6 +255,24 @@ TestIntfI::opCPrxList_async(const Test::AMD_TestIntf_opCPrxListPtr& opCPrxListCB } void +TestIntfI::opCSeq_async(const Test::AMD_TestIntf_opCSeqPtr& opCSeqCB, + const std::deque<Test::CPtr>& inSeq, + const Ice::Current& current) +{ + std::deque<Test::CPtr> outSeq(inSeq); + opCSeqCB->ice_response(outSeq, outSeq); +} + +void +TestIntfI::opCList_async(const Test::AMD_TestIntf_opCListPtr& opCListCB, + const Test::CList& inSeq, + const Ice::Current& current) +{ + Test::CList outSeq(inSeq); + opCListCB->ice_response(outSeq, outSeq); +} + +void TestIntfI::shutdown_async(const Test::AMD_TestIntf_shutdownPtr& shutdownCB, const Ice::Current& current) { diff --git a/cpp/test/Ice/custom/TestAMDI.h b/cpp/test/Ice/custom/TestAMDI.h index f4d87fd55fa..a6cccb1ac1a 100644 --- a/cpp/test/Ice/custom/TestAMDI.h +++ b/cpp/test/Ice/custom/TestAMDI.h @@ -124,6 +124,14 @@ public: const Test::CPrxList&, const Ice::Current&); + virtual void opCSeq_async(const Test::AMD_TestIntf_opCSeqPtr&, + const std::deque<Test::CPtr>&, + const Ice::Current&); + + virtual void opCList_async(const Test::AMD_TestIntf_opCListPtr&, + const Test::CList&, + const Ice::Current&); + virtual void shutdown_async(const Test::AMD_TestIntf_shutdownPtr&, const Ice::Current&); diff --git a/cpp/test/Ice/custom/TestI.cpp b/cpp/test/Ice/custom/TestI.cpp index f0620b39043..ab63e70cab5 100644 --- a/cpp/test/Ice/custom/TestI.cpp +++ b/cpp/test/Ice/custom/TestI.cpp @@ -254,6 +254,24 @@ TestIntfI::opCPrxList(const std::list< ::Test::CPrx>& inSeq, return inSeq; } +std::deque< ::Test::CPtr> +TestIntfI::opCSeq(const std::deque< ::Test::CPtr>& inSeq, + std::deque< ::Test::CPtr>& outSeq, + const Ice::Current& current) +{ + outSeq = inSeq; + return inSeq; +} + +std::list< ::Test::CPtr> +TestIntfI::opCList(const std::list< ::Test::CPtr>& inSeq, + std::list< ::Test::CPtr>& outSeq, + const Ice::Current& current) +{ + outSeq = inSeq; + return inSeq; +} + void TestIntfI::shutdown(const Ice::Current& current) { diff --git a/cpp/test/Ice/custom/TestI.h b/cpp/test/Ice/custom/TestI.h index 667307101b5..214d2ca0d37 100644 --- a/cpp/test/Ice/custom/TestI.h +++ b/cpp/test/Ice/custom/TestI.h @@ -125,6 +125,14 @@ public: std::list< ::Test::CPrx>&, const Ice::Current&); + virtual std::deque< ::Test::CPtr> opCSeq(const std::deque< ::Test::CPtr>&, + std::deque< ::Test::CPtr>&, + const Ice::Current&); + + virtual std::list< ::Test::CPtr> opCList(const std::list< ::Test::CPtr>&, + std::list< ::Test::CPtr>&, + const Ice::Current&); + virtual void shutdown(const Ice::Current&); private: |