diff options
author | Jose <jose@zeroc.com> | 2015-12-09 23:09:20 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2015-12-09 23:09:20 +0100 |
commit | a00673a2c1d9634102f91b7c6ebdd453d55a708f (patch) | |
tree | 2097f43ff5a1516b353ed0e88cc7b4174a518a17 /cpp/src | |
parent | Windows build fixes (diff) | |
download | ice-a00673a2c1d9634102f91b7c6ebdd453d55a708f.tar.bz2 ice-a00673a2c1d9634102f91b7c6ebdd453d55a708f.tar.xz ice-a00673a2c1d9634102f91b7c6ebdd453d55a708f.zip |
C++11 mapping server side input parameter fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerAdminI.cpp | 36 | ||||
-rw-r--r-- | cpp/src/Ice/MetricsAdminI.cpp | 20 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesAdminI.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesAdminI.h | 13 | ||||
-rw-r--r-- | cpp/src/IceDiscovery/LocatorI.cpp | 28 | ||||
-rw-r--r-- | cpp/src/IceDiscovery/LocatorI.h | 27 | ||||
-rw-r--r-- | cpp/src/IceDiscovery/LookupI.cpp | 34 | ||||
-rw-r--r-- | cpp/src/IceDiscovery/LookupI.h | 24 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 199 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 19 |
13 files changed, 329 insertions, 95 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 4952c61d152..e94431d3a2d 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1951,7 +1951,11 @@ IceInternal::ProcessI::shutdown(const Current&) } void +#ifdef ICE_CPP11_MAPPING +IceInternal::ProcessI::writeMessage(string message, Int fd, const Current&) +#else IceInternal::ProcessI::writeMessage(const string& message, Int fd, const Current&) +#endif { switch(fd) { diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 2f352cc61dd..05b235c303b 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -212,7 +212,11 @@ public: ProcessI(const Ice::CommunicatorPtr&); virtual void shutdown(const Ice::Current&); +#ifdef ICE_CPP11_MAPPING + virtual void writeMessage(std::string, Ice::Int, const Ice::Current&); +#else virtual void writeMessage(const std::string&, Ice::Int, const Ice::Current&); +#endif private: diff --git a/cpp/src/Ice/LoggerAdminI.cpp b/cpp/src/Ice/LoggerAdminI.cpp index 64c68dee606..86b820f27eb 100644 --- a/cpp/src/Ice/LoggerAdminI.cpp +++ b/cpp/src/Ice/LoggerAdminI.cpp @@ -33,12 +33,21 @@ public: LoggerAdminI(const PropertiesPtr&); - virtual void attachRemoteLogger(const RemoteLoggerPrxPtr&, const LogMessageTypeSeq&, +#ifdef ICE_CPP11_MAPPING + virtual void attachRemoteLogger(shared_ptr<RemoteLoggerPrx>, LogMessageTypeSeq, + StringSeq, Int, const Current&); + + virtual bool detachRemoteLogger(shared_ptr<RemoteLoggerPrx>, const Current&); + + virtual LogMessageSeq getLog(LogMessageTypeSeq, StringSeq, Int, string&, const Current&); +#else + virtual void attachRemoteLogger(const RemoteLoggerPrx&, const LogMessageTypeSeq&, const StringSeq&, Int, const Current&); - virtual bool detachRemoteLogger(const RemoteLoggerPrxPtr&, const Current&); + virtual bool detachRemoteLogger(const RemoteLoggerPrx&, const Current&); virtual LogMessageSeq getLog(const LogMessageTypeSeq&, const StringSeq&, Int, string&, const Current&); +#endif void destroy(); @@ -324,11 +333,19 @@ LoggerAdminI::LoggerAdminI(const PropertiesPtr& props) : } void -LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrxPtr& prx, +#ifdef ICE_CPP11_MAPPING +LoggerAdminI::attachRemoteLogger(shared_ptr<RemoteLoggerPrx> prx, + LogMessageTypeSeq messageTypes, + StringSeq categories, + Int messageMax, + const Current& current) +#else +LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx, const LogMessageTypeSeq& messageTypes, const StringSeq& categories, Int messageMax, const Current& current) +#endif { if(!prx) { @@ -438,7 +455,11 @@ LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrxPtr& prx, } bool -LoggerAdminI::detachRemoteLogger(const RemoteLoggerPrxPtr& remoteLogger, const Current& current) +#ifdef ICE_CPP11_MAPPING +LoggerAdminI::detachRemoteLogger(shared_ptr<RemoteLoggerPrx> remoteLogger, const Current& current) +#else +LoggerAdminI::detachRemoteLogger(const RemoteLoggerPrx& remoteLogger, const Current& current) +#endif { if(remoteLogger == 0) { @@ -467,8 +488,13 @@ LoggerAdminI::detachRemoteLogger(const RemoteLoggerPrxPtr& remoteLogger, const C } LogMessageSeq -LoggerAdminI::getLog(const LogMessageTypeSeq& messageTypes, const StringSeq& categories, +#ifdef ICE_CPP11_MAPPING +LoggerAdminI::getLog(LogMessageTypeSeq messageTypes, StringSeq categories, + Int messageMax, string& prefix, const Current& current) +#else +LoggerAdminI::getLog(LogMessageTypeSeq messageTypes, StringSeq categories, Int messageMax, string& prefix, const Current& current) +#endif { LogMessageSeq logMessages; { diff --git a/cpp/src/Ice/MetricsAdminI.cpp b/cpp/src/Ice/MetricsAdminI.cpp index a80e1a7c3ab..0fa85ff3c4f 100644 --- a/cpp/src/Ice/MetricsAdminI.cpp +++ b/cpp/src/Ice/MetricsAdminI.cpp @@ -529,7 +529,11 @@ MetricsAdminI::getMetricsViewNames(Ice::StringSeq& disabledViews, const Current& } void +#ifdef ICE_CPP11_MAPPING +MetricsAdminI::enableMetricsView(string viewName, const Current&) +#else MetricsAdminI::enableMetricsView(const string& viewName, const Current&) +#endif { { Lock sync(*this); @@ -540,7 +544,11 @@ MetricsAdminI::enableMetricsView(const string& viewName, const Current&) } void +#ifdef ICE_CPP11_MAPPING +MetricsAdminI::disableMetricsView(string viewName, const Current&) +#else MetricsAdminI::disableMetricsView(const string& viewName, const Current&) +#endif { { Lock sync(*this); @@ -551,7 +559,11 @@ MetricsAdminI::disableMetricsView(const string& viewName, const Current&) } MetricsView +#ifdef ICE_CPP11_MAPPING +MetricsAdminI::getMetricsView(string viewName, ::Ice::Long& timestamp, const Current&) +#else MetricsAdminI::getMetricsView(const string& viewName, ::Ice::Long& timestamp, const Current&) +#endif { Lock sync(*this); MetricsViewIPtr view = getMetricsView(viewName); @@ -564,7 +576,11 @@ MetricsAdminI::getMetricsView(const string& viewName, ::Ice::Long& timestamp, co } MetricsFailuresSeq +#ifdef ICE_CPP11_MAPPING +MetricsAdminI::getMapMetricsFailures(string viewName, string map, const Current&) +#else MetricsAdminI::getMapMetricsFailures(const string& viewName, const string& map, const Current&) +#endif { Lock sync(*this); MetricsViewIPtr view = getMetricsView(viewName); @@ -576,7 +592,11 @@ MetricsAdminI::getMapMetricsFailures(const string& viewName, const string& map, } MetricsFailures +#ifdef ICE_CPP11_MAPPING +MetricsAdminI::getMetricsFailures(string viewName, string map, string id, const Current&) +#else MetricsAdminI::getMetricsFailures(const string& viewName, const string& map, const string& id, const Current&) +#endif { Lock sync(*this); MetricsViewIPtr view = getMetricsView(viewName); diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 14086c0d81b..24ba8ea42b7 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -96,7 +96,11 @@ Ice::Object::___ice_isA(Incoming& __inS, const Current& __current) string __id; __is->read(__id, false); __inS.endReadParams(); +#ifdef ICE_CPP11_MAPPING + bool __ret = ice_isA(move(__id), __current); +#else bool __ret = ice_isA(__id, __current); +#endif BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(__ret); __inS.__endWriteParams(true); diff --git a/cpp/src/Ice/PropertiesAdminI.cpp b/cpp/src/Ice/PropertiesAdminI.cpp index 4cd90f614ba..bcf0370c245 100644 --- a/cpp/src/Ice/PropertiesAdminI.cpp +++ b/cpp/src/Ice/PropertiesAdminI.cpp @@ -30,14 +30,22 @@ PropertiesAdminI::PropertiesAdminI(const PropertiesPtr& properties, const Logger } string +#ifdef ICE_CPP11_MAPPING +PropertiesAdminI::getProperty(string name, const Current&) +#else PropertiesAdminI::getProperty(const string& name, const Current&) +#endif { Lock sync(*this); return _properties->getProperty(name); } PropertyDict +#ifdef ICE_CPP11_MAPPING +PropertiesAdminI::getPropertiesForPrefix(string prefix, const Current&) +#else PropertiesAdminI::getPropertiesForPrefix(const string& prefix, const Current&) +#endif { Lock sync(*this); return _properties->getPropertiesForPrefix(prefix); @@ -45,9 +53,9 @@ PropertiesAdminI::getPropertiesForPrefix(const string& prefix, const Current&) void #ifdef ICE_CPP11_MAPPING -PropertiesAdminI::setProperties_async(const PropertyDict& props, +PropertiesAdminI::setProperties_async(PropertyDict props, function<void ()> response, - function<void (const ::std::exception_ptr&)>, + function<void (exception_ptr)>, const Current&) #else PropertiesAdminI::setProperties_async(const AMD_PropertiesAdmin_setPropertiesPtr& cb, const PropertyDict& props, diff --git a/cpp/src/Ice/PropertiesAdminI.h b/cpp/src/Ice/PropertiesAdminI.h index 789a6aee6d5..4f23521e399 100644 --- a/cpp/src/Ice/PropertiesAdminI.h +++ b/cpp/src/Ice/PropertiesAdminI.h @@ -25,13 +25,16 @@ public: PropertiesAdminI(const Ice::PropertiesPtr&, const Ice::LoggerPtr&); - virtual std::string getProperty(const std::string&, const Ice::Current&); - virtual Ice::PropertyDict getPropertiesForPrefix(const std::string&, const Ice::Current&); - #ifdef ICE_CPP11_MAPPING - virtual void setProperties_async(const ::Ice::PropertyDict&, ::std::function<void ()>, - ::std::function<void (const ::std::exception_ptr&)>, const Ice::Current&); + virtual std::string getProperty(std::string, const Ice::Current&); + virtual Ice::PropertyDict getPropertiesForPrefix(std::string, const Ice::Current&); + virtual void setProperties_async(::Ice::PropertyDict, + ::std::function<void ()>, + ::std::function<void (::std::exception_ptr)>, + const Ice::Current&); #else + virtual std::string getProperty(const std::string&, const Ice::Current&); + virtual Ice::PropertyDict getPropertiesForPrefix(const std::string&, const Ice::Current&); virtual void setProperties_async(const Ice::AMD_PropertiesAdmin_setPropertiesPtr&, const Ice::PropertyDict&, const Ice::Current&); #endif diff --git a/cpp/src/IceDiscovery/LocatorI.cpp b/cpp/src/IceDiscovery/LocatorI.cpp index fe7b6122115..cc7fbc70ef2 100644 --- a/cpp/src/IceDiscovery/LocatorI.cpp +++ b/cpp/src/IceDiscovery/LocatorI.cpp @@ -26,10 +26,10 @@ LocatorRegistryI::LocatorRegistryI(const Ice::CommunicatorPtr& com) : #ifdef ICE_CPP11_MAPPING void -LocatorRegistryI::setAdapterDirectProxy_async(const string& adapterId, - const shared_ptr<ObjectPrx>& proxy, +LocatorRegistryI::setAdapterDirectProxy_async(string adapterId, + shared_ptr<ObjectPrx> proxy, function<void ()> response, - function<void (const exception_ptr&)>, + function<void (exception_ptr)>, const Ice::Current&) #else void @@ -57,11 +57,11 @@ LocatorRegistryI::setAdapterDirectProxy_async(const AMD_LocatorRegistry_setAdapt #ifdef ICE_CPP11_MAPPING void -LocatorRegistryI::setReplicatedAdapterDirectProxy_async(const string& adapterId, - const string& replicaGroupId, - const shared_ptr<ObjectPrx>& proxy, +LocatorRegistryI::setReplicatedAdapterDirectProxy_async(string adapterId, + string replicaGroupId, + shared_ptr<ObjectPrx> proxy, function<void ()> response, - function<void (const exception_ptr&)>, + function<void (exception_ptr)>, const Ice::Current&) #else void @@ -106,10 +106,10 @@ LocatorRegistryI::setReplicatedAdapterDirectProxy_async( #ifdef ICE_CPP11_MAPPING void -LocatorRegistryI::setServerProcessProxy_async(const string&, - const shared_ptr<ProcessPrx>&, +LocatorRegistryI::setServerProcessProxy_async(string, + shared_ptr<ProcessPrx>, function<void ()> response, - function<void (const exception_ptr&)>, + function<void (exception_ptr)>, const Ice::Current&) { response(); @@ -226,18 +226,18 @@ LocatorI::LocatorI(const LookupIPtr& lookup, const LocatorRegistryPrxPtr& regist #ifdef ICE_CPP11_MAPPING void -LocatorI::findObjectById_async(const Ice::Identity& id, +LocatorI::findObjectById_async(Ice::Identity id, function<void (const shared_ptr<ObjectPrx>&)> response, - function<void (const exception_ptr&)>, + function<void (exception_ptr)>, const Ice::Current&) const { _lookup->findObject(response, id); } void -LocatorI::findAdapterById_async(const std::string& adapterId, +LocatorI::findAdapterById_async(string adapterId, function<void (const shared_ptr<ObjectPrx>&)> response, - function<void (const exception_ptr&)>, + function<void (exception_ptr)>, const Ice::Current&) const { _lookup->findAdapter(response, adapterId); diff --git a/cpp/src/IceDiscovery/LocatorI.h b/cpp/src/IceDiscovery/LocatorI.h index 9bc375b6495..bf09b88a665 100644 --- a/cpp/src/IceDiscovery/LocatorI.h +++ b/cpp/src/IceDiscovery/LocatorI.h @@ -26,24 +26,25 @@ public: #ifdef ICE_CPP11_MAPPING virtual void - setAdapterDirectProxy_async(const std::string&, - const std::shared_ptr<Ice::ObjectPrx>&, + setAdapterDirectProxy_async(std::string, + std::shared_ptr<Ice::ObjectPrx>, std::function<void ()>, - std::function<void (const std::exception_ptr&)>, + std::function<void (std::exception_ptr)>, const Ice::Current&); virtual void - setReplicatedAdapterDirectProxy_async(const std::string&, const std::string&, - const std::shared_ptr<Ice::ObjectPrx>&, + setReplicatedAdapterDirectProxy_async(std::string, + std::string, + std::shared_ptr<Ice::ObjectPrx>, std::function<void ()>, - std::function<void (const std::exception_ptr&)>, + std::function<void (std::exception_ptr)>, const Ice::Current&); virtual void - setServerProcessProxy_async(const std::string&, - const std::shared_ptr<Ice::ProcessPrx>&, + setServerProcessProxy_async(std::string, + std::shared_ptr<Ice::ProcessPrx>, std::function<void ()>, - std::function<void (const std::exception_ptr&)>, + std::function<void (std::exception_ptr)>, const Ice::Current&); #else virtual void @@ -81,15 +82,15 @@ public: #ifdef ICE_CPP11_MAPPING virtual void - findObjectById_async(const Ice::Identity&, + findObjectById_async(Ice::Identity, std::function<void (const std::shared_ptr<Ice::ObjectPrx>&)>, - std::function<void (const std::exception_ptr&)>, + std::function<void (std::exception_ptr)>, const Ice::Current&) const; virtual void - findAdapterById_async(const std::string&, + findAdapterById_async(std::string, std::function<void (const std::shared_ptr<Ice::ObjectPrx>&)>, - std::function<void (const std::exception_ptr&)>, + std::function<void (std::exception_ptr)>, const Ice::Current&) const; #else virtual void diff --git a/cpp/src/IceDiscovery/LookupI.cpp b/cpp/src/IceDiscovery/LookupI.cpp index d44a97f287a..d7e9ef7b1fa 100644 --- a/cpp/src/IceDiscovery/LookupI.cpp +++ b/cpp/src/IceDiscovery/LookupI.cpp @@ -179,8 +179,13 @@ LookupI::setLookupReply(const LookupReplyPrxPtr& lookupReply) } void -LookupI::findObjectById(const string& domainId, const Ice::Identity& id, const IceDiscovery::LookupReplyPrxPtr& reply, +#ifdef ICE_CPP11_MAPPING +LookupI::findObjectById(string domainId, Ice::Identity id, shared_ptr<IceDiscovery::LookupReplyPrx> reply, + const Ice::Current&) +#else +LookupI::findObjectById(const string& domainId, const Ice::Identity& id, const IceDiscovery::LookupReplyPrx& reply, const Ice::Current&) +#endif { if(domainId != _domainId) { @@ -209,8 +214,13 @@ LookupI::findObjectById(const string& domainId, const Ice::Identity& id, const I } void -LookupI::findAdapterById(const string& domainId, const std::string& adapterId, - const IceDiscovery::LookupReplyPrxPtr& reply, const Ice::Current&) +#ifdef ICE_CPP11_MAPPING +LookupI::findAdapterById(string domainId, string adapterId, shared_ptr<IceDiscovery::LookupReplyPrx> reply, + const Ice::Current&) +#else +LookupI::findAdapterById(const string& domainId, const string& adapterId, const IceDiscovery::LookupReplyPrxPtr& reply, + const Ice::Current&) +#endif { if(domainId != _domainId) { @@ -441,16 +451,28 @@ LookupReplyI::LookupReplyI(const LookupIPtr& lookup) : _lookup(lookup) { } +#ifdef ICE_CPP11_MAPPING void -LookupReplyI::foundObjectById(const Ice::Identity& id, const Ice::ObjectPrxPtr& proxy, const Ice::Current&) +LookupReplyI::foundObjectById(Identity id, shared_ptr<ObjectPrx> proxy, const Current&) { _lookup->foundObject(id, proxy); } void -LookupReplyI::foundAdapterById(const std::string& adapterId, const Ice::ObjectPrxPtr& proxy, bool isReplicaGroup, - const Ice::Current&) +LookupReplyI::foundAdapterById(string adapterId, shared_ptr<ObjectPrx> proxy, bool isReplicaGroup, const Current&) { _lookup->foundAdapter(adapterId, proxy, isReplicaGroup); } +#else +void +LookupReplyI::foundObjectById(const Identity& id, const ObjectPrxPtr& proxy, const Current&) +{ + _lookup->foundObject(id, proxy); +} +void +LookupReplyI::foundAdapterById(const string& adapterId, const ObjectPrxPtr& proxy, bool isReplicaGroup, const Current&) +{ + _lookup->foundAdapter(adapterId, proxy, isReplicaGroup); +} +#endif diff --git a/cpp/src/IceDiscovery/LookupI.h b/cpp/src/IceDiscovery/LookupI.h index ad242f0d6d0..b54875ff0f2 100644 --- a/cpp/src/IceDiscovery/LookupI.h +++ b/cpp/src/IceDiscovery/LookupI.h @@ -216,22 +216,27 @@ public: void setLookupReply(const LookupReplyPrxPtr&); - virtual void findObjectById(const std::string&, const Ice::Identity&, const IceDiscovery::LookupReplyPrxPtr&, +#ifdef ICE_CPP11_MAPPING + virtual void findObjectById(std::string, + Ice::Identity, + ::std::shared_ptr<IceDiscovery::LookupReplyPrx>, const Ice::Current&); - virtual void findAdapterById(const std::string&, const std::string&, const IceDiscovery::LookupReplyPrxPtr&, + virtual void findAdapterById(std::string, std::string, ::std::shared_ptr<IceDiscovery::LookupReplyPrx>, const Ice::Current&); - -#ifdef ICE_CPP11_MAPPING void findObject(std::function<void (const std::shared_ptr<Ice::ObjectPrx>&)>, const Ice::Identity&); void findAdapter(std::function<void (const std::shared_ptr<Ice::ObjectPrx>&)>, const std::string&); #else + virtual void findObjectById(const std::string&, const Ice::Identity&, const IceDiscovery::LookupReplyPrx&, + const Ice::Current&); + virtual void findAdapterById(const std::string&, const std::string, ::std::shared_ptr<IceDiscovery::LookupReplyPrx>, + const Ice::Current&); void findObject(const Ice::AMD_Locator_findObjectByIdPtr&, const Ice::Identity&); void findAdapter(const Ice::AMD_Locator_findAdapterByIdPtr&, const std::string&); #endif void foundObject(const Ice::Identity&, const Ice::ObjectPrxPtr&); void foundAdapter(const std::string&, const Ice::ObjectPrxPtr&, bool); - + void adapterRequestTimedOut(const AdapterRequestPtr&); void objectRequestTimedOut(const ObjectRequestPtr&); @@ -270,8 +275,13 @@ public: LookupReplyI(const LookupIPtr&); - virtual void foundObjectById(const Ice::Identity&, const Ice::ObjectPrxPtr&, const Ice::Current&); - virtual void foundAdapterById(const std::string&, const Ice::ObjectPrxPtr&, bool, const Ice::Current&); +#ifdef ICE_CPP11_MAPPING + virtual void foundObjectById(Ice::Identity, std::shared_ptr<Ice::ObjectPrx>, const Ice::Current&); + virtual void foundAdapterById(std::string, std::shared_ptr<Ice::ObjectPrx>, bool, const Ice::Current&); +#else + virtual void foundObjectById(const Ice::Identity&, const Ice::ObjectPrx&, const Ice::Current&); + virtual void foundAdapterById(const std::string&, const Ice::ObjectPrx&, bool, const Ice::Current&); +#endif private: diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index bc61ca61fe3..bfc21c2cb46 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -662,7 +662,7 @@ Slice::returnTypeToString(const TypePtr& type, bool optional, const StringList& string Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx, bool cpp11) { - static const char* inputBuiltinTable[] = + static const char* cpp98InputBuiltinTable[] = { "::Ice::Byte", "bool", @@ -678,27 +678,52 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m "const ::Ice::ValuePtr&" }; - static const char* cpp11InputBuiltinTable[] = - { - "::Ice::Byte", - "bool", - "short", - "int", - "long long int", - "float", - "double", - "const ::std::string&", - "const ::std::shared_ptr<::Ice::Object>&", - "const ::std::shared_ptr<::Ice::ObjectPrx>&", - "const ::std::shared_ptr<void>&", - "const ::std::shared_ptr<::Ice::Value>&" - }; + static const char* cpp11InputLocalBuiltinTable[] = + { + "::Ice::Byte", + "bool", + "short", + "int", + "long long int", + "float", + "double", + "const ::std::string&", + "const ::std::shared_ptr<::Ice::Object>&", + "const ::std::shared_ptr<::Ice::ObjectPrx>&", + "const ::std::shared_ptr<void>&", + "const ::std::shared_ptr<::Ice::Value>&" + }; + static const char* cpp11InputBuiltinTable[] = + { + "::Ice::Byte", + "bool", + "short", + "int", + "long long int", + "float", + "double", + "::std::string&", + "::std::shared_ptr<::Ice::Object>", + "::std::shared_ptr<::Ice::ObjectPrx>", + "::std::shared_ptr<void>", + "::std::shared_ptr<::Ice::Value>" + }; + + typeCtx |= TypeContextInParam; if(optional) { - return "const IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx, cpp11)) +">&"; + if(cpp11 && !(typeCtx & TypeContextLocalOperation) && + !(typeCtx & TypeContextAMD)) + { + return "IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx, cpp11)) +">"; + } + else + { + return "const IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx, cpp11)) +">&"; + } } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); @@ -706,7 +731,14 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m { if(builtin->kind() == Builtin::KindString) { - return string("const ") + stringTypeToString(type, metaData, typeCtx) + "&"; + if(cpp11 && !(typeCtx & TypeContextLocalOperation) && !(typeCtx & TypeContextAMD)) + { + return stringTypeToString(type, metaData, typeCtx); + } + else + { + return string("const ") + stringTypeToString(type, metaData, typeCtx) + "&"; + } } else { @@ -714,16 +746,30 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m { if(builtin->kind() == Builtin::KindObject && !(typeCtx & TypeContextLocalOperation)) { - return "const ::std::shared_ptr<::Ice::Value>&"; + if(typeCtx & TypeContextAMD) + { + return "const ::std::shared_ptr<::Ice::Value>&"; + } + else + { + return "::std::shared_ptr<::Ice::Value>"; + } } else { - return cpp11InputBuiltinTable[builtin->kind()]; + if(typeCtx & TypeContextLocalOperation || typeCtx & TypeContextAMD) + { + return cpp11InputLocalBuiltinTable[builtin->kind()]; + } + else + { + return cpp11InputBuiltinTable[builtin->kind()]; + } } } else { - return inputBuiltinTable[builtin->kind()]; + return cpp98InputBuiltinTable[builtin->kind()]; } } } @@ -738,17 +784,41 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m { return t; } - else if(cl->isInterface() && !cl->isLocal()) - { - return "const ::std::shared_ptr<::Ice::Value>&"; - } - else if(cl->definition() && cl->definition()->isDelegate()) + else if(cl->isLocal() || (typeCtx & TypeContextLocalOperation)) { - return classDefToDelegateString(cl->definition(), typeCtx, cpp11); + if(cl->definition() && cl->definition()->isDelegate()) + { + return classDefToDelegateString(cl->definition(), typeCtx, cpp11); + } + else + { + return "const ::std::shared_ptr<" + fixKwd(cl->scoped()) + ">&"; + } } else { - return "const ::std::shared_ptr<" + fixKwd(cl->scoped()) + ">&"; + if(typeCtx & TypeContextAMD) + { + if(cl->isInterface()) + { + return "const ::std::shared_ptr<::Ice::Value>&"; + } + else + { + return "const ::std::shared_ptr<" + fixKwd(cl->scoped()) + ">&"; + } + } + else + { + if(cl->isInterface()) + { + return "::std::shared_ptr<::Ice::Value>"; + } + else + { + return "::std::shared_ptr<" + fixKwd(cl->scoped()) + ">"; + } + } } } else @@ -760,11 +830,28 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m StructPtr st = StructPtr::dynamicCast(type); if(st) { - if(!cpp11 && findMetaData(st->getMetaData()) == "%class") + if(cpp11) + { + if(st->isLocal() || (typeCtx & TypeContextLocalOperation) || (typeCtx & TypeContextAMD)) + { + return "const " + fixKwd(st->scoped()) + "&"; + } + else + { + return fixKwd(st->scoped()); + } + } + else { - return "const " + fixKwd(st->scoped() + "Ptr&"); + if(findMetaData(st->getMetaData()) == "%class") + { + return "const " + fixKwd(st->scoped() + "Ptr&"); + } + else + { + return "const " + fixKwd(st->scoped()) + "&"; + } } - return "const " + fixKwd(st->scoped()) + "&"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); @@ -777,13 +864,30 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m // Non local classes without operations map to the base // proxy class shared_ptr<Ice::ObjectPrx> // - if(def && !def->isInterface() && def->allOperations().empty()) + if(typeCtx & TypeContextLocalOperation) { - return "const ::std::shared_ptr<::Ice::ObjectPrx>"; + if(def && !def->isInterface() && def->allOperations().empty()) + { + return "const ::std::shared_ptr<::Ice::ObjectPrx>&"; + } + else + { + return "const ::std::shared_ptr<" + fixKwd(proxy->_class()->scoped() + "Prx") + ">&"; + } } else { - return "const ::std::shared_ptr<" + fixKwd(proxy->_class()->scoped() + "Prx") + ">&"; + string t; + if(def && !def->isInterface() && def->allOperations().empty()) + { + t = "::std::shared_ptr<::Ice::ObjectPrx>"; + } + else + { + t = "::std::shared_ptr<" + fixKwd(proxy->_class()->scoped() + "Prx") + ">"; + } + + return (typeCtx & TypeContextAMD) ? ("const " + t + "&") : t; } } else @@ -801,19 +905,40 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - return "const " + sequenceTypeToString(seq, metaData, typeCtx) + "&"; + if(cpp11 && !(typeCtx & TypeContextLocalOperation) && !(typeCtx & TypeContextAMD)) + { + return sequenceTypeToString(seq, metaData, typeCtx); + } + else + { + return "const " + sequenceTypeToString(seq, metaData, typeCtx) + "&"; + } } DictionaryPtr dict = DictionaryPtr::dynamicCast(type); if(dict) { - return "const " + dictionaryTypeToString(dict, metaData, typeCtx) + "&"; + if(cpp11 && !(typeCtx & TypeContextLocalOperation) && !(typeCtx & TypeContextAMD)) + { + return dictionaryTypeToString(dict, metaData, typeCtx); + } + else + { + return "const " + dictionaryTypeToString(dict, metaData, typeCtx) + "&"; + } } ContainedPtr contained = ContainedPtr::dynamicCast(type); if(contained) { - return "const " + fixKwd(contained->scoped()) + "&"; + if(cpp11 && !(typeCtx & TypeContextLocalOperation) && !(typeCtx & TypeContextAMD)) + { + return fixKwd(contained->scoped()); + } + else + { + return "const " + fixKwd(contained->scoped()) + "&"; + } } return "???"; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index c3d994ff1f5..8e598e882a9 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -8105,7 +8105,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) paramsDecl += typeString; paramsDecl += ' '; paramsDecl += paramName; - args += paramName; + args += (isMovable(type) && !isOutParam) ? ("::std::move(" + paramName + ")") : paramName; } if(!paramList.empty()) @@ -8127,12 +8127,19 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) argsAMD += ", "; } paramsAMD += inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring, true); - argsAMD += fixKwd(string(paramPrefix) + (*q)->name()); + if(isMovable((*q)->type())) + { + argsAMD += "::std::move(" + fixKwd(string(paramPrefix) + (*q)->name()) + ")"; + } + else + { + argsAMD += fixKwd(string(paramPrefix) + (*q)->name()); + } } if(ret) { - string typeString = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring, true); + string typeString = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring | TypeContextAMD, true); responseParams = typeString; responseParamsDecl = typeString + " __ret"; if(!outParams.empty()) @@ -8150,7 +8157,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) responseParamsDecl += ", "; } string paramName = fixKwd(string(paramPrefix) + (*q)->name()); - string typeString = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring, true); + string typeString = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring | TypeContextAMD, true); responseParams += typeString; responseParamsDecl += typeString + " " + paramName; } @@ -8191,7 +8198,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) H << "," << nl; } H << "::std::function<void (" << responseParams << ")>," << nl - << "::std::function<void (const ::std::exception_ptr&)>, const Ice::Current&)" + << "::std::function<void (::std::exception_ptr)>, const Ice::Current&)" << (isConst ? " const" : "") << " = 0;"; H.restoreIndent(); } @@ -8268,7 +8275,7 @@ Slice::Gen::Cpp11InterfaceVisitor::visitOperation(const OperationPtr& p) else { C << nl << "auto inS = ::std::make_shared<::IceInternal::IncomingAsync>(__inS);"; - C << nl << "auto __exception = [inS](const ::std::exception_ptr& e)"; + C << nl << "auto __exception = [inS](::std::exception_ptr e)"; C << sb; C << nl << "try"; C << sb; |