diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-07-19 12:16:43 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-07-19 12:16:43 -0400 |
commit | e16efc6d8f2abe2036a601c2695fd65bd9134246 (patch) | |
tree | 2af5e70e8b24e3596f14edec12cd249e8f056720 /cpp | |
parent | ICE-7240 - Python Ice/servantLocator cross test (diff) | |
download | ice-e16efc6d8f2abe2036a601c2695fd65bd9134246.tar.bz2 ice-e16efc6d8f2abe2036a601c2695fd65bd9134246.tar.xz ice-e16efc6d8f2abe2036a601c2695fd65bd9134246.zip |
C++11 support in test/Ice/echo
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/config/Make.rules | 3 | ||||
-rw-r--r-- | cpp/msbuild/ice.test.sln | 4 | ||||
-rw-r--r-- | cpp/test/Ice/echo/BlobjectI.cpp | 55 | ||||
-rw-r--r-- | cpp/test/Ice/echo/BlobjectI.h | 14 | ||||
-rw-r--r-- | cpp/test/Ice/echo/Server.cpp | 4 |
5 files changed, 74 insertions, 6 deletions
diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index 933f2064fd3..bdd10c344b7 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -67,8 +67,7 @@ cpp11_projects = test/Common \ test/IceBox/% cpp11_excludes = IcePatch2 \ - test/Ice/gc \ - test/Ice/echo + test/Ice/gc # # If building on a Linux multilib platform, we restrict what we build for diff --git a/cpp/msbuild/ice.test.sln b/cpp/msbuild/ice.test.sln index a31068e48f6..8acc3f9556d 100644 --- a/cpp/msbuild/ice.test.sln +++ b/cpp/msbuild/ice.test.sln @@ -1447,9 +1447,13 @@ Global {3E471DF3-EB57-4FC3-AF20-2CF548DBF5C1}.Release|x64.ActiveCfg = Release|x64 {3E471DF3-EB57-4FC3-AF20-2CF548DBF5C1}.Release|x64.Build.0 = Release|x64 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32 + {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Debug|Win32.Build.0 = Cpp11-Debug|Win32 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64 + {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Debug|x64.Build.0 = Cpp11-Debug|x64 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32 + {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Release|Win32.Build.0 = Cpp11-Release|Win32 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64 + {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Cpp11-Release|x64.Build.0 = Cpp11-Release|x64 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Debug|Win32.ActiveCfg = Debug|Win32 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Debug|Win32.Build.0 = Debug|Win32 {5F22AF4C-5DFE-43E9-98E6-64187F174761}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/cpp/test/Ice/echo/BlobjectI.cpp b/cpp/test/Ice/echo/BlobjectI.cpp index 2d86e66f276..984236d0f15 100644 --- a/cpp/test/Ice/echo/BlobjectI.cpp +++ b/cpp/test/Ice/echo/BlobjectI.cpp @@ -12,6 +12,7 @@ using namespace std; +#ifndef ICE_CPP11_MAPPING class Callback : public IceUtil::Shared { public: @@ -45,6 +46,7 @@ private: bool _twoway; }; typedef IceUtil::Handle<Callback> CallbackPtr; +#endif BlobjectI::BlobjectI() : _startBatch(false) @@ -66,6 +68,58 @@ BlobjectI::flushBatch() _batchProxy = 0; } +#ifdef ICE_CPP11_MAPPING +void +BlobjectI::ice_invokeAsync(std::vector<Ice::Byte> inEncaps, + std::function<void(bool, std::vector<Ice::Byte>)> response, + std::function<void(std::exception_ptr)> ex, + const Ice::Current& current) +{ + const bool twoway = current.requestId > 0; + auto obj = current.con->createProxy(current.id); + if(!twoway) + { + if(_startBatch) + { + _startBatch = false; + _batchProxy = obj->ice_batchOneway(); + } + if(_batchProxy) + { + obj = _batchProxy; + } + + if(!current.facet.empty()) + { + obj = obj->ice_facet(current.facet); + } + + if(_batchProxy) + { + vector<Ice::Byte> out; + obj->ice_invoke(current.operation, current.mode, inEncaps, out, current.ctx); + response(true, vector<Ice::Byte>()); + } + else + { + obj->ice_oneway()->ice_invokeAsync(current.operation, current.mode, inEncaps, + [](bool, std::vector<Ice::Byte>) { assert(0); }, + ex, + [&](bool) { response(true, vector<Ice::Byte>()); }, + current.ctx); + } + } + else + { + if(!current.facet.empty()) + { + obj = obj->ice_facet(current.facet); + } + + obj->ice_invokeAsync(current.operation, current.mode, inEncaps, response, ex, nullptr, current.ctx); + } +} +#else void BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCb, const vector<Ice::Byte>& inEncaps, const Ice::Current& current) @@ -116,3 +170,4 @@ BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCb, const ve obj->begin_ice_invoke(current.operation, current.mode, inEncaps, current.ctx, del); } } +#endif diff --git a/cpp/test/Ice/echo/BlobjectI.h b/cpp/test/Ice/echo/BlobjectI.h index 27a48791380..6f1956adf09 100644 --- a/cpp/test/Ice/echo/BlobjectI.h +++ b/cpp/test/Ice/echo/BlobjectI.h @@ -21,14 +21,24 @@ public: void startBatch(); void flushBatch(); +#ifdef ICE_CPP11_MAPPING + + virtual void ice_invokeAsync(std::vector<Ice::Byte>, + std::function<void(bool, std::vector<Ice::Byte>)>, + std::function<void(std::exception_ptr)>, + const Ice::Current&) override; + +#else virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const std::vector<Ice::Byte>&, const Ice::Current&); +#endif private: bool _startBatch; - Ice::ObjectPrx _batchProxy; + Ice::ObjectPrxPtr _batchProxy; }; -typedef IceUtil::Handle<BlobjectI> BlobjectIPtr; + +ICE_DEFINE_PTR(BlobjectIPtr, BlobjectI); #endif diff --git a/cpp/test/Ice/echo/Server.cpp b/cpp/test/Ice/echo/Server.cpp index 09ccc437c0d..e1d56838839 100644 --- a/cpp/test/Ice/echo/Server.cpp +++ b/cpp/test/Ice/echo/Server.cpp @@ -50,9 +50,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0)); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - BlobjectIPtr blob = new BlobjectI; + BlobjectIPtr blob = ICE_MAKE_SHARED(BlobjectI); adapter->addDefaultServant(blob, ""); - adapter->add(new EchoI(blob), communicator->stringToIdentity("__echo")); + adapter->add(ICE_MAKE_SHARED(EchoI, blob), communicator->stringToIdentity("__echo")); adapter->activate(); TEST_READY |