Skip to content

Commit

Permalink
Make Ice::Value the base class for mapped classes with the Original C…
Browse files Browse the repository at this point in the history
…++ mapping (#1650)
  • Loading branch information
bernardnormier authored Jan 9, 2024
1 parent 8483400 commit cbff64e
Show file tree
Hide file tree
Showing 87 changed files with 842 additions and 1,152 deletions.
2 changes: 1 addition & 1 deletion config/Make.project.rules
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ endef
define create-translator-project
$1_programs := $(notdir $1)
$1_dependencies := Slice IceUtil
$1_cppflags := -I$1 -std=c++17
$1_cppflags := -I$1
$1_targetdir := $(call bindir,$1)

#
Expand Down
5 changes: 4 additions & 1 deletion cpp/config/Make.rules
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ifeq ($(os),Darwin)
include $(lang_srcdir)/config/Make.xcodesdk.rules
endif

# We assume Make.rules.$(os) defines cppflags.
cppflags += -std=c++17

# Validate platforms and configs
$(eval $(call validate-config))

Expand Down Expand Up @@ -122,7 +125,7 @@ endif
# the cpp11 name to the target directory if building outside the build
# directory.
#
cpp11_cppflags = -DICE_CPP11_MAPPING -std=c++17
cpp11_cppflags = -DICE_CPP11_MAPPING
cpp11_ldflags = $(cpp11_cppflags)
cpp11_targetname = $(if $(or $(filter-out $($1_target),program),$(filter $(bindir)%,$($4_targetdir))),++11)
cpp11_targetdir = $(if $(filter %/build,$5),cpp11)
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <Ice/Comparable.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/GCObject.h>
#include <Ice/GCValue.h>
#include <Ice/Value.h>
#include <Ice/Incoming.h>
#include <Ice/IncomingAsync.h>
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/Ice/DefaultValueFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class DefaultValueFactory : public Ice::ValueFactory
}

