diff options
author | Mark Spruiell <mes@zeroc.com> | 2008-06-03 19:32:20 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2008-06-03 19:32:20 -0700 |
commit | 3d649bed4328992f41f567136025f58a019a5159 (patch) | |
tree | 470be901fbbfe5c6cd4269884412b0d36b48dc92 /cppe/include | |
parent | local interface fixes for slice2javae (diff) | |
download | ice-3d649bed4328992f41f567136025f58a019a5159.tar.bz2 ice-3d649bed4328992f41f567136025f58a019a5159.tar.xz ice-3d649bed4328992f41f567136025f58a019a5159.zip |
Various Ice-E fixes:
- Bug fix in slice2javae for local interfaces/classes
- Added Ice.LocalObjectHolder
- Reviewed Java/C++ demos and aligned with Ice
- Source code clean up (removed tabs, etc.)
Diffstat (limited to 'cppe/include')
26 files changed, 1032 insertions, 1032 deletions
diff --git a/cppe/include/IceE/AbstractMutex.h b/cppe/include/IceE/AbstractMutex.h index e19a14178d6..77f54bed9df 100644 --- a/cppe/include/IceE/AbstractMutex.h +++ b/cppe/include/IceE/AbstractMutex.h @@ -38,17 +38,17 @@ public: virtual void lock() const { - T::lock(); + T::lock(); } virtual void unlock() const { - T::unlock(); + T::unlock(); } virtual bool tryLock() const { - return T::tryLock(); + return T::tryLock(); } virtual ~AbstractMutexI() @@ -65,17 +65,17 @@ public: virtual void lock() const { - T::readLock(); + T::readLock(); } virtual void unlock() const { - T::unlock(); + T::unlock(); } virtual bool tryLock() const { - return T::tryReadLock(); + return T::tryReadLock(); } virtual ~AbstractMutexReadI() @@ -92,17 +92,17 @@ public: virtual void lock() const { - T::writeLock(); + T::writeLock(); } virtual void unlock() const { - T::unlock(); + T::unlock(); } virtual bool tryLock() const { - return T::tryWriteLock(); + return T::tryWriteLock(); } virtual ~AbstractMutexWriteI() diff --git a/cppe/include/IceE/BasicStream.h b/cppe/include/IceE/BasicStream.h index 2bc6cc488c1..a39c96aedf1 100644 --- a/cppe/include/IceE/BasicStream.h +++ b/cppe/include/IceE/BasicStream.h @@ -87,31 +87,31 @@ public: const Ice::StringConverterPtr& stringConverter, const Ice::WstringConverterPtr& wstringConverter, #endif bool unlimited = false) : - Buffer(messageSizeMax), - _instance(instance), - _currentReadEncaps(0), - _currentWriteEncaps(0), - _messageSizeMax(messageSizeMax), + Buffer(messageSizeMax), + _instance(instance), + _currentReadEncaps(0), + _currentWriteEncaps(0), + _messageSizeMax(messageSizeMax), _unlimited(unlimited), #ifdef ICEE_HAS_WSTRING _stringConverter(stringConverter), _wstringConverter(wstringConverter), #endif - _seqDataStack(0) + _seqDataStack(0) { - // Inlined for performance reasons. + // Inlined for performance reasons. } ~BasicStream() { - // Inlined for performance reasons. - - if(_currentReadEncaps != &_preAllocatedReadEncaps || - _currentWriteEncaps != &_preAllocatedWriteEncaps || - _seqDataStack) - { - clear(); // Not inlined. - } + // Inlined for performance reasons. + + if(_currentReadEncaps != &_preAllocatedReadEncaps || + _currentWriteEncaps != &_preAllocatedWriteEncaps || + _seqDataStack) + { + clear(); // Not inlined. + } } ICE_API void clear(); @@ -126,168 +126,168 @@ public: void resize(Container::size_type sz) { - if(!_unlimited && sz > _messageSizeMax) - { - Ice::throwMemoryLimitException(__FILE__, __LINE__); - } - - b.resize(sz); + if(!_unlimited && sz > _messageSizeMax) + { + Ice::throwMemoryLimitException(__FILE__, __LINE__); + } + + b.resize(sz); } void reset() // Inlined for performance reasons. { b.reset(); - i = b.begin(); + i = b.begin(); } ICE_API void startSeq(int, int); void checkSeq() { - checkSeq(static_cast<int>(b.end() - i)); + checkSeq(static_cast<int>(b.end() - i)); } void checkSeq(int bytesLeft) { - // - // Check, given the number of elements requested for this sequence, - // that this sequence, plus the sum of the sizes of the remaining - // number of elements of all enclosing sequences, would still fit - // within the message. - // - int size = 0; - SeqData* sd = _seqDataStack; - do - { - size += (sd->numElements - 1) * sd->minSize; - sd = sd->previous; - } - while(sd); - - if(size > bytesLeft) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } + // + // Check, given the number of elements requested for this sequence, + // that this sequence, plus the sum of the sizes of the remaining + // number of elements of all enclosing sequences, would still fit + // within the message. + // + int size = 0; + SeqData* sd = _seqDataStack; + do + { + size += (sd->numElements - 1) * sd->minSize; + sd = sd->previous; + } + while(sd); + + if(size > bytesLeft) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } } ICE_API void checkFixedSeq(int, int); // For sequences of fixed-size types. void endElement() { - assert(_seqDataStack); - --_seqDataStack->numElements; + assert(_seqDataStack); + --_seqDataStack->numElements; } ICE_API void endSeq(int); void startWriteEncaps() { - WriteEncaps* oldEncaps = _currentWriteEncaps; - if(!oldEncaps) // First allocated encaps? - { - _currentWriteEncaps = &_preAllocatedWriteEncaps; - } - else - { - _currentWriteEncaps = new WriteEncaps(); - _currentWriteEncaps->previous = oldEncaps; - } - _currentWriteEncaps->start = b.size(); - - write(Ice::Int(0)); // Placeholder for the encapsulation length. - write(encodingMajor); - write(encodingMinor); + WriteEncaps* oldEncaps = _currentWriteEncaps; + if(!oldEncaps) // First allocated encaps? + { + _currentWriteEncaps = &_preAllocatedWriteEncaps; + } + else + { + _currentWriteEncaps = new WriteEncaps(); + _currentWriteEncaps->previous = oldEncaps; + } + _currentWriteEncaps->start = b.size(); + + write(Ice::Int(0)); // Placeholder for the encapsulation length. + write(encodingMajor); + write(encodingMinor); } void endWriteEncaps() { - assert(_currentWriteEncaps); - Container::size_type start = _currentWriteEncaps->start; - Ice::Int sz = static_cast<Ice::Int>(b.size() - start); // Size includes size and version. - Ice::Byte* dest = &(*(b.begin() + start)); + assert(_currentWriteEncaps); + Container::size_type start = _currentWriteEncaps->start; + Ice::Int sz = static_cast<Ice::Int>(b.size() - start); // Size includes size and version. + Ice::Byte* dest = &(*(b.begin() + start)); #ifdef ICE_BIG_ENDIAN - const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&sz) + sizeof(Ice::Int) - 1; - *dest++ = *src--; - *dest++ = *src--; - *dest++ = *src--; - *dest = *src; + const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&sz) + sizeof(Ice::Int) - 1; + *dest++ = *src--; + *dest++ = *src--; + *dest++ = *src--; + *dest = *src; #else - const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&sz); - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - *dest = *src; + const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&sz); + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + *dest = *src; #endif - WriteEncaps* oldEncaps = _currentWriteEncaps; - _currentWriteEncaps = _currentWriteEncaps->previous; - if(oldEncaps == &_preAllocatedWriteEncaps) - { - oldEncaps->reset(); - } - else - { - delete oldEncaps; - } + WriteEncaps* oldEncaps = _currentWriteEncaps; + _currentWriteEncaps = _currentWriteEncaps->previous; + if(oldEncaps == &_preAllocatedWriteEncaps) + { + oldEncaps->reset(); + } + else + { + delete oldEncaps; + } } void startReadEncaps() { - ReadEncaps* oldEncaps = _currentReadEncaps; - if(!oldEncaps) // First allocated encaps? - { - _currentReadEncaps = &_preAllocatedReadEncaps; - } - else - { - _currentReadEncaps = new ReadEncaps(); - _currentReadEncaps->previous = oldEncaps; - } - _currentReadEncaps->start = i - b.begin(); - - // - // I don't use readSize() and writeSize() for encapsulations, - // because when creating an encapsulation, I must know in advance - // how many bytes the size information will require in the data - // stream. If I use an Int, it is always 4 bytes. For - // readSize()/writeSize(), it could be 1 or 5 bytes. - // - Ice::Int sz; - read(sz); - if(sz < 0) - { - Ice::throwNegativeSizeException(__FILE__, __LINE__); - } - if(i - sizeof(Ice::Int) + sz > b.end()) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } - _currentReadEncaps->sz = sz; - - Ice::Byte eMajor; - Ice::Byte eMinor; - read(eMajor); - read(eMinor); - if(eMajor != encodingMajor - || static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor)) - { - Ice::throwUnsupportedEncodingException(__FILE__, __LINE__, eMajor, eMinor, encodingMajor, encodingMinor); - } - _currentReadEncaps->encodingMajor = eMajor; - _currentReadEncaps->encodingMinor = eMinor; + ReadEncaps* oldEncaps = _currentReadEncaps; + if(!oldEncaps) // First allocated encaps? + { + _currentReadEncaps = &_preAllocatedReadEncaps; + } + else + { + _currentReadEncaps = new ReadEncaps(); + _currentReadEncaps->previous = oldEncaps; + } + _currentReadEncaps->start = i - b.begin(); + + // + // I don't use readSize() and writeSize() for encapsulations, + // because when creating an encapsulation, I must know in advance + // how many bytes the size information will require in the data + // stream. If I use an Int, it is always 4 bytes. For + // readSize()/writeSize(), it could be 1 or 5 bytes. + // + Ice::Int sz; + read(sz); + if(sz < 0) + { + Ice::throwNegativeSizeException(__FILE__, __LINE__); + } + if(i - sizeof(Ice::Int) + sz > b.end()) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } + _currentReadEncaps->sz = sz; + + Ice::Byte eMajor; + Ice::Byte eMinor; + read(eMajor); + read(eMinor); + if(eMajor != encodingMajor + || static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor)) + { + Ice::throwUnsupportedEncodingException(__FILE__, __LINE__, eMajor, eMinor, encodingMajor, encodingMinor); + } + _currentReadEncaps->encodingMajor = eMajor; + _currentReadEncaps->encodingMinor = eMinor; } void endReadEncaps() { - assert(_currentReadEncaps); - Container::size_type start = _currentReadEncaps->start; - Ice::Int sz = _currentReadEncaps->sz; - i = b.begin() + start + sz; - - ReadEncaps* oldEncaps = _currentReadEncaps; - _currentReadEncaps = _currentReadEncaps->previous; - if(oldEncaps == &_preAllocatedReadEncaps) - { - oldEncaps->reset(); - } - else - { - delete oldEncaps; - } + assert(_currentReadEncaps); + Container::size_type start = _currentReadEncaps->start; + Ice::Int sz = _currentReadEncaps->sz; + i = b.begin() + start + sz; + + ReadEncaps* oldEncaps = _currentReadEncaps; + _currentReadEncaps = _currentReadEncaps->previous; + if(oldEncaps == &_preAllocatedReadEncaps) + { + oldEncaps->reset(); + } + else + { + delete oldEncaps; + } } ICE_API Ice::Int getReadEncapsSize(); ICE_API void skipEncaps(); @@ -301,16 +301,16 @@ public: void writeSize(Ice::Int v) // Inlined for performance reasons. { - assert(v >= 0); - if(v > 254) - { - write(Ice::Byte(255)); - write(v); - } - else - { - write(static_cast<Ice::Byte>(v)); - } + assert(v >= 0); + if(v > 254) + { + write(Ice::Byte(255)); + write(v); + } + else + { + write(static_cast<Ice::Byte>(v)); + } } void rewriteSize(Ice::Int v, Container::iterator dest) @@ -342,21 +342,21 @@ public: void readSize(Ice::Int& v) // Inlined for performance reasons. { - Ice::Byte byte; - read(byte); - unsigned val = static_cast<unsigned char>(byte); - if(val == 255) - { - read(v); - if(v < 0) - { - Ice::throwNegativeSizeException(__FILE__, __LINE__); - } - } - else - { - v = static_cast<Ice::Int>(static_cast<unsigned char>(byte)); - } + Ice::Byte byte; + read(byte); + unsigned val = static_cast<unsigned char>(byte); + if(val == 255) + { + read(v); + if(v < 0) + { + Ice::throwNegativeSizeException(__FILE__, __LINE__); + } + } + else + { + v = static_cast<Ice::Int>(static_cast<unsigned char>(byte)); + } } ICE_API void writeBlob(const std::vector<Ice::Byte>&); @@ -364,42 +364,42 @@ public: void writeBlob(const Ice::Byte* v, Container::size_type sz) { - if(sz > 0) - { - Container::size_type pos = b.size(); - resize(pos + sz); - memcpy(&b[pos], &v[0], sz); - } + if(sz > 0) + { + Container::size_type pos = b.size(); + resize(pos + sz); + memcpy(&b[pos], &v[0], sz); + } } void readBlob(const Ice::Byte*& v, Container::size_type sz) { - if(sz > 0) - { - v = i; - if(static_cast<Container::size_type>(b.end() - i) < sz) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } - i += sz; - } - else - { - v = i; - } + if(sz > 0) + { + v = i; + if(static_cast<Container::size_type>(b.end() - i) < sz) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } + i += sz; + } + else + { + v = i; + } } void write(Ice::Byte v) // Inlined for performance reasons. { - b.push_back(v); + b.push_back(v); } void read(Ice::Byte& v) // Inlined for performance reasons. { - if(i >= b.end()) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } - v = *i++; + if(i >= b.end()) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } + v = *i++; } ICE_API void write(const Ice::Byte*, const Ice::Byte*); @@ -407,17 +407,17 @@ public: void write(bool v) // Inlined for performance reasons. { - b.push_back(static_cast<Ice::Byte>(v)); + b.push_back(static_cast<Ice::Byte>(v)); } ICE_API void write(const std::vector<bool>&); ICE_API void write(const bool*, const bool*); void read(bool& v) // Inlined for performance reasons. { - if(i >= b.end()) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } - v = *i++; + if(i >= b.end()) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } + v = *i++; } ICE_API void read(std::vector<bool>&); ICE_API bool* read(std::pair<const bool*, const bool*>&); @@ -431,44 +431,44 @@ public: void write(Ice::Int v) // Inlined for performance reasons. { - Container::size_type pos = b.size(); - resize(pos + sizeof(Ice::Int)); - Ice::Byte* dest = &b[pos]; + Container::size_type pos = b.size(); + resize(pos + sizeof(Ice::Int)); + Ice::Byte* dest = &b[pos]; #ifdef ICE_BIG_ENDIAN - const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&v) + sizeof(Ice::Int) - 1; - *dest++ = *src--; - *dest++ = *src--; - *dest++ = *src--; - *dest = *src; + const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&v) + sizeof(Ice::Int) - 1; + *dest++ = *src--; + *dest++ = *src--; + *dest++ = *src--; + *dest = *src; #else - const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&v); - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - *dest = *src; + const Ice::Byte* src = reinterpret_cast<const Ice::Byte*>(&v); + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + *dest = *src; #endif } void read(Ice::Int& v) // Inlined for performance reasons. { - if(b.end() - i < static_cast<int>(sizeof(Ice::Int))) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } - const Ice::Byte* src = &(*i); - i += sizeof(Ice::Int); + if(b.end() - i < static_cast<int>(sizeof(Ice::Int))) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } + const Ice::Byte* src = &(*i); + i += sizeof(Ice::Int); #ifdef ICE_BIG_ENDIAN - Ice::Byte* dest = reinterpret_cast<Ice::Byte*>(&v) + sizeof(Ice::Int) - 1; - *dest-- = *src++; - *dest-- = *src++; - *dest-- = *src++; - *dest = *src; + Ice::Byte* dest = reinterpret_cast<Ice::Byte*>(&v) + sizeof(Ice::Int) - 1; + *dest-- = *src++; + *dest-- = *src++; + *dest-- = *src++; + *dest = *src; #else - Ice::Byte* dest = reinterpret_cast<Ice::Byte*>(&v); - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - *dest = *src; + Ice::Byte* dest = reinterpret_cast<Ice::Byte*>(&v); + *dest++ = *src++; + *dest++ = *src++; + *dest++ = *src++; + *dest = *src; #endif } @@ -529,14 +529,14 @@ public: ICE_API void write(const std::string*, const std::string*, bool = true); void read(std::string& v, bool convert = true) { - Ice::Int sz; - readSize(sz); - if(sz > 0) - { - if(b.end() - i < sz) - { - Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); - } + Ice::Int sz; + readSize(sz); + if(sz > 0) + { + if(b.end() - i < sz) + { + Ice::throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); + } #ifdef ICEE_HAS_WSTRING if(convert && _stringConverter != 0) { @@ -548,12 +548,12 @@ public: std::string(reinterpret_cast<const char*>(&*i), reinterpret_cast<const char*>(&*i) + sz).swap(v); // v.assign(reinterpret_cast<const char*>(&(*i)), sz); } - i += sz; - } - else - { - v.clear(); - } + i += sz; + } + else + { + v.clear(); + } } ICE_API void read(std::vector<std::string>&, bool = true); @@ -600,36 +600,36 @@ private: { public: - ReadEncaps() : previous(0) { } // Inlined for performance reasons. - ~ReadEncaps() { } // Inlined for performance reasons. + ReadEncaps() : previous(0) { } // Inlined for performance reasons. + ~ReadEncaps() { } // Inlined for performance reasons. - void reset() { previous = 0; } // Inlined for performance reasons. - ICE_API void swap(ReadEncaps&); + void reset() { previous = 0; } // Inlined for performance reasons. + ICE_API void swap(ReadEncaps&); - Container::size_type start; - Ice::Int sz; + Container::size_type start; + Ice::Int sz; - Ice::Byte encodingMajor; - Ice::Byte encodingMinor; + Ice::Byte encodingMajor; + Ice::Byte encodingMinor; - ReadEncaps* previous; + ReadEncaps* previous; }; class WriteEncaps : private ::IceUtil::noncopyable { public: - WriteEncaps() : writeIndex(0), previous(0) { } // Inlined for performance reasons. - ~WriteEncaps() { } // Inlined for performance reasons. + WriteEncaps() : writeIndex(0), previous(0) { } // Inlined for performance reasons. + ~WriteEncaps() { } // Inlined for performance reasons. - void reset() { writeIndex = 0; previous = 0; } // Inlined for performance reasons. - ICE_API void swap(WriteEncaps&); + void reset() { writeIndex = 0; previous = 0; } // Inlined for performance reasons. + ICE_API void swap(WriteEncaps&); - Container::size_type start; + Container::size_type start; - Ice::Int writeIndex; + Ice::Int writeIndex; - WriteEncaps* previous; + WriteEncaps* previous; }; ReadEncaps* _currentReadEncaps; @@ -651,10 +651,10 @@ private: struct SeqData { - SeqData(int, int); - int numElements; - int minSize; - SeqData* previous; + SeqData(int, int); + int numElements; + int minSize; + SeqData* previous; }; SeqData* _seqDataStack; }; diff --git a/cppe/include/IceE/Buffer.h b/cppe/include/IceE/Buffer.h index 84d1d8b8893..196354d1685 100644 --- a/cppe/include/IceE/Buffer.h +++ b/cppe/include/IceE/Buffer.h @@ -32,156 +32,156 @@ public: { public: - // - // Standard vector-like operations. - // - - typedef Ice::Byte value_type; - typedef Ice::Byte* iterator; - typedef const Ice::Byte* const_iterator; - typedef Ice::Byte& reference; - typedef const Ice::Byte& const_reference; - typedef Ice::Byte* pointer; - typedef int difference_type; - typedef size_t size_type; + // + // Standard vector-like operations. + // + + typedef Ice::Byte value_type; + typedef Ice::Byte* iterator; + typedef const Ice::Byte* const_iterator; + typedef Ice::Byte& reference; + typedef const Ice::Byte& const_reference; + typedef Ice::Byte* pointer; + typedef int difference_type; + typedef size_t size_type; #ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION - Container(size_type maxCapacity) : - _buf(_fixed), - _size(0), - _capacity(ICE_BUFFER_FIXED_SIZE), - _maxCapacity(maxCapacity) - { - } + Container(size_type maxCapacity) : + _buf(_fixed), + _size(0), + _capacity(ICE_BUFFER_FIXED_SIZE), + _maxCapacity(maxCapacity) + { + } #else - Container(size_type maxCapacity) : - _buf(0), - _size(0), - _capacity(0), - _maxCapacity(maxCapacity) - { - } + Container(size_type maxCapacity) : + _buf(0), + _size(0), + _capacity(0), + _maxCapacity(maxCapacity) + { + } #endif - ~Container() - { + ~Container() + { #ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION - if(_buf != _fixed) - { - free(_buf); - } + if(_buf != _fixed) + { + free(_buf); + } #else - free(_buf); + free(_buf); #endif - } - - iterator begin() - { - return _buf; - } - - const_iterator begin() const - { - return _buf; - } - - iterator end() - { - return _buf + _size; - } - - const_iterator end() const - { - return _buf + _size; - } - - size_type size() const - { - return _size; - } - - bool empty() const - { - return !_size; - } - - ICE_API void swap(Container&); - - ICE_API void clear(); - - void resize(size_type n) // Inlined for performance reasons. + } + + iterator begin() + { + return _buf; + } + + const_iterator begin() const + { + return _buf; + } + + iterator end() + { + return _buf + _size; + } + + const_iterator end() const + { + return _buf + _size; + } + + size_type size() const + { + return _size; + } + + bool empty() const + { + return !_size; + } + + ICE_API void swap(Container&); + + ICE_API void clear(); + + void resize(size_type n) // Inlined for performance reasons. + { + if(n == 0) + { + clear(); + } + else if(n > _capacity) + { + reserve(n); + } + _size = n; + } + + void reset() + { + if(_size > 0 && _size * 2 < _capacity) + { + // + // If the current buffer size is smaller than the + // buffer capacity, we shrink the buffer memory to the + // current size. This is to avoid holding on too much + // memory if it's not needed anymore. + // + if(++_shrinkCounter > 2) + { + reserve(_size); + _shrinkCounter = 0; + } + } + else + { + _shrinkCounter = 0; + } + _size = 0; + } + + void push_back(value_type v) + { + resize(_size + 1); + _buf[_size - 1] = v; + } + + reference operator[](size_type n) + { + assert(n < _size); + return _buf[n]; + } + + const_reference operator[](size_type n) const { - if(n == 0) - { - clear(); - } - else if(n > _capacity) - { - reserve(n); - } - _size = n; - } - - void reset() - { - if(_size > 0 && _size * 2 < _capacity) - { - // - // If the current buffer size is smaller than the - // buffer capacity, we shrink the buffer memory to the - // current size. This is to avoid holding on too much - // memory if it's not needed anymore. - // - if(++_shrinkCounter > 2) - { - reserve(_size); - _shrinkCounter = 0; - } - } - else - { - _shrinkCounter = 0; - } - _size = 0; - } - - void push_back(value_type v) - { - resize(_size + 1); - _buf[_size - 1] = v; - } - - reference operator[](size_type n) - { - assert(n < _size); - return _buf[n]; - } - - const_reference operator[](size_type n) const - { - assert(n < _size); - return _buf[n]; - } + assert(n < _size); + return _buf[n]; + } private: - ICE_API Container(const Container&); - ICE_API void operator=(const Container&); - ICE_API void reserve(size_type); + ICE_API Container(const Container&); + ICE_API void operator=(const Container&); + ICE_API void reserve(size_type); - pointer _buf; - size_type _size; - size_type _capacity; - size_type _maxCapacity; - int _shrinkCounter; + pointer _buf; + size_type _size; + size_type _capacity; + size_type _maxCapacity; + int _shrinkCounter; #ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION - // - // For small buffers, we stack-allocate the memory. Only when - // a buffer size larger than _fixedSize is requested, we - // allocate memory dynamically. - // - value_type _fixed[ICE_BUFFER_FIXED_SIZE]; + // + // For small buffers, we stack-allocate the memory. Only when + // a buffer size larger than _fixedSize is requested, we + // allocate memory dynamically. + // + value_type _fixed[ICE_BUFFER_FIXED_SIZE]; #endif }; diff --git a/cppe/include/IceE/Cond.h b/cppe/include/IceE/Cond.h index b7a4810cc04..34b6b3b7152 100644 --- a/cppe/include/IceE/Cond.h +++ b/cppe/include/IceE/Cond.h @@ -87,11 +87,11 @@ public: template <typename Lock> inline void wait(const Lock& lock) const { - if(!lock.acquired()) - { - throw ThreadLockedException(__FILE__, __LINE__); - } - waitImpl(lock._mutex); + if(!lock.acquired()) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + waitImpl(lock._mutex); } // @@ -104,11 +104,11 @@ public: template <typename Lock> inline bool timedWait(const Lock& lock, const Time& timeout) const { - if(!lock.acquired()) - { - throw ThreadLockedException(__FILE__, __LINE__); - } - return timedWaitImpl(lock._mutex, timeout); + if(!lock.acquired()) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + return timedWaitImpl(lock._mutex, timeout); } private: @@ -204,7 +204,7 @@ Cond::waitImpl(const M& mutex) const if(rc != 0) { - throw ThreadSyscallException(__FILE__, __LINE__, rc); + throw ThreadSyscallException(__FILE__, __LINE__, rc); } } @@ -225,15 +225,15 @@ Cond::timedWaitImpl(const M& mutex, const Time& timeout) const if(rc != 0) { - // - // pthread_cond_timedwait returns ETIMEOUT in the event of a - // timeout. - // - if(rc != ETIMEDOUT) - { - throw ThreadSyscallException(__FILE__, __LINE__, rc); - } - return false; + // + // pthread_cond_timedwait returns ETIMEOUT in the event of a + // timeout. + // + if(rc != ETIMEDOUT) + { + throw ThreadSyscallException(__FILE__, __LINE__, rc); + } + return false; } return true; } diff --git a/cppe/include/IceE/Connection.h b/cppe/include/IceE/Connection.h index 7a76ae59024..6479cc74c97 100644 --- a/cppe/include/IceE/Connection.h +++ b/cppe/include/IceE/Connection.h @@ -52,9 +52,9 @@ public: enum DestructionReason { #ifndef ICEE_PURE_CLIENT - ObjectAdapterDeactivated, + ObjectAdapterDeactivated, #endif - CommunicatorDestroyed + CommunicatorDestroyed }; void activate(); @@ -104,10 +104,10 @@ private: #ifndef ICEE_PURE_CLIENT Connection(const IceInternal::InstancePtr&, const IceInternal::TransceiverPtr&, - const IceInternal::EndpointPtr&, const ObjectAdapterPtr&); + const IceInternal::EndpointPtr&, const ObjectAdapterPtr&); #else Connection(const IceInternal::InstancePtr&, const IceInternal::TransceiverPtr&, - const IceInternal::EndpointPtr&); + const IceInternal::EndpointPtr&); #endif ~Connection(); @@ -118,13 +118,13 @@ private: enum State { - StateNotValidated, - StateActive, + StateNotValidated, + StateActive, #ifndef ICEE_PURE_CLIENT - StateHolding, + StateHolding, #endif - StateClosing, - StateClosed + StateClosing, + StateClosed }; void validate(); @@ -151,13 +151,13 @@ private: class ThreadPerConnection : public IceUtil::Thread { public: - - ThreadPerConnection(const ConnectionPtr&); - virtual void run(); + + ThreadPerConnection(const ConnectionPtr&); + virtual void run(); private: - - ConnectionPtr _connection; + + ConnectionPtr _connection; }; friend class ThreadPerConnection; // Defined as mutable because "isFinished() const" sets this to 0. diff --git a/cppe/include/IceE/DisableWarnings.h b/cppe/include/IceE/DisableWarnings.h index 94cb4761451..d85290e9dcd 100644 --- a/cppe/include/IceE/DisableWarnings.h +++ b/cppe/include/IceE/DisableWarnings.h @@ -21,11 +21,11 @@ // #if defined(_MSC_VER) && _MSC_VER >= 1400 -# define _CRT_SECURE_NO_DEPRECATE 1 // C4996 '<C function>' was declared deprecated/ +# define _CRT_SECURE_NO_DEPRECATE 1 // C4996 '<C function>' was declared deprecated/ #endif #if defined(_MSC_VER) && _MSC_VER >= 1300 -# pragma warning( 4 : 4996 ) // C4996 'std::<function>' was declared deprecated +# pragma warning( 4 : 4996 ) // C4996 'std::<function>' was declared deprecated #endif #endif diff --git a/cppe/include/IceE/FactoryTable.h b/cppe/include/IceE/FactoryTable.h index e10c6135d4a..d5a0cb26698 100644 --- a/cppe/include/IceE/FactoryTable.h +++ b/cppe/include/IceE/FactoryTable.h @@ -23,7 +23,7 @@ public: ~FactoryTable(); }; -static FactoryTable factoryTableInitializer; // Dummy variable to force initialization of factoryTable +static FactoryTable factoryTableInitializer; // Dummy variable to force initialization of factoryTable extern ICE_API FactoryTableDef* factoryTable; diff --git a/cppe/include/IceE/Functional.h b/cppe/include/IceE/Functional.h index a529a8be329..26179a389bc 100644 --- a/cppe/include/IceE/Functional.h +++ b/cppe/include/IceE/Functional.h @@ -32,7 +32,7 @@ public: explicit MemFun(MemberFN p) : _mfn(p) { } R operator()(H handle) const { - return (handle.get() ->* _mfn)(); + return (handle.get() ->* _mfn)(); } }; @@ -47,7 +47,7 @@ public: explicit MemFun1(MemberFN p) : _mfn(p) { } R operator()(H handle, A arg) const { - return (handle.get() ->* _mfn)(arg); + return (handle.get() ->* _mfn)(arg); } }; @@ -62,7 +62,7 @@ public: explicit VoidMemFun(MemberFN p) : _mfn(p) { } void operator()(H handle) const { - (handle.get() ->* _mfn)(); + (handle.get() ->* _mfn)(); } }; @@ -77,7 +77,7 @@ public: explicit VoidMemFun1(MemberFN p) : _mfn(p) { } void operator()(H handle, A arg) const { - (handle.get() ->* _mfn)(arg); + (handle.get() ->* _mfn)(arg); } }; @@ -92,7 +92,7 @@ public: explicit SecondMemFun(MemberFN p) : _mfn(p) { } R operator()(std::pair<K, H> pair) const { - return (pair.second.get() ->* _mfn)(); + return (pair.second.get() ->* _mfn)(); } }; @@ -107,7 +107,7 @@ public: explicit SecondMemFun1(MemberFN p) : _mfn(p) { } R operator()(std::pair<K, H> pair, A arg) const { - return (pair.second.get() ->* _mfn)(arg); + return (pair.second.get() ->* _mfn)(arg); } }; @@ -122,7 +122,7 @@ public: explicit SecondVoidMemFun(MemberFN p) : _mfn(p) { } void operator()(std::pair<K, H> pair) const { - (pair.second.get() ->* _mfn)(); + (pair.second.get() ->* _mfn)(); } }; @@ -137,7 +137,7 @@ public: explicit SecondVoidMemFun1(MemberFN p) : _mfn(p) { } void operator()(std::pair<K, H> pair, A arg) const { - (pair.second.get() ->* _mfn)(arg); + (pair.second.get() ->* _mfn)(arg); } }; @@ -152,7 +152,7 @@ public: explicit ConstMemFun(MemberFN p) : _mfn(p) { } R operator()(H handle) const { - return (handle.get() ->* _mfn)(); + return (handle.get() ->* _mfn)(); } }; @@ -167,7 +167,7 @@ public: explicit ConstMemFun1(MemberFN p) : _mfn(p) { } R operator()(H handle, A arg) const { - return (handle.get() ->* _mfn)(arg); + return (handle.get() ->* _mfn)(arg); } }; @@ -182,7 +182,7 @@ public: explicit ConstVoidMemFun(MemberFN p) : _mfn(p) { } void operator()(H handle) const { - (handle.get() ->* _mfn)(); + (handle.get() ->* _mfn)(); } }; @@ -197,7 +197,7 @@ public: explicit ConstVoidMemFun1(MemberFN p) : _mfn(p) { } void operator()(H handle, A arg) const { - (handle.get() ->* _mfn)(arg); + (handle.get() ->* _mfn)(arg); } }; @@ -212,7 +212,7 @@ public: explicit SecondConstMemFun(MemberFN p) : _mfn(p) { } R operator()(std::pair<K, H> pair) const { - return (pair.second.get() ->* _mfn)(); + return (pair.second.get() ->* _mfn)(); } }; @@ -227,7 +227,7 @@ public: explicit SecondConstMemFun1(MemberFN p) : _mfn(p) { } R operator()(std::pair<K, H> pair, A arg) const { - return (pair.second.get() ->* _mfn)(arg); + return (pair.second.get() ->* _mfn)(arg); } }; @@ -242,7 +242,7 @@ public: explicit SecondConstVoidMemFun(MemberFN p) : _mfn(p) { } void operator()(std::pair<K, H> pair) const { - (pair.second.get() ->* _mfn)(); + (pair.second.get() ->* _mfn)(); } }; @@ -257,7 +257,7 @@ public: explicit SecondConstVoidMemFun1(MemberFN p) : _mfn(p) { } void operator()(std::pair<K, H> pair, A arg) const { - (pair.second.get() ->* _mfn)(arg); + (pair.second.get() ->* _mfn)(arg); } }; diff --git a/cppe/include/IceE/Handle.h b/cppe/include/IceE/Handle.h index f9947c09974..1f29a6290ab 100644 --- a/cppe/include/IceE/Handle.h +++ b/cppe/include/IceE/Handle.h @@ -29,51 +29,51 @@ public: T* get() const { - return _ptr; + return _ptr; } T* operator->() const { - if(!_ptr) - { - // - // We don't throw directly NullHandleException here to - // keep the code size of this method to a minimun (the - // assembly code for throwing an exception is much bigger - // than just a function call). This maximises the chances - // of inlining by compiler optimization. - // - throwNullHandleException(__FILE__, __LINE__); - } - - return _ptr; + if(!_ptr) + { + // + // We don't throw directly NullHandleException here to + // keep the code size of this method to a minimun (the + // assembly code for throwing an exception is much bigger + // than just a function call). This maximises the chances + // of inlining by compiler optimization. + // + throwNullHandleException(__FILE__, __LINE__); + } + + return _ptr; } T& operator*() const { - if(!_ptr) - { - // - // We don't throw directly NullHandleException here to - // keep the code size of this method to a minimun (the - // assembly code for throwing an exception is much bigger - // than just a function call). This maximises the chances - // of inlining by compiler optimization. - // - throwNullHandleException(__FILE__, __LINE__); - } - - return *_ptr; + if(!_ptr) + { + // + // We don't throw directly NullHandleException here to + // keep the code size of this method to a minimun (the + // assembly code for throwing an exception is much bigger + // than just a function call). This maximises the chances + // of inlining by compiler optimization. + // + throwNullHandleException(__FILE__, __LINE__); + } + + return *_ptr; } operator bool() const { - return _ptr ? true : false; + return _ptr ? true : false; } void swap(HandleBase& other) { - std::swap(_ptr, other._ptr); + std::swap(_ptr, other._ptr); } T* _ptr; @@ -96,12 +96,12 @@ inline bool operator==(const HandleBase<T>& lhs, const HandleBase<U>& rhs) U* r = rhs.get(); if(l && r) { - return *l == *r; + return *l == *r; } else { - return !l && !r; - } + return !l && !r; + } } template<typename T, typename U> @@ -117,11 +117,11 @@ inline bool operator<(const HandleBase<T>& lhs, const HandleBase<U>& rhs) U* r = rhs.get(); if(l && r) { - return *l < *r; + return *l < *r; } else { - return !l && r; + return !l && r; } } @@ -150,114 +150,114 @@ public: Handle(T* p = 0) { - this->_ptr = p; + this->_ptr = p; - if(this->_ptr) - { - this->_ptr->__incRef(); - } + if(this->_ptr) + { + this->_ptr->__incRef(); + } } template<typename Y> Handle(const Handle<Y>& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - this->_ptr->__incRef(); - } + if(this->_ptr) + { + this->_ptr->__incRef(); + } } Handle(const Handle& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - this->_ptr->__incRef(); - } + if(this->_ptr) + { + this->_ptr->__incRef(); + } } ~Handle() { - if(this->_ptr) - { - this->_ptr->__decRef(); - } + if(this->_ptr) + { + this->_ptr->__decRef(); + } } Handle& operator=(T* p) { - if(this->_ptr != p) - { - if(p) - { - p->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = p; - - if(ptr) - { - ptr->__decRef(); - } - } - return *this; + if(this->_ptr != p) + { + if(p) + { + p->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = p; + + if(ptr) + { + ptr->__decRef(); + } + } + return *this; } template<typename Y> Handle& operator=(const Handle<Y>& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - r._ptr->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = r._ptr; - - if(ptr) - { - ptr->__decRef(); - } - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + r._ptr->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = r._ptr; + + if(ptr) + { + ptr->__decRef(); + } + } + return *this; } Handle& operator=(const Handle& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - r._ptr->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = r._ptr; - - if(ptr) - { - ptr->__decRef(); - } - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + r._ptr->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = r._ptr; + + if(ptr) + { + ptr->__decRef(); + } + } + return *this; } template<class Y> static Handle dynamicCast(const HandleBase<Y>& r) { - return Handle(dynamic_cast<T*>(r._ptr)); + return Handle(dynamic_cast<T*>(r._ptr)); } template<class Y> static Handle dynamicCast(Y* p) { - return Handle(dynamic_cast<T*>(p)); + return Handle(dynamic_cast<T*>(p)); } }; @@ -284,146 +284,146 @@ public: Handle(T* p = 0) { - this->_ptr = p; + this->_ptr = p; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } template<typename Y> Handle(const Handle<Y>& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } template<typename Y> Handle(const ::IceUtil::Handle<Y>& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } Handle(const Handle& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } ~Handle() { - if(this->_ptr) - { - upCast(this->_ptr)->__decRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__decRef(); + } } Handle& operator=(T* p) { - if(this->_ptr != p) - { - if(p) - { - upCast(p)->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = p; - - if(ptr) - { - upCast(ptr)->__decRef(); - } - } - return *this; + if(this->_ptr != p) + { + if(p) + { + upCast(p)->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = p; + + if(ptr) + { + upCast(ptr)->__decRef(); + } + } + return *this; } template<typename Y> Handle& operator=(const Handle<Y>& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { + if(this->_ptr != r._ptr) + { + if(r._ptr) + { upCast(r._ptr)->__incRef(); - } + } - T* ptr = this->_ptr; - this->_ptr = r._ptr; + T* ptr = this->_ptr; + this->_ptr = r._ptr; - if(ptr) - { - upCast(ptr)->__decRef(); - } - } - return *this; + if(ptr) + { + upCast(ptr)->__decRef(); + } + } + return *this; } template<typename Y> Handle& operator=(const ::IceUtil::Handle<Y>& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - upCast(r._ptr)->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = r._ptr; - - if(ptr) - { - upCast(ptr)->__decRef(); - } - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + upCast(r._ptr)->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = r._ptr; + + if(ptr) + { + upCast(ptr)->__decRef(); + } + } + return *this; } Handle& operator=(const Handle& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - upCast(r._ptr)->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = r._ptr; - - if(ptr) - { - upCast(ptr)->__decRef(); - } - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + upCast(r._ptr)->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = r._ptr; + + if(ptr) + { + upCast(ptr)->__decRef(); + } + } + return *this; } template<class Y> static Handle dynamicCast(const ::IceUtil::HandleBase<Y>& r) { - return Handle(dynamic_cast<T*>(r._ptr)); + return Handle(dynamic_cast<T*>(r._ptr)); } template<class Y> static Handle dynamicCast(Y* p) { - return Handle(dynamic_cast<T*>(p)); + return Handle(dynamic_cast<T*>(p)); } }; diff --git a/cppe/include/IceE/Initialize.h b/cppe/include/IceE/Initialize.h index 31f1d828ac8..d2c54a88706 100644 --- a/cppe/include/IceE/Initialize.h +++ b/cppe/include/IceE/Initialize.h @@ -55,10 +55,10 @@ struct InitializationData }; ICE_API CommunicatorPtr initialize(int&, char*[], const InitializationData& = InitializationData(), - Int = ICEE_INT_VERSION); + Int = ICEE_INT_VERSION); ICE_API CommunicatorPtr initialize(StringSeq&, const InitializationData& = InitializationData(), - Int = ICEE_INT_VERSION); + Int = ICEE_INT_VERSION); ICE_API CommunicatorPtr initialize(const InitializationData& = InitializationData(), Int = ICEE_INT_VERSION); diff --git a/cppe/include/IceE/Lock.h b/cppe/include/IceE/Lock.h index e2e1baef852..36d754066cb 100644 --- a/cppe/include/IceE/Lock.h +++ b/cppe/include/IceE/Lock.h @@ -44,63 +44,63 @@ class LockT public: LockT(const T& mutex) : - _mutex(mutex) + _mutex(mutex) { - _mutex.lock(); - _acquired = true; + _mutex.lock(); + _acquired = true; } ~LockT() { - if (_acquired) - { - _mutex.unlock(); - } + if (_acquired) + { + _mutex.unlock(); + } } void acquire() const { - if (_acquired) - { - throw ThreadLockedException(__FILE__, __LINE__); - } - _mutex.lock(); - _acquired = true; + if (_acquired) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + _mutex.lock(); + _acquired = true; } bool tryAcquire() const { - if (_acquired) - { - throw ThreadLockedException(__FILE__, __LINE__); - } - _acquired = _mutex.tryLock(); - return _acquired; + if (_acquired) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + _acquired = _mutex.tryLock(); + return _acquired; } void release() const { - if (!_acquired) - { - throw ThreadLockedException(__FILE__, __LINE__); - } - _mutex.unlock(); - _acquired = false; + if (!_acquired) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + _mutex.unlock(); + _acquired = false; } bool acquired() const { - return _acquired; + return _acquired; } protected: // TryLockT's contructor LockT(const T& mutex, bool) : - _mutex(mutex) + _mutex(mutex) { - _acquired = _mutex.tryLock(); + _acquired = _mutex.tryLock(); } private: @@ -126,7 +126,7 @@ class TryLockT : public LockT<T> public: TryLockT(const T& mutex) : - LockT<T>(mutex, true) + LockT<T>(mutex, true) {} }; diff --git a/cppe/include/IceE/Monitor.h b/cppe/include/IceE/Monitor.h index 6d83ce18ffd..54993ec3c69 100644 --- a/cppe/include/IceE/Monitor.h +++ b/cppe/include/IceE/Monitor.h @@ -89,11 +89,11 @@ IceUtil::Monitor<T>::lock() const _mutex.lock(); if(_mutex.willUnlock()) { - // - // On the first mutex acquisition reset the number pending - // notifications. - // - _nnotify = 0; + // + // On the first mutex acquisition reset the number pending + // notifications. + // + _nnotify = 0; } } @@ -102,13 +102,13 @@ IceUtil::Monitor<T>::unlock() const { if(_mutex.willUnlock()) { - // - // Perform any pending notifications. - // - if(_nnotify != 0) - { - notifyImpl(_nnotify); - } + // + // Perform any pending notifications. + // + if(_nnotify != 0) + { + notifyImpl(_nnotify); + } } _mutex.unlock(); @@ -116,12 +116,12 @@ IceUtil::Monitor<T>::unlock() const int nnotify = _nnotify; if(_mutex.unlock()) { - // - // Perform any pending notifications. - // - if(nnotify != 0) + // + // Perform any pending notifications. + // + if(nnotify != 0) { - notifyImpl(nnotify); + notifyImpl(nnotify); } } */ @@ -133,11 +133,11 @@ IceUtil::Monitor<T>::tryLock() const bool result = _mutex.tryLock(); if(result && _mutex.willUnlock()) { - // - // On the first mutex acquisition reset the number pending - // notifications. - // - _nnotify = 0; + // + // On the first mutex acquisition reset the number pending + // notifications. + // + _nnotify = 0; } return result; } @@ -150,7 +150,7 @@ IceUtil::Monitor<T>::wait() const // if(_nnotify != 0) { - notifyImpl(_nnotify); + notifyImpl(_nnotify); } // @@ -158,15 +158,15 @@ IceUtil::Monitor<T>::wait() const // try { - _cond.waitImpl(_mutex); - // - // Reset the nnotify count once wait() returns. - // + _cond.waitImpl(_mutex); + // + // Reset the nnotify count once wait() returns. + // } catch(...) { - _nnotify = 0; - throw; + _nnotify = 0; + throw; } _nnotify = 0; @@ -180,7 +180,7 @@ IceUtil::Monitor<T>::timedWait(const Time& timeout) const // if(_nnotify != 0) { - notifyImpl(_nnotify); + notifyImpl(_nnotify); } bool rc; @@ -189,16 +189,16 @@ IceUtil::Monitor<T>::timedWait(const Time& timeout) const // try { - rc = _cond.timedWaitImpl(_mutex, timeout); + rc = _cond.timedWaitImpl(_mutex, timeout); - // - // Reset the nnotify count once wait() returns. - // + // + // Reset the nnotify count once wait() returns. + // } catch(...) { - _nnotify = 0; - throw; + _nnotify = 0; + throw; } _nnotify = 0; @@ -214,7 +214,7 @@ IceUtil::Monitor<T>::notify() // if(_nnotify != -1) { - ++_nnotify; + ++_nnotify; } } @@ -236,19 +236,19 @@ IceUtil::Monitor<T>::notifyImpl(int nnotify) const // if(nnotify == -1) { - _cond.broadcast(); - return; + _cond.broadcast(); + return; } else { - // - // Otherwise notify n times. - // - while(nnotify > 0) - { - _cond.signal(); - --nnotify; - } + // + // Otherwise notify n times. + // + while(nnotify > 0) + { + _cond.signal(); + --nnotify; + } } } diff --git a/cppe/include/IceE/Mutex.h b/cppe/include/IceE/Mutex.h index 67d131abcde..08a80bec3c0 100644 --- a/cppe/include/IceE/Mutex.h +++ b/cppe/include/IceE/Mutex.h @@ -87,7 +87,7 @@ private: #else struct LockState { - pthread_mutex_t* mutex; + pthread_mutex_t* mutex; }; #endif @@ -140,11 +140,11 @@ Mutex::tryLock() const { if(!TryEnterCriticalSection(&_mutex)) { - return false; + return false; } if(_mutex.RecursionCount > 1) { - LeaveCriticalSection(&_mutex); + LeaveCriticalSection(&_mutex); throw ThreadLockedException(__FILE__, __LINE__); } return true; @@ -178,7 +178,7 @@ Mutex::Mutex() : _mutex = CreateMutex(0, false, 0); if(_mutex == 0) { - throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); + throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); } } @@ -188,7 +188,7 @@ Mutex::~Mutex() BOOL rc = CloseHandle(_mutex); if(rc == 0) { - throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); + throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); } } @@ -198,14 +198,14 @@ Mutex::lock() const DWORD rc = WaitForSingleObject(_mutex, INFINITE); if(rc != WAIT_OBJECT_0) { - if(rc == WAIT_FAILED) - { - throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); - } - else - { - throw ThreadSyscallException(__FILE__, __LINE__, 0); - } + if(rc == WAIT_FAILED) + { + throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); + } + else + { + throw ThreadSyscallException(__FILE__, __LINE__, 0); + } } _recursionCount++; } @@ -216,18 +216,18 @@ Mutex::tryLock() const DWORD rc = WaitForSingleObject(_mutex, 0); if(rc != WAIT_OBJECT_0) { - return false; + return false; } else if(_recursionCount == 1) { - _recursionCount++; - unlock(); + _recursionCount++; + unlock(); throw ThreadLockedException(__FILE__, __LINE__); } else { - _recursionCount++; - return true; + _recursionCount++; + return true; } } @@ -238,7 +238,7 @@ Mutex::unlock() const BOOL rc = ReleaseMutex(_mutex); if(rc == 0) { - throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); + throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); } } @@ -287,7 +287,7 @@ Mutex::Mutex() if(rc != 0) { - throw ThreadSyscallException(__FILE__, __LINE__, rc); + throw ThreadSyscallException(__FILE__, __LINE__, rc); } } @@ -340,7 +340,7 @@ Mutex::unlock() const int rc = pthread_mutex_unlock(&_mutex); if(rc != 0) { - throw ThreadSyscallException(__FILE__, __LINE__, rc); + throw ThreadSyscallException(__FILE__, __LINE__, rc); } } diff --git a/cppe/include/IceE/Object.h b/cppe/include/IceE/Object.h index 11fe467c968..b8cd0bf0727 100644 --- a/cppe/include/IceE/Object.h +++ b/cppe/include/IceE/Object.h @@ -65,10 +65,10 @@ protected: static void __checkMode(OperationMode expected, OperationMode received) // Inline for performance reasons. { - if(expected != received) - { - __invalidMode(expected, received); // Not inlined. - } + if(expected != received) + { + __invalidMode(expected, received); // Not inlined. + } } static void __invalidMode(OperationMode, OperationMode); }; diff --git a/cppe/include/IceE/ObjectAdapter.h b/cppe/include/IceE/ObjectAdapter.h index 5d44274bd3b..3eb4d4a226f 100644 --- a/cppe/include/IceE/ObjectAdapter.h +++ b/cppe/include/IceE/ObjectAdapter.h @@ -91,11 +91,11 @@ public: private: ObjectAdapter(const IceInternal::InstancePtr&, const CommunicatorPtr&, const IceInternal::ObjectAdapterFactoryPtr&, - const std::string&, const std::string& + const std::string&, const std::string& #ifdef ICEE_HAS_ROUTER - , const RouterPrx& + , const RouterPrx& #endif - ); + ); ~ObjectAdapter(); friend class IceInternal::ObjectAdapterFactory; diff --git a/cppe/include/IceE/Outgoing.h b/cppe/include/IceE/Outgoing.h index 55ae1f42094..3e52544a35f 100644 --- a/cppe/include/IceE/Outgoing.h +++ b/cppe/include/IceE/Outgoing.h @@ -61,11 +61,11 @@ public: enum State { - StateUnsent, - StateInProgress, - StateOK, - StateUserException, - StateLocalException + StateUnsent, + StateInProgress, + StateOK, + StateUserException, + StateLocalException }; Outgoing(Ice::Connection*, Reference*, const std::string&, Ice::OperationMode, const Ice::Context*); diff --git a/cppe/include/IceE/Proxy.h b/cppe/include/IceE/Proxy.h index 99439e0f359..74c88f220a3 100644 --- a/cppe/include/IceE/Proxy.h +++ b/cppe/include/IceE/Proxy.h @@ -97,13 +97,13 @@ public: ICE_DEPRECATED_API ::Ice::Int ice_hash() const { - return ice_getHash(); + return ice_getHash(); } ICE_API ::Ice::Int ice_getHash() const; ICE_DEPRECATED_API ::Ice::CommunicatorPtr ice_communicator() const { - return ice_getCommunicator(); + return ice_getCommunicator(); } ICE_API ::Ice::CommunicatorPtr ice_getCommunicator() const; @@ -148,21 +148,21 @@ public: ICE_API ::Ice::Identity ice_getIdentity() const; ICE_DEPRECATED_API ::Ice::ObjectPrx ice_newIdentity(const ::Ice::Identity& id) const { - return ice_identity(id); + return ice_identity(id); } ICE_API ::Ice::ObjectPrx ice_identity(const ::Ice::Identity&) const; ICE_API ::Ice::Context ice_getContext() const; ICE_DEPRECATED_API ::Ice::ObjectPrx ice_newContext(const ::Ice::Context& ctx) const { - return ice_context(ctx); + return ice_context(ctx); } ICE_API ::Ice::ObjectPrx ice_context(const ::Ice::Context&) const; ICE_API const ::std::string& ice_getFacet() const; ICE_DEPRECATED_API ::Ice::ObjectPrx ice_newFacet(const ::std::string& facet) const { - return ice_facet(facet); + return ice_facet(facet); } ICE_API ::Ice::ObjectPrx ice_facet(const ::std::string&) const; @@ -226,14 +226,14 @@ public: ICE_DEPRECATED_API ::Ice::ConnectionPtr ice_connection() { - return ice_getConnection(); + return ice_getConnection(); } ICE_API ::Ice::ConnectionPtr ice_getConnection(); ICE_API ::Ice::ConnectionPtr ice_getCachedConnection() const; ::IceInternal::ReferencePtr __reference() const { - return _reference; + return _reference; } ICE_API void __copyFrom(const ::Ice::ObjectPrx&); @@ -258,15 +258,15 @@ private: void setup(const ::IceInternal::ReferencePtr& ref) { - // - // No need to synchronize "*this", as this operation is only - // called upon initialization. - // - - assert(!_reference); - assert(!_connection); - - _reference = ref; + // + // No need to synchronize "*this", as this operation is only + // called upon initialization. + // + + assert(!_reference); + assert(!_connection); + + _reference = ref; } friend class ::IceInternal::ProxyFactory; @@ -288,7 +288,7 @@ struct ProxyIdentityLess : std::binary_function<bool, ObjectPrx&, ObjectPrx&> { bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const { - return proxyIdentityLess(lhs, rhs); + return proxyIdentityLess(lhs, rhs); } }; @@ -296,7 +296,7 @@ struct ProxyIdentityEqual : std::binary_function<bool, ObjectPrx&, ObjectPrx&> { bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const { - return proxyIdentityEqual(lhs, rhs); + return proxyIdentityEqual(lhs, rhs); } }; @@ -304,7 +304,7 @@ struct ProxyIdentityAndFacetLess : std::binary_function<bool, ObjectPrx&, Object { bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const { - return proxyIdentityAndFacetLess(lhs, rhs); + return proxyIdentityAndFacetLess(lhs, rhs); } }; @@ -312,7 +312,7 @@ struct ProxyIdentityAndFacetEqual : std::binary_function<bool, ObjectPrx&, Objec { bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const { - return proxyIdentityAndFacetEqual(lhs, rhs); + return proxyIdentityAndFacetEqual(lhs, rhs); } }; @@ -391,14 +391,14 @@ checkedCastImpl(const ::Ice::ObjectPrx& b) P d = 0; if(b.get()) { - typedef typename P::element_type T; + typedef typename P::element_type T; - d = dynamic_cast<T*>(b.get()); - if(!d && b->ice_isA(T::ice_staticId())) - { - d = new T; - d->__copyFrom(b); - } + d = dynamic_cast<T*>(b.get()); + if(!d && b->ice_isA(T::ice_staticId())) + { + d = new T; + d->__copyFrom(b); + } } return d; } @@ -409,14 +409,14 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const ::Ice::Context& ctx) P d = 0; if(b.get()) { - typedef typename P::element_type T; + typedef typename P::element_type T; - d = dynamic_cast<T*>(b.get()); - if(!d && b->ice_isA(T::ice_staticId(), ctx)) - { - d = new T; - d->__copyFrom(b); - } + d = dynamic_cast<T*>(b.get()); + if(!d && b->ice_isA(T::ice_staticId(), ctx)) + { + d = new T; + d->__copyFrom(b); + } } return d; } @@ -427,14 +427,14 @@ uncheckedCastImpl(const ::Ice::ObjectPrx& b) P d = 0; if(b) { - typedef typename P::element_type T; + typedef typename P::element_type T; - d = dynamic_cast<T*>(b.get()); - if(!d) - { - d = new T; - d->__copyFrom(b); - } + d = dynamic_cast<T*>(b.get()); + if(!d) + { + d = new T; + d->__copyFrom(b); + } } return d; } @@ -473,7 +473,7 @@ uncheckedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::strin ::Ice::ObjectPrx d = 0; if(b) { - d = b->ice_facet(f); + d = b->ice_facet(f); } return d; } @@ -488,8 +488,8 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f) if(bb) { - d = new T; - d->__copyFrom(bb); + d = new T; + d->__copyFrom(bb); } return d; } @@ -504,8 +504,8 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Co if(bb) { - d = new T; - d->__copyFrom(bb); + d = new T; + d->__copyFrom(bb); } return d; } @@ -516,11 +516,11 @@ uncheckedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f) P d = 0; if(b) { - typedef typename P::element_type T; + typedef typename P::element_type T; - ::Ice::ObjectPrx bb = b->ice_facet(f); - d = new T; - d->__copyFrom(bb); + ::Ice::ObjectPrx bb = b->ice_facet(f); + d = new T; + d->__copyFrom(bb); } return d; } diff --git a/cppe/include/IceE/ProxyHandle.h b/cppe/include/IceE/ProxyHandle.h index 1dbf3743dea..3c04cf444d5 100644 --- a/cppe/include/IceE/ProxyHandle.h +++ b/cppe/include/IceE/ProxyHandle.h @@ -131,130 +131,130 @@ public: ProxyHandle(T* p = 0) { - this->_ptr = p; + this->_ptr = p; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } template<typename Y> ProxyHandle(const ProxyHandle<Y>& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } template<typename Y> ProxyHandle(const ::IceUtil::Handle<Y>& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } ProxyHandle(const ProxyHandle& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - upCast(this->_ptr)->__incRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__incRef(); + } } ~ProxyHandle() { - if(this->_ptr) - { - upCast(this->_ptr)->__decRef(); - } + if(this->_ptr) + { + upCast(this->_ptr)->__decRef(); + } } ProxyHandle& operator=(T* p) { - if(this->_ptr != p) - { - if(p) - { - upCast(p)->__incRef(); - } - - if(this->_ptr) - { - upCast(this->_ptr)->__decRef(); - } - - this->_ptr = p; - } - return *this; + if(this->_ptr != p) + { + if(p) + { + upCast(p)->__incRef(); + } + + if(this->_ptr) + { + upCast(this->_ptr)->__decRef(); + } + + this->_ptr = p; + } + return *this; } template<typename Y> ProxyHandle& operator=(const ProxyHandle<Y>& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - upCast(r._ptr)->__incRef(); - } - - if(this->_ptr) - { - upCast(this->_ptr)->__decRef(); - } - - this->_ptr = r._ptr; - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + upCast(r._ptr)->__incRef(); + } + + if(this->_ptr) + { + upCast(this->_ptr)->__decRef(); + } + + this->_ptr = r._ptr; + } + return *this; } template<typename Y> ProxyHandle& operator=(const ::IceUtil::Handle<Y>& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - upCast(r._ptr)->__incRef(); - } - - if(this->_ptr) - { - upCast(this->_ptr)->__decRef(); - } - - this->_ptr = r._ptr; - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + upCast(r._ptr)->__incRef(); + } + + if(this->_ptr) + { + upCast(this->_ptr)->__decRef(); + } + + this->_ptr = r._ptr; + } + return *this; } ProxyHandle& operator=(const ProxyHandle& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - upCast(r._ptr)->__incRef(); - } - - if(this->_ptr) - { - upCast(this->_ptr)->__decRef(); - } - - this->_ptr = r._ptr; - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + upCast(r._ptr)->__incRef(); + } + + if(this->_ptr) + { + upCast(this->_ptr)->__decRef(); + } + + this->_ptr = r._ptr; + } + return *this; } ::IceProxy::Ice::Object* __upCast() const @@ -265,39 +265,39 @@ public: template<class Y> static ProxyHandle checkedCast(const ProxyHandle<Y>& r) { - Y* tag = 0; - return ::IceInternal::checkedCastHelper<T>(r, tag); + Y* tag = 0; + return ::IceInternal::checkedCastHelper<T>(r, tag); } template<class Y> static ProxyHandle checkedCast(const ProxyHandle<Y>& r, const std::string& f) { - return ::IceInternal::checkedCastImpl<ProxyHandle>(r, f); + return ::IceInternal::checkedCastImpl<ProxyHandle>(r, f); } template<class Y> static ProxyHandle checkedCast(const ProxyHandle<Y>& r, const ::Ice::Context& ctx) { - return ::IceInternal::checkedCastHelper<T>(r, ctx); + return ::IceInternal::checkedCastHelper<T>(r, ctx); } template<class Y> static ProxyHandle checkedCast(const ProxyHandle<Y>& r, const std::string& f, const ::Ice::Context& ctx) { - return ::IceInternal::checkedCastImpl<ProxyHandle>(r, f, ctx); + return ::IceInternal::checkedCastImpl<ProxyHandle>(r, f, ctx); } template<class Y> static ProxyHandle uncheckedCast(const ProxyHandle<Y>& r) { - Y* tag = 0; - return::IceInternal::uncheckedCastHelper<T>(r, tag); + Y* tag = 0; + return::IceInternal::uncheckedCastHelper<T>(r, tag); } template<class Y> static ProxyHandle uncheckedCast(const ProxyHandle<Y>& r, const std::string& f) { - return ::IceInternal::uncheckedCastImpl<ProxyHandle>(r, f); + return ::IceInternal::uncheckedCastImpl<ProxyHandle>(r, f); } }; diff --git a/cppe/include/IceE/RecMutex.h b/cppe/include/IceE/RecMutex.h index 20cc59b9eb4..48cee28f5b8 100644 --- a/cppe/include/IceE/RecMutex.h +++ b/cppe/include/IceE/RecMutex.h @@ -77,13 +77,13 @@ private: #ifdef _WIN32 struct LockState { - int count; + int count; }; #else struct LockState { - pthread_mutex_t* mutex; - int count; + pthread_mutex_t* mutex; + int count; }; #endif diff --git a/cppe/include/IceE/ScopedArray.h b/cppe/include/IceE/ScopedArray.h index 7b40d3736a6..5d8a72b99ea 100644 --- a/cppe/include/IceE/ScopedArray.h +++ b/cppe/include/IceE/ScopedArray.h @@ -28,25 +28,25 @@ public: ~ScopedArray() { if(_ptr != 0) - { - delete[] _ptr; - } + { + delete[] _ptr; + } } void reset(T* ptr = 0) { - assert(ptr == 0 || ptr != _ptr); + assert(ptr == 0 || ptr != _ptr); if(_ptr != 0) - { - delete[] _ptr; - } - _ptr = ptr; + { + delete[] _ptr; + } + _ptr = ptr; } T& operator[](size_t i) const { - assert(_ptr != 0); - assert(i >= 0); + assert(_ptr != 0); + assert(i >= 0); return _ptr[i]; } @@ -58,8 +58,8 @@ public: void swap(ScopedArray& a) { T* tmp = a._ptr; - a._ptr = _ptr; - _ptr = tmp; + a._ptr = _ptr; + _ptr = tmp; } private: diff --git a/cppe/include/IceE/Shared.h b/cppe/include/IceE/Shared.h index 7df23f2214a..6db635520ea 100644 --- a/cppe/include/IceE/Shared.h +++ b/cppe/include/IceE/Shared.h @@ -61,9 +61,9 @@ inline void ice_atomic_set(ice_atomic_t* v, int i) inline void ice_atomic_inc(ice_atomic_t *v) { __asm__ __volatile__( - "lock ; incl %0" - :"=m" (v->counter) - :"m" (v->counter)); + "lock ; incl %0" + :"=m" (v->counter) + :"m" (v->counter)); } /** @@ -80,9 +80,9 @@ inline int ice_atomic_dec_and_test(ice_atomic_t *v) { unsigned char c; __asm__ __volatile__( - "lock ; decl %0; sete %1" - :"=m" (v->counter), "=qm" (c) - :"m" (v->counter) : "memory"); + "lock ; decl %0; sete %1" + :"=m" (v->counter), "=qm" (c) + :"m" (v->counter) : "memory"); return c != 0; } @@ -97,10 +97,10 @@ inline int ice_atomic_exchange_add(int i, ice_atomic_t* v) { int tmp = i; __asm__ __volatile__( - "lock ; xadd %0,(%2)" - :"+r"(tmp), "=m"(v->counter) - :"r"(v), "m"(v->counter) - : "memory"); + "lock ; xadd %0,(%2)" + :"+r"(tmp), "=m"(v->counter) + :"r"(v), "m"(v->counter) + : "memory"); return tmp + i; } @@ -147,31 +147,31 @@ public: void __incRef() { - assert(_ref >= 0); - ++_ref; + assert(_ref >= 0); + ++_ref; } void __decRef() { - assert(_ref > 0); - if(--_ref == 0) - { - if(!_noDelete) - { - _noDelete = true; - delete this; - } - } + assert(_ref > 0); + if(--_ref == 0) + { + if(!_noDelete) + { + _noDelete = true; + delete this; + } + } } int __getRef() const { - return _ref; + return _ref; } void __setNoDelete(bool b) { - _noDelete = b; + _noDelete = b; } private: @@ -199,49 +199,49 @@ public: void __incRef() { #if defined(_WIN32) - assert(InterlockedExchangeAdd(&_ref, 0) >= 0); - InterlockedIncrement(&_ref); + assert(InterlockedExchangeAdd(&_ref, 0) >= 0); + InterlockedIncrement(&_ref); #elif defined(ICEE_HAS_ATOMIC_FUNCTIONS) - assert(ice_atomic_exchange_add(0, &_ref) >= 0); - ice_atomic_inc(&_ref); + assert(ice_atomic_exchange_add(0, &_ref) >= 0); + ice_atomic_inc(&_ref); #else - _mutex.lock(); - assert(_ref >= 0); - ++_ref; - _mutex.unlock(); + _mutex.lock(); + assert(_ref >= 0); + ++_ref; + _mutex.unlock(); #endif } void __decRef() { #if defined(_WIN32) - assert(InterlockedExchangeAdd(&_ref, 0) > 0); - if(InterlockedDecrement(&_ref) == 0 && !_noDelete) - { - _noDelete = true; - delete this; - } + assert(InterlockedExchangeAdd(&_ref, 0) > 0); + if(InterlockedDecrement(&_ref) == 0 && !_noDelete) + { + _noDelete = true; + delete this; + } #elif defined(ICEE_HAS_ATOMIC_FUNCTIONS) - assert(ice_atomic_exchange_add(0, &_ref) > 0); - if(ice_atomic_dec_and_test(&_ref) && !_noDelete) - { - _noDelete = true; - delete this; - } + assert(ice_atomic_exchange_add(0, &_ref) > 0); + if(ice_atomic_dec_and_test(&_ref) && !_noDelete) + { + _noDelete = true; + delete this; + } #else - _mutex.lock(); - bool doDelete = false; - assert(_ref > 0); - if(--_ref == 0) - { - doDelete = !_noDelete; - _noDelete = true; - } - _mutex.unlock(); - if(doDelete) - { - delete this; - } + _mutex.lock(); + bool doDelete = false; + assert(_ref > 0); + if(--_ref == 0) + { + doDelete = !_noDelete; + _noDelete = true; + } + _mutex.unlock(); + if(doDelete) + { + delete this; + } #endif } diff --git a/cppe/include/IceE/StaticMutex.h b/cppe/include/IceE/StaticMutex.h index a30fd67a90f..b69c7fadc03 100644 --- a/cppe/include/IceE/StaticMutex.h +++ b/cppe/include/IceE/StaticMutex.h @@ -88,7 +88,7 @@ private: #else struct LockState { - pthread_mutex_t* mutex; + pthread_mutex_t* mutex; }; #endif @@ -141,7 +141,7 @@ StaticMutex::lock() const { if(!initialized()) { - initialize(); + initialize(); } EnterCriticalSection(_mutex); #ifndef _WIN32_WCE @@ -154,16 +154,16 @@ StaticMutex::tryLock() const { if(!initialized()) { - initialize(); + initialize(); } if(!TryEnterCriticalSection(_mutex)) { - return false; + return false; } #ifndef _WIN32_WCE if(_mutex->RecursionCount > 1) { - LeaveCriticalSection(_mutex); + LeaveCriticalSection(_mutex); throw ThreadLockedException(__FILE__, __LINE__); } #endif @@ -195,7 +195,7 @@ StaticMutex::lock(LockState&) const { if(!initialized()) { - initialize(); + initialize(); } EnterCriticalSection(_mutex); } @@ -243,7 +243,7 @@ StaticMutex::unlock() const int rc = pthread_mutex_unlock(&_mutex); if(rc != 0) { - throw ThreadSyscallException(__FILE__, __LINE__, rc); + throw ThreadSyscallException(__FILE__, __LINE__, rc); } } diff --git a/cppe/include/IceE/StringConverter.h b/cppe/include/IceE/StringConverter.h index 649bd65c6af..d2e2f7eaec1 100644 --- a/cppe/include/IceE/StringConverter.h +++ b/cppe/include/IceE/StringConverter.h @@ -50,13 +50,13 @@ public: // past the last byte returned by getMoreBytes). // virtual Byte* toUTF8(const charT* sourceStart, const charT* sourceEnd, - UTF8Buffer&) const = 0; + UTF8Buffer&) const = 0; // // Unmarshals a UTF-8 sequence into a basic_string // virtual void fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, - std::basic_string<charT>& target) const = 0; + std::basic_string<charT>& target) const = 0; }; typedef BasicStringConverter<char> StringConverter; diff --git a/cppe/include/IceE/Thread.h b/cppe/include/IceE/Thread.h index 24320757bbf..bb8f2bdd7a4 100644 --- a/cppe/include/IceE/Thread.h +++ b/cppe/include/IceE/Thread.h @@ -140,8 +140,8 @@ protected: #endif private: - Thread(const Thread&); // Copying is forbidden - void operator=(const Thread&); // Assignment is forbidden + Thread(const Thread&); // Copying is forbidden + void operator=(const Thread&); // Assignment is forbidden }; typedef Handle<Thread> ThreadPtr; diff --git a/cppe/include/IceE/Time.h b/cppe/include/IceE/Time.h index 754fdcab135..991acffa63d 100644 --- a/cppe/include/IceE/Time.h +++ b/cppe/include/IceE/Time.h @@ -44,142 +44,142 @@ public: Time operator-() const { - return Time(-_usec); + return Time(-_usec); } Time operator-(const Time& rhs) const { - return Time(_usec - rhs._usec); + return Time(_usec - rhs._usec); } Time operator+(const Time& rhs) const { - return Time(_usec + rhs._usec); + return Time(_usec + rhs._usec); } Time& operator+=(const Time& rhs) { - _usec += rhs._usec; - return *this; + _usec += rhs._usec; + return *this; } Time& operator-=(const Time& rhs) { - _usec -= rhs._usec; - return *this; + _usec -= rhs._usec; + return *this; } bool operator<(const Time& rhs) const { - return _usec < rhs._usec; + return _usec < rhs._usec; } bool operator<=(const Time& rhs) const { - return _usec <= rhs._usec; + return _usec <= rhs._usec; } bool operator>(const Time& rhs) const { - return _usec > rhs._usec; + return _usec > rhs._usec; } bool operator>=(const Time& rhs) const { - return _usec >= rhs._usec; + return _usec >= rhs._usec; } bool operator==(const Time& rhs) const { - return _usec == rhs._usec; + return _usec == rhs._usec; } bool operator!=(const Time& rhs) const { - return _usec != rhs._usec; + return _usec != rhs._usec; } double operator/(const Time& rhs) const { - return (double)_usec / (double)rhs._usec; + return (double)_usec / (double)rhs._usec; } Time& operator*=(int rhs) { - _usec *= rhs; - return *this; + _usec *= rhs; + return *this; } Time operator*(int rhs) const { - Time t; - t._usec = _usec * rhs; - return t; + Time t; + t._usec = _usec * rhs; + return t; } Time& operator/=(int rhs) { - _usec /= rhs; - return *this; + _usec /= rhs; + return *this; } Time operator/(int rhs) const { - Time t; - t._usec = _usec / rhs; - return t; + Time t; + t._usec = _usec / rhs; + return t; } Time& operator*=(Int64 rhs) { - _usec *= rhs; - return *this; + _usec *= rhs; + return *this; } Time operator*(Int64 rhs) const { - Time t; - t._usec = _usec * rhs; - return t; + Time t; + t._usec = _usec * rhs; + return t; } Time& operator/=(Int64 rhs) { - _usec /= rhs; - return *this; + _usec /= rhs; + return *this; } Time operator/(Int64 rhs) const { - Time t; - t._usec = _usec / rhs; - return t; + Time t; + t._usec = _usec / rhs; + return t; } Time& operator*=(double rhs) { - _usec = static_cast<Int64>(static_cast<double>(_usec) * rhs); - return *this; + _usec = static_cast<Int64>(static_cast<double>(_usec) * rhs); + return *this; } Time operator*(double rhs) const { - Time t; - t._usec = static_cast<Int64>(static_cast<double>(_usec) * rhs); - return t; + Time t; + t._usec = static_cast<Int64>(static_cast<double>(_usec) * rhs); + return t; } Time& operator/=(double rhs) { - _usec = static_cast<Int64>(static_cast<double>(_usec) / rhs); - return *this; + _usec = static_cast<Int64>(static_cast<double>(_usec) / rhs); + return *this; } Time operator/(double rhs) const { - Time t; - t._usec = static_cast<Int64>(static_cast<double>(_usec) / rhs); - return t; + Time t; + t._usec = static_cast<Int64>(static_cast<double>(_usec) / rhs); + return t; } private: diff --git a/cppe/include/IceE/Unicode.h b/cppe/include/IceE/Unicode.h index 5f225fe6605..f42c25b3f3c 100644 --- a/cppe/include/IceE/Unicode.h +++ b/cppe/include/IceE/Unicode.h @@ -97,10 +97,10 @@ ICE_API std::wstring stringToWstring(const std::string&); enum ConversionResult { - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ }; @@ -117,15 +117,15 @@ isLegalUTF8Sequence(const Byte* source, const Byte* end); ICE_API ConversionResult convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd, - Byte*& targetStart, Byte* targetEnd, ConversionFlags flags); + Byte*& targetStart, Byte* targetEnd, ConversionFlags flags); ICE_API ConversionResult convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd, - wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags); + wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags); ICE_API ConversionResult convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd, - std::wstring& target, ConversionFlags flags); + std::wstring& target, ConversionFlags flags); |