summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/InterfaceByValue.h2
-rw-r--r--cpp/include/Ice/SlicedData.h2
-rw-r--r--cpp/include/Ice/Value.h36
-rw-r--r--cpp/include/IceUtil/Config.h2
-rw-r--r--cpp/src/Ice/AsyncResult.cpp2
-rw-r--r--cpp/src/Ice/Value.cpp2
-rw-r--r--cpp/src/slice2cpp/Gen.cpp47
-rw-r--r--cpp/src/slice2cpp/Gen.h2
8 files changed, 56 insertions, 39 deletions
diff --git a/cpp/include/Ice/InterfaceByValue.h b/cpp/include/Ice/InterfaceByValue.h
index 3f042bae2c1..c2be72d3eb9 100644
--- a/cpp/include/Ice/InterfaceByValue.h
+++ b/cpp/include/Ice/InterfaceByValue.h
@@ -19,7 +19,7 @@ namespace Ice
{
template<typename T>
-class InterfaceByValue : public Value
+class InterfaceByValue : public Ice::ValueHelper<Ice::InterfaceByValue<T>, Ice::Value>
{
public:
diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h
index 2956e7431f2..f104ceb15f4 100644
--- a/cpp/include/Ice/SlicedData.h
+++ b/cpp/include/Ice/SlicedData.h
@@ -79,7 +79,7 @@ public:
//
class ICE_API UnknownSlicedObject
#ifdef ICE_CPP11_MAPPING
- : public Value
+ : public ValueHelper<UnknownSlicedObject, Value>
#else
: virtual public Object, private IceInternal::GCObject
#endif
diff --git a/cpp/include/Ice/Value.h b/cpp/include/Ice/Value.h
index 8aba347abbd..9e3d0449bd1 100644
--- a/cpp/include/Ice/Value.h
+++ b/cpp/include/Ice/Value.h
@@ -40,16 +40,44 @@ public:
virtual const std::string& ice_id() const;
static const std::string& ice_staticId();
- virtual ValuePtr ice_clone() const;
+ std::shared_ptr<Value> ice_clone() const;
protected:
-
+
+ virtual std::shared_ptr<Value> cloneImpl() const = 0;
+
virtual void __writeImpl(IceInternal::BasicStream*) const {}
virtual void __readImpl(IceInternal::BasicStream*) {}
};
-ICE_API void ice_writeObject(const OutputStreamPtr&, const ValuePtr&);
-ICE_API void ice_readObject(const InputStreamPtr&, ValuePtr&);
+template<typename T, typename Base> class ValueHelper : public Base
+{
+public:
+
+ using Base::Base;
+
+ ValueHelper() = default;
+
+ std::shared_ptr<T> ice_clone() const
+ {
+ return std::static_pointer_cast<T>(cloneImpl());
+ }
+
+ virtual const std::string& ice_id() const override
+ {
+ return T::ice_staticId();
+ }
+
+protected:
+
+ virtual std::shared_ptr<Value> cloneImpl() const
+ {
+ return std::make_shared<T>(static_cast<const T&>(*this));
+ }
+};
+
+ICE_API void ice_writeObject(const OutputStreamPtr&, const std::shared_ptr<Value>&);
+ICE_API void ice_readObject(const InputStreamPtr&, std::shared_ptr<Value>&);
}
#endif // C++11 mapping end
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index 74033859774..8e75fc73f45 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -291,7 +291,7 @@ typedef long long Int64;
# define ICE_IN(T) const T&
# define ICE_EXCEPTION_GET(T) T.get()
# define ICE_RETHROW_EXCEPTION(T) T->ice_throw()
-# define ICE_RESET_EXCEPTION(T, V) = T.reset(V)
+# define ICE_RESET_EXCEPTION(T,V) T.reset(V)
#endif
#endif
diff --git a/cpp/src/Ice/AsyncResult.cpp b/cpp/src/Ice/AsyncResult.cpp
index 7387366cbed..68b0af9745e 100644
--- a/cpp/src/Ice/AsyncResult.cpp
+++ b/cpp/src/Ice/AsyncResult.cpp
@@ -441,7 +441,7 @@ AsyncResult::cancel(const Ice::LocalException& ex)
}
handler = _cancellationHandler;
}
- handler->asyncRequestCanceled(ICE_DYNAMIC_CAST(OutgoingAsyncBase, shared_from_this()), ex);
+ handler->asyncRequestCanceled(ICE_DYNAMIC_CAST(OutgoingAsyncBase, ICE_SHARED_FROM_THIS), ex);
}
void
diff --git a/cpp/src/Ice/Value.cpp b/cpp/src/Ice/Value.cpp
index 751794d1500..174a8a0857b 100644
--- a/cpp/src/Ice/Value.cpp
+++ b/cpp/src/Ice/Value.cpp
@@ -68,7 +68,7 @@ Ice::Value::ice_id() const
ValuePtr
Ice::Value::ice_clone() const
{
- return make_shared<Value>(*this);
+ return cloneImpl();
}
#endif
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 4ee33bada58..f390ce4ce13 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -7930,18 +7930,17 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p)
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
- H << sp << nl << "class " << _dllExport << name << " : ";
- H.useCurrentPosAsIndent();
+ H << sp << nl << "class " << _dllExport << name << " : public ::Ice::ValueHelper<" << name << ", ";
+
if(!base || (base && base->isInterface()))
{
- H << "public ::Ice::Value";
+ H << "Ice::Value";
}
else
{
- H << "public " << fixKwd(base->scoped());
+ H << fixKwd(base->scoped());
}
-
- H.restoreIndent();
+ H << ">";
H << sb;
H.dec();
H << nl << "public:" << sp;
@@ -7976,10 +7975,6 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p)
emitOneShotConstructor(p);
H << sp;
- H << nl << "virtual ::std::shared_ptr<::Ice::Value> ice_clone() const;";
- H << sp;
- H << nl << "const ::std::string& ice_id() const;";
- H << sp;
H << nl << "static const ::std::string& ice_staticId();";
return true;
}
@@ -7989,6 +7984,7 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
string scoped = fixKwd(p->scoped());
string scope = fixKwd(p->scope());
+ string name = fixKwd(p->name());
ClassList bases = p->bases();
ClassDefPtr base;
if(!bases.empty() && !bases.front()->isInterface())
@@ -8058,26 +8054,12 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << eb;
C << sp;
- C << nl << "::std::shared_ptr<::Ice::Value>";
- C << nl << scoped.substr(2) << "::ice_clone() const";
- C << sb;
- C << nl << "return ::std::make_shared<" << scoped << ">(*this);";
- C << eb;
-
- C << sp;
C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_staticId()";
C << sb;
C << nl << "static const ::std::string typeId = \"" << p->scoped() << "\";";
C << nl << "return typeId;";
C << eb;
- C << sp;
- C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_id() const";
- C << sb;
- C << nl << "static const ::std::string typeId = \"" << p->scoped() << "\";";
- C << nl << "return typeId;";
- C << eb;
-
C << sp << nl << "namespace";
C << nl << "{";
@@ -8172,9 +8154,9 @@ Slice::Gen::Cpp11ValueVisitor::visitOperation(const OperationPtr&)
bool
-Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p)
+Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& derived, const ClassDefPtr& base)
{
- DataMemberList allDataMembers = p->allDataMembers();
+ DataMemberList allDataMembers = base->allDataMembers();
if(allDataMembers.empty())
{
return false;
@@ -8198,8 +8180,15 @@ Slice::Gen::Cpp11ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p
}
upcall += ")";
- H << nl << fixKwd(p->scoped()) << upcall;
-
+ if(base->isLocal())
+ {
+ H << nl << fixKwd(base->scoped());
+ }
+ else
+ {
+ H << nl << "Ice::ValueHelper<" << fixKwd(derived->scoped()) << ", " << fixKwd(base->scoped()) << ">";
+ }
+ H << upcall;
return true;
}
@@ -8231,7 +8220,7 @@ Slice::Gen::Cpp11ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p)
if(!bases.empty() && !bases.front()->isInterface())
{
- if(emitVirtualBaseInitializers(bases.front()))
+ if(emitVirtualBaseInitializers(p, bases.front()))
{
if(!dataMembers.empty())
{
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index 3924ff61c19..1507f43fd77 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -446,7 +446,7 @@ private:
protected:
- bool emitVirtualBaseInitializers(const ClassDefPtr&);
+ bool emitVirtualBaseInitializers(const ClassDefPtr&, const ClassDefPtr&);
void emitOneShotConstructor(const ClassDefPtr&);
void emitDataMember(const DataMemberPtr&);