diff options
author | Jose <jose@zeroc.com> | 2016-01-12 16:16:25 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-01-12 16:16:25 +0100 |
commit | e7b69a69673093523ade275b02e866e2413e636b (patch) | |
tree | 9ec38f89bf0147135888081793fa00499ca97742 /cpp/src | |
parent | C++11: Reduce code bloat from C++ proxy factory methods (diff) | |
download | ice-e7b69a69673093523ade275b02e866e2413e636b.tar.bz2 ice-e7b69a69673093523ade275b02e866e2413e636b.tar.xz ice-e7b69a69673093523ade275b02e866e2413e636b.zip |
C++11 minor improvements
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 20 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/SlicedData.cpp | 20 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 126 |
4 files changed, 86 insertions, 88 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 4e3de10edc8..ed6f5402460 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -1580,26 +1580,26 @@ IceInternal::BasicStream::read(vector<wstring>& v) } void -#ifndef ICE_CPP11_MAPPING -IceInternal::BasicStream::write(const ObjectPrxPtr& v) +#ifdef ICE_CPP11_MAPPING +IceInternal::BasicStream::writeProxy(const shared_ptr<ObjectPrx>& v) #else -IceInternal::BasicStream::writeProxy(const ObjectPrxPtr& v) +IceInternal::BasicStream::write(const ObjectPrx& v) #endif { _instance->proxyFactory()->proxyToStream(v, this); } -#ifndef ICE_CPP11_MAPPING -void -IceInternal::BasicStream::read(ObjectPrxPtr& v) +#ifdef ICE_CPP11_MAPPING +shared_ptr<ObjectPrx> +IceInternal::BasicStream::readProxy() { - v = _instance->proxyFactory()->streamToProxy(this); + return _instance->proxyFactory()->streamToProxy(this); } #else -ObjectPrxPtr -IceInternal::BasicStream::readProxy() +void +IceInternal::BasicStream::read(ObjectPrx& v) { - return _instance->proxyFactory()->streamToProxy(this); + v = _instance->proxyFactory()->streamToProxy(this); } #endif diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index c7af240dcac..f31669f9c85 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -304,13 +304,13 @@ operationModeToString(OperationMode mode) // // This could not happen with C++11 strong type enums // -#ifndef ICE_CPP11_MAPPING +#ifdef ICE_CPP11_MAPPING + assert(false); + return ""; +#else ostringstream os; os << "unknown value (" << mode << ")"; return os.str(); -#else - assert(false); - return ""; #endif } diff --git a/cpp/src/Ice/SlicedData.cpp b/cpp/src/Ice/SlicedData.cpp index d721b1c6c91..d2e9b89d388 100644 --- a/cpp/src/Ice/SlicedData.cpp +++ b/cpp/src/Ice/SlicedData.cpp @@ -43,6 +43,15 @@ Ice::SlicedData::__gcVisitMembers(IceInternal::GCVisitor& visitor) } } } + +void +Ice::UnknownSlicedObject::__gcVisitMembers(IceInternal::GCVisitor& _v) +{ + if(_slicedData) + { + _slicedData->__gcVisitMembers(_v); + } +} #endif Ice::UnknownSlicedObject::UnknownSlicedObject(const string& unknownTypeId) : _unknownTypeId(unknownTypeId) @@ -61,17 +70,6 @@ Ice::UnknownSlicedObject::getSlicedData() const return _slicedData; } -#ifndef ICE_CPP11_MAPPING -void -Ice::UnknownSlicedObject::__gcVisitMembers(IceInternal::GCVisitor& _v) -{ - if(_slicedData) - { - _slicedData->__gcVisitMembers(_v); - } -} -#endif - void Ice::UnknownSlicedObject::__write(IceInternal::BasicStream* __os) const { diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 435531772d1..14a8f60f8fd 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -592,56 +592,40 @@ Slice::Gen::generate(const UnitPtr& p) H << sp; H.zeroIndent(); - H << nl << "#ifndef ICE_CPP11_MAPPING // C++98 mapping"; + H << nl << "#ifdef ICE_CPP11_MAPPING // C++11 mapping"; H.restoreIndent(); C << sp; C.zeroIndent(); - C << nl << "#ifndef ICE_CPP11_MAPPING // C++98 mapping"; + C << nl << "#ifdef ICE_CPP11_MAPPING // C++11 mapping"; C.restoreIndent(); { - ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport); + Cpp11ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport); p->visit(&proxyDeclVisitor, false); - ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport); + Cpp11ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport); p->visit(&objectDeclVisitor, false); - TypesVisitor typesVisitor(H, C, _dllExport, _stream); + Cpp11TypesVisitor typesVisitor(H, C, _dllExport); p->visit(&typesVisitor, false); - StreamVisitor streamVisitor(H, C, _dllExport); + Cpp11StreamVisitor streamVisitor(H, C, _dllExport); p->visit(&streamVisitor, false); - AsyncVisitor asyncVisitor(H, C, _dllExport); - p->visit(&asyncVisitor, false); - - AsyncImplVisitor asyncImplVisitor(H, C, _dllExport); - p->visit(&asyncImplVisitor, false); - - // - // The templates are emitted before the proxy definition - // so the derivation hierarchy is known to the proxy: - // the proxy relies on knowing the hierarchy to make the begin_ - // methods type-safe. - // - AsyncCallbackVisitor asyncCallbackVisitor(H, C, _dllExport); - p->visit(&asyncCallbackVisitor, false); - - ProxyVisitor proxyVisitor(H, C, _dllExport); + Cpp11ProxyVisitor proxyVisitor(H, C, _dllExport); p->visit(&proxyVisitor, false); - ObjectVisitor objectVisitor(H, C, _dllExport, _stream); - p->visit(&objectVisitor, false); + Cpp11LocalObjectVisitor localObjectVisitor(H, C, _dllExport, _stream); + p->visit(&localObjectVisitor, false); - // - // We need to delay generating the template after the proxy - // definition, because completed calls the begin_ method in the - // proxy. - // - AsyncCallbackTemplateVisitor asyncCallbackTemplateVisitor(H, C, _dllExport); - p->visit(&asyncCallbackTemplateVisitor, false); + Cpp11InterfaceVisitor interfaceVisitor(H, C, _dllExport, _stream); + p->visit(&interfaceVisitor, false); - if(_impl) + Cpp11ValueVisitor valueVisitor(H, C, _dllExport, _stream); + p->visit(&valueVisitor, false); + + // TODO + /*if(_impl) { implH << "\n#include <"; if(_include.size()) @@ -661,46 +645,65 @@ Slice::Gen::generate(const UnitPtr& p) ImplVisitor implVisitor(implH, implC, _dllExport); p->visit(&implVisitor, false); - } + }*/ + + Cpp11CompatibilityVisitor compatibilityVisitor(H, C, _dllExport); + p->visit(&compatibilityVisitor, false); generateChecksumMap(p); } H << sp; H.zeroIndent(); - H << nl << "#else // C++11 mapping"; + H << nl << "#else // C++98 mapping"; H.restoreIndent(); C << sp; C.zeroIndent(); - C << nl << "#else // C++11 mapping"; + C << nl << "#else // C++98 mapping"; C.restoreIndent(); { - Cpp11ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport); + ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport); p->visit(&proxyDeclVisitor, false); - Cpp11ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport); + ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport); p->visit(&objectDeclVisitor, false); - Cpp11TypesVisitor typesVisitor(H, C, _dllExport); + TypesVisitor typesVisitor(H, C, _dllExport, _stream); p->visit(&typesVisitor, false); - Cpp11StreamVisitor streamVisitor(H, C, _dllExport); + StreamVisitor streamVisitor(H, C, _dllExport); p->visit(&streamVisitor, false); - Cpp11ProxyVisitor proxyVisitor(H, C, _dllExport); - p->visit(&proxyVisitor, false); + AsyncVisitor asyncVisitor(H, C, _dllExport); + p->visit(&asyncVisitor, false); - Cpp11LocalObjectVisitor localObjectVisitor(H, C, _dllExport, _stream); - p->visit(&localObjectVisitor, false); + AsyncImplVisitor asyncImplVisitor(H, C, _dllExport); + p->visit(&asyncImplVisitor, false); - Cpp11InterfaceVisitor interfaceVisitor(H, C, _dllExport, _stream); - p->visit(&interfaceVisitor, false); + // + // The templates are emitted before the proxy definition + // so the derivation hierarchy is known to the proxy: + // the proxy relies on knowing the hierarchy to make the begin_ + // methods type-safe. + // + AsyncCallbackVisitor asyncCallbackVisitor(H, C, _dllExport); + p->visit(&asyncCallbackVisitor, false); - Cpp11ValueVisitor valueVisitor(H, C, _dllExport, _stream); - p->visit(&valueVisitor, false); + ProxyVisitor proxyVisitor(H, C, _dllExport); + p->visit(&proxyVisitor, false); - // TODO - /*if(_impl) + ObjectVisitor objectVisitor(H, C, _dllExport, _stream); + p->visit(&objectVisitor, false); + + // + // We need to delay generating the template after the proxy + // definition, because completed calls the begin_ method in the + // proxy. + // + AsyncCallbackTemplateVisitor asyncCallbackTemplateVisitor(H, C, _dllExport); + p->visit(&asyncCallbackTemplateVisitor, false); + + if(_impl) { implH << "\n#include <"; if(_include.size()) @@ -720,23 +723,20 @@ Slice::Gen::generate(const UnitPtr& p) ImplVisitor implVisitor(implH, implC, _dllExport); p->visit(&implVisitor, false); - }*/ - - Cpp11CompatibilityVisitor compatibilityVisitor(H, C, _dllExport); - p->visit(&compatibilityVisitor, false); + } generateChecksumMap(p); - - H << sp; - H.zeroIndent(); - H << nl << "#endif"; - H.restoreIndent(); - - C << sp; - C.zeroIndent(); - C << nl << "#endif"; - C.restoreIndent(); } + + H << sp; + H.zeroIndent(); + H << nl << "#endif"; + H.restoreIndent(); + + C << sp; + C.zeroIndent(); + C << nl << "#endif"; + C.restoreIndent(); } void |