From ac11461bb5f8a0a558b55f57b4c14d331cb1f999 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 18 Mar 2024 23:00:45 -0400 Subject: [PATCH 1/8] Initial refactoring --- .vscode/settings.json | 4 +- config/Make.rules.Darwin | 2 +- cpp/include/Ice/AsyncResponseHandler.h | 2 +- cpp/include/Ice/InputStream.h | 8 +-- cpp/include/Ice/Object.h | 2 +- cpp/include/Ice/OutgoingResponse.h | 2 +- cpp/include/Ice/OutputStream.h | 2 +- cpp/include/Ice/Proxy.h | 6 +-- cpp/include/Ice/StreamHelpers.h | 22 ++++++++- cpp/src/Glacier2/Blobject.cpp | 4 +- cpp/src/Glacier2/Blobject.h | 4 +- cpp/src/Glacier2/ClientBlobject.cpp | 2 +- cpp/src/Glacier2/ClientBlobject.h | 2 +- cpp/src/Glacier2/RequestQueue.cpp | 10 ++-- cpp/src/Glacier2/RequestQueue.h | 8 +-- cpp/src/Glacier2/ServerBlobject.cpp | 2 +- cpp/src/Glacier2/ServerBlobject.h | 2 +- cpp/src/Ice/InputStream.cpp | 8 +-- cpp/src/Ice/Object.cpp | 2 +- cpp/src/Ice/OutgoingResponse.cpp | 2 +- cpp/src/Ice/OutputStream.cpp | 2 +- cpp/src/Ice/ProxyAsync.cpp | 8 +-- cpp/src/IceBridge/IceBridge.cpp | 16 +++--- cpp/src/IceGrid/AdminCallbackRouter.cpp | 2 +- cpp/src/IceGrid/AdminCallbackRouter.h | 2 +- cpp/src/IceGrid/AdminRouter.cpp | 4 +- cpp/src/IceGrid/AdminRouter.h | 4 +- cpp/src/IceGrid/AdminSessionI.cpp | 2 +- cpp/src/IceGrid/NodeAdminRouter.cpp | 2 +- cpp/src/IceGrid/NodeAdminRouter.h | 2 +- cpp/src/IceGrid/RegistryAdminRouter.cpp | 12 ++--- cpp/src/IceGrid/RegistryAdminRouter.h | 6 +-- cpp/src/IceLocatorDiscovery/PluginI.cpp | 14 +++--- cpp/src/IcePatch2/FileServerI.cpp | 2 +- cpp/src/IcePatch2/FileServerI.h | 4 +- cpp/src/slice2cpp/CPlusPlusUtil.cpp | 49 ++++++++++++++++-- cpp/test/Ice/custom/TestAMDI.cpp | 4 +- cpp/test/Ice/custom/TestAMDI.h | 7 ++- cpp/test/Ice/invoke/BlobjectI.cpp | 2 +- cpp/test/Ice/invoke/BlobjectI.h | 2 +- cpp/test/Ice/optional/TestAMDI.cpp | 32 ++++++------ cpp/test/Ice/optional/TestAMDI.h | 44 ++++++++--------- cpp/test/Ice/span/AllTests.cpp | 35 +++++++++++++ cpp/test/Ice/span/Client.cpp | 26 ++++++++++ cpp/test/Ice/span/Collocated.cpp | 28 +++++++++++ cpp/test/Ice/span/Makefile.mk | 7 +++ cpp/test/Ice/span/Server.cpp | 29 +++++++++++ cpp/test/Ice/span/ServerAMD.cpp | 30 +++++++++++ cpp/test/Ice/span/Test.ice | 35 +++++++++++++ cpp/test/Ice/span/TestAMD.ice | 36 ++++++++++++++ cpp/test/Ice/span/TestAMDI.cpp | 66 +++++++++++++++++++++++++ cpp/test/Ice/span/TestAMDI.h | 43 ++++++++++++++++ cpp/test/Ice/span/TestI.cpp | 50 +++++++++++++++++++ cpp/test/Ice/span/TestI.h | 24 +++++++++ php/src/Operation.cpp | 8 +-- python/modules/IcePy/Operation.cpp | 56 ++++++++++----------- swift/src/IceImpl/BlobjectFacade.h | 2 +- swift/src/IceImpl/BlobjectFacade.mm | 2 +- 58 files changed, 634 insertions(+), 161 deletions(-) create mode 100644 cpp/test/Ice/span/AllTests.cpp create mode 100644 cpp/test/Ice/span/Client.cpp create mode 100644 cpp/test/Ice/span/Collocated.cpp create mode 100644 cpp/test/Ice/span/Makefile.mk create mode 100644 cpp/test/Ice/span/Server.cpp create mode 100644 cpp/test/Ice/span/ServerAMD.cpp create mode 100644 cpp/test/Ice/span/Test.ice create mode 100644 cpp/test/Ice/span/TestAMD.ice create mode 100644 cpp/test/Ice/span/TestAMDI.cpp create mode 100644 cpp/test/Ice/span/TestAMDI.h create mode 100644 cpp/test/Ice/span/TestI.cpp create mode 100644 cpp/test/Ice/span/TestI.h diff --git a/.vscode/settings.json b/.vscode/settings.json index a6f94d752d1..97131cdc0ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -76,10 +76,12 @@ "xtree": "cpp", "execution": "cpp", "type_traits": "cpp", - "cassert": "cpp" + "cassert": "cpp", + "span": "cpp" }, "C_Cpp.default.cppStandard": "c++20", "cSpell.words": [ + "unmarshal", "unmarshaling" ], } diff --git a/config/Make.rules.Darwin b/config/Make.rules.Darwin index ab6a8b40474..a0948603564 100644 --- a/config/Make.rules.Darwin +++ b/config/Make.rules.Darwin @@ -46,7 +46,7 @@ clang_version = $(shell clang -dumpversion 2>&1 | cut -f1 -d\.) # We use -std=c++20 with clang 15.0 and later. ifeq ($(shell test $(clang_version) -ge 15 && echo yes),yes) - cppflags += -std=c++20 + cppflags += -std=c++17 else cppflags += -std=c++17 endif diff --git a/cpp/include/Ice/AsyncResponseHandler.h b/cpp/include/Ice/AsyncResponseHandler.h index fef42894010..4dbb68f8bf1 100644 --- a/cpp/include/Ice/AsyncResponseHandler.h +++ b/cpp/include/Ice/AsyncResponseHandler.h @@ -44,7 +44,7 @@ namespace IceInternal // else we ignore this call. } - void sendResponse(bool ok, const std::pair& encaps) noexcept + void sendResponse(bool ok, std::pair encaps) noexcept { if (!_responseSent.test_and_set()) { diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index 35d57b19b45..c124f63c7c8 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -81,7 +81,7 @@ namespace Ice * You can supply a communicator later by calling initialize(). * @param bytes The encoded data. */ - InputStream(const std::pair& bytes); + InputStream(std::pair bytes); /// \cond INTERNAL InputStream(IceInternal::Buffer&, bool = false); @@ -105,7 +105,7 @@ namespace Ice * @param communicator The communicator to use for unmarshaling tasks. * @param bytes The encoded data. */ - InputStream(const CommunicatorPtr& communicator, const std::pair& bytes); + InputStream(const CommunicatorPtr& communicator, std::pair bytes); /// \cond INTERNAL InputStream(const CommunicatorPtr& communicator, IceInternal::Buffer&, bool = false); @@ -138,7 +138,7 @@ namespace Ice * @param version The encoding version used to encode the data to be unmarshaled. * @param bytes The encoded data. */ - InputStream(const EncodingVersion& version, const std::pair& bytes); + InputStream(const EncodingVersion& version, std::pair bytes); /// \cond INTERNAL InputStream(const EncodingVersion&, IceInternal::Buffer&, bool = false); @@ -171,7 +171,7 @@ namespace Ice InputStream( const CommunicatorPtr& communicator, const EncodingVersion& version, - const std::pair& bytes); + std::pair bytes); /// \cond INTERNAL InputStream(const CommunicatorPtr&, const EncodingVersion&, IceInternal::Buffer&, bool = false); diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index 08805bafc3f..edcf6841874 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -210,7 +210,7 @@ namespace Ice */ virtual void ice_invokeAsync( std::pair inEncaps, - std::function&)> response, + std::function)> response, std::function error, const Current& current) = 0; diff --git a/cpp/include/Ice/OutgoingResponse.h b/cpp/include/Ice/OutgoingResponse.h index 6727b43f811..e5647444f42 100644 --- a/cpp/include/Ice/OutgoingResponse.h +++ b/cpp/include/Ice/OutgoingResponse.h @@ -158,7 +158,7 @@ namespace Ice */ ICE_API OutgoingResponse makeOutgoingResponse( bool ok, - const std::pair& encapsulation, + std::pair encapsulation, const Current& current) noexcept; /** diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h index ccc02762a10..032e9a43dc9 100644 --- a/cpp/include/Ice/OutputStream.h +++ b/cpp/include/Ice/OutputStream.h @@ -66,7 +66,7 @@ namespace Ice OutputStream( const CommunicatorPtr& communicator, const EncodingVersion& version, - const std::pair& bytes); + std::pair bytes); /** * Move constructor. diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index f3e5692c11b..b6a270372a7 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -480,7 +480,7 @@ namespace Ice bool ice_invoke( std::string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, std::vector& outParams, const Ice::Context& context = Ice::noExplicitContext) const; @@ -495,7 +495,7 @@ namespace Ice std::future>> ice_invokeAsync( std::string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, const Ice::Context& context = Ice::noExplicitContext) const; /** @@ -512,7 +512,7 @@ namespace Ice std::function ice_invokeAsync( std::string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, std::function)> response, std::function ex = nullptr, std::function sent = nullptr, diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h index f8728b6631f..6da03c6a7a3 100644 --- a/cpp/include/Ice/StreamHelpers.h +++ b/cpp/include/Ice/StreamHelpers.h @@ -13,6 +13,10 @@ #include #include +#ifdef __cpp_lib_span +# include +#endif + namespace Ice { /// \cond STREAM @@ -491,7 +495,7 @@ namespace Ice */ template struct StreamHelper, StreamHelperCategorySequence> { - template static inline void write(S* stream, const std::pair& v) + template static inline void write(S* stream, std::pair v) { stream->write(v.first, v.second); } @@ -499,6 +503,22 @@ namespace Ice template static inline void read(S* stream, std::pair& v) { stream->read(v); } }; +#ifdef __cpp_lib_span + /** + * Helper for span (C++20 or later). + * \headerfile Ice/Ice.h + */ + template struct StreamHelper, StreamHelperCategorySequence> + { + template inline static void write(S* stream, const std::span& v) + { + stream->write(v.data(), v.data() + v.size()); + } + + // No read. span are only for view types. + }; +#endif + /** * Helper for dictionaries. * \headerfile Ice/Ice.h diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp index dc45cfb43ac..4fc8dbec489 100644 --- a/cpp/src/Glacier2/Blobject.cpp +++ b/cpp/src/Glacier2/Blobject.cpp @@ -67,8 +67,8 @@ Glacier2::Blobject::updateObserver(const shared_ptr& inParams, - function&)> response, + pair inParams, + function)> response, function exception, const Current& current) { diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h index 2e2dfcba8b7..25543bdbd16 100644 --- a/cpp/src/Glacier2/Blobject.h +++ b/cpp/src/Glacier2/Blobject.h @@ -25,8 +25,8 @@ namespace Glacier2 protected: void invoke( Ice::ObjectPrx&, - const std::pair&, - std::function&)>, + std::pair, + std::function)>, std::function, const Ice::Current&); diff --git a/cpp/src/Glacier2/ClientBlobject.cpp b/cpp/src/Glacier2/ClientBlobject.cpp index a12c886d41f..588cef09356 100644 --- a/cpp/src/Glacier2/ClientBlobject.cpp +++ b/cpp/src/Glacier2/ClientBlobject.cpp @@ -30,7 +30,7 @@ Glacier2::ClientBlobject::ClientBlobject( void Glacier2::ClientBlobject::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function error, const Current& current) { diff --git a/cpp/src/Glacier2/ClientBlobject.h b/cpp/src/Glacier2/ClientBlobject.h index b9a5d2f6e69..9a44b2fecad 100644 --- a/cpp/src/Glacier2/ClientBlobject.h +++ b/cpp/src/Glacier2/ClientBlobject.h @@ -24,7 +24,7 @@ namespace Glacier2 void ice_invokeAsync( std::pair inEncaps, - std::function&)> response, + std::function)> response, std::function error, const Ice::Current& current) override; diff --git a/cpp/src/Glacier2/RequestQueue.cpp b/cpp/src/Glacier2/RequestQueue.cpp index 5e2ee7d8084..9fa3ec8d1b5 100644 --- a/cpp/src/Glacier2/RequestQueue.cpp +++ b/cpp/src/Glacier2/RequestQueue.cpp @@ -12,7 +12,7 @@ using namespace Glacier2; Glacier2::Request::Request( ObjectPrx proxy, - const std::pair& inParams, + pair inParams, const Current& current, bool forwardContext, const Ice::Context& sslContext, @@ -138,7 +138,7 @@ Glacier2::Request::override(const shared_ptr& other) const } void -Glacier2::Request::response(bool ok, const pair& outParams) +Glacier2::Request::response(bool ok, pair outParams) { assert(_proxy->ice_isTwoway()); _response(ok, outParams); @@ -245,7 +245,7 @@ Glacier2::RequestQueue::flushRequests() } auto self = shared_from_this(); request->invoke( - [self, request](bool ok, const pair& outParams) + [self, request](bool ok, pair outParams) { self->response(ok, outParams, request); }, [self, request](exception_ptr e) { self->exception(e, request); }); } @@ -289,7 +289,7 @@ Glacier2::RequestQueue::flush() auto request = *p; request->invoke( - [self, request](bool ok, const pair& outParams) + [self, request](bool ok, pair outParams) { self->response(ok, outParams, request); }, [self, request, completedExceptionally](exception_ptr e) { @@ -324,7 +324,7 @@ Glacier2::RequestQueue::flush() void Glacier2::RequestQueue::response( bool ok, - const pair& outParams, + pair outParams, const shared_ptr& request) { assert(request); diff --git a/cpp/src/Glacier2/RequestQueue.h b/cpp/src/Glacier2/RequestQueue.h index 034f8250264..182a9cdbd44 100644 --- a/cpp/src/Glacier2/RequestQueue.h +++ b/cpp/src/Glacier2/RequestQueue.h @@ -23,7 +23,7 @@ namespace Glacier2 public: Request( Ice::ObjectPrx, - const std::pair&, + std::pair, const Ice::Current&, bool, const Ice::Context&, @@ -39,7 +39,7 @@ namespace Glacier2 private: friend class RequestQueue; - void response(bool, const std::pair&); + void response(bool, std::pair); void exception(std::exception_ptr); void queued(); @@ -49,7 +49,7 @@ namespace Glacier2 const bool _forwardContext; const Ice::Context _sslContext; const std::string _override; - std::function&)> _response; + std::function)> _response; std::function _exception; }; @@ -68,7 +68,7 @@ namespace Glacier2 private: void flush(); - void response(bool, const std::pair&, const std::shared_ptr&); + void response(bool, std::pair, const std::shared_ptr&); void exception(std::exception_ptr, const std::shared_ptr&); void sent(bool, const std::shared_ptr&); diff --git a/cpp/src/Glacier2/ServerBlobject.cpp b/cpp/src/Glacier2/ServerBlobject.cpp index cee09c75ea0..4e8b3b218d6 100644 --- a/cpp/src/Glacier2/ServerBlobject.cpp +++ b/cpp/src/Glacier2/ServerBlobject.cpp @@ -16,7 +16,7 @@ Glacier2::ServerBlobject::ServerBlobject(shared_ptr instance, shared_p void Glacier2::ServerBlobject::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function error, const Current& current) { diff --git a/cpp/src/Glacier2/ServerBlobject.h b/cpp/src/Glacier2/ServerBlobject.h index bbb511a0d65..a878844c203 100644 --- a/cpp/src/Glacier2/ServerBlobject.h +++ b/cpp/src/Glacier2/ServerBlobject.h @@ -16,7 +16,7 @@ namespace Glacier2 void ice_invokeAsync( std::pair inEncaps, - std::function&)> response, + std::function)> response, std::function error, const Ice::Current& current) override; }; diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index b89ce919589..e7e22f3d45a 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -44,7 +44,7 @@ Ice::InputStream::InputStream() { initialize(currentEncoding); } Ice::InputStream::InputStream(const vector& v) : Buffer(v) { initialize(currentEncoding); } -Ice::InputStream::InputStream(const pair& p) : Buffer(p.first, p.second) +Ice::InputStream::InputStream(pair p) : Buffer(p.first, p.second) { initialize(currentEncoding); } @@ -58,7 +58,7 @@ Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const vector< initialize(communicator); } -Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const pair& p) +Ice::InputStream::InputStream(const CommunicatorPtr& communicator, pair p) : Buffer(p.first, p.second) { initialize(communicator); @@ -76,7 +76,7 @@ Ice::InputStream::InputStream(const EncodingVersion& encoding, const vector& p) +Ice::InputStream::InputStream(const EncodingVersion& encoding, pair p) : Buffer(p.first, p.second) { initialize(encoding); @@ -104,7 +104,7 @@ Ice::InputStream::InputStream( Ice::InputStream::InputStream( const CommunicatorPtr& communicator, const EncodingVersion& encoding, - const pair& p) + pair p) : Buffer(p.first, p.second) { initialize(communicator, encoding); diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 3d2606d8006..23b72ba7c7c 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -274,7 +274,7 @@ Ice::BlobjectArrayAsync::dispatch(IncomingRequest& request, std::function& outEncaps) + [responseHandler](bool ok, pair outEncaps) { responseHandler->sendResponse(ok, outEncaps); }, [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current()); diff --git a/cpp/src/Ice/OutgoingResponse.cpp b/cpp/src/Ice/OutgoingResponse.cpp index 4ce1efc062f..f38dec75853 100644 --- a/cpp/src/Ice/OutgoingResponse.cpp +++ b/cpp/src/Ice/OutgoingResponse.cpp @@ -255,7 +255,7 @@ Ice::makeEmptyOutgoingResponse(const Current& current) noexcept } OutgoingResponse -Ice::makeOutgoingResponse(bool ok, const pair& encapsulation, const Current& current) noexcept +Ice::makeOutgoingResponse(bool ok, pair encapsulation, const Current& current) noexcept { OutputStream ostr(current.adapter->getCommunicator(), Ice::currentProtocolEncoding); if (current.requestId != 0) diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp index 90e9d2f9e0b..8077e155e5a 100644 --- a/cpp/src/Ice/OutputStream.cpp +++ b/cpp/src/Ice/OutputStream.cpp @@ -85,7 +85,7 @@ Ice::OutputStream::OutputStream(const CommunicatorPtr& communicator, const Encod Ice::OutputStream::OutputStream( const CommunicatorPtr& communicator, const EncodingVersion& encoding, - const pair& buf) + pair buf) : Buffer(buf.first, buf.second), _closure(0), _currentEncaps(0) diff --git a/cpp/src/Ice/ProxyAsync.cpp b/cpp/src/Ice/ProxyAsync.cpp index 1596029d7d6..ef0aa25cba3 100644 --- a/cpp/src/Ice/ProxyAsync.cpp +++ b/cpp/src/Ice/ProxyAsync.cpp @@ -121,7 +121,7 @@ namespace IceInternal void invoke( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, const Ice::Context& context) { _read = [](bool ok, Ice::InputStream* stream) @@ -522,7 +522,7 @@ bool Ice::ObjectPrx::ice_invoke( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, vector& outParams, const Ice::Context& context) const { @@ -539,7 +539,7 @@ std::future>> Ice::ObjectPrx::ice_invokeAsync( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, const Ice::Context& context) const { using Outgoing = ::IceInternal::InvokePromiseOutgoing<::std::tuple>>; @@ -552,7 +552,7 @@ std::function Ice::ObjectPrx::ice_invokeAsync( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + std::pair inParams, std::function)> response, std::function ex, std::function sent, diff --git a/cpp/src/IceBridge/IceBridge.cpp b/cpp/src/IceBridge/IceBridge.cpp index bcb9adb454c..0c0fdfa9ab4 100644 --- a/cpp/src/IceBridge/IceBridge.cpp +++ b/cpp/src/IceBridge/IceBridge.cpp @@ -28,7 +28,7 @@ namespace // QueuedDispatch( pair p, - function&)>&& r, + function)>&& r, function&& e, const Current& c) : inParams(p.first, p.second), @@ -44,7 +44,7 @@ namespace QueuedDispatch(const QueuedDispatch&) = delete; const vector inParams; - function&)> response; + function)> response; function error; const Current current; }; @@ -98,7 +98,7 @@ namespace void closed(const shared_ptr&); void dispatch( pair, - function&)>, + function)>, function, const Current&); @@ -106,7 +106,7 @@ namespace void send( const shared_ptr&, pair, - function&)>, + function)>, function, const Current& current); @@ -137,7 +137,7 @@ namespace void ice_invokeAsync( pair inEncaps, - function&)> response, + function)> response, function error, const Current& current) final; @@ -307,7 +307,7 @@ BridgeConnection::closed(const shared_ptr& con) void BridgeConnection::dispatch( pair inParams, - function&)> response, + function)> response, function error, const Current& current) { @@ -344,7 +344,7 @@ void BridgeConnection::send( const shared_ptr& dest, pair inParams, - function&)> response, + function)> response, function error, const Current& current) { @@ -400,7 +400,7 @@ BridgeI::BridgeI(shared_ptr adapter, ObjectPrx target) void BridgeI::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function error, const Current& current) { diff --git a/cpp/src/IceGrid/AdminCallbackRouter.cpp b/cpp/src/IceGrid/AdminCallbackRouter.cpp index 9f5bb00562b..e137668c2ab 100644 --- a/cpp/src/IceGrid/AdminCallbackRouter.cpp +++ b/cpp/src/IceGrid/AdminCallbackRouter.cpp @@ -36,7 +36,7 @@ AdminCallbackRouter::removeMapping(const string& category) void AdminCallbackRouter::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/AdminCallbackRouter.h b/cpp/src/IceGrid/AdminCallbackRouter.h index 987831d92d2..b8c54f50fe5 100644 --- a/cpp/src/IceGrid/AdminCallbackRouter.h +++ b/cpp/src/IceGrid/AdminCallbackRouter.h @@ -24,7 +24,7 @@ namespace IceGrid void ice_invokeAsync( std::pair, - std::function&)>, + std::function)>, std::function, const Ice::Current& current) override; diff --git a/cpp/src/IceGrid/AdminRouter.cpp b/cpp/src/IceGrid/AdminRouter.cpp index 73aa9c2768a..77dd86fedf6 100644 --- a/cpp/src/IceGrid/AdminRouter.cpp +++ b/cpp/src/IceGrid/AdminRouter.cpp @@ -12,8 +12,8 @@ IceGrid::AdminRouter::AdminRouter(const shared_ptr& traceLevels) : void IceGrid::AdminRouter::invokeOnTarget( const Ice::ObjectPrx& target, - const pair& inParams, - function&)>&& response, + pair inParams, + function)>&& response, function&& exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/AdminRouter.h b/cpp/src/IceGrid/AdminRouter.h index 58b817d4b01..dec510f58bb 100644 --- a/cpp/src/IceGrid/AdminRouter.h +++ b/cpp/src/IceGrid/AdminRouter.h @@ -20,8 +20,8 @@ namespace IceGrid void invokeOnTarget( const Ice::ObjectPrx&, - const std::pair&, - std::function&)>&&, + std::pair, + std::function)>&&, std::function&&, const Ice::Current&); diff --git a/cpp/src/IceGrid/AdminSessionI.cpp b/cpp/src/IceGrid/AdminSessionI.cpp index ede63ae02af..40662325c56 100644 --- a/cpp/src/IceGrid/AdminSessionI.cpp +++ b/cpp/src/IceGrid/AdminSessionI.cpp @@ -25,7 +25,7 @@ namespace void ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function exception, const Ice::Current& current) override { diff --git a/cpp/src/IceGrid/NodeAdminRouter.cpp b/cpp/src/IceGrid/NodeAdminRouter.cpp index beb42934c27..bd67923b9a3 100644 --- a/cpp/src/IceGrid/NodeAdminRouter.cpp +++ b/cpp/src/IceGrid/NodeAdminRouter.cpp @@ -20,7 +20,7 @@ NodeServerAdminRouter::NodeServerAdminRouter(const shared_ptr& node) void NodeServerAdminRouter::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/NodeAdminRouter.h b/cpp/src/IceGrid/NodeAdminRouter.h index 4d61a5d050b..d2a8290f256 100644 --- a/cpp/src/IceGrid/NodeAdminRouter.h +++ b/cpp/src/IceGrid/NodeAdminRouter.h @@ -20,7 +20,7 @@ namespace IceGrid void ice_invokeAsync( std::pair, - std::function&)>, + std::function)>, std::function, const Ice::Current& current) override; diff --git a/cpp/src/IceGrid/RegistryAdminRouter.cpp b/cpp/src/IceGrid/RegistryAdminRouter.cpp index 9e457319cf6..a18bd0a7016 100644 --- a/cpp/src/IceGrid/RegistryAdminRouter.cpp +++ b/cpp/src/IceGrid/RegistryAdminRouter.cpp @@ -18,8 +18,8 @@ namespace public: SynchronizationCallbackI( const shared_ptr& adminRouter, - const pair& inParams, - function&)> response, + pair inParams, + function)> response, function exception, const Current& current) : _adminRouter(adminRouter), @@ -49,7 +49,7 @@ namespace private: const shared_ptr _adminRouter; - function&)> _response; + function)> _response; function _exception; const vector _inParams; const Current _current; @@ -65,7 +65,7 @@ RegistryServerAdminRouter::RegistryServerAdminRouter(const shared_ptr& void RegistryServerAdminRouter::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function exception, const Ice::Current& current) { @@ -116,7 +116,7 @@ RegistryNodeAdminRouter::RegistryNodeAdminRouter(const string& collocNodeName, c void RegistryNodeAdminRouter::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function exception, const Ice::Current& current) { @@ -165,7 +165,7 @@ RegistryReplicaAdminRouter::RegistryReplicaAdminRouter(const string& name, const void RegistryReplicaAdminRouter::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/RegistryAdminRouter.h b/cpp/src/IceGrid/RegistryAdminRouter.h index 2f07b147fd4..745adf590c1 100644 --- a/cpp/src/IceGrid/RegistryAdminRouter.h +++ b/cpp/src/IceGrid/RegistryAdminRouter.h @@ -18,7 +18,7 @@ namespace IceGrid void ice_invokeAsync( std::pair, - std::function&)>, + std::function)>, std::function, const Ice::Current& current) override; @@ -33,7 +33,7 @@ namespace IceGrid void ice_invokeAsync( std::pair, - std::function&)>, + std::function)>, std::function, const Ice::Current& current) override; @@ -49,7 +49,7 @@ namespace IceGrid void ice_invokeAsync( std::pair, - std::function&)>, + std::function)>, std::function, const Ice::Current& current) override; diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index d884372085d..d9eefca94a3 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -25,9 +25,9 @@ namespace LocatorI* locator, const string& operation, Ice::OperationMode mode, - const pair& inParams, + pair inParams, const Ice::Context& ctx, - function)> responseCallback, + function)> responseCallback, function exceptionCallback) : _locator(locator), _operation(operation), @@ -40,7 +40,7 @@ namespace } void invoke(const Ice::LocatorPrx&); - void response(bool, const pair&); + void response(bool, pair); void exception(std::exception_ptr); protected: @@ -49,7 +49,7 @@ namespace const Ice::OperationMode _mode; const Ice::Context _context; const Ice::ByteSeq _inParams; - function)> _responseCallback; + function)> _responseCallback; function _exceptionCallback; exception_ptr _exception; @@ -67,7 +67,7 @@ namespace void ice_invokeAsync( pair, - function&)>, + function)>, function, const Ice::Current&) final; @@ -341,7 +341,7 @@ Request::invoke(const Ice::LocatorPrx& l) } void -Request::response(bool ok, const pair& outParams) +Request::response(bool ok, pair outParams) { _responseCallback(ok, outParams); } @@ -445,7 +445,7 @@ LocatorI::setLookupReply(const LookupReplyPrx& lookupReply) void LocatorI::ice_invokeAsync( pair inParams, - function&)> responseCB, + function)> responseCB, function exceptionCB, const Ice::Current& current) { diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp index ff018b38b73..f70e1b8db7e 100644 --- a/cpp/src/IcePatch2/FileServerI.cpp +++ b/cpp/src/IcePatch2/FileServerI.cpp @@ -61,7 +61,7 @@ IcePatch2::FileServerI::getLargeFileCompressedAsync( string pa, int64_t pos, int32_t num, - function& returnValue)> response, + function returnValue)> response, function exception, const Current&) const { diff --git a/cpp/src/IcePatch2/FileServerI.h b/cpp/src/IcePatch2/FileServerI.h index 9ec77e2f851..31d74f6d0f7 100644 --- a/cpp/src/IcePatch2/FileServerI.h +++ b/cpp/src/IcePatch2/FileServerI.h @@ -27,7 +27,7 @@ namespace IcePatch2 std::string, std::int32_t, std::int32_t, - std::function& returnValue)>, + std::function returnValue)>, std::function, const Ice::Current&) const; @@ -35,7 +35,7 @@ namespace IcePatch2 std::string, std::int64_t, std::int32_t, - std::function& returnValue)>, + std::function returnValue)>, std::function, const Ice::Current&) const final; diff --git a/cpp/src/slice2cpp/CPlusPlusUtil.cpp b/cpp/src/slice2cpp/CPlusPlusUtil.cpp index 9492999bd7e..5ba7e4ee408 100644 --- a/cpp/src/slice2cpp/CPlusPlusUtil.cpp +++ b/cpp/src/slice2cpp/CPlusPlusUtil.cpp @@ -94,6 +94,51 @@ namespace } } + // Do we pass this type by value when it's an input parameter? + bool inputParamByValue(const TypePtr& type, const StringList& metaData) + { + BuiltinPtr builtin = dynamic_pointer_cast(type); + if ((builtin && (!builtin->isVariableLength() || builtin->kind() == Builtin::KindString))) + { + return true; + } + if (dynamic_pointer_cast(type)) + { + return true; + } + if (dynamic_pointer_cast(type) || dynamic_pointer_cast(type)) + { + static const string prefix = "cpp:"; + + // Return true for view-type (sequence and dictionary) and array (sequence only) + for (const auto& str : metaData) + { + if (str.find(prefix) == 0) + { + string::size_type pos = str.find(':', prefix.size()); + if (pos != string::npos) + { + string ss = str.substr(prefix.size()); + if (ss.find("view-type:") == 0) + { + return true; + } + // else check remaining meta data + } + else + { + if (str.substr(prefix.size()) == "array") + { + return true; + } + // else check remaining meta data + } + } + } + } + return false; + } + void writeParamAllocateCode( Output& out, const TypePtr& type, @@ -513,9 +558,7 @@ Slice::inputTypeToString( assert(typeCtx == TypeContext::None || typeCtx == TypeContext::UseWstring); typeCtx = (typeCtx | TypeContext::MarshalParam); - BuiltinPtr builtin = dynamic_pointer_cast(type); - if ((builtin && (!builtin->isVariableLength() || builtin->kind() == Builtin::KindString)) || - dynamic_pointer_cast(type)) + if (inputParamByValue(type, metaData)) { // Pass by value, even if it's optional. return typeToString(type, optional, scope, metaData, typeCtx); diff --git a/cpp/test/Ice/custom/TestAMDI.cpp b/cpp/test/Ice/custom/TestAMDI.cpp index 52bd08d6ba3..7142eb90633 100644 --- a/cpp/test/Ice/custom/TestAMDI.cpp +++ b/cpp/test/Ice/custom/TestAMDI.cpp @@ -34,7 +34,7 @@ TestIntfI::opBoolArrayAsync( void TestIntfI::opByteArrayAsync( pair in, - function&, const pair&)> response, + function, pair)> response, function, const Current&) { @@ -245,7 +245,7 @@ TestIntfI::opCListAsync( void TestIntfI::opOutArrayByteSeqAsync( ByteSeq in, - function&)> response, + function)> response, function, const Current&) { diff --git a/cpp/test/Ice/custom/TestAMDI.h b/cpp/test/Ice/custom/TestAMDI.h index d46f053a6f9..9734ddde4eb 100644 --- a/cpp/test/Ice/custom/TestAMDI.h +++ b/cpp/test/Ice/custom/TestAMDI.h @@ -24,9 +24,8 @@ class TestIntfI : public virtual Test::TestIntf void opByteArrayAsync( std::pair, - std::function&, - const std::pair&)>, + std::function< + void(std::pair, std::pair)>, std::function, const Ice::Current&) override; @@ -152,7 +151,7 @@ class TestIntfI : public virtual Test::TestIntf void opOutArrayByteSeqAsync( Test::ByteSeq, - std::function&)>, + std::function)>, std::function, const Ice::Current&) override; diff --git a/cpp/test/Ice/invoke/BlobjectI.cpp b/cpp/test/Ice/invoke/BlobjectI.cpp index f5cf2128138..096c417dd1a 100644 --- a/cpp/test/Ice/invoke/BlobjectI.cpp +++ b/cpp/test/Ice/invoke/BlobjectI.cpp @@ -110,7 +110,7 @@ BlobjectAsyncI::ice_invokeAsync( void BlobjectArrayAsyncI::ice_invokeAsync( pair inEncaps, - function&)> response, + function)> response, function, const Current& current) { diff --git a/cpp/test/Ice/invoke/BlobjectI.h b/cpp/test/Ice/invoke/BlobjectI.h index afa1286bb2c..0ded4bf0d02 100644 --- a/cpp/test/Ice/invoke/BlobjectI.h +++ b/cpp/test/Ice/invoke/BlobjectI.h @@ -34,7 +34,7 @@ class BlobjectArrayAsyncI final : public Ice::BlobjectArrayAsync public: void ice_invokeAsync( std::pair, - std::function&)>, + std::function)>, std::function, const Ice::Current&) final; }; diff --git a/cpp/test/Ice/optional/TestAMDI.cpp b/cpp/test/Ice/optional/TestAMDI.cpp index 92a60f8bc35..9365b0c0bcd 100644 --- a/cpp/test/Ice/optional/TestAMDI.cpp +++ b/cpp/test/Ice/optional/TestAMDI.cpp @@ -227,7 +227,7 @@ InitialI::opMyInterfaceProxyAsync( void InitialI::opByteSeqAsync( optional> p1, - function>&, const optional>&)> + function>, optional>)> response, function, const Ice::Current&) @@ -238,7 +238,7 @@ InitialI::opByteSeqAsync( void InitialI::opBoolSeqAsync( optional> p1, - function>&, const optional>&)> + function>, optional>)> response, function, const Ice::Current&) @@ -249,7 +249,7 @@ InitialI::opBoolSeqAsync( void InitialI::opShortSeqAsync( optional> p1, - function>&, const optional>&)> + function>, optional>)> response, function, const Ice::Current&) @@ -260,7 +260,7 @@ InitialI::opShortSeqAsync( void InitialI::opIntSeqAsync( optional> p1, - function>&, const optional>&)> + function>, optional>)> response, function, const Ice::Current&) @@ -272,8 +272,8 @@ void InitialI::opLongSeqAsync( optional> p1, function>&, - const optional>&)> response, + optional>, + optional>)> response, function, const Ice::Current&) { @@ -283,7 +283,7 @@ InitialI::opLongSeqAsync( void InitialI::opFloatSeqAsync( optional> p1, - function>&, const optional>&)> + function>, optional>)> response, function, const Ice::Current&) @@ -295,7 +295,7 @@ void InitialI::opDoubleSeqAsync( optional> p1, function< - void(const optional>&, const optional>&)> + void(optional>, optional>)> response, function, const Ice::Current&) @@ -317,8 +317,8 @@ void InitialI::opSmallStructSeqAsync( optional> p1, function>&, - const optional>&)> response, + optional>, + optional>)> response, function, const Ice::Current&) { @@ -329,8 +329,8 @@ void InitialI::opSmallStructListAsync( optional> p1, function>&, - const optional>&)> response, + optional>, + optional>)> response, function, const Ice::Current&) { @@ -341,8 +341,8 @@ void InitialI::opFixedStructSeqAsync( optional> p1, function>&, - const optional>&)> response, + optional>, + optional>)> response, function, const Ice::Current&) { @@ -353,8 +353,8 @@ void InitialI::opFixedStructListAsync( optional> p1, function>&, - const optional>&)> response, + optional>, + optional>)> response, function, const Ice::Current&) { diff --git a/cpp/test/Ice/optional/TestAMDI.h b/cpp/test/Ice/optional/TestAMDI.h index e9847ac1933..a93c84554f8 100644 --- a/cpp/test/Ice/optional/TestAMDI.h +++ b/cpp/test/Ice/optional/TestAMDI.h @@ -133,56 +133,56 @@ class InitialI final : public Test::Initial void opByteSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opBoolSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opShortSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opIntSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opLongSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opFloatSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opDoubleSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; @@ -195,32 +195,32 @@ class InitialI final : public Test::Initial void opSmallStructSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opSmallStructListAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opFixedStructSeqAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; void opFixedStructListAsync( std::optional>, std::function>&, - const std::optional>&)>, + std::optional>, + std::optional>)>, std::function, const Ice::Current&) final; diff --git a/cpp/test/Ice/span/AllTests.cpp b/cpp/test/Ice/span/AllTests.cpp new file mode 100644 index 00000000000..f8ec929d8af --- /dev/null +++ b/cpp/test/Ice/span/AllTests.cpp @@ -0,0 +1,35 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "Ice/Ice.h" +#include "TestHelper.h" +#include "Test.h" + +#include + +using namespace std; +using namespace Ice; +using namespace Test; + +TestIntfPrx +allTests(TestHelper* helper) +{ + CommunicatorPtr communicator = helper->communicator(); + TestIntfPrx prx(communicator, "test:" + helper->getTestEndpoint()); + + cout << "testing span... " << flush; + + { + vector v{std::byte{0}, std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}, std::byte{5}}; + + auto dataIn = span{v}.subspan(1, 3); + vector dataOut; + auto r = prx->opByteSpan(dataIn, dataOut); + vector dataInVec{dataIn.begin(), dataIn.end()}; + test(r == dataOut); + test(r == dataInVec); + } + cout << "ok" << endl; + return prx; +} diff --git a/cpp/test/Ice/span/Client.cpp b/cpp/test/Ice/span/Client.cpp new file mode 100644 index 00000000000..a2d186f1079 --- /dev/null +++ b/cpp/test/Ice/span/Client.cpp @@ -0,0 +1,26 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "Ice/Ice.h" +#include "TestHelper.h" +#include "Test.h" + +using namespace std; + +class Client : public Test::TestHelper +{ +public: + void run(int, char**); +}; + +void +Client::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); + Test::TestIntfPrx allTests(Test::TestHelper*); + Test::TestIntfPrx test = allTests(this); + test->shutdown(); +} + +DEFINE_TEST(Client) diff --git a/cpp/test/Ice/span/Collocated.cpp b/cpp/test/Ice/span/Collocated.cpp new file mode 100644 index 00000000000..25f5ba2e666 --- /dev/null +++ b/cpp/test/Ice/span/Collocated.cpp @@ -0,0 +1,28 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "Ice/Ice.h" +#include "TestHelper.h" +#include "TestI.h" + +using namespace std; + +class Collocated : public Test::TestHelper +{ +public: + void run(int, char**); +}; + +void +Collocated::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); + communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint()); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + adapter->add(std::make_shared(), Ice::stringToIdentity("test")); + Test::TestIntfPrx allTests(Test::TestHelper*); + allTests(this); +} + +DEFINE_TEST(Collocated) diff --git a/cpp/test/Ice/span/Makefile.mk b/cpp/test/Ice/span/Makefile.mk new file mode 100644 index 00000000000..fbad3415507 --- /dev/null +++ b/cpp/test/Ice/span/Makefile.mk @@ -0,0 +1,7 @@ +# +# Copyright (c) ZeroC, Inc. All rights reserved. +# + + $(test)_cppflags += -std=c++20 + +tests += $(test) diff --git a/cpp/test/Ice/span/Server.cpp b/cpp/test/Ice/span/Server.cpp new file mode 100644 index 00000000000..b34e086cbd6 --- /dev/null +++ b/cpp/test/Ice/span/Server.cpp @@ -0,0 +1,29 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "Ice/Ice.h" +#include "TestHelper.h" +#include "TestI.h" + +using namespace std; + +class Server : public Test::TestHelper +{ +public: + void run(int, char**); +}; + +void +Server::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); + communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint()); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + adapter->add(std::make_shared(), Ice::stringToIdentity("test")); + adapter->activate(); + serverReady(); + communicator->waitForShutdown(); +} + +DEFINE_TEST(Server) diff --git a/cpp/test/Ice/span/ServerAMD.cpp b/cpp/test/Ice/span/ServerAMD.cpp new file mode 100644 index 00000000000..86af5bfc2a2 --- /dev/null +++ b/cpp/test/Ice/span/ServerAMD.cpp @@ -0,0 +1,30 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "Ice/Ice.h" +#include "TestHelper.h" +#include "TestAMDI.h" + +using namespace std; + +class ServerAMD : public Test::TestHelper +{ +public: + void run(int, char**); +}; + +void +ServerAMD::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); + + communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint()); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + adapter->add(std::make_shared(), Ice::stringToIdentity("test")); + adapter->activate(); + serverReady(); + communicator->waitForShutdown(); +} + +DEFINE_TEST(ServerAMD) diff --git a/cpp/test/Ice/span/Test.ice b/cpp/test/Ice/span/Test.ice new file mode 100644 index 00000000000..ed21e9d363f --- /dev/null +++ b/cpp/test/Ice/span/Test.ice @@ -0,0 +1,35 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#pragma once + +// No need to include , since StreamHelpers.h includes it. + +module Test +{ + sequence ByteSeq; + sequence ShortSeq; + sequence StringSeq; + + interface TestIntf + { + ["cpp:view-type:std::span"] ByteSeq opByteSpan( + ["cpp:view-type:std::span"] ByteSeq dataIn, + out ["cpp:view-type:std::span"] ByteSeq dataOut); + + ["cpp:view-type:std::span"] ShortSeq opShortSpan( + ["cpp:view-type:std::span"] ShortSeq dataIn, + out ["cpp:view-type:std::span"] ShortSeq dataOut); + + ["cpp:view-type:std::span"] StringSeq opStringSpan( + ["cpp:view-type:std::span"] StringSeq dataIn, + out ["cpp:view-type:std::span"] StringSeq dataOut); + + ["cpp:view-type:std::span"] ByteSeq opOptionalByteSpan( + ["cpp:view-type:std::span"] optional(1) ByteSeq dataIn, + out ["cpp:view-type:std::span"] ByteSeq dataOut); + + void shutdown(); + } +} diff --git a/cpp/test/Ice/span/TestAMD.ice b/cpp/test/Ice/span/TestAMD.ice new file mode 100644 index 00000000000..efca5549672 --- /dev/null +++ b/cpp/test/Ice/span/TestAMD.ice @@ -0,0 +1,36 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#pragma once + +// No need to include , since StreamHelpers.h includes it. + +module Test +{ + sequence ByteSeq; + sequence ShortSeq; + sequence StringSeq; + + ["amd"] + interface TestIntf + { + ["cpp:view-type:std::span"] ByteSeq opByteSpan( + ["cpp:view-type:std::span"] ByteSeq dataIn, + out ["cpp:view-type:std::span"] ByteSeq dataOut); + + ["cpp:view-type:std::span"] ShortSeq opShortSpan( + ["cpp:view-type:std::span"] ShortSeq dataIn, + out ["cpp:view-type:std::span"] ShortSeq dataOut); + + ["cpp:view-type:std::span"] StringSeq opStringSpan( + ["cpp:view-type:std::span"] StringSeq dataIn, + out ["cpp:view-type:std::span"] StringSeq dataOut); + + ["cpp:view-type:std::span"] ByteSeq opOptionalByteSpan( + ["cpp:view-type:std::span"] optional(1) ByteSeq dataIn, + out ["cpp:view-type:std::span"] ByteSeq dataOut); + + void shutdown(); + } +} diff --git a/cpp/test/Ice/span/TestAMDI.cpp b/cpp/test/Ice/span/TestAMDI.cpp new file mode 100644 index 00000000000..e8a57e0c34f --- /dev/null +++ b/cpp/test/Ice/span/TestAMDI.cpp @@ -0,0 +1,66 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "TestAMDI.h" + +using namespace std; +using namespace Test; + +void +TestIntfAMDI::opByteSpanAsync( + ByteSeq dataIn, + function returnValue, span dataOut)> response, + function, + const Ice::Current&) +{ + response(dataIn, dataIn); +} + +void +TestIntfAMDI::opShortSpanAsync( + ShortSeq dataIn, + function returnValue, span dataOut)> response, + function, + const Ice::Current&) +{ + response(dataIn, dataIn); +} + +void +TestIntfAMDI::opStringSpanAsync( + StringSeq dataIn, + function returnValue, span dataOut)> response, + function, + const Ice::Current&) +{ + response(dataIn, dataIn); +} + +void +TestIntfAMDI::opOptionalByteSpanAsync( + optional dataIn, + function returnValue, span dataOut)> response, + function, + const Ice::Current&) +{ + if (dataIn) + { + response(*dataIn, *dataIn); + } + else + { + vector v = {byte{42}}; + response(v, v); + } +} + +void +TestIntfAMDI::shutdownAsync( + function response, + function, + const Ice::Current& current) +{ + current.adapter->getCommunicator()->shutdown(); + response(); +} diff --git a/cpp/test/Ice/span/TestAMDI.h b/cpp/test/Ice/span/TestAMDI.h new file mode 100644 index 00000000000..d3ba2977c5b --- /dev/null +++ b/cpp/test/Ice/span/TestAMDI.h @@ -0,0 +1,43 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#ifndef TEST_AMD_I_H +#define TEST_AMD_I_H + +#include "TestAMD.h" + +class TestIntfAMDI final : public Test::TestIntf +{ +public: + void opByteSpanAsync( + Test::ByteSeq dataIn, + std::function returnValue, std::span dataOut)> response, + std::function exception, + const Ice::Current& current) final; + + void opShortSpanAsync( + Test::ShortSeq dataIn, + std::function returnValue, std::span dataOut)> response, + std::function exception, + const Ice::Current& current) final; + + void opStringSpanAsync( + Test::StringSeq dataIn, + std::function returnValue, std::span dataOut)> response, + std::function exception, + const Ice::Current& current) final; + + void opOptionalByteSpanAsync( + std::optional dataIn, + std::function returnValue, std::span dataOut)> response, + std::function exception, + const Ice::Current& current) final; + + void shutdownAsync( + std::function response, + std::function exception, + const Ice::Current& current) final; +}; + +#endif diff --git a/cpp/test/Ice/span/TestI.cpp b/cpp/test/Ice/span/TestI.cpp new file mode 100644 index 00000000000..1511a27a693 --- /dev/null +++ b/cpp/test/Ice/span/TestI.cpp @@ -0,0 +1,50 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include "TestI.h" + +using namespace std; +using namespace Test; + +ByteSeq +TestIntfI::opByteSpan(ByteSeq dataIn, ByteSeq& dataOut, const Ice::Current&) +{ + dataOut = std::move(dataIn); + return dataOut; +} + +ShortSeq +TestIntfI::opShortSpan(ShortSeq dataIn, ShortSeq& dataOut, const Ice::Current&) +{ + dataOut = std::move(dataIn); + return dataOut; +} + +StringSeq +TestIntfI::opStringSpan(StringSeq dataIn, StringSeq& dataOut, const Ice::Current&) +{ + dataOut = std::move(dataIn); + return dataOut; +} + +ByteSeq +TestIntfI::opOptionalByteSpan(optional dataIn, ByteSeq& dataOut, const Ice::Current&) +{ + if (dataIn) + { + dataOut = *std::move(dataIn); + return dataOut; + } + else + { + dataOut = {std::byte{42}}; + return dataOut; + } +} + +void +TestIntfI::shutdown(const Ice::Current& current) +{ + current.adapter->getCommunicator()->shutdown(); +} diff --git a/cpp/test/Ice/span/TestI.h b/cpp/test/Ice/span/TestI.h new file mode 100644 index 00000000000..802e4129c06 --- /dev/null +++ b/cpp/test/Ice/span/TestI.h @@ -0,0 +1,24 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#ifndef TEST_I_H +#define TEST_I_H + +#include "Test.h" + +class TestIntfI final : public Test::TestIntf +{ +public: + Test::ByteSeq opByteSpan(Test::ByteSeq dataIn, Test::ByteSeq& dataOut, const Ice::Current&) final; + + Test::ShortSeq opShortSpan(Test::ShortSeq dataIn, Test::ShortSeq& dataOut, const Ice::Current&) final; + + Test::StringSeq opStringSpan(Test::StringSeq dataIn, Test::StringSeq& dataOut, const Ice::Current&) final; + + Test::ByteSeq opOptionalByteSpan(std::optional dataIn, Test::ByteSeq& dataOut, const Ice::Current&) final; + + void shutdown(const Ice::Current&) final; +}; + +#endif diff --git a/php/src/Operation.cpp b/php/src/Operation.cpp index 13b28994111..1f846572f5e 100644 --- a/php/src/Operation.cpp +++ b/php/src/Operation.cpp @@ -107,8 +107,8 @@ namespace IcePHP OperationIPtr _op; bool prepareRequest(int, zval*, Ice::OutputStream*, pair&); - void unmarshalResults(int, zval*, zval*, const pair&); - void unmarshalException(zval*, const pair&); + void unmarshalResults(int, zval*, zval*, pair); + void unmarshalException(zval*, pair); bool validateException(const ExceptionInfoPtr&) const; void checkTwowayOnly(const Ice::ObjectPrx&) const; }; @@ -445,7 +445,7 @@ IcePHP::TypedInvocation::prepareRequest( } void -IcePHP::TypedInvocation::unmarshalResults(int argc, zval* args, zval* ret, const pair& bytes) +IcePHP::TypedInvocation::unmarshalResults(int argc, zval* args, zval* ret, pair bytes) { Ice::InputStream is(_communicator->getCommunicator(), bytes); @@ -529,7 +529,7 @@ IcePHP::TypedInvocation::unmarshalResults(int argc, zval* args, zval* ret, const } void -IcePHP::TypedInvocation::unmarshalException(zval* zex, const pair& bytes) +IcePHP::TypedInvocation::unmarshalException(zval* zex, pair bytes) { Ice::InputStream is(_communicator->getCommunicator(), bytes); diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp index 17f03e2c846..eebb80eb27b 100644 --- a/python/modules/IcePy/Operation.cpp +++ b/python/modules/IcePy/Operation.cpp @@ -113,8 +113,8 @@ namespace IcePy MappingType, Ice::OutputStream*, pair&); - PyObject* unmarshalResults(const OperationPtr&, const pair&); - PyObject* unmarshalException(const OperationPtr&, const pair&); + PyObject* unmarshalResults(const OperationPtr&, pair); + PyObject* unmarshalException(const OperationPtr&, pair); bool validateException(const OperationPtr&, PyObject*) const; void checkTwowayOnly(const OperationPtr&, const Ice::ObjectPrx&) const; @@ -142,13 +142,13 @@ namespace IcePy PyObject* invoke(PyObject*, PyObject* = 0) final; - void response(bool, const pair&); + void response(bool, pair); void exception(std::exception_ptr); void sent(bool); protected: virtual function handleInvoke(PyObject*, PyObject*) = 0; - virtual void handleResponse(PyObject*, bool, const pair&) = 0; + virtual void handleResponse(PyObject*, bool, pair) = 0; PyObject* _pyProxy; string _operation; @@ -170,7 +170,7 @@ namespace IcePy protected: function handleInvoke(PyObject*, PyObject*) final; - void handleResponse(PyObject*, bool, const pair&) final; + void handleResponse(PyObject*, bool, pair) final; private: OperationPtr _op; @@ -192,7 +192,7 @@ namespace IcePy protected: function handleInvoke(PyObject*, PyObject*) final; - void handleResponse(PyObject*, bool, const pair&) final; + void handleResponse(PyObject*, bool, pair) final; string _op; }; @@ -201,7 +201,7 @@ namespace IcePy class Upcall : public enable_shared_from_this { public: - virtual void dispatch(PyObject*, const pair&, const Ice::Current&) = 0; + virtual void dispatch(PyObject*, pair, const Ice::Current&) = 0; virtual void response(PyObject*) = 0; virtual void exception(PyException&) = 0; @@ -217,18 +217,18 @@ namespace IcePy public: TypedUpcall( const OperationPtr&, - function&)>, + function)>, function, const Ice::CommunicatorPtr&); - void dispatch(PyObject*, const pair&, const Ice::Current&) final; + void dispatch(PyObject*, pair, const Ice::Current&) final; void response(PyObject*) final; void exception(PyException&) final; private: OperationPtr _op; - function&)> _response; + function)> _response; function _error; Ice::CommunicatorPtr _communicator; @@ -243,15 +243,15 @@ namespace IcePy { public: BlobjectUpcall( - function&)>, + function)>, function); - void dispatch(PyObject*, const pair&, const Ice::Current&) final; + void dispatch(PyObject*, pair, const Ice::Current&) final; void response(PyObject*) final; void exception(PyException&) final; private: - function&)> _response; + function)> _response; function _error; }; @@ -264,7 +264,7 @@ namespace IcePy void ice_invokeAsync( pair inEncaps, - function&)> response, + function)> response, function error, const Ice::Current& current) final; @@ -282,7 +282,7 @@ namespace IcePy void ice_invokeAsync( pair inEncaps, - function&)> response, + function)> response, function error, const Ice::Current& current) final; }; @@ -1479,7 +1479,7 @@ IcePy::Invocation::prepareRequest( } PyObject* -IcePy::Invocation::unmarshalResults(const OperationPtr& op, const pair& bytes) +IcePy::Invocation::unmarshalResults(const OperationPtr& op, pair bytes) { Py_ssize_t numResults = static_cast(op->outParams.size()); if (op->returnType) @@ -1558,7 +1558,7 @@ IcePy::Invocation::unmarshalResults(const OperationPtr& op, const pair& bytes) +IcePy::Invocation::unmarshalException(const OperationPtr& op, pair bytes) { Ice::InputStream is(_communicator, bytes); @@ -1920,7 +1920,7 @@ IcePy::AsyncInvocation::invoke(PyObject* args, PyObject* kwds) } void -IcePy::AsyncInvocation::response(bool ok, const pair& results) +IcePy::AsyncInvocation::response(bool ok, pair results) { AdoptThread adoptThread; // Ensure the current thread is able to call into Python. @@ -2091,14 +2091,14 @@ IcePy::AsyncTypedInvocation::handleInvoke(PyObject* args, PyObject* /* kwds */) _op->name, _op->sendMode, params, - [self](bool ok, const pair& results) { self->response(ok, results); }, + [self](bool ok, pair results) { self->response(ok, results); }, [self](exception_ptr ex) { self->exception(ex); }, [self](bool sentSynchronously) { self->sent(sentSynchronously); }, pyctx == Py_None ? Ice::noExplicitContext : context); } void -IcePy::AsyncTypedInvocation::handleResponse(PyObject* future, bool ok, const pair& results) +IcePy::AsyncTypedInvocation::handleResponse(PyObject* future, bool ok, pair results) { try { @@ -2309,14 +2309,14 @@ IcePy::AsyncBlobjectInvocation::handleInvoke(PyObject* args, PyObject* /* kwds * operation, sendMode, params, - [self](bool ok, const pair& results) { self->response(ok, results); }, + [self](bool ok, pair results) { self->response(ok, results); }, [self](exception_ptr ex) { self->exception(ex); }, [self](bool sentSynchronously) { self->sent(sentSynchronously); }, (ctx == 0 || ctx == Py_None) ? Ice::noExplicitContext : context); } void -IcePy::AsyncBlobjectInvocation::handleResponse(PyObject* future, bool ok, const pair& results) +IcePy::AsyncBlobjectInvocation::handleResponse(PyObject* future, bool ok, pair results) { // Prepare the args as a tuple of the bool and out param buffer. PyObjectHandle args = PyTuple_New(2); @@ -2426,7 +2426,7 @@ Upcall::dispatchImpl(PyObject* servant, const string& dispatchName, PyObject* ar // IcePy::TypedUpcall::TypedUpcall( const OperationPtr& op, - function&)> response, + function)> response, function error, const Ice::CommunicatorPtr& communicator) : _op(op), @@ -2439,7 +2439,7 @@ IcePy::TypedUpcall::TypedUpcall( void IcePy::TypedUpcall::dispatch( PyObject* servant, - const pair& inBytes, + pair inBytes, const Ice::Current& current) { _encoding = current.encoding; @@ -2625,7 +2625,7 @@ IcePy::TypedUpcall::exception(PyException& ex) // BlobjectUpcall // IcePy::BlobjectUpcall::BlobjectUpcall( - function&)> response, + function)> response, function error) : _response(std::move(response)), _error(std::move(error)) @@ -2635,7 +2635,7 @@ IcePy::BlobjectUpcall::BlobjectUpcall( void IcePy::BlobjectUpcall::dispatch( PyObject* servant, - const pair& inBytes, + pair inBytes, const Ice::Current& current) { Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); @@ -3027,7 +3027,7 @@ IcePy::TypedServantWrapper::TypedServantWrapper(PyObject* servant) void IcePy::TypedServantWrapper::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function error, const Ice::Current& current) { @@ -3104,7 +3104,7 @@ IcePy::BlobjectServantWrapper::BlobjectServantWrapper(PyObject* servant) : Serva void IcePy::BlobjectServantWrapper::ice_invokeAsync( pair inParams, - function&)> response, + function)> response, function error, const Ice::Current& current) { diff --git a/swift/src/IceImpl/BlobjectFacade.h b/swift/src/IceImpl/BlobjectFacade.h index a4a98a031f6..1048463037e 100644 --- a/swift/src/IceImpl/BlobjectFacade.h +++ b/swift/src/IceImpl/BlobjectFacade.h @@ -43,7 +43,7 @@ class BlobjectFacade : public Ice::BlobjectArrayAsync virtual void ice_invokeAsync( std::pair inEncaps, - std::function&)> response, + std::function)> response, std::function error, const Ice::Current& current); diff --git a/swift/src/IceImpl/BlobjectFacade.mm b/swift/src/IceImpl/BlobjectFacade.mm index dbcdde61d19..53b37fa2906 100644 --- a/swift/src/IceImpl/BlobjectFacade.mm +++ b/swift/src/IceImpl/BlobjectFacade.mm @@ -11,7 +11,7 @@ void BlobjectFacade::ice_invokeAsync( std::pair inEncaps, - std::function&)> response, + std::function)> response, std::function error, const Ice::Current& current) { From 421b456ecfcacaf9cb98cc1a15e93df71b16dbdb Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 18 Mar 2024 23:01:25 -0400 Subject: [PATCH 2/8] Fix typo --- cpp/test/Ice/span/Makefile.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/test/Ice/span/Makefile.mk b/cpp/test/Ice/span/Makefile.mk index fbad3415507..b8e4d1a3b3e 100644 --- a/cpp/test/Ice/span/Makefile.mk +++ b/cpp/test/Ice/span/Makefile.mk @@ -2,6 +2,6 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # - $(test)_cppflags += -std=c++20 +$(test)_cppflags += -std=c++20 tests += $(test) From 2a4f5e6778452f6e5c6fa3ba1a4093d6c8b2b86d Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 18 Mar 2024 23:12:13 -0400 Subject: [PATCH 3/8] Cleanup --- cpp/include/Ice/Connection.h | 1 - cpp/include/Ice/Endpoint.h | 1 - cpp/include/Ice/Logger.h | 1 - cpp/include/Ice/Plugin.h | 1 - cpp/include/IceBT/ConnectionInfo.h | 1 - cpp/include/IceBT/EndpointInfo.h | 1 - cpp/include/IceIAP/ConnectionInfo.h | 1 - cpp/include/IceIAP/EndpointInfo.h | 1 - cpp/include/IceSSL/ConnectionInfo.h | 1 - cpp/include/IceSSL/EndpointInfo.h | 1 - cpp/src/Glacier2/Instrumentation.h | 1 - 11 files changed, 11 deletions(-) diff --git a/cpp/include/Ice/Connection.h b/cpp/include/Ice/Connection.h index 0ae25c45211..a792d4f1730 100644 --- a/cpp/include/Ice/Connection.h +++ b/cpp/include/Ice/Connection.h @@ -9,7 +9,6 @@ #include "ProxyF.h" #include "ValueF.h" #include "Exception.h" -#include "StreamHelpers.h" #include "Comparable.h" #include "ObjectAdapterF.h" #include "Ice/Identity.h" diff --git a/cpp/include/Ice/Endpoint.h b/cpp/include/Ice/Endpoint.h index 58dc28b6183..9e18aeb2e2a 100644 --- a/cpp/include/Ice/Endpoint.h +++ b/cpp/include/Ice/Endpoint.h @@ -9,7 +9,6 @@ #include "ProxyF.h" #include "ValueF.h" #include "Exception.h" -#include "StreamHelpers.h" #include "Comparable.h" #include "Ice/Version.h" #include "Ice/BuiltinSequences.h" diff --git a/cpp/include/Ice/Logger.h b/cpp/include/Ice/Logger.h index eaeeec17a20..de068934645 100644 --- a/cpp/include/Ice/Logger.h +++ b/cpp/include/Ice/Logger.h @@ -8,7 +8,6 @@ #include "ProxyF.h" #include "ValueF.h" #include "Exception.h" -#include "StreamHelpers.h" #include "Comparable.h" #include "IceUtil/UndefSysMacros.h" diff --git a/cpp/include/Ice/Plugin.h b/cpp/include/Ice/Plugin.h index 2335d4188d4..9ccca36136e 100644 --- a/cpp/include/Ice/Plugin.h +++ b/cpp/include/Ice/Plugin.h @@ -9,7 +9,6 @@ #include "ProxyF.h" #include "ValueF.h" #include "Exception.h" -#include "StreamHelpers.h" #include "Comparable.h" #include "LoggerF.h" #include "Ice/BuiltinSequences.h" diff --git a/cpp/include/IceBT/ConnectionInfo.h b/cpp/include/IceBT/ConnectionInfo.h index ea53e8c11c4..de8fedea413 100644 --- a/cpp/include/IceBT/ConnectionInfo.h +++ b/cpp/include/IceBT/ConnectionInfo.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceBT/EndpointInfo.h b/cpp/include/IceBT/EndpointInfo.h index ad5a6e307a3..7342e9626a3 100644 --- a/cpp/include/IceBT/EndpointInfo.h +++ b/cpp/include/IceBT/EndpointInfo.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceIAP/ConnectionInfo.h b/cpp/include/IceIAP/ConnectionInfo.h index cfab1b0590c..cdfd4cb9ce0 100644 --- a/cpp/include/IceIAP/ConnectionInfo.h +++ b/cpp/include/IceIAP/ConnectionInfo.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceIAP/EndpointInfo.h b/cpp/include/IceIAP/EndpointInfo.h index 6eb4ffaf985..9605067afe5 100644 --- a/cpp/include/IceIAP/EndpointInfo.h +++ b/cpp/include/IceIAP/EndpointInfo.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceSSL/ConnectionInfo.h b/cpp/include/IceSSL/ConnectionInfo.h index a24cfbcad5f..8b9c622ef19 100644 --- a/cpp/include/IceSSL/ConnectionInfo.h +++ b/cpp/include/IceSSL/ConnectionInfo.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceSSL/EndpointInfo.h b/cpp/include/IceSSL/EndpointInfo.h index cd4f7f4df84..1ce7f063cde 100644 --- a/cpp/include/IceSSL/EndpointInfo.h +++ b/cpp/include/IceSSL/EndpointInfo.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/Glacier2/Instrumentation.h b/cpp/src/Glacier2/Instrumentation.h index 66adc8a7d69..e86f187dd6c 100644 --- a/cpp/src/Glacier2/Instrumentation.h +++ b/cpp/src/Glacier2/Instrumentation.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include From c8b3933570c87e27bedb364d3c0332730d27c9fc Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 19 Mar 2024 15:47:57 -0400 Subject: [PATCH 4/8] Add span test --- cpp/include/Ice/InputStream.h | 2 +- cpp/src/Ice/ConnectionI.h | 1 + cpp/test/Ice/span/AllTests.cpp | 82 +++++++++++++++++++++++++++++++++- cpp/test/Ice/span/Test.ice | 14 +++++- cpp/test/Ice/span/TestAMD.ice | 14 +++++- cpp/test/Ice/span/TestAMDI.cpp | 25 +++++++++-- cpp/test/Ice/span/TestAMDI.h | 14 +++++- cpp/test/Ice/span/TestI.cpp | 30 ++++++++----- cpp/test/Ice/span/TestI.h | 6 ++- 9 files changed, 164 insertions(+), 24 deletions(-) diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index c124f63c7c8..b866d850d8c 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -7,7 +7,6 @@ #include "CommunicatorF.h" #include "InstanceF.h" -#include "Object.h" #include "ValueF.h" #include "ProxyF.h" #include "LoggerF.h" @@ -22,6 +21,7 @@ #include #include +#include #include #include diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index ed2ab079c64..dfb29f0656f 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -27,6 +27,7 @@ #include #include #include +#include "Ice/OutgoingResponse.h" #include #include diff --git a/cpp/test/Ice/span/AllTests.cpp b/cpp/test/Ice/span/AllTests.cpp index f8ec929d8af..3c8e5fc6473 100644 --- a/cpp/test/Ice/span/AllTests.cpp +++ b/cpp/test/Ice/span/AllTests.cpp @@ -19,17 +19,95 @@ allTests(TestHelper* helper) TestIntfPrx prx(communicator, "test:" + helper->getTestEndpoint()); cout << "testing span... " << flush; - { vector v{std::byte{0}, std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}, std::byte{5}}; - auto dataIn = span{v}.subspan(1, 3); + auto dataIn = span{v}.subspan(1, 3); vector dataOut; auto r = prx->opByteSpan(dataIn, dataOut); vector dataInVec{dataIn.begin(), dataIn.end()}; test(r == dataOut); test(r == dataInVec); } + + { + vector v{0, 1, 2, 3, 4, 5}; + + auto dataIn = span{v}.subspan(1, 3); + vector dataOut; + auto r = prx->opShortSpan(dataIn, dataOut); + vector dataInVec{dataIn.begin(), dataIn.end()}; + test(r == dataOut); + test(r == dataInVec); + } + + { + vector v{"a", "bb", "ccc", "dddd", "eeeee"}; + + auto dataIn = span{v}.subspan(1, 3); + vector dataOut; + auto r = prx->opStringSpan(dataIn, dataOut); + vector dataInVec{dataIn.begin(), dataIn.end()}; + test(r == dataOut); + test(r == dataInVec); + } + cout << "ok" << endl; + cout << "testing span with optionals... " << flush; + { + vector v{std::byte{0}, std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}, std::byte{5}}; + + auto dataIn = span{v}.subspan(1, 3); + optional> dataOut; + auto r = prx->opOptionalByteSpan(dataIn, dataOut); + vector dataInVec{dataIn.begin(), dataIn.end()}; + test(r == dataOut); + test(r == dataInVec); + } + + { + vector v{0, 1, 2, 3, 4, 5}; + + auto dataIn = span{v}.subspan(1, 3); + optional> dataOut; + auto r = prx->opOptionalShortSpan(dataIn, dataOut); + vector dataInVec{dataIn.begin(), dataIn.end()}; + test(r == dataOut); + test(r == dataInVec); + } + + { + vector v{"a", "bb", "ccc", "dddd", "eeeee"}; + + auto dataIn = span{v}.subspan(1, 3); + optional> dataOut; + auto r = prx->opOptionalStringSpan(dataIn, dataOut); + vector dataInVec{dataIn.begin(), dataIn.end()}; + test(r == dataOut); + test(r == dataInVec); + } + + { + optional> dataOut; + auto r = prx->opOptionalByteSpan(nullopt, dataOut); + test(r == dataOut); + test(r == nullopt); + } + + { + optional> dataOut; + auto r = prx->opOptionalShortSpan(nullopt, dataOut); + test(r == dataOut); + test(r == nullopt); + } + + { + optional> dataOut; + auto r = prx->opOptionalStringSpan(nullopt, dataOut); + test(r == dataOut); + test(r == nullopt); + } + cout << "ok" << endl; + return prx; } diff --git a/cpp/test/Ice/span/Test.ice b/cpp/test/Ice/span/Test.ice index ed21e9d363f..abda0ad3e53 100644 --- a/cpp/test/Ice/span/Test.ice +++ b/cpp/test/Ice/span/Test.ice @@ -26,9 +26,19 @@ module Test ["cpp:view-type:std::span"] StringSeq dataIn, out ["cpp:view-type:std::span"] StringSeq dataOut); - ["cpp:view-type:std::span"] ByteSeq opOptionalByteSpan( + // Same with optionals + + ["cpp:view-type:std::span"] optional(10) ByteSeq opOptionalByteSpan( ["cpp:view-type:std::span"] optional(1) ByteSeq dataIn, - out ["cpp:view-type:std::span"] ByteSeq dataOut); + out ["cpp:view-type:std::span"] optional(11) ByteSeq dataOut); + + ["cpp:view-type:std::span"] optional(10) ShortSeq opOptionalShortSpan( + ["cpp:view-type:std::span"] optional(1) ShortSeq dataIn, + out ["cpp:view-type:std::span"] optional(11) ShortSeq dataOut); + + ["cpp:view-type:std::span"] optional(10) StringSeq opOptionalStringSpan( + ["cpp:view-type:std::span"] optional(1) StringSeq dataIn, + out ["cpp:view-type:std::span"] optional(11) StringSeq dataOut); void shutdown(); } diff --git a/cpp/test/Ice/span/TestAMD.ice b/cpp/test/Ice/span/TestAMD.ice index efca5549672..e6fe1e0dd00 100644 --- a/cpp/test/Ice/span/TestAMD.ice +++ b/cpp/test/Ice/span/TestAMD.ice @@ -27,9 +27,19 @@ module Test ["cpp:view-type:std::span"] StringSeq dataIn, out ["cpp:view-type:std::span"] StringSeq dataOut); - ["cpp:view-type:std::span"] ByteSeq opOptionalByteSpan( + // Same with optionals + + ["cpp:view-type:std::span"] optional(10) ByteSeq opOptionalByteSpan( ["cpp:view-type:std::span"] optional(1) ByteSeq dataIn, - out ["cpp:view-type:std::span"] ByteSeq dataOut); + out ["cpp:view-type:std::span"] optional(11) ByteSeq dataOut); + + ["cpp:view-type:std::span"] optional(10) ShortSeq opOptionalShortSpan( + ["cpp:view-type:std::span"] optional(1) ShortSeq dataIn, + out ["cpp:view-type:std::span"] optional(11) ShortSeq dataOut); + + ["cpp:view-type:std::span"] optional(10) StringSeq opOptionalStringSpan( + ["cpp:view-type:std::span"] optional(1) StringSeq dataIn, + out ["cpp:view-type:std::span"] optional(11) StringSeq dataOut); void shutdown(); } diff --git a/cpp/test/Ice/span/TestAMDI.cpp b/cpp/test/Ice/span/TestAMDI.cpp index e8a57e0c34f..efd18e82a4d 100644 --- a/cpp/test/Ice/span/TestAMDI.cpp +++ b/cpp/test/Ice/span/TestAMDI.cpp @@ -40,7 +40,27 @@ TestIntfAMDI::opStringSpanAsync( void TestIntfAMDI::opOptionalByteSpanAsync( optional dataIn, - function returnValue, span dataOut)> response, + function> returnValue, optional> dataOut)> response, + function, + const Ice::Current&) +{ + response(dataIn, dataIn); +} + +void +TestIntfAMDI::opOptionalShortSpanAsync( + optional dataIn, + function> returnValue, optional> dataOut)> response, + function, + const Ice::Current&) +{ + response(dataIn, dataIn); +} + +void +TestIntfAMDI::opOptionalStringSpanAsync( + optional dataIn, + function> returnValue, optional> dataOut)> response, function, const Ice::Current&) { @@ -50,8 +70,7 @@ TestIntfAMDI::opOptionalByteSpanAsync( } else { - vector v = {byte{42}}; - response(v, v); + response(nullopt, nullopt); } } diff --git a/cpp/test/Ice/span/TestAMDI.h b/cpp/test/Ice/span/TestAMDI.h index d3ba2977c5b..5b83060f22d 100644 --- a/cpp/test/Ice/span/TestAMDI.h +++ b/cpp/test/Ice/span/TestAMDI.h @@ -30,7 +30,19 @@ class TestIntfAMDI final : public Test::TestIntf void opOptionalByteSpanAsync( std::optional dataIn, - std::function returnValue, std::span dataOut)> response, + std::function> returnValue, std::optional> dataOut)> response, + std::function exception, + const Ice::Current& current) final; + + void opOptionalShortSpanAsync( + std::optional dataIn, + std::function> returnValue, std::optional> dataOut)> response, + std::function exception, + const Ice::Current& current) final; + + void opOptionalStringSpanAsync( + std::optional dataIn, + std::function> returnValue, std::optional> dataOut)> response, std::function exception, const Ice::Current& current) final; diff --git a/cpp/test/Ice/span/TestI.cpp b/cpp/test/Ice/span/TestI.cpp index 1511a27a693..3567e74c43f 100644 --- a/cpp/test/Ice/span/TestI.cpp +++ b/cpp/test/Ice/span/TestI.cpp @@ -28,19 +28,25 @@ TestIntfI::opStringSpan(StringSeq dataIn, StringSeq& dataOut, const Ice::Current return dataOut; } -ByteSeq -TestIntfI::opOptionalByteSpan(optional dataIn, ByteSeq& dataOut, const Ice::Current&) +optional +TestIntfI::opOptionalByteSpan(optional dataIn, optional& dataOut, const Ice::Current&) { - if (dataIn) - { - dataOut = *std::move(dataIn); - return dataOut; - } - else - { - dataOut = {std::byte{42}}; - return dataOut; - } + dataOut = std::move(dataIn); + return dataOut; +} + +optional +TestIntfI::opOptionalShortSpan(optional dataIn, optional& dataOut, const Ice::Current&) +{ + dataOut = std::move(dataIn); + return dataOut; +} + +optional +TestIntfI::opOptionalStringSpan(optional dataIn, optional& dataOut, const Ice::Current&) +{ + dataOut = std::move(dataIn); + return dataOut; } void diff --git a/cpp/test/Ice/span/TestI.h b/cpp/test/Ice/span/TestI.h index 802e4129c06..a79cbe9bcb4 100644 --- a/cpp/test/Ice/span/TestI.h +++ b/cpp/test/Ice/span/TestI.h @@ -16,7 +16,11 @@ class TestIntfI final : public Test::TestIntf Test::StringSeq opStringSpan(Test::StringSeq dataIn, Test::StringSeq& dataOut, const Ice::Current&) final; - Test::ByteSeq opOptionalByteSpan(std::optional dataIn, Test::ByteSeq& dataOut, const Ice::Current&) final; + std::optional opOptionalByteSpan(std::optional dataIn, std::optional& dataOut, const Ice::Current&) final; + + std::optional opOptionalShortSpan(std::optional dataIn, std::optional& dataOut, const Ice::Current&) final; + + std::optional opOptionalStringSpan(std::optional dataIn, std::optional& dataOut, const Ice::Current&) final; void shutdown(const Ice::Current&) final; }; From 35bb0fb90d7ad2acf295c0454d660e221a8416d5 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 19 Mar 2024 16:29:22 -0400 Subject: [PATCH 5/8] gcc fix --- config/Make.rules.Darwin | 2 +- cpp/include/Ice/StreamHelpers.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/Make.rules.Darwin b/config/Make.rules.Darwin index a0948603564..ab6a8b40474 100644 --- a/config/Make.rules.Darwin +++ b/config/Make.rules.Darwin @@ -46,7 +46,7 @@ clang_version = $(shell clang -dumpversion 2>&1 | cut -f1 -d\.) # We use -std=c++20 with clang 15.0 and later. ifeq ($(shell test $(clang_version) -ge 15 && echo yes),yes) - cppflags += -std=c++17 + cppflags += -std=c++20 else cppflags += -std=c++17 endif diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h index 6da03c6a7a3..6efd2e58659 100644 --- a/cpp/include/Ice/StreamHelpers.h +++ b/cpp/include/Ice/StreamHelpers.h @@ -13,8 +13,8 @@ #include #include -#ifdef __cpp_lib_span -# include +#if __has_include() +#include #endif namespace Ice From 7abcfec2c61d444085d174f5776302387f96e505 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Wed, 20 Mar 2024 13:19:32 -0400 Subject: [PATCH 6/8] Add msbuild support --- cpp/msbuild/ice.test.sln | 47 +++++ .../Ice/span/msbuild/client/client.vcxproj | 161 +++++++++++++++++ .../msbuild/client/client.vcxproj.filters | 93 ++++++++++ .../Ice/span/msbuild/client/packages.config | 5 + .../msbuild/collocated/collocated.vcxproj | 163 ++++++++++++++++++ .../collocated/collocated.vcxproj.filters | 99 +++++++++++ .../span/msbuild/collocated/packages.config | 5 + .../Ice/span/msbuild/server/packages.config | 5 + .../Ice/span/msbuild/server/server.vcxproj | 162 +++++++++++++++++ .../msbuild/server/server.vcxproj.filters | 96 +++++++++++ .../span/msbuild/serveramd/packages.config | 5 + .../span/msbuild/serveramd/serveramd.vcxproj | 162 +++++++++++++++++ .../serveramd/serveramd.vcxproj.filters | 96 +++++++++++ 13 files changed, 1099 insertions(+) create mode 100644 cpp/test/Ice/span/msbuild/client/client.vcxproj create mode 100644 cpp/test/Ice/span/msbuild/client/client.vcxproj.filters create mode 100644 cpp/test/Ice/span/msbuild/client/packages.config create mode 100644 cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj create mode 100644 cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj.filters create mode 100644 cpp/test/Ice/span/msbuild/collocated/packages.config create mode 100644 cpp/test/Ice/span/msbuild/server/packages.config create mode 100644 cpp/test/Ice/span/msbuild/server/server.vcxproj create mode 100644 cpp/test/Ice/span/msbuild/server/server.vcxproj.filters create mode 100644 cpp/test/Ice/span/msbuild/serveramd/packages.config create mode 100644 cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj create mode 100644 cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj.filters diff --git a/cpp/msbuild/ice.test.sln b/cpp/msbuild/ice.test.sln index 84c51d76ce7..66ad4b84be3 100644 --- a/cpp/msbuild/ice.test.sln +++ b/cpp/msbuild/ice.test.sln @@ -1114,6 +1114,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\IceStorm\ {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "span", "span", "{1F7C0DCA-55EC-4906-9614-57F41E482721}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\span\msbuild\client\client.vcxproj", "{C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Ice\span\msbuild\server\server.vcxproj", "{9420E497-D3F4-41B0-B4D0-B44F201AE733}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "collocated", "..\test\Ice\span\msbuild\collocated\collocated.vcxproj", "{CE3F4137-F8A0-4488-B67A-A2A5D6225573}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serveramd", "..\test\Ice\span\msbuild\serveramd\serveramd.vcxproj", "{990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -2594,6 +2604,38 @@ Global {7D48DD81-247D-467E-B94C-D23EC94BDAB0}.Release|Win32.Build.0 = Release|Win32 {7D48DD81-247D-467E-B94C-D23EC94BDAB0}.Release|x64.ActiveCfg = Release|x64 {7D48DD81-247D-467E-B94C-D23EC94BDAB0}.Release|x64.Build.0 = Release|x64 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Debug|Win32.ActiveCfg = Debug|Win32 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Debug|Win32.Build.0 = Debug|Win32 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Debug|x64.ActiveCfg = Debug|x64 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Debug|x64.Build.0 = Debug|x64 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Release|Win32.ActiveCfg = Release|Win32 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Release|Win32.Build.0 = Release|Win32 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Release|x64.ActiveCfg = Release|x64 + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}.Release|x64.Build.0 = Release|x64 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Debug|Win32.ActiveCfg = Debug|Win32 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Debug|Win32.Build.0 = Debug|Win32 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Debug|x64.ActiveCfg = Debug|x64 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Debug|x64.Build.0 = Debug|x64 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Release|Win32.ActiveCfg = Release|Win32 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Release|Win32.Build.0 = Release|Win32 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Release|x64.ActiveCfg = Release|x64 + {9420E497-D3F4-41B0-B4D0-B44F201AE733}.Release|x64.Build.0 = Release|x64 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Debug|Win32.ActiveCfg = Debug|Win32 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Debug|Win32.Build.0 = Debug|Win32 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Debug|x64.ActiveCfg = Debug|x64 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Debug|x64.Build.0 = Debug|x64 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Release|Win32.ActiveCfg = Release|Win32 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Release|Win32.Build.0 = Release|Win32 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Release|x64.ActiveCfg = Release|x64 + {CE3F4137-F8A0-4488-B67A-A2A5D6225573}.Release|x64.Build.0 = Release|x64 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Debug|Win32.ActiveCfg = Debug|Win32 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Debug|Win32.Build.0 = Debug|Win32 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Debug|x64.ActiveCfg = Debug|x64 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Debug|x64.Build.0 = Debug|x64 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Release|Win32.ActiveCfg = Release|Win32 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Release|Win32.Build.0 = Release|Win32 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Release|x64.ActiveCfg = Release|x64 + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2868,6 +2910,11 @@ Global {0DDD44E0-E425-47BE-8DAA-06CA0E8704D2} = {C167C995-BD18-4BF1-828E-66F7FA0A6BE6} {372EA6E7-43FD-49F2-A7CB-FC863BAD9E14} = {CEF4EDB3-7782-4B65-9D97-55783C166F4D} {7D48DD81-247D-467E-B94C-D23EC94BDAB0} = {372EA6E7-43FD-49F2-A7CB-FC863BAD9E14} + {1F7C0DCA-55EC-4906-9614-57F41E482721} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC} + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28} = {1F7C0DCA-55EC-4906-9614-57F41E482721} + {9420E497-D3F4-41B0-B4D0-B44F201AE733} = {1F7C0DCA-55EC-4906-9614-57F41E482721} + {CE3F4137-F8A0-4488-B67A-A2A5D6225573} = {1F7C0DCA-55EC-4906-9614-57F41E482721} + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01} = {1F7C0DCA-55EC-4906-9614-57F41E482721} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E6FDB68A-64BA-4577-ABCD-40A01257F8AB} diff --git a/cpp/test/Ice/span/msbuild/client/client.vcxproj b/cpp/test/Ice/span/msbuild/client/client.vcxproj new file mode 100644 index 00000000000..a37e04aad41 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/client/client.vcxproj @@ -0,0 +1,161 @@ + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28} + + + + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + + + + + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/client/client.vcxproj.filters b/cpp/test/Ice/span/msbuild/client/client.vcxproj.filters new file mode 100644 index 00000000000..17ade848b96 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/client/client.vcxproj.filters @@ -0,0 +1,93 @@ + + + + + Source Files + + + Source Files + + + Source Files\x64\Debug + + + Source Files\Win32\Debug + + + Source Files\x64\Release + + + Source Files\Win32\Release + + + + + {8105ca1d-a768-47e9-ab7a-96c34c2fbdac} + + + {6356f48e-b263-4dcb-8e97-1337bfa845f4} + + + {0495825d-dbec-4593-acdd-d3feb280f86b} + ice + + + {9f454c5a-c96a-4c87-bea7-f33b4f8d2c86} + + + {7185b435-f1f8-4d65-bc86-2930f96faf9c} + + + {e0293e38-3b33-4a46-8460-6171c9a83d0f} + + + {71bd269b-739c-40a2-b6e1-e41cf45bec05} + + + {2ea154ca-3837-4d6e-aa49-d5fcb1158440} + + + {54d10c42-3772-4534-b900-bac4e97341ac} + + + {cd541da3-9c36-4923-ad01-4a74acae60b6} + + + {c1cfb0e8-2a70-492d-85a3-417982a612be} + + + {0f24181a-1b36-42da-8712-c33fed2ef1ed} + + + {fcec95e7-6fa9-4c17-94b1-ae713e416242} + + + {0e319f54-33e1-4271-ae96-8b71dfbda357} + + + {b0059172-c4a1-42ec-98a7-6edc769c9ed8} + + + + + Header Files\x64\Debug + + + Header Files\Win32\Debug + + + Header Files\x64\Release + + + Header Files\Win32\Release + + + + + + + + Slice Files + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/client/packages.config b/cpp/test/Ice/span/msbuild/client/packages.config new file mode 100644 index 00000000000..a36cb289a52 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/client/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj b/cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj new file mode 100644 index 00000000000..cdd019bffa8 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj @@ -0,0 +1,163 @@ + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {CE3F4137-F8A0-4488-B67A-A2A5D6225573} + + + + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + + + + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj.filters b/cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj.filters new file mode 100644 index 00000000000..4a1f6406060 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/collocated/collocated.vcxproj.filters @@ -0,0 +1,99 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files\x64\Debug + + + Source Files\Win32\Debug + + + Source Files\x64\Release + + + Source Files\Win32\Release + + + + + {aee0c7a0-abeb-4f8e-a49f-3e17b2ad5ae8} + + + {9e85597e-8cf0-49e6-a4e7-9c778cd8744b} + + + {84f99a0a-0ca3-4300-b1b3-242d277c7538} + ice + + + {093a2357-e211-4dcd-93d1-99e1d788cd42} + + + {885ab2c2-9fa1-4a0c-bfd0-df96764df6bf} + + + {2ae84329-b1ea-480a-91d6-77cafe2b8412} + + + {742a5fae-91fd-486d-8674-e9f27766f666} + + + {2f62796e-f8ba-4436-8433-49def0092f71} + + + {e8ee5ec4-83db-4952-9440-8fdf83d99369} + + + {a5b062d6-0cfd-4119-8974-20c7df6ed99e} + + + {5d143775-261d-49d7-ab29-c2b55b6fc662} + + + {e3cc8211-f499-469b-bf76-a9306afe521e} + + + {5656df30-b2b0-4df2-ac50-817f1787147d} + + + {4e81e6cb-aef1-4c3e-ad09-26f467a405fa} + + + {b7422207-2891-4d7e-9618-da453ed33e53} + + + + + Header Files + + + Header Files\x64\Debug + + + Header Files\Win32\Debug + + + Header Files\x64\Release + + + Header Files\Win32\Release + + + + + + + + Slice Files + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/collocated/packages.config b/cpp/test/Ice/span/msbuild/collocated/packages.config new file mode 100644 index 00000000000..a36cb289a52 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/collocated/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/server/packages.config b/cpp/test/Ice/span/msbuild/server/packages.config new file mode 100644 index 00000000000..a36cb289a52 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/server/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/server/server.vcxproj b/cpp/test/Ice/span/msbuild/server/server.vcxproj new file mode 100644 index 00000000000..9d46c4d3a47 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/server/server.vcxproj @@ -0,0 +1,162 @@ + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {9420E497-D3F4-41B0-B4D0-B44F201AE733} + + + + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + + + + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + true + true + true + ..\..\Test.ice + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/server/server.vcxproj.filters b/cpp/test/Ice/span/msbuild/server/server.vcxproj.filters new file mode 100644 index 00000000000..ab9ab1a06fb --- /dev/null +++ b/cpp/test/Ice/span/msbuild/server/server.vcxproj.filters @@ -0,0 +1,96 @@ + + + + + Source Files + + + Source Files + + + Source Files\x64\Debug + + + Source Files\Win32\Debug + + + Source Files\x64\Release + + + Source Files\Win32\Release + + + + + {b9e87dbb-c804-479d-b949-420ebf58cc43} + + + {5690c6ea-de57-49ce-a998-0111287b41e9} + + + {631f33d9-9e94-41ed-b397-80b1c94e735c} + ice + + + {f087ba95-2f1a-4a5c-bfcc-bb51ed6ee2f2} + + + {29788b93-089e-4887-aa64-9bf4b3392896} + + + {98afe211-747d-4c02-8c3d-6c898403dbe8} + + + {5a8c0c83-5253-47de-ba1a-fb287c1a7126} + + + {510749e2-b9d2-4a36-85df-32a33f3aeb94} + + + {8d158974-38be-455e-894b-65357d8c628b} + + + {37e73980-fccb-44a8-9ca8-f706ede401c0} + + + {c9ec1640-2d2f-4f2a-b99e-ffd5d5b72962} + + + {a6fed86b-a088-44bc-8750-dc88a454baee} + + + {7b715b4e-a1b8-4d42-9b0d-d61ccc517f04} + + + {5408d5ad-939d-40f4-a3fa-5b016cf64b8b} + + + {8f35a987-e85a-4448-80ab-7042c0f2b36b} + + + + + Header Files + + + Header Files\x64\Debug + + + Header Files\Win32\Debug + + + Header Files\x64\Release + + + Header Files\Win32\Release + + + + + + + + Slice Files + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/serveramd/packages.config b/cpp/test/Ice/span/msbuild/serveramd/packages.config new file mode 100644 index 00000000000..a36cb289a52 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/serveramd/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj b/cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj new file mode 100644 index 00000000000..c0b76b1c988 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj @@ -0,0 +1,162 @@ + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {990E8CB2-4A3B-44EA-86C4-FECAC29B9E01} + + + + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + Application + true + $(DefaultPlatformToolset) + + + Application + false + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + + + + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + ..\..;%(AdditionalIncludeDirectories) + + + + + + + + + + true + true + true + ..\..\TestAMD.ice + + + true + true + true + ..\..\TestAMD.ice + + + true + true + true + ..\..\TestAMD.ice + + + true + true + true + ..\..\TestAMD.ice + + + + + + true + true + true + ..\..\TestAMD.ice + + + true + true + true + ..\..\TestAMD.ice + + + true + true + true + ..\..\TestAMD.ice + + + true + true + true + ..\..\TestAMD.ice + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj.filters b/cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj.filters new file mode 100644 index 00000000000..ef913e1a5f7 --- /dev/null +++ b/cpp/test/Ice/span/msbuild/serveramd/serveramd.vcxproj.filters @@ -0,0 +1,96 @@ + + + + + Source Files + + + Source Files + + + Source Files\x64\Debug + + + Source Files\Win32\Debug + + + Source Files\x64\Release + + + Source Files\Win32\Release + + + + + {918433c0-1bdb-4fda-89cc-7c004997aa2f} + + + {915f40f3-dddf-484f-880a-a6f1306c5cc8} + + + {a9e7e716-83cf-41bd-b8b4-4a530981e290} + ice + + + {a7d82ea7-f223-43c9-8699-2ef0599cc607} + + + {736ad4c1-0db0-4aa7-b540-6cf8ae74237f} + + + {0b50609a-94a6-4e40-a9cc-c7c1c5e8d8ff} + + + {370fe038-ee5b-4e9c-a387-a76756eec5ac} + + + {30ee9642-01c5-4737-8e74-f1cbbd230d2b} + + + {5bb450c8-6185-4fe3-9905-3e75850cfe0d} + + + {c81031b6-bc22-406a-b747-4926c1bdd3ea} + + + {72cf1d8b-37df-4a8e-8183-2aed70495c0b} + + + {c3122d37-4a14-436c-bd4e-71005474e906} + + + {64fd6db3-a15e-4dbd-8cbb-265ce9ffed3d} + + + {9da1223e-f2f4-4383-be1f-39f014f1d74d} + + + {5b94b7c8-71e6-4053-b23f-ae592a77c279} + + + + + Header Files + + + Header Files\x64\Debug + + + Header Files\Win32\Debug + + + Header Files\x64\Release + + + Header Files\Win32\Release + + + + + + + + Slice Files + + + \ No newline at end of file From 3ae848b249101e46174dbf482690fdb939cbcded Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Wed, 20 Mar 2024 14:22:35 -0400 Subject: [PATCH 7/8] Reformat --- cpp/include/Ice/StreamHelpers.h | 4 ++-- cpp/src/Glacier2/RequestQueue.cpp | 5 +---- cpp/test/Ice/optional/TestAMDI.cpp | 24 ++++++++---------------- cpp/test/Ice/span/TestAMDI.cpp | 7 ++----- cpp/test/Ice/span/TestAMDI.h | 12 +++++++++--- cpp/test/Ice/span/TestI.h | 19 ++++++++++++++----- python/modules/IcePy/Operation.cpp | 14 +++----------- 7 files changed, 39 insertions(+), 46 deletions(-) diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h index 6efd2e58659..308bd5f7464 100644 --- a/cpp/include/Ice/StreamHelpers.h +++ b/cpp/include/Ice/StreamHelpers.h @@ -14,7 +14,7 @@ #include #if __has_include() -#include +# include #endif namespace Ice @@ -504,7 +504,7 @@ namespace Ice }; #ifdef __cpp_lib_span - /** + /** * Helper for span (C++20 or later). * \headerfile Ice/Ice.h */ diff --git a/cpp/src/Glacier2/RequestQueue.cpp b/cpp/src/Glacier2/RequestQueue.cpp index 9fa3ec8d1b5..80a4d9015a2 100644 --- a/cpp/src/Glacier2/RequestQueue.cpp +++ b/cpp/src/Glacier2/RequestQueue.cpp @@ -322,10 +322,7 @@ Glacier2::RequestQueue::flush() } void -Glacier2::RequestQueue::response( - bool ok, - pair outParams, - const shared_ptr& request) +Glacier2::RequestQueue::response(bool ok, pair outParams, const shared_ptr& request) { assert(request); request->response(ok, outParams); diff --git a/cpp/test/Ice/optional/TestAMDI.cpp b/cpp/test/Ice/optional/TestAMDI.cpp index 9365b0c0bcd..e21610e1387 100644 --- a/cpp/test/Ice/optional/TestAMDI.cpp +++ b/cpp/test/Ice/optional/TestAMDI.cpp @@ -227,8 +227,7 @@ InitialI::opMyInterfaceProxyAsync( void InitialI::opByteSeqAsync( optional> p1, - function>, optional>)> - response, + function>, optional>)> response, function, const Ice::Current&) { @@ -238,8 +237,7 @@ InitialI::opByteSeqAsync( void InitialI::opBoolSeqAsync( optional> p1, - function>, optional>)> - response, + function>, optional>)> response, function, const Ice::Current&) { @@ -249,8 +247,7 @@ InitialI::opBoolSeqAsync( void InitialI::opShortSeqAsync( optional> p1, - function>, optional>)> - response, + function>, optional>)> response, function, const Ice::Current&) { @@ -260,8 +257,7 @@ InitialI::opShortSeqAsync( void InitialI::opIntSeqAsync( optional> p1, - function>, optional>)> - response, + function>, optional>)> response, function, const Ice::Current&) { @@ -271,9 +267,8 @@ InitialI::opIntSeqAsync( void InitialI::opLongSeqAsync( optional> p1, - function>, - optional>)> response, + function>, optional>)> + response, function, const Ice::Current&) { @@ -283,8 +278,7 @@ InitialI::opLongSeqAsync( void InitialI::opFloatSeqAsync( optional> p1, - function>, optional>)> - response, + function>, optional>)> response, function, const Ice::Current&) { @@ -294,9 +288,7 @@ InitialI::opFloatSeqAsync( void InitialI::opDoubleSeqAsync( optional> p1, - function< - void(optional>, optional>)> - response, + function>, optional>)> response, function, const Ice::Current&) { diff --git a/cpp/test/Ice/span/TestAMDI.cpp b/cpp/test/Ice/span/TestAMDI.cpp index efd18e82a4d..e4a40bd811d 100644 --- a/cpp/test/Ice/span/TestAMDI.cpp +++ b/cpp/test/Ice/span/TestAMDI.cpp @@ -14,7 +14,7 @@ TestIntfAMDI::opByteSpanAsync( function, const Ice::Current&) { - response(dataIn, dataIn); + response(dataIn, dataIn); } void @@ -75,10 +75,7 @@ TestIntfAMDI::opOptionalStringSpanAsync( } void -TestIntfAMDI::shutdownAsync( - function response, - function, - const Ice::Current& current) +TestIntfAMDI::shutdownAsync(function response, function, const Ice::Current& current) { current.adapter->getCommunicator()->shutdown(); response(); diff --git a/cpp/test/Ice/span/TestAMDI.h b/cpp/test/Ice/span/TestAMDI.h index 5b83060f22d..86e80be3e1a 100644 --- a/cpp/test/Ice/span/TestAMDI.h +++ b/cpp/test/Ice/span/TestAMDI.h @@ -30,19 +30,25 @@ class TestIntfAMDI final : public Test::TestIntf void opOptionalByteSpanAsync( std::optional dataIn, - std::function> returnValue, std::optional> dataOut)> response, + std::function> returnValue, + std::optional> dataOut)> response, std::function exception, const Ice::Current& current) final; void opOptionalShortSpanAsync( std::optional dataIn, - std::function> returnValue, std::optional> dataOut)> response, + std::function> returnValue, + std::optional> dataOut)> response, std::function exception, const Ice::Current& current) final; void opOptionalStringSpanAsync( std::optional dataIn, - std::function> returnValue, std::optional> dataOut)> response, + std::function< + void(std::optional> returnValue, std::optional> dataOut)> + response, std::function exception, const Ice::Current& current) final; diff --git a/cpp/test/Ice/span/TestI.h b/cpp/test/Ice/span/TestI.h index a79cbe9bcb4..40332015b00 100644 --- a/cpp/test/Ice/span/TestI.h +++ b/cpp/test/Ice/span/TestI.h @@ -16,11 +16,20 @@ class TestIntfI final : public Test::TestIntf Test::StringSeq opStringSpan(Test::StringSeq dataIn, Test::StringSeq& dataOut, const Ice::Current&) final; - std::optional opOptionalByteSpan(std::optional dataIn, std::optional& dataOut, const Ice::Current&) final; - - std::optional opOptionalShortSpan(std::optional dataIn, std::optional& dataOut, const Ice::Current&) final; - - std::optional opOptionalStringSpan(std::optional dataIn, std::optional& dataOut, const Ice::Current&) final; + std::optional opOptionalByteSpan( + std::optional dataIn, + std::optional& dataOut, + const Ice::Current&) final; + + std::optional opOptionalShortSpan( + std::optional dataIn, + std::optional& dataOut, + const Ice::Current&) final; + + std::optional opOptionalStringSpan( + std::optional dataIn, + std::optional& dataOut, + const Ice::Current&) final; void shutdown(const Ice::Current&) final; }; diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp index eebb80eb27b..2dab3767ee5 100644 --- a/python/modules/IcePy/Operation.cpp +++ b/python/modules/IcePy/Operation.cpp @@ -242,9 +242,7 @@ namespace IcePy class BlobjectUpcall final : public Upcall { public: - BlobjectUpcall( - function)>, - function); + BlobjectUpcall(function)>, function); void dispatch(PyObject*, pair, const Ice::Current&) final; void response(PyObject*) final; @@ -2437,10 +2435,7 @@ IcePy::TypedUpcall::TypedUpcall( } void -IcePy::TypedUpcall::dispatch( - PyObject* servant, - pair inBytes, - const Ice::Current& current) +IcePy::TypedUpcall::dispatch(PyObject* servant, pair inBytes, const Ice::Current& current) { _encoding = current.encoding; @@ -2633,10 +2628,7 @@ IcePy::BlobjectUpcall::BlobjectUpcall( } void -IcePy::BlobjectUpcall::dispatch( - PyObject* servant, - pair inBytes, - const Ice::Current& current) +IcePy::BlobjectUpcall::dispatch(PyObject* servant, pair inBytes, const Ice::Current& current) { Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); From de35dbfdd8aa3dd81bfccae523f7af185c718ad5 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Wed, 20 Mar 2024 15:07:07 -0400 Subject: [PATCH 8/8] Add build dependencies for span test --- cpp/msbuild/ice.test.sln | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cpp/msbuild/ice.test.sln b/cpp/msbuild/ice.test.sln index 66ad4b84be3..49af4b113a5 100644 --- a/cpp/msbuild/ice.test.sln +++ b/cpp/msbuild/ice.test.sln @@ -1117,12 +1117,24 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "span", "span", "{1F7C0DCA-55EC-4906-9614-57F41E482721}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\span\msbuild\client\client.vcxproj", "{C1C9DE0E-4DFD-4E60-A04F-02CC305F8A28}" + ProjectSection(ProjectDependencies) = postProject + {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Ice\span\msbuild\server\server.vcxproj", "{9420E497-D3F4-41B0-B4D0-B44F201AE733}" + ProjectSection(ProjectDependencies) = postProject + {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "collocated", "..\test\Ice\span\msbuild\collocated\collocated.vcxproj", "{CE3F4137-F8A0-4488-B67A-A2A5D6225573}" + ProjectSection(ProjectDependencies) = postProject + {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "serveramd", "..\test\Ice\span\msbuild\serveramd\serveramd.vcxproj", "{990E8CB2-4A3B-44EA-86C4-FECAC29B9E01}" + ProjectSection(ProjectDependencies) = postProject + {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution