diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 371f0baeb3f..b9f6a9c029c 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -17,7 +17,15 @@ runs: working-directory: ${{ inputs.working_directory }} run: python3 allTests.py --debug --all --continue --workers=4 --export-xml=test-report.xml ${{ inputs.flags }} shell: bash - if: runner.os == 'macOS' || runner.os == 'Linux' + if: runner.os == 'macOS' + + - name: Test + working-directory: ${{ inputs.working_directory }} + run: | + ulimit -c unlimited + python3 allTests.py --debug --all --continue --workers=4 --export-xml=test-report.xml ${{ inputs.flags }} + shell: bash + if: runner.os == 'Linux' - name: Test working-directory: ${{ inputs.working_directory }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e0cd7db24f..37edfb050f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,6 +128,14 @@ jobs: if-no-files-found: ignore if: always() + - name: Upload Linux core dumps + uses: actions/upload-artifact@v4 + with: + name: core-dumps-${{ matrix.config }}-${{ matrix.os }} + path: /var/lib/apport/coredump/* + if-no-files-found: ignore + if: runner.os == 'Linux' && always() + - name: Upload macOS crash diagnostics uses: actions/upload-artifact@v4 with: diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 6a522128ce2..9d96f79179f 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -34,6 +34,9 @@ "upcalls", "zeroc" ], + "flagWords": [ + "wether" + ], "dictionaries": [ "csharp", "softwareTerms", diff --git a/config/Make.rules.Linux b/config/Make.rules.Linux index feaef93f754..ffc383670d8 100644 --- a/config/Make.rules.Linux +++ b/config/Make.rules.Linux @@ -35,19 +35,28 @@ else ifneq ($(and $(filter centos rhel fedora,$(linux_id)),$(filter x86_64 i%86, supported-platforms = x64 x86 multilib-platform = yes +# We filter out -m32, -m64, because Slice compilers are always build as 64bit executables, and we set +# the correct value for each arch build below. We also filter out -march setting to ensure our x86 builds +# target x86-64 capable processor. + ifeq ($(OPTIMIZE),yes) # Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined. -# NOTE: We remove the -m32/-m64 flags since we'll add them below. -opt-cppflags = $(if $(CXXFLAGS),,$(filter-out -m32 -m64,$(shell setarch $1 rpm --eval %optflags))) +opt-cppflags = $(if $(CXXFLAGS),,$(filter-out -m32 -m64 -march=%,$(shell setarch $1 rpm --eval %optflags))) opt-ldflags = $(if $(LDFLAGS),,$(shell setarch $1 rpm --eval %?__global_ldflags)) endif -x64_cppflags := $(call opt-cppflags,x86_64) -m64 +CXXFLAGS := $(filter-out -m32 -m64 -march=%, $(CXXFLAGS)) +LDFLAGS := $(filter-out -m32 -m64, $(LDFLAGS)) + +# Targeting x86-64-v2, compatible with most x86-64 processors. This matches the defaults in RHEL 9 x86-64 builds. +# https://developers.redhat.com/blog/2021/01/05/building-red-hat-enterprise-linux-9-for-the-x86-64-v2-microarchitecture-level + +x64_cppflags := $(call opt-cppflags,x86_64) -m64 -march=x86-64-v2 x64_ldflags := $(call opt-ldflags,x86_64) -m64 x64_targetdir = $(if $(filter %/build,$5),/x64,$(if $(filter-out $($1_target),program),64)) x64_installdir = $(if $(and $(filter-out $($1_target),program),$(if $5,$(filter-out %64,$5),true)),64) -x86_cppflags := $(call opt-cppflags,i386) -m32 +x86_cppflags := $(call opt-cppflags,i386) -m32 -march=x86-64-v2 x86_ldflags := $(call opt-ldflags,i386) -m32 x86_targetdir = $(if $(filter %/build,$5),/x86) x86_targetname = $(if $(is-bin-program),32) diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index a0dd7e84b73..7836f952aad 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -409,6 +409,11 @@ + + + + + diff --git a/cpp/include/DataStorm/DataStorm.h b/cpp/include/DataStorm/DataStorm.h index 1580eee74aa..19c5ae5fb82 100644 --- a/cpp/include/DataStorm/DataStorm.h +++ b/cpp/include/DataStorm/DataStorm.h @@ -272,7 +272,7 @@ namespace DataStorm void waitForUnread(unsigned int count = 1) const; /** - * Returns wether or not unread samples are available. + * Returns whether or not unread samples are available. * * @return True if there unread samples are queued, false otherwise. */ diff --git a/cpp/include/Ice/Connection.h b/cpp/include/Ice/Connection.h index fdf38d71070..3f6940386e8 100644 --- a/cpp/include/Ice/Connection.h +++ b/cpp/include/Ice/Connection.h @@ -17,14 +17,6 @@ #include #include -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace Ice { /** @@ -50,57 +42,6 @@ namespace Ice * A collection of HTTP headers. */ using HeaderDict = std::map; -} - -namespace Ice -{ - /** - * Base class providing access to the connection details. - * \headerfile Ice/Ice.h - */ - class ICE_API ConnectionInfo - { - public: - ConnectionInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - */ - ConnectionInfo(ConnectionInfoPtr underlying, bool incoming, std::string adapterName, std::string connectionId) - : underlying(std::move(underlying)), - incoming(incoming), - adapterName(std::move(adapterName)), - connectionId(std::move(connectionId)) - { - } - - virtual ~ConnectionInfo(); - - // Deleted to prevent accidental slicing. - ConnectionInfo(const ConnectionInfo&) = delete; - ConnectionInfo& operator=(const ConnectionInfo&) = delete; - - /** - * The information of the underlying transport or null if there's no underlying transport. - */ - ConnectionInfoPtr underlying; - /** - * Whether or not the connection is an incoming or outgoing connection. - */ - bool incoming; - /** - * The name of the adapter associated with the connection. - */ - std::string adapterName; - /** - * The connection id. - */ - std::string connectionId; - }; /** * This method is called by the connection when the connection is closed. If the callback needs more information @@ -259,45 +200,45 @@ namespace Ice }; /** - * Provides access to the connection details of an IP connection + * Base class providing access to the connection details. * \headerfile Ice/Ice.h */ - class ICE_API IPConnectionInfo : public ConnectionInfo + class ICE_API ConnectionInfo { public: - IPConnectionInfo() : localAddress(""), localPort(-1), remoteAddress(""), remotePort(-1) {} - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param localAddress The local address. - * @param localPort The local port. - * @param remoteAddress The remote address. - * @param remotePort The remote port. - */ - IPConnectionInfo( - ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - std::string localAddress, - int localPort, - std::string remoteAddress, - int remotePort) - : ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - localAddress(std::move(localAddress)), - localPort(localPort), - remoteAddress(std::move(remoteAddress)), - remotePort(remotePort) - { - } - - ~IPConnectionInfo() override; + ConnectionInfo() = default; + virtual ~ConnectionInfo(); // Deleted to prevent accidental slicing. + ConnectionInfo(const ConnectionInfo&) = delete; + ConnectionInfo& operator=(const ConnectionInfo&) = delete; + + /** + * The information of the underlying transport or null if there's no underlying transport. + */ + ConnectionInfoPtr underlying; + /** + * Whether or not the connection is an incoming or outgoing connection. + */ + bool incoming; + /** + * The name of the adapter associated with the connection. + */ + std::string adapterName; + /** + * The connection id. + */ + std::string connectionId; + }; + + /** + * Provides access to the connection details of an IP connection + * \headerfile Ice/Ice.h + */ + class ICE_API IPConnectionInfo : public ConnectionInfo + { + public: + IPConnectionInfo() = default; IPConnectionInfo(const IPConnectionInfo&) = delete; IPConnectionInfo& operator=(const IPConnectionInfo&) = delete; @@ -323,52 +264,11 @@ namespace Ice * Provides access to the connection details of a TCP connection * \headerfile Ice/Ice.h */ - class ICE_API TCPConnectionInfo : public IPConnectionInfo + class ICE_API TCPConnectionInfo final : public IPConnectionInfo { public: - TCPConnectionInfo() : rcvSize(0), sndSize(0) {} - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param localAddress The local address. - * @param localPort The local port. - * @param remoteAddress The remote address. - * @param remotePort The remote port. - * @param rcvSize The connection buffer receive size. - * @param sndSize The connection buffer send size. - */ - TCPConnectionInfo( - ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - std::string localAddress, - int localPort, - std::string remoteAddress, - int remotePort, - int rcvSize, - int sndSize) - : IPConnectionInfo( - std::move(underlying), - incoming, - std::move(adapterName), - std::move(connectionId), - std::move(localAddress), - localPort, - std::move(remoteAddress), - remotePort), - rcvSize(rcvSize), - sndSize(sndSize) - { - } - - ~TCPConnectionInfo() override; - - // Deleted to prevent accidental slicing. + TCPConnectionInfo() = default; + ~TCPConnectionInfo() final; TCPConnectionInfo(const TCPConnectionInfo&) = delete; TCPConnectionInfo& operator=(const TCPConnectionInfo&) = delete; @@ -386,58 +286,11 @@ namespace Ice * Provides access to the connection details of a UDP connection * \headerfile Ice/Ice.h */ - class ICE_API UDPConnectionInfo : public IPConnectionInfo + class ICE_API UDPConnectionInfo final : public IPConnectionInfo { public: - UDPConnectionInfo() : mcastPort(-1), rcvSize(0), sndSize(0) {} - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param localAddress The local address. - * @param localPort The local port. - * @param remoteAddress The remote address. - * @param remotePort The remote port. - * @param mcastAddress The multicast address. - * @param mcastPort The multicast port. - * @param rcvSize The connection buffer receive size. - * @param sndSize The connection buffer send size. - */ - UDPConnectionInfo( - ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - std::string localAddress, - int localPort, - std::string remoteAddress, - int remotePort, - std::string mcastAddress, - int mcastPort, - int rcvSize, - int sndSize) - : IPConnectionInfo( - std::move(underlying), - incoming, - std::move(adapterName), - std::move(connectionId), - std::move(localAddress), - localPort, - std::move(remoteAddress), - remotePort), - mcastAddress(std::move(mcastAddress)), - mcastPort(mcastPort), - rcvSize(rcvSize), - sndSize(sndSize) - { - } - - ~UDPConnectionInfo() override; - - // Deleted to prevent accidental slicing. + UDPConnectionInfo() = default; + ~UDPConnectionInfo() final; UDPConnectionInfo(const UDPConnectionInfo&) = delete; UDPConnectionInfo& operator=(const UDPConnectionInfo&) = delete; @@ -463,33 +316,11 @@ namespace Ice * Provides access to the connection details of a WebSocket connection * \headerfile Ice/Ice.h */ - class ICE_API WSConnectionInfo : public ConnectionInfo + class ICE_API WSConnectionInfo final : public ConnectionInfo { public: WSConnectionInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param headers The headers from the HTTP upgrade request. - */ - WSConnectionInfo( - ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - HeaderDict headers) - : ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - headers(std::move(headers)) - { - } - - ~WSConnectionInfo() override; - - // Deleted to prevent accidental slicing. + ~WSConnectionInfo() final; WSConnectionInfo(const WSConnectionInfo&) = delete; WSConnectionInfo& operator=(const WSConnectionInfo&) = delete; @@ -500,10 +331,4 @@ namespace Ice }; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/Ice/Endpoint.h b/cpp/include/Ice/Endpoint.h index b0ff1eb1aa7..2089e1818c1 100644 --- a/cpp/include/Ice/Endpoint.h +++ b/cpp/include/Ice/Endpoint.h @@ -9,41 +9,48 @@ #include "Ice/Version.h" #include - -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif +#include namespace Ice { /** - * Base class providing access to the endpoint details. + * The user-level interface to an endpoint. * \headerfile Ice/Ice.h */ - class ICE_API EndpointInfo + class ICE_API Endpoint { public: - EndpointInfo() = default; + Endpoint() = default; + virtual ~Endpoint(); + + Endpoint(const Endpoint&) = delete; + Endpoint& operator=(const Endpoint&) = delete; + + virtual bool operator==(const Endpoint&) const = 0; + virtual bool operator<(const Endpoint&) const = 0; /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. + * Return a string representation of the endpoint. + * @return The string representation of the endpoint. */ - EndpointInfo(EndpointInfoPtr underlying, int timeout, bool compress) - : underlying(std::move(underlying)), - timeout(timeout), - compress(compress) - { - } + virtual std::string toString() const noexcept = 0; - virtual ~EndpointInfo(); + /** + * Returns the endpoint information. + * @return The endpoint information class. + */ + virtual EndpointInfoPtr getInfo() const noexcept = 0; + }; + /** + * Base class providing access to the endpoint details. + * \headerfile Ice/Ice.h + */ + class ICE_API EndpointInfo + { + public: + EndpointInfo() = default; + virtual ~EndpointInfo(); EndpointInfo(const EndpointInfo&) = delete; EndpointInfo& operator=(const EndpointInfo&) = delete; @@ -78,35 +85,6 @@ namespace Ice bool compress; }; - /** - * The user-level interface to an endpoint. - * \headerfile Ice/Ice.h - */ - class ICE_API Endpoint - { - public: - Endpoint() = default; - virtual ~Endpoint(); - - Endpoint(const Endpoint&) = delete; - Endpoint& operator=(const Endpoint&) = delete; - - virtual bool operator==(const Endpoint&) const = 0; - virtual bool operator<(const Endpoint&) const = 0; - - /** - * Return a string representation of the endpoint. - * @return The string representation of the endpoint. - */ - virtual std::string toString() const noexcept = 0; - - /** - * Returns the endpoint information. - * @return The endpoint information class. - */ - virtual EndpointInfoPtr getInfo() const noexcept = 0; - }; - /** * Provides access to the address details of a IP endpoint. * @see Endpoint @@ -116,32 +94,6 @@ namespace Ice { public: IPEndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param host The host or address configured with the endpoint. - * @param port The port number. - * @param sourceAddress The source IP address. - */ - IPEndpointInfo( - EndpointInfoPtr underlying, - int timeout, - bool compress, - std::string host, - int port, - std::string sourceAddress) - : EndpointInfo(std::move(underlying), timeout, compress), - host(std::move(host)), - port(port), - sourceAddress(std::move(sourceAddress)) - { - } - - ~IPEndpointInfo() override; - IPEndpointInfo(const IPEndpointInfo&) = delete; IPEndpointInfo& operator=(const IPEndpointInfo&) = delete; @@ -168,29 +120,6 @@ namespace Ice { public: TCPEndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param host The host or address configured with the endpoint. - * @param port The port number. - * @param sourceAddress The source IP address. - */ - TCPEndpointInfo( - EndpointInfoPtr underlying, - int timeout, - bool compress, - std::string host, - int port, - std::string sourceAddress) - : IPEndpointInfo(std::move(underlying), timeout, compress, std::move(host), port, std::move(sourceAddress)) - { - } - - ~TCPEndpointInfo() override; - TCPEndpointInfo(const TCPEndpointInfo&) = delete; TCPEndpointInfo& operator=(const TCPEndpointInfo&) = delete; }; @@ -204,35 +133,6 @@ namespace Ice { public: UDPEndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param host The host or address configured with the endpoint. - * @param port The port number. - * @param sourceAddress The source IP address. - * @param mcastInterface The multicast interface. - * @param mcastTtl The multicast time-to-live (or hops). - */ - UDPEndpointInfo( - EndpointInfoPtr underlying, - int timeout, - bool compress, - std::string host, - int port, - std::string sourceAddress, - std::string mcastInterface, - int mcastTtl) - : IPEndpointInfo(std::move(underlying), timeout, compress, std::move(host), port, std::move(sourceAddress)), - mcastInterface(std::move(mcastInterface)), - mcastTtl(mcastTtl) - { - } - - ~UDPEndpointInfo() override; - UDPEndpointInfo(const UDPEndpointInfo&) = delete; UDPEndpointInfo& operator=(const UDPEndpointInfo&) = delete; @@ -254,22 +154,6 @@ namespace Ice { public: WSEndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param resource The URI configured with the endpoint. - */ - WSEndpointInfo(EndpointInfoPtr underlying, int timeout, bool compress, std::string resource) - : EndpointInfo(std::move(underlying), timeout, compress), - resource(std::move(resource)) - { - } - - ~WSEndpointInfo() override; - WSEndpointInfo(const WSEndpointInfo&) = delete; WSEndpointInfo& operator=(const WSEndpointInfo&) = delete; @@ -288,29 +172,6 @@ namespace Ice { public: OpaqueEndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param rawEncoding The encoding version of the opaque endpoint (to decode or encode the rawBytes). - * @param rawBytes The raw encoding of the opaque endpoint. - */ - OpaqueEndpointInfo( - EndpointInfoPtr underlying, - int timeout, - bool compress, - EncodingVersion rawEncoding, - std::vector rawBytes) - : EndpointInfo(std::move(underlying), timeout, compress), - rawEncoding(std::move(rawEncoding)), - rawBytes(std::move(rawBytes)) - { - } - - ~OpaqueEndpointInfo() override; - OpaqueEndpointInfo(const OpaqueEndpointInfo&) = delete; OpaqueEndpointInfo& operator=(const OpaqueEndpointInfo&) = delete; @@ -325,10 +186,4 @@ namespace Ice }; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/Ice/SSL/ConnectionInfo.h b/cpp/include/Ice/SSL/ConnectionInfo.h index c6f4293ca07..d1aa5b9d3e0 100644 --- a/cpp/include/Ice/SSL/ConnectionInfo.h +++ b/cpp/include/Ice/SSL/ConnectionInfo.h @@ -13,14 +13,6 @@ // `#if defined(ICE_USE_XXX)/#endif` directives are used to include the appropriate structure based on the platform. We // avoid using `#elif` directives because, we want to define all the classes when building the doxygen documentation. -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace Ice::SSL { #if defined(ICE_USE_SCHANNEL) @@ -37,28 +29,7 @@ namespace Ice::SSL { public: SchannelConnectionInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param peerCertificate The peer certificate. - */ - SchannelConnectionInfo( - Ice::ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - PCCERT_CONTEXT peerCertificate) - : Ice::ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - peerCertificate(peerCertificate) - { - } - - ~SchannelConnectionInfo() override; - + ~SchannelConnectionInfo() final; SchannelConnectionInfo(const SchannelConnectionInfo&) = delete; SchannelConnectionInfo& operator=(const SchannelConnectionInfo&) = delete; @@ -83,28 +54,7 @@ namespace Ice::SSL { public: SecureTransportConnectionInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param peerCertificate The peer certificate. - */ - SecureTransportConnectionInfo( - Ice::ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - SecCertificateRef peerCertificate) - : Ice::ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - peerCertificate(peerCertificate) - { - } - - ~SecureTransportConnectionInfo() override; - + ~SecureTransportConnectionInfo() final; SecureTransportConnectionInfo(const SecureTransportConnectionInfo&) = delete; SecureTransportConnectionInfo& operator=(const SecureTransportConnectionInfo&) = delete; @@ -129,28 +79,7 @@ namespace Ice::SSL { public: OpenSSLConnectionInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param peerCertificate The peer certificate. - */ - OpenSSLConnectionInfo( - Ice::ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - X509* peerCertificate) - : Ice::ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - peerCertificate(peerCertificate) - { - } - - ~OpenSSLConnectionInfo() override; - + ~OpenSSLConnectionInfo() final; OpenSSLConnectionInfo(const OpenSSLConnectionInfo&) = delete; OpenSSLConnectionInfo& operator=(const OpenSSLConnectionInfo&) = delete; @@ -162,10 +91,4 @@ namespace Ice::SSL #endif } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/Ice/SSL/EndpointInfo.h b/cpp/include/Ice/SSL/EndpointInfo.h index 7aad0736256..9e0955a4140 100644 --- a/cpp/include/Ice/SSL/EndpointInfo.h +++ b/cpp/include/Ice/SSL/EndpointInfo.h @@ -7,14 +7,6 @@ #include "../Endpoint.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace Ice::SSL { /** @@ -24,20 +16,6 @@ namespace Ice::SSL { public: EndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - */ - EndpointInfo(Ice::EndpointInfoPtr underlying, int timeout, bool compress) - : Ice::EndpointInfo(std::move(underlying), timeout, compress) - { - } - - ~EndpointInfo() override; - EndpointInfo(const EndpointInfo&) = delete; EndpointInfo& operator=(const EndpointInfo&) = delete; }; @@ -45,10 +23,4 @@ namespace Ice::SSL using EndpointInfoPtr = std::shared_ptr; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/Ice/ios/iAPConnectionInfo.h b/cpp/include/Ice/ios/iAPConnectionInfo.h index c77de4bd2bb..aa5c14e45c1 100644 --- a/cpp/include/Ice/ios/iAPConnectionInfo.h +++ b/cpp/include/Ice/ios/iAPConnectionInfo.h @@ -7,61 +7,17 @@ #include "../Connection.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace IceIAP { /** * Provides access to the connection details of an IAP connection * \headerfile Ice/Ice.h */ - class ConnectionInfo : public Ice::ConnectionInfo + class ConnectionInfo final : public Ice::ConnectionInfo { public: ConnectionInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param name The accessory name. - * @param manufacturer The accessory manufacturer. - * @param modelNumber The accessory model number. - * @param firmwareRevision The accessory firmware revision. - * @param hardwareRevision The accessory hardware revision. - * @param protocol The protocol used by the accessory. - */ - ConnectionInfo( - Ice::ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - std::string name, - std::string manufacturer, - std::string modelNumber, - std::string firmwareRevision, - std::string hardwareRevision, - std::string protocol) - : Ice::ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - name(std::move(name)), - manufacturer(std::move(manufacturer)), - modelNumber(std::move(modelNumber)), - firmwareRevision(std::move(firmwareRevision)), - hardwareRevision(std::move(hardwareRevision)), - protocol(std::move(protocol)) - { - } - - ~ConnectionInfo() override; - + ~ConnectionInfo() final; ConnectionInfo(const ConnectionInfo&) = delete; ConnectionInfo& operator=(const ConnectionInfo&) = delete; @@ -94,10 +50,4 @@ namespace IceIAP using ConnectionInfoPtr = std::shared_ptr; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/Ice/ios/iAPEndpointInfo.h b/cpp/include/Ice/ios/iAPEndpointInfo.h index efd45ff881b..57ec7ad2a0b 100644 --- a/cpp/include/Ice/ios/iAPEndpointInfo.h +++ b/cpp/include/Ice/ios/iAPEndpointInfo.h @@ -7,14 +7,6 @@ #include "../Endpoint.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace IceIAP { /** @@ -25,35 +17,6 @@ namespace IceIAP { public: EndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint of null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param manufacturer The accessory manufacturer or empty to not match against a manufacturer. - * @param modelNumber The accessory model number or empty to not match against a model number. - * @param name The accessory name or empty to not match against the accessory name. - * @param protocol The protocol supported by the accessory. - */ - EndpointInfo( - Ice::EndpointInfoPtr underlying, - int timeout, - bool compress, - std::string manufacturer, - std::string modelNumber, - std::string name, - std::string protocol) - : Ice::EndpointInfo(std::move(underlying), timeout, compress), - manufacturer(std::move(manufacturer)), - modelNumber(std::move(modelNumber)), - name(std::move(name)), - protocol(std::move(protocol)) - { - } - - ~EndpointInfo() override; - EndpointInfo(const EndpointInfo&) = delete; EndpointInfo& operator=(const EndpointInfo&) = delete; @@ -81,10 +44,4 @@ namespace IceIAP using EndpointInfoPtr = std::shared_ptr; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/IceBT/ConnectionInfo.h b/cpp/include/IceBT/ConnectionInfo.h index 748994299b3..fa7640542ce 100644 --- a/cpp/include/IceBT/ConnectionInfo.h +++ b/cpp/include/IceBT/ConnectionInfo.h @@ -8,14 +8,6 @@ #include "Ice/Connection.h" #include "Types.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace IceBT { /** @@ -25,59 +17,11 @@ namespace IceBT class ICEBT_API ConnectionInfo : public Ice::ConnectionInfo { public: - ConnectionInfo() - : localAddress(""), - localChannel(-1), - remoteAddress(""), - remoteChannel(-1), - uuid(""), - rcvSize(0), - sndSize(0) - { - } - - ~ConnectionInfo() override; - + ConnectionInfo() = default; + ~ConnectionInfo() final; ConnectionInfo(const ConnectionInfo&) = delete; ConnectionInfo& operator=(const ConnectionInfo&) = delete; - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - * @param localAddress The local Bluetooth address. - * @param localChannel The local RFCOMM channel. - * @param remoteAddress The remote Bluetooth address. - * @param remoteChannel The remote RFCOMM channel. - * @param uuid The UUID of the service being offered (in a server) or targeted (in a client). - * @param rcvSize The connection buffer receive size. - * @param sndSize The connection buffer send size. - */ - ConnectionInfo( - Ice::ConnectionInfoPtr underlying, - bool incoming, - std::string adapterName, - std::string connectionId, - std::string localAddress, - int localChannel, - std::string remoteAddress, - int remoteChannel, - std::string uuid, - int rcvSize, - int sndSize) - : Ice::ConnectionInfo(std::move(underlying), incoming, std::move(adapterName), std::move(connectionId)), - localAddress(std::move(localAddress)), - localChannel(localChannel), - remoteAddress(std::move(remoteAddress)), - remoteChannel(remoteChannel), - uuid(std::move(uuid)), - rcvSize(rcvSize), - sndSize(sndSize) - { - } - /** * The local Bluetooth address. */ @@ -111,10 +55,4 @@ namespace IceBT using ConnectionInfoPtr = std::shared_ptr; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/include/IceBT/EndpointInfo.h b/cpp/include/IceBT/EndpointInfo.h index a21b63d8aa5..31564120e1c 100644 --- a/cpp/include/IceBT/EndpointInfo.h +++ b/cpp/include/IceBT/EndpointInfo.h @@ -8,14 +8,6 @@ #include "Ice/Endpoint.h" #include "Types.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace IceBT { /** @@ -26,24 +18,6 @@ namespace IceBT { public: EndpointInfo() = default; - - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param addr The address configured with the endpoint. - * @param uuid The UUID configured with the endpoint. - */ - EndpointInfo(Ice::EndpointInfoPtr underlying, int timeout, bool compress, std::string addr, std::string uuid) - : Ice::EndpointInfo(std::move(underlying), timeout, compress), - addr(std::move(addr)), - uuid(std::move(uuid)) - { - } - - ~EndpointInfo() override; - EndpointInfo(const EndpointInfo&) = delete; EndpointInfo& operator=(const EndpointInfo&) = delete; @@ -60,10 +34,4 @@ namespace IceBT using EndpointInfoPtr = std::shared_ptr; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/src/DataStorm/DataElementI.cpp b/cpp/src/DataStorm/DataElementI.cpp index b8058b7e217..fa88d300e93 100644 --- a/cpp/src/DataStorm/DataElementI.cpp +++ b/cpp/src/DataStorm/DataElementI.cpp @@ -178,7 +178,8 @@ DataElementI::attach( session->subscriberInitialized(topicId, id > 0 ? data.id : -data.id, data.samples, key, shared_from_this()); if (!samplesI.empty()) { - return [=, this]() { initSamples(samplesI, topicId, data.id, priority, now, id < 0); }; + return [=, self = shared_from_this()]() + { self->initSamples(samplesI, topicId, data.id, priority, now, id < 0); }; } return nullptr; } diff --git a/cpp/src/DataStorm/NodeI.cpp b/cpp/src/DataStorm/NodeI.cpp index 345ede60d5b..c528b40acf6 100644 --- a/cpp/src/DataStorm/NodeI.cpp +++ b/cpp/src/DataStorm/NodeI.cpp @@ -184,22 +184,20 @@ NodeI::createSession( return; // Shutting down or already connected } - auto self = shared_from_this(); s->ice_getConnectionAsync( - [=, this](auto connection) mutable + [=, self = shared_from_this()](auto connection) mutable { if (session->checkSession()) { return; } - if (connection && !connection->getAdapter()) - { - connection->setAdapter(getInstance()->getObjectAdapter()); - } - if (connection) { + if (!connection->getAdapter()) + { + connection->setAdapter(self->getInstance()->getObjectAdapter()); + } subscriberSession = subscriberSession->ice_fixed(connection); } @@ -207,22 +205,26 @@ NodeI::createSession( { // Must be called before connected s->confirmCreateSessionAsync( - _proxy, + self->_proxy, session->getProxy(), nullptr, - [=](auto ex) { self->removePublisherSession(*subscriber, session, ex); }); + [self, subscriber, session](auto ex) + { self->removePublisherSession(*subscriber, session, ex); }); assert(!s->ice_getCachedConnection() || s->ice_getCachedConnection() == connection); + + // Session::connected informs the subscriber session of all the topic writers in the current node. session->connected( *subscriberSession, connection, - getInstance()->getTopicFactory()->getTopicWriters()); + self->getInstance()->getTopicFactory()->getTopicWriters()); } catch (const Ice::LocalException&) { - removePublisherSession(*subscriber, session, current_exception()); + self->removePublisherSession(*subscriber, session, current_exception()); } }, - [=](auto ex) { self->removePublisherSession(*subscriber, session, ex); }); + [self = shared_from_this(), subscriber, session](auto ex) + { self->removePublisherSession(*subscriber, session, ex); }); } catch (const Ice::LocalException&) { @@ -257,47 +259,40 @@ NodeI::confirmCreateSession( publisherSession = publisherSession->ice_fixed(current.con); } + // Session::connected informs the publisher session of all the topic readers in the current node. session->connected(*publisherSession, current.con, getInstance()->getTopicFactory()->getTopicReaders()); } void NodeI::createSubscriberSession( NodePrx subscriber, - const Ice::ConnectionPtr& connection, + const Ice::ConnectionPtr& subscriberConnection, const shared_ptr& session) { auto instance = _instance.lock(); if (!instance) { - // Ignore the Node is being destroyed. + // Ignore the Node is being shutdown. return; } try { - subscriber = getNodeWithExistingConnection(std::move(instance), subscriber, connection); + subscriber = getNodeWithExistingConnection(std::move(instance), subscriber, subscriberConnection); - auto self = shared_from_this(); -#if defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif subscriber->ice_getConnectionAsync( - [=, this](auto connection) + [=, self = shared_from_this()](auto connection) { if (connection && !connection->getAdapter()) { - connection->setAdapter(getInstance()->getObjectAdapter()); + connection->setAdapter(self->getInstance()->getObjectAdapter()); } subscriber->initiateCreateSessionAsync( - _proxy, + self->_proxy, nullptr, [=](auto ex) { self->removePublisherSession(subscriber, session, ex); }); }, - [=](auto ex) { self->removePublisherSession(subscriber, session, ex); }); -#if defined(__GNUC__) -# pragma GCC diagnostic pop -#endif + [=, self = shared_from_this()](auto ex) { self->removePublisherSession(subscriber, session, ex); }); } catch (const Ice::LocalException&) { @@ -306,18 +301,21 @@ NodeI::createSubscriberSession( } void -NodeI::createPublisherSession(NodePrx publisher, const Ice::ConnectionPtr& con, shared_ptr session) +NodeI::createPublisherSession( + NodePrx publisher, + const Ice::ConnectionPtr& publisherConnection, + shared_ptr session) { auto instance = _instance.lock(); if (!instance) { - // Ignore the Node is being destroyed. + // Ignore the Node is being shutdown. return; } try { - auto p = getNodeWithExistingConnection(std::move(instance), publisher, con); + auto p = getNodeWithExistingConnection(std::move(instance), publisher, publisherConnection); unique_lock lock(_mutex); if (!session) @@ -329,9 +327,8 @@ NodeI::createPublisherSession(NodePrx publisher, const Ice::ConnectionPtr& con, } } - auto self = shared_from_this(); p->ice_getConnectionAsync( - [=, this](auto connection) + [=, self = shared_from_this()](auto connection) { if (session->checkSession()) { @@ -340,13 +337,13 @@ NodeI::createPublisherSession(NodePrx publisher, const Ice::ConnectionPtr& con, if (connection && !connection->getAdapter()) { - connection->setAdapter(getInstance()->getObjectAdapter()); + connection->setAdapter(self->getInstance()->getObjectAdapter()); } try { p->createSessionAsync( - _proxy, + self->_proxy, session->getProxy(), false, nullptr, @@ -354,10 +351,11 @@ NodeI::createPublisherSession(NodePrx publisher, const Ice::ConnectionPtr& con, } catch (const Ice::LocalException&) { - removeSubscriberSession(publisher, session, current_exception()); + self->removeSubscriberSession(publisher, session, current_exception()); } }, - [=](exception_ptr ex) { self->removeSubscriberSession(publisher, session, ex); }); + [=, self = shared_from_this()](exception_ptr ex) + { self->removeSubscriberSession(publisher, session, ex); }); } catch (const Ice::LocalException&) { diff --git a/cpp/src/DataStorm/NodeSessionManager.cpp b/cpp/src/DataStorm/NodeSessionManager.cpp index dd84cc3d50c..3f1cd19ec9e 100644 --- a/cpp/src/DataStorm/NodeSessionManager.cpp +++ b/cpp/src/DataStorm/NodeSessionManager.cpp @@ -112,8 +112,7 @@ NodeSessionManager::createOrGet(NodePrx node, const Ice::ConnectionPtr& connecti session->init(); _sessions.emplace(node->ice_getIdentity(), session); - // TODO we should review this code, to avoid using the proxy shared_ptr as a map key. - // Specially the connection manager doesn't use this proxy for lookup. + // Register a callback with the connection manager to destroy the session when the connection is closed. instance->getConnectionManager()->add( connection, make_shared(node), @@ -306,6 +305,13 @@ NodeSessionManager::forward(const Ice::ByteSeq& inParams, const Ice::Current& cu void NodeSessionManager::connect(LookupPrx lookup, NodePrx proxy) { + auto instance = _instance.lock(); + if (!instance) + { + // Ignore the Node is being shutdown. + return; + } + try { lookup->createSessionAsync( @@ -326,6 +332,10 @@ NodeSessionManager::connect(LookupPrx lookup, NodePrx proxy) [=, self = shared_from_this()](std::exception_ptr) { self->disconnected(lookup); }); } catch (const Ice::CommunicatorDestroyedException&) + { + // Ignore node is being shutdown. + } + catch (const std::exception&) { disconnected(lookup); } @@ -338,6 +348,7 @@ NodeSessionManager::connected(NodePrx node, LookupPrx lookup) auto instance = _instance.lock(); if (!instance) { + // Ignore the Node is being shutdown. return; } @@ -376,6 +387,7 @@ NodeSessionManager::connected(NodePrx node, LookupPrx lookup) } catch (const Ice::CommunicatorDestroyedException&) { + // Ignore node is being shutdown. } } } @@ -407,21 +419,7 @@ NodeSessionManager::disconnected(LookupPrx lookup) if (instance) { instance->scheduleTimerTask( - [=, self = shared_from_this()] - { -#if defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - auto instance = self->_instance.lock(); - if (instance) - { - self->connect(lookup, self->_nodePrx); - } -#if defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - }, + [=, self = shared_from_this()] { self->connect(lookup, self->_nodePrx); }, instance->getRetryDelay(_retryCount++)); } } diff --git a/cpp/src/DataStorm/SessionI.cpp b/cpp/src/DataStorm/SessionI.cpp index 7b28e4676aa..03a12b12744 100644 --- a/cpp/src/DataStorm/SessionI.cpp +++ b/cpp/src/DataStorm/SessionI.cpp @@ -512,27 +512,23 @@ SessionI::disconnected(const Ice::Current& current) } void -SessionI::connected(SessionPrx session, const Ice::ConnectionPtr& connection, const TopicInfoSeq& topics) +SessionI::connected(SessionPrx session, const Ice::ConnectionPtr& newConnection, const TopicInfoSeq& topics) { lock_guard lock(_mutex); if (_destroyed || _session) { - assert(_connectedCallbacks.empty()); return; } _session = session; - _connection = connection; - if (connection) + _connection = newConnection; + if (newConnection) { auto self = shared_from_this(); -#if defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif + // Register a callback with the connection manager to reconnect the session if the connection is closed. _instance->getConnectionManager()->add( - connection, + newConnection, self, [self](auto connection, auto ex) { @@ -544,9 +540,6 @@ SessionI::connected(SessionPrx session, const Ice::ConnectionPtr& connection, co } } }); -#if defined(__GNUC__) -# pragma GCC diagnostic pop -#endif } if (_retryTask) @@ -571,6 +564,7 @@ SessionI::connected(SessionPrx session, const Ice::ConnectionPtr& connection, co { try { + // Announce the topics to the peer, don't wait for the result. _session->announceTopicsAsync(topics, true, nullptr); } catch (const Ice::LocalException&) @@ -578,12 +572,6 @@ SessionI::connected(SessionPrx session, const Ice::ConnectionPtr& connection, co // Ignore } } - - for (auto c : _connectedCallbacks) - { - c(_proxy); - } - _connectedCallbacks.clear(); } bool @@ -592,6 +580,7 @@ SessionI::disconnected(const Ice::ConnectionPtr& connection, exception_ptr ex) lock_guard lock(_mutex); if (_destroyed || (connection && _connection != connection) || !_session) { + // Ignore we either already destroyed, or disconnected, or a new connection has already been established. return false; } @@ -605,21 +594,22 @@ SessionI::disconnected(const Ice::ConnectionPtr& connection, exception_ptr ex) } else { - throw Ice::CloseConnectionException(__FILE__, __LINE__); + throw Ice::CloseConnectionException{__FILE__, __LINE__}; } } catch (const std::exception& e) { Trace out(_traceLevels, _traceLevels->sessionCat); - out << _id << ": session `" << _session->ice_getIdentity() << "' disconnected:\n"; + out << _id << ": session '" << _session->ice_getIdentity() << "' disconnected:\n"; out << (_connection ? _connection->toString() : "") << "\n"; out << e.what(); } } + auto self = shared_from_this(); for (auto& t : _topics) { - runWithTopics(t.first, [&](TopicI* topic, TopicSubscriber&) { topic->detach(t.first, shared_from_this()); }); + runWithTopics(t.first, [id = t.first, self](TopicI* topic, TopicSubscriber&) { topic->detach(id, self); }); } _session = nullopt; @@ -635,9 +625,7 @@ SessionI::retry(NodePrx node, exception_ptr exception) if (exception) { - // // Don't retry if we are shutting down. - // try { rethrow_exception(exception); @@ -655,20 +643,17 @@ SessionI::retry(NodePrx node, exception_ptr exception) } } - if (node->ice_getEndpoints().empty() && node->ice_getAdapterId().empty()) + // Cancel any pending retry task, before we start a new one below. + if (_retryTask) { - if (_retryTask) - { - _instance->cancelTimerTask(_retryTask); - _retryTask = nullptr; - } - _retryCount = 0; + _instance->cancelTimerTask(_retryTask); + _retryTask = nullptr; + } - // - // If we can't retry connecting to the node because we don't have its endpoints, - // we just wait for the duration of the last retry delay for the peer to reconnect. - // If it doesn't reconnect, we'll destroy this session after the timeout. - // + if (node->ice_getEndpoints().empty() && node->ice_getAdapterId().empty()) + { + // We cannot retry because we don't have the peer endpoints. Wait twice the last retry interval for the peer to + // reconnect. auto delay = _instance->getRetryDelay(_instance->getRetryCount()) * 2; if (_traceLevels->session > 0) @@ -678,16 +663,15 @@ SessionI::retry(NodePrx node, exception_ptr exception) << " (ms) for peer to reconnect"; } + // Schedule a timer to remove the session if the peer doesn't reconnect. _retryTask = make_shared([self = shared_from_this()] { self->remove(); }); _instance->scheduleTimerTask(_retryTask, delay); } else { - // - // If we can retry the connection attempt, we schedule a timer to retry. Always - // retry immediately on the first attempt. - // + // Schedule a timer to retry. Always retry immediately on the first attempt. auto delay = _retryCount == 0 ? 0ms : _instance->getRetryDelay(_retryCount - 1); + // Increment the retry count, it is reset by disconnected. ++_retryCount; if (_traceLevels->session > 0) @@ -703,13 +687,14 @@ SessionI::retry(NodePrx node, exception_ptr exception) out << _id << ": connection to `" << node->ice_toString() << "` failed and the retry limit has been reached"; } + if (exception) { try { rethrow_exception(exception); } - catch (const Ice::LocalException& ex) + catch (const std::exception& ex) { out << '\n' << ex.what(); } @@ -770,21 +755,14 @@ SessionI::destroyImpl(const exception_ptr& ex) _session = nullopt; _connection = nullptr; + auto self = shared_from_this(); for (const auto& t : _topics) { - runWithTopics( - t.first, - [&](TopicI* topic, TopicSubscriber&) { topic->detach(t.first, shared_from_this()); }); + runWithTopics(t.first, [id = t.first, self](TopicI* topic, TopicSubscriber&) { topic->detach(id, self); }); } _topics.clear(); } - for (auto c : _connectedCallbacks) - { - c(nullopt); - } - _connectedCallbacks.clear(); - try { _instance->getObjectAdapter()->remove(_proxy->ice_getIdentity()); @@ -811,12 +789,10 @@ SessionI::checkSession() { if (_connection) { - // - // Make sure the connection is still established. It's possible that the connection got closed - // and we're not notified yet by the connection manager. Check session explicitly check for the - // connection to make sure that if we get a session creation request from a peer (which might - // detect the connection closure before), it doesn't get ignored. - // + // Make sure the connection is still established. It's possible that the connection got closed and we + // were not notified yet by the connection manager. Check session explicitly check for the connection + // to make sure that if we get a session creation request from a peer (which might detect the connection + // closure before), it doesn't get ignored. try { _connection->throwException(); diff --git a/cpp/src/DataStorm/SessionI.h b/cpp/src/DataStorm/SessionI.h index 19b950435ff..8990db725a5 100644 --- a/cpp/src/DataStorm/SessionI.h +++ b/cpp/src/DataStorm/SessionI.h @@ -345,7 +345,6 @@ namespace DataStormI std::optional _session; Ice::ConnectionPtr _connection; - std::vector)>> _connectedCallbacks; }; class SubscriberSessionI : public SessionI, public DataStormContract::SubscriberSession diff --git a/cpp/src/DataStorm/TopicFactoryI.cpp b/cpp/src/DataStorm/TopicFactoryI.cpp index d81432552c7..efb9a432d75 100644 --- a/cpp/src/DataStorm/TopicFactoryI.cpp +++ b/cpp/src/DataStorm/TopicFactoryI.cpp @@ -70,10 +70,6 @@ TopicFactoryI::createTopicReader( catch (const Ice::ObjectAdapterDestroyedException&) { } - catch (const std::exception&) - { - assert(false); - } return reader; } @@ -127,10 +123,6 @@ TopicFactoryI::createTopicWriter( catch (const Ice::ObjectAdapterDestroyedException&) { } - catch (const std::exception&) - { - assert(false); - } return writer; } diff --git a/cpp/src/DataStorm/TopicI.cpp b/cpp/src/DataStorm/TopicI.cpp index 4a96bb142ee..fd8b598e608 100644 --- a/cpp/src/DataStorm/TopicI.cpp +++ b/cpp/src/DataStorm/TopicI.cpp @@ -13,24 +13,6 @@ using namespace DataStormContract; namespace { - template vector toSeq(const map& map) - { - vector seq; - seq.reserve(map.size()); - for (const auto& p : map) - { - seq.push_back(p.second); - } - return seq; - } - - int toInt(const string& v, int value = 0) - { - istringstream is(v); - is >> value; - return value; - } - static Topic::Updater noOpUpdater = [](const shared_ptr& previous, const shared_ptr& next, const Ice::CommunicatorPtr&) { next->setValue(previous); }; @@ -57,6 +39,54 @@ namespace bool match(const shared_ptr&) const final { return true; } }; const auto alwaysMatchFilter = make_shared(); + + DataStorm::ClearHistoryPolicy parseClearHistory(const std::string& value) + { + if (value == "OnAdd") + { + return DataStorm::ClearHistoryPolicy::OnAdd; + } + else if (value == "OnRemove") + { + return DataStorm::ClearHistoryPolicy::OnRemove; + } + else if (value == "OnAll") + { + return DataStorm::ClearHistoryPolicy::OnAll; + } + else if (value == "OnAllExceptPartialUpdate") + { + return DataStorm::ClearHistoryPolicy::OnAllExceptPartialUpdate; + } + else if (value == "Never") + { + return DataStorm::ClearHistoryPolicy::Never; + } + else + { + throw Ice::ParseException(__FILE__, __LINE__, "Invalid clear history policy: " + value); + } + } + + DataStorm::DiscardPolicy parseDiscardPolicy(const std::string& value) + { + if (value == "Never") + { + return DataStorm::DiscardPolicy::None; + } + else if (value == "SendTime") + { + return DataStorm::DiscardPolicy::SendTime; + } + else if (value == "Priority") + { + return DataStorm::DiscardPolicy::Priority; + } + else + { + throw Ice::ParseException(__FILE__, __LINE__, "Invalid discard policy: " + value); + } + } } TopicI::TopicI( @@ -78,6 +108,8 @@ TopicI::TopicI( _instance(_factory.lock()->getInstance()), _traceLevels(_instance->getTraceLevels()), _id(id), + // The collocated forwarder is initalized here to avoid using a nullable proxy. The forwarder is only used by + // the instance that owns it and is removed in destroy implementation. _forwarder{_instance->getCollocatedForwarder()->add( [this](Ice::ByteSeq inParams, const Ice::Current& current) { forward(inParams, current); })}, _destroyed(false), @@ -272,24 +304,24 @@ TopicI::getElementSpecs(int64_t topicId, const ElementInfoSeq& infos, const shar } void -TopicI::attach(int64_t id, const shared_ptr& session, SessionPrx prx) +TopicI::attach(int64_t id, shared_ptr session, SessionPrx peerSession) { - auto p = _listeners.find(ListenerKey{session}); + auto p = _listeners.find(session); if (p == _listeners.end()) { - p = _listeners.emplace(ListenerKey{session}, Listener(std::move(prx))).first; + p = _listeners.emplace(std::move(session), Listener(std::move(peerSession))).first; } if (p->second.topics.insert(id).second) { - session->subscribe(id, this); + p->first->subscribe(id, this); } } void TopicI::detach(int64_t id, const shared_ptr& session) { - auto p = _listeners.find(ListenerKey{session}); + auto p = _listeners.find(session); if (p != _listeners.end() && p->second.topics.erase(id)) { session->unsubscribe(id, this); @@ -710,16 +742,17 @@ TopicI::notifyListenerWaiters(unique_lock& lock) const void TopicI::disconnect() { - map listeners; + map, Listener> listeners; { unique_lock lock(_mutex); listeners.swap(_listeners); } + for (auto s : listeners) { for (auto t : s.second.topics) { - s.first.session->disconnect(t, this); + s.first->disconnect(t, this); } } @@ -782,6 +815,7 @@ TopicI::add(const shared_ptr& element, const vectorgetId(), "", key->encode(_instance->getCommunicator())}); p->second.insert(element); } + if (!infos.empty()) { try @@ -817,46 +851,6 @@ TopicI::addFiltered(const shared_ptr& element, const shared_ptrsecond); - } - p = properties.find(prefix + ".SampleCount"); - if (p != properties.end()) - { - config.sampleCount = toInt(p->second); - } - p = properties.find(prefix + ".ClearHistory"); - if (p != properties.end()) - { - if (p->second == "OnAdd") - { - config.clearHistory = DataStorm::ClearHistoryPolicy::OnAdd; - } - else if (p->second == "OnRemove") - { - config.clearHistory = DataStorm::ClearHistoryPolicy::OnRemove; - } - else if (p->second == "OnAll") - { - config.clearHistory = DataStorm::ClearHistoryPolicy::OnAll; - } - else if (p->second == "OnAllExceptPartialUpdate") - { - config.clearHistory = DataStorm::ClearHistoryPolicy::OnAllExceptPartialUpdate; - } - else if (p->second == "Never") - { - config.clearHistory = DataStorm::ClearHistoryPolicy::Never; - } - } -} - TopicReaderI::TopicReaderI( shared_ptr factory, shared_ptr keyFactory, @@ -876,8 +870,7 @@ TopicReaderI::TopicReaderI( std::move(name), id) { - _defaultConfig = {-1, 0, DataStorm::ClearHistoryPolicy::OnAll, DataStorm::DiscardPolicy::None}; - _defaultConfig = mergeConfigs(parseConfig("DataStorm.Topic")); + _defaultConfig = parseConfig(); } shared_ptr @@ -954,47 +947,41 @@ TopicReaderI::destroy() } DataStorm::ReaderConfig -TopicReaderI::parseConfig(const string& prefix) const +TopicReaderI::parseConfig() const { + auto properties = _instance->getCommunicator()->getProperties(); DataStorm::ReaderConfig config; - auto properties = _instance->getCommunicator()->getProperties()->getPropertiesForPrefix(prefix); - parseConfigImpl(properties, prefix, config); - auto p = properties.find(prefix + ".DiscardPolicy"); - if (p != properties.end()) - { - if (p->second == "None") - { - config.discardPolicy = DataStorm::DiscardPolicy::None; - } - else if (p->second == "SendTime") - { - config.discardPolicy = DataStorm::DiscardPolicy::SendTime; - } - else if (p->second == "SendTime") - { - config.discardPolicy = DataStorm::DiscardPolicy::Priority; - } - } + config.clearHistory = parseClearHistory(properties->getIceProperty("DataStorm.Topic.ClearHistory")); + config.sampleCount = properties->getIcePropertyAsInt("DataStorm.Topic.SampleCount"); + config.sampleLifetime = properties->getIcePropertyAsInt("DataStorm.Topic.SampleLifetime"); + config.discardPolicy = parseDiscardPolicy(properties->getIceProperty("DataStorm.Topic.DiscardPolicy")); return config; } DataStorm::ReaderConfig TopicReaderI::mergeConfigs(DataStorm::ReaderConfig config) const { - if (!config.sampleCount && _defaultConfig.sampleCount) + if (!config.sampleCount.has_value()) { + assert(_defaultConfig.sampleCount.has_value()); config.sampleCount = _defaultConfig.sampleCount; } - if (!config.sampleLifetime && _defaultConfig.sampleLifetime) + + if (!config.sampleLifetime.has_value()) { + assert(_defaultConfig.sampleLifetime.has_value()); config.sampleLifetime = _defaultConfig.sampleLifetime; } - if (!config.clearHistory && _defaultConfig.clearHistory) + + if (!config.clearHistory.has_value()) { + assert(_defaultConfig.clearHistory.has_value()); config.clearHistory = _defaultConfig.clearHistory; } - if (!config.discardPolicy && _defaultConfig.discardPolicy) + + if (!config.discardPolicy.has_value()) { + assert(_defaultConfig.discardPolicy.has_value()); config.discardPolicy = _defaultConfig.discardPolicy; } return config; @@ -1019,8 +1006,7 @@ TopicWriterI::TopicWriterI( std::move(name), id) { - _defaultConfig = {-1, 0, DataStorm::ClearHistoryPolicy::OnAll}; - _defaultConfig = mergeConfigs(parseConfig("DataStorm.Topic")); + _defaultConfig = parseConfig(); } shared_ptr @@ -1064,39 +1050,41 @@ TopicWriterI::destroy() } DataStorm::WriterConfig -TopicWriterI::parseConfig(const string& prefix) const +TopicWriterI::parseConfig() const { + auto properties = _instance->getCommunicator()->getProperties(); DataStorm::WriterConfig config; - auto properties = _instance->getCommunicator()->getProperties()->getPropertiesForPrefix(prefix); - parseConfigImpl(properties, prefix, config); - auto p = properties.find(prefix + ".Priority"); - if (p != properties.end()) - { - istringstream is(p->second); - int priority; - is >> priority; - config.priority = priority; - } + config.clearHistory = parseClearHistory(properties->getIceProperty("DataStorm.Topic.ClearHistory")); + config.sampleCount = properties->getIcePropertyAsInt("DataStorm.Topic.SampleCount"); + config.sampleLifetime = properties->getIcePropertyAsInt("DataStorm.Topic.SampleLifetime"); + config.priority = properties->getIcePropertyAsInt("DataStorm.Topic.Priority"); return config; } DataStorm::WriterConfig TopicWriterI::mergeConfigs(DataStorm::WriterConfig config) const { - if (!config.sampleCount && _defaultConfig.sampleCount) + if (!config.sampleCount.has_value()) { + assert(_defaultConfig.sampleCount.has_value()); config.sampleCount = _defaultConfig.sampleCount; } - if (!config.sampleLifetime && _defaultConfig.sampleLifetime) + + if (!config.sampleLifetime.has_value()) { + assert(_defaultConfig.sampleLifetime.has_value()); config.sampleLifetime = _defaultConfig.sampleLifetime; } - if (!config.clearHistory && _defaultConfig.clearHistory) + + if (!config.clearHistory.has_value()) { + assert(_defaultConfig.clearHistory.has_value()); config.clearHistory = _defaultConfig.clearHistory; } - if (!config.priority && _defaultConfig.priority) + + if (!config.priority.has_value()) { + assert(_defaultConfig.priority.has_value()); config.priority = _defaultConfig.priority; } return config; diff --git a/cpp/src/DataStorm/TopicI.h b/cpp/src/DataStorm/TopicI.h index 7647d88928d..2dcc702b9eb 100644 --- a/cpp/src/DataStorm/TopicI.h +++ b/cpp/src/DataStorm/TopicI.h @@ -18,13 +18,6 @@ namespace DataStormI class TopicI : public virtual Topic, public std::enable_shared_from_this { - struct ListenerKey - { - std::shared_ptr session; - - bool operator<(const ListenerKey& other) const { return session < other.session; } - }; - struct Listener { Listener(DataStormContract::SessionPrx sessionPrx) : proxy(std::move(sessionPrx)) {} @@ -58,7 +51,7 @@ namespace DataStormI DataStormContract::ElementSpecSeq getElementSpecs(std::int64_t, const DataStormContract::ElementInfoSeq&, const std::shared_ptr&); - void attach(std::int64_t, const std::shared_ptr&, DataStormContract::SessionPrx); + void attach(std::int64_t, std::shared_ptr, DataStormContract::SessionPrx); void detach(std::int64_t, const std::shared_ptr&); DataStormContract::ElementSpecAckSeq attachElements( @@ -116,8 +109,6 @@ namespace DataStormI void add(const std::shared_ptr&, const std::vector>&); void addFiltered(const std::shared_ptr&, const std::shared_ptr&); - void parseConfigImpl(const Ice::PropertyDict&, const std::string&, DataStorm::Config&) const; - friend class DataElementI; friend class DataReaderI; friend class FilteredDataReaderI; @@ -142,7 +133,7 @@ namespace DataStormI bool _destroyed; std::map, std::set>> _keyElements; std::map, std::set>> _filteredElements; - std::map _listeners; + std::map, Listener> _listeners; std::map, Updater> _updaters; size_t _listenerCount; mutable size_t _waiters; @@ -182,7 +173,7 @@ namespace DataStormI void destroy() final; private: - DataStorm::ReaderConfig parseConfig(const std::string&) const; + DataStorm::ReaderConfig parseConfig() const; DataStorm::ReaderConfig mergeConfigs(DataStorm::ReaderConfig) const; DataStorm::ReaderConfig _defaultConfig; @@ -210,7 +201,7 @@ namespace DataStormI void destroy() final; private: - DataStorm::WriterConfig parseConfig(const std::string&) const; + DataStorm::WriterConfig parseConfig() const; DataStorm::WriterConfig mergeConfigs(DataStorm::WriterConfig) const; DataStorm::WriterConfig _defaultConfig; diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 10a5f0bbe59..787bc2a5991 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -9,7 +9,6 @@ using namespace std; // Implement virtual destructors out of line to avoid weak vtables. Ice::ConnectionInfo::~ConnectionInfo() {} -Ice::IPConnectionInfo::~IPConnectionInfo() {} Ice::TCPConnectionInfo::~TCPConnectionInfo() {} Ice::UDPConnectionInfo::~UDPConnectionInfo() {} Ice::WSConnectionInfo::~WSConnectionInfo() {} diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index b22198f0b0f..c5a5b47939c 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -1237,7 +1237,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) // // Connection is validated on first message. This is only used by - // setState() to check wether or not we can print a connection + // setState() to check whether or not we can print a connection // warning (a client might close the connection forcefully if the // connection isn't validated, we don't want to print a warning // in this case). diff --git a/cpp/src/Ice/EndpointI.cpp b/cpp/src/Ice/EndpointI.cpp index 229d93562bc..6713215fb83 100644 --- a/cpp/src/Ice/EndpointI.cpp +++ b/cpp/src/Ice/EndpointI.cpp @@ -98,10 +98,3 @@ IceInternal::EndpointI::checkOption(const string&, const string&, const string&) // Must be overridden to check for options. return false; } - -// Implement virtual destructors out of line to avoid weak vtables. -Ice::IPEndpointInfo::~IPEndpointInfo() {} -Ice::TCPEndpointInfo::~TCPEndpointInfo() {} -Ice::UDPEndpointInfo::~UDPEndpointInfo() {} -Ice::WSEndpointInfo::~WSEndpointInfo() {} -Ice::OpaqueEndpointInfo::~OpaqueEndpointInfo() {} diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h index 82976944fdc..01cff625d89 100644 --- a/cpp/src/Ice/EndpointI.h +++ b/cpp/src/Ice/EndpointI.h @@ -116,11 +116,13 @@ namespace IceInternal // Used only for server endpoints. virtual std::vector expandHost() const = 0; - // Returns true when the most underlying endpoint is an IP endpoint with a loopback address. - virtual bool isLoopback() const = 0; + // Returns true when the most underlying endpoint is an IP endpoint with a loopback or multicast address. + virtual bool isLoopbackOrMulticast() const = 0; + + // Returns a new endpoint with the specified host (if not empty) and all local options cleared. May return + // shared_from_this(). + virtual std::shared_ptr toPublishedEndpoint(std::string publishedHost) const = 0; - // Returns a new endpoint with the specified host; returns this when this operation is not applicable. - virtual std::shared_ptr withPublishedHost(std::string host) const = 0; // // Check whether the endpoint is equivalent to another one. // @@ -140,7 +142,7 @@ namespace IceInternal virtual bool checkOption(const std::string&, const std::string&, const std::string&); }; - template class InfoI : public T + template class InfoI final : public T { public: InfoI(const EndpointIPtr& endpoint) : _endpoint(endpoint) @@ -149,11 +151,13 @@ namespace IceInternal T::timeout = _endpoint->timeout(); } - virtual std::int16_t type() const noexcept { return _endpoint->type(); } + ~InfoI() = default; + + std::int16_t type() const noexcept final { return _endpoint->type(); } - virtual bool datagram() const noexcept { return _endpoint->datagram(); } + bool datagram() const noexcept final { return _endpoint->datagram(); } - virtual bool secure() const noexcept { return _endpoint->secure(); } + bool secure() const noexcept final { return _endpoint->secure(); } private: const EndpointIPtr _endpoint; diff --git a/cpp/src/Ice/IPEndpointI.cpp b/cpp/src/Ice/IPEndpointI.cpp index c18b9ebba55..29333d5e4ab 100644 --- a/cpp/src/Ice/IPEndpointI.cpp +++ b/cpp/src/Ice/IPEndpointI.cpp @@ -137,15 +137,9 @@ IceInternal::IPEndpointI::expandHost() const } bool -IceInternal::IPEndpointI::isLoopback() const +IceInternal::IPEndpointI::isLoopbackOrMulticast() const { - return _host.empty() ? false : isLoopbackAddress(_host); -} - -shared_ptr -IceInternal::IPEndpointI::withPublishedHost(string host) const -{ - return createEndpoint(host, _port, _connectionId); + return _host.empty() ? false : isLoopbackOrMulticastAddress(_host); } bool diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h index d7dbd4c370a..5522884e861 100644 --- a/cpp/src/Ice/IPEndpointI.h +++ b/cpp/src/Ice/IPEndpointI.h @@ -49,8 +49,7 @@ namespace IceInternal std::function)>, std::function) const override; std::vector expandHost() const override; - bool isLoopback() const override; - std::shared_ptr withPublishedHost(std::string host) const override; + bool isLoopbackOrMulticast() const override; bool equivalent(const EndpointIPtr&) const override; std::size_t hash() const noexcept override; std::string options() const override; diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 9cf722b57c5..b9228e97f5b 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -2145,7 +2145,7 @@ IceInternal::isIpAddress(const string& name) } bool -IceInternal::isLoopbackAddress(const string& name) +IceInternal::isLoopbackOrMulticastAddress(const string& name) { if (name.empty()) { @@ -2158,12 +2158,12 @@ IceInternal::isLoopbackAddress(const string& name) if (inet_pton(AF_INET, name.c_str(), &addr) > 0) { // It's an IPv4 address - return addr.s_addr == htonl(INADDR_LOOPBACK); + return addr.s_addr == htonl(INADDR_LOOPBACK) || IN_MULTICAST(ntohl(addr.s_addr)); } else if (inet_pton(AF_INET6, name.c_str(), &addr6) > 0) { // It's an IPv6 address - return IN6_IS_ADDR_LOOPBACK(&addr6); + return IN6_IS_ADDR_LOOPBACK(&addr6) || IN6_IS_ADDR_MULTICAST(&addr6); } return false; } diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index ffee0fa1a81..f75c1fd9a06 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -260,7 +260,7 @@ namespace IceInternal #endif ICE_API bool isIpAddress(const std::string&); - ICE_API bool isLoopbackAddress(const std::string&); + ICE_API bool isLoopbackOrMulticastAddress(const std::string&); ICE_API std::string getHostName(); } diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 4b679d043b7..740cd0f064f 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -1190,13 +1190,13 @@ ObjectAdapterI::computePublishedEndpoints() endpoints.push_back(factory->endpoint()); } - // Remove all loopback endpoints + // Remove all loopback/multicast endpoints vector endpointsNoLoopback; copy_if( endpoints.begin(), endpoints.end(), back_inserter(endpointsNoLoopback), - [](const EndpointIPtr& endpoint) { return !endpoint->isLoopback(); }); + [](const EndpointIPtr& endpoint) { return !endpoint->isLoopbackOrMulticast(); }); // Retrieve published host string publishedHost = _communicator->getProperties()->getProperty(_name + ".PublishedHost"); @@ -1205,34 +1205,31 @@ ObjectAdapterI::computePublishedEndpoints() { endpoints = std::move(endpointsNoLoopback); - // For non-loopback endpoints, we use the fully qualified name of the local host as default for - // publishedHost. + // For non-loopback/multicast endpoints, we use the fully qualified name of the local host as default + // for publishedHost. if (publishedHost.empty()) { publishedHost = getHostName(); // fully qualified name of local host } } - // else keep endpoints as-is; they are all loopback. + // else keep endpoints as-is; they are all loopback or multicast - if (!publishedHost.empty()) - { - vector newEndpoints; + vector newEndpoints; - // Replace the host in all endpoints by publishedHost (when applicable), and remove duplicates. - for (const auto& endpoint : endpoints) + // Replace the host in all endpoints by publishedHost (when applicable), clear local options and remove + // duplicates. + for (const auto& endpoint : endpoints) + { + EndpointIPtr newEndpoint = endpoint->toPublishedEndpoint(publishedHost); + if (find_if( + newEndpoints.begin(), + newEndpoints.end(), + [&newEndpoint](const EndpointIPtr& p) { return *newEndpoint == *p; }) == newEndpoints.end()) { - EndpointIPtr newEndpoint = endpoint->withPublishedHost(publishedHost); - if (find_if( - newEndpoints.begin(), - newEndpoints.end(), - [&newEndpoint](const EndpointIPtr& p) { return *newEndpoint == *p; }) == newEndpoints.end()) - { - newEndpoints.push_back(newEndpoint); - } + newEndpoints.push_back(newEndpoint); } - endpoints = std::move(newEndpoints); } - // else keep the loopback-only endpoints as-is (with IP addresses) + endpoints = std::move(newEndpoints); } } diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index 425d02fa358..cd3212b799a 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -43,28 +43,40 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(int16_t type, InputStream* s) : _t namespace { - class OpaqueEndpointInfoI : public Ice::OpaqueEndpointInfo +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" +#elif defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wshadow" +#endif + + class OpaqueEndpointInfoI final : public Ice::OpaqueEndpointInfo { public: - OpaqueEndpointInfoI(int16_t type, const Ice::EncodingVersion& rawEncoding, vector rawBytes); + OpaqueEndpointInfoI(int16_t type, const Ice::EncodingVersion& rawEncoding, vector rawBytes) : _type(type) + { + OpaqueEndpointInfo::rawEncoding = rawEncoding; + OpaqueEndpointInfo::rawBytes = std::move(rawBytes); + } - virtual int16_t type() const noexcept { return _type; } + ~OpaqueEndpointInfoI() final = default; - virtual bool datagram() const noexcept { return false; } + int16_t type() const noexcept final { return _type; } - virtual bool secure() const noexcept { return false; } + bool datagram() const noexcept final { return false; } + + bool secure() const noexcept final { return false; } private: int16_t _type; }; -} -// -// COMPILERFIX: inlining this constructor causes crashes with gcc 4.0.1. -// -OpaqueEndpointInfoI::OpaqueEndpointInfoI(int16_t type, const Ice::EncodingVersion& rawEncodingP, vector rawBytesP) - : Ice::OpaqueEndpointInfo(nullptr, -1, false, rawEncodingP, std::move(rawBytesP)), - _type(type) -{ + +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) +# pragma GCC diagnostic pop +#endif } void @@ -169,13 +181,13 @@ IceInternal::OpaqueEndpointI::expandHost() const } bool -IceInternal::OpaqueEndpointI::isLoopback() const +IceInternal::OpaqueEndpointI::isLoopbackOrMulticast() const { return false; } shared_ptr -IceInternal::OpaqueEndpointI::withPublishedHost(string) const +IceInternal::OpaqueEndpointI::toPublishedEndpoint(string) const { return const_cast(this)->shared_from_this(); } diff --git a/cpp/src/Ice/OpaqueEndpointI.h b/cpp/src/Ice/OpaqueEndpointI.h index 6793fb453ed..bfdea04dd96 100644 --- a/cpp/src/Ice/OpaqueEndpointI.h +++ b/cpp/src/Ice/OpaqueEndpointI.h @@ -41,8 +41,8 @@ namespace IceInternal AcceptorPtr acceptor(const std::string&, const std::optional&) const final; std::vector expandHost() const final; - bool isLoopback() const final; - std::shared_ptr withPublishedHost(std::string host) const final; + bool isLoopbackOrMulticast() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; bool equivalent(const EndpointIPtr&) const final; std::size_t hash() const noexcept final; std::string options() const final; diff --git a/cpp/src/Ice/OutputUtil.cpp b/cpp/src/Ice/OutputUtil.cpp index 8c4bc7349be..02cbe445202 100644 --- a/cpp/src/Ice/OutputUtil.cpp +++ b/cpp/src/Ice/OutputUtil.cpp @@ -20,9 +20,6 @@ namespace IceInternal StartAbrk sabrk; EndAbrk eabrk; Separator sp; - EndElement ee; - StartEscapes startEscapes; - EndEscapes endEscapes; } // ---------------------------------------------------------------------- @@ -330,231 +327,3 @@ IceInternal::operator<<(Output& out, ios_base& (*val)(ios_base&)) out.print(s.str()); return out; } - -// ---------------------------------------------------------------------- -// XMLOutput -// ---------------------------------------------------------------------- - -IceInternal::XMLOutput::XMLOutput() : OutputBase(), _se(false), _text(false), _escape(false) {} - -IceInternal::XMLOutput::XMLOutput(ostream& os) : OutputBase(os), _se(false), _text(false), _escape(false) {} - -IceInternal::XMLOutput::XMLOutput(const char* s) : OutputBase(s), _se(false), _text(false), _escape(false) {} - -void -IceInternal::XMLOutput::print(const string& s) -{ - if (_se) - { - _out << '>'; - _se = false; - } - _text = true; - - if (_escape) - { - OutputBase::print(escape(s)); - } - else - { - OutputBase::print(s); - } -} - -void -IceInternal::XMLOutput::newline() -{ - if (_se) - { - _se = false; - _out << '>'; - } - OutputBase::newline(); -} - -void -IceInternal::XMLOutput::startElement(const string& element) -{ - newline(); - - // - // If we're not in SGML mode the output of the '>' character is - // deferred until either the //end-element (in which case a /> is - // emitted) or until something //is displayed. - // - if (_escape) - { - _out << '<' << escape(element); - } - else - { - _out << '<' << element; - } - _se = true; - _text = false; - - string::size_type pos = element.find_first_of(" \t"); - if (pos == string::npos) - { - _elementStack.push(element); - } - else - { - _elementStack.push(element.substr(0, pos)); - } - - ++_pos; // TODO: ??? - inc(); - _separator = false; -} - -void -IceInternal::XMLOutput::endElement() -{ - string element = _elementStack.top(); - _elementStack.pop(); - - dec(); - if (_se) - { - _out << ">'; - } - else - { - if (!_text) - { - newline(); - } - _out << "'; - } - --_pos; // TODO: ??? - - _se = false; - _text = false; -} - -void -IceInternal::XMLOutput::attr(const string& name, const string& value) -{ - // - // Precondition: Attributes can only be attached to elements. - // - assert(_se); - _out << " " << name << "=\"" << escape(value) << '"'; -} - -void -IceInternal::XMLOutput::startEscapes() -{ - _escape = true; -} - -void -IceInternal::XMLOutput::endEscapes() -{ - _escape = false; -} - -string -IceInternal::XMLOutput::currentElement() const -{ - if (_elementStack.size() > 0) - { - return _elementStack.top(); - } - else - { - return string(); - } -} - -string -IceInternal::XMLOutput::escape(const string& input) const -{ - string v = input; - - // - // Find out whether there is a reserved character to avoid - // conversion if not necessary. - // - const string allReserved = "<>'\"&"; - if (v.find_first_of(allReserved) != string::npos) - { - // - // First convert all & to & - // - size_t pos = 0; - while ((pos = v.find_first_of('&', pos)) != string::npos) - { - v.insert(pos + 1, "amp;"); - pos += 4; - } - - // - // Next convert remaining reserved characters. - // - const string reserved = "<>'\""; - pos = 0; - while ((pos = v.find_first_of(reserved, pos)) != string::npos) - { - string replace; - switch (v[pos]) - { - case '>': - replace = ">"; - break; - - case '<': - replace = "<"; - break; - - case '\'': - replace = "'"; - break; - - case '"': - replace = """; - break; - - default: - assert(false); - } - - v.erase(pos, 1); - v.insert(pos, replace); - pos += replace.size(); - } - } - return v; -} - -XMLOutput& -IceInternal::operator<<(XMLOutput& out, ios_base& (*val)(ios_base&)) -{ - ostringstream s; - s << val; - out.print(s.str()); - return out; -} - -IceInternal::StartElement::StartElement(const string& name) : _name(name) {} - -const string& -IceInternal::StartElement::getName() const -{ - return _name; -} - -IceInternal::Attribute::Attribute(const string& name, const string& value) : _name(name), _value(value) {} - -const string& -IceInternal::Attribute::getName() const -{ - return _name; -} - -const string& -IceInternal::Attribute::getValue() const -{ - return _value; -} diff --git a/cpp/src/Ice/OutputUtil.h b/cpp/src/Ice/OutputUtil.h index d604a8fb61b..9b80fba5f8d 100644 --- a/cpp/src/Ice/OutputUtil.h +++ b/cpp/src/Ice/OutputUtil.h @@ -187,130 +187,6 @@ namespace IceInternal } ICE_API Output& operator<<(Output&, std::ios_base& (*)(std::ios_base&)); - - // ---------------------------------------------------------------------- - // XMLOutput - // ---------------------------------------------------------------------- - - class ICE_API XMLOutput : public OutputBase - { - public: - XMLOutput(); - XMLOutput(std::ostream&); - XMLOutput(const char*); - - virtual void print(const std::string&); // Print a string. - - virtual void newline(); // Print newline. - - void startElement(const std::string&); // Start an element. - void endElement(); // End an element. - void attr(const std::string&, const std::string&); // Add an attribute to an element. - - void startEscapes(); - void endEscapes(); - - std::string currentElement() const; - - private: - std::string escape(const std::string&) const; - - std::stack _elementStack; - - bool _se; - bool _text; - - bool _escape; - }; - - template inline XMLOutput& operator<<(XMLOutput& out, const T& val) - { - std::ostringstream s; - s << val; - out.print(s.str()); - return out; - } - - template<> inline XMLOutput& operator<<(XMLOutput& o, const NextLine&) - { - o.newline(); - return o; - } - - template<> inline XMLOutput& operator<<(XMLOutput& o, const Separator&) - { - o.separator(); - return o; - } - - class ICE_API EndElement{}; - extern ICE_API EndElement ee; - - template<> inline XMLOutput& operator<<(XMLOutput& o, const EndElement&) - { - o.endElement(); - return o; - } - - class ICE_API StartElement - { - public: - StartElement(const std::string&); - - const std::string& getName() const; - - private: - const std::string _name; - }; - - typedef StartElement se; - - template<> inline XMLOutput& operator<<(XMLOutput& o, const StartElement& e) - { - o.startElement(e.getName()); - return o; - } - - class ICE_API Attribute - { - public: - Attribute(const std::string&, const std::string&); - - const std::string& getName() const; - const std::string& getValue() const; - - private: - const std::string _name; - const std::string _value; - }; - - typedef Attribute attr; - - template<> inline XMLOutput& operator<<(XMLOutput& o, const Attribute& e) - { - o.attr(e.getName(), e.getValue()); - return o; - } - - class ICE_API StartEscapes{}; - extern ICE_API StartEscapes startEscapes; - - class ICE_API EndEscapes{}; - extern ICE_API EndEscapes endEscapes; - - template<> inline XMLOutput& operator<<(XMLOutput& o, const StartEscapes&) - { - o.startEscapes(); - return o; - } - - template<> inline XMLOutput& operator<<(XMLOutput& o, const EndEscapes&) - { - o.endEscapes(); - return o; - } - - ICE_API XMLOutput& operator<<(XMLOutput&, std::ios_base& (*)(std::ios_base&)); } #endif diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 11c69f5f23b..af095ef620b 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -572,6 +572,11 @@ const Property DataStormPropsData[] = Property{"Node.Server", "", false, false, &PropertyNames::ObjectAdapterProps}, Property{"Node.Server.Enabled", "1", false, false, nullptr}, Property{"Node.Server.ForwardDiscoveryToMulticast", "0", false, false, nullptr}, + Property{"Topic.ClearHistory", "OnAll", false, false, nullptr}, + Property{"Topic.DiscardPolicy", "Never", false, false, nullptr}, + Property{"Topic.Priority", "0", false, false, nullptr}, + Property{"Topic.SampleCount", "-1", false, false, nullptr}, + Property{"Topic.SampleLifetime", "0", false, false, nullptr}, Property{"Trace.Data", "0", false, false, nullptr}, Property{"Trace.Session", "0", false, false, nullptr}, Property{"Trace.Topic", "0", false, false, nullptr} @@ -583,7 +588,7 @@ const PropertyArray PropertyNames::DataStormProps .prefixOnly=false, .isOptIn=true, .properties=DataStormPropsData, - .length=13 + .length=18 }; const std::array PropertyNames::validProps = diff --git a/cpp/src/Ice/SSL/SSLEndpointI.cpp b/cpp/src/Ice/SSL/SSLEndpointI.cpp index 9c2ea665458..f6479f23922 100644 --- a/cpp/src/Ice/SSL/SSLEndpointI.cpp +++ b/cpp/src/Ice/SSL/SSLEndpointI.cpp @@ -79,8 +79,6 @@ Ice::SSL::OpenSSLConnectionInfo::~OpenSSLConnectionInfo() } #endif -Ice::SSL::EndpointInfo::~EndpointInfo() {} - Ice::SSL::EndpointI::EndpointI(const InstancePtr& instance, const IceInternal::EndpointIPtr& del) : _instance(instance), _delegate(del) @@ -254,15 +252,15 @@ Ice::SSL::EndpointI::expandHost() const } bool -Ice::SSL::EndpointI::isLoopback() const +Ice::SSL::EndpointI::isLoopbackOrMulticast() const { - return _delegate->isLoopback(); + return _delegate->isLoopbackOrMulticast(); } shared_ptr -Ice::SSL::EndpointI::withPublishedHost(string host) const +Ice::SSL::EndpointI::toPublishedEndpoint(string publishedHost) const { - return endpoint(_delegate->withPublishedHost(std::move(host))); + return endpoint(_delegate->toPublishedEndpoint(std::move(publishedHost))); } bool diff --git a/cpp/src/Ice/SSL/SSLEndpointI.h b/cpp/src/Ice/SSL/SSLEndpointI.h index 29f4dc22353..f954d966a38 100644 --- a/cpp/src/Ice/SSL/SSLEndpointI.h +++ b/cpp/src/Ice/SSL/SSLEndpointI.h @@ -43,8 +43,8 @@ namespace Ice::SSL IceInternal::AcceptorPtr acceptor(const std::string&, const std::optional&) const final; std::vector expandHost() const final; - bool isLoopback() const final; - std::shared_ptr withPublishedHost(std::string host) const final; + bool isLoopbackOrMulticast() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; bool equivalent(const IceInternal::EndpointIPtr&) const final; std::size_t hash() const noexcept final; std::string options() const final; diff --git a/cpp/src/Ice/SSL/SchannelTransceiverI.cpp b/cpp/src/Ice/SSL/SchannelTransceiverI.cpp index 160d065d9ff..e4674cf92d8 100644 --- a/cpp/src/Ice/SSL/SchannelTransceiverI.cpp +++ b/cpp/src/Ice/SSL/SchannelTransceiverI.cpp @@ -1037,7 +1037,7 @@ Schannel::TransceiverI::TransceiverI( ssl, // The SSL context handle. false, // This is an outgoing connection. _host, // The target host. - true, // Wether or not the peer must provide a certificate. + true, // Whether or not the peer must provide a certificate. 0, // Disable revocation checking. false); // Whether or not revocation checks only uses cached information. }; diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index dceeade014c..aa8a29cb082 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -122,6 +122,22 @@ IceInternal::TcpEndpointI::datagram() const return false; } +shared_ptr +IceInternal::TcpEndpointI::toPublishedEndpoint(string publishedHost) const +{ + // A server endpoint can't have a source address or connection ID. + assert(!isAddressValid(_sourceAddr) && _connectionId.empty()); + + if (publishedHost.empty()) + { + return const_cast(this)->shared_from_this(); + } + else + { + return make_shared(_instance, publishedHost, _port, Address{}, _timeout, "", _compress); + } +} + TransceiverPtr IceInternal::TcpEndpointI::transceiver() const { diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index 705dc27bc33..ee65991d143 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -37,6 +37,8 @@ namespace IceInternal EndpointIPtr compress(bool) const final; bool datagram() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; + TransceiverPtr transceiver() const final; AcceptorPtr acceptor(const std::string&, const std::optional&) const final; diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index 325d30c67a8..f7e6db54524 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -149,6 +149,21 @@ IceInternal::UdpEndpointI::datagram() const return true; } +shared_ptr +IceInternal::UdpEndpointI::toPublishedEndpoint(string publishedHost) const +{ + return make_shared( + _instance, + publishedHost.empty() ? _host : publishedHost, + _port, + Address{}, + "", + -1, + false, // for "connect" + "", + _compress); +} + TransceiverPtr IceInternal::UdpEndpointI::transceiver() const { diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index 6ed878787bf..ac5454719f3 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -41,6 +41,8 @@ namespace IceInternal EndpointIPtr compress(bool) const final; bool datagram() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; + TransceiverPtr transceiver() const final; AcceptorPtr acceptor(const std::string&, const std::optional&) const final; diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp index 68b50fb61a6..af7e0e85276 100644 --- a/cpp/src/Ice/WSEndpoint.cpp +++ b/cpp/src/Ice/WSEndpoint.cpp @@ -275,15 +275,15 @@ IceInternal::WSEndpoint::expandHost() const } bool -IceInternal::WSEndpoint::isLoopback() const +IceInternal::WSEndpoint::isLoopbackOrMulticast() const { - return _delegate->isLoopback(); + return _delegate->isLoopbackOrMulticast(); } shared_ptr -IceInternal::WSEndpoint::withPublishedHost(string host) const +IceInternal::WSEndpoint::toPublishedEndpoint(string publishedHost) const { - return endpoint(_delegate->withPublishedHost(std::move(host))); + return endpoint(_delegate->toPublishedEndpoint(std::move(publishedHost))); } bool diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h index 26744c5e416..69485e656cf 100644 --- a/cpp/src/Ice/WSEndpoint.h +++ b/cpp/src/Ice/WSEndpoint.h @@ -47,8 +47,8 @@ namespace IceInternal AcceptorPtr acceptor(const std::string&, const std::optional&) const final; std::vector expandHost() const final; - bool isLoopback() const final; - std::shared_ptr withPublishedHost(std::string host) const final; + bool isLoopbackOrMulticast() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; bool equivalent(const EndpointIPtr&) const final; std::size_t hash() const noexcept final; std::string options() const final; diff --git a/cpp/src/Ice/ios/iAPEndpointI.h b/cpp/src/Ice/ios/iAPEndpointI.h index 09f65cb005f..b417c05c149 100644 --- a/cpp/src/Ice/ios/iAPEndpointI.h +++ b/cpp/src/Ice/ios/iAPEndpointI.h @@ -55,8 +55,8 @@ namespace IceObjC IceInternal::AcceptorPtr acceptor(const std::string&, const std::optional&) const final; std::vector expandHost() const final; - bool isLoopback() const final; - std::shared_ptr withPublishedHost(std::string host) const final; + bool isLoopbackOrMulticast() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; bool equivalent(const IceInternal::EndpointIPtr&) const final; bool operator==(const Ice::Endpoint&) const final; diff --git a/cpp/src/Ice/ios/iAPEndpointI.mm b/cpp/src/Ice/ios/iAPEndpointI.mm index 402421dad7e..0492db1d5d3 100644 --- a/cpp/src/Ice/ios/iAPEndpointI.mm +++ b/cpp/src/Ice/ios/iAPEndpointI.mm @@ -78,7 +78,6 @@ ICEIAP_API void registerIceIAP(bool loadOnInitialize) // Implement virtual destructors out of line to avoid weak vtables. IceIAP::ConnectionInfo::~ConnectionInfo() {} -IceIAP::EndpointInfo::~EndpointInfo() {} IceObjC::iAPEndpointI::iAPEndpointI( const ProtocolInstancePtr& instance, @@ -309,13 +308,13 @@ ICEIAP_API void registerIceIAP(bool loadOnInitialize) } bool -IceObjC::iAPEndpointI::isLoopback() const +IceObjC::iAPEndpointI::isLoopbackOrMulticast() const { return false; } shared_ptr -IceObjC::iAPEndpointI::withPublishedHost(string) const +IceObjC::iAPEndpointI::toPublishedEndpoint(string) const { return const_cast(this)->shared_from_this(); } diff --git a/cpp/src/IceBT/EndpointI.cpp b/cpp/src/IceBT/EndpointI.cpp index 9c1bb65ae06..562467eda47 100644 --- a/cpp/src/IceBT/EndpointI.cpp +++ b/cpp/src/IceBT/EndpointI.cpp @@ -23,7 +23,6 @@ using namespace IceBT; // Implement virtual destructors out of line to avoid weak vtables. IceBT::ConnectionInfo::~ConnectionInfo() {} -IceBT::EndpointInfo::~EndpointInfo() {} IceBT::EndpointI::EndpointI( const InstancePtr& instance, @@ -198,13 +197,13 @@ IceBT::EndpointI::expandHost() const } bool -IceBT::EndpointI::isLoopback() const +IceBT::EndpointI::isLoopbackOrMulticast() const { return false; } shared_ptr -IceBT::EndpointI::withPublishedHost(string) const +IceBT::EndpointI::toPublishedEndpoint(string) const { return const_cast(this)->shared_from_this(); } @@ -606,8 +605,6 @@ IceBT::EndpointI::checkOption(const string& option, const string& argument, cons IceBT::EndpointInfoI::EndpointInfoI(const EndpointIPtr& endpoint) : _endpoint(endpoint) {} -IceBT::EndpointInfoI::~EndpointInfoI() {} - int16_t IceBT::EndpointInfoI::type() const noexcept { diff --git a/cpp/src/IceBT/EndpointI.h b/cpp/src/IceBT/EndpointI.h index 805ad9675a4..d0dd44f328b 100644 --- a/cpp/src/IceBT/EndpointI.h +++ b/cpp/src/IceBT/EndpointI.h @@ -48,8 +48,8 @@ namespace IceBT IceInternal::AcceptorPtr acceptor(const std::string&, const std::optional&) const final; std::vector expandHost() const final; - bool isLoopback() const final; - std::shared_ptr withPublishedHost(std::string host) const final; + bool isLoopbackOrMulticast() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; bool equivalent(const IceInternal::EndpointIPtr&) const final; bool operator==(const Ice::Endpoint&) const final; @@ -82,7 +82,7 @@ namespace IceBT { public: EndpointInfoI(const EndpointIPtr&); - ~EndpointInfoI(); + ~EndpointInfoI() = default; std::int16_t type() const noexcept final; bool datagram() const noexcept final; diff --git a/cpp/src/IceDB/IceDB.cpp b/cpp/src/IceDB/IceDB.cpp index e8d91c11bdf..e6f749e86ea 100644 --- a/cpp/src/IceDB/IceDB.cpp +++ b/cpp/src/IceDB/IceDB.cpp @@ -191,22 +191,6 @@ ReadOnlyTxn::~ReadOnlyTxn() {} ReadOnlyTxn::ReadOnlyTxn(const Env& env) : Txn(env, MDB_RDONLY) {} -void -ReadOnlyTxn::reset() -{ - mdb_txn_reset(_mtxn); -} - -void -ReadOnlyTxn::renew() -{ - const int rc = mdb_txn_renew(_mtxn); - if (rc != MDB_SUCCESS) - { - throw LMDBException(__FILE__, __LINE__, rc); - } -} - ReadWriteTxn::~ReadWriteTxn() {} ReadWriteTxn::ReadWriteTxn(const Env& env) : Txn(env, 0) {} @@ -318,12 +302,6 @@ CursorBase::close() } } -MDB_cursor* -CursorBase::mcursor() const -{ - return _mcursor; -} - bool CursorBase::get(MDB_val* key, MDB_val* data, MDB_cursor_op op) { @@ -335,19 +313,6 @@ CursorBase::get(MDB_val* key, MDB_val* data, MDB_cursor_op op) return rc == MDB_SUCCESS; } -void -CursorBase::put(MDB_val* key, MDB_val* data, unsigned int flags) -{ - assert(key->mv_size <= maxKeySize); - assert(!_readOnly); - - const int rc = mdb_cursor_put(_mcursor, key, data, flags); - if (rc != MDB_SUCCESS) - { - throw LMDBException(__FILE__, __LINE__, rc); - } -} - bool CursorBase::find(MDB_val* key) { @@ -361,29 +326,6 @@ CursorBase::find(MDB_val* key, MDB_val* data) return get(key, data, MDB_SET); } -void -CursorBase::del(unsigned int flags) -{ - assert(!_readOnly); - - const int rc = mdb_cursor_del(_mcursor, flags); - if (rc != MDB_SUCCESS) - { - throw LMDBException(__FILE__, __LINE__, rc); - } -} - -void -CursorBase::renew(const ReadOnlyTxn& txn) -{ - assert(_readOnly); - const int rc = mdb_cursor_renew(txn.mtxn(), CursorBase::_mcursor); - if (rc != MDB_SUCCESS) - { - throw LMDBException(__FILE__, __LINE__, rc); - } -} - // // On Windows, we use a default LMDB map size of 10MB, whereas on other platforms // (Linux, macOS), we use a default of 100MB. diff --git a/cpp/src/IceDB/IceDB.h b/cpp/src/IceDB/IceDB.h index 643af991915..f73bdbd763f 100644 --- a/cpp/src/IceDB/IceDB.h +++ b/cpp/src/IceDB/IceDB.h @@ -134,9 +134,6 @@ namespace IceDB public: explicit ReadOnlyTxn(const Env&); ~ReadOnlyTxn(); - - void reset(); - void renew(); }; class ICE_DB_API ReadWriteTxn : public Txn @@ -268,7 +265,6 @@ namespace IceDB { public: void close(); - MDB_cursor* mcursor() const; protected: CursorBase(MDB_dbi dbi, const Txn& txn); @@ -278,11 +274,8 @@ namespace IceDB CursorBase& operator=(const CursorBase&) = delete; bool get(MDB_val*, MDB_val*, MDB_cursor_op); - void put(MDB_val*, MDB_val*, unsigned int); bool find(MDB_val*); bool find(MDB_val*, MDB_val*); - void del(unsigned int); - void renew(const ReadOnlyTxn&); private: MDB_cursor* _mcursor; @@ -350,33 +343,12 @@ namespace IceDB { public: ReadWriteCursor(const Dbi& dbi, const ReadWriteTxn& txn) : Cursor(dbi, txn) {} - - void put(const K& key, const D& data, unsigned int flags = 0) - { - unsigned char kbuf[maxKeySize]; - MDB_val mkey = {maxKeySize, kbuf}; - if (Codec::write(key, mkey)) - { - H hdata; - MDB_val mdata; - Codec::write(data, mdata, hdata); - CursorBase::put(&mkey, &mdata, flags); - } - else - { - throw KeyTooLongException(__FILE__, __LINE__, mkey.mv_size); - } - } - - void del(unsigned int flags = 0) { CursorBase::del(flags); } }; template class ReadOnlyCursor : public Cursor { public: ReadOnlyCursor(const Dbi& dbi, const ReadOnlyTxn& txn) : Cursor(dbi, txn) {} - - void renew(const ReadOnlyTxn& txn) { CursorBase::renew(txn); } }; // diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp index 7d5bd7203d7..f22ea145da1 100644 --- a/cpp/src/IceXML/Parser.cpp +++ b/cpp/src/IceXML/Parser.cpp @@ -25,245 +25,11 @@ IceXML::ParserException::ice_id() const noexcept return "::IceXML::ParserException"; } -// -// Node -// -IceXML::Node::Node(const shared_ptr& parent, const string& name, const string& value, int line, int column) - : _parent(parent), - _name(name), - _value(value), - _line(line), - _column(column) -{ -} - -shared_ptr -IceXML::Node::getParent() const -{ - return _parent; -} - -string -IceXML::Node::getName() const -{ - return _name; -} - -string -IceXML::Node::getValue() const -{ - return _value; -} - -IceXML::NodeList -IceXML::Node::getChildren() const -{ - return NodeList(); -} - -IceXML::Attributes -IceXML::Node::getAttributes() const -{ - return Attributes(); -} - -string -IceXML::Node::getAttribute(const string&) const -{ - return string(); -} - -bool -IceXML::Node::addChild(const shared_ptr&) -{ - return false; -} - -void -IceXML::Node::destroy() -{ - _parent = 0; -} - -int -IceXML::Node::getLine() const -{ - return _line; -} - -int -IceXML::Node::getColumn() const -{ - return _column; -} - -// -// Element -// -IceXML::Element::Element( - const shared_ptr& parent, - const string& name, - const Attributes& attributes, - int line, - int column) - : Node(parent, name, "", line, column), - _attributes(attributes) -{ -} - -IceXML::NodeList -IceXML::Element::getChildren() const -{ - return _children; -} - -IceXML::Attributes -IceXML::Element::getAttributes() const -{ - return _attributes; -} - -string -IceXML::Element::getAttribute(const string& name) const -{ - Attributes::const_iterator p = _attributes.find(name); - if (p != _attributes.end()) - { - return p->second; - } - return string(); -} - -bool -IceXML::Element::addChild(const shared_ptr& child) -{ - _children.push_back(child); - return true; -} - -void -IceXML::Element::destroy() -{ - Node::destroy(); - for (NodeList::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->destroy(); - } -} - -// -// Text -// -IceXML::Text::Text(const shared_ptr& parent, const string& value, int line, int column) - : Node(parent, "", value, line, column) -{ -} - -// -// Document -// -IceXML::Document::Document() : Node(0, "", "", 0, 0) {} - -IceXML::NodeList -IceXML::Document::getChildren() const -{ - return _children; -} - -bool -IceXML::Document::addChild(const shared_ptr& child) -{ - _children.push_back(child); - return true; -} - -void -IceXML::Document::destroy() -{ - Node::destroy(); - for (NodeList::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->destroy(); - } -} - // // Handler // IceXML::Handler::~Handler() {} -void -IceXML::Handler::error(const string& msg, int line, int column) -{ - ostringstream out; - out << "XML error at input line " << line << ", column " << column << ":" << endl << msg; - throw ParserException(__FILE__, __LINE__, out.str()); -} - -// -// DocumentBuilder -// -namespace IceXML -{ - class DocumentBuilder : public Handler - { - public: - DocumentBuilder(); - - virtual void startElement(const string&, const Attributes&, int, int); - virtual void endElement(const string&, int, int); - virtual void characters(const string&, int, int); - - shared_ptr getDocument() const; - - private: - list> _nodeStack; - shared_ptr _document; - }; -} - -IceXML::DocumentBuilder::DocumentBuilder() -{ - _document = make_shared(); - _nodeStack.push_front(_document); -} - -void -IceXML::DocumentBuilder::startElement(const string& name, const Attributes& attributes, int line, int column) -{ - auto parent = _nodeStack.front(); - auto element = make_shared(parent, name, attributes, line, column); - -#ifdef NDEBUG - parent->addChild(element); -#else - assert(parent->addChild(element)); -#endif - - _nodeStack.push_front(element); -} - -void -IceXML::DocumentBuilder::endElement(const string&, int, int) -{ - assert(!_nodeStack.empty()); - _nodeStack.pop_front(); -} - -void -IceXML::DocumentBuilder::characters(const string& data, int line, int column) -{ - auto parent = _nodeStack.front(); - auto text = make_shared(parent, data, line, column); - parent->addChild(text); -} - -shared_ptr -IceXML::DocumentBuilder::getDocument() const -{ - return _document; -} - // // expat callbacks // @@ -312,22 +78,6 @@ extern "C" // // Parser // -shared_ptr -IceXML::Parser::parse(const string& file) -{ - DocumentBuilder builder; - parse(file, builder); - return builder.getDocument(); -} - -shared_ptr -IceXML::Parser::parse(istream& in) -{ - DocumentBuilder builder; - parse(in, builder); - return builder.getDocument(); -} - void IceXML::Parser::parse(const string& file, Handler& handler) // The given filename must be UTF-8 encoded { diff --git a/cpp/src/IceXML/Parser.h b/cpp/src/IceXML/Parser.h index c42c7b2ad4d..4624eada5c3 100644 --- a/cpp/src/IceXML/Parser.h +++ b/cpp/src/IceXML/Parser.h @@ -40,82 +40,8 @@ namespace IceXML const char* ice_id() const noexcept final; }; - class Document; - class Element; - class Node; - class Text; - - using NodeList = std::vector>; using Attributes = std::map; - class ICE_XML_API Node - { - public: - virtual ~Node() = default; - - virtual std::shared_ptr getParent() const; - virtual std::string getName() const; - virtual std::string getValue() const; - virtual NodeList getChildren() const; - virtual Attributes getAttributes() const; - virtual std::string getAttribute(const std::string&) const; - - virtual bool addChild(const std::shared_ptr&); - - virtual void destroy(); - - int getLine() const; - int getColumn() const; - - protected: - Node(const std::shared_ptr&, const std::string&, const std::string&, int, int); - - std::shared_ptr _parent; - std::string _name; - std::string _value; - int _line; - int _column; - }; - - class ICE_XML_API Element final : public Node - { - public: - Element(const std::shared_ptr&, const std::string&, const Attributes&, int, int); - - NodeList getChildren() const override; - Attributes getAttributes() const override; - std::string getAttribute(const std::string&) const override; - - bool addChild(const std::shared_ptr&) override; - - void destroy() override; - - private: - NodeList _children; - Attributes _attributes; - }; - - class ICE_XML_API Text final : public Node - { - public: - Text(const std::shared_ptr&, const std::string&, int, int); - }; - - class ICE_XML_API Document : public Node - { - public: - Document(); - - NodeList getChildren() const override; - - bool addChild(const std::shared_ptr&) override; - - void destroy() override; - - private: - NodeList _children; - }; - class ICE_XML_API Handler { public: @@ -124,15 +50,12 @@ namespace IceXML virtual void startElement(const std::string&, const Attributes&, int, int) = 0; virtual void endElement(const std::string&, int, int) = 0; virtual void characters(const std::string&, int, int) = 0; - virtual void error(const std::string&, int, int); + virtual void error(const std::string&, int, int) = 0; }; class ICE_XML_API Parser { public: - static std::shared_ptr parse(const std::string&); // The given filename must be UTF-8 encoded - static std::shared_ptr parse(std::istream&); - static void parse(const std::string&, Handler&); static void parse(std::istream&, Handler&); }; diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 6bda03b1594..2d663963e97 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -297,47 +297,47 @@ Slice::DefinitionContext::initSuppressedWarnings() } // ---------------------------------------------------------------------- -// Comment +// DocComment // ---------------------------------------------------------------------- bool -Slice::Comment::isDeprecated() const +Slice::DocComment::isDeprecated() const { return _isDeprecated; } StringList -Slice::Comment::deprecated() const +Slice::DocComment::deprecated() const { return _deprecated; } StringList -Slice::Comment::overview() const +Slice::DocComment::overview() const { return _overview; } StringList -Slice::Comment::seeAlso() const +Slice::DocComment::seeAlso() const { return _seeAlso; } StringList -Slice::Comment::returns() const +Slice::DocComment::returns() const { return _returns; } map -Slice::Comment::parameters() const +Slice::DocComment::parameters() const { return _parameters; } map -Slice::Comment::exceptions() const +Slice::DocComment::exceptions() const { return _exceptions; } @@ -611,9 +611,9 @@ Slice::Contained::line() const } string -Slice::Contained::comment() const +Slice::Contained::docComment() const { - return _comment; + return _docComment; } namespace @@ -743,17 +743,17 @@ namespace } } -CommentPtr -Slice::Contained::parseComment(function linkFormatter, bool stripMarkup) const +DocCommentPtr +Slice::Contained::parseDocComment(function linkFormatter, bool stripMarkup) const { // Split the comment's raw text up into lines. - StringList lines = splitComment(_comment, std::move(linkFormatter), stripMarkup); + StringList lines = splitComment(_docComment, std::move(linkFormatter), stripMarkup); if (lines.empty()) { return nullptr; } - CommentPtr comment = make_shared(); + DocCommentPtr comment = make_shared(); // Parse the comment's text. StringList::const_iterator i; @@ -1019,7 +1019,7 @@ Slice::Contained::Contained(const ContainerPtr& container, const string& name) assert(_unit); _file = _unit->currentFile(); _line = _unit->currentLine(); - _comment = _unit->currentComment(); + _docComment = _unit->currentDocComment(); _includeLevel = _unit->currentIncludeLevel(); } @@ -4597,9 +4597,9 @@ Slice::Unit::createUnit(bool all, const StringList& defaultFileMetadata) } void -Slice::Unit::setComment(const string& comment) +Slice::Unit::setDocComment(const string& comment) { - _currentComment = ""; + _currentDocComment = ""; string::size_type end = 0; while (true) @@ -4626,7 +4626,7 @@ Slice::Unit::setComment(const string& comment) { if (end + 1 > begin) { - _currentComment += comment.substr(begin, end + 1 - begin); + _currentDocComment += comment.substr(begin, end + 1 - begin); } ++end; } @@ -4637,7 +4637,7 @@ Slice::Unit::setComment(const string& comment) { if (end + 1 > begin) { - _currentComment += comment.substr(begin, end + 1 - begin); + _currentDocComment += comment.substr(begin, end + 1 - begin); } } break; @@ -4646,20 +4646,20 @@ Slice::Unit::setComment(const string& comment) } void -Slice::Unit::addToComment(const string& comment) +Slice::Unit::addToDocComment(const string& comment) { - if (!_currentComment.empty()) + if (!_currentDocComment.empty()) { - _currentComment += '\n'; + _currentDocComment += '\n'; } - _currentComment += comment; + _currentDocComment += comment; } string -Slice::Unit::currentComment() +Slice::Unit::currentDocComment() { string comment; - comment.swap(_currentComment); + comment.swap(_currentDocComment); return comment; } @@ -4731,14 +4731,14 @@ Slice::Unit::setCurrentFile(const std::string& currentFile, int lineNumber) } } pushDefinitionContext(); - _currentComment = ""; + _currentDocComment = ""; break; } case Pop: { --_currentIncludeLevel; popDefinitionContext(); - _currentComment = ""; + _currentDocComment = ""; break; } default: @@ -4949,7 +4949,7 @@ Slice::Unit::parse(const string& filename, FILE* file, bool debugMode) assert(!Slice::currentUnit); Slice::currentUnit = this; - _currentComment = ""; + _currentDocComment = ""; _currentIncludeLevel = 0; _topLevelFile = fullPath(filename); pushContainer(shared_from_this()); diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index 52a7cbcab55..82c1d79ad74 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -242,10 +242,10 @@ namespace Slice using DefinitionContextPtr = std::shared_ptr; // ---------------------------------------------------------------------- - // Comment + // DocComment // ---------------------------------------------------------------------- - class Comment final + class DocComment final { public: bool isDeprecated() const; @@ -275,7 +275,7 @@ namespace Slice std::map _parameters; std::map _exceptions; }; - using CommentPtr = std::shared_ptr; + using DocCommentPtr = std::shared_ptr; // ---------------------------------------------------------------------- // SyntaxTreeBase @@ -370,8 +370,8 @@ namespace Slice std::string file() const; int line() const; - std::string comment() const; - CommentPtr parseComment( + std::string docComment() const; + DocCommentPtr parseDocComment( std::function linkFormatter, bool stripMarkup = false) const; @@ -403,7 +403,7 @@ namespace Slice std::string _scoped; std::string _file; int _line; - std::string _comment; + std::string _docComment; int _includeLevel; MetadataList _metadata; }; @@ -987,9 +987,9 @@ namespace Slice public: static UnitPtr createUnit(bool all, const StringList& defaultFileMetadata = StringList()); - void setComment(const std::string& comment); - void addToComment(const std::string& comment); - std::string currentComment(); // Not const, as this function removes the current comment. + void setDocComment(const std::string& comment); + void addToDocComment(const std::string& comment); + std::string currentDocComment(); // Not const, as this function removes the current doc-comment. std::string currentFile() const; std::string topLevelFile() const; int currentLine() const; @@ -1045,7 +1045,7 @@ namespace Slice bool _all; MetadataList _defaultFileMetadata; int _errors; - std::string _currentComment; + std::string _currentDocComment; int _currentIncludeLevel; std::string _topLevelFile; std::stack _definitionContextStack; diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp index 0bde7d88f00..83dcb27d629 100644 --- a/cpp/src/Slice/Scanner.cpp +++ b/cpp/src/Slice/Scanner.cpp @@ -1824,7 +1824,7 @@ case 21: YY_RULE_SETUP #line 320 "src/Slice/Scanner.l" { - currentUnit->addToComment(yytext + 3); + currentUnit->addToDocComment(yytext + 3); } YY_BREAK /* Matches and consumes a C++ style comment. */ @@ -1871,7 +1871,7 @@ YY_RULE_SETUP string comment(yytext); // The last 2 characters are the '*/' matched by this rule. - currentUnit->setComment(comment.substr(0, yyleng - 2)); + currentUnit->setDocComment(comment.substr(0, yyleng - 2)); } YY_BREAK /* Handles reaching EOF while scanning a C style comment by issuing a warning but continuing normally. */ @@ -1881,7 +1881,7 @@ case YY_STATE_EOF(C_COMMENT): yy_pop_state(); currentUnit->error("encountered EOF while scanning a comment"); - currentUnit->setComment(yytext); + currentUnit->setDocComment(yytext); } YY_BREAK /* ========== Preprocessor Statements ========== */ diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 3f19cc96ad1..c6edc757c09 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -317,7 +317,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo /* Matches and records a triple-slash style doc comment. */ <*>"///".* { - currentUnit->addToComment(yytext + 3); + currentUnit->addToDocComment(yytext + 3); } /* Matches and consumes a C++ style comment. */ @@ -347,7 +347,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo string comment(yytext); // The last 2 characters are the '*/' matched by this rule. - currentUnit->setComment(comment.substr(0, yyleng - 2)); + currentUnit->setDocComment(comment.substr(0, yyleng - 2)); } /* Handles reaching EOF while scanning a C style comment by issuing a warning but continuing normally. */ @@ -355,7 +355,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo yy_pop_state(); currentUnit->error("encountered EOF while scanning a comment"); - currentUnit->setComment(yytext); + currentUnit->setDocComment(yytext); } /* ========== Preprocessor Statements ========== */ diff --git a/cpp/src/Slice/SliceUtil.cpp b/cpp/src/Slice/SliceUtil.cpp index 5f424a57b48..55820aef999 100644 --- a/cpp/src/Slice/SliceUtil.cpp +++ b/cpp/src/Slice/SliceUtil.cpp @@ -321,7 +321,7 @@ Slice::filterMcppWarnings(const string& message) } void -Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const string& comment) +Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const string& commentStyle) { // // Get only the file name part of the given path. @@ -333,16 +333,16 @@ Slice::printGeneratedHeader(IceInternal::Output& out, const string& path, const file = file.substr(pos + 1); } - out << comment << " \n"; - out << comment << "\n"; - out << comment << " Generated from file `" << file << "'" + out << commentStyle << " \n"; + out << commentStyle << "\n"; + out << commentStyle << " Generated from file `" << file << "'" << "\n"; - out << comment << "\n"; - out << comment << " Warning: do not edit this file." + out << commentStyle << "\n"; + out << commentStyle << " Warning: do not edit this file." << "\n"; - out << comment << "\n"; - out << comment << " \n"; - out << comment << "\n"; + out << commentStyle << "\n"; + out << commentStyle << " \n"; + out << commentStyle << "\n"; } void diff --git a/cpp/src/ice2slice/Gen.cpp b/cpp/src/ice2slice/Gen.cpp index 3df2889c690..0ca7b41d525 100644 --- a/cpp/src/ice2slice/Gen.cpp +++ b/cpp/src/ice2slice/Gen.cpp @@ -282,9 +282,9 @@ namespace return result += "}"; } - void writeComment(const ContainedPtr& contained, Output& out) + void writeDocComment(const ContainedPtr& contained, Output& out) { - CommentPtr comment = contained->parseComment(slice2LinkFormatter, true); + DocCommentPtr comment = contained->parseDocComment(slice2LinkFormatter, true); if (!comment) { return; @@ -328,7 +328,7 @@ namespace { for (const auto& member : dataMembers) { - writeComment(member, out); + writeDocComment(member, out); out << nl; if (member->optional()) { @@ -427,7 +427,7 @@ Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "class " << p->name(); if (base) @@ -452,7 +452,7 @@ Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "interface " << p->name(); if (bases.size() > 0) { @@ -474,7 +474,7 @@ Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) for (OperationList::const_iterator q = operations.begin(); q != operations.end();) { OperationPtr op = *q; - writeComment(op, out); + writeDocComment(op, out); if (op->hasMetadata("marshaled-result")) { out << nl << "[cs::encodedReturn]"; @@ -542,7 +542,7 @@ Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "exception " << p->name(); if (ExceptionPtr base = p->base()) { @@ -565,7 +565,7 @@ Gen::TypesVisitor::visitStructStart(const StructPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "compact struct " << p->name() << " {"; out.inc(); @@ -583,7 +583,7 @@ Gen::TypesVisitor::visitSequence(const SequencePtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "typealias " << p->name() << " = "; for (const auto& metadata : p->getMetadata()) @@ -622,7 +622,7 @@ Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "typealias " << p->name() << " = "; for (const auto& metadata : p->getMetadata()) @@ -647,7 +647,7 @@ Gen::TypesVisitor::visitEnum(const EnumPtr& p) Output& out = getOutput(p); out << sp; - writeComment(p, out); + writeDocComment(p, out); out << nl << "enum " << p->name() << " {"; out.inc(); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index c6a67c68344..c099dd53624 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -385,12 +385,12 @@ namespace void writeDocSummary(Output& out, const ContainedPtr& p, GenerateDeprecated generateDeprecated = GenerateDeprecated::Yes) { - if (p->comment().empty()) + if (p->docComment().empty()) { return; } - CommentPtr doc = p->parseComment(cppLinkFormatter); + DocCommentPtr doc = p->parseDocComment(cppLinkFormatter); out << nl << "/**"; @@ -448,7 +448,7 @@ namespace void writeOpDocParams( Output& out, const OperationPtr& op, - const CommentPtr& doc, + const DocCommentPtr& doc, OpDocParamType type, const StringList& preParams = StringList(), const StringList& postParams = StringList()) @@ -489,7 +489,7 @@ namespace } } - void writeOpDocExceptions(Output& out, const OperationPtr& op, const CommentPtr& doc) + void writeOpDocExceptions(Output& out, const OperationPtr& op, const DocCommentPtr& doc) { for (const auto& [name, lines] : doc->exceptions()) { @@ -508,7 +508,7 @@ namespace void writeOpDocSummary( Output& out, const OperationPtr& op, - const CommentPtr& doc, + const DocCommentPtr& doc, OpDocParamType type, bool showExceptions, GenerateDeprecated generateDeprecated = GenerateDeprecated::Yes, @@ -1534,7 +1534,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) const string deprecatedAttribute = getDeprecatedAttribute(p); - CommentPtr comment = p->parseComment(cppLinkFormatter); + DocCommentPtr comment = p->parseDocComment(cppLinkFormatter); const string contextDoc = "@param " + contextParam + " The Context map to send with the invocation."; const string futureDoc = "The future object for the invocation."; @@ -1947,7 +1947,7 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) vector params; vector allParamDecls; - map allComments; + map allDocComments; for (const auto& dataMember : dataMembers) { @@ -1960,9 +1960,9 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) typeToString(dataMember->type(), dataMember->optional(), scope, dataMember->getMetadata(), _useWstring); allParamDecls.push_back(typeName + " " + fixKwd(dataMember->name())); - if (CommentPtr comment = dataMember->parseComment(cppLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(cppLinkFormatter)) { - allComments[dataMember->name()] = comment; + allDocComments[dataMember->name()] = comment; } } @@ -2003,8 +2003,8 @@ Slice::Gen::DataDefVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - map::iterator r = allComments.find(dataMember->name()); - if (r != allComments.end()) + map::iterator r = allDocComments.find(dataMember->name()); + if (r != allDocComments.end()) { H << nl << " * @param " << fixKwd(r->first) << " " << getDocSentence(r->second->overview()); } @@ -2428,7 +2428,7 @@ Slice::Gen::DataDefVisitor::emitOneShotConstructor(const ClassDefPtr& p) if (!allDataMembers.empty()) { vector allParamDecls; - map allComments; + map allDocComments; DataMemberList dataMembers = p->dataMembers(); for (const auto& dataMember : allDataMembers) @@ -2436,9 +2436,9 @@ Slice::Gen::DataDefVisitor::emitOneShotConstructor(const ClassDefPtr& p) string typeName = typeToString(dataMember->type(), dataMember->optional(), scope, dataMember->getMetadata(), _useWstring); allParamDecls.push_back(typeName + " " + fixKwd(dataMember->name())); - if (CommentPtr comment = dataMember->parseComment(cppLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(cppLinkFormatter)) { - allComments[dataMember->name()] = comment; + allDocComments[dataMember->name()] = comment; } } @@ -2447,8 +2447,8 @@ Slice::Gen::DataDefVisitor::emitOneShotConstructor(const ClassDefPtr& p) H << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - map::iterator r = allComments.find(dataMember->name()); - if (r != allComments.end()) + map::iterator r = allDocComments.find(dataMember->name()); + if (r != allDocComments.end()) { H << nl << " * @param " << fixKwd(r->first) << " " << getDocSentence(r->second->overview()); } @@ -2791,7 +2791,7 @@ Slice::Gen::InterfaceVisitor::visitOperation(const OperationPtr& p) const string currentTypeDecl = "const " + getUnqualified("::Ice::Current&", interfaceScope); const string currentDecl = currentTypeDecl + " " + currentParam; - CommentPtr comment = p->parseComment(cppLinkFormatter); + DocCommentPtr comment = p->parseDocComment(cppLinkFormatter); if (ret) { diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 7155d0f0c8c..ef5da6971ed 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -891,9 +891,9 @@ Slice::CsVisitor::splitIntoLines(const string& comment) } void -Slice::CsVisitor::splitComment(const ContainedPtr& p, StringList& summaryLines, StringList& remarksLines) +Slice::CsVisitor::splitDocComment(const ContainedPtr& p, StringList& summaryLines, StringList& remarksLines) { - string s = p->comment(); + string s = p->docComment(); const string paramTag = "@param"; const string throwsTag = "@throws"; @@ -930,7 +930,7 @@ Slice::CsVisitor::writeDocComment(const ContainedPtr& p, const string& extraPara { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1002,7 +1002,7 @@ Slice::CsVisitor::writeDocCommentAMI( { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1132,7 +1132,7 @@ Slice::CsVisitor::writeDocCommentTaskAsyncAMI( { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1203,7 +1203,7 @@ Slice::CsVisitor::writeDocCommentAMD(const OperationPtr& p, const string& extraP { StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); if (summaryLines.empty()) { @@ -1284,7 +1284,7 @@ Slice::CsVisitor::writeDocCommentParam(const OperationPtr& p, ParamDir paramType // StringList summaryLines; StringList remarksLines; - splitComment(p, summaryLines, remarksLines); + splitDocComment(p, summaryLines, remarksLines); const string paramTag = "name(); opName[0] = static_cast(toupper(static_cast(opName[0]))); @@ -560,7 +560,7 @@ Slice::JavaVisitor::writeMarshaledResultType( Output& out, const OperationPtr& op, const string& package, - const CommentPtr& dc) + const DocCommentPtr& dc) { string opName = op->name(); const TypePtr ret = op->returnType(); @@ -1295,7 +1295,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const InterfaceDefPtr& p) for (const auto& op : ops) { - CommentPtr dc = op->parseComment(javaLinkFormatter); + DocCommentPtr dc = op->parseDocComment(javaLinkFormatter); vector params = getParams(op, package); const string currentParam = "com.zeroc.Ice.Current " + getEscapedParamName(op, "current"); @@ -1846,7 +1846,7 @@ Slice::JavaVisitor::writeDocCommentLines(Output& out, const string& text) } void -Slice::JavaVisitor::writeDocComment(Output& out, const UnitPtr& unt, const CommentPtr& dc) +Slice::JavaVisitor::writeDocComment(Output& out, const UnitPtr& unt, const DocCommentPtr& dc) { if (!dc) { @@ -1901,7 +1901,7 @@ Slice::JavaVisitor::writeProxyDocComment( Output& out, const OperationPtr& p, const string& package, - const CommentPtr& dc, + const DocCommentPtr& dc, bool async, const string& contextParam) { @@ -2060,7 +2060,7 @@ Slice::JavaVisitor::writeServantDocComment( Output& out, const OperationPtr& p, const string& package, - const CommentPtr& dc, + const DocCommentPtr& dc, bool async) { if (!dc) @@ -2297,7 +2297,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) } } - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Slice interfaces map to Java interfaces. @@ -2535,7 +2535,7 @@ Slice::Gen::TypesVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) open(absolute, p->file()); Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); bool hasOptionals = false; for (const auto& op : p->allOperations()) @@ -2607,7 +2607,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Generate the "Result" type needed by operations that return multiple values. @@ -2648,7 +2648,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -2914,7 +2914,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -3232,7 +3232,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -3514,7 +3514,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -3530,7 +3530,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) { out << ','; } - CommentPtr edc = (*en)->parseComment(javaLinkFormatter); + DocCommentPtr edc = (*en)->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), edc); if (edc && edc->isDeprecated()) { @@ -3653,7 +3653,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) out << sp; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); writeDocComment(out, p->unit(), dc); if (dc && dc->isDeprecated()) { @@ -4004,7 +4004,7 @@ Slice::Gen::ProxyVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) open(absolute, p->file()); Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Generate a Java interface as the user-visible type @@ -4044,7 +4044,7 @@ Slice::Gen::ProxyVisitor::visitInterfaceDefEnd(const InterfaceDefPtr& p) { Output& out = output(); - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); const string package = getPackage(p); const string contextParam = "java.util.Map context"; @@ -4264,7 +4264,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) const string contextParam = "java.util.Map " + contextParamName; const string noExplicitContextArg = "com.zeroc.Ice.ObjectPrx.noExplicitContext"; - CommentPtr dc = p->parseComment(javaLinkFormatter); + DocCommentPtr dc = p->parseDocComment(javaLinkFormatter); // // Synchronous methods with required parameters. diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 1811884a0d9..b9b6a4b68f4 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -25,9 +25,9 @@ namespace Slice }; std::string getResultType(const OperationPtr&, const std::string&, bool, bool); - void writeResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const CommentPtr&); + void writeResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const DocCommentPtr&); void - writeMarshaledResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const CommentPtr&); + writeMarshaledResultType(::IceInternal::Output&, const OperationPtr&, const std::string&, const DocCommentPtr&); void allocatePatcher(::IceInternal::Output&, const TypePtr&, const std::string&, const std::string&); std::string getPatcher(const TypePtr&, const std::string&, const std::string&); @@ -96,13 +96,13 @@ namespace Slice void writeHiddenDocComment(::IceInternal::Output&); void writeDocCommentLines(::IceInternal::Output&, const StringList&); void writeDocCommentLines(::IceInternal::Output&, const std::string&); - void writeDocComment(::IceInternal::Output&, const UnitPtr&, const CommentPtr&); + void writeDocComment(::IceInternal::Output&, const UnitPtr&, const DocCommentPtr&); void writeDocComment(::IceInternal::Output&, const std::string&); void writeProxyDocComment( ::IceInternal::Output&, const OperationPtr&, const std::string&, - const CommentPtr&, + const DocCommentPtr&, bool, const std::string&); void writeHiddenProxyDocComment(::IceInternal::Output&, const OperationPtr&); @@ -110,7 +110,7 @@ namespace Slice ::IceInternal::Output&, const OperationPtr&, const std::string&, - const CommentPtr&, + const DocCommentPtr&, bool); void writeSeeAlso(::IceInternal::Output&, const UnitPtr&, const std::string&); }; diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 55bfc689d55..31cdf0c7cc8 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -163,7 +163,7 @@ namespace } } - void writeDeprecated(Output& out, const CommentPtr& comment, const ContainedPtr& contained) + void writeDeprecated(Output& out, const DocCommentPtr& comment, const ContainedPtr& contained) { // JavaScript doesn't provide a way to deprecate elements other than by using a comment, so we map both the // Slice @deprecated tag and the deprecated metadata argument to a `@deprecated` JSDoc tag. @@ -247,7 +247,7 @@ namespace OpDocAllParams }; - void writeOpDocExceptions(Output& out, const OperationPtr& op, const CommentPtr& doc) + void writeOpDocExceptions(Output& out, const OperationPtr& op, const DocCommentPtr& doc) { map exDoc = doc->exceptions(); for (map::iterator p = exDoc.begin(); p != exDoc.end(); ++p) @@ -479,7 +479,7 @@ void Slice::JsVisitor::writeDocCommentFor(const ContainedPtr& p, bool includeDeprecated) { assert(!dynamic_pointer_cast(p)); - CommentPtr comment = p->parseComment(jsLinkFormatter); + DocCommentPtr comment = p->parseDocComment(jsLinkFormatter); if (!comment && (!includeDeprecated || !p->isDeprecated())) { // There's nothing to write for this doc-comment. @@ -2376,7 +2376,7 @@ Slice::Gen::TypeScriptVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - if (CommentPtr comment = dataMember->parseComment(jsLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(jsLinkFormatter)) { _out << nl << " * @param " << fixId(dataMember->name()) << " " << getDocSentence(comment->overview()); } @@ -2425,7 +2425,7 @@ void Slice::Gen::TypeScriptVisitor::writeOpDocSummary( Output& out, const OperationPtr& op, - const CommentPtr& comment, + const DocCommentPtr& comment, bool forDispatch) { out << nl << "/**"; @@ -2562,7 +2562,7 @@ Slice::Gen::TypeScriptVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } _out << sp; - writeOpDocSummary(_out, op, op->parseComment(jsLinkFormatter), false); + writeOpDocSummary(_out, op, op->parseDocComment(jsLinkFormatter), false); _out << nl << fixId(op->name()) << spar; for (const auto& param : inParams) { @@ -2658,7 +2658,7 @@ Slice::Gen::TypeScriptVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) } _out << sp; - writeOpDocSummary(_out, op, op->parseComment(jsLinkFormatter), true); + writeOpDocSummary(_out, op, op->parseDocComment(jsLinkFormatter), true); _out << nl << "abstract " << fixId(op->name()) << spar; for (const auto& param : inParams) { @@ -2736,7 +2736,7 @@ Slice::Gen::TypeScriptVisitor::visitExceptionStart(const ExceptionPtr& p) _out << nl << " * One-shot constructor to initialize all data members."; for (const auto& dataMember : allDataMembers) { - if (CommentPtr comment = dataMember->parseComment(jsLinkFormatter)) + if (DocCommentPtr comment = dataMember->parseDocComment(jsLinkFormatter)) { _out << nl << " * @param " << fixId(dataMember->name()) << " " << getDocSentence(comment->overview()); } diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h index 1b9d915300e..9f5d4aa7099 100644 --- a/cpp/src/slice2js/Gen.h +++ b/cpp/src/slice2js/Gen.h @@ -180,7 +180,7 @@ namespace Slice void writeOpDocSummary( ::IceInternal::Output& out, const OperationPtr& op, - const CommentPtr& doc, + const DocCommentPtr& doc, bool forDispatch); // The module name of the current unit. diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp index 4c2c80127c1..44f9fb7dfdf 100644 --- a/cpp/src/slice2matlab/Main.cpp +++ b/cpp/src/slice2matlab/Main.cpp @@ -860,7 +860,7 @@ namespace void writeDocSummary(IceInternal::Output& out, const ContainedPtr& p) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; @@ -890,7 +890,7 @@ namespace for (const auto& enumerator : enumerators) { out << nl << "% " << fixEnumerator(enumerator->name()); - CommentPtr enumeratorDoc = enumerator->parseComment(matlabLinkFormatter, true); + DocCommentPtr enumeratorDoc = enumerator->parseDocComment(matlabLinkFormatter, true); if (enumeratorDoc) { StringList enumeratorOverview = enumeratorDoc->overview(); @@ -913,7 +913,7 @@ namespace for (const auto& member : members) { out << nl << "% " << fixIdent(member->name()); - if (CommentPtr memberDoc = member->parseComment(matlabLinkFormatter, true)) + if (DocCommentPtr memberDoc = member->parseDocComment(matlabLinkFormatter, true)) { StringList memberOverview = memberDoc->overview(); if (!memberOverview.empty()) @@ -935,7 +935,7 @@ namespace for (const auto& member : members) { out << nl << "% " << fixExceptionMember(member->name()); - if (CommentPtr memberDoc = member->parseComment(matlabLinkFormatter, true)) + if (DocCommentPtr memberDoc = member->parseDocComment(matlabLinkFormatter, true)) { StringList memberOverview = memberDoc->overview(); if (!memberOverview.empty()) @@ -957,7 +957,7 @@ namespace for (const auto& member : members) { out << nl << "% " << fixIdent(member->name()); - if (CommentPtr memberDoc = member->parseComment(matlabLinkFormatter, true)) + if (DocCommentPtr memberDoc = member->parseDocComment(matlabLinkFormatter, true)) { StringList memberOverview = memberDoc->overview(); if (!memberOverview.empty()) @@ -995,7 +995,7 @@ namespace void writeOpDocSummary(IceInternal::Output& out, const OperationPtr& p, bool async) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; @@ -1156,7 +1156,7 @@ namespace void writeProxyDocSummary(IceInternal::Output& out, const InterfaceDefPtr& p) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; @@ -1184,7 +1184,7 @@ namespace for (OperationList::const_iterator q = ops.begin(); q != ops.end(); ++q) { OperationPtr op = *q; - CommentPtr opdoc = op->parseComment(matlabLinkFormatter, true); + DocCommentPtr opdoc = op->parseDocComment(matlabLinkFormatter, true); out << nl << "% " << fixOp(op->name()); if (opdoc) { @@ -1235,7 +1235,7 @@ namespace void writeMemberDoc(IceInternal::Output& out, const DataMemberPtr& p) { - CommentPtr doc = p->parseComment(matlabLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(matlabLinkFormatter, true); if (!doc) { return; diff --git a/cpp/src/slice2py/Python.cpp b/cpp/src/slice2py/Python.cpp index c1773b5082e..b97ece1fbd8 100644 --- a/cpp/src/slice2py/Python.cpp +++ b/cpp/src/slice2py/Python.cpp @@ -536,8 +536,6 @@ Slice::Python::compile(const vector& argv) Ice::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); - bool keepComments = true; - ostringstream os; if (dependxml) { @@ -592,7 +590,7 @@ Slice::Python::compile(const vector& argv) else { PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__"); + FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2PY__"); if (cppHandle == 0) { diff --git a/cpp/src/slice2py/PythonUtil.cpp b/cpp/src/slice2py/PythonUtil.cpp index 40e8e441613..880de7a5836 100644 --- a/cpp/src/slice2py/PythonUtil.cpp +++ b/cpp/src/slice2py/PythonUtil.cpp @@ -275,14 +275,14 @@ namespace Slice void writeDocstring(const string&, const EnumeratorList&); typedef map StringMap; - struct OpComment + struct OpDocComment { vector description; map> params; vector returns; map> exceptions; }; - bool parseOpComment(const string&, OpComment&); + bool parseOpDocComment(const string&, OpDocComment&); enum DocstringMode { @@ -437,7 +437,7 @@ Slice::Python::CodeVisitor::visitModuleStart(const ModulePtr& p) } _out << nl << "__name__ = '" << abs << "'"; - writeDocstring(p->comment(), "_M_" + abs + ".__doc__ = "); + writeDocstring(p->docComment(), "_M_" + abs + ".__doc__ = "); _moduleStack.push_front(abs); return true; @@ -574,7 +574,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) _out.inc(); - writeDocstring(p->comment(), p->dataMembers()); + writeDocstring(p->docComment(), p->dataMembers()); // // __init__ @@ -1151,7 +1151,7 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p) DataMemberList members = p->dataMembers(); - writeDocstring(p->comment(), members); + writeDocstring(p->docComment(), members); // // __init__ @@ -1291,7 +1291,7 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p) _out << nl << "class " << name << "(object):"; _out.inc(); - writeDocstring(p->comment(), members); + writeDocstring(p->docComment(), members); _out << nl << "def __init__(self"; writeConstructorParams(memberList); @@ -1585,7 +1585,7 @@ Slice::Python::CodeVisitor::visitEnum(const EnumPtr& p) _out << nl << "class " << name << "(Ice.EnumBase):"; _out.inc(); - writeDocstring(p->comment(), enumerators); + writeDocstring(p->docComment(), enumerators); _out << sp << nl << "def __init__(self, _n, _v):"; _out.inc(); @@ -2248,7 +2248,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb map> docs; for (const auto& member : members) { - vector doc = stripMarkup(member->comment()); + vector doc = stripMarkup(member->docComment()); if (!doc.empty()) { docs[member->name()] = doc; @@ -2304,7 +2304,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat map> docs; for (const auto& enumerator : enumerators) { - vector doc = stripMarkup(enumerator->comment()); + vector doc = stripMarkup(enumerator->docComment()); if (!doc.empty()) { docs[enumerator->name()] = doc; @@ -2339,7 +2339,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat } bool -Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c) +Slice::Python::CodeVisitor::parseOpDocComment(const string& comment, OpDocComment& c) { // // Remove most javadoc & HTML markup. @@ -2507,8 +2507,8 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c) void Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode mode) { - OpComment comment; - if (!parseOpComment(op->comment(), comment)) + OpDocComment comment; + if (!parseOpDocComment(op->docComment(), comment)) { return; } diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp index eafd7771195..50fe86996db 100644 --- a/cpp/src/slice2swift/SwiftUtil.cpp +++ b/cpp/src/slice2swift/SwiftUtil.cpp @@ -346,7 +346,7 @@ SwiftGenerator::writeDocSentence(IceInternal::Output& out, const StringList& lin void SwiftGenerator::writeDocSummary(IceInternal::Output& out, const ContainedPtr& p) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -382,7 +382,7 @@ SwiftGenerator::writeDocSummary(IceInternal::Output& out, const ContainedPtr& p) void SwiftGenerator::writeOpDocSummary(IceInternal::Output& out, const OperationPtr& p, bool dispatch) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -526,7 +526,7 @@ SwiftGenerator::writeOpDocSummary(IceInternal::Output& out, const OperationPtr& void SwiftGenerator::writeProxyDocSummary(IceInternal::Output& out, const InterfaceDefPtr& p, const string& swiftModule) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -552,7 +552,7 @@ SwiftGenerator::writeProxyDocSummary(IceInternal::Output& out, const InterfaceDe out << nl << "/// " << prx << " Methods:"; for (const auto& op : ops) { - CommentPtr opdoc = op->parseComment(swiftLinkFormatter, true); + DocCommentPtr opdoc = op->parseDocComment(swiftLinkFormatter, true); optional opDocOverview; if (opdoc) { @@ -583,7 +583,7 @@ SwiftGenerator::writeProxyDocSummary(IceInternal::Output& out, const InterfaceDe void SwiftGenerator::writeServantDocSummary(IceInternal::Output& out, const InterfaceDefPtr& p, const string& swiftModule) { - CommentPtr doc = p->parseComment(swiftLinkFormatter, true); + DocCommentPtr doc = p->parseDocComment(swiftLinkFormatter, true); if (!doc) { return; @@ -609,7 +609,7 @@ SwiftGenerator::writeServantDocSummary(IceInternal::Output& out, const Interface for (const auto& op : ops) { out << nl << "/// - " << fixIdent(op->name()); - CommentPtr opdoc = op->parseComment(swiftLinkFormatter, true); + DocCommentPtr opdoc = op->parseDocComment(swiftLinkFormatter, true); if (opdoc) { StringList opdocOverview = opdoc->overview(); diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp index e93638987b0..f339589f25d 100644 --- a/cpp/test/Ice/background/EndpointI.cpp +++ b/cpp/test/Ice/background/EndpointI.cpp @@ -200,15 +200,15 @@ EndpointI::expandHost() const } bool -EndpointI::isLoopback() const +EndpointI::isLoopbackOrMulticast() const { - return _endpoint->isLoopback(); + return _endpoint->isLoopbackOrMulticast(); } shared_ptr -EndpointI::withPublishedHost(string host) const +EndpointI::toPublishedEndpoint(string publishedHost) const { - return endpoint(_endpoint->withPublishedHost(std::move(host))); + return endpoint(_endpoint->toPublishedEndpoint(std::move(publishedHost))); } bool diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h index 99e89b69d5e..41bd61b0c13 100644 --- a/cpp/test/Ice/background/EndpointI.h +++ b/cpp/test/Ice/background/EndpointI.h @@ -35,8 +35,8 @@ class EndpointI final : public IceInternal::EndpointI, public std::enable_shared IceInternal::AcceptorPtr acceptor(const std::string&, const std::optional&) const final; std::vector expandHost() const final; - bool isLoopback() const final; - std::shared_ptr withPublishedHost(std::string host) const final; + bool isLoopbackOrMulticast() const final; + std::shared_ptr toPublishedEndpoint(std::string publishedHost) const final; bool equivalent(const IceInternal::EndpointIPtr&) const final; // From TestEndpoint diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp index dcc61f52245..87cd0e2997b 100644 --- a/cpp/test/Ice/info/AllTests.cpp +++ b/cpp/test/Ice/info/AllTests.cpp @@ -109,7 +109,9 @@ allTests(Test::TestHelper* helper) Ice::EndpointSeq endpoints = adapter->getEndpoints(); test(endpoints.size() == 2); Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints(); - test(endpoints == publishedEndpoints); + test(publishedEndpoints.size() == 2); + test(*endpoints[0] == *publishedEndpoints[0]); + test(*endpoints[1] == *publishedEndpoints[1]); Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo()); test(ipEndpoint); @@ -130,7 +132,8 @@ allTests(Test::TestHelper* helper) test(endpoints.size() == 1); adapter->setPublishedEndpoints(endpoints); publishedEndpoints = adapter->getPublishedEndpoints(); - test(endpoints == publishedEndpoints); + test(publishedEndpoints.size() == 1); + test(*endpoints[0] == *publishedEndpoints[0]); adapter->destroy(); diff --git a/csharp/src/Ice/Connection.cs b/csharp/src/Ice/Connection.cs index 70c8ceff802..ea5ad2ba9eb 100644 --- a/csharp/src/Ice/Connection.cs +++ b/csharp/src/Ice/Connection.cs @@ -25,57 +25,6 @@ public enum CompressBatch BasedOnProxy } - /// - /// Base class providing access to the connection details. - /// - public class ConnectionInfo - { - /// - /// The underlying connection information. - /// - public ConnectionInfo? underlying; - - /// - /// Whether the connection is an incoming connection (true) or an outgoing connection (false). - /// - public bool incoming; - - /// - /// The name of the adapter associated with the connection. - /// - public string adapterName; - - /// - /// The connection id. - /// - public string connectionId; - - /// - /// Initializes a new instance of the class. - /// - public ConnectionInfo() - { - adapterName = ""; - connectionId = ""; - } - - /// - /// Initializes a new instance of the class. - /// - /// The underlying connection information. - /// Whether the connection is an incoming connection (true) or an outgoing - /// connection (false). - /// The name of the adapter associated with the connection. - /// The connection id. - public ConnectionInfo(ConnectionInfo underlying, bool incoming, string adapterName, string connectionId) - { - this.underlying = underlying; - this.incoming = incoming; - this.adapterName = adapterName; - this.connectionId = connectionId; - } - } - public delegate void CloseCallback(Connection con); /// @@ -181,123 +130,56 @@ System.Threading.Tasks.Task flushBatchRequestsAsync( void throwException(); } - public class IPConnectionInfo : ConnectionInfo + /// + /// Base class providing access to the connection details. + /// + public class ConnectionInfo { - public string localAddress; - public int localPort; - public string remoteAddress; - public int remotePort; + /// + /// The underlying connection information. + /// + public ConnectionInfo? underlying; + + /// + /// Whether the connection is an incoming connection (true) or an outgoing connection (false). + /// + public bool incoming; + + /// + /// The name of the adapter associated with the connection. + /// + public string adapterName = ""; - public IPConnectionInfo() - { - localAddress = ""; - localPort = -1; - remoteAddress = ""; - remotePort = -1; - } + /// + /// The connection id. + /// + public string connectionId = ""; + } - public IPConnectionInfo( - ConnectionInfo underlying, - bool incoming, - string adapterName, - string connectionId, - string localAddress, - int localPort, - string remoteAddress, - int remotePort) - : base(underlying, incoming, adapterName, connectionId) - { - this.localAddress = localAddress; - this.localPort = localPort; - this.remoteAddress = remoteAddress; - this.remotePort = remotePort; - } + public class IPConnectionInfo : ConnectionInfo + { + public string localAddress = ""; + public int localPort = -1; + public string remoteAddress = ""; + public int remotePort = -1; } - public class TCPConnectionInfo : IPConnectionInfo + public sealed class TCPConnectionInfo : IPConnectionInfo { public int rcvSize; public int sndSize; - - public TCPConnectionInfo() - { - rcvSize = 0; - sndSize = 0; - } - - public TCPConnectionInfo( - ConnectionInfo underlying, - bool incoming, - string adapterName, - string connectionId, - string localAddress, - int localPort, - string remoteAddress, - int remotePort, - int rcvSize, - int sndSize) - : base(underlying, incoming, adapterName, connectionId, localAddress, localPort, remoteAddress, remotePort) - { - this.rcvSize = rcvSize; - this.sndSize = sndSize; - } } - public class UDPConnectionInfo : IPConnectionInfo + public sealed class UDPConnectionInfo : IPConnectionInfo { - public string mcastAddress; - public int mcastPort; + public string mcastAddress = ""; + public int mcastPort = -1; public int rcvSize; public int sndSize; - - public UDPConnectionInfo() - { - mcastAddress = ""; - mcastPort = -1; - rcvSize = 0; - sndSize = 0; - } - - public UDPConnectionInfo( - ConnectionInfo underlying, - bool incoming, - string adapterName, - string connectionId, - string localAddress, - int localPort, - string remoteAddress, - int remotePort, - string mcastAddress, - int mcastPort, - int rcvSize, - int sndSize) - : base(underlying, incoming, adapterName, connectionId, localAddress, localPort, remoteAddress, remotePort) - { - this.mcastAddress = mcastAddress; - this.mcastPort = mcastPort; - this.rcvSize = rcvSize; - this.sndSize = sndSize; - } } - public class WSConnectionInfo : ConnectionInfo + public sealed class WSConnectionInfo : ConnectionInfo { - public Dictionary headers; - - public WSConnectionInfo() - { - headers = []; - } - - public WSConnectionInfo( - ConnectionInfo underlying, - bool incoming, - string adapterName, - string connectionId, - Dictionary headers) - : base(underlying, incoming, adapterName, connectionId) - { - this.headers = headers; - } + public Dictionary headers = []; } } diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 4504da19a81..5f5145637cb 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -807,7 +807,7 @@ public override void message(ThreadPoolCurrent current) // // Connection is validated on first message. This is only used by - // setState() to check wether or not we can print a connection + // setState() to check whether or not we can print a connection // warning (a client might close the connection forcefully if the // connection isn't validated, we don't want to print a warning // in this case). diff --git a/csharp/src/Ice/Endpoint.cs b/csharp/src/Ice/Endpoint.cs index d1ced0b16c7..3971ae8d98b 100644 --- a/csharp/src/Ice/Endpoint.cs +++ b/csharp/src/Ice/Endpoint.cs @@ -4,6 +4,18 @@ namespace Ice; +/// +/// Base class for all endpoints. +/// +public interface Endpoint +{ + /// + /// Returns the endpoint information. + /// + /// The endpoint information class. + EndpointInfo getInfo(); +} + /// /// Base class providing access to the endpoint details. /// @@ -35,29 +47,6 @@ public abstract class EndpointInfo /// Returns true if this endpoint is secure; otherwise false. /// True if the endpoint is secure. public abstract bool secure(); - - protected EndpointInfo() - { - } - - protected EndpointInfo(EndpointInfo? underlying, int timeout, bool compress) - { - this.underlying = underlying; - this.timeout = timeout; - this.compress = compress; - } -} - -/// -/// Base class for all endpoints. -/// -public interface Endpoint -{ - /// - /// Returns the endpoint information. - /// - /// The endpoint information class. - EndpointInfo getInfo(); } /// @@ -68,7 +57,7 @@ public abstract class IPEndpointInfo : EndpointInfo /// /// The host or address configured with the endpoint. /// - public string host; + public string host = ""; /// /// The endpoint's port number. @@ -78,33 +67,11 @@ public abstract class IPEndpointInfo : EndpointInfo /// /// The source IP address. /// - public string sourceAddress; - - protected IPEndpointInfo() - { - this.host = ""; - this.sourceAddress = ""; - } - - protected IPEndpointInfo(EndpointInfo underlying, int timeout, bool compress, string host, int port, string sourceAddress) - : base(underlying, timeout, compress) - { - this.host = host; - this.port = port; - this.sourceAddress = sourceAddress; - } + public string sourceAddress = ""; } public abstract class TCPEndpointInfo : IPEndpointInfo { - protected TCPEndpointInfo() - { - } - - protected TCPEndpointInfo(EndpointInfo underlying, int timeout, bool compress, string host, int port, string sourceAddress) - : base(underlying, timeout, compress, host, port, sourceAddress) - { - } } /// @@ -112,21 +79,9 @@ protected TCPEndpointInfo(EndpointInfo underlying, int timeout, bool compress, s /// public abstract class UDPEndpointInfo : IPEndpointInfo { - public string mcastInterface; + public string mcastInterface = ""; public int mcastTtl; - - protected UDPEndpointInfo() - { - this.mcastInterface = ""; - } - - protected UDPEndpointInfo(EndpointInfo underlying, int timeout, bool compress, string host, int port, string sourceAddress, string mcastInterface, int mcastTtl) - : base(underlying, timeout, compress, host, port, sourceAddress) - { - this.mcastInterface = mcastInterface; - this.mcastTtl = mcastTtl; - } } /// @@ -137,18 +92,7 @@ public abstract class WSEndpointInfo : EndpointInfo /// /// The URI configured with the endpoint. /// - public string resource; - - protected WSEndpointInfo() - { - resource = ""; - } - - protected WSEndpointInfo(EndpointInfo underlying, int timeout, bool compress, string resource) - : base(underlying, timeout, compress) - { - this.resource = resource; - } + public string resource = ""; } /// @@ -164,18 +108,5 @@ public abstract class OpaqueEndpointInfo : EndpointInfo /// /// The raw encoding of the opaque endpoint. /// - public byte[] rawBytes; - - protected OpaqueEndpointInfo() - { - rawEncoding = new EncodingVersion(); - rawBytes = []; - } - - protected OpaqueEndpointInfo(EndpointInfo underlying, int timeout, bool compress, EncodingVersion rawEncoding, byte[] rawBytes) - : base(underlying, timeout, compress) - { - this.rawEncoding = rawEncoding; - this.rawBytes = rawBytes; - } + public byte[] rawBytes = []; } diff --git a/csharp/src/Ice/Internal/EndpointI.cs b/csharp/src/Ice/Internal/EndpointI.cs index 1907cff840a..6ffa5cac0f0 100644 --- a/csharp/src/Ice/Internal/EndpointI.cs +++ b/csharp/src/Ice/Internal/EndpointI.cs @@ -133,11 +133,11 @@ public virtual void streamWrite(Ice.OutputStream s) // Used only for server endpoints. public abstract List expandHost(); - // Returns true when the most underlying endpoint is an IP endpoint with a loopback address. - public abstract bool isLoopback(); + // Returns true when the most underlying endpoint is an IP endpoint with a loopback or multicast address. + public abstract bool isLoopbackOrMulticast(); - // Returns a new endpoint with the specified host; returns this when this operation is not applicable. - public abstract EndpointI withPublishedHost(string host); + // Returns a new endpoint with the specified host (if not empty) and all local options cleared. May return this. + public abstract EndpointI toPublishedEndpoint(string publishedHost); // // Check whether the endpoint is equivalent to another one. diff --git a/csharp/src/Ice/Internal/IPEndpointI.cs b/csharp/src/Ice/Internal/IPEndpointI.cs index 1a2ea7bd855..c16d316a62d 100644 --- a/csharp/src/Ice/Internal/IPEndpointI.cs +++ b/csharp/src/Ice/Internal/IPEndpointI.cs @@ -128,10 +128,18 @@ public override List expandHost() // Empty host_ means the endpoint is a wildcard address. This method must be called only on an endpoint with an // empty host or an IP address. - public override bool isLoopback() => - host_.Length > 0 && IPAddress.IsLoopback(IPAddress.Parse(host_)); - - public override EndpointI withPublishedHost(string host) => createEndpoint(host, port_, connectionId_); + public override bool isLoopbackOrMulticast() + { + if (host_.Length > 0) + { + var ipEndPoint = IPEndPoint.Parse(host_); + return IPAddress.IsLoopback(ipEndPoint.Address) || Network.isMulticast(ipEndPoint); + } + else + { + return false; + } + } public override bool equivalent(EndpointI endpoint) { @@ -142,8 +150,7 @@ public override bool equivalent(EndpointI endpoint) IPEndpointI ipEndpointI = (IPEndpointI)endpoint; return ipEndpointI.type() == type() && ipEndpointI.host_.Equals(host_, StringComparison.Ordinal) && - ipEndpointI.port_ == port_ && - Network.addressEquals(ipEndpointI.sourceAddr_, sourceAddr_); + ipEndpointI.port_ == port_; } public virtual List connectors(List addresses, NetworkProxy proxy) diff --git a/csharp/src/Ice/Internal/OpaqueEndpointI.cs b/csharp/src/Ice/Internal/OpaqueEndpointI.cs index 52426e8c0e4..dc870715a8a 100644 --- a/csharp/src/Ice/Internal/OpaqueEndpointI.cs +++ b/csharp/src/Ice/Internal/OpaqueEndpointI.cs @@ -59,12 +59,13 @@ public override string ToString() return "opaque -t " + _type + " -e " + Ice.Util.encodingVersionToString(_rawEncoding) + " -v " + val; } - private sealed class InfoI : Ice.OpaqueEndpointInfo + private sealed class InfoI : OpaqueEndpointInfo { - public InfoI(short type, Ice.EncodingVersion rawEncoding, byte[] rawBytes) - : base(null, -1, false, rawEncoding, rawBytes) + public InfoI(short type, EncodingVersion rawEncoding, byte[] rawBytes) { _type = type; + this.rawEncoding = rawEncoding; + this.rawBytes = rawBytes; } public override short type() @@ -213,9 +214,9 @@ public override Acceptor acceptor(string adapterName, SslServerAuthenticationOpt public override List expandHost() => [this]; - public override bool isLoopback() => false; + public override bool isLoopbackOrMulticast() => false; - public override EndpointI withPublishedHost(string host) => this; + public override EndpointI toPublishedEndpoint(string host) => this; // // Check whether the endpoint is equivalent to another one. diff --git a/csharp/src/Ice/Internal/TcpEndpointI.cs b/csharp/src/Ice/Internal/TcpEndpointI.cs index 8114db0d626..2163e103193 100644 --- a/csharp/src/Ice/Internal/TcpEndpointI.cs +++ b/csharp/src/Ice/Internal/TcpEndpointI.cs @@ -212,6 +212,21 @@ public override void fillEndpointInfo(Ice.IPEndpointInfo info) info.compress = _compress; } + public override EndpointI toPublishedEndpoint(string publishedHost) + { + // A server endpoint can't have a source address or connection ID. + Debug.Assert(sourceAddr_ is null && connectionId_.Length == 0); + + if (publishedHost.Length == 0) + { + return this; + } + else + { + return new TcpEndpointI(instance_, publishedHost, port_, sourceAddr: null, _timeout, conId: "", _compress); + } + } + protected override bool checkOption(string option, string argument, string endpoint) { if (base.checkOption(option, argument, endpoint)) diff --git a/csharp/src/Ice/Internal/UdpEndpointI.cs b/csharp/src/Ice/Internal/UdpEndpointI.cs index 6fe5be0b450..f12d39b00f9 100644 --- a/csharp/src/Ice/Internal/UdpEndpointI.cs +++ b/csharp/src/Ice/Internal/UdpEndpointI.cs @@ -332,6 +332,18 @@ public override void fillEndpointInfo(Ice.IPEndpointInfo info) } } + public override EndpointI toPublishedEndpoint(string publishedHost) => + new UdpEndpointI( + instance_, + publishedHost.Length > 0 ? publishedHost : host_, + port_, + sourceAddr: null, + mcastInterface: "", + mttl: -1, + conn: false, // for "connect" + conId: "", + _compress); + protected override bool checkOption(string option, string argument, string endpoint) { if (base.checkOption(option, argument, endpoint)) diff --git a/csharp/src/Ice/Internal/WSEndpoint.cs b/csharp/src/Ice/Internal/WSEndpoint.cs index b715ff47e79..47b22b2b048 100644 --- a/csharp/src/Ice/Internal/WSEndpoint.cs +++ b/csharp/src/Ice/Internal/WSEndpoint.cs @@ -217,9 +217,10 @@ public WSEndpoint endpoint(EndpointI delEndp) public override List expandHost() => _delegate.expandHost().Select(e => endpoint(e) as EndpointI).ToList(); - public override bool isLoopback() => _delegate.isLoopback(); + public override bool isLoopbackOrMulticast() => _delegate.isLoopbackOrMulticast(); - public override EndpointI withPublishedHost(string host) => endpoint(_delegate.withPublishedHost(host)); + public override EndpointI toPublishedEndpoint(string publishedHost) => + endpoint(_delegate.toPublishedEndpoint(publishedHost)); public override bool equivalent(EndpointI endpoint) { diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index b837d910604..7fa969709cf 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -1326,8 +1326,8 @@ private EndpointI[] computePublishedEndpoints() // endpoints. endpoints = _incomingConnectionFactories.Select(f => f.endpoint()); - // Remove all loopback endpoints. - IEnumerable endpointsNoLoopback = endpoints.Where(e => !e.isLoopback()); + // Remove all loopback/multicast endpoints. + IEnumerable endpointsNoLoopback = endpoints.Where(e => !e.isLoopbackOrMulticast()); // Retrieve published host string publishedHost = _instance.initializationData().properties!.getProperty($"{_name}.PublishedHost"); @@ -1336,20 +1336,16 @@ private EndpointI[] computePublishedEndpoints() { endpoints = endpointsNoLoopback; - // For non-loopback endpoints, we use the fully qualified name of the local host as default for - // publishedHost. + // For non-loopback & non-multicast endpoints, we use the fully qualified name of the local host as + // default for publishedHost. if (publishedHost.Length == 0) { publishedHost = Dns.GetHostEntry("").HostName; // fully qualified name of local host } } - if (publishedHost.Length > 0) - { - // Replace the host in all endpoints by publishedHost (when applicable). - endpoints = endpoints.Select(e => e.withPublishedHost(publishedHost)).Distinct(); - } - // else keep the loopback-only endpoints as-is (with IP addresses) + // Replace the host in all endpoints by publishedHost (when applicable) and clear all local options. + endpoints = endpoints.Select(e => e.toPublishedEndpoint(publishedHost)).Distinct(); } } diff --git a/csharp/src/Ice/SSL/ConnectionInfo.cs b/csharp/src/Ice/SSL/ConnectionInfo.cs index 513d8840ece..61b2e5df641 100644 --- a/csharp/src/Ice/SSL/ConnectionInfo.cs +++ b/csharp/src/Ice/SSL/ConnectionInfo.cs @@ -6,31 +6,9 @@ namespace Ice.SSL; -public class ConnectionInfo : Ice.ConnectionInfo +public sealed class ConnectionInfo : Ice.ConnectionInfo { - public string cipher; - - public X509Certificate2[] certs; + public string cipher = ""; + public X509Certificate2[] certs = []; public bool verified; - - public ConnectionInfo() - { - cipher = ""; - certs = []; - } - - public ConnectionInfo( - Ice.ConnectionInfo underlying, - bool incoming, - string adapterName, - string connectionId, - string cipher, - X509Certificate2[] certs, - bool verified) - : base(underlying, incoming, adapterName, connectionId) - { - this.cipher = cipher; - this.certs = certs; - this.verified = verified; - } } diff --git a/csharp/src/Ice/SSL/EndpointI.cs b/csharp/src/Ice/SSL/EndpointI.cs index 5a84bbabb4e..18a20827a87 100644 --- a/csharp/src/Ice/SSL/EndpointI.cs +++ b/csharp/src/Ice/SSL/EndpointI.cs @@ -155,9 +155,10 @@ public EndpointI endpoint(Ice.Internal.EndpointI del) public override List expandHost() => _delegate.expandHost().Select(e => endpoint(e) as Internal.EndpointI).ToList(); - public override bool isLoopback() => _delegate.isLoopback(); + public override bool isLoopbackOrMulticast() => _delegate.isLoopbackOrMulticast(); - public override EndpointI withPublishedHost(string host) => endpoint(_delegate.withPublishedHost(host)); + public override EndpointI toPublishedEndpoint(string publishedHost) => + endpoint(_delegate.toPublishedEndpoint(publishedHost)); public override bool equivalent(Ice.Internal.EndpointI endpoint) { diff --git a/csharp/src/Ice/SSL/EndpointInfo.cs b/csharp/src/Ice/SSL/EndpointInfo.cs index 52205b7eac8..a624e5cf51f 100644 --- a/csharp/src/Ice/SSL/EndpointInfo.cs +++ b/csharp/src/Ice/SSL/EndpointInfo.cs @@ -6,12 +6,4 @@ namespace Ice.SSL; public abstract class EndpointInfo : Ice.EndpointInfo { - protected EndpointInfo() - { - } - - protected EndpointInfo(Ice.EndpointInfo? underlying, int timeout, bool compress) - : base(underlying, timeout, compress) - { - } } diff --git a/csharp/src/IceLocatorDiscovery/PluginI.cs b/csharp/src/IceLocatorDiscovery/PluginI.cs index 582e94b3127..2df79758b4b 100644 --- a/csharp/src/IceLocatorDiscovery/PluginI.cs +++ b/csharp/src/IceLocatorDiscovery/PluginI.cs @@ -11,11 +11,6 @@ public Ice.Plugin create(Ice.Communicator communicator, string name, string[] args) => new PluginI(communicator); } -public interface Plugin : Ice.Plugin -{ - List getLocators(string instanceName, int waitTime); -} - internal class Request : TaskCompletionSource { public Request( @@ -206,48 +201,6 @@ public override Task } } - public List getLocators(string instanceName, int waitTime) - { - // - // Clear locators from previous search. - // - lock (_mutex) - { - _locators.Clear(); - } - - // - // Find a locator - // - invoke(null, null); - - // - // Wait for responses - // - if (instanceName.Length == 0) - { - Thread.Sleep(waitTime); - } - else - { - lock (_mutex) - { - while (!_locators.ContainsKey(instanceName) && _pending) - { - Monitor.Wait(_mutex, waitTime); - } - } - } - - // - // Return found locators - // - lock (_mutex) - { - return new List(_locators.Values); - } - } - public void foundLocator(Ice.LocatorPrx locator) { @@ -363,7 +316,6 @@ public void if (_pendingRequests.Count == 0) { _locators[locator.ice_getIdentity().category] = l; - Monitor.Pulse(_mutex); } else { @@ -427,7 +379,7 @@ public void foreach (var l in _lookups) { - _ = preformFindLocatorAsync(l.Key, l.Value); + _ = performFindLocatorAsync(l.Key, l.Value); } _timer.schedule(this, _timeout); } @@ -457,8 +409,11 @@ public void } } - async Task preformFindLocatorAsync(LookupPrx lookupPrx, LookupReplyPrx lookupReplyPrx) + async Task performFindLocatorAsync(LookupPrx lookupPrx, LookupReplyPrx lookupReplyPrx) { + // Exit the mutex lock before proceeding. + await Task.Yield(); + // Send multicast request. try { @@ -507,11 +462,7 @@ private void exception(Exception ex) _lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); } - if (_pendingRequests.Count == 0) - { - Monitor.Pulse(_mutex); - } - else + if (_pendingRequests.Count > 0) { foreach (Request req in _pendingRequests) { @@ -589,11 +540,7 @@ public void runTimerTask() _lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); } - if (_pendingRequests.Count == 0) - { - Monitor.Pulse(_mutex); - } - else + if (_pendingRequests.Count > 0) { foreach (Request req in _pendingRequests) { @@ -740,12 +687,6 @@ public void } } - private List - getLocators(string instanceName, int waitTime) - { - return _locator.getLocators(instanceName, waitTime); - } - private Ice.Communicator _communicator; private Ice.ObjectAdapter _locatorAdapter; private Ice.ObjectAdapter _replyAdapter; diff --git a/csharp/test/Ice/background/EndpointI.cs b/csharp/test/Ice/background/EndpointI.cs index baa87d1cb24..a598c632bed 100644 --- a/csharp/test/Ice/background/EndpointI.cs +++ b/csharp/test/Ice/background/EndpointI.cs @@ -176,9 +176,10 @@ public EndpointI endpoint(Ice.Internal.EndpointI delEndp) public override List expandHost() => _endpoint.expandHost().Select(e => new EndpointI(e) as Ice.Internal.EndpointI).ToList(); - public override bool isLoopback() => _endpoint.isLoopback(); + public override bool isLoopbackOrMulticast() => _endpoint.isLoopbackOrMulticast(); - public override EndpointI withPublishedHost(string host) => endpoint(_endpoint.withPublishedHost(host)); + public override EndpointI toPublishedEndpoint(string publishedHost) => + endpoint(_endpoint.toPublishedEndpoint(publishedHost)); public override bool equivalent(Ice.Internal.EndpointI endpoint) { diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionI.java index 2bf1ca860b1..9bfd611a3aa 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionI.java @@ -585,7 +585,7 @@ public void message(ThreadPoolCurrent current) { // // Connection is validated on first message. This is only used by - // setState() to check wether or not we can print a connection + // setState() to check whether or not we can print a connection // warning (a client might close the connection forcefully if the // connection isn't validated, we don't want to print a warning // in this case). diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionInfo.java index 166d3bc2530..2d29a9dc5e6 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ConnectionInfo.java @@ -1,35 +1,9 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Connection.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Base class providing access to the connection details. */ public class ConnectionInfo implements Cloneable { - public ConnectionInfo() { - this.adapterName = ""; - this.connectionId = ""; - } - - public ConnectionInfo( - ConnectionInfo underlying, boolean incoming, String adapterName, String connectionId) { - this.underlying = underlying; - this.incoming = incoming; - this.adapterName = adapterName; - this.connectionId = connectionId; - } - /** The information of the underyling transport or null if there's no underlying transport. */ public ConnectionInfo underlying; @@ -37,18 +11,18 @@ public ConnectionInfo( public boolean incoming; /** The name of the adapter associated with the connection. */ - public String adapterName; + public String adapterName = ""; /** The connection id. */ - public String connectionId; + public String connectionId = ""; + @Override public ConnectionInfo clone() { - ConnectionInfo c = null; try { - c = (ConnectionInfo) super.clone(); + return (ConnectionInfo) super.clone(); } catch (CloneNotSupportedException ex) { assert false; // impossible + return null; } - return c; } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointI.java index 69aabc19bcc..ce50e8f0412 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointI.java @@ -116,12 +116,13 @@ public abstract Acceptor acceptor( // Used only for server endpoints. public abstract java.util.List expandHost(); - // Returns true when the most underlying endpoint is an IP endpoint with a loopback address. - public abstract boolean isLoopback(); + // Returns true when the most underlying endpoint is an IP endpoint with a loopback or multicast + // address. + public abstract boolean isLoopbackOrMulticast(); - // Returns a new endpoint with the specified host; returns this when this operation is not - // applicable. - public abstract EndpointI withPublishedHost(String host); + // Returns a new endpoint with the specified host (if not empty) and all local options cleared. + // May return this. + public abstract EndpointI toPublishedEndpoint(String publishedHost); // // Check whether the endpoint is equivalent to another one. diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointInfo.java index 3bda803f052..034e3175d0d 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/EndpointInfo.java @@ -1,31 +1,10 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Endpoint.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Base class providing access to the endpoint details. */ public abstract class EndpointInfo implements Cloneable { - public EndpointInfo() {} - - public EndpointInfo(EndpointInfo underlying, int timeout, boolean compress) { - this.underlying = underlying; - this.timeout = timeout; - this.compress = compress; - } - - /** The information of the underyling endpoint or null if there's no underlying endpoint. */ + /** The information of the underlying endpoint or null if there's no underlying endpoint. */ public EndpointInfo underlying; /** The timeout for the endpoint in milliseconds. 0 means non-blocking, -1 means no timeout. */ @@ -55,13 +34,13 @@ public EndpointInfo(EndpointInfo underlying, int timeout, boolean compress) { */ public abstract boolean secure(); + @Override public EndpointInfo clone() { - EndpointInfo c = null; try { - c = (EndpointInfo) super.clone(); + return (EndpointInfo) super.clone(); } catch (CloneNotSupportedException ex) { assert false; // impossible + return null; } - return c; } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPConnectionInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPConnectionInfo.java index 87b42d916c2..b312b4ed842 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPConnectionInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPConnectionInfo.java @@ -1,59 +1,18 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Connection.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Provides access to the connection details of an IP connection */ public class IPConnectionInfo extends ConnectionInfo { - public IPConnectionInfo() { - super(); - this.localAddress = ""; - this.localPort = -1; - this.remoteAddress = ""; - this.remotePort = -1; - } - - public IPConnectionInfo( - ConnectionInfo underlying, - boolean incoming, - String adapterName, - String connectionId, - String localAddress, - int localPort, - String remoteAddress, - int remotePort) { - super(underlying, incoming, adapterName, connectionId); - this.localAddress = localAddress; - this.localPort = localPort; - this.remoteAddress = remoteAddress; - this.remotePort = remotePort; - } - /** The local address. */ - public String localAddress; + public String localAddress = ""; /** The local port. */ - public int localPort; + public int localPort = -1; /** The remote address. */ - public String remoteAddress; + public String remoteAddress = ""; /** The remote port. */ - public int remotePort; - - public IPConnectionInfo clone() { - return (IPConnectionInfo) super.clone(); - } + public int remotePort = -1; } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointI.java index f83fd495882..ea4dfc3124a 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointI.java @@ -115,19 +115,19 @@ public java.util.List expandHost() { } @Override - public boolean isLoopback() { - try { - return !_host.isEmpty() && java.net.InetAddress.getByName(_host).isLoopbackAddress(); - } catch (java.net.UnknownHostException ex) { + public boolean isLoopbackOrMulticast() { + if (_host.isEmpty()) { return false; + } else { + try { + var address = java.net.InetAddress.getByName(_host); + return address.isLoopbackAddress() || address.isMulticastAddress(); + } catch (java.net.UnknownHostException ex) { + return false; + } } } - @Override - public EndpointI withPublishedHost(String host) { - return createEndpoint(host, _port, _connectionId); - } - @Override public boolean equivalent(EndpointI endpoint) { if (!(endpoint instanceof IPEndpointI)) { @@ -137,8 +137,7 @@ public boolean equivalent(EndpointI endpoint) { IPEndpointI ipEndpointI = (IPEndpointI) endpoint; return ipEndpointI.type() == type() && ipEndpointI._normalizedHost.equals(_normalizedHost) - && ipEndpointI._port == _port - && java.util.Objects.equals(ipEndpointI._sourceAddr, _sourceAddr); + && ipEndpointI._port == _port; } public java.util.List connectors( diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointInfo.java index 6b5aaae71ca..55036b84b24 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/IPEndpointInfo.java @@ -1,17 +1,4 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Endpoint.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; @@ -21,35 +8,12 @@ * @see Endpoint */ public abstract class IPEndpointInfo extends EndpointInfo { - public IPEndpointInfo() { - super(); - this.host = ""; - this.sourceAddress = ""; - } - - public IPEndpointInfo( - EndpointInfo underlying, - int timeout, - boolean compress, - String host, - int port, - String sourceAddress) { - super(underlying, timeout, compress); - this.host = host; - this.port = port; - this.sourceAddress = sourceAddress; - } - /** The host or address configured with the endpoint. */ - public String host; + public String host = ""; /** The port number. */ public int port; /** The source IP address. */ - public String sourceAddress; - - public IPEndpointInfo clone() { - return (IPEndpointInfo) super.clone(); - } + public String sourceAddress = ""; } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java index 6379a5d236e..f8ac6195807 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java @@ -1398,9 +1398,9 @@ private EndpointI[] computePublishedEndpoints() { .map(IncomingConnectionFactory::endpoint) .toList(); - // Remove all loopback endpoints. + // Remove all loopback/multicast endpoints. var endpointsNoLoopback = - endpointsList.stream().filter(e -> !e.isLoopback()).toList(); + endpointsList.stream().filter(e -> !e.isLoopbackOrMulticast()).toList(); // Retrieve published host. String publishedHost = @@ -1416,8 +1416,8 @@ private EndpointI[] computePublishedEndpoints() { } else { endpoints = endpointsNoLoopback.stream(); - // For non-loopback endpoints, we use the fully qualified name of the local host - // as default for publishedHost. + // For non-loopback/multicast endpoints, we use the fully qualified name of the + // local host as default for publishedHost. if (publishedHost.isEmpty()) { try { publishedHost = InetAddress.getLocalHost().getHostName(); @@ -1428,14 +1428,12 @@ private EndpointI[] computePublishedEndpoints() { } } - if (!publishedHost.isEmpty()) { - // Replace the host in all endpoints by publishedHost (when applicable). - final String publishedHostCapture = publishedHost; - endpoints = - endpoints - .map(e -> e.withPublishedHost(publishedHostCapture)) - .distinct(); - } + // Replace the host in all endpoints by publishedHost (when applicable) and clear + // local options. + final String publishedHostCapture = publishedHost; + endpoints = + endpoints.map(e -> e.toPublishedEndpoint(publishedHostCapture)).distinct(); + endpointsArray = endpoints.toArray(EndpointI[]::new); } else { endpointsArray = endpointsList.toArray(EndpointI[]::new); diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointI.java index e5328abfa69..f1bfdee1066 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointI.java @@ -51,22 +51,27 @@ public void streamWriteImpl(OutputStream s) { // @Override public EndpointInfo getInfo() { - return new OpaqueEndpointInfo(null, -1, false, _rawEncoding, _rawBytes) { - @Override - public short type() { - return _type; - } + var info = + new OpaqueEndpointInfo() { + @Override + public short type() { + return _type; + } - @Override - public boolean datagram() { - return false; - } + @Override + public boolean datagram() { + return false; + } - @Override - public boolean secure() { - return false; - } - }; + @Override + public boolean secure() { + return false; + } + }; + + info.rawEncoding = _rawEncoding; + info.rawBytes = _rawBytes; + return info; } // @@ -186,12 +191,12 @@ public java.util.List expandHost() { } @Override - public boolean isLoopback() { + public boolean isLoopbackOrMulticast() { return false; } @Override - public EndpointI withPublishedHost(String host) { + public EndpointI toPublishedEndpoint(String publishedHost) { return this; } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointInfo.java index 1a1fe7442d5..b5edba5aae9 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/OpaqueEndpointInfo.java @@ -1,17 +1,4 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Endpoint.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; @@ -21,29 +8,9 @@ * @see Endpoint */ public abstract class OpaqueEndpointInfo extends EndpointInfo { - public OpaqueEndpointInfo() { - super(); - this.rawEncoding = new EncodingVersion(); - } - - public OpaqueEndpointInfo( - EndpointInfo underlying, - int timeout, - boolean compress, - EncodingVersion rawEncoding, - byte[] rawBytes) { - super(underlying, timeout, compress); - this.rawEncoding = rawEncoding; - this.rawBytes = rawBytes; - } - /** The encoding version of the opaque endpoint (to decode or encode the rawBytes). */ public EncodingVersion rawEncoding; /** The raw encoding of the opaque endpoint. */ public byte[] rawBytes; - - public OpaqueEndpointInfo clone() { - return (OpaqueEndpointInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/ConnectionInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/ConnectionInfo.java index fb35c8409d1..aefb05bc4d1 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/ConnectionInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/ConnectionInfo.java @@ -1,40 +1,15 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice.SSL; /** Provides access to the connection details of an SSL connection */ -public class ConnectionInfo extends com.zeroc.Ice.ConnectionInfo { - public ConnectionInfo() { - super(); - this.cipher = ""; - } - - public ConnectionInfo( - com.zeroc.Ice.ConnectionInfo underlying, - boolean incoming, - String adapterName, - String connectionId, - String cipher, - java.security.cert.Certificate[] certs, - boolean verified) { - super(underlying, incoming, adapterName, connectionId); - this.cipher = cipher; - this.certs = certs; - this.verified = verified; - } - +public final class ConnectionInfo extends com.zeroc.Ice.ConnectionInfo { /** The negotiated cipher suite. */ - public String cipher; + public String cipher = ""; /** The certificate chain. */ public java.security.cert.Certificate[] certs; /** The certificate chain verification status. */ public boolean verified; - - public ConnectionInfo clone() { - return (ConnectionInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointI.java index a50fbc20a75..93b62c97192 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointI.java @@ -22,8 +22,8 @@ public void streamWriteImpl(com.zeroc.Ice.OutputStream s) { // @Override public com.zeroc.Ice.EndpointInfo getInfo() { - EndpointInfo info = - new EndpointInfo(_delegate.getInfo(), timeout(), compress()) { + var info = + new EndpointInfo() { @Override public short type() { return EndpointI.this.type(); @@ -39,8 +39,9 @@ public boolean secure() { return EndpointI.this.secure(); } }; - info.compress = info.underlying.compress; + info.underlying = _delegate.getInfo(); info.timeout = info.underlying.timeout; + info.compress = info.underlying.compress; return info; } @@ -169,13 +170,13 @@ public java.util.List expandHost() { } @Override - public boolean isLoopback() { - return _delegate.isLoopback(); + public boolean isLoopbackOrMulticast() { + return _delegate.isLoopbackOrMulticast(); } @Override - public com.zeroc.Ice.EndpointI withPublishedHost(String host) { - return endpoint(_delegate.withPublishedHost(host)); + public com.zeroc.Ice.EndpointI toPublishedEndpoint(String publishedHost) { + return endpoint(_delegate.toPublishedEndpoint(publishedHost)); } @Override diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointInfo.java index b9bd54fb62e..2bfc68d8337 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/SSL/EndpointInfo.java @@ -1,20 +1,6 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice.SSL; /** Provides access to an SSL endpoint information. */ -public abstract class EndpointInfo extends com.zeroc.Ice.EndpointInfo { - public EndpointInfo() { - super(); - } - - public EndpointInfo(com.zeroc.Ice.EndpointInfo underlying, int timeout, boolean compress) { - super(underlying, timeout, compress); - } - - public EndpointInfo clone() { - return (EndpointInfo) super.clone(); - } -} +public abstract class EndpointInfo extends com.zeroc.Ice.EndpointInfo {} diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPConnectionInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPConnectionInfo.java index 8b853686d5a..2c6e95582da 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPConnectionInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPConnectionInfo.java @@ -1,59 +1,12 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Connection.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Provides access to the connection details of a TCP connection */ -public class TCPConnectionInfo extends IPConnectionInfo { - public TCPConnectionInfo() { - super(); - this.rcvSize = 0; - this.sndSize = 0; - } - - public TCPConnectionInfo( - ConnectionInfo underlying, - boolean incoming, - String adapterName, - String connectionId, - String localAddress, - int localPort, - String remoteAddress, - int remotePort, - int rcvSize, - int sndSize) { - super( - underlying, - incoming, - adapterName, - connectionId, - localAddress, - localPort, - remoteAddress, - remotePort); - this.rcvSize = rcvSize; - this.sndSize = sndSize; - } - +public final class TCPConnectionInfo extends IPConnectionInfo { /** The connection buffer receive size. */ public int rcvSize; /** The connection buffer send size. */ public int sndSize; - - public TCPConnectionInfo clone() { - return (TCPConnectionInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPEndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPEndpointInfo.java index ec664e2fcb1..b3db4648414 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPEndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TCPEndpointInfo.java @@ -1,17 +1,4 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Endpoint.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; @@ -20,22 +7,4 @@ * * @see Endpoint */ -public abstract class TCPEndpointInfo extends IPEndpointInfo { - public TCPEndpointInfo() { - super(); - } - - public TCPEndpointInfo( - EndpointInfo underlying, - int timeout, - boolean compress, - String host, - int port, - String sourceAddress) { - super(underlying, timeout, compress, host, port, sourceAddress); - } - - public TCPEndpointInfo clone() { - return (TCPEndpointInfo) super.clone(); - } -} +public abstract class TCPEndpointInfo extends IPEndpointInfo {} diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java index fa28e53e54b..d5d29ca3c51 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/TcpEndpointI.java @@ -213,6 +213,17 @@ public int hashCode() { return h; } + @Override + public EndpointI toPublishedEndpoint(String publishedHost) { + // A server endpoint can't have a source address or connection ID. + assert (_sourceAddr == null && _connectionId.isEmpty()); + if (publishedHost.isEmpty()) { + return this; + } else { + return new TcpEndpointI(_instance, publishedHost, _port, null, _timeout, "", _compress); + } + } + @Override protected boolean checkOption(String option, String argument, String endpoint) { if (super.checkOption(option, argument, endpoint)) { diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPConnectionInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPConnectionInfo.java index ca5d9b62b85..d1a9fccbcc1 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPConnectionInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPConnectionInfo.java @@ -1,71 +1,18 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Connection.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Provides access to the connection details of a UDP connection */ -public class UDPConnectionInfo extends IPConnectionInfo { - public UDPConnectionInfo() { - super(); - this.mcastAddress = ""; - this.mcastPort = -1; - this.rcvSize = 0; - this.sndSize = 0; - } - - public UDPConnectionInfo( - ConnectionInfo underlying, - boolean incoming, - String adapterName, - String connectionId, - String localAddress, - int localPort, - String remoteAddress, - int remotePort, - String mcastAddress, - int mcastPort, - int rcvSize, - int sndSize) { - super( - underlying, - incoming, - adapterName, - connectionId, - localAddress, - localPort, - remoteAddress, - remotePort); - this.mcastAddress = mcastAddress; - this.mcastPort = mcastPort; - this.rcvSize = rcvSize; - this.sndSize = sndSize; - } - +public final class UDPConnectionInfo extends IPConnectionInfo { /** The multicast address. */ - public String mcastAddress; + public String mcastAddress = ""; /** The multicast port. */ - public int mcastPort; + public int mcastPort = -1; /** The connection buffer receive size. */ public int rcvSize; /** The connection buffer send size. */ public int sndSize; - - public UDPConnectionInfo clone() { - return (UDPConnectionInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPEndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPEndpointInfo.java index 56110c59a54..e30d9d3c2fe 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPEndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UDPEndpointInfo.java @@ -1,17 +1,4 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Endpoint.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; @@ -21,32 +8,9 @@ * @see Endpoint */ public abstract class UDPEndpointInfo extends IPEndpointInfo { - public UDPEndpointInfo() { - super(); - this.mcastInterface = ""; - } - - public UDPEndpointInfo( - EndpointInfo underlying, - int timeout, - boolean compress, - String host, - int port, - String sourceAddress, - String mcastInterface, - int mcastTtl) { - super(underlying, timeout, compress, host, port, sourceAddress); - this.mcastInterface = mcastInterface; - this.mcastTtl = mcastTtl; - } - /** The multicast interface. */ - public String mcastInterface; + public String mcastInterface = ""; /** The multicast time-to-live (or hops). */ public int mcastTtl; - - public UDPEndpointInfo clone() { - return (UDPEndpointInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UdpEndpointI.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UdpEndpointI.java index a80c4f35184..843f19763e3 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UdpEndpointI.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/UdpEndpointI.java @@ -317,6 +317,20 @@ public void fillEndpointInfo(IPEndpointInfo info) { } } + @Override + public EndpointI toPublishedEndpoint(String publishedHost) { + return new UdpEndpointI( + _instance, + publishedHost.isEmpty() ? _host : publishedHost, + _port, + null, + "", + -1, + false, // for "connect" + "", + _compress); + } + @Override protected boolean checkOption(String option, String argument, String endpoint) { if (super.checkOption(option, argument, endpoint)) { diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSConnectionInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSConnectionInfo.java index d0c3ee8c36b..e13afa44a9b 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSConnectionInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSConnectionInfo.java @@ -1,40 +1,9 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Connection.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Provides access to the connection details of a WebSocket connection */ -public class WSConnectionInfo extends ConnectionInfo { - public WSConnectionInfo() { - super(); - } - - public WSConnectionInfo( - ConnectionInfo underlying, - boolean incoming, - String adapterName, - String connectionId, - java.util.Map headers) { - super(underlying, incoming, adapterName, connectionId); - this.headers = headers; - } - +public final class WSConnectionInfo extends ConnectionInfo { /** The headers from the HTTP upgrade request. */ public java.util.Map headers; - - public WSConnectionInfo clone() { - return (WSConnectionInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpoint.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpoint.java index ac4dcacd2cb..7ded2b689f0 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpoint.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpoint.java @@ -34,8 +34,8 @@ public WSEndpoint(ProtocolInstance instance, EndpointI del, InputStream s) { @Override public EndpointInfo getInfo() { - WSEndpointInfo info = - new WSEndpointInfo(_delegate.getInfo(), timeout(), compress(), _resource) { + var info = + new WSEndpointInfo() { @Override public short type() { return WSEndpoint.this.type(); @@ -51,8 +51,11 @@ public boolean secure() { return WSEndpoint.this.secure(); } }; - info.compress = info.underlying.compress; + + info.underlying = _delegate.getInfo(); info.timeout = info.underlying.timeout; + info.compress = info.underlying.compress; + info.resource = _resource; return info; } @@ -179,13 +182,13 @@ public java.util.List expandHost() { } @Override - public boolean isLoopback() { - return _delegate.isLoopback(); + public boolean isLoopbackOrMulticast() { + return _delegate.isLoopbackOrMulticast(); } @Override - public EndpointI withPublishedHost(String host) { - return endpoint(_delegate.withPublishedHost(host)); + public EndpointI toPublishedEndpoint(String publishedHost) { + return endpoint(_delegate.toPublishedEndpoint(publishedHost)); } @Override diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpointInfo.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpointInfo.java index 4a86d537aae..20cccba6639 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpointInfo.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/WSEndpointInfo.java @@ -1,36 +1,9 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// -// -// Ice version 3.7.10 -// -// -// -// Generated from file `Endpoint.ice' -// -// Warning: do not edit this file. -// -// -// +// Copyright (c) ZeroC, Inc. package com.zeroc.Ice; /** Provides access to a WebSocket endpoint information. */ public abstract class WSEndpointInfo extends EndpointInfo { - public WSEndpointInfo() { - super(); - this.resource = ""; - } - - public WSEndpointInfo(EndpointInfo underlying, int timeout, boolean compress, String resource) { - super(underlying, timeout, compress); - this.resource = resource; - } - /** The URI configured with the endpoint. */ - public String resource; - - public WSEndpointInfo clone() { - return (WSEndpointInfo) super.clone(); - } + public String resource = ""; } diff --git a/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/ConnectionInfo.java b/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/ConnectionInfo.java index 0d571b41a88..159ab0a2022 100644 --- a/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/ConnectionInfo.java +++ b/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/ConnectionInfo.java @@ -3,62 +3,25 @@ package com.zeroc.IceBT; /** Provides access to the details of a Bluetooth connection. */ -public class ConnectionInfo extends com.zeroc.Ice.ConnectionInfo { - public ConnectionInfo() { - super(); - this.localAddress = ""; - this.localChannel = -1; - this.remoteAddress = ""; - this.remoteChannel = -1; - this.uuid = ""; - this.rcvSize = 0; - this.sndSize = 0; - } - - public ConnectionInfo( - com.zeroc.Ice.ConnectionInfo underlying, - boolean incoming, - String adapterName, - String connectionId, - String localAddress, - int localChannel, - String remoteAddress, - int remoteChannel, - String uuid, - int rcvSize, - int sndSize) { - super(underlying, incoming, adapterName, connectionId); - this.localAddress = localAddress; - this.localChannel = localChannel; - this.remoteAddress = remoteAddress; - this.remoteChannel = remoteChannel; - this.uuid = uuid; - this.rcvSize = rcvSize; - this.sndSize = sndSize; - } - +public final class ConnectionInfo extends com.zeroc.Ice.ConnectionInfo { /** The local Bluetooth address. */ - public String localAddress; + public String localAddress = ""; /** The local RFCOMM channel. */ - public int localChannel; + public int localChannel = -1; /** The remote Bluetooth address. */ - public String remoteAddress; + public String remoteAddress = ""; /** The remote RFCOMM channel. */ - public int remoteChannel; + public int remoteChannel = -1; /** The UUID of the service being offered (in a server) or targeted (in a client). */ - public String uuid; + public String uuid = ""; /** The connection buffer receive size. */ public int rcvSize; /** The connection buffer send size. */ public int sndSize; - - public ConnectionInfo clone() { - return (ConnectionInfo) super.clone(); - } } diff --git a/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointI.java b/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointI.java index 4d705bd5e59..a1631a46a45 100644 --- a/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointI.java +++ b/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointI.java @@ -161,12 +161,12 @@ public java.util.List expandHost() { } @Override - public boolean isLoopback() { + public boolean isLoopbackOrMulticast() { return false; } @Override - public com.zeroc.Ice.EndpointI withPublishedHost(String host) { + public com.zeroc.Ice.EndpointI toPublishedEndpoint(String publishedHost) { return this; } diff --git a/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointInfo.java b/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointInfo.java index 19ab70322b0..527016e48e6 100644 --- a/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointInfo.java +++ b/java/src/com.zeroc.icebt/src/main/java/com/zeroc/IceBT/EndpointInfo.java @@ -4,30 +4,9 @@ /** Provides access to Bluetooth endpoint information. */ public abstract class EndpointInfo extends com.zeroc.Ice.EndpointInfo { - public EndpointInfo() { - super(); - this.addr = ""; - this.uuid = ""; - } - - public EndpointInfo( - com.zeroc.Ice.EndpointInfo underlying, - int timeout, - boolean compress, - String addr, - String uuid) { - super(underlying, timeout, compress); - this.addr = addr; - this.uuid = uuid; - } - /** The address configured with the endpoint. */ - public String addr; + public String addr = ""; /** The UUID configured with the endpoint. */ - public String uuid; - - public EndpointInfo clone() { - return (EndpointInfo) super.clone(); - } + public String uuid = ""; } diff --git a/java/test/src/main/java/test/Ice/background/EndpointI.java b/java/test/src/main/java/test/Ice/background/EndpointI.java index 4500e63d6c0..5bcc90556b7 100644 --- a/java/test/src/main/java/test/Ice/background/EndpointI.java +++ b/java/test/src/main/java/test/Ice/background/EndpointI.java @@ -154,13 +154,13 @@ public java.util.List expandHost() { } @Override - public boolean isLoopback() { - return _endpoint.isLoopback(); + public boolean isLoopbackOrMulticast() { + return _endpoint.isLoopbackOrMulticast(); } @Override - public com.zeroc.Ice.EndpointI withPublishedHost(String host) { - return endpoint(_endpoint.withPublishedHost(host)); + public com.zeroc.Ice.EndpointI toPublishedEndpoint(String publishedHost) { + return endpoint(_endpoint.toPublishedEndpoint(publishedHost)); } @Override diff --git a/js/src/Ice/Connection.d.ts b/js/src/Ice/Connection.d.ts index 8bdc9dc2582..a5986562178 100644 --- a/js/src/Ice/Connection.d.ts +++ b/js/src/Ice/Connection.d.ts @@ -4,46 +4,6 @@ declare module "ice" { namespace Ice { - /** - * Base class providing access to the connection details. - */ - class ConnectionInfo { - /** - * Constructs a new `ConnectionInfo` object. - * - * @param underlying - The information of the underlying transport, or `null` if there is no underlying transport. - * @param incoming - Indicates whether the connection is incoming (`true`) or outgoing (`false`). - * @param adapterName - The name of the adapter associated with the connection. - * @param connectionId - The connection ID. - */ - constructor( - underlying?: Ice.ConnectionInfo, - incoming?: boolean, - adapterName?: string, - connectionId?: string, - ); - - /** - * The information of the underlying transport, or `null` if there is no underlying transport. - */ - underlying: Ice.ConnectionInfo; - - /** - * Indicates whether the connection is incoming (`true`) or outgoing (`false`). - */ - incoming: boolean; - - /** - * The name of the adapter associated with this connection. - */ - adapterName: string; - - /** - * The connection id. - */ - connectionId: string; - } - /** * Callback invoked when the connection is closed. If additional information about the closure is needed, * the callback can call {@link Connection#throwException}. @@ -164,32 +124,34 @@ declare module "ice" { } /** - * Provides access to the connection details of an IP connection + * Base class providing access to the connection details. */ - class IPConnectionInfo extends ConnectionInfo { + class ConnectionInfo { /** - * Constructs a new `IPConnectionInfo` object. - * - * @param underlying - The information of the underlying transport, or `null` if there is no underlying transport. - * @param incoming - Indicates whether the connection is incoming (`true`) or outgoing (`false`). - * @param adapterName - The name of the adapter associated with the connection. - * @param connectionId - The connection ID. - * @param localAddress - The local IP address. - * @param localPort - The local port number. - * @param remoteAddress - The remote IP address. - * @param remotePort - The remote port number. + * The information of the underlying transport, or `null` if there is no underlying transport. + */ + underlying: Ice.ConnectionInfo; + + /** + * Indicates whether the connection is incoming (`true`) or outgoing (`false`). + */ + incoming: boolean; + + /** + * The name of the adapter associated with this connection. + */ + adapterName: string; + + /** + * The connection id. */ - constructor( - underlying?: Ice.ConnectionInfo, - incoming?: boolean, - adapterName?: string, - connectionId?: string, - localAddress?: string, - localPort?: number, - remoteAddress?: string, - remotePort?: number, - ); + connectionId: string; + } + /** + * Provides access to the connection details of an IP connection + */ + class IPConnectionInfo extends ConnectionInfo { /** * The local address. */ @@ -215,34 +177,6 @@ declare module "ice" { * Provides access to the connection details of a TCP connection */ class TCPConnectionInfo extends IPConnectionInfo { - /** - * Constructs a new `TCPConnectionInfo` object. - * - * @param underlying - The information of the underlying transport, or `null` if there is no underlying - * transport. - * @param incoming - Indicates whether the connection is incoming (`true`) or outgoing (`false`). - * @param adapterName - The name of the adapter associated with the connection. - * @param connectionId - The connection ID. - * @param localAddress - The local IP address. - * @param localPort - The local port number. - * @param remoteAddress - The remote IP address. - * @param remotePort - The remote port number. - * @param rcvSize - The receive buffer size in bytes. - * @param sndSize - The send buffer size in bytes. - */ - constructor( - underlying?: Ice.ConnectionInfo, - incoming?: boolean, - adapterName?: string, - connectionId?: string, - localAddress?: string, - localPort?: number, - remoteAddress?: string, - remotePort?: number, - rcvSize?: number, - sndSize?: number, - ); - /** * The connection buffer receive size. */ @@ -285,24 +219,6 @@ declare module "ice" { * Provides access to the connection details of a WebSocket connection. */ class WSConnectionInfo extends ConnectionInfo { - /** - * Constructs a new `WSConnectionInfo` object. - * - * @param underlying - The information of the underlying transport, or `null` if there is no underlying - * transport. - * @param incoming - Indicates whether the connection is incoming (`true`) or outgoing (`false`). - * @param adapterName - The name of the adapter associated with the connection. - * @param connectionId - The connection ID. - * @param headers - The headers from the HTTP upgrade request. - */ - constructor( - underlying?: Ice.ConnectionInfo, - incoming?: boolean, - adapterName?: string, - connectionId?: string, - headers?: HeaderDict, - ); - /** * The headers from the HTTP upgrade request. */ diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js index 597b9fbc54a..e03cc42d983 100644 --- a/js/src/Ice/ConnectionI.js +++ b/js/src/Ice/ConnectionI.js @@ -447,7 +447,7 @@ export class ConnectionI { DEV: console.assert(this._readStream.buffer.remaining === 0); this._readHeader = false; - // Connection is validated on first message. This is only used by setState() to check wether or not + // Connection is validated on first message. This is only used by setState() to check whether or not // we can print a connection warning (a client might close the connection forcefully if the // connection isn't validated, we don't want to print a warning in this case). this._validated = true; diff --git a/js/src/Ice/Endpoint.d.ts b/js/src/Ice/Endpoint.d.ts index aee1bc0b6bf..fff86942a77 100644 --- a/js/src/Ice/Endpoint.d.ts +++ b/js/src/Ice/Endpoint.d.ts @@ -4,51 +4,6 @@ declare module "ice" { namespace Ice { - /** - * Base class providing access to the endpoint details. - */ - class EndpointInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - */ - constructor(underlying?: Ice.EndpointInfo, timeout?: number, compress?: boolean); - - /** - * The information of the underlying endpoint or null if there's no underlying endpoint. - */ - underlying: Ice.EndpointInfo; - - /** - * The timeout for the endpoint in milliseconds. 0 means non-blocking, -1 means no timeout. - */ - timeout: number; - - /** - * Specifies whether or not compression should be used if available when using this endpoint. - */ - compress: boolean; - - /** - * Returns the type of the endpoint. - * @returns The endpoint type. - */ - type(): number; - - /** - * Returns true if this endpoint is a datagram endpoint. - * @returns True for a datagram endpoint. - */ - datagram(): boolean; - - /** - * @returns True for a secure endpoint. - */ - secure(): boolean; - } - /** * The user-level interface to an endpoint. */ @@ -75,42 +30,23 @@ declare module "ice" { } /** - * Provides access to the address details of a IP endpoint. - * @see Endpoint + * Base class providing access to the endpoint details. */ - class IPEndpointInfo extends EndpointInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param host The host or address configured with the endpoint. - * @param port The port number. - * @param sourceAddress The source IP address. - */ - constructor( - underlying?: Ice.EndpointInfo, - timeout?: number, - compress?: boolean, - host?: string, - port?: number, - sourceAddress?: string, - ); - + class EndpointInfo { /** - * The host or address configured with the endpoint. + * The information of the underlying endpoint or null if there's no underlying endpoint. */ - host: string; + underlying: Ice.EndpointInfo; /** - * The port number. + * The timeout for the endpoint in milliseconds. 0 means non-blocking, -1 means no timeout. */ - port: number; + timeout: number; /** - * The source IP address. + * Specifies whether or not compression should be used if available when using this endpoint. */ - sourceAddress: string; + compress: boolean; /** * Returns the type of the endpoint. @@ -131,80 +67,40 @@ declare module "ice" { } /** - * Provides access to a TCP endpoint information. + * Provides access to the address details of a IP endpoint. * @see Endpoint */ - class TCPEndpointInfo extends IPEndpointInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param host The host or address configured with the endpoint. - * @param port The port number. - * @param sourceAddress The source IP address. - */ - constructor( - underlying?: Ice.EndpointInfo, - timeout?: number, - compress?: boolean, - host?: string, - port?: number, - sourceAddress?: string, - ); - + class IPEndpointInfo extends EndpointInfo { /** - * Returns the type of the endpoint. - * @returns The endpoint type. + * The host or address configured with the endpoint. */ - type(): number; + host: string; /** - * Returns true if this endpoint is a datagram endpoint. - * @returns True for a datagram endpoint. + * The port number. */ - datagram(): boolean; + port: number; /** - * @returns True for a secure endpoint. + * The source IP address. */ - secure(): boolean; + sourceAddress: string; } + /** + * Provides access to a TCP endpoint information. + * @see Endpoint + */ + class TCPEndpointInfo extends IPEndpointInfo {} + /** * Provides access to a WebSocket endpoint information. */ class WSEndpointInfo extends EndpointInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param resource The URI configured with the endpoint. - */ - constructor(underlying?: Ice.EndpointInfo, timeout?: number, compress?: boolean, resource?: string); - /** * The URI configured with the endpoint. */ resource: string; - - /** - * Returns the type of the endpoint. - * @returns The endpoint type. - */ - type(): number; - - /** - * Returns true if this endpoint is a datagram endpoint. - * @returns True for a datagram endpoint. - */ - datagram(): boolean; - - /** - * @returns True for a secure endpoint. - */ - secure(): boolean; } /** @@ -212,22 +108,6 @@ declare module "ice" { * @see Endpoint */ class OpaqueEndpointInfo extends EndpointInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - * @param rawEncoding The encoding version of the opaque endpoint (to decode or encode the rawBytes). - * @param rawBytes The raw encoding of the opaque endpoint. - */ - constructor( - underlying?: Ice.EndpointInfo, - timeout?: number, - compress?: boolean, - rawEncoding?: EncodingVersion, - rawBytes?: ByteSeq, - ); - /** * The encoding version of the opaque endpoint (to decode or encode the rawBytes). */ @@ -237,23 +117,6 @@ declare module "ice" { * The raw encoding of the opaque endpoint. */ rawBytes: ByteSeq; - - /** - * Returns the type of the endpoint. - * @returns The endpoint type. - */ - type(): number; - - /** - * Returns true if this endpoint is a datagram endpoint. - * @returns True for a datagram endpoint. - */ - datagram(): boolean; - - /** - * @returns True for a secure endpoint. - */ - secure(): boolean; } } } diff --git a/js/src/Ice/Endpoint.js b/js/src/Ice/Endpoint.js index 7d945d9f45a..c431dc7b760 100644 --- a/js/src/Ice/Endpoint.js +++ b/js/src/Ice/Endpoint.js @@ -1,62 +1,29 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import { Ice as Ice_Version } from "./Version.js"; -const { EncodingVersion } = Ice_Version; +// Copyright (c) ZeroC, Inc. /** * Base class providing access to the endpoint details. **/ -export class EndpointInfo { - constructor(underlying = null, timeout = 0, compress = false) { - this.underlying = underlying; - this.timeout = timeout; - this.compress = compress; - } -} +export class EndpointInfo {} /** * Provides access to the address details of a IP endpoint. * @see {@link Endpoint} **/ -export class IPEndpointInfo extends EndpointInfo { - constructor(underlying, timeout, compress, host = "", port = 0, sourceAddress = "") { - super(underlying, timeout, compress); - this.host = host; - this.port = port; - this.sourceAddress = sourceAddress; - } -} +export class IPEndpointInfo extends EndpointInfo {} /** * Provides access to a TCP endpoint information. * @see {@link Endpoint} **/ -export class TCPEndpointInfo extends IPEndpointInfo { - constructor(underlying, timeout, compress, host, port, sourceAddress) { - super(underlying, timeout, compress, host, port, sourceAddress); - } -} +export class TCPEndpointInfo extends IPEndpointInfo {} /** * Provides access to a WebSocket endpoint information. **/ -export class WSEndpointInfo extends EndpointInfo { - constructor(underlying, timeout, compress, resource = "") { - super(underlying, timeout, compress); - this.resource = resource; - } -} +export class WSEndpointInfo extends EndpointInfo {} /** * Provides access to the details of an opaque endpoint. * @see {@link Endpoint} **/ -export class OpaqueEndpointInfo extends EndpointInfo { - constructor(underlying, timeout, compress, rawEncoding = new EncodingVersion(), rawBytes = null) { - super(underlying, timeout, compress); - this.rawEncoding = rawEncoding; - this.rawBytes = rawBytes; - } -} +export class OpaqueEndpointInfo extends EndpointInfo {} diff --git a/js/src/Ice/OpaqueEndpoint.js b/js/src/Ice/OpaqueEndpoint.js index 6efccbfe639..58ed4ba45a4 100644 --- a/js/src/Ice/OpaqueEndpoint.js +++ b/js/src/Ice/OpaqueEndpoint.js @@ -31,7 +31,7 @@ export class OpaqueEndpointI extends EndpointI { // Return the endpoint information. // getInfo() { - return new OpaqueEndpointInfoI(null, -1, false, this._rawEncoding, this._rawBytes, this._type); + return new OpaqueEndpointInfoI(this._rawEncoding, this._rawBytes, this._type); } // @@ -313,8 +313,13 @@ export class OpaqueEndpointI extends EndpointI { } class OpaqueEndpointInfoI extends OpaqueEndpointInfo { - constructor(timeout, compress, rawEncoding, rawBytes, type) { - super(-1, false, rawEncoding, rawBytes); + constructor(rawEncoding, rawBytes, type) { + super(); + this.underlying = null; + this.timeout = -1; + this.compress = false; + this.rawEncoding = rawEncoding; + this.rawBytes = rawBytes; this._type = type; } diff --git a/js/src/Ice/SSL/ConnectionInfo.d.ts b/js/src/Ice/SSL/ConnectionInfo.d.ts index f5f1b70fc99..ab9bc09903c 100644 --- a/js/src/Ice/SSL/ConnectionInfo.d.ts +++ b/js/src/Ice/SSL/ConnectionInfo.d.ts @@ -9,22 +9,7 @@ declare module "ice" { * Provides access to the connection details of an SSL connection */ class ConnectionInfo extends Ice.ConnectionInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying transport or null if there's no underlying transport. - * @param incoming Whether or not the connection is an incoming or outgoing connection. - * @param adapterName The name of the adapter associated with the connection. - * @param connectionId The connection id. - */ - constructor( - underlying?: Ice.ConnectionInfo, - incoming?: boolean, - adapterName?: string, - connectionId?: string, - cipher?: string, - certs?: Ice.StringSeq, - verified?: boolean, - ); + // TODO: add missing fields (cipher, certs, verified) } } } diff --git a/js/src/Ice/SSL/ConnectionInfo.js b/js/src/Ice/SSL/ConnectionInfo.js index 04f22a35523..cb0a608b64d 100644 --- a/js/src/Ice/SSL/ConnectionInfo.js +++ b/js/src/Ice/SSL/ConnectionInfo.js @@ -7,8 +7,4 @@ import { ConnectionInfo as IceConnectionInfo } from "../Connection.js"; /** * Provides access to the connection details of an SSL connection **/ -export class ConnectionInfo extends IceConnectionInfo { - constructor(underlying, incoming, adapterName, connectionId) { - super(underlying, incoming, adapterName, connectionId); - } -} +export class ConnectionInfo extends IceConnectionInfo {} diff --git a/js/src/Ice/SSL/EndpointInfo.d.ts b/js/src/Ice/SSL/EndpointInfo.d.ts index e3b82630fb3..3ab3667ac27 100644 --- a/js/src/Ice/SSL/EndpointInfo.d.ts +++ b/js/src/Ice/SSL/EndpointInfo.d.ts @@ -4,29 +4,7 @@ declare module "ice" { /** * Provides access to an SSL endpoint information. */ - class EndpointInfo extends Ice.EndpointInfo { - /** - * One-shot constructor to initialize all data members. - * @param underlying The information of the underlying endpoint or null if there's no underlying endpoint. - * @param timeout The timeout for the endpoint in milliseconds. - * @param compress Specifies whether or not compression should be used if available when using this endpoint. - */ - constructor(underlying?: Ice.EndpointInfo, timeout?: number, compress?: boolean); - /** - * Returns the type of the endpoint. - * @returns The endpoint type. - */ - type(): number; - /** - * Returns true if this endpoint is a datagram endpoint. - * @returns True for a datagram endpoint. - */ - datagram(): boolean; - /** - * @returns True for a secure endpoint. - */ - secure(): boolean; - } + class EndpointInfo extends Ice.EndpointInfo {} } } } diff --git a/js/src/Ice/SSL/EndpointInfo.js b/js/src/Ice/SSL/EndpointInfo.js index 455d9679e06..bdf7ca77d5d 100644 --- a/js/src/Ice/SSL/EndpointInfo.js +++ b/js/src/Ice/SSL/EndpointInfo.js @@ -7,8 +7,4 @@ import { EndpointInfo as IceEndpointInfo } from "../Endpoint.js"; /** * Provides access to an SSL endpoint information. **/ -export class EndpointInfo extends IceEndpointInfo { - constructor(underlying, timeout, compress) { - super(underlying, timeout, compress); - } -} +export class EndpointInfo extends IceEndpointInfo {} diff --git a/js/src/Ice/TcpEndpointI.js b/js/src/Ice/TcpEndpointI.js index 2020762195e..44fca628650 100644 --- a/js/src/Ice/TcpEndpointI.js +++ b/js/src/Ice/TcpEndpointI.js @@ -24,7 +24,16 @@ export class TcpEndpointI extends IPEndpointI { getInfo() { const info = new TCPEndpointInfo(); this.fillEndpointInfo(info); - return this.secure() ? new SSLEndpointInfo(info, info.timeout, info.compress) : info; + + if (this.secure()) { + const sslInfo = new SSLEndpointInfo(); + sslInfo.underlying = info; + sslInfo.timeout = info.timeout; + sslInfo.compress = info.compress; + return sslInfo; + } else { + return info; + } } // diff --git a/js/src/Ice/WSTransceiver.js b/js/src/Ice/WSTransceiver.js index 9fd599c52dd..d9236cff1f6 100644 --- a/js/src/Ice/WSTransceiver.js +++ b/js/src/Ice/WSTransceiver.js @@ -248,11 +248,19 @@ if (typeof WebSocket !== "undefined") { tcpInfo.localPort = -1; tcpInfo.remoteAddress = this._addr.host; tcpInfo.remotePort = this._addr.port; - info.underlying = this._secure - ? new SSLConnectionInfo(tcpInfo, tcpInfo.timeout, tcpInfo.compress) - : tcpInfo; tcpInfo.rcvSize = -1; tcpInfo.sndSize = this._maxSendPacketSize; + + if (this._secure) { + const sslInfo = new SSLConnectionInfo(); + sslInfo.underlying = tcpInfo; + sslInfo.timeout = tcpInfo.timeout; + sslInfo.compress = tcpInfo.compress; + info.underlying = sslInfo; + } else { + info.underlying = tcpInfo; + } + info.headers = {}; return info; } diff --git a/python/modules/IcePy/Slice.cpp b/python/modules/IcePy/Slice.cpp index 121e99ca156..ed2590b1ed9 100644 --- a/python/modules/IcePy/Slice.cpp +++ b/python/modules/IcePy/Slice.cpp @@ -116,12 +116,10 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) debug = opts.isSet("d") || opts.isSet("debug"); all = opts.isSet("all"); - bool keepComments = true; - for (const auto& file : files) { Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("icecpp", file, cppArgs); - FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__"); + FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2PY__"); if (cppHandle == 0) {