diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index 1f285067830..96639e8aaf7 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -22,6 +22,45 @@ This feature has been deprecated since Ice 3.7. - An interface can no longer be used as a type This feature, known as "interface by value", has been deprecated since Ice 3.7. You can still define proxies with the usual syntax, `Greeter*`, where `Greeter` represents an interface. +## C++ Changes + +- The C++98 mapping is now called the Original mapping. + +- The C++11 mapping is now called the New mapping. + +- (Original mapping) The base class for mapped class instances is now Ice::Value, like in the new mapping. Previously, +Ice::Object was the base class for both mapped class instances and servants. + +- (Original mapping) Ice::Value does not derive from IceUtil::Shared and the generated Ptr for mapped classed is now an +Ice::SharedPtr that behaves mostly like the previous IceUtil (and IceInternal) Handle by wrapping a std::shared_ptr. +The important differences are: + - the comparison operators of Ice::SharedPtr compare pointers like std::shared_ptr but unlike IceUtil::Handle. + - the pointed-to object no longer holds the reference count, and as result you must be careful and avoid creating + multiple SharedPtr managing the same object. For example: + ``` + MyClassPtr c1 = new MyClass(); // SharedPtr to class instance + MyClassPtr c2 = c1; // c1 and c2 point to the same instance + MyClassPtr c3 = c1.get(); // c3 points to the same instance. With Ice 3.7 and before, it's ok as it simply adds a + // a reference count to the shared instance. As of Ice 3.8, it's incorrect since c3 is a new + // independent SharedPtr with its own reference count. + ``` + +- (Original mapping) Removed all support for garbage collection (GC) of class instances. If you create or receive a +graph of class instances with a cycle, you must break this cycle to avoid a leak. + +- (New mapping) Ice::optional is now an alias for std::optional. + +- (Original mapping) IceUtil::Optional is now an alias for std::optional. When upgrading from Ice 3.7 or earlier, you +need to replace calls to `get()` on IceUtil::Optional by calls to `value()`. + +## Objective-C Changes + +- The base class for class instances is now Ice::Value. Previously, Ice::Object was the base class for both mapped class +instances and servants. + +- The slice compiler no longer generates an Objective-C protocol for Slice classes. It generates only an Objective-C +class (interface). + ## Ice Service Changes - The implementations of Glacier2, IceGrid, IceStorm and IcePatch2 were updated to use the new C++ mapping. diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 63e32eff874..2ea8c4e8976 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -319,7 +319,6 @@ generated from the section label. - diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index 2bcc0152fd2..df9cecb3fbe 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -104,8 +104,6 @@ cpp11_projects = test/Common \ test/IceGrid/% \ test/IceBridge/simple -cpp11_excludes = test/Ice/gc - # # If building on a Linux multilib platform, we restrict what we build for # the 32-bits architecture. We basically, build the same set of components diff --git a/cpp/include/Ice/Communicator.h b/cpp/include/Ice/Communicator.h index d6d8b7ae7f8..fa57de1e278 100644 --- a/cpp/include/Ice/Communicator.h +++ b/cpp/include/Ice/Communicator.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/Ice/GCValue.h b/cpp/include/Ice/GCValue.h deleted file mode 100644 index 04675b6f31b..00000000000 --- a/cpp/include/Ice/GCValue.h +++ /dev/null @@ -1,76 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef ICE_GC_OBJECT_H -#define ICE_GC_OBJECT_H - -#ifndef ICE_CPP11_MAPPING - -#include - -#include -#include - -namespace IceInternal -{ - -class GCValue; - -class GCVisitor -{ -public: - - virtual ~GCVisitor() - { - } - - virtual bool visit(GCValue*) = 0; -}; - -class ICE_API GCValue : public virtual Ice::Value -{ -public: - - // - // Flags constant used for collection of graphs - // - static const unsigned char Collectable; - static const unsigned char CycleMember; - static const unsigned char Visiting; - - // - // Override IceUtil::Shared methods - // - virtual void __incRef(); - virtual void __decRef(); - virtual int __getRef() const; - virtual void __setNoDelete(bool); - - // - // Override Object methods - // - virtual bool _iceGcVisit(GCVisitor&); - virtual void ice_collectable(bool); - - // - // This method is implemented by Slice classes to visit class - // members. - // - virtual void _iceGcVisitMembers(IceInternal::GCVisitor&) = 0; - - int _iceGetRefUnsafe() - { - return _ref; - } - -private: - - bool collect(IceUtilInternal::MutexPtrLock&); -}; - -} - -#endif - -#endif diff --git a/cpp/include/Ice/Handle.h b/cpp/include/Ice/Handle.h index 46e0bc1265f..06202f3d928 100644 --- a/cpp/include/Ice/Handle.h +++ b/cpp/include/Ice/Handle.h @@ -9,8 +9,7 @@ #include // -// "Handle" or "smart pointer" template for classes derived from -// IceInternal::GCShared, IceUtil::Shared, or IceUtil::SimpleShared. +// "Handle" or "smart pointer" template for classes derived from IceUtil::Shared, or IceUtil::SimpleShared. // // In contrast to IceUtil::Handle, IceInternal::Handle can be used // for a type T that has been declared but not defined. The only diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index 7f4380149ca..16df572c1dd 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -36,7 +36,7 @@ patchHandle(void* addr, const ValuePtr& v) IceInternal::Ex::throwUOE(T::ice_staticId(), v); } #else - IceInternal::Handle* p = static_cast*>(addr); + SharedPtr* p = static_cast*>(addr); _icePatchValuePtr(*p, v); // Generated _icePatchValuePtr function, necessary for forward declarations. #endif } @@ -251,16 +251,6 @@ class ICE_API InputStream : public IceInternal::Buffer void setCompactIdResolver(const CompactIdResolverPtr& r); #endif -#ifndef ICE_CPP11_MAPPING - /** - * Indicates whether to mark instances of Slice classes as collectable. If the stream is - * initialized with a communicator, this setting defaults to the value of the - * Ice.CollectObjects property, otherwise the setting defaults to false. - * @param b True to mark instances as collectable, false otherwise. - */ - void setCollectObjects(bool b); -#endif - /** * Indicates whether to slice instances of Slice classes to a known Slice type when a more * derived type is unknown. An instance is "sliced" when no static information is available @@ -1094,7 +1084,7 @@ class ICE_API InputStream : public IceInternal::Buffer read(&patchHandle, &v); } #else // C++98 mapping - template void read(IceInternal::Handle& v) + template void read(Ice::SharedPtr& v) { read(&patchHandle, &v); } @@ -1476,10 +1466,6 @@ class ICE_API InputStream : public IceInternal::Buffer Encaps _preAllocatedEncaps; -#ifndef ICE_CPP11_MAPPING - bool _collectObjects; -#endif - bool _traceSlicing; size_t _classGraphDepthMax; diff --git a/cpp/include/Ice/MetricsAdminI.h b/cpp/include/Ice/MetricsAdminI.h index 4fafd69b9ad..27b0e03f962 100644 --- a/cpp/include/Ice/MetricsAdminI.h +++ b/cpp/include/Ice/MetricsAdminI.h @@ -121,7 +121,7 @@ template class MetricsMapT : public MetricsMapI, private IceU public: typedef MetricsType T; - typedef ICE_INTERNAL_HANDLE TPtr; + typedef ICE_SHARED_PTR TPtr; ICE_DEFINE_PTR(MetricsMapTPtr, MetricsMapT); diff --git a/cpp/include/Ice/MetricsFunctional.h b/cpp/include/Ice/MetricsFunctional.h index 3d4dc819dff..c0f04534167 100644 --- a/cpp/include/Ice/MetricsFunctional.h +++ b/cpp/include/Ice/MetricsFunctional.h @@ -64,6 +64,22 @@ template struct ReferenceWrapper& > return v.get(); } }; + +template struct ReferenceWrapper > +{ + static R* get(const Ice::SharedPtr& v) + { + return v.get(); + } +}; + +template struct ReferenceWrapper& > +{ + static R* get(const Ice::SharedPtr& v) + { + return v.get(); + } +}; #endif template struct ReferenceWrapper diff --git a/cpp/include/Ice/MetricsObserverI.h b/cpp/include/Ice/MetricsObserverI.h index 5ec343b6be9..75763dbc0f0 100644 --- a/cpp/include/Ice/MetricsObserverI.h +++ b/cpp/include/Ice/MetricsObserverI.h @@ -31,7 +31,7 @@ template class MetricsHelperT virtual std::string operator()(const std::string&) const = 0; - virtual void initMetrics(const ICE_INTERNAL_HANDLE&) const + virtual void initMetrics(const ICE_SHARED_PTR&) const { // To be overridden in specialization to initialize state attributes } diff --git a/cpp/include/Ice/ObjectAdapter.h b/cpp/include/Ice/ObjectAdapter.h index d66dc6c35cb..5457c81812d 100644 --- a/cpp/include/Ice/ObjectAdapter.h +++ b/cpp/include/Ice/ObjectAdapter.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/Ice/ObjectF.h b/cpp/include/Ice/ObjectF.h index c4cde83c57e..303e247a7d2 100644 --- a/cpp/include/Ice/ObjectF.h +++ b/cpp/include/Ice/ObjectF.h @@ -19,9 +19,6 @@ using ObjectPtr = ::std::shared_ptr; #else ICE_API Object* upCast(Object*); typedef IceInternal::Handle ObjectPtr; -/// \cond INTERNAL -ICE_API void _icePatchValuePtr(ObjectPtr&, const ObjectPtr&); -/// \endcond #endif } diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h index d1915dd2f81..2c9eb387e80 100644 --- a/cpp/include/Ice/OutputStream.h +++ b/cpp/include/Ice/OutputStream.h @@ -810,9 +810,9 @@ class ICE_API OutputStream : public IceInternal::Buffer * Writes a value instance to the stream. * @param v The value to be written. */ - template void write(const IceInternal::Handle& v) + template void write(const Ice::SharedPtr& v) { - write(ValuePtr(upCast(v.get()))); + write(ValuePtr(v)); } #endif diff --git a/cpp/include/Ice/Properties.h b/cpp/include/Ice/Properties.h index a9af97d4e93..d2c4a2e683d 100644 --- a/cpp/include/Ice/Properties.h +++ b/cpp/include/Ice/Properties.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/Ice/PropertiesF.h b/cpp/include/Ice/PropertiesF.h index 61ca36187c2..b3e9057d09e 100644 --- a/cpp/include/Ice/PropertiesF.h +++ b/cpp/include/Ice/PropertiesF.h @@ -115,9 +115,6 @@ ICE_API Object* upCast(PropertiesAdmin*); typedef ::IceInternal::Handle< PropertiesAdmin> PropertiesAdminPtr; typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::PropertiesAdmin> PropertiesAdminPrx; typedef PropertiesAdminPrx PropertiesAdminPrxPtr; -/// \cond INTERNAL -ICE_API void _icePatchValuePtr(PropertiesAdminPtr&, const ObjectPtr&); -/// \endcond } diff --git a/cpp/include/Ice/SharedPtr.h b/cpp/include/Ice/SharedPtr.h new file mode 100644 index 00000000000..70053fcc199 --- /dev/null +++ b/cpp/include/Ice/SharedPtr.h @@ -0,0 +1,128 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#ifndef ICE_SHARED_PTR_H +#define ICE_SHARED_PTR_H + +#include + +namespace Ice +{ + +/** + * A smart pointer that wraps a std::shared_ptr and provides an API similar to the IceUtil::Handle API. + * It's the primary smart pointer for the Original Mapping. + * \headerfile Ice/Ice.h + */ +template +class SharedPtr +{ +public: + + typedef T element_type; + + SharedPtr(T* p = nullptr) noexcept : _ptr(p) + { + } + + SharedPtr(const SharedPtr&) noexcept = default; + + template + SharedPtr(const SharedPtr& r) noexcept : _ptr(r.underlying()) + { + } + + explicit SharedPtr(std::shared_ptr&& r) noexcept : _ptr(std::move(r)) + { + } + + ~SharedPtr() = default; + + SharedPtr& operator=(T* p) noexcept + { + if(_ptr.get() != p) + { + _ptr = std::shared_ptr(p); + } + return *this; + } + + template + SharedPtr& operator=(const SharedPtr& r) noexcept + { + if(_ptr != r.underlying()) + { + _ptr = r.underlying(); + } + return *this; + } + + SharedPtr& operator=(const SharedPtr& r) noexcept + { + if(_ptr != r._ptr) + { + _ptr = r._ptr; + } + return *this; + } + + T* get() const noexcept { return _ptr.get(); } + + T* operator->() const noexcept { return _ptr.get(); } + + T& operator*() const noexcept { return *_ptr; } + + operator bool() const noexcept { return _ptr.operator bool(); } + + void swap(SharedPtr& other) noexcept { _ptr.swap(other._ptr); } + + std::shared_ptr& underlying() noexcept { return _ptr; } + const std::shared_ptr& underlying() const noexcept { return _ptr; } + + template + static SharedPtr dynamicCast(const SharedPtr& r) noexcept + { + return SharedPtr(std::dynamic_pointer_cast(r.underlying())); + } + +private: + + std::shared_ptr _ptr; +}; + +// The semantics of these comparison operators is _not_ the same as with IceUtil::Handle. IceUtil::Handle compares the +// pointed-to objects, after dereferencing the pointers. SharedPtr compares the pointers like shared_ptr. +// This does not make a significant difference for Ice::Value and Ice::Object since their default comparison operators +// in Ice 3.7 and before compares "this". + +template +inline bool operator==(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() == rhs.underlying(); } + +#if __cplusplus >= 202002L + +template +inline std::strong_ordering operator<=>(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() <=> rhs.underlying(); } + +#else + +template +inline bool operator!=(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() != rhs.underlying(); } + +template +inline bool operator<(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() < rhs.underlying();} + +template +inline bool operator<=(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() <= rhs.underlying(); } + +template +inline bool operator>(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() > rhs.underlying(); } + +template +inline bool operator>=(const SharedPtr& lhs, const SharedPtr& rhs) noexcept { return lhs.underlying() >= rhs.underlying(); } + +#endif + +} + +#endif diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h index 3b579ca513f..56ad3155a8b 100644 --- a/cpp/include/Ice/SlicedData.h +++ b/cpp/include/Ice/SlicedData.h @@ -6,7 +6,6 @@ #define ICE_SLICED_DATA_H #include -#include #include namespace Ice @@ -76,25 +75,13 @@ class ICE_API SlicedData * Clears the slices to break potential cyclic references. */ void clear(); - -#ifndef ICE_CPP11_MAPPING - /// \cond INTERNAL - void _iceGcVisitMembers(IceInternal::GCVisitor&); - /// \endcond -#endif - }; /** * Represents an instance of an unknown type. * \headerfile Ice/Ice.h */ -class ICE_API UnknownSlicedValue : -#ifdef ICE_CPP11_MAPPING - public Value -#else - public IceInternal::GCValue -#endif +class ICE_API UnknownSlicedValue : public Value { public: @@ -150,10 +137,6 @@ class ICE_API UnknownSlicedValue : */ virtual std::string ice_id() const; - /// \cond INTERNAL - virtual void _iceGcVisitMembers(IceInternal::GCVisitor&); - /// \endcond - /// \cond STREAM virtual void _iceWrite(::Ice::OutputStream*) const; virtual void _iceRead(::Ice::InputStream*); diff --git a/cpp/include/Ice/SlicedDataF.h b/cpp/include/Ice/SlicedDataF.h index 83842a02508..24087f62154 100644 --- a/cpp/include/Ice/SlicedDataF.h +++ b/cpp/include/Ice/SlicedDataF.h @@ -5,8 +5,9 @@ #ifndef ICE_SLICED_DATA_F_H #define ICE_SLICED_DATA_F_H -#include +#include #include +#include namespace Ice { @@ -28,8 +29,7 @@ typedef IceInternal::Handle SliceInfoPtr; ICE_API IceUtil::Shared* upCast(SlicedData*); typedef IceInternal::Handle SlicedDataPtr; -ICE_API IceUtil::Shared* upCast(UnknownSlicedValue*); -typedef IceInternal::Handle UnknownSlicedValuePtr; +using UnknownSlicedValuePtr = SharedPtr; #endif /** The slices of unknown types. */ diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h index 967ab6ddabd..9fc0910330d 100644 --- a/cpp/include/Ice/StreamHelpers.h +++ b/cpp/include/Ice/StreamHelpers.h @@ -6,6 +6,7 @@ #define ICE_STREAM_HELPERS_H #include +#include #include #include @@ -421,7 +422,7 @@ struct StreamableTraits<::std::shared_ptr, typename ::std::enable_if<::std::i }; #else template -struct StreamableTraits< ::IceInternal::Handle > +struct StreamableTraits> { static const StreamHelperCategory helper = StreamHelperCategoryClass; static const int minWireSize = 1; diff --git a/cpp/include/Ice/Value.h b/cpp/include/Ice/Value.h index 738870dbc01..1e7632ff121 100644 --- a/cpp/include/Ice/Value.h +++ b/cpp/include/Ice/Value.h @@ -5,13 +5,7 @@ #ifndef ICE_VALUE_H #define ICE_VALUE_H -// TODO: temporary -#ifdef ICE_CPP11_MAPPING -# include -#else -# include -#endif - +#include #include namespace Ice @@ -20,11 +14,6 @@ namespace Ice class InputStream; } -namespace IceInternal -{ - class GCVisitor; -} - namespace Ice { @@ -153,29 +142,22 @@ template class ValueHelper : public Base * The base class for instances of Slice classes. * \headerfile Ice/Ice.h */ -class ICE_API Value : public virtual IceUtil::Shared +class ICE_API Value { public: - virtual bool operator==(const Value&) const; - virtual bool operator<(const Value&) const; + Value() = default; + Value(const Value&) = default; + Value(Value&&) = default; + Value& operator=(const Value&) = default; + Value& operator=(Value&&) = default; + virtual ~Value() = default; /// \cond STREAM virtual void _iceWrite(Ice::OutputStream*) const; virtual void _iceRead(Ice::InputStream*); /// \endcond - /// \cond INTERNAL - virtual bool _iceGcVisit(IceInternal::GCVisitor&) { return false; } - /// \endcond - - /** - * Determines whether this object, and by extension the graph of all objects reachable from this object, - * are eligible for garbage collection when all external references to the graph have been released. - * @param b True if the object is eligible, false otherwise. - */ - virtual void ice_collectable(bool b); - /** * The Ice run time invokes this method prior to marshaling an object's data members. This allows a subclass * to override this method in order to validate its data members. @@ -213,15 +195,6 @@ class ICE_API Value : public virtual IceUtil::Shared */ virtual SlicedDataPtr ice_getSlicedData() const; -protected: - - Value() = default; - Value(const Value&) = default; - Value(Value&&) = default; - Value& operator=(const Value&) = default; - Value& operator=(Value&&) = default; - virtual ~Value() = default; - protected: /// \cond STREAM diff --git a/cpp/include/Ice/ValueF.h b/cpp/include/Ice/ValueF.h index 56a29f81122..2ee3456d1d8 100644 --- a/cpp/include/Ice/ValueF.h +++ b/cpp/include/Ice/ValueF.h @@ -6,7 +6,7 @@ #define ICE_VALUE_F_H #include -#include +#include namespace Ice { @@ -20,8 +20,8 @@ using ValuePtr = ::std::shared_ptr; #else -ICE_API Value* upCast(Value*); -typedef IceInternal::Handle ValuePtr; +using ValuePtr = SharedPtr; + /// \cond INTERNAL ICE_API void _icePatchValuePtr(ValuePtr&, const ValuePtr&); /// \endcond diff --git a/cpp/include/IceBox/Service.h b/cpp/include/IceBox/Service.h index f82f62dfe48..cdc9b5faa17 100644 --- a/cpp/include/IceBox/Service.h +++ b/cpp/include/IceBox/Service.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceGrid/PluginFacade.h b/cpp/include/IceGrid/PluginFacade.h index 70710c4079e..453d34560e9 100644 --- a/cpp/include/IceGrid/PluginFacade.h +++ b/cpp/include/IceGrid/PluginFacade.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h index 10dfe256f3c..7a16824b47d 100644 --- a/cpp/include/IceUtil/Config.h +++ b/cpp/include/IceUtil/Config.h @@ -291,9 +291,11 @@ typedef long long Int64; # include # define ICE_HANDLE ::std::shared_ptr # define ICE_INTERNAL_HANDLE ::std::shared_ptr +# define ICE_SHARED_PTR ::std::shared_ptr # define ICE_PROXY_HANDLE ::std::shared_ptr # define ICE_MAKE_SHARED(T, ...) ::std::make_shared(__VA_ARGS__) # define ICE_DEFINE_PTR(TPtr, T) using TPtr = ::std::shared_ptr +# define ICE_DEFINE_SHARED_PTR(TPtr, T) using TPtr = ::std::shared_ptr # define ICE_ENUM(CLASS,ENUMERATOR) CLASS::ENUMERATOR # define ICE_SCOPED_ENUM(CLASS,ENUMERATOR) CLASS::ENUMERATOR # define ICE_NULLPTR nullptr @@ -309,9 +311,11 @@ typedef long long Int64; #else // C++98 mapping # define ICE_HANDLE ::IceUtil::Handle # define ICE_INTERNAL_HANDLE ::IceInternal::Handle +# define ICE_SHARED_PTR ::Ice::SharedPtr # define ICE_PROXY_HANDLE ::IceInternal::ProxyHandle # define ICE_MAKE_SHARED(T, ...) new T(__VA_ARGS__) # define ICE_DEFINE_PTR(TPtr, T) typedef ::IceUtil::Handle TPtr +# define ICE_DEFINE_SHARED_PTR(TPtr, T) using TPtr = ::Ice::SharedPtr # define ICE_ENUM(CLASS,ENUMERATOR) ENUMERATOR # define ICE_SCOPED_ENUM(CLASS,ENUMERATOR) CLASS##ENUMERATOR # define ICE_NULLPTR 0 diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h index 5df56b94a0f..eda50a00fa4 100644 --- a/cpp/include/IceUtil/Shared.h +++ b/cpp/include/IceUtil/Shared.h @@ -80,7 +80,7 @@ class ICE_API Shared // // Flag constant used by the Shared class. Derived classes - // such as GCValue define more flag constants. + // can define more flag constants. // static const unsigned char NoDelete; diff --git a/cpp/msbuild/ice.test.sln b/cpp/msbuild/ice.test.sln index 2679c905002..01372fea0bb 100644 --- a/cpp/msbuild/ice.test.sln +++ b/cpp/msbuild/ice.test.sln @@ -184,13 +184,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Ice\fault {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gc", "gc", "{D47FCF7F-D83C-4699-9B3B-F58265E6239A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\gc\msbuild\client.vcxproj", "{FA42EA5F-FDBE-4F27-ACC7-7717E401C868}" - ProjectSection(ProjectDependencies) = postProject - {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C} - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hash", "hash", "{74640E74-D6AA-414C-8238-0FFDC854AE98}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\hash\msbuild\client.vcxproj", "{685612A9-F2AA-4ACA-8327-5D40E4731906}" @@ -1689,18 +1682,6 @@ Global {CC0C7076-D15B-42AB-AFD6-CE40472F6E84}.Release|Win32.Build.0 = Release|Win32 {CC0C7076-D15B-42AB-AFD6-CE40472F6E84}.Release|x64.ActiveCfg = Release|x64 {CC0C7076-D15B-42AB-AFD6-CE40472F6E84}.Release|x64.Build.0 = Release|x64 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Debug|Win32.ActiveCfg = Debug|Win32 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Debug|Win32.Build.0 = Debug|Win32 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Debug|x64.ActiveCfg = Debug|x64 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Debug|x64.Build.0 = Debug|x64 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Release|Win32.ActiveCfg = Release|Win32 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Release|Win32.Build.0 = Release|Win32 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Release|x64.ActiveCfg = Release|x64 - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868}.Release|x64.Build.0 = Release|x64 {685612A9-F2AA-4ACA-8327-5D40E4731906}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32 {685612A9-F2AA-4ACA-8327-5D40E4731906}.Cpp11-Debug|Win32.Build.0 = Cpp11-Debug|Win32 {685612A9-F2AA-4ACA-8327-5D40E4731906}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64 @@ -4175,8 +4156,6 @@ Global {81413A55-9551-483B-BAC5-7D903C5DC167} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC} {606D6061-3084-498A-988A-7F5B9FE8732D} = {81413A55-9551-483B-BAC5-7D903C5DC167} {CC0C7076-D15B-42AB-AFD6-CE40472F6E84} = {81413A55-9551-483B-BAC5-7D903C5DC167} - {D47FCF7F-D83C-4699-9B3B-F58265E6239A} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC} - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868} = {D47FCF7F-D83C-4699-9B3B-F58265E6239A} {74640E74-D6AA-414C-8238-0FFDC854AE98} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC} {685612A9-F2AA-4ACA-8327-5D40E4731906} = {74640E74-D6AA-414C-8238-0FFDC854AE98} {D3A57C0F-C26F-4D25-A890-4D151D16C0D7} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC} diff --git a/cpp/src/Ice/GCValue.cpp b/cpp/src/Ice/GCValue.cpp deleted file mode 100644 index 58336ac81a7..00000000000 --- a/cpp/src/Ice/GCValue.cpp +++ /dev/null @@ -1,442 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#include - -#ifndef ICE_CPP11_MAPPING - -#include -#include - -using namespace std; -using namespace IceUtil; -using namespace IceInternal; - -namespace -{ - -typedef ::map GCCountMap; -Mutex* gcMutex = 0; - -class Init -{ -public: - - Init() - { - gcMutex = new Mutex(); - } - - ~Init() - { - delete gcMutex; - gcMutex = 0; - } -}; - -Init init; - -class ClearMembers : public GCVisitor -{ -public: - - virtual bool visit(GCValue*); -}; -ClearMembers clearMembers; - -class DecreaseRefCounts : public GCVisitor -{ -public: - - DecreaseRefCounts(GCCountMap&); - - virtual bool visit(GCValue*); - -private: - - GCCountMap& _counts; -}; - -class RestoreRefCountsIfReachable : public GCVisitor -{ -public: - - RestoreRefCountsIfReachable(GCCountMap&); - - virtual bool visit(GCValue*); - -private: - - GCCountMap& _counts; - bool _reachable; -}; - -class MarkCollectable : public GCVisitor -{ -public: - - MarkCollectable(); - - virtual bool visit(GCValue*); - - void visitNeighbor(GCValue*); - -private: - - int _counter; - map _numbers; - stack _p; - stack _s; - - class VisitNeighbors : public IceInternal::GCVisitor - { - public: - - void setVisitor(MarkCollectable*); - virtual bool visit(GCValue*); - - private: - - MarkCollectable* _visitor; - }; - VisitNeighbors _neighborsVisitor; -}; - -class ClearCollectable : public GCVisitor -{ -public: - - virtual bool visit(GCValue*); -}; - -} - -bool -ClearMembers::visit(GCValue*) -{ - return true; -} - -DecreaseRefCounts::DecreaseRefCounts(GCCountMap& counts) : _counts(counts) -{ -} - -bool -DecreaseRefCounts::visit(GCValue* obj) -{ - // - // Visit the object only once when the object is inserted for - // the first time in the counts map. After, we just decrement - // its reference count. Decrementing the reference counts of - // reachable objects will indicate when a cycle is - // collectable. Collectable objects are those with a reference - // count of zero and for which there's no "reachable" parent - // object (objects with a reference count > 0). - // - GCCountMap::iterator p = _counts.find(obj); - if(p == _counts.end()) - { - _counts.insert(make_pair(obj, obj->_iceGetRefUnsafe() - 1)); - if(obj->__hasFlag(GCValue::Collectable)) - { - obj->_iceGcVisitMembers(*this); - } - } - else - { - --p->second; - } - return false; -} - -RestoreRefCountsIfReachable::RestoreRefCountsIfReachable(GCCountMap& counts) : _counts(counts), _reachable(false) -{ -} - -bool -RestoreRefCountsIfReachable::visit(GCValue* obj) -{ - GCCountMap::iterator p = _counts.find(obj); - if(p == _counts.end()) - { - // - // If the object has been removed from the counts map, - // it's reachable. - // - return false; - } - else if(_reachable) - { - // - // If parent object is reachable, this object is also - // reachable. Remove it from the counts map and also make - // reachable children. - // - _counts.erase(p); - obj->_iceGcVisitMembers(*this); - } - else if(p->second == 0) - { - // - // If the object is collectable, set its count to -1 to - // indicate that it was already visited prevent it from - // being visited again. - // - p->second = -1; - obj->_iceGcVisitMembers(*this); - } - else if(p->second > 0) - { - // - // Object isn't collectable, remove it from the counts map - // and visit its sub-graph to remove children wobjects from - // the counts map since they are also reachable. - // - _counts.erase(p); - - _reachable = true; - obj->_iceGcVisitMembers(*this); - _reachable = false; - } - return false; -} - -MarkCollectable::MarkCollectable() : _counter(0) -{ - _neighborsVisitor.setVisitor(this); -} - -bool -MarkCollectable::visit(GCValue* obj) -{ - // - // Set the collectable flag on the object graph. While setting the - // flag, we also check if the object graph has cycles and mark all the - // objects which are part of a cycle with the CycleMember flag. - // - // We use the path-based strong component algorithm to detect the - // strong components of the graph. - // - - if(obj->__hasFlag(GCValue::Collectable)) - { - return false; - } - obj->__setFlag(GCValue::Collectable); - - _numbers[obj] = ++_counter; - _p.push(obj); - _s.push(obj); - - obj->_iceGcVisitMembers(_neighborsVisitor); - - if(_p.top() == obj) - { - GCValue* o; - do - { - o = _s.top(); - _s.pop(); - o->__setFlag(GCValue::CycleMember); - } - while(o != obj); - _p.pop(); - } - return false; -} - -void -MarkCollectable::visitNeighbor(GCValue* obj) -{ - map::const_iterator p = _numbers.find(obj); - if(p == _numbers.end()) - { - visit(obj); - } - else if(!obj->__hasFlag(GCValue::CycleMember)) - { - while(_numbers[_p.top()] > p->second) - { - _p.pop(); - } - } -} - -void -MarkCollectable::VisitNeighbors::setVisitor(MarkCollectable* visitor) -{ - _visitor = visitor; -} - -bool -MarkCollectable::VisitNeighbors::visit(GCValue* obj) -{ - _visitor->visitNeighbor(obj); - return false; -} - -bool -ClearCollectable::visit(GCValue* obj) -{ - // - // Clear the collectable flag on the object graph. - // - if(obj->__hasFlag(GCValue::Collectable)) - { - obj->__clearFlag(GCValue::Collectable | GCValue::CycleMember); - obj->_iceGcVisitMembers(*this); - } - return false; -} - -// -// Flags constant used for collection of graphs. -// -const unsigned char GCValue::Collectable = 2; -const unsigned char GCValue::CycleMember = 4; -const unsigned char GCValue::Visiting = 8; - -// -// GCValue -// -void -IceInternal::GCValue::__incRef() -{ - IceUtilInternal::MutexPtrLock lock(gcMutex); - ++_ref; -} - -void -IceInternal::GCValue::__decRef() -{ - IceUtilInternal::MutexPtrLock lock(gcMutex); - bool doDelete = false; - assert(_ref > 0); - - // - // Try to collect the object each time its reference count is - // decremented and only if it's part of a cycle. - // - if(_ref > 1 && __hasFlag(CycleMember) && collect(lock)) - { - return; - } - - if(--_ref == 0) - { - doDelete = !__hasFlag(NoDelete); - __setFlag(NoDelete); - } - - lock.release(); - if(doDelete) - { - delete this; - } -} - -int -IceInternal::GCValue::__getRef() const -{ - IceUtilInternal::MutexPtrLock lock(gcMutex); - return _ref; -} - -void -IceInternal::GCValue::__setNoDelete(bool b) -{ - IceUtilInternal::MutexPtrLock lock(gcMutex); - IceUtil::Shared::__setNoDelete(b); -} - -bool -GCValue::_iceGcVisit(GCVisitor& v) -{ - return v.visit(this); -} - -void -GCValue::ice_collectable(bool enable) -{ - IceUtilInternal::MutexPtrLock lock(gcMutex); - if(enable) - { - ClearCollectable().visit(this); - MarkCollectable().visit(this); - } - else - { - ClearCollectable().visit(this); - } -} - -bool -GCValue::collect(IceUtilInternal::MutexPtrLock& lock) -{ - GCCountMap counts; - - // - // Go through the object graph and decrease reference counts for - // all the objects from the graph. Cycles which can be collected - // should lead to objects with a zero reference count. - // - DecreaseRefCounts(counts).visit(this); - assert(counts.find(this) != counts.end()); - if(counts[this] > 0) - { - return false; // Object is still reachable, we're done. - } - - // - // Go the graph again and check for objects which are still - // reachable. If there are any, we restore the reference counts - // for the sub-graph of the reachable object and we remove the - // reachable objects from the counts map. At the end, if the - // counts map is empty, it indicates that this object graph isn't - // collectable yet. - // - RestoreRefCountsIfReachable(counts).visit(this); - if(counts.empty()) - { - return false; - } - - assert(counts.find(this) != counts.end()); // This object must be collectable. - - // - // At this point, we can release the lock. The objects from counts - // are un-reachable from the user code and clearing the members of - // the collectable objects requires acquiring the mutex to - // decrement their reference counts. - // - lock.release(); - - // - // Break all the cyclic reference counts of objects which are - // remaining in the counts map by clearing members. - // - // We first go through the list to mark all the objects as - // non-deletable and we also disable collection for all those - // objects since we already know they are collectable. - // - // After clearing members, we delete all the collectable - // objects. We can't just delete the objects since those objects - // likely point to each other. - // - for(GCCountMap::const_iterator p = counts.begin(); p != counts.end(); ++p) - { - p->first->__setFlag(NoDelete); - p->first->__clearFlag(CycleMember); // Disable cycle collection. - } - for(GCCountMap::const_iterator p = counts.begin(); p != counts.end(); ++p) - { - p->first->_iceGcVisitMembers(clearMembers); - } - for(GCCountMap::const_iterator p = counts.begin(); p != counts.end(); ++p) - { - delete p->first; - } - return true; -} -#endif diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index 030e5971733..39ff95bce57 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -156,10 +156,6 @@ Ice::InputStream::initialize(Instance* instance, const EncodingVersion& encoding initialize(encoding); _instance = instance; - -#ifndef ICE_CPP11_MAPPING - _collectObjects = _instance->collectObjects(); -#endif _traceSlicing = _instance->traceLevels()->slicing > 0; _classGraphDepthMax = _instance->classGraphDepthMax(); } @@ -170,9 +166,6 @@ Ice::InputStream::initialize(const EncodingVersion& encoding) _instance = 0; _encoding = encoding; _currentEncaps = 0; -#ifndef ICE_CPP11_MAPPING - _collectObjects = false; -#endif _traceSlicing = false; _classGraphDepthMax = 0x7fffffff; _closure = 0; @@ -217,14 +210,6 @@ Ice::InputStream::setCompactIdResolver(const CompactIdResolverPtr& r) _compactIdResolver = r; } -#ifndef ICE_CPP11_MAPPING -void -Ice::InputStream::setCollectObjects(bool on) -{ - _collectObjects = on; -} -#endif - void Ice::InputStream::setSliceValues(bool on) { @@ -271,9 +256,6 @@ Ice::InputStream::swap(InputStream& other) std::swap(_instance, other._instance); std::swap(_encoding, other._encoding); -#ifndef ICE_CPP11_MAPPING - std::swap(_collectObjects, other._collectObjects); -#endif std::swap(_traceSlicing, other._traceSlicing); std::swap(_classGraphDepthMax, other._classGraphDepthMax); std::swap(_closure, other._closure); @@ -1595,12 +1577,6 @@ Ice::InputStream::postUnmarshal(const ValuePtr& v) const { try { -#ifndef ICE_CPP11_MAPPING - if(_collectObjects) - { - v->ice_collectable(true); - } -#endif v->ice_postUnmarshal(); } catch(const std::exception& ex) diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 61e786b0401..b495f6b51a3 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -942,7 +942,6 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _messageSizeMax(0), _batchAutoFlushSize(0), _classGraphDepthMax(0), - _collectObjects(false), _toStringMode(ICE_ENUM(ToStringMode, Unicode)), _acceptClassCycles(false), _implicitContext(0), @@ -1206,8 +1205,6 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi } } - const_cast(_collectObjects) = _initData.properties->getPropertyAsInt("Ice.CollectObjects") > 0; - string toStringModeStr = _initData.properties->getPropertyWithDefault("Ice.ToStringMode", "Unicode"); if(toStringModeStr == "ASCII") { diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 150167190d8..4995c393285 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -104,7 +104,6 @@ class Instance : public IceUtil::Shared, public IceUtil::Monitor::iterator q = (*p)->instances.begin(); q != (*p)->instances.end(); ++q) - { - if(q->get()->_iceGcVisit(visitor)) - { - *q = 0; - } - } - } -} -#endif - Ice::UnknownSlicedValue::UnknownSlicedValue(const string& unknownTypeId) : _unknownTypeId(unknownTypeId) { } @@ -101,15 +81,6 @@ Ice::UnknownSlicedValue::ice_id() const return _unknownTypeId; } -void -Ice::UnknownSlicedValue::_iceGcVisitMembers(IceInternal::GCVisitor& _v) -{ - if(_slicedData) - { - _slicedData->_iceGcVisitMembers(_v); - } -} - #endif void diff --git a/cpp/src/Ice/Value.cpp b/cpp/src/Ice/Value.cpp index 0b09dbf56fa..d73d6e03009 100644 --- a/cpp/src/Ice/Value.cpp +++ b/cpp/src/Ice/Value.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include using namespace std; @@ -71,31 +72,12 @@ Ice::Value::ice_getSlicedData() const #else -Value* Ice::upCast(Value* p) { return p; } - void Ice::_icePatchValuePtr(ValuePtr& obj, const ValuePtr& v) { obj = v; } -bool -Ice::Value::operator==(const Value& r) const -{ - return this == &r; -} - -bool -Ice::Value::operator<(const Value& r) const -{ - return this < &r; -} - -void -Ice::Value::ice_collectable(bool) -{ -} - void Ice::Value::ice_preMarshal() { diff --git a/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj b/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj index e718a56b474..e0621acc13e 100644 --- a/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj +++ b/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj @@ -619,7 +619,6 @@ - diff --git a/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj.filters b/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj.filters index 6e362bd97bc..5a1e6bd3fe3 100644 --- a/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj.filters +++ b/cpp/src/Ice/msbuild/ice++11/ice++11.vcxproj.filters @@ -378,9 +378,6 @@ Source Files - - Source Files - Source Files diff --git a/cpp/src/Ice/msbuild/ice/ice.vcxproj b/cpp/src/Ice/msbuild/ice/ice.vcxproj index c5be624da84..2aeb6fd4e2b 100644 --- a/cpp/src/Ice/msbuild/ice/ice.vcxproj +++ b/cpp/src/Ice/msbuild/ice/ice.vcxproj @@ -624,7 +624,6 @@ - diff --git a/cpp/src/Ice/msbuild/ice/ice.vcxproj.filters b/cpp/src/Ice/msbuild/ice/ice.vcxproj.filters index 311813b0572..5e4488be9e2 100644 --- a/cpp/src/Ice/msbuild/ice/ice.vcxproj.filters +++ b/cpp/src/Ice/msbuild/ice/ice.vcxproj.filters @@ -377,9 +377,6 @@ Source Files - - Source Files - Source Files diff --git a/cpp/src/IceStorm/Instrumentation.h b/cpp/src/IceStorm/Instrumentation.h index 490a409c0d6..9a3a2b90cd5 100644 --- a/cpp/src/IceStorm/Instrumentation.h +++ b/cpp/src/IceStorm/Instrumentation.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/IceUtil/Shared.cpp b/cpp/src/IceUtil/Shared.cpp index a06ff11a5f6..2c8d1dfed5e 100644 --- a/cpp/src/IceUtil/Shared.cpp +++ b/cpp/src/IceUtil/Shared.cpp @@ -8,7 +8,7 @@ using namespace IceUtil; // // Flag constant used by the Shared class. Derived classes -// such as GCValue define more flag constants. +// can define more flag constants. // const unsigned char IceUtil::Shared::NoDelete = 1; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 4f68b0c1e17..9bf7f943e72 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2588,15 +2588,7 @@ Slice::Gen::DeclVisitor::visitClassDecl(const ClassDeclPtr& p) string scoped = fixKwd(p->scoped()); H << sp << nl << "class " << name << ';'; - - // - // upCast is not _upCast nor _iceUpCast for historical reasons. IceInternal::Handle - // depends on this name - // - H << nl << "/// \\cond INTERNAL"; - H << nl << _dllExport << getUnqualified("::Ice::Value*", scope) << " upCast(" << name << "*);"; - H << nl << "/// \\endcond"; - H << nl << "typedef ::IceInternal::Handle< " << name << "> " << p->name() << "Ptr;"; + H << nl << "using " << p->name() << "Ptr = ::Ice::SharedPtr<" << name << ">;"; // // _ice prefix because this function is in the Slice module namespace, where the user @@ -3145,8 +3137,6 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr base = p->base(); DataMemberList dataMembers = p->dataMembers(); DataMemberList allDataMembers = p->allDataMembers(); - bool basePreserved = p->inheritsMetaData("preserve-slice"); - bool preserved = basePreserved || p->hasMetaData("preserve-slice"); H << sp; writeDocSummary(H, p); @@ -3159,14 +3149,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) } else { - H << "public virtual " << getUnqualified("::Ice::Value", scope); - } - - bool override = p->canBeCyclic() && (!base || !base->canBeCyclic()); - bool hasGCValueBaseClass = basePreserved || override || preserved; - if(!basePreserved && (override || preserved)) - { - H << ", public ::IceInternal::GCValue"; + H << "public " << getUnqualified("::Ice::Value", scope); } H.restoreIndent(); @@ -3227,11 +3210,6 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << name << "(const " << name << "&) = default;"; H << nl << name << "& operator=(const " << name << "&) = default;"; - C << sp; - C << nl << "/// \\cond INTERNAL"; - C << nl << _dllExport << "::Ice::Value* " << scope.substr(2) << "upCast(" << name << "* p) { return p; }" << nl; - C << nl << "/// \\endcond"; - // // It would make sense to provide a covariant ice_clone(); unfortunately many compilers // (including VS2010) generate bad code for covariant types that use virtual inheritance @@ -3244,31 +3222,12 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << " */"; H << nl << "virtual " << getUnqualified("::Ice::ValuePtr", scope) << " ice_clone() const;"; - if(hasGCValueBaseClass) - { - C.zeroIndent(); - C << sp; - C << nl << "#if defined(_MSC_VER)"; - C << nl << "# pragma warning(push)"; - C << nl << "# pragma warning(disable:4589)"; - C << nl << "#endif"; - C.restoreIndent(); - } C << nl << "::Ice::ValuePtr"; C << nl << scoped.substr(2) << "::ice_clone() const"; C << sb; C << nl << getUnqualified("::Ice::Value*", scope) << " p = new " << name << "(*this);"; C << nl << "return p;"; - C << eb; - if(hasGCValueBaseClass) - { - C.zeroIndent(); - C << nl << "#if defined(_MSC_VER)"; - C << nl << "# pragma warning(pop)"; - C << nl << "#endif"; - C.restoreIndent(); - } H << sp; H << nl << "/**"; @@ -3298,8 +3257,6 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) C << nl << "return typeId;"; C << eb; - emitGCFunctions(p); - return true; } @@ -3529,21 +3486,6 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << eb; C << nl << "/// \\endcond"; - H << sp; - H << nl << "/// \\cond INTERNAL"; - H << nl << "inline bool operator==(const " << fixKwd(p->name()) << "& lhs, const " << fixKwd(p->name()) << "& rhs)"; - H << sb; - H << nl << "return static_cast(lhs) == static_cast(rhs);"; - H << eb; - H << sp; - H << nl << "inline bool operator<(const " << fixKwd(p->name()) << "& lhs, const " << fixKwd(p->name()) << "& rhs)"; - H << sb; - H << nl << "return static_cast(lhs) < static_cast(rhs);"; - H << eb; - H << nl << "/// \\endcond"; - _useWstring = resetUseWstring(_useWstringHist); } @@ -3563,143 +3505,6 @@ Slice::Gen::ObjectVisitor::emitDataMember(const DataMemberPtr& p) << name << ';'; } -void -Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) -{ - string scoped = fixKwd(p->scoped()); - string scope = fixKwd(p->scope()); - string name = fixKwd(p->name()); - ClassDefPtr base = p->base(); - DataMemberList dataMembers = p->dataMembers(); - - // - // A class can potentially be part of a cycle if it (recursively) contains class - // members. - // - bool canBeCyclic = p->canBeCyclic(); - bool basePreserved = p->inheritsMetaData("preserve-slice"); - bool preserved = basePreserved || p->hasMetaData("preserve-slice"); - - // - // _iceGcVisit() is overridden by the basemost class that can be - // cyclic, plus all classes derived from that class. - // - // We also override these methods for the initial preserved class in a - // hierarchy, regardless of whether the class itself is cyclic. - // - if(canBeCyclic || (preserved && !basePreserved)) - { - H << nl << "/// \\cond INTERNAL"; - H << nl << "virtual void _iceGcVisitMembers(::IceInternal::GCVisitor&);"; - H << nl << "/// \\endcond"; - - C << sp << nl << "void" << nl << scoped.substr(2) << "::_iceGcVisitMembers(::IceInternal::GCVisitor& v_)"; - C << sb; - - bool hasCyclicBase = base && base->canBeCyclic(); - if(hasCyclicBase || basePreserved) - { - emitUpcall(base, "::_iceGcVisitMembers(v_);", scope); - } - - if(preserved && !basePreserved) - { - C << nl << "if(_iceSlicedData)"; - C << sb; - C << nl << "_iceSlicedData->_iceGcVisitMembers(v_);"; - C << eb; - } - - for(DataMemberList::const_iterator i = dataMembers.begin(); i != dataMembers.end(); ++i) - { - if((*i)->type()->usesClasses()) - { - if((*i)->optional()) - { - C << nl << "if(" << fixKwd((*i)->name()) << ')'; - C << sb; - emitGCVisitCode((*i)->type(), getDataMemberRef(*i), "", 0); - C << eb; - } - else - { - emitGCVisitCode((*i)->type(), getDataMemberRef(*i), "", 0); - } - } - } - C << eb; - } -} - -void -Slice::Gen::ObjectVisitor::emitGCVisitCode(const TypePtr& p, const string& prefix, const string& name, int level) -{ - BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); - if((builtin && - (BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject || BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindValue)) || - ClassDeclPtr::dynamicCast(p)) - { - C << nl << "if(" << prefix << name << ')'; - C << sb; - ClassDeclPtr decl = ClassDeclPtr::dynamicCast(p); - if(decl) - { - string scope = fixKwd(decl->scope()); - C << nl << "if((" << scope << "upCast(" << prefix << name << ".get())->_iceGcVisit(v_)))"; - } - else - { - C << nl << "if((" << prefix << name << ".get())->_iceGcVisit(v_))"; - } - C << sb; - C << nl << prefix << name << " = 0;"; - C << eb; - C << eb; - } - else if(StructPtr::dynamicCast(p)) - { - StructPtr s = StructPtr::dynamicCast(p); - DataMemberList dml = s->dataMembers(); - for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i) - { - if((*i)->type()->usesClasses()) - { - emitGCVisitCode((*i)->type(), prefix + name + ".", fixKwd((*i)->name()), ++level); - } - } - } - else if(DictionaryPtr::dynamicCast(p)) - { - DictionaryPtr d = DictionaryPtr::dynamicCast(p); - string scoped = fixKwd(d->scoped()); - ostringstream tmp; - tmp << "_i" << level; - string iterName = tmp.str(); - C << sb; - C << nl << "for(" << scoped << "::iterator " << iterName << " = " << prefix + name - << ".begin(); " << iterName << " != " << prefix + name << ".end(); ++" << iterName << ")"; - C << sb; - emitGCVisitCode(d->valueType(), "", string("(*") + iterName + ").second", ++level); - C << eb; - C << eb; - } - else if(SequencePtr::dynamicCast(p)) - { - SequencePtr s = SequencePtr::dynamicCast(p); - string scoped = fixKwd(s->scoped()); - ostringstream tmp; - tmp << "_i" << level; - string iterName = tmp.str(); - C << sb; - C << nl << "for(" << scoped << "::iterator " << iterName << " = " << prefix + name - << ".begin(); " << iterName << " != " << prefix + name << ".end(); ++" << iterName << ")"; - C << sb; - emitGCVisitCode(s->type(), string("(*") + iterName + ")", "", ++level); - C << eb; - C << eb; - } -} - bool Slice::Gen::ObjectVisitor::emitBaseInitializers(const ClassDefPtr& p) { diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 52c3e629e92..4387d4c4f16 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -201,9 +201,6 @@ class Gen : private ::IceUtil::noncopyable private: void emitDataMember(const DataMemberPtr&); - void emitGCFunctions(const ClassDefPtr&); - void emitGCVisitCode(const TypePtr&, const std::string&, const std::string&, int); - void emitGCClearCode(const TypePtr&, const std::string&, const std::string&, int); bool emitBaseInitializers(const ClassDefPtr&); void emitOneShotConstructor(const ClassDefPtr&); void emitUpcall(const ClassDefPtr&, const std::string&, const std::string&); diff --git a/cpp/test/Ice/gc/Client.cpp b/cpp/test/Ice/gc/Client.cpp deleted file mode 100644 index 162042960a0..00000000000 --- a/cpp/test/Ice/gc/Client.cpp +++ /dev/null @@ -1,530 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace Test; - -namespace -{ - -int num = 0; -::IceUtil::Mutex* numMutex = 0; - -class Init -{ -public: - - Init() - { - numMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete numMutex; - numMutex = 0; - } -}; - -Init init; - -} - -static void -incNum() -{ - IceUtilInternal::MutexPtrLock lock(numMutex); - ++num; -} - -static void -decNum() -{ - IceUtilInternal::MutexPtrLock lock(numMutex); - --num; -} - -static int -getNum() -{ - IceUtilInternal::MutexPtrLock lock(numMutex); - return num; -} - -struct N : public C -{ - N() - { - incNum(); - } - - ~N() - { - decNum(); - } -}; - -typedef ::IceInternal::Handle NPtr; - -struct N2 : public C2 -{ - N2() - { - incNum(); - } - - ~N2() - { - decNum(); - } -}; - -typedef ::IceInternal::Handle N2Ptr; - -struct NN : public Node -{ - NN() - { - incNum(); - } - - ~NN() - { - decNum(); - } -}; - -typedef ::IceInternal::Handle NNPtr; - -struct NL : public Leaf -{ - NL() - { - incNum(); - } - - ~NL() - { - decNum(); - } -}; - -typedef ::IceInternal::Handle NLPtr; - -class TestHaveCycles : public IceInternal::GCVisitor -{ -public: - - virtual bool visit(IceInternal::GCValue* obj) - { - if(obj->__hasFlag(IceInternal::GCValue::Visiting)) - { - return false; - } - test(obj->__hasFlag(IceInternal::GCValue::CycleMember) && obj->__hasFlag(IceInternal::GCValue::Collectable)); - - obj->__setFlag(IceInternal::GCValue::Visiting); - obj->_iceGcVisitMembers(*this); - obj->__clearFlag(IceInternal::GCValue::Visiting); - return false; - } -}; - -void -allTests() -{ - cout << "testing single instance... " << flush; - { - NPtr n = new N; - test(getNum() == 1); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing single instance cycle... " << flush; - { - NPtr n = new N; - n->left = n; - test(getNum() == 1); - n->ice_collectable(true); - TestHaveCycles().visit(n.get()); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing single instance cycle with double pointers... " << flush; - { - NPtr n = new N; - n->left = n; - n->right = n; - n->ice_collectable(true); - TestHaveCycles().visit(n.get()); - test(getNum() == 1); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing double instance cycle... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - n1 = 0; - test(n2->left->left == n2); - test(getNum() == 2); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing double instance cycle with double pointers... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->right = n2; - n2->right = n1; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - n1 = 0; - test(n2->left->left == n2); - test(getNum() == 2); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing double instance cycle with looped pointers... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - n1->right = n1; - n2->right = n2; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - test(getNum() == 2); - n1 = 0; - test(n2->left->left == n2); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing triple instance cycle... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - n1 = 0; - test(n2->left->left->left == n2); - test(getNum() == 3); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing triple instance cycle with double pointers... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->right = n2; - n2->right = n3; - n3->right = n1; - test(getNum() == 3); - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing triple instance cycle with opposing pointers... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - n1->left = n2; - n2->left = n3; - n3->left = n1; - n1->right = n3; - n2->right = n1; - n3->right = n2; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - test(getNum() == 3); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing cycle with trailing instances... " << flush; - NPtr n; - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - n1->left = n2; - n2->left = n1; - n2->right = n3; - n3->left = n4; - n = n3; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - test(getNum() == 4); - } - test(getNum() == 2); - n = 0; - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing cycle with trailing instances and trailing cycle... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - NPtr n5 = new N; - NPtr n6 = new N; - n1->left = n2; - n2->left = n1; - n2->right = n3; - n3->left = n4; - n4->right = n5; - n5->right = n6; - n6->right = n5; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - n = n4; - test(getNum() == 6); - } - test(getNum() == 3); - n = 0; - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing complex cycles... " << flush; - { - NPtr n1 = new N; - NPtr n2 = new N; - NPtr n3 = new N; - NPtr n4 = new N; - NPtr n5 = new N; - NPtr n6 = new N; - NPtr n7 = new N; - NPtr n8 = new N; - - n1->left = n2; - n2->left = n3; - n2->right = n4; - n3->left = n8; - n3->right = n5; - n4->left = n5; - n5->left = n6; - n6->left = n5; - n6->right = n7; - n7->left = n3; - n8->left = n1; - n1->ice_collectable(true); - TestHaveCycles().visit(n1.get()); - - n4->ice_collectable(false); - - n4->ice_collectable(true); - TestHaveCycles().visit(n4.get()); - - n = n4; - test(getNum() == 8); - } - test(getNum() == 8); - n = 0; - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing random graphs... " << flush; - { - for(int i = 10; i <= 150; i += 10) // random graphs with 10 to 150 nodes - { - { - vector nodes; - for(int j = 0; j < i; ++j) - { - nodes.push_back(new N()); - } - - for(int j = 0; j < i; ++j) - { - nodes[static_cast(j)]->left = nodes[IceUtilInternal::random(i)]; - nodes[static_cast(j)]->right = nodes[IceUtilInternal::random(i)]; - } - - for(int j = 0; j < i; ++j) - { - nodes[static_cast(j)]->ice_collectable(true); - } - test(getNum() == i); - } - test(getNum() == 0); - } - } - cout << "ok" << endl; - - cout << "testing sequence element cycle... " << flush; - { - CSeq cs; - cs.push_back(new N); - cs.push_back(new N); - cs[0]->left = cs[1]; - cs[1]->left = cs[0]; - cs[0]->ice_collectable(true); - cs[1]->ice_collectable(true); - test(getNum() == 2); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing dictionary element cycle... " << flush; - { - CDict cd; - NPtr n1 = new N; - NPtr n2 = new N; - n1->left = n2; - n2->left = n1; - cd[0] = n1; - cd[1] = n2; - cd[0]->ice_collectable(true); - cd[1]->ice_collectable(true); - test(getNum() == 2); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing sequence of struct cycle... " << flush; - { - SSeq ss; - S s; - - ss.push_back(s); - ss.push_back(s); - ss[0].theC = new N; - ss[1].theC = new N; - ss[0].theC->left = ss[1].theC; - ss[1].theC->left = ss[0].theC; - ss[0].theC->ice_collectable(true); - ss[1].theC->ice_collectable(true); - test(getNum() == 2); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing sequence of struct of dictionary cycle... " << flush; - { - N2Ptr n2 = new N2; - S2 s2; - n2->theS2Seq.push_back(s2); - n2->theS2Seq.push_back(s2); - n2->theS2Seq[0].theC2Dict[0] = n2; - n2->theS2Seq[0].theC2Dict[1] = n2; - n2->theS2Seq[1].theC2Dict[0] = n2; - n2->theS2Seq[1].theC2Dict[1] = n2; - n2->ice_collectable(true); - test(getNum() == 1); - } - test(getNum() == 0); - cout << "ok" << endl; - - cout << "testing leaf nodes... " << flush; - - { - NNPtr nn = new NN; - nn->l = new NL; - test(getNum() == 2); - } - test(getNum() == 0); - - { - NLPtr p; - { - NNPtr nn = new NN; - p = new NL; - nn->l = p; - test(getNum() == 2); - } - test(getNum() == 1); - } - test(getNum() == 0); - - { - NNPtr nn = new NN; - NLPtr nl = new NL; - nn->l = nl; - nn->n = nn; - nn->ice_collectable(true); - TestHaveCycles().visit(nn.get()); - test(getNum() == 2); - } - test(getNum() == 0); - - { - NNPtr nn1 = new NN; - NNPtr nn2 = new NN; - NLPtr nl = new NL; - nn1->l = nl; - nn1->n = nn2; - nn2->l = nl; - nn2->n = nn1; - nn1->ice_collectable(true); - TestHaveCycles().visit(nn1.get()); - test(getNum() == 3); - } - test(getNum() == 0); - - { - NLPtr nl = new NL; - test(getNum() == 1); - } - test(getNum() == 0); - - { - NNPtr nn1 = new NN; - nn1->n = new NN; - test(getNum() == 2); - } - test(getNum() == 0); - - cout << "ok" << endl; -} - -class Client : public Test::TestHelper -{ -public: - - void run(int, char**); -}; - -void -Client::run(int, char**) -{ - allTests(); -} - -DEFINE_TEST(Client) diff --git a/cpp/test/Ice/gc/Test.ice b/cpp/test/Ice/gc/Test.ice deleted file mode 100644 index 4ecf4dcbb07..00000000000 --- a/cpp/test/Ice/gc/Test.ice +++ /dev/null @@ -1,185 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#pragma once - -[["suppress-warning:deprecated"]] - -module Test -{ - -class C -{ - C left; - C right; -} -sequence CSeq; - -dictionary CDict; - -struct S -{ - C theC; -} -sequence SSeq; - -class C2; -dictionary C2Dict; - -struct S2 -{ - C2Dict theC2Dict; -} - -sequence S2Seq; - -class C2 -{ - S2Seq theS2Seq; -} - -class Leaf -{ - int i; -} - -class Node -{ - Leaf l; - Node n; -} - -// -// Remainder of definitions are there to test that the generated code compiles; -// they are not used for the actual run-time tests. -// - -// Sequence of classes defined above. - -// Sequence of structs defined above. - -sequence C2DictSeq; // Sequence of dictionary. - -sequence CSeqSeq; // Sequence of sequence. - -// Struct containing classes defined above. - -struct A // Struct containing sequence. -{ - SSeq theSSeq; -} - -// Struct containing dictionary defined above. - -struct B // Struct containing struct. -{ - S theS; -} - -// Dictionary of classes defined above. - -dictionary CSeqDict; // Dictionary containing sequence. - -dictionary SDict; // Dictionary containing struct. - -dictionary CDictDict; // Dictionary containing dictionary. - -class CTest -{ - CSeq theCSeq; - SSeq theSSeq; - C2DictSeq theC2DictSeq; - CSeqSeq theCSeqSeq; - S theS; - A theA; - S2 theS2; - B theB; - CDict theCDict; - CSeqDict theCSeqDict; - SDict theSDict; - CDictDict theCDictDict; -} - -module AAA -{ - class B; - - sequence BSeq; - dictionary BDict; - struct BStruct - { - B bMem; - } - - class C - { - Object obj1; - Object obj2; - B b1; - B b2; - BSeq x; - BDict y; - BStruct z; - } -} - -module AAA -{ - sequence CSeq; - dictionary CDict; - struct CStruct - { - C cMem; - } - - class B - { - Object obj1; - Object obj2; - C c1; - C c2; - CSeq x; - CDict y; - CStruct z; - } -} - -module CCC -{ - class Forward; -} - -module CCC -{ - class Forward - { - } -} - -module DDD -{ - interface I - { - void op(); - } - - class C - { - } - - class C2; - - class U - { - I* myIstar; - C myC; - C2 myC2; - } - - class C2 - { - } -} - -} diff --git a/cpp/test/Ice/gc/msbuild/client.vcxproj b/cpp/test/Ice/gc/msbuild/client.vcxproj deleted file mode 100644 index 5308b73377c..00000000000 --- a/cpp/test/Ice/gc/msbuild/client.vcxproj +++ /dev/null @@ -1,340 +0,0 @@ - - - - - - - Cpp11-Debug - Win32 - - - Cpp11-Debug - x64 - - - Cpp11-Release - Win32 - - - Cpp11-Release - x64 - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {FA42EA5F-FDBE-4F27-ACC7-7717E401C868} - - - - - - Application - true - $(DefaultPlatformToolset) - - - Application - true - $(DefaultPlatformToolset) - - - Application - false - $(DefaultPlatformToolset) - - - Application - false - $(DefaultPlatformToolset) - - - Application - true - $(DefaultPlatformToolset) - - - Application - true - $(DefaultPlatformToolset) - - - Application - false - $(DefaultPlatformToolset) - - - Application - false - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - ..\..;%(AdditionalIncludeDirectories) - - - - - - - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - - - - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - true - true - true - true - true - true - true - ..\Test.ice - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/cpp/test/Ice/gc/msbuild/client.vcxproj.filters b/cpp/test/Ice/gc/msbuild/client.vcxproj.filters deleted file mode 100644 index 7cf07c8b3db..00000000000 --- a/cpp/test/Ice/gc/msbuild/client.vcxproj.filters +++ /dev/null @@ -1,138 +0,0 @@ - - - - - Source Files - - - Source Files\x64\Cpp11-Debug - - - Source Files\Win32\Cpp11-Debug - - - Source Files\x64\Debug - - - Source Files\Win32\Debug - - - Source Files\x64\Release - - - Source Files\Win32\Release - - - Source Files\x64\Cpp11-Release - - - Source Files\Win32\Cpp11-Release - - - - - {bf7a60ba-e6fa-462c-932e-67c925c2d724} - - - {083c00bf-b12f-437b-8a67-d2b7269c382e} - - - {d9ffdb0c-44f2-4e82-b60f-f5e5e0d9eef0} - ice - - - {c4b97d3f-b5d0-4a88-baa3-a5d25efa3cb6} - - - {b7218a93-6a10-415c-8796-e2e39890761d} - - - {965f15c3-2b39-4841-af59-9f2d1e0d409c} - - - {27f22892-b456-4f1d-907a-f06175dc2e17} - - - {13626163-49d2-4d4d-acd1-8f8231605e8c} - - - {2adfe4b6-f156-441f-98ef-b125dc32c9e4} - - - {5ad50c0d-11b4-426c-abb5-c760cab70c57} - - - {4635efbe-1056-4112-a5c6-87885d991729} - - - {816e8c3c-c473-42af-aa19-0ca6d1ce75cd} - - - {109e5c21-6efb-4947-b933-e45a4a38a535} - - - {8b2972a5-9bc7-485d-812b-8e71b54a00c3} - - - {6a561b0d-f6fb-4176-82ed-6d77569bd3b0} - - - {324be231-acdc-4927-9af9-5a4b92ef65ff} - - - {551b01c1-f70d-480a-b329-fd9457a4e2cb} - - - {81a31c95-d422-496c-90d1-b571f5889354} - - - {647f3263-5a57-42e7-9a03-ff5fd03b977a} - - - {f05a9a89-f8d1-4b72-9cae-c7b5bde62427} - - - {f3a50158-d1bb-44e1-9aaa-b12d871c4676} - - - {8ce16643-3d51-4550-98a7-2aab9e997e7e} - - - {a3938de5-ab86-414b-83ec-06ad7cff5b45} - - - - - Header Files\x64\Cpp11-Debug - - - Header Files\Win32\Cpp11-Debug - - - Header Files\x64\Debug - - - Header Files\Win32\Debug - - - Header Files\x64\Release - - - Header Files\Win32\Release - - - Header Files\x64\Cpp11-Release - - - Header Files\Win32\Cpp11-Release - - - - - - - - Slice Files - - - \ No newline at end of file diff --git a/cpp/test/Ice/gc/msbuild/packages.config b/cpp/test/Ice/gc/msbuild/packages.config deleted file mode 100644 index a93e137eccd..00000000000 --- a/cpp/test/Ice/gc/msbuild/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/cpp/test/Ice/gc/test.py b/cpp/test/Ice/gc/test.py deleted file mode 100644 index 3636632dd89..00000000000 --- a/cpp/test/Ice/gc/test.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# - -TestSuite(__name__, options = { "cpp11" : [False] }) diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp index 0786cd416d3..2148485a4af 100644 --- a/cpp/test/Ice/objects/AllTests.cpp +++ b/cpp/test/Ice/objects/AllTests.cpp @@ -205,11 +205,11 @@ allTests(Test::TestHelper* helper) test(b2 != dynamic_pointer_cast(d)); test(c != dynamic_pointer_cast(d)); #else - test(b1 != c); - test(b1 != d); - test(b2 != c); - test(b2 != d); - test(c != d); + test(b1 != BPtr::dynamicCast(c)); + test(b1 != BPtr::dynamicCast(d)); + test(b2 != BPtr::dynamicCast(c)); + test(b2 != BPtr::dynamicCast(d)); + test(c != CPtr::dynamicCast(d)); #endif test(b1->theB == b1); test(b1->theC == ICE_NULLPTR); @@ -268,11 +268,11 @@ allTests(Test::TestHelper* helper) test(d->theC == nullptr); #else test(b1 != b2); - test(b1 != c); - test(b1 != d); - test(b2 != c); - test(b2 != d); - test(c != d); + test(b1 != BPtr::dynamicCast(c)); + test(b1 != BPtr::dynamicCast(d)); + test(b2 != BPtr::dynamicCast(c)); + test(b2 != BPtr::dynamicCast(d)); + test(c != CPtr::dynamicCast(d)); test(b1->theA == b2); test(b1->theB == b1); test(b1->theC == ICE_NULLPTR); diff --git a/cpp/test/Ice/objects/Client.cpp b/cpp/test/Ice/objects/Client.cpp index 48d9f25d8f4..fdee6ca803d 100644 --- a/cpp/test/Ice/objects/Client.cpp +++ b/cpp/test/Ice/objects/Client.cpp @@ -107,9 +107,6 @@ Client::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); #ifdef ICE_CPP11_MAPPING diff --git a/cpp/test/Ice/objects/Collocated.cpp b/cpp/test/Ice/objects/Collocated.cpp index c6ebff30319..e640de161bb 100644 --- a/cpp/test/Ice/objects/Collocated.cpp +++ b/cpp/test/Ice/objects/Collocated.cpp @@ -99,9 +99,6 @@ Collocated::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif properties->setProperty("Ice.Warn.Dispatch", "0"); Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp index 1864b0afbc6..582c1168f6c 100644 --- a/cpp/test/Ice/objects/TestI.cpp +++ b/cpp/test/Ice/objects/TestI.cpp @@ -79,13 +79,6 @@ InitialI::InitialI(const Ice::ObjectAdapterPtr& adapter) : _e(new EI), _f(new FI(_e)) { -#ifndef ICE_CPP11_MAPPING - _b1->ice_collectable(true); - _b2->ice_collectable(true); - _c->ice_collectable(true); - _d->ice_collectable(true); -#endif - _b1->theA = _b2; // Cyclic reference to another B _b1->theB = _b1; // Self reference. _b1->theC = 0; // Null reference. @@ -108,8 +101,6 @@ InitialI::InitialI(const Ice::ObjectAdapterPtr& adapter) : InitialI::~InitialI() { -#ifdef ICE_CPP11_MAPPING - // No GC with the C++11 mapping _b1->theA = ICE_NULLPTR; _b1->theB = ICE_NULLPTR; @@ -118,7 +109,6 @@ InitialI::~InitialI() _b2->theC = ICE_NULLPTR; _c->theB = ICE_NULLPTR; -#endif } void diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h index 417fa00fa98..5d91ca0387e 100644 --- a/cpp/test/Ice/objects/TestI.h +++ b/cpp/test/Ice/objects/TestI.h @@ -40,7 +40,7 @@ class EI : public Test::E bool checkValues(); }; -ICE_DEFINE_PTR(EIPtr, EI); +ICE_DEFINE_SHARED_PTR(EIPtr, EI); class FI : public Test::F { @@ -51,7 +51,7 @@ class FI : public Test::F bool checkValues(); }; -ICE_DEFINE_PTR(FIPtr, FI); +ICE_DEFINE_SHARED_PTR(FIPtr, FI); class InitialI : public Test::Initial { diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp index 168f2a60d02..47adea7a149 100644 --- a/cpp/test/Ice/optional/AllTests.cpp +++ b/cpp/test/Ice/optional/AllTests.cpp @@ -449,10 +449,6 @@ allTests(Test::TestHelper* helper, bool) mo1->bos->push_back(true); mo1->bos->push_back(false); -#ifndef ICE_CPP11_MAPPING - mo1->ice_collectable(true); -#endif - MultiOptionalPtr mo2 = ICE_MAKE_SHARED(MultiOptional, *mo1); MultiOptionalPtr mo3 = ICE_MAKE_SHARED(MultiOptional); @@ -668,9 +664,6 @@ allTests(Test::TestHelper* helper, bool) // Clear the second half of the optional parameters MultiOptionalPtr mo8 = ICE_MAKE_SHARED(MultiOptional, *mo5); -#ifndef ICE_CPP11_MAPPING - mo8->ice_collectable(true); -#endif mo8->b = IceUtil::None; mo8->d = IceUtil::None; mo8->f = IceUtil::None; @@ -768,17 +761,15 @@ allTests(Test::TestHelper* helper, bool) factory->setEnabled(false); } -#ifdef ICE_CPP11_MAPPING - mo1->k = shared_ptr(); - mo2->k = shared_ptr(); - mo3->k = shared_ptr(); - mo4->k = shared_ptr(); - mo5->k = shared_ptr(); - mo6->k = shared_ptr(); - mo7->k = shared_ptr(); - mo8->k = shared_ptr(); - mo9->k = shared_ptr(); -#endif + mo1->k = nullptr; + mo2->k = nullptr; + mo3->k = nullptr; + mo4->k = nullptr; + mo5->k = nullptr; + mo6->k = nullptr; + mo7->k = nullptr; + mo8->k = nullptr; + mo9->k = nullptr; // // Use the 1.0 encoding with operations whose only class parameters are optional. @@ -1493,8 +1484,8 @@ allTests(Test::TestHelper* helper, bool) out.write(1, Ice::make_optional(f)); out.write(2, Ice::make_optional(f->ae)); #else - out.write(1, makeOptional(f)); - out.write(2, makeOptional(f->ae)); + out.write(1, IceUtil::makeOptional(f)); + out.write(2, IceUtil::makeOptional(f->ae)); #endif out.endEncapsulation(); out.finished(inEncaps); diff --git a/cpp/test/Ice/optional/Client.cpp b/cpp/test/Ice/optional/Client.cpp index 4806e2f02cf..3537588b4b4 100644 --- a/cpp/test/Ice/optional/Client.cpp +++ b/cpp/test/Ice/optional/Client.cpp @@ -21,9 +21,6 @@ Client::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); InitialPrxPtr allTests(Test::TestHelper*, bool); InitialPrxPtr initial = allTests(this, false); diff --git a/cpp/test/Ice/optional/Server.cpp b/cpp/test/Ice/optional/Server.cpp index a84d6694b7e..767ea2ec0c9 100644 --- a/cpp/test/Ice/optional/Server.cpp +++ b/cpp/test/Ice/optional/Server.cpp @@ -21,9 +21,6 @@ Server::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint()); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); diff --git a/cpp/test/Ice/optional/ServerAMD.cpp b/cpp/test/Ice/optional/ServerAMD.cpp index f9d16fed20f..e51be87790d 100644 --- a/cpp/test/Ice/optional/ServerAMD.cpp +++ b/cpp/test/Ice/optional/ServerAMD.cpp @@ -20,9 +20,6 @@ ServerAMD::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint()); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); diff --git a/cpp/test/Ice/slicing/objects/AllTests.cpp b/cpp/test/Ice/slicing/objects/AllTests.cpp index d06d50b3d78..831f46350ae 100644 --- a/cpp/test/Ice/slicing/objects/AllTests.cpp +++ b/cpp/test/Ice/slicing/objects/AllTests.cpp @@ -12,12 +12,10 @@ using namespace Test; namespace { -#ifdef ICE_CPP11_MAPPING - -void breakCycles(shared_ptr); +void breakCycles(Ice::ValuePtr); template -void breakCycles(const vector>& s) +void breakCycles(const vector>& s) { for(auto e : s) { @@ -26,7 +24,7 @@ void breakCycles(const vector>& s) } template -void breakCycles(const map>& d) +void breakCycles(const map>& d) { for(auto e : d) { @@ -34,11 +32,11 @@ void breakCycles(const map>& d) } } -void breakCycles(shared_ptr o) +void breakCycles(ICE_SHARED_PTR o) { - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(D1, o)) { - auto d1 = dynamic_pointer_cast(o); + auto d1 = ICE_DYNAMIC_CAST(D1, o); auto tmp = d1->pd1; d1->pd1 = nullptr; if(tmp != d1) @@ -46,52 +44,52 @@ void breakCycles(shared_ptr o) breakCycles(tmp); } } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(D3, o)) { - auto d3 = dynamic_pointer_cast(o); + auto d3 = ICE_DYNAMIC_CAST(D3, o); d3->pd3 = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(B, o)) { - auto b = dynamic_pointer_cast(o); - if(b->pb != nullptr) + auto b = ICE_DYNAMIC_CAST(B, o); + if(b->pb) { b->pb->pb = nullptr; } b->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PDerived, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(PDerived, o); p->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(CompactPDerived, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(CompactPDerived, o); p->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PCDerived, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(PCDerived, o); auto seq(p->pbs); p->pbs.clear(); breakCycles(seq); } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(CompactPCDerived, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(CompactPCDerived, o); auto seq(p->pbs); p->pbs.clear(); breakCycles(seq); } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PCDerived3, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(PCDerived3, o); p->pcd3 = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PNode, o)) { - auto curr = dynamic_pointer_cast(o); + auto curr = ICE_DYNAMIC_CAST(PNode, o); while(curr && o != curr->next) { auto next = curr->next; @@ -99,31 +97,22 @@ void breakCycles(shared_ptr o) curr = next; } } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(SS1, o)) { - auto s = dynamic_pointer_cast(o); + auto s = ICE_DYNAMIC_CAST(SS1, o); breakCycles(s->s); } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(SS2, o)) { - auto s = dynamic_pointer_cast(o); + auto s = ICE_DYNAMIC_CAST(SS2, o); breakCycles(s->s); } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(Forward, o)) { - auto f = dynamic_pointer_cast(o); + auto f = ICE_DYNAMIC_CAST(Forward, o); f->h = nullptr; } } -#else - -template -void breakCycles(T) -{ - // no op, we rely on C++98 collection. -} - -#endif class CallbackBase : public IceUtil::Monitor { @@ -1636,9 +1625,6 @@ allTests(Test::TestHelper* helper) d3->pd3 = d1; d1->pb = d3; d1->pd1 = d3; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#endif BPtr b1 = test->returnTest3(d1, d3); @@ -1688,9 +1674,6 @@ allTests(Test::TestHelper* helper) d3->pd3 = d1; d1->pb = d3; d1->pd1 = d3; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#endif #ifdef ICE_CPP11_MAPPING auto f = test->returnTest3Async(d1, d3); @@ -1749,9 +1732,7 @@ allTests(Test::TestHelper* helper) d3->pd3 = d1; d1->pb = d3; d1->pd1 = d3; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#endif + BPtr b1 = test->returnTest3(d3, d1); test(b1); @@ -1802,9 +1783,6 @@ allTests(Test::TestHelper* helper) d3->pd3 = d1; d1->pb = d3; d1->pd1 = d3; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#endif #ifdef ICE_CPP11_MAPPING auto f = test->returnTest3Async(d3, d1); @@ -2002,9 +1980,6 @@ allTests(Test::TestHelper* helper) d3->pb = d3; d3->sd3 = "D3.sd3"; d3->pd3 = b1; -#ifndef ICE_CPP11_MAPPING - d3->ice_collectable(true); -#endif BPtr b2 = ICE_MAKE_SHARED(B); b2->sb = "B.sb(2)"; @@ -2041,9 +2016,6 @@ allTests(Test::TestHelper* helper) d3->pb = d3; d3->sd3 = "D3.sd3"; d3->pd3 = b1; -#ifndef ICE_CPP11_MAPPING - d3->ice_collectable(true); -#endif BPtr b2 = ICE_MAKE_SHARED(B); b2->sb = "B.sb(2)"; @@ -2089,17 +2061,13 @@ allTests(Test::TestHelper* helper) d3->pb = d3; d3->sd3 = "D3.sd3"; d3->pd3 = d11; -#ifndef ICE_CPP11_MAPPING - d3->ice_collectable(true); -#endif + D1Ptr d12 = ICE_MAKE_SHARED(D1); d12->sb = "D1.sb(2)"; d12->pb = d12; d12->sd1 = "D1.sd1(2)"; d12->pd1 = d11; -#ifndef ICE_CPP11_MAPPING - d12->ice_collectable(true); -#endif + BPtr r = test->returnTest3(d3, d12); test(r); test(r->ice_id() == "::Test::B"); @@ -2133,17 +2101,12 @@ allTests(Test::TestHelper* helper) d3->pb = d3; d3->sd3 = "D3.sd3"; d3->pd3 = d11; -#ifndef ICE_CPP11_MAPPING - d3->ice_collectable(true); -#endif + D1Ptr d12 = ICE_MAKE_SHARED(D1); d12->sb = "D1.sb(2)"; d12->pb = d12; d12->sd1 = "D1.sd1(2)"; d12->pd1 = d11; -#ifndef ICE_CPP11_MAPPING - d12->ice_collectable(true); -#endif #ifdef ICE_CPP11_MAPPING auto r = test->returnTest3Async(d3, d12).get(); @@ -2190,9 +2153,7 @@ allTests(Test::TestHelper* helper) ss1d3->sb = "D3.sb"; ss1d3->sd3 = "D3.sd3"; ss1d3->pb = ss1b; -#ifndef ICE_CPP11_MAPPING - ss1d3->ice_collectable(true); -#endif + BPtr ss2b = ICE_MAKE_SHARED(B); ss2b->sb = "B.sb"; ss2b->pb = ss1b; @@ -2223,10 +2184,6 @@ allTests(Test::TestHelper* helper) ss2->s.push_back(ss2d1); ss2->s.push_back(ss2d3); -#ifndef ICE_CPP11_MAPPING - ss1->ice_collectable(true); - ss2->ice_collectable(true); -#endif ss = test->sequenceTest(ss1, ss2); breakCycles(ss1); @@ -2289,9 +2246,6 @@ allTests(Test::TestHelper* helper) ss1d3->sb = "D3.sb"; ss1d3->sd3 = "D3.sd3"; ss1d3->pb = ss1b; -#ifndef ICE_CPP11_MAPPING - ss1d3->ice_collectable(true); -#endif BPtr ss2b = ICE_MAKE_SHARED(B); ss2b->sb = "B.sb"; @@ -2322,10 +2276,6 @@ allTests(Test::TestHelper* helper) ss2->s.push_back(ss2b); ss2->s.push_back(ss2d1); ss2->s.push_back(ss2d3); -#ifndef ICE_CPP11_MAPPING - ss1->ice_collectable(true); - ss2->ice_collectable(true); -#endif #ifdef ICE_CPP11_MAPPING ss = test->sequenceTestAsync(ss1, ss2).get(); @@ -2395,9 +2345,6 @@ allTests(Test::TestHelper* helper) d1->pb = d1; d1->sd1 = s.str(); bin[i] = d1; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#endif } r = test->dictionaryTest(bin, bout); @@ -2459,9 +2406,6 @@ allTests(Test::TestHelper* helper) d1->pb = d1; d1->sd1 = s.str(); bin[i] = d1; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#endif } #ifdef ICE_CPP11_MAPPING @@ -2769,9 +2713,6 @@ allTests(Test::TestHelper* helper) pd->pi = 3; pd->ps = "preserved"; pd->pb = pd; -#ifndef ICE_CPP11_MAPPING - pd->ice_collectable(true); -#endif PBasePtr r = test->exchangePBase(pd); PDerivedPtr p2 = ICE_DYNAMIC_CAST(PDerived, r); test(p2); @@ -2814,10 +2755,6 @@ allTests(Test::TestHelper* helper) PCDerivedPtr pcd = ICE_MAKE_SHARED(PCDerived); pcd->pi = 3; pcd->pbs.push_back(pcd); -#ifndef ICE_CPP11_MAPPING - pcd->ice_collectable(true); -#endif - PBasePtr r = test->exchangePBase(pcd); PCDerivedPtr p2 = ICE_DYNAMIC_CAST(PCDerived, r); if(test->ice_getEncodingVersion() == Ice::Encoding_1_0) @@ -2848,10 +2785,6 @@ allTests(Test::TestHelper* helper) CompactPCDerivedPtr pcd = ICE_MAKE_SHARED(CompactPCDerived); pcd->pi = 3; pcd->pbs.push_back(pcd); -#ifndef ICE_CPP11_MAPPING - pcd->ice_collectable(true); -#endif - PBasePtr r = test->exchangePBase(pcd); CompactPCDerivedPtr p2 = ICE_DYNAMIC_CAST(CompactPCDerived, r); if(test->ice_getEncodingVersion() == Ice::Encoding_1_0) @@ -2968,10 +2901,6 @@ allTests(Test::TestHelper* helper) pd->ps = "preserved"; pd->pb = pd; -#ifndef ICE_CPP11_MAPPING - pd->ice_collectable(true); -#endif - #ifdef ICE_CPP11_MAPPING try { @@ -2980,9 +2909,7 @@ allTests(Test::TestHelper* helper) test(r->pi == 3); test(r->ps == "preserved"); test(r->pb == r); - breakCycles(r); - breakCycles(pd); } catch(...) { @@ -2994,6 +2921,7 @@ allTests(Test::TestHelper* helper) pd, newCallback_TestIntf_exchangePBase(cb, &Callback::response_preserved1, &Callback::exception)); cb->check(); #endif + breakCycles(pd); } { @@ -3053,9 +2981,7 @@ allTests(Test::TestHelper* helper) breakCycles(r); breakCycles(p2); } - breakCycles(pcd); #else - pcd->ice_collectable(true); CallbackPtr cb = new Callback; if(test->ice_getEncodingVersion() == Ice::Encoding_1_0) @@ -3070,6 +2996,7 @@ allTests(Test::TestHelper* helper) } cb->check(); #endif + breakCycles(pcd); } { @@ -3101,10 +3028,7 @@ allTests(Test::TestHelper* helper) breakCycles(r); breakCycles(p2); } - breakCycles(pcd); #else - pcd->ice_collectable(true); - CallbackPtr cb = new Callback; if(test->ice_getEncodingVersion() == Ice::Encoding_1_0) { @@ -3120,6 +3044,7 @@ allTests(Test::TestHelper* helper) } cb->check(); #endif + breakCycles(pcd); } { @@ -3189,130 +3114,5 @@ allTests(Test::TestHelper* helper) } cout << "ok" << endl; -#ifndef ICE_CPP11_MAPPING - cout << "garbage collection for preserved classes... " << flush; - try - { - // - // Register a factory in order to substitute our own subclass of PNode. This provides - // an easy way to determine how many unmarshaled instances currently exist. - // - communicator->getValueFactoryManager()->add(new NodeFactoryI, PNode::ice_staticId()); - - // - // Relay a graph through the server. This test uses a preserved class - // with a class member, so the preserved class already supports GC. - // - { - PNodePtr c = new PNode; - c->next = new PNode; - c->next->next = new PNode; - c->next->next->next = c; - - test(PNodeI::counter == 0); - PNodePtr n = test->exchangePNode(c); - c->next->next->next = 0; // Break the cycle. - - test(PNodeI::counter == 3); - n = 0; // Release reference. - test(PNodeI::counter == 0); - } - - // - // Obtain a preserved object from the server where the most-derived - // type is unknown. The preserved slice refers to a graph of PNode - // objects. - // - { - test(PNodeI::counter == 0); - PreservedPtr p = test->PBSUnknownAsPreservedWithGraph(); - test->checkPBSUnknownWithGraph(p); - if(test->ice_getEncodingVersion() == Ice::Encoding_1_0) - { - test(!p->ice_getSlicedData()); - test(PNodeI::counter == 0); - } - else - { - test(p->ice_getSlicedData()); - test(PNodeI::counter == 3); - p->ice_getSlicedData()->clear(); - p = 0; // Release reference. - test(PNodeI::counter == 0); - } - } - - // - // Register a factory in order to substitute our own subclass of Preserved. This provides - // an easy way to determine how many unmarshaled instances currently exist. - // - communicator->getValueFactoryManager()->add(new PreservedFactoryI, Preserved::ice_staticId()); - - // - // Obtain a preserved object from the server where the most-derived - // type is unknown. A data member in the preserved slice refers to the - // outer object, so the chain of references looks like this: - // - // outer->slicedData->outer - // - { - test(PreservedI::counter == 0); - PreservedPtr p = test->PBSUnknown2AsPreservedWithGraph(); - test->checkPBSUnknown2WithGraph(p); - if(test->ice_getEncodingVersion() != Ice::Encoding_1_0) - { - test(p->ice_getSlicedData()); - p->ice_getSlicedData()->clear(); - } - test(PreservedI::counter == 1); - p = 0; // Release reference. - test(PreservedI::counter == 0); - } - - // - // Throw a preserved exception where the most-derived type is unknown. - // The preserved exception slice contains a class data member. This - // object is also preserved, and its most-derived type is also unknown. - // The preserved slice of the object contains a class data member that - // refers to itself. - // - // The chain of references looks like this: - // - // ex->slicedData->obj->slicedData->obj - // - try - { - test(PreservedI::counter == 0); - - try - { - test->throwPreservedException(); - } - catch(const PreservedException&) - { - // - // The class instance is only retained when the encoding is > 1.0. - // - if(test->ice_getEncodingVersion() != Ice::Encoding_1_0) - { - test(PreservedI::counter == 1); - } - } - - // - // Exception has gone out of scope. - // - test(PreservedI::counter == 0); - } - catch(const Ice::Exception&) - { - test(false); - } - } - catch(const Ice::OperationNotExistException&) - { - } - cout << "ok" << endl; -#endif return test; } diff --git a/cpp/test/Ice/slicing/objects/Client.cpp b/cpp/test/Ice/slicing/objects/Client.cpp index b9f217e495d..5d5e904b75c 100644 --- a/cpp/test/Ice/slicing/objects/Client.cpp +++ b/cpp/test/Ice/slicing/objects/Client.cpp @@ -20,11 +20,7 @@ void Client::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); - // - // For this test, we enable object collection. - // properties->setProperty("Ice.AcceptClassCycles", "1"); - properties->setProperty("Ice.CollectObjects", "1"); Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); TestIntfPrxPtr allTests(Test::TestHelper*); diff --git a/cpp/test/Ice/slicing/objects/Server.cpp b/cpp/test/Ice/slicing/objects/Server.cpp index b7ca13be31b..f1b36cd9a48 100644 --- a/cpp/test/Ice/slicing/objects/Server.cpp +++ b/cpp/test/Ice/slicing/objects/Server.cpp @@ -20,9 +20,6 @@ Server::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint() + " -t 2000"); diff --git a/cpp/test/Ice/slicing/objects/ServerAMD.cpp b/cpp/test/Ice/slicing/objects/ServerAMD.cpp index e7e60f6998f..e5abab64d3b 100644 --- a/cpp/test/Ice/slicing/objects/ServerAMD.cpp +++ b/cpp/test/Ice/slicing/objects/ServerAMD.cpp @@ -20,9 +20,6 @@ ServerAMD::run(int argc, char** argv) { Ice::PropertiesPtr properties = createTestProperties(argc, argv); properties->setProperty("Ice.AcceptClassCycles", "1"); -#ifndef ICE_CPP11_MAPPING - properties->setProperty("Ice.CollectObjects", "1"); -#endif Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0"); communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint() + " -t 2000"); diff --git a/cpp/test/Ice/slicing/objects/TestAMDI.cpp b/cpp/test/Ice/slicing/objects/TestAMDI.cpp index 55ca8bb63ef..2dde37cbbff 100644 --- a/cpp/test/Ice/slicing/objects/TestAMDI.cpp +++ b/cpp/test/Ice/slicing/objects/TestAMDI.cpp @@ -716,9 +716,6 @@ TestI::SUnknownAsObject_async(const AMD_TestIntf_SUnknownAsObjectPtr& cb, const SUnknownPtr su = new SUnknown; su->su = "SUnknown.su"; su->cycle = su; -#ifndef ICE_CPP11_MAPPING - su->ice_collectable(true); -#endif cb->ice_response(su); } @@ -746,7 +743,6 @@ TestI::oneElementCycle_async(const AMD_TestIntf_oneElementCyclePtr& cb, const :: BPtr b = new B; b->sb = "B1.sb"; b->pb = b; - b->ice_collectable(true); cb->ice_response(b); } @@ -759,7 +755,6 @@ TestI::twoElementCycle_async(const AMD_TestIntf_twoElementCyclePtr& cb, const :: b2->sb = "B2.sb"; b2->pb = b1; b1->pb = b2; - b1->ice_collectable(true); cb->ice_response(b1); } @@ -776,8 +771,6 @@ TestI::D1AsB_async(const AMD_TestIntf_D1AsBPtr& cb, const ::Ice::Current&) d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; - d1->ice_collectable(true); - d2->ice_collectable(true); cb->ice_response(d1); } @@ -794,7 +787,6 @@ TestI::D1AsD1_async(const AMD_TestIntf_D1AsD1Ptr& cb, const ::Ice::Current&) d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; - d1->ice_collectable(true); cb->ice_response(d1); } @@ -811,7 +803,6 @@ TestI::D2AsB_async(const AMD_TestIntf_D2AsBPtr& cb, const ::Ice::Current&) d1->pd1 = d2; d2->pb = d1; d2->pd2 = d1; - d2->ice_collectable(true); cb->ice_response(d2); } @@ -828,8 +819,6 @@ TestI::paramTest1_async(const AMD_TestIntf_paramTest1Ptr& cb, const ::Ice::Curre d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; - d1->ice_collectable(true); - d2->ice_collectable(true); cb->ice_response(d1, d2); } @@ -846,7 +835,6 @@ TestI::paramTest2_async(const AMD_TestIntf_paramTest2Ptr& cb, const ::Ice::Curre d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; - d1->ice_collectable(true); cb->ice_response(d2, d1); } @@ -890,7 +878,6 @@ TestI::paramTest4_async(const AMD_TestIntf_paramTest4Ptr& cb, const ::Ice::Curre d4->p1->sb = "B.sb (1)"; d4->p2 = new B; d4->p2->sb = "B.sb (2)"; - d4->ice_collectable(true); cb->ice_response(d4->p2, d4); } @@ -907,7 +894,6 @@ TestI::returnTest1_async(const AMD_TestIntf_returnTest1Ptr& cb, const ::Ice::Cur d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; - d1->ice_collectable(true); cb->ice_response(d2, d2, d1); } @@ -924,8 +910,6 @@ TestI::returnTest2_async(const AMD_TestIntf_returnTest2Ptr& cb, const ::Ice::Cur d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; - d1->ice_collectable(true); - d2->ice_collectable(true); cb->ice_response(d1, d1, d2); } @@ -958,7 +942,6 @@ TestI::dictionaryTest_async(const AMD_TestIntf_dictionaryTestPtr& cb, const BDic d2->pb = b->pb; d2->sd2 = "D2"; d2->pd2 = d2; - d2->ice_collectable(true); bout[i * 10] = d2; } BDict r; @@ -971,7 +954,6 @@ TestI::dictionaryTest_async(const AMD_TestIntf_dictionaryTestPtr& cb, const BDic d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second); d1->sd1 = s.str(); d1->pd1 = d1; - d1->ice_collectable(true); r[i * 20] = d1; } cb->ice_response(r, bout); @@ -1114,7 +1096,6 @@ TestI::throwBaseAsBase_async(const AMD_TestIntf_throwBaseAsBasePtr& cb, const :: be.pb = new B; be.pb->sb = "sb"; be.pb->pb = be.pb; - be.pb->ice_collectable(true); cb->ice_exception(be); } @@ -1132,8 +1113,6 @@ TestI::throwDerivedAsBase_async(const AMD_TestIntf_throwDerivedAsBasePtr& cb, co de.pd1->pb = de.pd1; de.pd1->sd1 = "sd2"; de.pd1->pd1 = de.pd1; - de.pb->ice_collectable(true); - de.pd1->ice_collectable(true); cb->ice_exception(de); } @@ -1151,8 +1130,6 @@ TestI::throwDerivedAsDerived_async(const AMD_TestIntf_throwDerivedAsDerivedPtr& de.pd1->pb = de.pd1; de.pd1->sd1 = "sd2"; de.pd1->pd1 = de.pd1; - de.pb->ice_collectable(true); - de.pd1->ice_collectable(true); cb->ice_exception(de); } @@ -1164,7 +1141,6 @@ TestI::throwUnknownDerivedAsBase_async(const AMD_TestIntf_throwUnknownDerivedAsB d2->pb = d2; d2->sd2 = "sd2 d2"; d2->pd2 = d2; - d2->ice_collectable(true); UnknownDerivedException ude; ude.sbe = "sbe"; @@ -1192,7 +1168,6 @@ TestI::useForward_async(const AMD_TestIntf_useForwardPtr& cb, const ::Ice::Curre ForwardPtr f = new Forward; f->h = new Hidden; f->h->f = f; - f->ice_collectable(true); cb->ice_response(f); } diff --git a/cpp/test/Ice/slicing/objects/TestI.cpp b/cpp/test/Ice/slicing/objects/TestI.cpp index 8b8e3a648cd..df1c6636581 100644 --- a/cpp/test/Ice/slicing/objects/TestI.cpp +++ b/cpp/test/Ice/slicing/objects/TestI.cpp @@ -12,12 +12,10 @@ using namespace std; namespace { -#ifdef ICE_CPP11_MAPPING - -void breakCycles(shared_ptr); +void breakCycles(Ice::ValuePtr); template -void breakCycles(const vector>& s) +void breakCycles(const vector>& s) { for(auto e : s) { @@ -26,7 +24,7 @@ void breakCycles(const vector>& s) } template -void breakCycles(const map>& d) +void breakCycles(const map>& d) { for(auto e : d) { @@ -34,11 +32,11 @@ void breakCycles(const map>& d) } } -void breakCycles(shared_ptr o) +void breakCycles(Ice::ValuePtr o) { - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(D1, o)) { - auto d1 = dynamic_pointer_cast(o); + auto d1 = ICE_DYNAMIC_CAST(D1, o); auto tmp = d1->pd1; d1->pd1 = nullptr; if(tmp != d1) @@ -46,47 +44,47 @@ void breakCycles(shared_ptr o) breakCycles(tmp); } } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(D2, o)) { - auto d2 = dynamic_pointer_cast(o); + auto d2 = ICE_DYNAMIC_CAST(D2, o); d2->pd2 = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(D4, o)) { - auto d4 = dynamic_pointer_cast(o); + auto d4 = ICE_DYNAMIC_CAST(D4, o); d4->p1 = nullptr; d4->p2 = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(B, o)) { - auto b = dynamic_pointer_cast(o); - if(b->pb != nullptr) + auto b = ICE_DYNAMIC_CAST(B, o); + if(b->pb) { b->pb->pb = nullptr; } b->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(Preserved, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(Preserved, o); if(p->ice_getSlicedData()) { p->ice_getSlicedData()->clear(); } } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PDerived, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(PDerived, o); p->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(CompactPDerived, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(CompactPDerived, o); p->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PNode, o)) { - auto curr = dynamic_pointer_cast(o); + auto curr = ICE_DYNAMIC_CAST(PNode, o); while(curr && o != curr->next) { curr = curr->next; @@ -96,52 +94,38 @@ void breakCycles(shared_ptr o) curr->next = nullptr; } } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PSUnknown, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(PSUnknown, o); breakCycles(p->graph); } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(PSUnknown2, o)) { - auto p = dynamic_pointer_cast(o); + auto p = ICE_DYNAMIC_CAST(PSUnknown2, o); p->pb = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(SS1, o)) { - auto s = dynamic_pointer_cast(o); + auto s = ICE_DYNAMIC_CAST(SS1, o); breakCycles(s->s); } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(SS2, o)) { - auto s = dynamic_pointer_cast(o); + auto s = ICE_DYNAMIC_CAST(SS2, o); breakCycles(s->s); } - if(dynamic_pointer_cast(o)) - { - auto s = dynamic_pointer_cast(o); - breakCycles(s->c1); - breakCycles(s->c2); - } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(Forward, o)) { - auto f = dynamic_pointer_cast(o); + auto f = ICE_DYNAMIC_CAST(Forward, o); f->h = nullptr; } - if(dynamic_pointer_cast(o)) + if(ICE_DYNAMIC_CAST(SUnknown, o)) { - auto u = dynamic_pointer_cast(o); + auto u = ICE_DYNAMIC_CAST(SUnknown, o); u->cycle = nullptr; } } -#else -template -void breakCycles(T) -{ - // no op, we rely on C++98 collection. -} - -#endif } TestI::TestI() @@ -150,12 +134,10 @@ TestI::TestI() TestI::~TestI() { -#ifdef ICE_CPP11_MAPPING for(auto e : _values) { breakCycles(e); } -#endif } Ice::ValuePtr @@ -216,11 +198,7 @@ TestI::SUnknownAsObject(const ::Ice::Current&) SUnknownPtr su = ICE_MAKE_SHARED(SUnknown); su->su = "SUnknown.su"; su->cycle = su; -#ifndef ICE_CPP11_MAPPING - su->ice_collectable(true); -#else _values.push_back(su); -#endif return su; } @@ -237,9 +215,7 @@ TestI::checkSUnknown(ICE_IN(Ice::ValuePtr) obj, const ::Ice::Current& current) test(su); test(su->su == "SUnknown.su"); } -#ifdef ICE_CPP11_MAPPING su->cycle = nullptr; -#endif } BPtr @@ -248,11 +224,7 @@ TestI::oneElementCycle(const ::Ice::Current&) BPtr b = ICE_MAKE_SHARED(B); b->sb = "B1.sb"; b->pb = b; -#ifndef ICE_CPP11_MAPPING - b->ice_collectable(true); -#else _values.push_back(b); -#endif return b; } @@ -265,11 +237,7 @@ TestI::twoElementCycle(const ::Ice::Current&) b2->sb = "B2.sb"; b2->pb = b1; b1->pb = b2; -#ifndef ICE_CPP11_MAPPING - b1->ice_collectable(true); -#else _values.push_back(b1); -#endif return b1; } @@ -286,11 +254,7 @@ TestI::D1AsB(const ::Ice::Current&) d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#else _values.push_back(d1); -#endif return d1; } @@ -307,11 +271,7 @@ TestI::D1AsD1(const ::Ice::Current&) d2->pd2 = d1; d1->pb = d2; d1->pd1 = d2; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#else _values.push_back(d1); -#endif return d1; } @@ -328,11 +288,7 @@ TestI::D2AsB(const ::Ice::Current&) d1->pd1 = d2; d2->pb = d1; d2->pd2 = d1; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#else _values.push_back(d1); -#endif return d2; } @@ -351,11 +307,7 @@ TestI::paramTest1(BPtr& p1, BPtr& p2, const ::Ice::Current&) d1->pd1 = d2; p1 = d1; p2 = d2; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#else _values.push_back(d1); -#endif } void @@ -394,12 +346,11 @@ TestI::paramTest3(BPtr& p1, BPtr& p2, const ::Ice::Current&) d3->pd1 = 0; d4->pd2 = d3; -#ifdef ICE_CPP11_MAPPING _values.push_back(d1); _values.push_back(d2); _values.push_back(d3); _values.push_back(d4); -#endif + return d3; } @@ -414,9 +365,7 @@ TestI::paramTest4(BPtr& p1, const ::Ice::Current&) d4->p2 = ICE_MAKE_SHARED(B); d4->p2->sb = "B.sb (2)"; p1 = d4; -#ifdef ICE_CPP11_MAPPING _values.push_back(d4); -#endif return d4->p2; } @@ -436,7 +385,6 @@ TestI::returnTest2(BPtr& p1, BPtr& p2, const ::Ice::Current&) return p1; } -#ifdef ICE_CPP11_MAPPING BPtr TestI::returnTest3(ICE_IN(BPtr) p1, ICE_IN(BPtr) p2, const ::Ice::Current&) { @@ -444,13 +392,6 @@ TestI::returnTest3(ICE_IN(BPtr) p1, ICE_IN(BPtr) p2, const ::Ice::Current&) _values.push_back(p2); return p1; } -#else -BPtr -TestI::returnTest3(ICE_IN(BPtr) p1, ICE_IN(BPtr), const ::Ice::Current&) -{ - return p1; -} -#endif SS3 TestI::sequenceTest(ICE_IN(SS1Ptr) p1, ICE_IN(SS2Ptr) p2, const ::Ice::Current&) @@ -458,10 +399,8 @@ TestI::sequenceTest(ICE_IN(SS1Ptr) p1, ICE_IN(SS2Ptr) p2, const ::Ice::Current&) SS3 ss; ss.c1 = p1; ss.c2 = p2; -#ifdef ICE_CPP11_MAPPING _values.push_back(p1); _values.push_back(p2); -#endif return ss; } @@ -477,11 +416,7 @@ TestI::dictionaryTest(ICE_IN(BDict) bin, BDict& bout, const ::Ice::Current&) d2->pb = b->pb; d2->sd2 = "D2"; d2->pd2 = d2; -#ifndef ICE_CPP11_MAPPING - d2->ice_collectable(true); -#else _values.push_back(d2); -#endif bout[i * 10] = d2; } BDict r; @@ -494,11 +429,7 @@ TestI::dictionaryTest(ICE_IN(BDict) bin, BDict& bout, const ::Ice::Current&) d1->pb = (i == 0 ? BPtr(0) : r.find((i - 1) * 20)->second); d1->sd1 = s.str(); d1->pd1 = d1; -#ifndef ICE_CPP11_MAPPING - d1->ice_collectable(true); -#else _values.push_back(d1); -#endif r[i * 20] = d1; } return r; @@ -507,9 +438,7 @@ TestI::dictionaryTest(ICE_IN(BDict) bin, BDict& bout, const ::Ice::Current&) Test::PBasePtr TestI::exchangePBase(ICE_IN(Test::PBasePtr) pb, const Ice::Current&) { -#ifdef ICE_CPP11_MAPPING _values.push_back(pb); -#endif return pb; } @@ -649,9 +578,7 @@ TestI::checkPBSUnknown2WithGraph(ICE_IN(Test::PreservedPtr) p, const Ice::Curren Test::PNodePtr TestI::exchangePNode(ICE_IN(Test::PNodePtr) pn, const Ice::Current&) { -#ifdef ICE_CPP11_MAPPING _values.push_back(pn); -#endif return pn; } @@ -663,11 +590,7 @@ TestI::throwBaseAsBase(const ::Ice::Current&) be.pb = ICE_MAKE_SHARED(B); be.pb->sb = "sb"; be.pb->pb = be.pb; -#ifndef ICE_CPP11_MAPPING - be.pb->ice_collectable(true); -#else _values.push_back(be.pb); -#endif throw be; } @@ -685,13 +608,8 @@ TestI::throwDerivedAsBase(const ::Ice::Current&) de.pd1->pb = de.pd1; de.pd1->sd1 = "sd2"; de.pd1->pd1 = de.pd1; -#ifndef ICE_CPP11_MAPPING - de.pb->ice_collectable(true); - de.pd1->ice_collectable(true); -#else _values.push_back(de.pb); _values.push_back(de.pd1); -#endif throw de; } @@ -709,13 +627,8 @@ TestI::throwDerivedAsDerived(const ::Ice::Current&) de.pd1->pb = de.pd1; de.pd1->sd1 = "sd2"; de.pd1->pd1 = de.pd1; -#ifndef ICE_CPP11_MAPPING - de.pb->ice_collectable(true); - de.pd1->ice_collectable(true); -#else _values.push_back(de.pb); _values.push_back(de.pd1); -#endif throw de; } @@ -727,11 +640,7 @@ TestI::throwUnknownDerivedAsBase(const ::Ice::Current&) d2->pb = d2; d2->sd2 = "sd2 d2"; d2->pd2 = d2; -#ifndef ICE_CPP11_MAPPING - d2->ice_collectable(true); -#else _values.push_back(d2); -#endif UnknownDerivedException ude; ude.sbe = "sbe"; ude.pb = d2; @@ -776,11 +685,7 @@ TestI::useForward(ForwardPtr& f, const ::Ice::Current&) f = ICE_MAKE_SHARED(Forward); f->h = ICE_MAKE_SHARED(Hidden); f->h->f = f; -#ifndef ICE_CPP11_MAPPING - f->ice_collectable(true); -#else _values.push_back(f); -#endif } void diff --git a/cpp/test/Ice/slicing/objects/TestI.h b/cpp/test/Ice/slicing/objects/TestI.h index 6e5468f7f2d..267a5b0e996 100644 --- a/cpp/test/Ice/slicing/objects/TestI.h +++ b/cpp/test/Ice/slicing/objects/TestI.h @@ -92,9 +92,7 @@ class TestI : public virtual Test::TestIntf private: -#ifdef ICE_CPP11_MAPPING - std::vector> _values; -#endif + std::vector _values; }; #endif diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp index 90a5aea33eb..3e664a2ca55 100644 --- a/cpp/test/Ice/stream/Client.cpp +++ b/cpp/test/Ice/stream/Client.cpp @@ -43,7 +43,7 @@ class TestObjectWriter : public Ice::Value MyClassPtr obj; bool called; }; -ICE_DEFINE_PTR(TestObjectWriterPtr, TestObjectWriter); +ICE_DEFINE_SHARED_PTR(TestObjectWriterPtr, TestObjectWriter); #ifdef ICE_CPP11_MAPPING class TestObjectReader : public Ice::ValueHelper @@ -73,7 +73,7 @@ class TestObjectReader : public Ice::Value MyClassPtr obj; bool called; }; -ICE_DEFINE_PTR(TestObjectReaderPtr, TestObjectReader); +ICE_DEFINE_SHARED_PTR(TestObjectReaderPtr, TestObjectReader); // Required for ValueHelper<>'s _iceReadImpl and _iceWriteIpml #ifdef ICE_CPP11_MAPPING @@ -125,7 +125,6 @@ class TestValueFactory : public Ice::ValueFactory }; #endif -#ifdef ICE_CPP11_MAPPING void patchObject(void* addr, const Ice::ValuePtr& v) { @@ -133,15 +132,6 @@ patchObject(void* addr, const Ice::ValuePtr& v) assert(p); *p = v; } -#else -void -patchObject(void* addr, const Ice::ValuePtr& v) -{ - Ice::ValuePtr* p = static_cast(addr); - assert(p); - *p = v; -} -#endif #ifdef ICE_CPP11_MAPPING class MyClassFactoryWrapper @@ -820,12 +810,6 @@ allTests(Test::TestHelper* helper) c->seq9.push_back(ICE_ENUM(MyEnum, enum1)); c->d["hi"] = c; -#ifndef ICE_CPP11_MAPPING - // - // No GC support in C++11. - // - c->ice_collectable(true); -#endif arr.push_back(c); } Ice::OutputStream out(communicator); @@ -834,9 +818,6 @@ allTests(Test::TestHelper* helper) out.finished(data); Ice::InputStream in(communicator, data); -#ifndef ICE_CPP11_MAPPING - in.setCollectObjects(true); -#endif MyClassS arr2; in.read(arr2); in.readPendingValues(); @@ -870,9 +851,6 @@ allTests(Test::TestHelper* helper) out2.finished(data); Ice::InputStream in2(communicator, data); -#ifndef ICE_CPP11_MAPPING - in2.setCollectObjects(true); -#endif MyClassSS arr2S; in2.read(arr2S); in2.readPendingValues(); @@ -1034,20 +1012,11 @@ allTests(Test::TestHelper* helper) c->seq9.push_back(ICE_ENUM(MyEnum, enum1)); ex.c = c; -#ifndef ICE_CPP11_MAPPING - // - // No GC support in C++11. - // - ex.c->ice_collectable(true); -#endif out.write(ex); out.finished(data); Ice::InputStream in(communicator, data); -#ifndef ICE_CPP11_MAPPING - in.setCollectObjects(true); -#endif try { in.throwException(); @@ -1066,15 +1035,12 @@ allTests(Test::TestHelper* helper) test(ex1.c->seq8 == c->seq8); test(ex1.c->seq9 == c->seq9); -#ifdef ICE_CPP11_MAPPING ex1.c->c = nullptr; ex1.c->o = nullptr; -#endif } -#ifdef ICE_CPP11_MAPPING + c->c = nullptr; c->o = nullptr; -#endif } { diff --git a/objective-c/src/Ice/Stream.mm b/objective-c/src/Ice/Stream.mm index 01ea24b762d..2f899e61904 100644 --- a/objective-c/src/Ice/Stream.mm +++ b/objective-c/src/Ice/Stream.mm @@ -84,7 +84,7 @@ virtual void ice_postUnmarshal() ICEValue* _obj; }; -typedef IceUtil::Handle ValueWrapperPtr; +typedef Ice::SharedPtr ValueWrapperPtr; class ReadValueBase : public IceUtil::Shared { @@ -2268,7 +2268,7 @@ -(void) reset:(BOOL)__unused clearBuffer } } --(Ice::Value*) addObject:(ICEValue*)object +-(Ice::ValuePtr) addObject:(ICEValue*)object { // // Ice::ValueWrapper is a subclass of Ice::Value that wraps an Objective-C object for marshaling. @@ -2283,13 +2283,13 @@ -(void) reset:(BOOL)__unused clearBuffer std::map::const_iterator p = objectWriters_->find(object); if(p != objectWriters_->end()) { - return p->second.get(); + return p->second; } else { IceObjC::ValueWrapperPtr writer = new IceObjC::ValueWrapper(object); objectWriters_->insert(std::make_pair(object, writer)); - return writer.get(); + return writer; } } diff --git a/php/src/Communicator.cpp b/php/src/Communicator.cpp index ae706ea58ff..61da78ae852 100644 --- a/php/src/Communicator.cpp +++ b/php/src/Communicator.cpp @@ -2026,7 +2026,9 @@ IcePHP::FactoryWrapper::create(const string& id) return 0; } - return new ValueReader(&obj, cls, _info); + // Create a temporary shared_ptr that sees enable_shared_from_this. + ValueReaderPtr result = new ValueReader(&obj, cls, _info); + return result; } void @@ -2118,7 +2120,9 @@ IcePHP::DefaultValueFactory::create(const string& id) throw AbortMarshaling(); } - return new ValueReader(&obj, cls, _info); + // Create a temporary shared_ptr that sees enable_shared_from_this. + ValueReaderPtr result = new ValueReader(&obj, cls, _info); + return result; } void diff --git a/php/src/Types.cpp b/php/src/Types.cpp index 4d82902e09e..4dc13a516d1 100644 --- a/php/src/Types.cpp +++ b/php/src/Types.cpp @@ -3168,7 +3168,7 @@ IcePHP::ValueReader::_iceRead(Ice::InputStream* is) { StreamUtil* util = reinterpret_cast(is->getClosure()); assert(util); - util->add(this); + util->add(ValueReaderPtr(shared_from_this())); // // Define the "unknownTypeId" member for an instance of UnknownSlicedObject. diff --git a/php/src/Types.h b/php/src/Types.h index e36dc394899..a6ca3b24190 100644 --- a/php/src/Types.h +++ b/php/src/Types.h @@ -45,7 +45,7 @@ typedef std::vector ClassInfoList; typedef std::map ObjectMap; class ValueReader; -typedef IceUtil::Handle ValueReaderPtr; +typedef Ice::SharedPtr ValueReaderPtr; struct PrintObjectHistory { @@ -553,7 +553,7 @@ class ValueWriter : public Ice::Value // // ValueReader unmarshals the state of an Ice value. // -class ValueReader : public Ice::Value +class ValueReader : public std::enable_shared_from_this, public Ice::Value { public: diff --git a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp index 054a638e2c2..57417f429fd 100644 --- a/python/modules/IcePy/Types.cpp +++ b/python/modules/IcePy/Types.cpp @@ -3851,7 +3851,7 @@ IcePy::ValueReader::_iceRead(Ice::InputStream* is) { StreamUtil* util = reinterpret_cast(is->getClosure()); assert(util); - util->add(this); + util->add(ValueReaderPtr(shared_from_this())); // // Define the "unknownTypeId" member for an instance of UnknownSlicedObject. diff --git a/python/modules/IcePy/Types.h b/python/modules/IcePy/Types.h index 8c4ad5a194e..2a52d2e76e3 100644 --- a/python/modules/IcePy/Types.h +++ b/python/modules/IcePy/Types.h @@ -41,7 +41,7 @@ class AbortMarshaling typedef std::map ObjectMap; class ValueReader; -typedef IceUtil::Handle ValueReaderPtr; +typedef Ice::SharedPtr ValueReaderPtr; // // The delayed nature of class unmarshaling in the Ice protocol requires us to @@ -639,7 +639,7 @@ class ValueWriter : public Ice::Value // // ValueReader unmarshals the state of an Ice object. // -class ValueReader : public Ice::Value +class ValueReader : public std::enable_shared_from_this, public Ice::Value { public: diff --git a/python/modules/IcePy/ValueFactoryManager.cpp b/python/modules/IcePy/ValueFactoryManager.cpp index 7db6e0d5527..4161a586a0d 100644 --- a/python/modules/IcePy/ValueFactoryManager.cpp +++ b/python/modules/IcePy/ValueFactoryManager.cpp @@ -232,7 +232,10 @@ IcePy::FactoryWrapper::create(const string& id) return 0; } - return new ValueReader(obj.get(), info); + // We need to create a shared_ptr that sees the enable_shared_from_this. Otherwise, shared_from_this() later on + // will fail. + ValueReaderPtr result = new ValueReader(obj.get(), info); + return result; } PyObject* @@ -300,7 +303,10 @@ IcePy::DefaultValueFactory::create(const string& id) throw AbortMarshaling(); } - return new ValueReader(obj.get(), info); + // We need to create a shared_ptr that sees the enable_shared_from_this. Otherwise, shared_from_this() later on + // will fail. + ValueReaderPtr result = new ValueReader(obj.get(), info); + return result; } void diff --git a/ruby/src/IceRuby/Types.cpp b/ruby/src/IceRuby/Types.cpp index bfc42c3d951..0d22957b35a 100644 --- a/ruby/src/IceRuby/Types.cpp +++ b/ruby/src/IceRuby/Types.cpp @@ -2666,7 +2666,7 @@ IceRuby::ValueReader::_iceRead(Ice::InputStream* is) { StreamUtil* util = reinterpret_cast(is->getClosure()); assert(util); - util->add(this); + util->add(ValueReaderPtr(shared_from_this())); // // Define the "unknownTypeId" member for an instance of UnknownSlicedValue. diff --git a/ruby/src/IceRuby/Types.h b/ruby/src/IceRuby/Types.h index 8d82d7037f8..4db4f6954b0 100644 --- a/ruby/src/IceRuby/Types.h +++ b/ruby/src/IceRuby/Types.h @@ -38,7 +38,7 @@ class AbortMarshaling typedef std::map ValueMap; class ValueReader; -typedef IceUtil::Handle ValueReaderPtr; +typedef Ice::SharedPtr ValueReaderPtr; struct PrintObjectHistory { @@ -508,7 +508,7 @@ class ValueWriter : public Ice::Value // // ValueReader unmarshals the state of an Ice object. // -class ValueReader : public Ice::Value +class ValueReader : public std::enable_shared_from_this, public Ice::Value { public: diff --git a/ruby/src/IceRuby/ValueFactoryManager.cpp b/ruby/src/IceRuby/ValueFactoryManager.cpp index 73870065f6d..d6bb6be44b3 100644 --- a/ruby/src/IceRuby/ValueFactoryManager.cpp +++ b/ruby/src/IceRuby/ValueFactoryManager.cpp @@ -268,7 +268,9 @@ IceRuby::FactoryWrapper::create(const string& id) return 0; } - return new ValueReader(obj, info); + // Create a temporary shared_ptr that sees enable_shared_from_this. + ValueReaderPtr result = new ValueReader(obj, info); + return result; } VALUE @@ -341,7 +343,10 @@ IceRuby::DefaultValueFactory::create(const string& id) // volatile VALUE obj = callRuby(rb_class_new_instance, 0, reinterpret_cast(0), info->rubyClass); assert(!NIL_P(obj)); - return new ValueReader(obj, info); + + // Create a temporary shared_ptr that sees enable_shared_from_this. + ValueReaderPtr result = new ValueReader(obj, info); + return result; } void diff --git a/scripts/Component.py b/scripts/Component.py index 3bd827e2841..0185e6d1db8 100644 --- a/scripts/Component.py +++ b/scripts/Component.py @@ -61,7 +61,6 @@ def getFilters(self, mapping, config): ["Ice/background", "Ice/echo", "Ice/faultTolerance", - "Ice/gc", "Ice/library", "Ice/logger", "Ice/properties", diff --git a/swift/Rakefile b/swift/Rakefile index a7edbc7aea9..82eb1ef39cb 100644 --- a/swift/Rakefile +++ b/swift/Rakefile @@ -157,7 +157,6 @@ def create_platform_targets(project, platform, bindist) "AsyncResult.cpp", "AsyncResult.cpp", "DLLMain.cpp", - "GCValue.cpp", "ResponseHandler.cpp", "SystemdJournal.cpp", "OpenSSL*",