#ifndef NDEBUG
virtual ::Ice::ObjectPtr create(const ::std::string& typeId)
virtual ::Ice::ValuePtr create(const ::std::string& typeId)
#else
virtual ::Ice::ObjectPtr create(const ::std::string&)
virtual ::Ice::ValuePtr create(const ::std::string&)
#endif
{
assert(typeId == _typeId);
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/Ice/GCObject.h → cpp/include/Ice/GCValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

#ifndef ICE_CPP11_MAPPING

#include <Ice/Object.h>
#include <Ice/Value.h>

#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/Mutex.h>

namespace IceInternal
{

class GCObject;
class GCValue;

class GCVisitor
{
Expand All @@ -25,10 +25,10 @@ class GCVisitor
{
}

virtual bool visit(GCObject*) = 0;
virtual bool visit(GCValue*) = 0;
};

class ICE_API GCObject : public virtual Ice::Object
class ICE_API GCValue : public virtual Ice::Value
{
public:

Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/Handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// "Handle" or "smart pointer" template for classes derived from
// IceInternal::GCShared, IceUtil::Shared, or IceUtil::SimpleShared.
//
// In constrast to IceUtil::Handle, IceInternal::Handle<T> can be used
// In contrast to IceUtil::Handle, IceInternal::Handle<T> can be used
// for a type T that has been declared but not defined. The only
// requirement is a declaration of the following function:
//
Expand Down
1 change: 0 additions & 1 deletion cpp/include/Ice/Ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
# include <Ice/NativePropertiesAdmin.h>
# include <Ice/Instrumentation.h>
# include <Ice/RegisterPlugins.h>
# include <Ice/InterfaceByValue.h>
# include <Ice/StringConverter.h>
# include <Ice/IconvStringConverter.h>
# include <Ice/UUID.h>
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ patchHandle(void* addr, const ValuePtr& v)
}
#else
IceInternal::Handle<T>* p = static_cast<IceInternal::Handle<T>*>(addr);
_icePatchObjectPtr(*p, v); // Generated _icePatchObjectPtr function, necessary for forward declarations.
_icePatchValuePtr(*p, v); // Generated _icePatchValuePtr function, necessary for forward declarations.
#endif
}
/// \endcond
Expand Down
57 changes: 0 additions & 57 deletions cpp/include/Ice/InterfaceByValue.h

This file was deleted.

104 changes: 5 additions & 99 deletions cpp/include/Ice/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@
#include <Ice/Current.h>
#include <Ice/Format.h>

namespace Ice
{

class OutputStream;
class InputStream;

}

namespace IceInternal
{

class Incoming;
class Direct;
class GCVisitor;

}

Expand Down Expand Up @@ -189,7 +180,7 @@ class ICE_API Object
* The base class for servants.
* \headerfile Ice/Ice.h
*/
class ICE_API Object : public virtual IceUtil::Shared
class ICE_API Object : public virtual IceUtil::Shared
{
public:

Expand Down Expand Up @@ -239,80 +230,12 @@ class ICE_API Object : public virtual IceUtil::Shared
bool _iceD_ice_id(IceInternal::Incoming&, const Current&);
/// \endcond

/**
* Returns the Freeze metadata attributes for an operation.
*
* @param operation The name of the operation.
* @return The least significant bit indicates whether the operation is a read
* or write operation. If the bit is set, the operation is a write operation.
* The expression ice_operationAttributes("op") &amp; 0x1 is true if
* the operation has a <code>["freeze:write"]</code> metadata directive.
* <p>
* The second and third least significant bit indicate the transactional mode
* of the operation. The expression <code>ice_operationAttributes("op") &amp; 0x6 &gt;&gt; 1</code>
* indicates the transactional mode as follows:
* <dl>
* <dt>0</dt>
* <dd><code>["freeze:read:supports"]</code></dd>
* <dt>1</dt>
* <dd><code>["freeze:read:mandatory"]</code> or <code>["freeze:write:mandatory"]</code></dd>
* <dt>2</dt>
* <dd><code>["freeze:read:required"]</code> or <code>["freeze:write:required"]</code></dd>
* <dt>3</dt>
* <dd><code>["freeze:read:never"]</code></dd>
* </dl>
*
* Refer to the Freeze manual for more information on the TransactionalEvictor.
*/
virtual Int ice_operationAttributes(const std::string& operation) const;

/// \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.
*/
virtual void ice_preMarshal();

/**
* The Ice run time invokes this method vafter unmarshaling an object's data members. This allows a
* subclass to override this method in order to perform additional initialization.
*/
virtual void ice_postUnmarshal();

/**
* Obtains the Slice type ID of this type.
* @return The return value is always "::Ice::Object".
*/
static const std::string& ice_staticId();

/**
* Returns a shallow copy of the object.
* @return The cloned object.
*/
virtual ObjectPtr ice_clone() const;

/**
* Obtains the sliced data associated with this instance.
* @return The sliced data if the value has a preserved-slice base class and has been sliced during
* unmarshaling of the value, nil otherwise.
*/
virtual SlicedDataPtr ice_getSlicedData() const;

/**
* Dispatches an invocation to a servant. This method is used by dispatch interceptors to forward an invocation
* to a servant (or to another interceptor).
Expand All @@ -326,28 +249,11 @@ class ICE_API Object : public virtual IceUtil::Shared
virtual bool _iceDispatch(IceInternal::Incoming&, const Current&);
/// \endcond

protected:
protected:

Object() {} // This class is abstract.
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-copy-dtor"
#endif
virtual ~Object() {}
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

protected:

/// \cond STREAM
virtual void _iceWriteImpl(Ice::OutputStream*) const {}
virtual void _iceReadImpl(Ice::InputStream*) {}
/// \endcond

/// \cond INTERNAL
static void _iceCheckMode(OperationMode, OperationMode);
/// \endcond
/// \cond INTERNAL
static void _iceCheckMode(OperationMode, OperationMode);
/// \endcond
};
#endif

Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/ObjectAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <Ice/Comparable.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/GCObject.h>
#include <Ice/GCValue.h>
#include <Ice/Value.h>
#include <Ice/Incoming.h>
#include <Ice/IncomingAsync.h>
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/Ice/ObjectF.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ using ObjectPtr = ::std::shared_ptr<Object>;
#else
ICE_API Object* upCast(Object*);
typedef IceInternal::Handle<Object> ObjectPtr;
typedef ObjectPtr ValuePtr;
/// \cond INTERNAL
ICE_API void _icePatchObjectPtr(ObjectPtr&, const ObjectPtr&);
ICE_API void _icePatchValuePtr(ObjectPtr&, const ObjectPtr&);
/// \endcond
#endif

Expand Down
14 changes: 10 additions & 4 deletions cpp/include/Ice/OutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@

#include <Ice/CommunicatorF.h>
#include <Ice/InstanceF.h>
#include <Ice/Object.h>
#include <Ice/ValueF.h>

// TODO: temporary
#ifdef ICE_CPP11_MAPPING
# include <Ice/ValueF.h>
#else
# include <Ice/Value.h>
#endif

#include <Ice/ProxyF.h>
#include <Ice/Buffer.h>
#include <Ice/Protocol.h>
Expand Down Expand Up @@ -794,7 +800,7 @@ class ICE_API OutputStream : public IceInternal::Buffer
* Writes a value instance to the stream.
* @param v The value to be written.
*/
void write(const ObjectPtr& v)
void write(const ValuePtr& v)
{
initEncaps();
_currentEncaps->encoder->write(v);
Expand All @@ -806,7 +812,7 @@ class ICE_API OutputStream : public IceInternal::Buffer
*/
template<typename T> void write(const IceInternal::Handle<T>& v)
{
write(ObjectPtr(upCast(v.get())));
write(ValuePtr(upCast(v.get())));
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <Ice/Comparable.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/GCObject.h>
#include <Ice/GCValue.h>
#include <Ice/Value.h>
#include <Ice/Incoming.h>
#include <Ice/FactoryTableInit.h>
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/PropertiesF.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ typedef ::IceInternal::Handle< PropertiesAdmin> PropertiesAdminPtr;
typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::PropertiesAdmin> PropertiesAdminPrx;
typedef PropertiesAdminPrx PropertiesAdminPrxPtr;
/// \cond INTERNAL
ICE_API void _icePatchObjectPtr(PropertiesAdminPtr&, const ObjectPtr&);
ICE_API void _icePatchValuePtr(PropertiesAdminPtr&, const ObjectPtr&);
/// \endcond

}
Expand Down
Loading

0 comments on commit cbff64e

Please sign in to comment.