diff options
author | Bernard Normier <bernard@zeroc.com> | 2012-10-11 14:44:58 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2012-10-11 14:44:58 -0400 |
commit | 027e0fe8d3d1a6c4cf2f6ba2e80016c102943ebe (patch) | |
tree | 5a17059ea764321a0b6e43f1083dcd6c7db363f1 /cpp/src | |
parent | ICE-4829 - Certificate failure on W2003 (diff) | |
download | ice-027e0fe8d3d1a6c4cf2f6ba2e80016c102943ebe.tar.bz2 ice-027e0fe8d3d1a6c4cf2f6ba2e80016c102943ebe.tar.xz ice-027e0fe8d3d1a6c4cf2f6ba2e80016c102943ebe.zip |
Partial fix for ICE-4869: C++ stream read/write for structs (and structs-as-class)
is now generated as templates.
Removed most slice2cpp --stream uses (but not all)
Also fixed various build failures on Solaris.
Diffstat (limited to 'cpp/src')
34 files changed, 197 insertions, 142 deletions
diff --git a/cpp/src/Freeze/ObjectStore.cpp b/cpp/src/Freeze/ObjectStore.cpp index 4015ab63eb5..99a09af7b98 100644 --- a/cpp/src/Freeze/ObjectStore.cpp +++ b/cpp/src/Freeze/ObjectStore.cpp @@ -336,7 +336,7 @@ Freeze::ObjectStoreBase::marshal(const Identity& ident, { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get(), encoding, true); - ident.__write(&stream); + stream.write(ident); vector<Byte>(stream.b.begin(), stream.b.end()).swap(bytes); } @@ -351,7 +351,7 @@ Freeze::ObjectStoreBase::unmarshal(Identity& ident, stream.b.resize(bytes.size()); memcpy(&stream.b[0], &bytes[0], bytes.size()); stream.i = stream.b.begin(); - ident.__read(&stream); + stream.read(ident); } void @@ -366,7 +366,7 @@ Freeze::ObjectStoreBase::marshal(const ObjectRecord& v, stream.startWriteEncaps(); if(keepStats) { - v.__write(&stream); + stream.write(v); } else { @@ -395,7 +395,7 @@ Freeze::ObjectStoreBase::unmarshal(ObjectRecord& v, if(keepStats) { - v.__read(&stream); + stream.read(v); } else { diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index c984fbab901..947ede7fbed 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -1369,10 +1369,10 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) throw ex; } ProtocolVersion pv; - pv.__read(&_readStream); + _readStream.read(pv); checkSupportedProtocol(pv); EncodingVersion ev; - ev.__read(&_readStream); + _readStream.read(ev); checkSupportedProtocolEncoding(ev); Byte messageType; @@ -2218,8 +2218,8 @@ Ice::ConnectionI::initiateShutdown() os.write(magic[1]); os.write(magic[2]); os.write(magic[3]); - currentProtocol.__write(&os); - currentProtocolEncoding.__write(&os); + os.write(currentProtocol); + os.write(currentProtocolEncoding); os.write(closeConnectionMsg); os.write((Byte)1); // compression status: compression supported but not used. os.write(headerSize); // Message size. @@ -2280,8 +2280,8 @@ Ice::ConnectionI::validate(SocketOperation operation) _writeStream.write(magic[1]); _writeStream.write(magic[2]); _writeStream.write(magic[3]); - currentProtocol.__write(&_writeStream); - currentProtocolEncoding.__write(&_writeStream); + _writeStream.write(currentProtocol); + _writeStream.write(currentProtocolEncoding); _writeStream.write(validateConnectionMsg); _writeStream.write(static_cast<Byte>(0)); // Compression status (always zero for validate connection). _writeStream.write(headerSize); // Message size. @@ -2345,10 +2345,10 @@ Ice::ConnectionI::validate(SocketOperation operation) throw ex; } ProtocolVersion pv; - pv.__read(&_readStream); + _readStream.read(pv); checkSupportedProtocol(pv); EncodingVersion ev; - ev.__read(&_readStream); + _readStream.read(ev); checkSupportedProtocolEncoding(ev); Byte messageType; _readStream.read(messageType); diff --git a/cpp/src/Ice/DefaultsAndOverrides.h b/cpp/src/Ice/DefaultsAndOverrides.h index d2f624470d1..d043e30bb5d 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.h +++ b/cpp/src/Ice/DefaultsAndOverrides.h @@ -15,6 +15,7 @@ #include <Ice/DefaultsAndOverridesF.h> #include <Ice/PropertiesF.h> #include <Ice/Endpoint.h> +#include <Ice/EndpointTypes.h> #include <Ice/Format.h> namespace IceInternal diff --git a/cpp/src/Ice/ImplicitContextI.cpp b/cpp/src/Ice/ImplicitContextI.cpp index 86118533e67..eb130202eb2 100644 --- a/cpp/src/Ice/ImplicitContextI.cpp +++ b/cpp/src/Ice/ImplicitContextI.cpp @@ -8,6 +8,8 @@ // ********************************************************************** #include <Ice/ImplicitContextI.h> +#include <Ice/BasicStream.h> +#include <Ice/Object.h> #include <IceUtil/Mutex.h> #include <IceUtil/MutexPtrLock.h> diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 9c0fc36f509..962749a871f 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -309,7 +309,7 @@ IceInternal::IncomingBase::__handleException(const std::exception& exc) assert(false); } - rfe->id.__write(&_os); + _os.write(rfe->id); // // For compatibility with the old FacetPath. @@ -548,7 +548,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager, BasicStre // // Read the current. // - _current.id.__read(_is); + _is->read(_current.id); // // For compatibility with the old FacetPath. diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index f5978fac90b..70edf85aa0b 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -206,14 +206,4 @@ install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) endif -$(HDIR)/BuiltinSequences.h BuiltinSequences.cpp: $(SDIR)/BuiltinSequences.ice $(SLICE2CPP) $(SLICEPARSERLIB) - rm -f $(HDIR)/BuiltinSequences.h BuiltinSequences.cpp - $(SLICE2CPP) $(SLICE2CPPFLAGS) --stream $(SDIR)/BuiltinSequences.ice - mv BuiltinSequences.h $(HDIR) - -$(HDIR)/Metrics.h Metrics.cpp: $(SDIR)/Metrics.ice $(SLICE2CPP) $(SLICEPARSERLIB) - rm -f $(HDIR)/Metrics.h Metrics.cpp - $(SLICE2CPP) $(SLICE2CPPFLAGS) --stream $(SDIR)/Metrics.ice - mv Metrics.h $(HDIR) - include .depend diff --git a/cpp/src/Ice/Makefile.mak b/cpp/src/Ice/Makefile.mak index 9383a7ba28d..970653b53d2 100644 --- a/cpp/src/Ice/Makefile.mak +++ b/cpp/src/Ice/Makefile.mak @@ -145,11 +145,6 @@ $(DLLNAME): $(OBJS) Ice.res $(MT) -nologo -manifest $@.manifest -outputresource:$@;#2 && del /q $@.manifest
@if exist $(DLLNAME:.dll=.exp) del /q $(DLLNAME:.dll=.exp)
-$(HDIR)\BuiltinSequences.h BuiltinSequences.cpp: $(SDIR)\BuiltinSequences.ice $(SLICE2CPP) $(SLICEPARSERLIB)
- del /q $(HDIR)\BuiltinSequences.h BuiltinSequences.cpp
- $(SLICE2CPP) $(SLICE2CPPFLAGS) --stream $(SDIR)\BuiltinSequences.ice
- move BuiltinSequences.h $(HDIR)
-
Service.obj: EventLoggerMsg.h
Ice.res: EventLoggerMsg.rc
diff --git a/cpp/src/Ice/MetricsAdminI.cpp b/cpp/src/Ice/MetricsAdminI.cpp index 6e6910224d1..1bde9603020 100644 --- a/cpp/src/Ice/MetricsAdminI.cpp +++ b/cpp/src/Ice/MetricsAdminI.cpp @@ -389,7 +389,7 @@ MetricsAdminI::updateViews() map<string, MetricsViewIPtr>::const_iterator q = _views.find(viewName); if(q == _views.end()) { - q = views.insert(make_pair(viewName, new MetricsViewI(viewName))).first; + q = views.insert(map<string, MetricsViewIPtr>::value_type(viewName, new MetricsViewI(viewName))).first; } else { diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index e79fa217e91..513c9505129 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -444,7 +444,8 @@ getLocalAddresses(ProtocolSupport protocol) struct in_addr* inaddr = &reinterpret_cast<struct sockaddr_in*>(&addr)->sin_addr; if(inaddr->s_addr != 0 && inaddr->s_addr != htonl(INADDR_LOOPBACK)) { - for(unsigned int j = 0; j < result.size(); ++j) + unsigned int j; + for(j = 0; j < result.size(); ++j) { if(compareAddress(addr, result[j]) == 0) { @@ -464,7 +465,8 @@ getLocalAddresses(ProtocolSupport protocol) struct in6_addr* inaddr6 = &reinterpret_cast<struct sockaddr_in6*>(&addr)->sin6_addr; if(!IN6_IS_ADDR_UNSPECIFIED(inaddr6) && !IN6_IS_ADDR_LOOPBACK(inaddr6)) { - for(unsigned int j = 0; j < result.size(); ++j) + unsigned int j; + for(j = 0; j < result.size(); ++j) { if(compareAddress(addr, result[j]) == 0) { diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp index d0dee1f32f1..a54f45398b7 100644 --- a/cpp/src/Ice/ObjectAdapterFactory.cpp +++ b/cpp/src/Ice/ObjectAdapterFactory.cpp @@ -9,6 +9,7 @@ #include <Ice/ObjectAdapterFactory.h> #include <Ice/ObjectAdapterI.h> +#include <Ice/Object.h> #include <Ice/LocalException.h> #include <Ice/Functional.h> #include <IceUtil/UUID.h> diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index db135a44199..a8c3b703712 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -26,8 +26,10 @@ #include <Ice/ConnectorF.h> #include <Ice/LocatorInfoF.h> #include <Ice/ThreadPoolF.h> +#include <Ice/OutgoingAsyncF.h> #include <Ice/Exception.h> #include <Ice/BuiltinSequences.h> +#include <Ice/Proxy.h> #include <list> namespace Ice diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 44571200fdf..3e4d24a563b 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -112,7 +112,7 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation try { - _handler->getReference()->getIdentity().__write(&_os); + _os.write(_handler->getReference()->getIdentity()); // // For compatibility with the old FacetPath. @@ -402,7 +402,7 @@ IceInternal::Outgoing::finished(BasicStream& is) // exception, you will have a memory leak. // Identity ident; - ident.__read(&_is); + _is.read(ident); // // For compatibility with the old FacetPath. diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index efbc752c897..f608b6f434b 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -452,7 +452,7 @@ IceInternal::OutgoingAsync::__prepare(const std::string& operation, OperationMod Reference* ref = _proxy->__reference().get(); - ref->getIdentity().__write(&_os); + _os.write(ref->getIdentity()); // // For compatibility with the old FacetPath. @@ -643,7 +643,7 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is) case replyOperationNotExist: { Identity ident; - ident.__read(&_is); + _is.read(ident); // // For compatibility with the old FacetPath. diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index a831145fedf..c28520afcd6 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -73,7 +73,7 @@ ObjectPrx IceInternal::ProxyFactory::streamToProxy(BasicStream* s) const { Identity ident; - ident.__read(s); + s->read(ident); ReferencePtr ref = _instance->referenceFactory()->create(ident, s); return referenceToProxy(ref); @@ -84,13 +84,13 @@ IceInternal::ProxyFactory::proxyToStream(const ObjectPrx& proxy, BasicStream* s) { if(proxy) { - proxy->__reference()->getIdentity().__write(s); + s->write(proxy->__reference()->getIdentity()); proxy->__reference()->streamWrite(s); } else { Identity ident; - ident.__write(s); + s->write(ident); } } diff --git a/cpp/src/Ice/RouterInfo.h b/cpp/src/Ice/RouterInfo.h index b3508d7edba..c1b1077a73b 100644 --- a/cpp/src/Ice/RouterInfo.h +++ b/cpp/src/Ice/RouterInfo.h @@ -15,8 +15,10 @@ #include <Ice/RouterInfoF.h> #include <Ice/RouterF.h> #include <Ice/ProxyF.h> +#include <Ice/ReferenceF.h> #include <Ice/EndpointIF.h> #include <Ice/BuiltinSequences.h> +#include <Ice/Identity.h> #include <set> diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 311e4edbaa4..4baa8fed6cb 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -192,8 +192,8 @@ IceInternal::TcpEndpointI::TcpEndpointI(BasicStream* s) : s->read(const_cast<bool&>(_compress)); if(s->getReadEncoding() > Ice::Encoding_1_0) { - const_cast<Ice::ProtocolVersion&>(_protocol).__read(s); - const_cast<Ice::EncodingVersion&>(_encoding).__read(s); + s->read(const_cast<Ice::ProtocolVersion&>(_protocol)); + s->read(const_cast<Ice::EncodingVersion&>(_encoding)); } else { @@ -214,8 +214,8 @@ IceInternal::TcpEndpointI::streamWrite(BasicStream* s) const s->write(_compress); if(s->getWriteEncoding() > Ice::Encoding_1_0) { - _protocol.__write(s); - _encoding.__write(s); + s->write(_protocol); + s->write(_encoding); } s->endWriteEncaps(); } diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index 49bd4329ef3..e107904e92d 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -48,6 +48,10 @@ public: virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; +#ifdef __SUNPRO_CC + using EndpointI::connectionId; +#endif + private: virtual ::Ice::Int hashInit() const; diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp index 3dcd019b209..7d0448b7036 100644 --- a/cpp/src/Ice/TraceUtil.cpp +++ b/cpp/src/Ice/TraceUtil.cpp @@ -29,7 +29,7 @@ static void printIdentityFacetOperation(ostream& s, BasicStream& stream) { Identity identity; - identity.__read(&stream); + stream.read(identity); s << "\nidentity = " << stream.instance()->identityToString(identity); vector<string> facet; diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index c20a430bbe6..4be1d98bd77 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -218,8 +218,8 @@ IceInternal::UdpEndpointI::UdpEndpointI(BasicStream* s) : s->startReadEncaps(); s->read(const_cast<string&>(_host), false); s->read(const_cast<Int&>(_port)); - const_cast<Ice::ProtocolVersion&>(_protocol).__read(s); - const_cast<Ice::EncodingVersion&>(_encoding).__read(s); + s->read(const_cast<Ice::ProtocolVersion&>(_protocol)); + s->read(const_cast<Ice::EncodingVersion&>(_encoding)); // Not transmitted. //s->read(const_cast<bool&>(_connect)); s->read(const_cast<bool&>(_compress)); @@ -233,8 +233,8 @@ IceInternal::UdpEndpointI::streamWrite(BasicStream* s) const s->startWriteEncaps(); s->write(_host, false); s->write(_port); - _protocol.__write(s); - _encoding.__write(s); + s->write(_protocol); + s->write(_encoding); // Not transmitted. //s->write(_connect); s->write(_compress); diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index 9bfe598f9ad..03b671af62c 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -48,6 +48,10 @@ public: virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; +#ifdef __SUNPRO_CC + using EndpointI::connectionId; +#endif + private: virtual ::Ice::Int hashInit() const; diff --git a/cpp/src/Ice/winrt/Makefile.mak b/cpp/src/Ice/winrt/Makefile.mak index 1e40c3599ea..4fa485239a4 100644 --- a/cpp/src/Ice/winrt/Makefile.mak +++ b/cpp/src/Ice/winrt/Makefile.mak @@ -197,12 +197,6 @@ RES_FILE = $(SOURCE_DIR)\Ice.res $(LIBNAME): $(LOCAL_OBJS) $(OBJS) $(RES_FILE) sdks $(AR) $(ARFLAGS) $(OBJS) $(LOCAL_OBJS) /out:$(LIBNAME) -$(HDIR)\BuiltinSequences.h ..\BuiltinSequences.cpp: $(slicedir)\Ice\BuiltinSequences.ice $(SLICE2CPP) - del /q $(HDIR)\BuiltinSequences.h ..\BuiltinSequences.cpp - $(SLICE2CPP) $(CORE_SLICE2CPPFLAGS) --stream $(slicedir)\Ice\BuiltinSequences.ice - move BuiltinSequences.cpp .. - move BuiltinSequences.h $(HDIR) - Service.obj: $(SOURCE_DIR)\EventLoggerMsg.h Ice.res: $(SOURCE_DIR)\EventLoggerMsg.rc diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 52ae52be798..e874b8bf17a 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -2120,7 +2120,15 @@ Database::checkUpdate(const ApplicationHelper& oldApp, out << "check for application `" << application << "' update failed:"; if(!unreachableNodes.empty()) { +#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES) + Ice::StringSeq nodes; + for(set<string>::const_iterator p = unreachableNodes.begin(); p != unreachableNodes.end(); ++p) + { + nodes.push_back(*p); + } +#else Ice::StringSeq nodes(unreachableNodes.begin(), unreachableNodes.end()); +#endif if(nodes.size() == 1) { out << "\nthe node `" << nodes[0] << "' is down"; @@ -2154,7 +2162,16 @@ Database::checkUpdate(const ApplicationHelper& oldApp, } if(!unreachableNodes.empty()) { +#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES) + Ice::StringSeq nodes; + for(set<string>::const_iterator p = unreachableNodes.begin(); p != unreachableNodes.end\ + (); ++p) + { + nodes.push_back(*p); + } +#else Ice::StringSeq nodes(unreachableNodes.begin(), unreachableNodes.end()); +#endif if(nodes.size() == 1) { os << "\nthe node `" << nodes[0] << "' is down"; diff --git a/cpp/src/IceGrid/FreezeDB/Makefile.mak b/cpp/src/IceGrid/FreezeDB/Makefile.mak index 6e44e3c5c65..c140b1d741b 100644 --- a/cpp/src/IceGrid/FreezeDB/Makefile.mak +++ b/cpp/src/IceGrid/FreezeDB/Makefile.mak @@ -30,12 +30,12 @@ SRCS = $(OBJS:.obj=.cpp) \ HDIR = $(headerdir)/IceGrid
SDIR = $(slicedir)/IceGrid
-SLICE2FREEZECMD = $(SLICE2FREEZE) -I..\.. --ice --include-dir IceGrid\FreezeDB $(ICECPPFLAGS)
+SLICE2FREEZECMD = $(SLICE2FREEZE) -I..\.. --ice --include-dir IceGrid/FreezeDB $(ICECPPFLAGS)
!include $(top_srcdir)\config\Make.rules.mak
CPPFLAGS = -I..\.. -Idummyinclude $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
-SLICE2CPPFLAGS = -I..\.. --ice --include-dir IceGrid\FreezeDB $(SLICE2CPPFLAGS)
+SLICE2CPPFLAGS = -I..\.. --ice --include-dir IceGrid/FreezeDB $(SLICE2CPPFLAGS)
LINKWITH = icegrid$(LIBSUFFIX).lib glacier2$(LIBSUFFIX).lib icedb$(LIBSUFFIX).lib freeze$(LIBSUFFIX).lib $(LIBS)
MLINKWITH = freeze$(LIBSUFFIX).lib icegrid$(LIBSUFFIX).lib icegriddb$(LIBSUFFIX).lib $(LIBS)
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index dd94ec2feda..4901b6752b4 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -98,6 +98,7 @@ CheckUpdateResult::getResult() os << ex; throw NodeUnreachableException(_node, os.str()); } + return false; } ServerCache::ServerCache(const Ice::CommunicatorPtr& communicator, diff --git a/cpp/src/IceGrid/SqlDB/SqlStringApplicationInfoDict.cpp b/cpp/src/IceGrid/SqlDB/SqlStringApplicationInfoDict.cpp index 2e05d6a4d91..6f2952ac0ec 100644 --- a/cpp/src/IceGrid/SqlDB/SqlStringApplicationInfoDict.cpp +++ b/cpp/src/IceGrid/SqlDB/SqlStringApplicationInfoDict.cpp @@ -106,7 +106,7 @@ SqlStringApplicationInfoDict::put(const DatabaseConnectionPtr& connection, IceInternal::InstancePtr instance = IceInternal::getInstance(_communicator); IceInternal::BasicStream stream(instance.get(), connection->getEncoding()); stream.startWriteEncaps(); - info.descriptor.__write(&stream); + stream.write(info.descriptor); stream.writePendingObjects(); stream.endWriteEncaps(); @@ -256,7 +256,7 @@ SqlStringApplicationInfoDict::find(const DatabaseConnectionPtr& connection, ::memcpy(&stream.b[0], bytes.data(), bytes.size()); stream.i = stream.b.begin(); stream.startReadEncaps(); - info.descriptor.__read(&stream); + stream.read(info.descriptor); stream.readPendingObjects(); stream.endReadEncaps(); @@ -302,7 +302,7 @@ SqlStringApplicationInfoDict::getMap(const DatabaseConnectionPtr& connection, ::memcpy(&stream.b[0], bytes.data(), bytes.size()); stream.i = stream.b.begin(); stream.startReadEncaps(); - info.descriptor.__read(&stream); + stream.read(info.descriptor); stream.readPendingObjects(); stream.endReadEncaps(); diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp index 7479263eb33..1cfb7bce4a0 100644 --- a/cpp/src/IceSSL/Certificate.cpp +++ b/cpp/src/IceSSL/Certificate.cpp @@ -14,6 +14,7 @@ #include <IceSSL/Plugin.h> #include <IceSSL/Util.h> #include <IceSSL/RFC2253.h> +#include <Ice/Object.h> #include <openssl/x509v3.h> #include <openssl/pem.h> diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index ebc0dff0842..6b2b9b0a55b 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -16,6 +16,7 @@ #include <Ice/BasicStream.h> #include <Ice/LocalException.h> #include <Ice/DefaultsAndOverrides.h> +#include <Ice/Object.h> #include <Ice/HashUtil.h> using namespace std; @@ -192,8 +193,8 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, IceInternal::BasicStre s->read(const_cast<bool&>(_compress)); if(s->getReadEncoding() > Ice::Encoding_1_0) { - const_cast<Ice::ProtocolVersion&>(_protocol).__read(s); - const_cast<Ice::EncodingVersion&>(_encoding).__read(s); + s->read(const_cast<Ice::ProtocolVersion&>(_protocol)); + s->read(const_cast<Ice::EncodingVersion&>(_encoding)); } else { @@ -214,8 +215,8 @@ IceSSL::EndpointI::streamWrite(IceInternal::BasicStream* s) const s->write(_compress); if(s->getWriteEncoding() > Ice::Encoding_1_0) { - _protocol.__write(s); - _encoding.__write(s); + s->write(_protocol); + s->write(_encoding); } s->endWriteEncaps(); } diff --git a/cpp/src/IceSSL/PluginI.cpp b/cpp/src/IceSSL/PluginI.cpp index 9ba271a2864..d1cfada9660 100644 --- a/cpp/src/IceSSL/PluginI.cpp +++ b/cpp/src/IceSSL/PluginI.cpp @@ -12,6 +12,7 @@ #include <IceSSL/TransceiverI.h> #include <Ice/LocalException.h> +#include <Ice/Object.h> using namespace std; using namespace Ice; diff --git a/cpp/src/IceSSL/RFC2253.cpp b/cpp/src/IceSSL/RFC2253.cpp index 16fdbf6c86c..a0caca6b5fa 100644 --- a/cpp/src/IceSSL/RFC2253.cpp +++ b/cpp/src/IceSSL/RFC2253.cpp @@ -11,6 +11,7 @@ #include <IceSSL/Plugin.h> #include <IceSSL/RFC2253.h> +#include <Ice/Object.h> using namespace std; using namespace IceSSL; diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp index f0ddfc86cca..2b7b26e7144 100644 --- a/cpp/src/IceSSL/Util.cpp +++ b/cpp/src/IceSSL/Util.cpp @@ -16,6 +16,7 @@ #include <IceUtil/FileUtil.h> #include <Ice/LocalException.h> #include <Ice/Network.h> +#include <Ice/Object.h> #ifdef _WIN32 # include <direct.h> diff --git a/cpp/src/IceStorm/FreezeDB/Makefile.mak b/cpp/src/IceStorm/FreezeDB/Makefile.mak index 7acf6a95ee7..09b9b995ef6 100644 --- a/cpp/src/IceStorm/FreezeDB/Makefile.mak +++ b/cpp/src/IceStorm/FreezeDB/Makefile.mak @@ -41,12 +41,12 @@ SRCS = $(OBJS:.obj=.cpp) \ HDIR = $(headerdir)/IceStorm
SDIR = $(slicedir)/IceStorm
-SLICE2FREEZECMD = $(SLICE2FREEZE) -I..\.. --ice --include-dir IceStorm\FreezeDB $(ICECPPFLAGS)
+SLICE2FREEZECMD = $(SLICE2FREEZE) -I..\.. --ice --include-dir IceStorm/FreezeDB $(ICECPPFLAGS)
!include $(top_srcdir)\config\Make.rules.mak
CPPFLAGS = -I..\.. -Idummyinclude $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
-SLICE2CPPFLAGS = -I..\.. --ice --include-dir IceStorm\FreezeDB $(SLICE2CPPFLAGS)
+SLICE2CPPFLAGS = -I..\.. --ice --include-dir IceStorm/FreezeDB $(SLICE2CPPFLAGS)
LINKWITH = icestormservice$(LIBSUFFIX).lib icestorm$(LIBSUFFIX).lib icedb$(LIBSUFFIX).lib freeze$(LIBSUFFIX).lib $(LIBS)
MLINKWITH = freeze$(LIBSUFFIX).lib icestormservice$(LIBSUFFIX).lib icestorm$(LIBSUFFIX).lib $(LIBS)
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 5f5a4d187fa..b96e2f1360c 100755 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -1573,6 +1573,40 @@ Slice::Container::hasNonLocalClassDefs() const } bool +Slice::Container::hasLocalClassDefsWithAsync() const +{ + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + { + ClassDefPtr cl = ClassDefPtr::dynamicCast(*p); + if(cl && cl->isLocal()) + { + if(cl->hasMetaData("async")) + { + return true; + } + + OperationList ol = cl->operations(); + for(OperationList::const_iterator q = ol.begin(); q != ol.end(); ++q) + { + cerr << (*q)->name() << endl; + if((*q)->hasMetaData("async")) + { + return true; + } + } + } + + ContainerPtr container = ContainerPtr::dynamicCast(*p); + if(container && container->hasLocalClassDefsWithAsync()) + { + return true; + } + } + + return false; +} + +bool Slice::Container::hasNonLocalSequences() const { for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 6738a68f10c..3d89df4997b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -136,6 +136,12 @@ writeMarshalUnmarshalDataMember(IceUtilInternal::Output& C, const DataMemberPtr& } void +writeMarshalUnmarshalDataMemberInHolder(IceUtilInternal::Output& C, const string& holder, const DataMemberPtr& p, bool marshal) +{ + writeMarshalUnmarshalCode(C, p->type(), p->optional(), p->tag(), holder + fixKwd(p->name()), marshal, p->getMetaData()); +} + +void writeMarshalUnmarshalDataMembers(IceUtilInternal::Output& C, const DataMemberList& dataMembers, const DataMemberList& optionalDataMembers, @@ -374,6 +380,11 @@ Slice::Gen::generate(const UnitPtr& p) C << "\n#include <Ice/LocalException.h>"; C << "\n#include <Ice/ObjectFactory.h>"; } + else if(p->hasLocalClassDefsWithAsync()) + { + H << "\n#include <Ice/Proxy.h>"; + H << "\n#include <Ice/OutgoingAsync.h>"; + } if(p->hasNonLocalDataOnlyClasses() || p->hasNonLocalExceptions()) { @@ -386,13 +397,9 @@ Slice::Gen::generate(const UnitPtr& p) if(p->usesNonLocals()) { C << "\n#include <Ice/BasicStream.h>"; - - if(!p->hasNonLocalClassDefs() && !p->hasNonLocalClassDecls()) - { - C << "\n#include <Ice/Object.h>"; - } + C << "\n#include <Ice/Object.h>"; } - + if(_stream || p->hasNonLocalClassDefs() || p->hasNonLocalExceptions()) { if(!p->hasNonLocalClassDefs()) @@ -479,8 +486,8 @@ Slice::Gen::generate(const UnitPtr& p) TypesVisitor typesVisitor(H, C, _dllExport, _stream); p->visit(&typesVisitor, false); - StreamVisitor streamVistor(H, C); - p->visit(&streamVistor, false); + StreamVisitor streamVisitor(H, C, _dllExport); + p->visit(&streamVisitor, false); AsyncVisitor asyncVisitor(H, C, _dllExport); p->visit(&asyncVisitor, false); @@ -1196,12 +1203,6 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) params.push_back(fixKwd((*q)->name())); } - string dllExport; - if(findMetaData(p->getMetaData()) != "%class") - { - dllExport = _dllExport; - } - H << sp << nl << "bool operator==(const " << name << "& __rhs) const"; H << sb; H << nl << "if(this == &__rhs)"; @@ -1253,57 +1254,6 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) H << sb; H << nl << "return !operator<(__rhs);"; H << eb; - - if(!p->isLocal()) - { - // - // None of these member functions are virtual! - // - H << sp << nl << dllExport << "void __write(::IceInternal::BasicStream*) const;"; - H << nl << dllExport << "void __read(::IceInternal::BasicStream*);"; - - if(_stream) - { - H << nl << dllExport << "void __write(const ::Ice::OutputStreamPtr&) const;"; - H << nl << dllExport << "void __read(const ::Ice::InputStreamPtr&);"; - } - - C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const"; - C << sb; - for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeMarshalUnmarshalDataMember(C, *q, true); - } - C << eb; - - C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)"; - C << sb; - for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeMarshalUnmarshalDataMember(C, *q, false); - } - C << eb; - - if(_stream) - { - C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const"; - C << sb; - for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - C << nl << "__os->write(" << fixKwd((*q)->name()) << ");"; - } - C << eb; - - C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)"; - C << sb; - for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - C << nl << "__is->read(" << fixKwd((*q)->name()) << ");"; - } - C << eb; - } - } - H << eb << ';'; if(findMetaData(p->getMetaData()) == "%class") @@ -6032,10 +5982,11 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) } } -Slice::Gen::StreamVisitor::StreamVisitor(Output& h, Output& c) : - H(h), C(c) +Slice::Gen::StreamVisitor::StreamVisitor(Output& h, Output& c, const string& dllExport) : + H(h), + C(c), + _dllExport(dllExport) { - } bool @@ -6055,6 +6006,9 @@ Slice::Gen::StreamVisitor::visitModuleStart(const ModulePtr& m) // H << sp; H << nl << "namespace Ice" << nl << '{'; + + C << sp; + C << nl << "namespace Ice" << nl << '{'; } return true; @@ -6069,6 +6023,7 @@ Slice::Gen::StreamVisitor::visitModuleEnd(const ModulePtr& m) // Only emit this for the top-level module. // H << nl << '}'; + C << nl << '}'; } } @@ -6094,15 +6049,13 @@ Slice::Gen::StreamVisitor::visitStructStart(const StructPtr& p) { bool classMetaData = findMetaData(p->getMetaData(), false) == "%class"; string scoped = p->scoped(); + + string fullStructName = classMetaData ? fixKwd(scoped + "Ptr") : fixKwd(scoped); + H << nl << "template<>"; - if(classMetaData) - { - H << nl << "struct StreamableTraits< " << fixKwd(scoped + "Ptr") << ">"; - } - else - { - H << nl << "struct StreamableTraits< " << fixKwd(scoped) << ">"; - } + + H << nl << "struct StreamableTraits< " << fullStructName << ">"; + H << sb; if(classMetaData) { @@ -6122,6 +6075,53 @@ Slice::Gen::StreamVisitor::visitStructStart(const StructPtr& p) H << nl << "static const bool fixedLength = true;"; } H << eb << ";" << nl; + + DataMemberList dataMembers = p->dataMembers(); + + string holder = classMetaData ? "v->" : "v."; + + H << nl << "template<class S>"; + H << nl << "struct StreamWriter< " << fullStructName << ", S>"; + H << sb; + H << nl << "static void write(S* __os, const " << fullStructName << "& v)"; + H << sb; + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + writeMarshalUnmarshalDataMemberInHolder(H, holder, *q, true); + } + H << eb; + H << eb << ";" << nl; + + H << nl << "template<class S>"; + H << nl << "struct StreamReader< " << fullStructName << ", S>"; + H << sb; + H << nl << "static void read(S* __is, " << fullStructName << "& v)"; + H << sb; + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + writeMarshalUnmarshalDataMemberInHolder(H, holder, *q, false); + } + H << eb; + H << eb << ";" << nl; + + if(!_dllExport.empty()) + { + // + // We tell "importers" that the implementation exports these instantiations + // + H << nl << "#if defined(ICE_HAS_DECLSPEC_IMPORT_EXPORT) && !defined(" << _dllExport.substr(0, _dllExport.size() - 1) + "_EXPORTS)"; + H << nl << "template struct " << _dllExport << "StreamWriter< " << fullStructName << ", ::IceInternal::BasicStream>;"; + H << nl << "template struct " << _dllExport << "StreamReader< " << fullStructName << ", ::IceInternal::BasicStream>;"; + H << nl << "#endif" << nl; + + // + // The instantations: + // + C << nl << "#ifdef ICE_HAS_DECLSPEC_IMPORT_EXPORT"; + C << nl << "template struct " << _dllExport << "StreamWriter< " << fullStructName << ", ::IceInternal::BasicStream>;"; + C << nl << "template struct " << _dllExport << "StreamReader< " << fullStructName << ", ::IceInternal::BasicStream>;"; + C << nl << "#endif" << nl; + } } return false; } diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 9d05ca2a8b5..a8377f6fa35 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -402,7 +402,7 @@ private: { public: - StreamVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&); + StreamVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); @@ -414,6 +414,7 @@ private: ::IceUtilInternal::Output& H; ::IceUtilInternal::Output& C; + std::string _dllExport; }; private: |