diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/ObjectStore.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/.depend | 1 | ||||
-rw-r--r-- | cpp/src/Ice/Buffer.cpp | 118 | ||||
-rw-r--r-- | cpp/src/Ice/Makefile | 1 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.cpp | 5 | ||||
-rw-r--r-- | cpp/src/Ice/ice.dsp | 4 | ||||
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 9 |
7 files changed, 138 insertions, 10 deletions
diff --git a/cpp/src/Freeze/ObjectStore.cpp b/cpp/src/Freeze/ObjectStore.cpp index dfbe0de1651..a8cc39c9079 100644 --- a/cpp/src/Freeze/ObjectStore.cpp +++ b/cpp/src/Freeze/ObjectStore.cpp @@ -257,7 +257,7 @@ Freeze::ObjectStore::marshal(const Identity& ident, Key& bytes, const Communicat IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get()); ident.__write(&stream); - stream.b.copyToVector(bytes); + vector<Byte>(stream.b.begin(), stream.b.end()).swap(bytes); } void @@ -265,7 +265,8 @@ Freeze::ObjectStore::unmarshal(Identity& ident, const Key& bytes, const Communic { IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get()); - stream.b.copyFromVector(bytes); + stream.b.resize(bytes.size()); + memcpy(&stream.b[0], &bytes[0], bytes.size()); stream.i = stream.b.begin(); ident.__read(&stream); } @@ -279,7 +280,7 @@ Freeze::ObjectStore::marshal(const ObjectRecord& v, Value& bytes, const Communic v.__write(&stream); stream.writePendingObjects(); stream.endWriteEncaps(); - stream.b.copyToVector(bytes); + vector<Byte>(stream.b.begin(), stream.b.end()).swap(bytes); } void @@ -288,7 +289,8 @@ Freeze::ObjectStore::unmarshal(ObjectRecord& v, const Value& bytes, const Commun IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get()); stream.sliceObjects(false); - stream.b.copyFromVector(bytes); + stream.b.resize(bytes.size()); + memcpy(&stream.b[0], &bytes[0], bytes.size()); stream.i = stream.b.begin(); stream.startReadEncaps(); v.__read(&stream); diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend index 3d397320e44..629b20efe59 100644 --- a/cpp/src/Ice/.depend +++ b/cpp/src/Ice/.depend @@ -1,5 +1,6 @@ Acceptor.o: Acceptor.cpp ../Ice/Acceptor.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../Ice/AcceptorF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../Ice/TransceiverF.h Application.o: Application.cpp ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/Stats.h ../../include/Ice/Communicator.h ../../include/Ice/StatsF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/RouterF.h ../../include/Ice/LocatorF.h ../../include/Ice/PluginF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/FacetMap.h ../../include/Ice/ServantLocator.h ../../include/Ice/Object.h ../../include/IceUtil/GCShared.h ../../include/IceUtil/GCRecMutex.h ../../include/IceUtil/RecMutex.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/IdentityUtil.h ../../include/Ice/OutgoingAsync.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/IncomingAsync.h ../../include/Ice/Incoming.h ../../include/Ice/ServantManagerF.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Process.h ../../include/Ice/Outgoing.h ../../include/Ice/Direct.h ../../include/Ice/Connection.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../../include/Ice/Stream.h ../../include/IceUtil/StaticMutex.h ../../include/IceUtil/CtrlCHandler.h ../../include/IceUtil/GC.h ../../include/IceUtil/Thread.h +Buffer.o: Buffer.cpp ../../include/Ice/Buffer.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/BuiltinSequences.h BasicStream.o: BasicStream.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Buffer.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../../include/Ice/Object.h ../../include/IceUtil/GCShared.h ../../include/IceUtil/GCRecMutex.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../Ice/ProxyFactory.h ../../include/Ice/ObjectFactory.h ../Ice/ObjectFactoryManager.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/LocalException.h ../../include/Ice/BuiltinSequences.h ../Ice/Protocol.h ../../include/Ice/FactoryTable.h ../../include/Ice/FactoryTableDef.h ../../include/IceUtil/StaticMutex.h ../../include/Ice/UserExceptionFactoryF.h ../Ice/TraceUtil.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h BuiltinSequences.o: BuiltinSequences.cpp ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Object.h ../../include/IceUtil/GCShared.h ../../include/IceUtil/GCRecMutex.h ../../include/IceUtil/RecMutex.h ../../include/Ice/IncomingAsyncF.h CommunicatorF.o: CommunicatorF.cpp ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp new file mode 100644 index 00000000000..02d8295ffba --- /dev/null +++ b/cpp/src/Ice/Buffer.cpp @@ -0,0 +1,118 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Buffer.h> +#include <Ice/LocalException.h> + +using namespace std; +using namespace Ice; +using namespace IceInternal; + +void +IceInternal::Buffer::swap(Buffer& other) +{ +#ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION + Container::difference_type pos = i - b.begin(); + Container::difference_type otherPos = other.i - other.b.begin(); + b.swap(other.b); + i = b.begin() + otherPos; + other.i = other.b.begin() + pos; +#else + b.swap(other.b); + std::swap(i, other.i); +#endif +} + +void +IceInternal::Buffer::Container::swap(Container& other) +{ +#ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION + if(_buf == _fixed) + { + if(other._buf == other._fixed) + { + value_type tmp[_fixedSize]; + memcpy(tmp, _fixed, _size); + memcpy(_fixed, other._fixed, other._size); + memcpy(other._fixed, tmp, _size); + } + else + { + _buf = other._buf; + memcpy(other._fixed, _fixed, _size); + other._buf = other._fixed; + } + } + else + { + if(other._buf == other._fixed) + { + other._buf = _buf; + memcpy(_fixed, other._fixed, other._size); + _buf = _fixed; + } + else + { + std::swap(_buf, other._buf); + } + } +#else + std::swap(_buf, other._buf); +#endif + + std::swap(_size, other._size); + std::swap(_capacity, other._capacity); +} + +void +IceInternal::Buffer::Container::resize(size_type n) +{ + if(n == 0) + { + clear(); + } + else + { + if(n > _capacity) + { + _capacity = std::max<size_type>(n, 2 * _capacity); + _capacity = std::max<size_type>(static_cast<size_type>(240), _capacity); + +#ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION + if(_buf != _fixed) + { + _buf = reinterpret_cast<pointer>(realloc(_buf, _capacity)); + } + else + { + _buf = reinterpret_cast<pointer>(malloc(_capacity)); + memcpy(_buf, _fixed, _size); + } +#else + if(_buf) + { + _buf = reinterpret_cast<pointer>(realloc(_buf, _capacity)); + } + else + { + _buf = reinterpret_cast<pointer>(malloc(_capacity)); + } +#endif + + if(!_buf) + { + SyscallException ex(__FILE__, __LINE__); + ex.error = getSystemErrno(); + throw ex; + } + } + + _size = n; + } +} diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index d98809d43fb..09991eb6ea2 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -17,6 +17,7 @@ TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(li OBJS = Acceptor.o \ Application.o \ + Buffer.o \ BasicStream.o \ BuiltinSequences.o \ CommunicatorF.o \ diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index 5dda15a3b30..b11789d619a 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -35,7 +35,8 @@ IceInternal::BasicOutputStream::BasicOutputStream(IceInternal::Instance* instanc Ice::InputStreamI::InputStreamI(const Ice::CommunicatorPtr& communicator, const vector<Byte>& data) : _communicator(communicator), _is(IceInternal::getInstance(communicator).get(), this) { - _is.b.copyFromVector(data); + _is.b.resize(data.size()); + memcpy(&_is.b[0], &data[0], data.size()); _is.i = _is.b.begin(); } @@ -441,7 +442,7 @@ Ice::OutputStreamI::writePendingObjects() void Ice::OutputStreamI::finished(vector<Byte>& bytes) { - _os.b.copyToVector(bytes); + vector<Byte>(_os.b.begin(), _os.b.end()).swap(bytes); } // diff --git a/cpp/src/Ice/ice.dsp b/cpp/src/Ice/ice.dsp index 051d198ca4b..d09edc6e667 100644 --- a/cpp/src/Ice/ice.dsp +++ b/cpp/src/Ice/ice.dsp @@ -118,6 +118,10 @@ SOURCE=.\BasicStream.cpp # End Source File
# Begin Source File
+SOURCE=.\Buffer.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\BuiltinSequences.cpp
# End Source File
# Begin Source File
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 46f94c52479..4c63ae376b7 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -169,7 +169,7 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, b { C << nl << "stream.endWriteEncaps();"; } - C << nl << "stream.b.copyToVector(bytes);"; + C << nl << "::std::vector<Ice::Byte>(stream.b.begin(), stream.b.end()).swap(bytes);"; C << eb; C << sp << nl << "void" << nl << name << "::read(" << typeToString(type) << "& v, " @@ -181,7 +181,8 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, b { C << nl << "stream.sliceObjects(false);"; } - C << nl << "stream.b.copyFromVector(bytes);"; + C << nl << "stream.b.resize(bytes.size());"; + C << nl << "::memcpy(&stream.b[0], &bytes[0], bytes.size());"; C << nl << "stream.i = stream.b.begin();"; if(encaps) { @@ -468,7 +469,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di { C << nl << "__stream.writePendingObjects();"; } - C << nl << "__stream.b.copyToVector(__bytes);"; + C << nl << "::std::vector<Ice::Byte>(__stream.b.begin(), __stream.b.end()).swap(__bytes);"; } C << eb; } @@ -850,7 +851,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member { C << nl << "__stream.writePendingObjects();"; } - C << nl << "__stream.b.copyToVector(__bytes);"; + C << nl << "::std::vector<Ice::Byte>(__stream.b.begin(), __stream.b.end()).swap(__bytes);"; C << eb; } |