summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-05-03 20:14:31 -0400
committerBernard Normier <bernard@zeroc.com>2017-05-03 20:14:31 -0400
commit34156adcd7d7a1cc458260aabbd6b1857dab84b7 (patch)
tree7379294e035ba71def6df3131ee7edc882258505 /cpp
parentMore makefile fixes (diff)
downloadice-34156adcd7d7a1cc458260aabbd6b1857dab84b7.tar.bz2
ice-34156adcd7d7a1cc458260aabbd6b1857dab84b7.tar.xz
ice-34156adcd7d7a1cc458260aabbd6b1857dab84b7.zip
Generate alias for "delegate" in C++11 (ICE-7859)
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/FactoryTable.h12
-rw-r--r--cpp/include/Ice/InputStream.h8
-rw-r--r--cpp/include/Ice/UserExceptionFactory.h7
-rw-r--r--cpp/include/IceUtil/Config.h10
-rw-r--r--cpp/src/Ice/ConnectionI.cpp20
-rw-r--r--cpp/src/Ice/ConnectionI.h14
-rw-r--r--cpp/src/Ice/FactoryTable.cpp12
-rw-r--r--cpp/src/Ice/InputStream.cpp10
-rw-r--r--cpp/src/Ice/ValueFactoryManagerI.cpp6
-rw-r--r--cpp/src/Ice/ValueFactoryManagerI.h6
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp40
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.h2
-rw-r--r--cpp/src/slice2cpp/Gen.cpp35
13 files changed, 89 insertions, 93 deletions
diff --git a/cpp/include/Ice/FactoryTable.h b/cpp/include/Ice/FactoryTable.h
index 401d6a94e3b..010d33411d7 100644
--- a/cpp/include/Ice/FactoryTable.h
+++ b/cpp/include/Ice/FactoryTable.h
@@ -34,12 +34,12 @@ class ICE_API FactoryTable : private IceUtil::noncopyable
{
public:
- void addExceptionFactory(const ::std::string&, ICE_IN(ICE_USER_EXCEPTION_FACTORY));
- ICE_USER_EXCEPTION_FACTORY getExceptionFactory(const ::std::string&) const;
+ void addExceptionFactory(const ::std::string&, ICE_IN(ICE_DELEGATE(::Ice::UserExceptionFactory)));
+ ICE_DELEGATE(::Ice::UserExceptionFactory) getExceptionFactory(const ::std::string&) const;
void removeExceptionFactory(const ::std::string&);
- void addValueFactory(const ::std::string&, ICE_IN(ICE_VALUE_FACTORY));
- ICE_VALUE_FACTORY getValueFactory(const ::std::string&) const;
+ void addValueFactory(const ::std::string&, ICE_IN(ICE_DELEGATE(::Ice::ValueFactory)));
+ ICE_DELEGATE(::Ice::ValueFactory) getValueFactory(const ::std::string&) const;
void removeValueFactory(const ::std::string&);
void addTypeId(int, const ::std::string&);
@@ -50,11 +50,11 @@ private:
IceUtil::Mutex _m;
- typedef ::std::pair<ICE_USER_EXCEPTION_FACTORY, int> EFPair;
+ typedef ::std::pair< ICE_DELEGATE(::Ice::UserExceptionFactory), int> EFPair;
typedef ::std::map< ::std::string, EFPair> EFTable;
EFTable _eft;
- typedef ::std::pair<ICE_VALUE_FACTORY, int> VFPair;
+ typedef ::std::pair< ICE_DELEGATE(::Ice::ValueFactory), int> VFPair;
typedef ::std::map< ::std::string, VFPair> VFTable;
VFTable _vft;
diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h
index 363f41767ed..8eaf708ea0c 100644
--- a/cpp/include/Ice/InputStream.h
+++ b/cpp/include/Ice/InputStream.h
@@ -633,7 +633,7 @@ public:
Int readEnum(Int);
// Exception
- void throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY) = ICE_NULLPTR);
+ void throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory)) = ICE_NULLPTR);
// Read/write/skip optionals
void skipOptional(OptionalFormat);
@@ -721,7 +721,7 @@ private:
virtual ~EncapsDecoder();
virtual void read(PatchFunc, void*) = 0;
- virtual void throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY)) = 0;
+ virtual void throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory))) = 0;
virtual void startInstance(SliceType) = 0;
virtual SlicedDataPtr endInstance(bool) = 0;
@@ -796,7 +796,7 @@ private:
}
virtual void read(PatchFunc, void*);
- virtual void throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY));
+ virtual void throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory)));
virtual void startInstance(SliceType);
virtual SlicedDataPtr endInstance(bool);
@@ -831,7 +831,7 @@ private:
}
virtual void read(PatchFunc, void*);
- virtual void throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY));
+ virtual void throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory)));
virtual void startInstance(SliceType);
virtual SlicedDataPtr endInstance(bool);
diff --git a/cpp/include/Ice/UserExceptionFactory.h b/cpp/include/Ice/UserExceptionFactory.h
index ad47d764dfc..8f8baa4f480 100644
--- a/cpp/include/Ice/UserExceptionFactory.h
+++ b/cpp/include/Ice/UserExceptionFactory.h
@@ -16,6 +16,13 @@
#ifdef ICE_CPP11_MAPPING
+namespace Ice
+{
+
+using UserExceptionFactory = std::function<void(const std::string&)>;
+
+}
+
namespace IceInternal
{
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index 26b3441c0cc..1c95cdb3f48 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -378,10 +378,7 @@ typedef long long Int64;
# define ICE_GET_SHARED_FROM_THIS(p) p->shared_from_this()
# define ICE_CHECKED_CAST(T, ...) Ice::checkedCast<T>(__VA_ARGS__)
# define ICE_UNCHECKED_CAST(T, ...) Ice::uncheckedCast<T>(__VA_ARGS__)
-# define ICE_VALUE_FACTORY ::std::function<::std::shared_ptr<::Ice::Value>(const std::string&)>
-# define ICE_USER_EXCEPTION_FACTORY ::std::function<void(const std::string&)>
-# define ICE_CLOSE_CALLBACK ::std::function<void(const ::std::shared_ptr<::Ice::Connection>&)>
-# define ICE_HEARTBEAT_CALLBACK ::std::function<void(const ::std::shared_ptr<::Ice::Connection>&)>
+# define ICE_DELEGATE(T) T
# define ICE_IN(...) __VA_ARGS__
# define ICE_SET_EXCEPTION_FROM_CLONE(T, V) T = V
#else // C++98 mapping
@@ -399,10 +396,7 @@ typedef long long Int64;
# define ICE_GET_SHARED_FROM_THIS(p) p
# define ICE_CHECKED_CAST(T, ...) T::checkedCast(__VA_ARGS__)
# define ICE_UNCHECKED_CAST(T, ...) T::uncheckedCast(__VA_ARGS__)
-# define ICE_VALUE_FACTORY ::Ice::ValueFactoryPtr
-# define ICE_USER_EXCEPTION_FACTORY ::Ice::UserExceptionFactoryPtr
-# define ICE_CLOSE_CALLBACK ::Ice::CloseCallbackPtr
-# define ICE_HEARTBEAT_CALLBACK ::Ice::HeartbeatCallbackPtr
+# define ICE_DELEGATE(T) T##Ptr
# define ICE_IN(...) const __VA_ARGS__&
# define ICE_SET_EXCEPTION_FROM_CLONE(T, V) T.reset(V)
#endif
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index b2c04d7fb1d..55e3c48d18e 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -72,7 +72,7 @@ public:
DispatchCall(const ConnectionIPtr& connection, const ConnectionI::StartCallbackPtr& startCB,
const vector<ConnectionI::OutgoingMessage>& sentCBs, Byte compress, Int requestId,
Int invokeNum, const ServantManagerPtr& servantManager, const ObjectAdapterPtr& adapter,
- const OutgoingAsyncBasePtr& outAsync, const ICE_HEARTBEAT_CALLBACK& heartbeatCallback,
+ const OutgoingAsyncBasePtr& outAsync, const ICE_DELEGATE(HeartbeatCallback)& heartbeatCallback,
InputStream& stream) :
DispatchWorkItem(connection),
_connection(connection),
@@ -108,7 +108,7 @@ private:
const ServantManagerPtr _servantManager;
const ObjectAdapterPtr _adapter;
const OutgoingAsyncBasePtr _outAsync;
- const ICE_HEARTBEAT_CALLBACK _heartbeatCallback;
+ const ICE_DELEGATE(HeartbeatCallback) _heartbeatCallback;
InputStream _stream;
};
@@ -1064,14 +1064,14 @@ Ice::ConnectionI::end_heartbeat(const AsyncResultPtr& r)
#endif
void
-Ice::ConnectionI::setHeartbeatCallback(ICE_IN(ICE_HEARTBEAT_CALLBACK) callback)
+Ice::ConnectionI::setHeartbeatCallback(ICE_IN(ICE_DELEGATE(HeartbeatCallback)) callback)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
_heartbeatCallback = callback;
}
void
-Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_CLOSE_CALLBACK) callback)
+Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_DELEGATE(CloseCallback)) callback)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
if(_state >= StateClosed)
@@ -1082,7 +1082,7 @@ Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_CLOSE_CALLBACK) callback)
{
public:
- CallbackWorkItem(const ConnectionIPtr& connection, ICE_IN(ICE_CLOSE_CALLBACK) callback) :
+ CallbackWorkItem(const ConnectionIPtr& connection, ICE_IN(ICE_DELEGATE(CloseCallback)) callback) :
_connection(connection),
#ifdef ICE_CPP11_MAPPING
_callback(move(callback))
@@ -1100,7 +1100,7 @@ Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_CLOSE_CALLBACK) callback)
private:
const ConnectionIPtr _connection;
- const ICE_CLOSE_CALLBACK _callback;
+ const ICE_DELEGATE(CloseCallback) _callback;
};
#ifdef ICE_CPP11_MAPPING
_threadPool->dispatch(new CallbackWorkItem(ICE_SHARED_FROM_THIS, move(callback)));
@@ -1116,7 +1116,7 @@ Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_CLOSE_CALLBACK) callback)
}
void
-Ice::ConnectionI::closeCallback(const ICE_CLOSE_CALLBACK& callback)
+Ice::ConnectionI::closeCallback(const ICE_DELEGATE(CloseCallback)& callback)
{
try
{
@@ -1569,7 +1569,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
ServantManagerPtr servantManager;
ObjectAdapterPtr adapter;
OutgoingAsyncBasePtr outAsync;
- ICE_HEARTBEAT_CALLBACK heartbeatCallback;
+ ICE_DELEGATE(HeartbeatCallback) heartbeatCallback;
int dispatchCount = 0;
ThreadPoolMessage<ConnectionI> msg(current, *this);
@@ -1839,7 +1839,7 @@ void
ConnectionI::dispatch(const StartCallbackPtr& startCB, const vector<OutgoingMessage>& sentCBs,
Byte compress, Int requestId, Int invokeNum, const ServantManagerPtr& servantManager,
const ObjectAdapterPtr& adapter, const OutgoingAsyncBasePtr& outAsync,
- const ICE_HEARTBEAT_CALLBACK& heartbeatCallback, InputStream& stream)
+ const ICE_DELEGATE(HeartbeatCallback)& heartbeatCallback, InputStream& stream)
{
int dispatchedCount = 0;
@@ -3211,7 +3211,7 @@ Ice::ConnectionI::doUncompress(InputStream& compressed, InputStream& uncompresse
SocketOperation
Ice::ConnectionI::parseMessage(InputStream& stream, Int& invokeNum, Int& requestId, Byte& compress,
ServantManagerPtr& servantManager, ObjectAdapterPtr& adapter,
- OutgoingAsyncBasePtr& outAsync, ICE_HEARTBEAT_CALLBACK& heartbeatCallback,
+ OutgoingAsyncBasePtr& outAsync, ICE_DELEGATE(HeartbeatCallback)& heartbeatCallback,
int& dispatchCount)
{
assert(_state > StateNotValidated && _state < StateClosed);
diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h
index 19969700913..928cc298d00 100644
--- a/cpp/src/Ice/ConnectionI.h
+++ b/cpp/src/Ice/ConnectionI.h
@@ -192,8 +192,8 @@ public:
virtual void end_flushBatchRequests(const AsyncResultPtr&);
#endif
- virtual void setCloseCallback(ICE_IN(ICE_CLOSE_CALLBACK));
- virtual void setHeartbeatCallback(ICE_IN(ICE_HEARTBEAT_CALLBACK));
+ virtual void setCloseCallback(ICE_IN(ICE_DELEGATE(CloseCallback)));
+ virtual void setHeartbeatCallback(ICE_IN(ICE_DELEGATE(HeartbeatCallback)));
virtual void heartbeat();
@@ -254,10 +254,10 @@ public:
void dispatch(const StartCallbackPtr&, const std::vector<OutgoingMessage>&, Byte, Int, Int,
const IceInternal::ServantManagerPtr&, const ObjectAdapterPtr&,
const IceInternal::OutgoingAsyncBasePtr&,
- const ICE_HEARTBEAT_CALLBACK&, Ice::InputStream&);
+ const ICE_DELEGATE(HeartbeatCallback)&, Ice::InputStream&);
void finish(bool);
- void closeCallback(const ICE_CLOSE_CALLBACK&);
+ void closeCallback(const ICE_DELEGATE(CloseCallback)&);
virtual ~ConnectionI();
@@ -305,7 +305,7 @@ private:
IceInternal::SocketOperation parseMessage(Ice::InputStream&, Int&, Int&, Byte&,
IceInternal::ServantManagerPtr&, ObjectAdapterPtr&,
- IceInternal::OutgoingAsyncBasePtr&, ICE_HEARTBEAT_CALLBACK&, int&);
+ IceInternal::OutgoingAsyncBasePtr&, ICE_DELEGATE(HeartbeatCallback)&, int&);
void invokeAll(Ice::InputStream&, Int, Int, Byte,
const IceInternal::ServantManagerPtr&, const ObjectAdapterPtr&);
@@ -387,8 +387,8 @@ private:
bool _initialized;
bool _validated;
- ICE_CLOSE_CALLBACK _closeCallback;
- ICE_HEARTBEAT_CALLBACK _heartbeatCallback;
+ ICE_DELEGATE(CloseCallback) _closeCallback;
+ ICE_DELEGATE(HeartbeatCallback) _heartbeatCallback;
};
}
diff --git a/cpp/src/Ice/FactoryTable.cpp b/cpp/src/Ice/FactoryTable.cpp
index 36951aa0cc6..d14d55fe649 100644
--- a/cpp/src/Ice/FactoryTable.cpp
+++ b/cpp/src/Ice/FactoryTable.cpp
@@ -26,7 +26,7 @@ Ice::UserExceptionFactory::~UserExceptionFactory()
// If the factory is present already, increment its reference count.
//
void
-IceInternal::FactoryTable::addExceptionFactory(const string& t, ICE_IN(ICE_USER_EXCEPTION_FACTORY) f)
+IceInternal::FactoryTable::addExceptionFactory(const string& t, ICE_IN(ICE_DELEGATE(::Ice::UserExceptionFactory)) f)
{
IceUtil::Mutex::Lock lock(_m);
assert(f);
@@ -44,12 +44,12 @@ IceInternal::FactoryTable::addExceptionFactory(const string& t, ICE_IN(ICE_USER_
//
// Return the exception factory for a given type ID
//
-ICE_USER_EXCEPTION_FACTORY
+ICE_DELEGATE(::Ice::UserExceptionFactory)
IceInternal::FactoryTable::getExceptionFactory(const string& t) const
{
IceUtil::Mutex::Lock lock(_m);
EFTable::const_iterator i = _eft.find(t);
- return i != _eft.end() ? i->second.first : ICE_USER_EXCEPTION_FACTORY();
+ return i != _eft.end() ? i->second.first : ICE_DELEGATE(::Ice::UserExceptionFactory)();
}
//
@@ -76,7 +76,7 @@ IceInternal::FactoryTable::removeExceptionFactory(const string& t)
// Add a factory to the value factory table.
//
void
-IceInternal::FactoryTable::addValueFactory(const string& t, ICE_IN(ICE_VALUE_FACTORY) f)
+IceInternal::FactoryTable::addValueFactory(const string& t, ICE_IN(ICE_DELEGATE(::Ice::ValueFactory)) f)
{
IceUtil::Mutex::Lock lock(_m);
assert(f);
@@ -94,12 +94,12 @@ IceInternal::FactoryTable::addValueFactory(const string& t, ICE_IN(ICE_VALUE_FAC
//
// Return the value factory for a given type ID
//
-ICE_VALUE_FACTORY
+ICE_DELEGATE(::Ice::ValueFactory)
IceInternal::FactoryTable::getValueFactory(const string& t) const
{
IceUtil::Mutex::Lock lock(_m);
VFTable::const_iterator i = _vft.find(t);
- return i != _vft.end() ? i->second.first : ICE_VALUE_FACTORY();
+ return i != _vft.end() ? i->second.first : ICE_DELEGATE(::Ice::ValueFactory)();
}
//
diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp
index 61f71c7b5ba..0dc57a742ac 100644
--- a/cpp/src/Ice/InputStream.cpp
+++ b/cpp/src/Ice/InputStream.cpp
@@ -1437,7 +1437,7 @@ Ice::InputStream::readEnum(Int maxValue)
}
void
-Ice::InputStream::throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY) factory)
+Ice::InputStream::throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory)) factory)
{
initEncaps();
_currentEncaps->decoder->throwException(factory);
@@ -1998,7 +1998,7 @@ Ice::InputStream::EncapsDecoder10::read(PatchFunc patchFunc, void* patchAddr)
}
void
-Ice::InputStream::EncapsDecoder10::throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY) factory)
+Ice::InputStream::EncapsDecoder10::throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory)) factory)
{
assert(_sliceType == NoSlice);
@@ -2020,7 +2020,7 @@ Ice::InputStream::EncapsDecoder10::throwException(ICE_IN(ICE_USER_EXCEPTION_FACT
//
startSlice();
const string mostDerivedId = _typeId;
- ICE_USER_EXCEPTION_FACTORY exceptionFactory = factory;
+ ICE_DELEGATE(UserExceptionFactory) exceptionFactory = factory;
while(true)
{
//
@@ -2328,7 +2328,7 @@ Ice::InputStream::EncapsDecoder11::read(PatchFunc patchFunc, void* patchAddr)
}
void
-Ice::InputStream::EncapsDecoder11::throwException(ICE_IN(ICE_USER_EXCEPTION_FACTORY) factory)
+Ice::InputStream::EncapsDecoder11::throwException(ICE_IN(ICE_DELEGATE(UserExceptionFactory)) factory)
{
assert(!_current);
@@ -2339,7 +2339,7 @@ Ice::InputStream::EncapsDecoder11::throwException(ICE_IN(ICE_USER_EXCEPTION_FACT
//
startSlice();
const string mostDerivedId = _current->typeId;
- ICE_USER_EXCEPTION_FACTORY exceptionFactory = factory;
+ ICE_DELEGATE(UserExceptionFactory) exceptionFactory = factory;
while(true)
{
//
diff --git a/cpp/src/Ice/ValueFactoryManagerI.cpp b/cpp/src/Ice/ValueFactoryManagerI.cpp
index 27f04ff1e5a..cded3c2b045 100644
--- a/cpp/src/Ice/ValueFactoryManagerI.cpp
+++ b/cpp/src/Ice/ValueFactoryManagerI.cpp
@@ -16,7 +16,7 @@ using namespace Ice;
using namespace IceInternal;
void
-IceInternal::ValueFactoryManagerI::add(ICE_IN(ICE_VALUE_FACTORY) factory, const string& id)
+IceInternal::ValueFactoryManagerI::add(ICE_IN(ICE_DELEGATE(ValueFactory)) factory, const string& id)
{
IceUtil::Mutex::Lock sync(*this);
@@ -29,10 +29,10 @@ IceInternal::ValueFactoryManagerI::add(ICE_IN(ICE_VALUE_FACTORY) factory, const
throw ex;
}
- _factoryMapHint = _factoryMap.insert(_factoryMapHint, pair<const string, ICE_VALUE_FACTORY>(id, factory));
+ _factoryMapHint = _factoryMap.insert(_factoryMapHint, pair<const string, ICE_DELEGATE(ValueFactory)>(id, factory));
}
-ICE_VALUE_FACTORY
+ICE_DELEGATE(ValueFactory)
IceInternal::ValueFactoryManagerI::find(const string& id) const
{
IceUtil::Mutex::Lock sync(*this);
diff --git a/cpp/src/Ice/ValueFactoryManagerI.h b/cpp/src/Ice/ValueFactoryManagerI.h
index 748ab9de035..9bc79df6a53 100644
--- a/cpp/src/Ice/ValueFactoryManagerI.h
+++ b/cpp/src/Ice/ValueFactoryManagerI.h
@@ -26,12 +26,12 @@ public:
ValueFactoryManagerI();
- virtual void add(ICE_IN(ICE_VALUE_FACTORY), const std::string&);
- virtual ICE_VALUE_FACTORY find(const std::string&) const;
+ virtual void add(ICE_IN(ICE_DELEGATE(::Ice::ValueFactory)), const std::string&);
+ virtual ICE_DELEGATE(::Ice::ValueFactory) find(const std::string&) const;
private:
- typedef std::map<std::string, ICE_VALUE_FACTORY> FactoryMap;
+ typedef std::map<std::string, ICE_DELEGATE(::Ice::ValueFactory)> FactoryMap;
FactoryMap _factoryMap;
mutable FactoryMap::iterator _factoryMapHint;
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 30f184c17d4..a6e0408189f 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -697,11 +697,11 @@ Slice::typeToString(const TypePtr& type, const StringList& metaData, int typeCtx
{
if(cl->definition() && cl->definition()->isDelegate())
{
- return classDefToDelegateString(cl->definition());
+ return fixKwd(cl->scoped());
}
else if(cl->isInterface() && !cl->isLocal())
{
- return "std::shared_ptr<::Ice::Value>";
+ return "::std::shared_ptr<::Ice::Value>";
}
else
{
@@ -886,7 +886,7 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m
{
if(cl->definition() && cl->definition()->isDelegate())
{
- return classDefToDelegateString(cl->definition(), typeCtx);
+ return fixKwd(cl->scoped());
}
else if(cl->isInterface() && !cl->isLocal())
{
@@ -1047,7 +1047,7 @@ Slice::outputTypeToString(const TypePtr& type, bool optional, const StringList&
{
if(cl->definition() && cl->definition()->isDelegate())
{
- return classDefToDelegateString(cl->definition(), typeCtx) + "&";
+ return fixKwd(cl->scoped()) + "&";
}
else if(cl->isInterface() && !cl->isLocal())
{
@@ -1800,35 +1800,3 @@ Slice::getDataMemberRef(const DataMemberPtr& p)
return "(*" + name + ")";
}
}
-
-string
-Slice::classDefToDelegateString(const ClassDefPtr& cl, int typeCtx)
-{
- assert(cl->isDelegate());
-
- // A delegate only has one operation
- OperationPtr op = cl->allOperations().front();
-
- TypePtr ret = op->returnType();
- string retS = returnTypeToString(ret, op->returnIsOptional(), op->getMetaData(), typeCtx);
-
- string t = "::std::function<" + retS + "(";
-
- ParamDeclList paramList = cl->allOperations().front()->parameters();
- for(ParamDeclList::iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if((*q)->isOutParam())
- {
- t += outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), typeCtx);
- }
- else
- {
- t += inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), typeCtx);
- }
-
- t += distance(q, paramList.end()) == 1 ? "" : ", ";
- }
-
- t += ")>";
- return t;
-}
diff --git a/cpp/src/Slice/CPlusPlusUtil.h b/cpp/src/Slice/CPlusPlusUtil.h
index a82fb9ead3d..c018c74996d 100644
--- a/cpp/src/Slice/CPlusPlusUtil.h
+++ b/cpp/src/Slice/CPlusPlusUtil.h
@@ -71,8 +71,6 @@ std::string findMetaData(const StringList&, int = 0);
bool inWstringModule(const SequencePtr&);
std::string getDataMemberRef(const DataMemberPtr&);
-
-std::string classDefToDelegateString(const ClassDefPtr&, int = 0);
}
#endif
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 8b1ebf320ee..e096ae39e1e 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -6408,12 +6408,41 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
{
return false;
}
+
+ string name = fixKwd(p->name());
+
if(p->isDelegate())
{
+ int typeCtx = _useWstring | TypeContextLocal | TypeContextCpp11;
+
+ // Generate alias
+ H << sp << nl << "using " << name << " = ";
+
+ // A delegate only has one operation
+ OperationPtr op = p->allOperations().front();
+ TypePtr ret = op->returnType();
+ string retS = returnTypeToString(ret, op->returnIsOptional(), op->getMetaData(), typeCtx);
+
+ H << "::std::function<" << retS << "(";
+
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::iterator q = paramList.begin(); q != paramList.end(); ++q)
+ {
+ if((*q)->isOutParam())
+ {
+ H << outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), typeCtx);
+ }
+ else
+ {
+ H << inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), typeCtx);
+ }
+ H << (IceUtilInternal::distance(q, paramList.end()) == 1 ? "" : ", ");
+ }
+ H << ")>;";
+
return false;
}
- string name = fixKwd(p->name());
string scope = fixKwd(p->scope());
string scoped = fixKwd(p->scoped());
ClassList bases = p->bases();
@@ -6434,7 +6463,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
bool virtualInheritance = p->isInterface();
while(q != bases.end())
{
- H << "public ";
+ H << "public ";
if(virtualInheritance || (*q)->isInterface())
{
H << "virtual ";
@@ -6589,7 +6618,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitOperation(const OperationPtr& p)
int typeCtx = _useWstring | TypeContextLocal | TypeContextCpp11;
TypePtr ret = p->returnType();
string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(),
- typeCtx | TypeContextCpp11);
+ typeCtx);
string params = "(";
string paramsDecl = "(";