diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-06-11 18:53:17 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-06-11 18:53:17 +0200 |
commit | 27b1f7cc1b061fbf3a1582963d0af08d5839d480 (patch) | |
tree | c93c4a0c885ec941ec33116dd2f5683042d96a34 /cpp/src | |
parent | Java port (diff) | |
download | ice-27b1f7cc1b061fbf3a1582963d0af08d5839d480.tar.bz2 ice-27b1f7cc1b061fbf3a1582963d0af08d5839d480.tar.xz ice-27b1f7cc1b061fbf3a1582963d0af08d5839d480.zip |
Support for optionals
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/BasicStream.cpp | 519 | ||||
-rw-r--r-- | cpp/src/Ice/Exception.cpp | 17 | ||||
-rw-r--r-- | cpp/src/Ice/ImplicitContextI.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 15 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.cpp | 659 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.h | 88 | ||||
-rw-r--r-- | cpp/src/Ice/TraceUtil.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceUtil/Exception.cpp | 34 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 1035 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.cpp | 2066 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.h | 73 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.y | 127 | ||||
-rw-r--r-- | cpp/src/Slice/GrammarUtil.h | 13 | ||||
-rwxr-xr-x | cpp/src/Slice/Parser.cpp | 92 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 1125 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 21 | ||||
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 64 |
21 files changed, 2325 insertions, 3652 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 0d8ea17953d..e08d7ad9b49 100755 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -154,12 +154,12 @@ IceInternal::BasicStream::swap(BasicStream& other) std::swap(_closure, other._closure); // - // Swap is never called for BasicStreams that have encapsulations being read/write. + // Swap is never called for BasicStreams that have encapsulations being read/write. However, + // encapsulations might still be set in case marhsalling or un-marhsalling failed. We just + // reset the encapsulations if there are still some set. // - assert(!_currentReadEncaps); - assert(!_currentWriteEncaps); - assert(!other._currentReadEncaps); - assert(!other._currentWriteEncaps); + resetEncaps(); + other.resetEncaps(); std::swap(_unlimited, other._unlimited); std::swap(_startSeq, other._startSeq); @@ -168,6 +168,28 @@ IceInternal::BasicStream::swap(BasicStream& other) } void +IceInternal::BasicStream::resetEncaps() +{ + while(_currentReadEncaps && _currentReadEncaps != &_preAllocatedReadEncaps) + { + ReadEncaps* oldEncaps = _currentReadEncaps; + _currentReadEncaps = _currentReadEncaps->previous; + delete oldEncaps; + } + + while(_currentWriteEncaps && _currentWriteEncaps != &_preAllocatedWriteEncaps) + { + WriteEncaps* oldEncaps = _currentWriteEncaps; + _currentWriteEncaps = _currentWriteEncaps->previous; + delete oldEncaps; + } + + _preAllocatedReadEncaps.reset(); + _preAllocatedWriteEncaps.reset(); +} + + +void IceInternal::BasicStream::format(Ice::FormatType format) { if(format != DefaultFormat) @@ -242,14 +264,14 @@ IceInternal::BasicStream::skipEncaps() return encoding; } -void -IceInternal::BasicStream::readAndCheckSeqSize(int minSize, Int& sz) +Int +IceInternal::BasicStream::readAndCheckSeqSize(int minSize) { - readSize(sz); + Int sz = readSize(); if(sz == 0) { - return; + return sz; } // @@ -288,6 +310,8 @@ IceInternal::BasicStream::readAndCheckSeqSize(int minSize, Int& sz) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } + + return sz; } void @@ -319,15 +343,6 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz) } } -void IceInternal::BasicStream::write(Byte v, int end) -{ - if(v >= end) - { - throw MarshalException(__FILE__, __LINE__, "enumerator out of range"); - } - write(v); -} - void IceInternal::BasicStream::write(const Byte* begin, const Byte* end) { @@ -342,20 +357,25 @@ IceInternal::BasicStream::write(const Byte* begin, const Byte* end) } void -IceInternal::BasicStream::read(Byte& b, int end) +IceInternal::BasicStream::read(std::vector<Ice::Byte>& v) { - read(b); - if(b >= end) + std::pair<const Ice::Byte*, const Ice::Byte*> p; + read(p); + if(p.first != p.second) + { + v.resize(static_cast<Ice::Int>(p.second - p.first)); + copy(p.first, p.second, v.begin()); + } + else { - throw MarshalException(__FILE__, __LINE__, "enumerator out of range"); + v.clear(); } } void IceInternal::BasicStream::read(pair<const Byte*, const Byte*>& v) { - Int sz; - readAndCheckSeqSize(1, sz); + Int sz = readAndCheckSeqSize(1); if(sz > 0) { v.first = i; @@ -423,8 +443,7 @@ IceInternal::BasicStream::write(const bool* begin, const bool* end) void IceInternal::BasicStream::read(vector<bool>& v) { - Int sz; - readAndCheckSeqSize(1, sz); + Int sz = readAndCheckSeqSize(1); if(sz > 0) { v.resize(sz); @@ -473,8 +492,7 @@ bool* IceInternal::BasicStream::read(pair<const bool*, const bool*>& v) { bool* result = 0; - Int sz; - readAndCheckSeqSize(1, sz); + Int sz = readAndCheckSeqSize(1); if(sz > 0) { result = BasicStreamReadBoolHelper<sizeof(bool)>::read(v, sz, i); @@ -505,16 +523,6 @@ IceInternal::BasicStream::write(Short v) } void -IceInternal::BasicStream::write(Short v, int end) -{ - if(v < 0 || v >= end) - { - throw MarshalException(__FILE__, __LINE__, "enumerator out of range"); - } - write(v); -} - -void IceInternal::BasicStream::write(const Short* begin, const Short* end) { Int sz = static_cast<Int>(end - begin); @@ -559,20 +567,9 @@ IceInternal::BasicStream::read(Short& v) } void -IceInternal::BasicStream::read(Short& v, int end) -{ - read(v); - if(v < 0 || v >= end) - { - throw MarshalException(__FILE__, __LINE__, "enumerator out of range"); - } -} - -void IceInternal::BasicStream::read(vector<Short>& v) { - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Short)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Short))); if(sz > 0) { Container::iterator begin = i; @@ -601,8 +598,7 @@ Short* IceInternal::BasicStream::read(pair<const Short*, const Short*>& v) { Short* result = 0; - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Short)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Short))); if(sz > 0) { #if defined(__i386) || defined(_M_IX86) @@ -638,26 +634,6 @@ IceInternal::BasicStream::read(pair<const Short*, const Short*>& v) } void -IceInternal::BasicStream::read(Int& v, int end) -{ - read(v); - if(v < 0 || v >= end) - { - throw MarshalException(__FILE__, __LINE__, "enumerator out of range"); - } -} - -void -IceInternal::BasicStream::write(Int v, int end) -{ - if(v < 0 || v >= end) - { - throw MarshalException(__FILE__, __LINE__, "enumerator out of range"); - } - write(v); -} - -void IceInternal::BasicStream::write(const Int* begin, const Int* end) { Int sz = static_cast<Int>(end - begin); @@ -686,8 +662,7 @@ IceInternal::BasicStream::write(const Int* begin, const Int* end) void IceInternal::BasicStream::read(vector<Int>& v) { - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Int)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Int))); if(sz > 0) { Container::iterator begin = i; @@ -718,8 +693,7 @@ Int* IceInternal::BasicStream::read(pair<const Int*, const Int*>& v) { Int* result = 0; - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Int)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Int))); if(sz > 0) { #if defined(__i386) || defined(_M_IX86) @@ -850,8 +824,7 @@ IceInternal::BasicStream::read(Long& v) void IceInternal::BasicStream::read(vector<Long>& v) { - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Long)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Long))); if(sz > 0) { Container::iterator begin = i; @@ -886,8 +859,7 @@ Long* IceInternal::BasicStream::read(pair<const Long*, const Long*>& v) { Long* result = 0; - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Long)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Long))); if(sz > 0) { #if defined(__i386) || defined(_M_IX86) @@ -1002,8 +974,7 @@ IceInternal::BasicStream::read(Float& v) void IceInternal::BasicStream::read(vector<Float>& v) { - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Float)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Float))); if(sz > 0) { Container::iterator begin = i; @@ -1034,8 +1005,7 @@ Float* IceInternal::BasicStream::read(pair<const Float*, const Float*>& v) { Float* result = 0; - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Float)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Float))); if(sz > 0) { #if defined(__i386) || defined(_M_IX86) @@ -1203,8 +1173,7 @@ IceInternal::BasicStream::read(Double& v) void IceInternal::BasicStream::read(vector<Double>& v) { - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Double)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Double))); if(sz > 0) { Container::iterator begin = i; @@ -1254,8 +1223,7 @@ Double* IceInternal::BasicStream::read(pair<const Double*, const Double*>& v) { Double* result = 0; - Int sz; - readAndCheckSeqSize(static_cast<int>(sizeof(Double)), sz); + Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Double))); if(sz > 0) { #if defined(__i386) || defined(_M_IX86) @@ -1407,8 +1375,7 @@ IceInternal::BasicStream::readConverted(string& v, int sz) void IceInternal::BasicStream::read(vector<string>& v, bool convert) { - Int sz; - readAndCheckSeqSize(1, sz); + Int sz = readAndCheckSeqSize(1); if(sz > 0) { v.resize(sz); @@ -1504,8 +1471,7 @@ IceInternal::BasicStream::write(const wstring* begin, const wstring* end) void IceInternal::BasicStream::read(wstring& v) { - Int sz; - readSize(sz); + Int sz = readSize(); if(sz > 0) { if(b.end() - i < sz) @@ -1525,8 +1491,7 @@ IceInternal::BasicStream::read(wstring& v) void IceInternal::BasicStream::read(vector<wstring>& v) { - Int sz; - readAndCheckSeqSize(1, sz); + Int sz = readAndCheckSeqSize(1); if(sz > 0) { v.resize(sz); @@ -1553,12 +1518,209 @@ IceInternal::BasicStream::read(ObjectPrx& v) v = _instance->proxyFactory()->streamToProxy(this); } +Int +IceInternal::BasicStream::readEnum(Int limit) +{ + if(getReadEncoding() == Encoding_1_0) + { + if(limit <= 127) + { + Byte value; + read(value); + return value; + } + else if(limit <= 32767) + { + Short value; + read(value); + return value; + } + else + { + Int value; + read(value); + return value; + } + } + else + { + return readSize(); + } +} + +void +IceInternal::BasicStream::writeEnum(Int v, Int limit) +{ + if(getWriteEncoding() == Encoding_1_0) + { + if(limit <= 127) + { + write(static_cast<Byte>(v)); + } + else if(limit <= 32767) + { + write(static_cast<Short>(v)); + } + else + { + write(v); + } + } + else + { + writeSize(v); + } +} + void IceInternal::BasicStream::sliceObjects(bool doSlice) { _sliceObjects = doSlice; } + +bool +IceInternal::BasicStream::readOptImpl(Int readTag, OptionalType expectedType) +{ + Int tag = 0; + OptionalType type; + do + { + if(i >= b.begin() + _currentReadEncaps->start + _currentReadEncaps->sz) + { + return false; // End of encapsulation also indicates end of optionals. + } + + Byte v; + read(v); + type = static_cast<OptionalType>(v & 0x07); // First 3 bits. + tag = static_cast<Int>(v >> 3); + if(tag == 31) + { + tag = readSize(); + } + } + while(type != OptionalTypeEndMarker && tag < readTag && skipOpt(type)); // Skip optional data members + + if(type == OptionalTypeEndMarker || tag > readTag) + { + // + // Rewind the stream to correctly read the next optional data + // member tag & type next time. + // + i -= tag < 31 ? 1 : (tag < 255 ? 2 : 6); + return false; // No optional data members with the requested tag. + } + + assert(readTag == tag); + if(type != expectedType) + { + ostringstream os; + os << "invalid optional data member `" << tag << "': unexpected type"; + throw MarshalException(__FILE__, __LINE__, os.str()); + } + + // + // We have an optional data member with the requested tag and + // type. + // + return true; +} + +void +IceInternal::BasicStream::writeOptImpl(Int tag, OptionalType type) +{ + Byte v = static_cast<Byte>(type); + if(tag < 31) + { + v |= tag << 3; + write(v); + } + else + { + v |= 0x0F8; // tag = 31 + write(v); + writeSize(tag); + } +} + +bool +IceInternal::BasicStream::skipOpt(OptionalType type) +{ + int sz; + switch(type) + { + case Ice::OptionalTypeF1: + { + sz = 1; + break; + } + case Ice::OptionalTypeF2: + { + sz = 2; + break; + } + case Ice::OptionalTypeF4: + { + sz = 4; + break; + } + case Ice::OptionalTypeF8: + { + sz = 8; + break; + } + case Ice::OptionalTypeSize: + { + skipSize(); + return true; + } + case Ice::OptionalTypeVSize: + { + sz = readSize(); + break; + } + case Ice::OptionalTypeFSize: + { + read(sz); + break; + } + default: + { + return false; + } + } + skip(sz); + return true; +} + +bool +BasicStream::skipOpts() +{ + // + // Skip remaining un-read optional members. + // + OptionalType type; + do + { + if(i >= b.begin() + _currentReadEncaps->start + _currentReadEncaps->sz) + { + return false; // End of encapsulation also indicates end of optionals. + } + + Byte v; + read(v); + type = static_cast<OptionalType>(v & 0x07); // Read first 3 bits. + if(static_cast<Int>(v >> 3) == 31) + { + skipSize(); + } + } + while(skipOpt(type)); + assert(type == OptionalTypeEndMarker); + return true; +} + void IceInternal::BasicStream::throwUnmarshalOutOfBoundsException(const char* file, int line) { @@ -1577,6 +1739,7 @@ IceInternal::BasicStream::initReadEncaps() if(!_currentReadEncaps) // Lazy initialization. { _currentReadEncaps = &_preAllocatedReadEncaps; + _currentReadEncaps->sz = b.size(); } if(!_currentReadEncaps->decoder) // Lazy initialization. @@ -1812,7 +1975,7 @@ IceInternal::BasicStream::EncapsEncoder::endSlice() // if(_sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS) { - _stream->write(static_cast<Byte>(MemberTypeEndMarker)); + _stream->write(static_cast<Byte>(OptionalTypeEndMarker)); } // @@ -1861,30 +2024,12 @@ IceInternal::BasicStream::EncapsEncoder::endSlice() } void -IceInternal::BasicStream::EncapsEncoder::writeOpt(int tag, MemberType type) -{ - assert(_sliceType != NoSlice); - _sliceFlags |= FLAG_HAS_OPTIONAL_MEMBERS; - Byte v = static_cast<Byte>(type); - if(tag < 31) - { - v |= tag << 3; - } - else - { - v |= 0x0F8; // tag = 31 - _stream->writeSize(tag); - } -} - -void IceInternal::BasicStream::EncapsEncoder::writePendingObjects() { // - // With the 1.0 encoding, only write pending objects if nil or - // non-nil references were written (_usesClasses = - // true). Otherwise, write pending objects only if some non-nil - // references were written. + // With the 1.0 encoding, write pending objects if nil or non-nil + // references were written (_usesClasses = true). Otherwise, write + // pending objects only if some non-nil references were written. // if(_encaps->encoding == Encoding_1_0) { @@ -1898,6 +2043,14 @@ IceInternal::BasicStream::EncapsEncoder::writePendingObjects() { return; } + else + { + // + // Write end marker for encapsulation optionals before encoding + // the pending objects. + // + _stream->write(static_cast<Byte>(OptionalTypeEndMarker)); + } while(!_toBeMarshaledMap.empty()) { @@ -1973,6 +2126,11 @@ IceInternal::BasicStream::EncapsEncoder::writeSlicedData(const SlicedDataPtr& sl // _stream->writeBlob((*p)->bytes); + if((*p)->hasOptionalMembers) + { + _sliceFlags |= FLAG_HAS_OPTIONAL_MEMBERS; + } + // // Assemble and write the indirection table. The table must have the same order // as the list of objects. @@ -2041,7 +2199,7 @@ IceInternal::BasicStream::EncapsDecoder::read(PatchFunc patchFunc, void* patchAd // // Later versions use a size. // - _stream->readSize(index); + index = _stream->readSize(); if(index < 0) { throw MarshalException(__FILE__, __LINE__, "invalid object id"); @@ -2141,8 +2299,8 @@ IceInternal::BasicStream::EncapsDecoder::throwException(const UserExceptionFacto } // - // Performance sensitive, so we use lazy initialization - // for tracing. + // Performance sensitive, so we use lazy initialization for + // tracing. // if(_traceSlicing == -1) { @@ -2156,8 +2314,7 @@ IceInternal::BasicStream::EncapsDecoder::throwException(const UserExceptionFacto if(_sliceFlags & FLAG_IS_LAST_SLICE) { - // TODO: Consider adding a new exception, such as NoExceptionFactory? - throw UnmarshalOutOfBoundsException(__FILE__, __LINE__, "unknown exception type `" + mostDerivedId + "'"); + throw NoExceptionFactoryException(__FILE__, __LINE__, "", "unknown exception type `" + mostDerivedId + "'"); } skipSlice(); // Slice off what we don't understand. @@ -2203,8 +2360,7 @@ IceInternal::BasicStream::EncapsDecoder::endObject(bool preserve) // // For compatibility with the old AFM. // - Int sz; - _stream->readSize(sz); + Int sz = _stream->readSize(); if(sz != 0) { throw MarshalException(__FILE__, __LINE__, "invalid Object slice"); @@ -2287,8 +2443,7 @@ IceInternal::BasicStream::EncapsDecoder::startSlice() { if(_sliceFlags & FLAG_HAS_TYPE_ID_INDEX) { - Int index; - _stream->readSize(index); + Int index = _stream->readSize(); TypeIdReadMap::const_iterator k = _typeIdMap.find(index); if(k == _typeIdMap.end()) { @@ -2341,15 +2496,7 @@ IceInternal::BasicStream::EncapsDecoder::endSlice() { if(_sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS) { - // - // Read remaining un-read optional members. - // - Byte v; - do - { - _stream->read(v); - } - while(skipOpt(static_cast<MemberType>(v & 0x07))); + _stream->skipOpts(); } // @@ -2365,13 +2512,15 @@ IceInternal::BasicStream::EncapsDecoder::endSlice() _stream->readSizeSeq(indirectionTable); // - // Sanity checks. + // Sanity checks. If there are optional members, it's possible + // that not all object references were read if they are from + // unknown optional data members. // if(indirectionTable.empty() && !_indirectPatchList.empty()) { throw MarshalException(__FILE__, __LINE__, "empty indirection table"); } - else if(!indirectionTable.empty() && _indirectPatchList.empty()) + else if(!indirectionTable.empty() && _indirectPatchList.empty() && !(_sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS)) { throw MarshalException(__FILE__, __LINE__, "no references to indirection table"); } @@ -2399,73 +2548,13 @@ IceInternal::BasicStream::EncapsDecoder::endSlice() } } -bool -IceInternal::BasicStream::EncapsDecoder::readOpt(int readTag, MemberType expectedType) -{ - assert(_sliceType != NoSlice); - if(!(_sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS)) - { - return false; // No optional data members - } - - int tag; - MemberType type; - do - { - Byte v; - _stream->read(v); - - type = static_cast<MemberType>(v & 0x07); // Read first 3 bits. - tag = static_cast<int>(v >> 3); - if(tag == 31) - { - _stream->readSize(tag); - } - } - while(tag < readTag && skipOpt(type)); // Skip optional data members with lower tag values. - - if(type == MemberTypeEndMarker) - { - // - // Clear the optional members flag since we've reach the end. We clear - // the flag to prevent endSlice to skip un-read optional members and - // to prevent other optional members from being read. - // - _sliceFlags &= ~FLAG_HAS_OPTIONAL_MEMBERS; - return false; - } - else if(tag > readTag) - { - // - // Rewind the stream so that we correctly read the next - // optional data member tag & type. - // - _stream->i -= tag < 31 ? 1 : (tag < 255 ? 2 : 6); - return false; // No optional data members with the requested tag. - } - - assert(readTag == tag); - if(type != expectedType) - { - ostringstream os; - os << "invalid optional data member `" << tag << "' in `" << _typeId << "': unexpected type"; - throw MarshalException(__FILE__, __LINE__, os.str()); - } - - // - // We have an optional data member with the requested tag and - // type. - // - return true; -} - void IceInternal::BasicStream::EncapsDecoder::readPendingObjects() { // - // With the 1.0 encoding, only read pending objects if nil or - // non-nil references were read (_usesClasses == true). Otherwise, - // read pending objects only if some non-nil references were read. + // With the 1.0 encoding, read pending objects if nil or non-nil + // references were read (_usesClasses == true). Otherwise, read + // pending objects only if some non-nil references were read. // if(_encaps->encoding == Encoding_1_0) { @@ -2479,12 +2568,20 @@ IceInternal::BasicStream::EncapsDecoder::readPendingObjects() { return; } + else + { + // + // Read unread encapsulation optionals before reading the + // pending objects. + // + _stream->skipOpts(); + } Int num; ObjectList objectList; do { - _stream->readSize(num); + num = _stream->readSize(); for(Int k = num; k > 0; --k) { objectList.push_back(readInstance()); @@ -2536,7 +2633,7 @@ IceInternal::BasicStream::EncapsDecoder::readInstance() } else { - _stream->readSize(index); + index = _stream->readSize(); } ObjectPtr v; @@ -2727,11 +2824,7 @@ IceInternal::BasicStream::EncapsDecoder::skipSlice() if(_sliceFlags & FLAG_HAS_SLICE_SIZE) { assert(_sliceSize >= 4); - _stream->i += _sliceSize - sizeof(Int); - if(_stream->i > _stream->b.end()) - { - throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); - } + _stream->skip(_sliceSize - sizeof(Int)); } else { @@ -2745,7 +2838,17 @@ IceInternal::BasicStream::EncapsDecoder::skipSlice() // SliceInfoPtr info = new SliceInfo; info->typeId = _typeId; - vector<Byte>(start, _stream->i).swap(info->bytes); + info->hasOptionalMembers = _sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS; + if(info->hasOptionalMembers) + { + // Don't include the optional member end marker. It will be re-written by + // endSlice when the sliced data is re-written. + vector<Byte>(start, _stream->i - 1).swap(info->bytes); + } + else + { + vector<Byte>(start, _stream->i).swap(info->bytes); + } _slices.push_back(info); _indirectionTables.push_back(IndexList()); @@ -2796,7 +2899,7 @@ IceInternal::BasicStream::EncapsDecoder::readSlicedData() { throw MarshalException(__FILE__, __LINE__, "invalid id in object indirection table"); } - addPatchEntry(id, __patch__ObjectPtr, &_slices[n]->objects[j++]); + addPatchEntry(id, &patchHandle<Ice::Object>, &_slices[n]->objects[j++]); } } diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index a5b2aafa246..002851f917d 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -26,11 +26,11 @@ namespace Ex { void -throwUOE(const string& expectedType, const string& actualType) +throwUOE(const string& expectedType, const string& type) { throw Ice::UnexpectedObjectException(__FILE__, __LINE__, - "expected element of type `" + expectedType + "' but received '" + actualType, - actualType, expectedType); + "expected element of type `" + expectedType + "' but received '" + + type, type, expectedType); } void @@ -591,6 +591,17 @@ Ice::NoObjectFactoryException::ice_print(ostream& out) const } void +Ice::NoExceptionFactoryException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ":\nprotocol error: no suitable exception factory found for `" << type << "'"; + if(!reason.empty()) + { + out << ":\n" << reason; + } +} + +void Ice::UnexpectedObjectException::ice_print(ostream& out) const { Exception::ice_print(out); diff --git a/cpp/src/Ice/ImplicitContextI.cpp b/cpp/src/Ice/ImplicitContextI.cpp index a14c7cc01f3..ce5b2cb7d95 100644 --- a/cpp/src/Ice/ImplicitContextI.cpp +++ b/cpp/src/Ice/ImplicitContextI.cpp @@ -215,19 +215,19 @@ SharedImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStream IceUtil::Mutex::Lock lock(_mutex); if(proxyCtx.size() == 0) { - __writeContext(s, _context); + s->write(_context); } else if(_context.size() == 0) { lock.release(); - __writeContext(s, proxyCtx); + s->write(proxyCtx); } else { Context combined = proxyCtx; combined.insert(_context.begin(), _context.end()); lock.release(); - __writeContext(s, combined); + s->write(combined); } } @@ -596,17 +596,17 @@ PerThreadImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStr if(threadCtx == 0 || threadCtx->size() == 0) { - __writeContext(s, proxyCtx); + s->write(proxyCtx); } else if(proxyCtx.size() == 0) { - __writeContext(s, *threadCtx); + s->write(*threadCtx); } else { Context combined = proxyCtx; combined.insert(threadCtx->begin(), threadCtx->end()); - __writeContext(s, combined); + s->write(combined); } } diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 4d95113c5f7..15e49a61608 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -528,8 +528,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager, BasicStre _is->read(b); _current.mode = static_cast<OperationMode>(b); - Int sz; - _is->readSize(sz); + Int sz = _is->readSize(); while(sz--) { pair<const string, string> pr; diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 8cce4a577a0..875c58ed78d 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -20,7 +20,13 @@ using namespace std; using namespace Ice; using namespace IceInternal; -IceUtil::Shared* Ice::upCast(Object* p) { return p; } +Object* Ice::upCast(Object* p) { return p; } + +void +Ice::__patch(ObjectPtr& obj, ObjectPtr& v) +{ + obj = v; +} bool Ice::Object::operator==(const Object& r) const @@ -242,13 +248,6 @@ Ice::Object::__collocDispatch(IceInternal::Direct& request) return request.run(this); } -void -Ice::__patch__ObjectPtr(void* __addr, ObjectPtr& v) -{ - ObjectPtr* p = static_cast<ObjectPtr*>(__addr); - *p = v; -} - namespace { diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 1056b6628c5..e922fb30486 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -133,7 +133,7 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation // // Explicit context // - __writeContext(&_os, *context); + _os.write(*context); } else { @@ -144,7 +144,7 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation const Context& prxContext = _handler->getReference()->getContext()->getValue(); if(implicitContext == 0) { - __writeContext(&_os, prxContext); + _os.write(prxContext); } else { diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index f4aa8b63f20..c68c271cefc 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -460,7 +460,7 @@ IceInternal::OutgoingAsync::__prepare(const std::string& operation, OperationMod // // Explicit context // - __writeContext(&_os, *context); + _os.write(*context); } else { @@ -471,7 +471,7 @@ IceInternal::OutgoingAsync::__prepare(const std::string& operation, OperationMod const Context& prxContext = ref->getContext()->getValue(); if(implicitContext == 0) { - __writeContext(&_os, prxContext); + _os.write(prxContext); } else { diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 016078785ca..4c0c716811b 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -583,8 +583,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) vector<EndpointIPtr> endpoints; string adapterId; - Ice::Int sz; - s->readSize(sz); + Ice::Int sz = s->readSize(); if(sz > 0) { diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index b25856f58ad..1db13f0f33c 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -37,7 +37,7 @@ class UserExceptionFactoryI : public IceInternal::UserExceptionFactory { public: - UserExceptionFactoryI(const Ice::UserExceptionReaderFactoryPtr& factory) : + UserExceptionFactoryI(const UserExceptionReaderFactoryPtr& factory) : _factory(factory) { } @@ -49,7 +49,7 @@ public: private: - const Ice::UserExceptionReaderFactoryPtr _factory; + const UserExceptionReaderFactoryPtr _factory; }; } @@ -57,23 +57,23 @@ private: // // UserExceptionReader // -Ice::UserExceptionReader::UserExceptionReader(const Ice::CommunicatorPtr& communicator) : +UserExceptionReader::UserExceptionReader(const CommunicatorPtr& communicator) : _communicator(communicator) { } -Ice::UserExceptionReader::~UserExceptionReader() throw() +UserExceptionReader::~UserExceptionReader() throw() { } void -Ice::UserExceptionReader::__write(BasicStream*) const +UserExceptionReader::__write(BasicStream*) const { assert(false); } void -Ice::UserExceptionReader::__read(BasicStream* is) +UserExceptionReader::__read(BasicStream* is) { InputStreamI* stream = reinterpret_cast<InputStreamI*>(is->closure()); assert(stream); @@ -81,13 +81,13 @@ Ice::UserExceptionReader::__read(BasicStream* is) } bool -Ice::UserExceptionReader::__usesClasses() const +UserExceptionReader::__usesClasses() const { return usesClasses(); } void -Ice::UserExceptionReader::__usesClasses(bool b) +UserExceptionReader::__usesClasses(bool b) { usesClasses(b); } @@ -95,7 +95,7 @@ Ice::UserExceptionReader::__usesClasses(bool b) // // InputStreamI // -Ice::InputStreamI::InputStreamI(const Ice::CommunicatorPtr& communicator, const vector<Byte>& data) : +InputStreamI::InputStreamI(const CommunicatorPtr& communicator, const vector<Byte>& data) : _communicator(communicator), _closure(0) { @@ -106,7 +106,7 @@ Ice::InputStreamI::InputStreamI(const Ice::CommunicatorPtr& communicator, const _is->i = _is->b.begin(); } -Ice::InputStreamI::InputStreamI(const Ice::CommunicatorPtr& communicator, const pair<const Byte*, const Byte*>& data) : +InputStreamI::InputStreamI(const CommunicatorPtr& communicator, const pair<const Byte*, const Byte*>& data) : _communicator(communicator), _closure(0) { @@ -117,230 +117,39 @@ Ice::InputStreamI::InputStreamI(const Ice::CommunicatorPtr& communicator, const _is->i = _is->b.begin(); } -Ice::InputStreamI::~InputStreamI() +InputStreamI::~InputStreamI() { delete _is; } CommunicatorPtr -Ice::InputStreamI::communicator() const +InputStreamI::communicator() const { return _communicator; } void -Ice::InputStreamI::sliceObjects(bool b) +InputStreamI::sliceObjects(bool b) { _is->sliceObjects(b); } -bool -Ice::InputStreamI::readBool() -{ - bool v; - _is->read(v); - return v; -} - -vector<bool> -Ice::InputStreamI::readBoolSeq() -{ - vector<bool> v; - _is->read(v); - return v; -} - -bool* -Ice::InputStreamI::readBoolSeq(pair<const bool*, const bool*>& p) -{ - return _is->read(p); -} - -Byte -Ice::InputStreamI::readByte() -{ - Byte v; - _is->read(v); - return v; -} - -vector<Byte> -Ice::InputStreamI::readByteSeq() -{ - pair<const Byte*, const Byte*> p; - _is->read(p); - vector<Byte> v(p.first, p.second); - return v; -} - -void -Ice::InputStreamI::readByteSeq(pair<const Byte*, const Byte*>& p) -{ - _is->read(p); -} - -Short -Ice::InputStreamI::readShort() -{ - Short v; - _is->read(v); - return v; -} - -vector<Short> -Ice::InputStreamI::readShortSeq() -{ - vector<Short> v; - _is->read(v); - return v; -} - -Short* -Ice::InputStreamI::readShortSeq(pair<const Short*, const Short*>& p) -{ - return _is->read(p); -} - -Int -Ice::InputStreamI::readInt() -{ - Int v; - _is->read(v); - return v; -} - -vector<Int> -Ice::InputStreamI::readIntSeq() -{ - vector<Int> v; - _is->read(v); - return v; -} - -Int* -Ice::InputStreamI::readIntSeq(pair<const Int*, const Int*>& p) -{ - return _is->read(p); -} - -Long -Ice::InputStreamI::readLong() -{ - Long v; - _is->read(v); - return v; -} - -vector<Long> -Ice::InputStreamI::readLongSeq() -{ - vector<Long> v; - _is->read(v); - return v; -} - -Long* -Ice::InputStreamI::readLongSeq(pair<const Long*, const Long*>& p) -{ - return _is->read(p); -} - -Float -Ice::InputStreamI::readFloat() -{ - Float v; - _is->read(v); - return v; -} - -vector<Float> -Ice::InputStreamI::readFloatSeq() -{ - vector<Float> v; - _is->read(v); - return v; -} - -Float* -Ice::InputStreamI::readFloatSeq(pair<const Float*, const Float*>& p) -{ - return _is->read(p); -} - -Double -Ice::InputStreamI::readDouble() -{ - Double v; - _is->read(v); - return v; -} - -vector<Double> -Ice::InputStreamI::readDoubleSeq() -{ - vector<Double> v; - _is->read(v); - return v; -} - -Double* -Ice::InputStreamI::readDoubleSeq(pair<const Double*, const Double*>& p) -{ - return _is->read(p); -} - -string -Ice::InputStreamI::readString(bool convert) -{ - string v; - _is->read(v, convert); - return v; -} - -vector<string> -Ice::InputStreamI::readStringSeq(bool convert) -{ - vector<string> v; - _is->read(v, convert); - return v; -} - -wstring -Ice::InputStreamI::readWstring() -{ - wstring v; - _is->read(v); - return v; -} - -vector<wstring> -Ice::InputStreamI::readWstringSeq() -{ - vector<wstring> v; - _is->read(v); - return v; -} - Int -Ice::InputStreamI::readSize() +InputStreamI::readSize() { - Int sz; - _is->readSize(sz); - return sz; + return _is->readSize(); } Int -Ice::InputStreamI::readAndCheckSeqSize(int minSize) +InputStreamI::readAndCheckSeqSize(int minSize) { - Int sz; - _is->readAndCheckSeqSize(minSize, sz); - return sz; + return _is->readAndCheckSeqSize(minSize); } ObjectPrx -Ice::InputStreamI::readProxy() +InputStreamI::readProxy() { - Ice::ObjectPrx v; + ObjectPrx v; _is->read(v); return v; } @@ -359,208 +168,232 @@ patchObject(void* addr, ObjectPtr& v) } void -Ice::InputStreamI::readObject(const ReadObjectCallbackPtr& cb) +InputStreamI::readObject(const ReadObjectCallbackPtr& cb) { _callbacks.push_back(cb); // Keep reference to callback. _is->read(patchObject, cb.get()); } void -Ice::InputStreamI::read(bool& v) +InputStreamI::read(bool& v) { _is->read(v); } void -Ice::InputStreamI::read(::Ice::Byte& v) +InputStreamI::read(Byte& v) { _is->read(v); } void -Ice::InputStreamI::read(::Ice::Short& v) +InputStreamI::read(Short& v) { _is->read(v); } void -Ice::InputStreamI::read(Ice::Int& v) +InputStreamI::read(Int& v) { _is->read(v); } void -Ice::InputStreamI::read(Ice::Long& v) +InputStreamI::read(Long& v) { _is->read(v); } void -Ice::InputStreamI::read(Ice::Float& v) +InputStreamI::read(Float& v) { _is->read(v); } void -Ice::InputStreamI::read(Ice::Double& v) +InputStreamI::read(Double& v) { _is->read(v); } void -Ice::InputStreamI::read(string& v, bool convert) +InputStreamI::read(string& v, bool convert) { _is->read(v, convert); } void -Ice::InputStreamI::read(vector<string>& v, bool convert) +InputStreamI::read(vector<string>& v, bool convert) { _is->read(v, convert); } void -Ice::InputStreamI::read(wstring& v) +InputStreamI::read(wstring& v) { _is->read(v); } void -Ice::InputStreamI::read(pair<const bool*, const bool*>& p, ::IceUtil::ScopedArray<bool>& result) +InputStreamI::read(pair<const bool*, const bool*>& p, ::IceUtil::ScopedArray<bool>& result) { result.reset(_is->read(p)); } void -Ice::InputStreamI::read(pair<const Ice::Byte*, const Ice::Byte*>& p) +InputStreamI::read(pair<const Byte*, const Byte*>& p) { _is->read(p); } void -Ice::InputStreamI::read(pair<const Ice::Short*, const Ice::Short*>& p, ::IceUtil::ScopedArray<Ice::Short>& result) +InputStreamI::read(pair<const Short*, const Short*>& p, ::IceUtil::ScopedArray<Short>& result) { result.reset(_is->read(p)); } void -Ice::InputStreamI::read(pair<const Ice::Int*, const Ice::Int*>& p, ::IceUtil::ScopedArray<Ice::Int>& result) +InputStreamI::read(pair<const Int*, const Int*>& p, ::IceUtil::ScopedArray<Int>& result) { result.reset(_is->read(p)); } void -Ice::InputStreamI::read(pair<const Ice::Long*, const Ice::Long*>& p, ::IceUtil::ScopedArray<Ice::Long>& result) +InputStreamI::read(pair<const Long*, const Long*>& p, ::IceUtil::ScopedArray<Long>& result) { result.reset(_is->read(p)); } void -Ice::InputStreamI::read(pair<const Ice::Float*, const Ice::Float*>& p, ::IceUtil::ScopedArray<Ice::Float>& result) +InputStreamI::read(pair<const Float*, const Float*>& p, ::IceUtil::ScopedArray<Float>& result) { result.reset(_is->read(p)); } void -Ice::InputStreamI::read(pair<const Ice::Double*, const Ice::Double*>& p, - ::IceUtil::ScopedArray<Ice::Double>& result) +InputStreamI::read(pair<const Double*, const Double*>& p, + ::IceUtil::ScopedArray<Double>& result) { result.reset(_is->read(p)); } +bool +InputStreamI::readOptional(Int tag, OptionalType type) +{ + return _is->readOpt(tag, type); +} + void -Ice::InputStreamI::throwException() +InputStreamI::throwException() { _is->throwException(); } void -Ice::InputStreamI::throwException(const UserExceptionReaderFactoryPtr& factory) +InputStreamI::throwException(const UserExceptionReaderFactoryPtr& factory) { UserExceptionFactoryPtr del = new UserExceptionFactoryI(factory); _is->throwException(del); } void -Ice::InputStreamI::startObject() +InputStreamI::startObject() { _is->startReadObject(); } SlicedDataPtr -Ice::InputStreamI::endObject(bool preserve) +InputStreamI::endObject(bool preserve) { return _is->endReadObject(preserve); } void -Ice::InputStreamI::startException() +InputStreamI::startException() { _is->startReadException(); } SlicedDataPtr -Ice::InputStreamI::endException(bool preserve) +InputStreamI::endException(bool preserve) { return _is->endReadException(preserve); } string -Ice::InputStreamI::startSlice() +InputStreamI::startSlice() { return _is->startReadSlice(); } void -Ice::InputStreamI::endSlice() +InputStreamI::endSlice() { _is->endReadSlice(); } -Ice::EncodingVersion -Ice::InputStreamI::startEncapsulation() +void +InputStreamI::skipSlice() +{ + _is->skipSlice(); +} + +EncodingVersion +InputStreamI::startEncapsulation() { return _is->startReadEncaps(); } void -Ice::InputStreamI::endEncapsulation() +InputStreamI::endEncapsulation() { _is->endReadEncapsChecked(); } -Ice::EncodingVersion -Ice::InputStreamI::skipEncapsulation() +EncodingVersion +InputStreamI::skipEncapsulation() { return _is->skipEncaps(); } -void -Ice::InputStreamI::skipSlice() +EncodingVersion +InputStreamI::getEncoding() { - _is->skipSlice(); + return _is->getReadEncoding(); } void -Ice::InputStreamI::readPendingObjects() +InputStreamI::readPendingObjects() { _is->readPendingObjects(); } void -Ice::InputStreamI::rewind() +InputStreamI::rewind() { _is->clear(); _is->i = _is->b.begin(); } void -Ice::InputStreamI::closure(void* p) +InputStreamI::skip(Int sz) +{ + _is->skip(sz); +} + +void +InputStreamI::skipSize() +{ + _is->skipSize(); +} + +void +InputStreamI::closure(void* p) { _closure = p; } void* -Ice::InputStreamI::closure() const +InputStreamI::closure() const { return _closure; } @@ -568,7 +401,7 @@ Ice::InputStreamI::closure() const // // OutputStreamI // -Ice::OutputStreamI::OutputStreamI(const Ice::CommunicatorPtr& communicator, BasicStream* os) : +OutputStreamI::OutputStreamI(const CommunicatorPtr& communicator, BasicStream* os) : _communicator(communicator), _os(os), _own(!os) { if(!_os) @@ -579,7 +412,7 @@ Ice::OutputStreamI::OutputStreamI(const Ice::CommunicatorPtr& communicator, Basi _os->closure(this); } -Ice::OutputStreamI::~OutputStreamI() +OutputStreamI::~OutputStreamI() { if(_own) { @@ -588,31 +421,31 @@ Ice::OutputStreamI::~OutputStreamI() } CommunicatorPtr -Ice::OutputStreamI::communicator() const +OutputStreamI::communicator() const { return _communicator; } void -Ice::OutputStreamI::writeObject(const ObjectPtr& v) +OutputStreamI::writeObject(const ObjectPtr& v) { _os->write(v); } void -Ice::OutputStreamI::writeException(const UserException& v) +OutputStreamI::writeException(const UserException& v) { _os->write(v); } void -Ice::OutputStreamI::writeProxy(const ObjectPrx& v) +OutputStreamI::writeProxy(const ObjectPrx& v) { _os->write(v); } void -Ice::OutputStreamI::writeSize(Int sz) +OutputStreamI::writeSize(Int sz) { if(sz < 0) { @@ -623,61 +456,61 @@ Ice::OutputStreamI::writeSize(Int sz) } void -Ice::OutputStreamI::write(bool v) +OutputStreamI::write(bool v) { _os->write(v); } void -Ice::OutputStreamI::write(Byte v) +OutputStreamI::write(Byte v) { _os->write(v); } void -Ice::OutputStreamI::write(Short v) +OutputStreamI::write(Short v) { _os->write(v); } void -Ice::OutputStreamI::write(Int v) +OutputStreamI::write(Int v) { _os->write(v); } void -Ice::OutputStreamI::write(Long v) +OutputStreamI::write(Long v) { _os->write(v); } void -Ice::OutputStreamI::write(Float v) +OutputStreamI::write(Float v) { _os->write(v); } void -Ice::OutputStreamI::write(Double v) +OutputStreamI::write(Double v) { _os->write(v); } void -Ice::OutputStreamI::write(const string& v, bool convert) +OutputStreamI::write(const string& v, bool convert) { _os->write(v, convert); } void -Ice::OutputStreamI::write(const char* v, bool convert) +OutputStreamI::write(const char* v, bool convert) { _os->write(v, convert); } void -Ice::OutputStreamI::write(const vector<string>& v, bool convert) +OutputStreamI::write(const vector<string>& v, bool convert) { if(v.size() == 0) { @@ -690,121 +523,139 @@ Ice::OutputStreamI::write(const vector<string>& v, bool convert) } void -Ice::OutputStreamI::write(const wstring& v) +OutputStreamI::write(const wstring& v) { _os->write(v); } void -Ice::OutputStreamI::write(const bool* begin, const bool* end) +OutputStreamI::write(const bool* begin, const bool* end) { _os->write(begin, end); } void -Ice::OutputStreamI::write(const Byte* begin, const Byte* end) +OutputStreamI::write(const Byte* begin, const Byte* end) { _os->write(begin, end); } void -Ice::OutputStreamI::write(const Int* begin, const Int* end) +OutputStreamI::write(const Short* begin, const Short* end) { _os->write(begin, end); } void -Ice::OutputStreamI::write(const Long* begin, const Long* end) +OutputStreamI::write(const Int* begin, const Int* end) { _os->write(begin, end); } void -Ice::OutputStreamI::write(const Float* begin, const Float* end) +OutputStreamI::write(const Long* begin, const Long* end) { _os->write(begin, end); } void -Ice::OutputStreamI::write(const Double* begin, const Double* end) +OutputStreamI::write(const Float* begin, const Float* end) { _os->write(begin, end); } void -Ice::OutputStreamI::format(FormatType format) +OutputStreamI::write(const Double* begin, const Double* end) +{ + _os->write(begin, end); +} + +void +OutputStreamI::writeOptional(Int tag, OptionalType type) +{ + _os->writeOpt(tag, type); +} + +void +OutputStreamI::format(FormatType format) { _os->format(format); } void -Ice::OutputStreamI::startObject(const SlicedDataPtr& slicedData) +OutputStreamI::startObject(const SlicedDataPtr& slicedData) { _os->startWriteObject(slicedData); } void -Ice::OutputStreamI::endObject() +OutputStreamI::endObject() { _os->endWriteObject(); } void -Ice::OutputStreamI::startException(const SlicedDataPtr& slicedData) +OutputStreamI::startException(const SlicedDataPtr& slicedData) { _os->startWriteException(slicedData); } void -Ice::OutputStreamI::endException() +OutputStreamI::endException() { _os->endWriteException(); } void -Ice::OutputStreamI::startSlice(const string& typeId, bool lastSlice) +OutputStreamI::startSlice(const string& typeId, bool lastSlice) { _os->startWriteSlice(typeId, lastSlice); } void -Ice::OutputStreamI::endSlice() +OutputStreamI::endSlice() { _os->endWriteSlice(); } void -Ice::OutputStreamI::startEncapsulation(const Ice::EncodingVersion& version) +OutputStreamI::startEncapsulation(const EncodingVersion& version) { _os->startWriteEncaps(version); } void -Ice::OutputStreamI::startEncapsulation() +OutputStreamI::startEncapsulation() { _os->startWriteEncaps(); } void -Ice::OutputStreamI::endEncapsulation() +OutputStreamI::endEncapsulation() { _os->endWriteEncapsChecked(); } +EncodingVersion +OutputStreamI::getEncoding() +{ + return _os->getWriteEncoding(); +} + void -Ice::OutputStreamI::writePendingObjects() +OutputStreamI::writePendingObjects() { _os->writePendingObjects(); } void -Ice::OutputStreamI::finished(vector<Byte>& bytes) +OutputStreamI::finished(vector<Byte>& bytes) { vector<Byte>(_os->b.begin(), _os->b.end()).swap(bytes); } void -Ice::OutputStreamI::reset(bool clearBuffer) +OutputStreamI::reset(bool clearBuffer) { _os->clear(); @@ -820,229 +671,29 @@ Ice::OutputStreamI::reset(bool clearBuffer) _os->i = _os->b.begin(); } -void -Ice::OutputStreamI::writeBool(bool v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeBoolSeq(const vector<bool>& v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeBoolSeq(const bool* begin, const bool* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::writeByte(Byte v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeByteSeq(const vector<Byte>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } -} - -void -Ice::OutputStreamI::writeByteSeq(const Ice::Byte* begin, const Ice::Byte* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::writeShort(Short v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeShortSeq(const vector<Short>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } -} - -void -Ice::OutputStreamI::writeShortSeq(const Ice::Short* begin, const Ice::Short* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::writeInt(Int v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeIntSeq(const vector<Int>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } -} - -void -Ice::OutputStreamI::writeIntSeq(const Ice::Int* begin, const Ice::Int* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::writeLong(Long v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeLongSeq(const vector<Long>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } -} - -void -Ice::OutputStreamI::writeLongSeq(const Ice::Long* begin, const Ice::Long* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::writeFloat(Float v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeFloatSeq(const vector<Float>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } -} - -void -Ice::OutputStreamI::writeFloatSeq(const Ice::Float* begin, const Ice::Float* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::writeDouble(Double v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeDoubleSeq(const vector<Double>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } -} - -void -Ice::OutputStreamI::writeDoubleSeq(const Ice::Double* begin, const Ice::Double* end) -{ - write(begin, end); -} - -void -Ice::OutputStreamI::write(const Short* begin, const Short* end) -{ - _os->write(begin, end); -} - -void -Ice::OutputStreamI::writeString(const string& v, bool convert) +OutputStream::size_type +OutputStreamI::pos() { - _os->write(v, convert); + return _os->pos(); } void -Ice::OutputStreamI::writeStringSeq(const vector<string>& v, bool convert) +OutputStreamI::rewrite(size_type p, Int sz) { - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size(), convert); - } -} - -void -Ice::OutputStreamI::writeWstring(const wstring& v) -{ - _os->write(v); -} - -void -Ice::OutputStreamI::writeWstringSeq(const vector<wstring>& v) -{ - if(v.size() == 0) - { - _os->writeSize(0); - } - else - { - _os->write(&v[0], &v[0] + v.size()); - } + _os->rewrite(p, sz); } // // ObjectReader // void -Ice::ObjectReader::__write(BasicStream*) const +ObjectReader::__write(BasicStream*) const { assert(false); } void -Ice::ObjectReader::__read(BasicStream* is) +ObjectReader::__read(BasicStream* is) { InputStreamI* stream = reinterpret_cast<InputStreamI*>(is->closure()); assert(stream); @@ -1050,13 +701,13 @@ Ice::ObjectReader::__read(BasicStream* is) } void -Ice::ObjectReader::__write(const Ice::OutputStreamPtr&) const +ObjectReader::__write(const OutputStreamPtr&) const { assert(false); } void -Ice::ObjectReader::__read(const Ice::InputStreamPtr&) +ObjectReader::__read(const InputStreamPtr&) { assert(false); } @@ -1065,7 +716,7 @@ Ice::ObjectReader::__read(const Ice::InputStreamPtr&) // ObjectWriter // void -Ice::ObjectWriter::__write(BasicStream* os) const +ObjectWriter::__write(BasicStream* os) const { OutputStreamI* stream = reinterpret_cast<OutputStreamI*>(os->closure()); assert(stream); @@ -1073,19 +724,19 @@ Ice::ObjectWriter::__write(BasicStream* os) const } void -Ice::ObjectWriter::__read(BasicStream*) +ObjectWriter::__read(BasicStream*) { assert(false); } void -Ice::ObjectWriter::__write(const Ice::OutputStreamPtr&) const +ObjectWriter::__write(const OutputStreamPtr&) const { assert(false); } void -Ice::ObjectWriter::__read(const Ice::InputStreamPtr&) +ObjectWriter::__read(const InputStreamPtr&) { assert(false); } @@ -1093,17 +744,17 @@ Ice::ObjectWriter::__read(const Ice::InputStreamPtr&) // // UserExceptionWriter // -Ice::UserExceptionWriter::UserExceptionWriter(const Ice::CommunicatorPtr& communicator) : +UserExceptionWriter::UserExceptionWriter(const CommunicatorPtr& communicator) : _communicator(communicator) { } -Ice::UserExceptionWriter::~UserExceptionWriter() throw() +UserExceptionWriter::~UserExceptionWriter() throw() { } void -Ice::UserExceptionWriter::__write(BasicStream* os) const +UserExceptionWriter::__write(BasicStream* os) const { OutputStreamI* stream = reinterpret_cast<OutputStreamI*>(os->closure()); if(!stream) @@ -1117,13 +768,13 @@ Ice::UserExceptionWriter::__write(BasicStream* os) const } void -Ice::UserExceptionWriter::__read(BasicStream*) +UserExceptionWriter::__read(BasicStream*) { assert(false); } bool -Ice::UserExceptionWriter::__usesClasses() const +UserExceptionWriter::__usesClasses() const { return usesClasses(); } diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h index 947fb7ee681..4041d126efd 100644 --- a/cpp/src/Ice/StreamI.h +++ b/cpp/src/Ice/StreamI.h @@ -38,43 +38,6 @@ public: virtual void sliceObjects(bool); - // - // These methods should be removed when the old stream API is removed. - // - virtual bool readBool(); - virtual Byte readByte(); - virtual Short readShort(); - virtual Int readInt(); - virtual Long readLong(); - virtual Float readFloat(); - virtual Double readDouble(); - virtual ::std::string readString(bool = true); - virtual ::std::wstring readWstring(); - - // - // These methods should be removed when the old stream API is removed. - // - virtual std::vector< bool > readBoolSeq(); - virtual std::vector< Byte > readByteSeq(); - virtual std::vector< Short > readShortSeq(); - virtual std::vector< Int > readIntSeq(); - virtual std::vector< Long > readLongSeq(); - virtual std::vector< Float > readFloatSeq(); - virtual std::vector< Double > readDoubleSeq(); - virtual std::vector< std::string > readStringSeq(bool = true); - virtual std::vector< std::wstring > readWstringSeq(); - - // - // These methods should be removed when the old stream API is removed. - // - virtual bool* readBoolSeq(std::pair<const bool*, const bool*>&); - virtual void readByteSeq(std::pair<const Byte*, const Byte*>&); - virtual Short* readShortSeq(std::pair<const Short*, const Short*>&); - virtual Int* readIntSeq(std::pair<const Int*, const Int*>&); - virtual Long* readLongSeq(std::pair<const Long*, const Long*>&); - virtual Float* readFloatSeq(std::pair<const Float*, const Float*>&); - virtual Double* readDoubleSeq(std::pair<const Double*, const Double*>&); - virtual Int readSize(); virtual Int readAndCheckSeqSize(int); @@ -98,9 +61,14 @@ public: virtual void endEncapsulation(); virtual Ice::EncodingVersion skipEncapsulation(); + virtual Ice::EncodingVersion getEncoding(); + virtual void readPendingObjects(); virtual void rewind(); + + virtual void skip(Ice::Int); + virtual void skipSize(); virtual void read(bool& v); virtual void read(Byte& v); @@ -120,6 +88,8 @@ public: virtual void read(std::pair<const Float*, const Float*>&, ::IceUtil::ScopedArray<Float>&); virtual void read(std::pair<const Double*, const Double*>&, ::IceUtil::ScopedArray<Double>&); + virtual bool readOptional(Int, OptionalType); + virtual void closure(void*); virtual void* closure() const; @@ -143,43 +113,6 @@ public: virtual CommunicatorPtr communicator() const; - // - // These methods should be removed when the old stream API is removed. - // - virtual void writeBool(bool); - virtual void writeByte(Byte); - virtual void writeShort(Short); - virtual void writeInt(Int); - virtual void writeLong(Long); - virtual void writeFloat(Float); - virtual void writeDouble(Double); - virtual void writeString(const ::std::string&, bool = true); - virtual void writeWstring(const ::std::wstring&); - - // - // These methods should be removed when the old stream API is removed. - // - virtual void writeBoolSeq(const std::vector< bool >&); - virtual void writeByteSeq(const std::vector< Byte >&); - virtual void writeShortSeq(const std::vector< Short >&); - virtual void writeIntSeq(const std::vector< Int >&); - virtual void writeLongSeq(const std::vector< Long >&); - virtual void writeFloatSeq(const std::vector< Float >&); - virtual void writeDoubleSeq(const std::vector< Double >&); - virtual void writeStringSeq(const std::vector< std::string >&, bool = true); - virtual void writeWstringSeq(const std::vector< std::wstring >&); - - // - // These methods should be removed when the old stream API is removed. - // - virtual void writeBoolSeq(const bool*, const bool*); - virtual void writeByteSeq(const Byte*, const Byte*); - virtual void writeShortSeq(const Short*, const Short*); - virtual void writeIntSeq(const Int*, const Int*); - virtual void writeLongSeq(const Long*, const Long*); - virtual void writeFloatSeq(const Float*, const Float*); - virtual void writeDoubleSeq(const Double*, const Double*); - virtual void writeObject(const ObjectPtr&); virtual void writeException(const UserException&); virtual void writeProxy(const ObjectPrx&); @@ -206,6 +139,8 @@ public: virtual void write(const Float*, const Float*); virtual void write(const Double*, const Double*); + virtual void writeOptional(Int, OptionalType); + virtual void format(FormatType); virtual void startObject(const SlicedDataPtr&); @@ -221,12 +156,17 @@ public: virtual void startEncapsulation(); virtual void endEncapsulation(); + virtual Ice::EncodingVersion getEncoding(); + virtual void writePendingObjects(); virtual void finished(std::vector< Byte >&); virtual void reset(bool); + virtual size_type pos(); + virtual void rewrite(size_type, Int); + private: const CommunicatorPtr _communicator; diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp index 2f377159042..3dcd019b209 100644 --- a/cpp/src/Ice/TraceUtil.cpp +++ b/cpp/src/Ice/TraceUtil.cpp @@ -100,8 +100,7 @@ printRequestHeader(ostream& s, BasicStream& stream) } } - Int sz; - stream.readSize(sz); + Int sz = stream.readSize(); s << "\ncontext = "; while(sz--) { diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 350df152b29..399cecd678b 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -450,3 +450,37 @@ IceUtil::FileLockException::error() const { return _error; } + +IceUtil::OptionalNotSetException::OptionalNotSetException(const char* file, int line) : + Exception(file, line) +{ + if(IceUtilInternal::nullHandleAbort) + { + abort(); + } +} + +IceUtil::OptionalNotSetException::~OptionalNotSetException() throw() +{ +} + +const char* IceUtil::OptionalNotSetException::_name = "IceUtil::OptionalNotSetException"; + +string +IceUtil::OptionalNotSetException::ice_name() const +{ + return _name; +} + +IceUtil::Exception* +IceUtil::OptionalNotSetException::ice_clone() const +{ + return new OptionalNotSetException(*this); +} + +void +IceUtil::OptionalNotSetException::ice_throw() const +{ + throw *this; +} + diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 98d2aa98510..9b9cf36490c 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -20,6 +20,299 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; +namespace +{ + +string toTemplateArg(const string& arg) +{ + if(arg.empty()) + { + return arg; + } + string fixed = arg; + if(arg[0] == ':') + { + fixed = " " + fixed; + } + if(fixed[fixed.length() - 1] == '>') + { + fixed = fixed + " "; + } + return fixed; +} + +string +sequenceTypeToString(const SequencePtr& seq, const StringList& metaData, int typeCtx) +{ + string seqType = findMetaData(metaData, typeCtx); + if(!seqType.empty()) + { + if(seqType == "array" || seqType == "range:array") + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(typeCtx & TypeContextAMIPrivateEnd) + { + if(builtin && builtin->kind() == Builtin::KindByte) + { + string s = typeToString(seq->type()); + return "::std::pair<const " + s + "*, const " + s + "*>"; + } + else if(builtin && + builtin->kind() != Builtin::KindString && + builtin->kind() != Builtin::KindObject && + builtin->kind() != Builtin::KindObjectProxy) + { + string s = toTemplateArg(typeToString(builtin)); + return "::std::pair< ::IceUtil::ScopedArray<" + s + ">, " + + "::std::pair<const " + s + "*, const " + s + "*> >"; + } + else + { + string s = toTemplateArg(typeToString(seq->type(), seq->typeMetaData(), + inWstringModule(seq) ? TypeContextUseWstring : 0)); + return "::std::vector<" + s + '>'; + } + } + string s = typeToString(seq->type(), seq->typeMetaData(), inWstringModule(seq) ? TypeContextUseWstring : 0); + return "::std::pair<const " + s + "*, const " + s + "*>"; + } + else if(seqType.find("range") == 0) + { + string s; + if(seqType.find("range:") == 0) + { + s = seqType.substr(strlen("range:")); + } + else + { + s = fixKwd(seq->scoped()); + } + if(typeCtx & TypeContextAMIPrivateEnd) + { + return s; + } + if(s[0] == ':') + { + s = " " + s; + } + return "::std::pair<" + s + "::const_iterator, " + s + "::const_iterator>"; + } + else + { + return seqType; + } + } + else + { + // Get the metadata associated at the point of definition. + bool protobuf; + seqType = findMetaData(seq, seq->getMetaData(), protobuf, typeCtx); + if(protobuf && !seqType.empty()) + { + return seqType; + } + return fixKwd(seq->scoped()); + } +} + +void +writeParamAllocateCode(Output& out, const TypePtr& type, bool optional, const string& fixedName, + const StringList& metaData, int typeCtx) +{ + string s = typeToString(type, metaData, typeCtx); + if(optional) + { + s = "IceUtil::Optional<" + toTemplateArg(s) + '>'; + } + out << nl << s << ' ' << fixedName << ';'; + + if(!(typeCtx & TypeContextInParam)) + { + return; // We're done. + } + + // + // If using a range or array we need to allocate the range container, or + // array as well now to ensure they are always in the same scope. + // + SequencePtr seq = SequencePtr::dynamicCast(type); + if(seq) + { + bool protobuf; + string seqType = findMetaData(seq, metaData, protobuf, typeCtx); + if(!protobuf && seqType.empty()) + { + seqType = findMetaData(seq, seq->getMetaData(), protobuf, typeCtx); + } + if(protobuf) + { + return; + } + + string s; + if(seqType == "array" || seqType == "range:array") + { + s = typeToString(seq, metaData, TypeContextAMIPrivateEnd); + } + else if(seqType.find("range") == 0) + { + StringList md; + if(seqType.find("range:") == 0) + { + md.push_back("cpp:type:" + seqType.substr(strlen("range:"))); + } + s = typeToString(seq, md); + } + + if(!s.empty()) + { + if(optional) + { + s = "IceUtil::Optional<" + toTemplateArg(s) + '>'; + } + out << nl << s << " ___" << fixedName << ";"; + } + } +} + +void +writeParamEndCode(Output& out, const TypePtr& type, bool optional, const string& fixedName, const StringList& metaData) +{ + SequencePtr seq = SequencePtr::dynamicCast(type); + if(seq) + { + bool protobuf; + string seqType = findMetaData(seq, metaData, protobuf, TypeContextInParam); + if(!protobuf && seqType.empty()) + { + seqType = findMetaData(seq, seq->getMetaData(), protobuf, TypeContextInParam); + } + if(!protobuf) + { + if(seqType == "array" || seqType == "range:array") + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && + builtin->kind() != Builtin::KindByte && + builtin->kind() != Builtin::KindString && + builtin->kind() != Builtin::KindObject && + builtin->kind() != Builtin::KindObjectProxy) + { + if(optional) + { + out << nl << "if(___" << fixedName << ")"; + out << sb; + out << nl << fixedName << " = ___" << fixedName << "->second;"; + out << eb; + } + else + { + out << nl << fixedName << " = ___" << fixedName << ".second;"; + } + } + else if(!builtin || + builtin->kind() == Builtin::KindString || + builtin->kind() == Builtin::KindObject || + builtin->kind() == Builtin::KindObjectProxy) + { + if(optional) + { + out << nl << "if(___" << fixedName << ")"; + out << sb; + out << nl << fixedName << ".__setIsSet();"; + out << nl << fixedName << "->first" << " = &(*___" << fixedName << ")[0];"; + out << nl << fixedName << "->second" << " = " << fixedName << "->first + " << "___" + << fixedName << "->size();"; + out << eb; + } + else + { + out << nl << fixedName << ".first" << " = &___" << fixedName << "[0];"; + out << nl << fixedName << ".second" << " = " << fixedName << ".first + " << "___" + << fixedName << ".size();"; + } + } + } + else if(seqType.find("range") == 0) + { + if(optional) + { + out << nl << "if(___" << fixedName << ")"; + out << sb; + out << nl << fixedName << ".__setIsSet();"; + out << nl << fixedName << "->first = (*___" << fixedName << ").begin();"; + out << nl << fixedName << "->second = (*___" << fixedName << ").end();"; + out << eb; + } + else + { + out << nl << fixedName << ".first = ___" << fixedName << ".begin();"; + out << nl << fixedName << ".second = ___" << fixedName << ".end();"; + } + } + } + } +} + +void +writeMarshalUnmarshalParams(Output& out, const ParamDeclList& params, const OperationPtr& op, bool marshal, int typeCtx) +{ + // + // Marshal non optional parameters. + // + ParamDeclList optionals; + for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) + { + if((*p)->optional()) + { + optionals.push_back(*p); + } + else + { + writeMarshalUnmarshalCode(out, (*p)->type(), false, 0, fixKwd((*p)->name()), marshal, (*p)->getMetaData(), + typeCtx); + } + } + if(op && op->returnType()) + { + if(!op->returnIsOptional()) + { + writeMarshalUnmarshalCode(out, op->returnType(), false, 0, "__ret", marshal, op->getMetaData(), typeCtx); + } + } + + // + // Sort optional parameters by tag. + // + class SortFn + { + public: + static bool compare(const ParamDeclPtr& lhs, const ParamDeclPtr& rhs) + { + return lhs->tag() < rhs->tag(); + } + }; + optionals.sort(SortFn::compare); + + // + // Marshal optional parameters. + // + bool checkReturnType = op && op->returnIsOptional(); + for(ParamDeclList::const_iterator p = optionals.begin(); p != optionals.end(); ++p) + { + if(checkReturnType && op->returnTag() < (*p)->tag()) + { + writeMarshalUnmarshalCode(out, op->returnType(), true, op->returnTag(), "__ret", marshal, + op->getMetaData(), typeCtx); + checkReturnType = false; + } + writeMarshalUnmarshalCode(out, (*p)->type(), true, (*p)->tag(), fixKwd((*p)->name()), marshal, + (*p)->getMetaData(), typeCtx); + } +} + +} + Slice::FeatureProfile Slice::featureProfile = Slice::Ice; char @@ -107,100 +400,6 @@ Slice::printDllExportStuff(Output& out, const string& dllExport) } } -namespace -{ - -string -sequenceTypeToString(const SequencePtr& seq, const StringList& metaData, int typeCtx) -{ - string seqType = findMetaData(metaData, typeCtx); - if(!seqType.empty()) - { - if(seqType == "array" || seqType == "range:array") - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); - if(typeCtx & TypeContextAMIPrivateEnd) - { - if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy) - { - seqType = findMetaData(seq->getMetaData()); - if(seqType.empty()) - { - return typeToString(seq); - } - else - { - return "::std::vector< " + typeToString(seq->type()) + ">"; - } - } - else if(builtin->kind() == Builtin::KindByte) - { - string s = typeToString(seq->type()); - return "::std::pair<const " + s + "*, const " + s + "*>"; - } - else if(builtin->kind() != Builtin::KindString && - builtin->kind() != Builtin::KindObject && - builtin->kind() != Builtin::KindObjectProxy) - { - string s = typeToString(builtin); - if(s[0] == ':') - { - s = " " + s; - } - return "::std::pair< ::IceUtil::ScopedArray<" + s + ">," + - " ::std::pair<const " + s + "*, const " + s + "*> >"; - } - else - { - return "::std::vector< " + typeToString(seq->type(), - seq->typeMetaData(), - inWstringModule(seq) ? TypeContextUseWstring : 0) + ">"; - } - } - string s = typeToString(seq->type(), seq->typeMetaData(), inWstringModule(seq) ? TypeContextUseWstring : 0); - return "::std::pair<const " + s + "*, const " + s + "*>"; - } - else if(seqType.find("range") == 0) - { - string s; - if(seqType.find("range:") == 0) - { - s = seqType.substr(strlen("range:")); - } - else - { - s = fixKwd(seq->scoped()); - } - if(typeCtx & TypeContextAMIPrivateEnd) - { - return s; - } - if(s[0] == ':') - { - s = " " + s; - } - return "::std::pair<" + s + "::const_iterator, " + s + "::const_iterator>"; - } - else - { - return seqType; - } - } - else - { - // Get the metadata associated at the point of definition. - bool protobuf; - seqType = findMetaData(seq, seq->getMetaData(), protobuf, typeCtx); - if(protobuf && !seqType.empty()) - { - return seqType; - } - return fixKwd(seq->scoped()); - } -} - -} - string Slice::typeToString(const TypePtr& type, const StringList& metaData, int typeCtx) { @@ -284,18 +483,36 @@ Slice::typeToString(const TypePtr& type, const StringList& metaData, int typeCtx } string -Slice::returnTypeToString(const TypePtr& type, const StringList& metaData, int typeCtx) +Slice::typeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx) +{ + if(optional) + { + return "IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx)) + ">"; + } + else + { + return typeToString(type, metaData, typeCtx); + } +} + +string +Slice::returnTypeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx) { if(!type) { return "void"; } + if(optional) + { + return "IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx)) + ">"; + } + return typeToString(type, metaData, typeCtx); } string -Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, int typeCtx) +Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx) { static const char* inputBuiltinTable[] = { @@ -314,6 +531,11 @@ Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, int ty typeCtx |= TypeContextInParam; + if(optional) + { + return "const IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx)) +">&"; + } + BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) { @@ -379,7 +601,7 @@ Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, int ty } string -Slice::outputTypeToString(const TypePtr& type, const StringList& metaData, int typeCtx) +Slice::outputTypeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx) { static const char* outputBuiltinTable[] = { @@ -395,6 +617,11 @@ Slice::outputTypeToString(const TypePtr& type, const StringList& metaData, int t "::Ice::ObjectPrx&", "::Ice::LocalObjectPtr&" }; + + if(optional) + { + return "IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx)) +">&"; + } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) @@ -595,560 +822,97 @@ Slice::fixKwd(const string& name) } void -Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& fixedParam, bool marshal, - const string& str, bool pointer, const StringList& metaData, int typeCtx) +Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, bool optional, int tag, const string& param, + bool marshal, const StringList& metaData, int typeCtx, const string& str, bool pointer) { - string stream; + ostringstream os; if(str.empty()) { - stream = marshal ? "__os" : "__is"; + os << (marshal ? "__os" : "__is"); } else { - stream = str; + os << str; } string deref; if(pointer) { - deref = "->"; + os << "->"; } else { - deref = '.'; + os << '.'; } - - string func = marshal ? "write(" : "read("; - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(builtin) + if(marshal) { - if(builtin->kind() == Builtin::KindObject) - { - if(marshal) - { - out << nl << stream << deref << func << fixedParam << ");"; - } - else - { - out << nl << stream << deref << func << "::Ice::__patch__ObjectPtr, &" << fixedParam << ");"; - } - return; - } - else - { - out << nl << stream << deref << func << fixedParam << ");"; - return; - } + os << "write("; } - - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if(cl) + else { - string scope = fixKwd(cl->scope()); - if(marshal) - { - out << nl << stream << deref << "write(::Ice::ObjectPtr(" << scope << "upCast(" << fixedParam - << ".get())));"; - } - else - { - out << nl << stream << deref << "read(" << scope << "__patch__" << cl->name() << "Ptr, &" << fixedParam - << ");"; - } - - return; + os << "read("; } - ProxyPtr px = ProxyPtr::dynamicCast(type); - if(px) - { - string scope = fixKwd(px->_class()->scope()); - if(marshal) - { - out << nl << stream << deref << "write(::Ice::ObjectPrx(::IceProxy" << scope << "upCast(" << fixedParam - << ".get())));"; - } - else - { - out << nl << scope << "__read(" << (pointer ? "" : "&") << stream << ", " << fixedParam << ");"; - } - return; - } - - StructPtr st = StructPtr::dynamicCast(type); - if(st) + if(optional) { - string deref; - if(findMetaData(st->getMetaData()) == "class") - { - if(!marshal) - { - out << nl << fixedParam << " = new " << fixKwd(st->scoped()) << ";"; - } - out << nl << fixedParam << "->__" << func << (pointer ? "" : "&") << stream << ");"; - } - else - { - out << nl << fixedParam << ".__" << func << (pointer ? "" : "&") << stream << ");"; - } - return; + os << tag << ", "; } - - SequencePtr seq = SequencePtr::dynamicCast(type); - if(seq) - { - builtin = BuiltinPtr::dynamicCast(seq->type()); - string funcSeq = (marshal ? "write" : "read") + fixKwd(seq->name()) + "("; - - if(marshal) - { - string seqType = findMetaData(metaData, typeCtx); - string scope = fixKwd(seq->scope()); - if(seqType == "array" || seqType == "range:array") - { - // - // Use array (pair<const TYPE*, const TYPE*>). In parameters only. - // - if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy) - { - // - // Sequence type in not handled by BasicStream functions. If the sequence is the - // default vector than we can use the sequences generated write function. Otherwise - // we need to generate marshal code to write each element. - // - seqType = findMetaData(seq->getMetaData()); - if(seqType.empty()) - { - out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", " - << fixedParam << ".first, " << fixedParam << ".second);"; - } - else - { - out << nl << "::Ice::Int __sz_" << fixedParam << " = static_cast< ::Ice::Int>(" << fixedParam - << ".second - " << fixedParam << ".first);"; - out << nl << stream << deref << "writeSize(__sz_" << fixedParam << ");"; - out << nl << "for(int __i_" << fixedParam << " = 0; __i_" << fixedParam << " < __sz_" - << fixedParam << "; ++__i_" << fixedParam << ")"; - out << sb; - writeMarshalUnmarshalCode(out, seq->type(), fixedParam + ".first[__i_" + fixedParam + "]", - true); - out << eb; - } - } - else - { - // - // Use BasicStream write functions. - // - out << nl << stream << deref << func << fixedParam << ".first, " << fixedParam << ".second);"; - } - } - else if(seqType.find("range") == 0) - { - // - // Use range (pair<TYPE::const_iterator, TYPE::const_iterator). Only for in paramaters. - // Need to check if the range defines an iterator type other than the actual sequence - // type. - // - StringList l; - if(seqType.find("range:") == 0) - { - seqType = seqType.substr(strlen("range:")); - l.push_back("cpp:" + seqType); - } - else - { - seqType = fixKwd(seq->scoped()); - } - out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(IceUtilInternal::distance(" - << fixedParam << ".first, " << fixedParam << ".second)));"; - out << nl << "for(" << seqType << "::const_iterator ___" << fixedParam << " = " - << fixedParam << ".first; ___" << fixedParam << " != " << fixedParam << ".second; ++___" - << fixedParam << ")"; - out << sb; - writeMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true, "", true, l); - out << eb; - } - else if(!seqType.empty()) - { - out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));"; - out << nl << seqType << "::const_iterator __p_" << fixedParam << ";"; - out << nl << "for(__p_" << fixedParam << " = " << fixedParam << ".begin(); __p_" << fixedParam - << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")"; - out << sb; - writeMarshalUnmarshalCode(out, seq->type(), "(*__p_" + fixedParam + ")", true); - out << eb; - } - else - { - // - // No modifying metadata specified. Use appropriate write methods for type. - // - bool protobuf; - seqType = findMetaData(seq, seq->getMetaData(), protobuf); - if(protobuf || !seqType.empty()) - { - out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", " << fixedParam - << ");"; - } - else if(!builtin || - builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) - { - out << nl << "if(" << fixedParam << ".size() == 0)"; - out << sb; - out << nl << stream << deref << "writeSize(0);"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", &" - << fixedParam << "[0], &" << fixedParam << "[0] + " << fixedParam << ".size());"; - out << eb; - } - else if(builtin->kind() == Builtin::KindBool) - { - out << nl << stream << deref << func << fixedParam << ");"; - } - else - { - out << nl << "if(" << fixedParam << ".size() == 0)"; - out << sb; - out << nl << stream << deref << "writeSize(0);"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << stream << deref << func << "&" << fixedParam << "[0], &" << fixedParam - << "[0] + " << fixedParam << ".size());"; - out << eb; - } - } - } - else + string func = os.str(); + if(!marshal) + { + SequencePtr seq = SequencePtr::dynamicCast(type); + if(seq && !(typeCtx & TypeContextAMIPrivateEnd)) { string seqType = findMetaData(metaData, typeCtx); - string scope = fixKwd(seq->scope()); if(seqType == "array" || seqType == "range:array") { - // - // Use array (pair<const TYPE*, const TYPE*>). In parameters only. - // - if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy) - { - seqType = findMetaData(seq->getMetaData()); - if(seqType.empty()) - { - out << nl << typeToString(type) << " ___" << fixedParam << ";"; - out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", ___" - << fixedParam << ");"; - } - else - { - seqType = "::std::vector< " + typeToString(seq->type()) + ">"; - StringList l; - l.push_back("cpp:type:" + seqType); - out << nl << seqType << " ___" << fixedParam << ";"; - writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, l); - } - } - else if(builtin->kind() == Builtin::KindByte) - { - out << nl << stream << deref << func << fixedParam << ");"; - } - else if(builtin->kind() != Builtin::KindString && builtin->kind() != Builtin::KindObject && - builtin->kind() != Builtin::KindObjectProxy) - { - string s = typeToString(builtin); - if(s[0] == ':') - { - s = " " + s; - } - - if(typeCtx & TypeContextAMIPrivateEnd) - { - out << nl << fixedParam << ".first.reset(" << stream << deref << func << fixedParam - << ".second));"; - } - else - { - out << nl << "::IceUtil::ScopedArray<" << s << "> ___" << fixedParam << '(' - << stream << deref << func << fixedParam << "));"; - } - } - else + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(builtin && builtin->kind() == Builtin::KindByte) { - out << nl << "::std::vector< " - << typeToString(seq->type(), seq->typeMetaData(), - inWstringModule(seq) ? TypeContextUseWstring : 0) << "> ___" - << fixedParam << ";"; - out << nl << stream << deref << func << "___" << fixedParam << ");"; + out << nl << func << param << ");"; + return; } - if(!builtin || builtin->kind() == Builtin::KindString || builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) - { - if(typeCtx & TypeContextAMIPrivateEnd) - { - out << nl << fixedParam << ".swap(" << "___" << fixedParam << ");"; - } - else - { - out << nl << fixedParam << ".first" << " = &___" << fixedParam << "[0];"; - out << nl << fixedParam << ".second" << " = " << fixedParam << ".first + " << "___" - << fixedParam << ".size();"; - } - } + out << nl << func << "___" << param << ");"; + writeParamEndCode(out, seq, optional, param, metaData); + return; } else if(seqType.find("range") == 0) { - // - // Use range (pair<TYPE::const_iterator, TYPE::const_iterator>). In paramters only. - // Need to check if iterator type other than default is specified. - // - StringList md; - if(seqType.find("range:") == 0) - { - md.push_back("cpp:type:" + seqType.substr(strlen("range:"))); - } - if(typeCtx & TypeContextAMIPrivateEnd) - { - writeMarshalUnmarshalCode(out, seq, fixedParam, false, "", true, md); - } - else - { - writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, md); - out << nl << fixedParam << ".first = ___" << fixedParam << ".begin();"; - out << nl << fixedParam << ".second = ___" << fixedParam << ".end();"; - } - } - else if(!seqType.empty()) - { - // - // Using alternate sequence type. - // - out << nl << "::Ice::Int __sz_" << fixedParam << ";"; - out << nl << stream << deref << "readAndCheckSeqSize(" << seq->type()->minWireSize() << ", __sz_" - << fixedParam << ");"; - out << nl << seqType << "(__sz_" << fixedParam << ").swap(" << fixedParam << ");"; - out << nl << seqType << "::iterator __p_" << fixedParam << ";"; - out << nl << "for(__p_" << fixedParam << " = " << fixedParam << ".begin(); __p_" << fixedParam - << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")"; - out << sb; - writeMarshalUnmarshalCode(out, seq->type(), "(*__p_" + fixedParam + ")", false); - out << eb; - } - else - { - // - // No modifying metadata supplied. Just use - // appropriate read function. - // - bool protobuf; - seqType = findMetaData(seq, seq->getMetaData(), protobuf); - if(protobuf || - !seqType.empty() || - !builtin || - builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) - { - out << nl << scope << "__" << funcSeq << (pointer ? "" : "&") << stream << ", " - << fixedParam << ");"; - } - else if(builtin->kind() == Builtin::KindByte) - { - StringList md; - md.push_back("cpp:array"); - string tmpParam = "___"; - - // - // Catch some case in which it is not possible to just prepend - // underscores to param to use as temporary variable. - // - if(fixedParam.find("(*") == 0) - { - tmpParam += fixedParam.substr(2, fixedParam.length() - 3); - } - else if(fixedParam.find("[i]") != string::npos) - { - tmpParam += fixedParam.substr(0, fixedParam.length() - 3); - } - else if(fixedParam.find("->second") != string::npos) - { - tmpParam += fixedParam.substr(0, fixedParam.length() - 8); - } - else - { - tmpParam += fixedParam; - } - out << nl << typeToString(type, md, TypeContextInParam) << " " << tmpParam << ";"; - out << nl << stream << deref << func << tmpParam << ");"; - out << nl << "::std::vector< ::Ice::Byte>(" << tmpParam << ".first, " << tmpParam - << ".second).swap(" << fixedParam << ");"; - } - else - { - out << nl << stream << deref << func << fixedParam << ");"; - } + out << nl << func << "___" << param << ");"; + writeParamEndCode(out, seq, optional, param, metaData); + return; } } - return; } - - DictionaryPtr dict = DictionaryPtr::dynamicCast(type); - if(dict) - { - string scope = fixKwd(dict->scope()); - string funcDict = (marshal ? "write" : "read") + fixKwd(dict->name()) + "("; - out << nl << scope << "__" << funcDict << (pointer ? "" : "&") << stream << ", " << fixedParam << ");"; - return; - } - - ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); - assert(constructed); - out << nl << fixKwd(constructed->scope()) << "__" << func << (pointer ? "" : "&") << stream << ", " - << fixedParam << ");"; + out << nl << func << param << ");"; } void -Slice::writeMarshalCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData, - int typeCtx) +Slice::writeMarshalCode(Output& out, const ParamDeclList& params, const OperationPtr& op, int typeCtx) { - for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) - { - writeMarshalUnmarshalCode(out, (*p)->type(), fixKwd((*p)->name()), true, "", true, (*p)->getMetaData(), - typeCtx); - } - if(ret) - { - writeMarshalUnmarshalCode(out, ret, "__ret", true, "", true, metaData); - } + writeMarshalUnmarshalParams(out, params, op, true, typeCtx); } void -Slice::writeUnmarshalCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData, - int typeCtx) -{ - for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) - { - writeMarshalUnmarshalCode(out, (*p)->type(), fixKwd((*p)->name()), false, "", true, (*p)->getMetaData(), - typeCtx); - } - if(ret) - { - writeMarshalUnmarshalCode(out, ret, "__ret", false, "", true, metaData, typeCtx); - } -} - -namespace -{ - -void -writeParamAllocateCode(Output& out, const TypePtr& type, const string& fixedName, const StringList& metaData, - int typeCtx) +Slice::writeUnmarshalCode(Output& out, const ParamDeclList& params, const OperationPtr& op, int typeCtx) { - out << nl << typeToString(type, metaData, typeCtx) << ' ' << fixedName; - StructPtr st = StructPtr::dynamicCast(type); - if(st && findMetaData(st->getMetaData()) == "class") - { - out << " = new " << fixKwd(st->scoped()); - } - out << ';'; - - if(!(typeCtx & TypeContextInParam)) - { - return; // We're done. - } - - // - // If using a range or array we need to allocate the range container, or - // array as well now to ensure they are always in the same scope. - // - SequencePtr seq = SequencePtr::dynamicCast(type); - if(seq) - { - bool protobuf; - string seqType = findMetaData(seq, metaData, protobuf, typeCtx); - if(!protobuf && seqType.empty()) - { - seqType = findMetaData(seq, seq->getMetaData(), protobuf, typeCtx); - } - if(protobuf) - { - return; - } - if(seqType == "array" || seqType == "range:array") - { - if(typeCtx & TypeContextAMICallPrivateEnd) - { - out << nl << typeToString(seq, metaData, TypeContextAMIPrivateEnd) << " ___" << fixedName << ";"; -// BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); -// if(builtin && -// builtin->kind() != Builtin::KindByte && -// builtin->kind() != Builtin::KindString && -// builtin->kind() != Builtin::KindObject && -// builtin->kind() != Builtin::KindObjectProxy) -// { -// out << nl << typeToString(seq, metaData, TypeContextAMIPrivateEnd) << " ___" << fixedName << ";"; -// } -// else if(!builtin || builtin->kind() != Builtin::KindByte) -// { -// out << nl << typeToString(seq, metaData) << " ___" << fixedName << ";"; -// } - } - } - else if(seqType.find("range") == 0) - { - StringList md; - if(seqType.find("range:") == 0) - { - md.push_back("cpp:type:" + seqType.substr(strlen("range:"))); - } - out << nl << typeToString(seq, md) << " ___" << fixedName << ";"; - } - } -} - + writeMarshalUnmarshalParams(out, params, op, false, typeCtx); } void -Slice::writeAllocateCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData, - int typeCtx) +Slice::writeAllocateCode(Output& out, const ParamDeclList& params, const OperationPtr& op, int typeCtx) { for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) { - writeParamAllocateCode(out, (*p)->type(), fixKwd((*p)->name()), (*p)->getMetaData(), typeCtx); - } - if(ret) - { - writeParamAllocateCode(out, ret, "__ret", metaData, typeCtx); - } -} - -void -Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal, - const string& str, const StringList& metaData, int typeCtx) -{ - string fixedParam = fixKwd(param); - - string stream; - if(str.empty()) - { - stream = marshal ? "__outS" : "__inS"; - } - else - { - stream = str; + writeParamAllocateCode(out, (*p)->type(), (*p)->optional(), fixKwd((*p)->name()), (*p)->getMetaData(), typeCtx); } - - if(marshal) - { - out << nl << stream << "->write(" << fixedParam << ");"; - } - else + if(op && op->returnType()) { - out << nl << stream << "->read(" << fixedParam << ");"; + writeParamAllocateCode(out, op->returnType(), op->returnIsOptional(), "__ret", op->getMetaData(), typeCtx); } } @@ -1197,63 +961,16 @@ Slice::getEndArg(const TypePtr& type, const StringList& metaData, const string& return endArg; } -namespace -{ - -void -writeParamEndCode(Output& out, const TypePtr& type, const string& fixedName, const StringList& metaData) -{ - SequencePtr seq = SequencePtr::dynamicCast(type); - if(seq) - { - bool protobuf; - string seqType = findMetaData(seq, metaData, protobuf, TypeContextInParam); - if(!protobuf && seqType.empty()) - { - seqType = findMetaData(seq, seq->getMetaData(), protobuf, TypeContextInParam); - } - if(!protobuf) - { - if(seqType == "array" || seqType == "range:array") - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); - if(builtin && - builtin->kind() != Builtin::KindByte && - builtin->kind() != Builtin::KindString && - builtin->kind() != Builtin::KindObject && - builtin->kind() != Builtin::KindObjectProxy) - { - out << nl << fixedName << " = ___" << fixedName << ".second;"; - } - else if(!builtin || builtin->kind() == Builtin::KindString || builtin->kind() == Builtin::KindObject || - builtin->kind() == Builtin::KindObjectProxy) - { - out << nl << fixedName << ".first" << " = &___" << fixedName << "[0];"; - out << nl << fixedName << ".second" << " = " << fixedName << ".first + " << "___" - << fixedName << ".size();"; - } - } - else if(seqType.find("range") == 0) - { - out << nl << fixedName << ".first = ___" << fixedName << ".begin();"; - out << nl << fixedName << ".second = ___" << fixedName << ".end();"; - } - } - } -} - -} - void -Slice::writeEndCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData) +Slice::writeEndCode(Output& out, const ParamDeclList& params, const OperationPtr& op) { for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) { - writeParamEndCode(out, (*p)->type(), fixKwd((*p)->name()), (*p)->getMetaData()); + writeParamEndCode(out, (*p)->type(), (*p)->optional(), fixKwd((*p)->name()), (*p)->getMetaData()); } - if(ret) + if(op && op->returnType()) { - writeParamEndCode(out, ret, "__ret", metaData); + writeParamEndCode(out, op->returnType(), op->returnIsOptional(), "__ret", op->getMetaData()); } } @@ -1307,7 +1024,7 @@ Slice::findMetaData(const SequencePtr& seq, const StringList& metaData, bool& is } return ""; } - else if((typeCtx & (TypeContextInParam | TypeContextAMIPrivateEnd)) && + else if((typeCtx & (TypeContextInParam | TypeContextAMIPrivateEnd)) && !(typeCtx & TypeContextAMIEnd) && ss.find("range:") == 0) { return str.substr(prefix.size()); @@ -1434,3 +1151,23 @@ Slice::inWstringModule(const SequencePtr& seq) } return false; } + + +string +Slice::getDataMemberRef(const DataMemberPtr& p) +{ + string name = fixKwd(p->name()); + if(!p->optional()) + { + return name; + } + + if(BuiltinPtr::dynamicCast(p->type())) + { + return "*" + name; + } + else + { + return "(*" + name + ")"; + } +} diff --git a/cpp/src/Slice/Grammar.cpp b/cpp/src/Slice/Grammar.cpp index 97aef00aed5..d5c742768f2 100644 --- a/cpp/src/Slice/Grammar.cpp +++ b/cpp/src/Slice/Grammar.cpp @@ -1,23 +1,24 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -28,7 +29,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -46,7 +47,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -54,28 +55,117 @@ /* Pure parsers. */ #define YYPURE 1 -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ -#define yyparse slice_parse -#define yylex slice_lex -#define yyerror slice_error -#define yylval slice_lval -#define yychar slice_char -#define yydebug slice_debug -#define yynerrs slice_nerrs +#define yyparse slice_parse +#define yylex slice_lex +#define yyerror slice_error +#define yylval slice_lval +#define yychar slice_char +#define yydebug slice_debug +#define yynerrs slice_nerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_MODULE = 258, + ICE_CLASS = 259, + ICE_INTERFACE = 260, + ICE_EXCEPTION = 261, + ICE_STRUCT = 262, + ICE_SEQUENCE = 263, + ICE_DICTIONARY = 264, + ICE_ENUM = 265, + ICE_OUT = 266, + ICE_EXTENDS = 267, + ICE_IMPLEMENTS = 268, + ICE_THROWS = 269, + ICE_VOID = 270, + ICE_BYTE = 271, + ICE_BOOL = 272, + ICE_SHORT = 273, + ICE_INT = 274, + ICE_LONG = 275, + ICE_FLOAT = 276, + ICE_DOUBLE = 277, + ICE_STRING = 278, + ICE_OBJECT = 279, + ICE_LOCAL_OBJECT = 280, + ICE_LOCAL = 281, + ICE_CONST = 282, + ICE_FALSE = 283, + ICE_TRUE = 284, + ICE_IDEMPOTENT = 285, + ICE_OPTIONAL = 286, + ICE_SCOPE_DELIMITER = 287, + ICE_IDENTIFIER = 288, + ICE_STRING_LITERAL = 289, + ICE_INTEGER_LITERAL = 290, + ICE_FLOATING_POINT_LITERAL = 291, + ICE_IDENT_OP = 292, + ICE_KEYWORD_OP = 293, + ICE_OPTIONAL_OP = 294, + ICE_METADATA_OPEN = 295, + ICE_METADATA_CLOSE = 296, + ICE_GLOBAL_METADATA_OPEN = 297, + ICE_GLOBAL_METADATA_CLOSE = 298, + BAD_CHAR = 299 + }; +#endif +/* Tokens. */ +#define ICE_MODULE 258 +#define ICE_CLASS 259 +#define ICE_INTERFACE 260 +#define ICE_EXCEPTION 261 +#define ICE_STRUCT 262 +#define ICE_SEQUENCE 263 +#define ICE_DICTIONARY 264 +#define ICE_ENUM 265 +#define ICE_OUT 266 +#define ICE_EXTENDS 267 +#define ICE_IMPLEMENTS 268 +#define ICE_THROWS 269 +#define ICE_VOID 270 +#define ICE_BYTE 271 +#define ICE_BOOL 272 +#define ICE_SHORT 273 +#define ICE_INT 274 +#define ICE_LONG 275 +#define ICE_FLOAT 276 +#define ICE_DOUBLE 277 +#define ICE_STRING 278 +#define ICE_OBJECT 279 +#define ICE_LOCAL_OBJECT 280 +#define ICE_LOCAL 281 +#define ICE_CONST 282 +#define ICE_FALSE 283 +#define ICE_TRUE 284 +#define ICE_IDEMPOTENT 285 +#define ICE_OPTIONAL 286 +#define ICE_SCOPE_DELIMITER 287 +#define ICE_IDENTIFIER 288 +#define ICE_STRING_LITERAL 289 +#define ICE_INTEGER_LITERAL 290 +#define ICE_FLOATING_POINT_LITERAL 291 +#define ICE_IDENT_OP 292 +#define ICE_KEYWORD_OP 293 +#define ICE_OPTIONAL_OP 294 +#define ICE_METADATA_OPEN 295 +#define ICE_METADATA_CLOSE 296 +#define ICE_GLOBAL_METADATA_OPEN 297 +#define ICE_GLOBAL_METADATA_CLOSE 298 +#define BAD_CHAR 299 + -/* Copy the first part of user declarations. */ -/* Line 189 of yacc.c */ +/* Copy the first part of user declarations. */ #line 1 "../Slice/Grammar.y" @@ -122,9 +212,6 @@ slice_error(const char* s) -/* Line 189 of yacc.c */ -#line 127 "Grammar.tab.c" - /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -143,73 +230,20 @@ slice_error(const char* s) # define YYTOKEN_TABLE 0 #endif - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ICE_MODULE = 258, - ICE_CLASS = 259, - ICE_INTERFACE = 260, - ICE_EXCEPTION = 261, - ICE_STRUCT = 262, - ICE_SEQUENCE = 263, - ICE_DICTIONARY = 264, - ICE_ENUM = 265, - ICE_OUT = 266, - ICE_EXTENDS = 267, - ICE_IMPLEMENTS = 268, - ICE_THROWS = 269, - ICE_VOID = 270, - ICE_BYTE = 271, - ICE_BOOL = 272, - ICE_SHORT = 273, - ICE_INT = 274, - ICE_LONG = 275, - ICE_FLOAT = 276, - ICE_DOUBLE = 277, - ICE_STRING = 278, - ICE_OBJECT = 279, - ICE_LOCAL_OBJECT = 280, - ICE_LOCAL = 281, - ICE_CONST = 282, - ICE_FALSE = 283, - ICE_TRUE = 284, - ICE_IDEMPOTENT = 285, - ICE_OPTIONAL = 286, - ICE_SCOPE_DELIMITER = 287, - ICE_IDENTIFIER = 288, - ICE_STRING_LITERAL = 289, - ICE_INTEGER_LITERAL = 290, - ICE_FLOATING_POINT_LITERAL = 291, - ICE_IDENT_OP = 292, - ICE_KEYWORD_OP = 293, - ICE_OPTIONAL_OP = 294, - ICE_METADATA_OPEN = 295, - ICE_METADATA_CLOSE = 296, - ICE_GLOBAL_METADATA_OPEN = 297, - ICE_GLOBAL_METADATA_CLOSE = 298, - BAD_CHAR = 299 - }; -#endif - - - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif + /* Copy the second part of user declarations. */ -/* Line 264 of yacc.c */ -#line 213 "Grammar.tab.c" +/* Line 216 of yacc.c. */ +#line 247 "Grammar.tab.c" #ifdef short # undef short @@ -259,7 +293,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -284,14 +318,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int yyi) +YYID (int i) #else static int -YYID (yyi) - int yyi; +YYID (i) + int i; #endif { - return yyi; + return i; } #endif @@ -372,9 +406,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; + yytype_int16 yyss; + YYSTYPE yyvs; + }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -408,12 +442,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ +# define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -424,16 +458,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 13 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 860 +#define YYLAST 875 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 54 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 68 +#define YYNNTS 69 /* YYNRULES -- Number of rules. */ -#define YYNRULES 188 +#define YYNRULES 190 /* YYNRULES -- Number of states. */ -#define YYNSTATES 280 +#define YYNSTATES 282 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -486,81 +520,82 @@ static const yytype_uint16 yyprhs[] = 26, 27, 32, 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 63, 70, 73, 76, 79, 80, 88, 91, 92, 97, 101, 104, - 105, 108, 113, 118, 122, 125, 127, 129, 132, 135, - 138, 139, 146, 151, 155, 158, 159, 161, 164, 167, - 170, 171, 180, 183, 184, 187, 188, 193, 197, 200, - 201, 203, 207, 210, 212, 214, 216, 219, 223, 226, - 230, 231, 237, 238, 244, 246, 248, 251, 254, 257, - 258, 266, 270, 272, 274, 277, 278, 283, 287, 290, - 291, 293, 297, 299, 301, 303, 311, 319, 330, 341, - 344, 347, 348, 355, 361, 365, 367, 369, 371, 372, - 374, 375, 376, 380, 386, 391, 398, 402, 408, 411, - 412, 414, 417, 421, 423, 425, 427, 429, 431, 433, - 435, 437, 439, 442, 444, 446, 449, 452, 454, 458, - 460, 462, 463, 465, 467, 469, 471, 473, 475, 482, - 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, - 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, - 528, 530, 532, 534, 536, 538, 540, 542, 544 + 105, 108, 112, 116, 119, 121, 124, 126, 128, 131, + 134, 137, 138, 145, 150, 154, 157, 158, 160, 163, + 166, 169, 170, 179, 182, 183, 186, 187, 192, 196, + 199, 200, 202, 206, 209, 211, 214, 216, 218, 221, + 225, 228, 232, 233, 239, 240, 246, 248, 250, 253, + 256, 259, 260, 268, 272, 274, 276, 279, 280, 285, + 289, 292, 293, 295, 299, 301, 303, 305, 313, 321, + 332, 343, 346, 349, 350, 357, 363, 367, 369, 371, + 373, 374, 376, 377, 378, 382, 388, 393, 400, 404, + 410, 413, 414, 416, 419, 423, 425, 427, 429, 431, + 433, 435, 437, 439, 441, 444, 446, 448, 451, 454, + 456, 460, 462, 464, 465, 467, 469, 471, 473, 475, + 477, 484, 490, 492, 494, 496, 498, 500, 502, 504, + 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, + 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, + 546 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 55, 0, -1, 58, -1, 42, 117, 43, -1, 40, - 117, 41, -1, -1, -1, 56, 59, 58, -1, -1, + 55, 0, -1, 58, -1, 42, 118, 43, -1, 40, + 118, 41, -1, -1, -1, 56, 59, 58, -1, -1, 57, 62, 60, 45, 58, -1, -1, 1, 45, 61, - 58, -1, 57, 62, -1, -1, 63, -1, 81, -1, - 82, -1, 95, -1, 96, -1, 66, -1, 67, -1, - 75, -1, 76, -1, 104, -1, 105, -1, 107, -1, - 120, -1, -1, 3, 33, 64, 46, 58, 47, -1, - 6, 33, -1, 6, 121, -1, 118, 65, -1, -1, - 118, 65, 69, 68, 46, 70, 47, -1, 12, 114, - -1, -1, 57, 73, 45, 70, -1, 1, 45, 70, - -1, 57, 73, -1, -1, 115, 33, -1, 39, 35, - 48, 71, -1, 39, 114, 48, 71, -1, 39, 48, - 71, -1, 31, 71, -1, 71, -1, 87, -1, 7, - 33, -1, 7, 121, -1, 118, 74, -1, -1, 118, - 74, 77, 46, 78, 47, -1, 57, 79, 45, 78, - -1, 1, 45, 78, -1, 57, 79, -1, -1, 87, - -1, 4, 33, -1, 4, 121, -1, 118, 80, -1, - -1, 118, 80, 84, 85, 83, 46, 86, 47, -1, - 12, 114, -1, -1, 13, 98, -1, -1, 57, 93, - 45, 86, -1, 1, 45, 86, -1, 57, 93, -1, - -1, 72, -1, 72, 49, 119, -1, 115, 121, -1, - 115, -1, 115, -1, 15, -1, 88, 37, -1, 30, - 88, 37, -1, 88, 38, -1, 30, 88, 38, -1, - -1, 89, 112, 48, 91, 113, -1, -1, 89, 1, - 48, 92, 113, -1, 87, -1, 90, -1, 5, 33, - -1, 5, 121, -1, 118, 94, -1, -1, 118, 94, - 99, 97, 46, 100, 47, -1, 114, 50, 98, -1, - 114, -1, 24, -1, 12, 98, -1, -1, 57, 101, - 45, 100, -1, 1, 45, 100, -1, 57, 101, -1, - -1, 90, -1, 103, 50, 102, -1, 103, -1, 114, - -1, 121, -1, 118, 8, 51, 57, 115, 52, 33, - -1, 118, 8, 51, 57, 115, 52, 121, -1, 118, - 9, 51, 57, 115, 50, 57, 115, 52, 33, -1, - 118, 9, 51, 57, 115, 50, 57, 115, 52, 121, - -1, 10, 33, -1, 10, 121, -1, -1, 118, 106, - 108, 46, 109, 47, -1, 118, 10, 46, 109, 47, - -1, 110, 50, 109, -1, 110, -1, 33, -1, 121, - -1, -1, 11, -1, -1, -1, 111, 57, 71, -1, - 112, 50, 111, 57, 71, -1, 111, 57, 115, 121, - -1, 112, 50, 111, 57, 115, 121, -1, 111, 57, - 115, -1, 112, 50, 111, 57, 115, -1, 14, 102, - -1, -1, 33, -1, 32, 33, -1, 114, 32, 33, - -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, - -1, 21, -1, 22, -1, 23, -1, 24, -1, 24, - 53, -1, 25, -1, 114, -1, 114, 53, -1, 34, - 116, -1, 34, -1, 117, 50, 116, -1, 116, -1, - 26, -1, -1, 35, -1, 36, -1, 114, -1, 34, - -1, 28, -1, 29, -1, 27, 57, 115, 33, 49, - 119, -1, 27, 57, 115, 49, 119, -1, 3, -1, - 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, - 9, -1, 10, -1, 11, -1, 12, -1, 13, -1, - 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, - 19, -1, 20, -1, 21, -1, 22, -1, 23, -1, - 24, -1, 25, -1, 26, -1, 27, -1, 28, -1, - 29, -1, 30, -1, 31, -1 + 58, -1, 57, 62, -1, -1, 63, -1, 82, -1, + 83, -1, 96, -1, 97, -1, 66, -1, 67, -1, + 76, -1, 77, -1, 105, -1, 106, -1, 108, -1, + 121, -1, -1, 3, 33, 64, 46, 58, 47, -1, + 6, 33, -1, 6, 122, -1, 119, 65, -1, -1, + 119, 65, 69, 68, 46, 70, 47, -1, 12, 115, + -1, -1, 57, 74, 45, 70, -1, 1, 45, 70, + -1, 57, 74, -1, -1, 116, 33, -1, 39, 35, + 48, -1, 39, 115, 48, -1, 39, 48, -1, 31, + -1, 72, 71, -1, 71, -1, 88, -1, 7, 33, + -1, 7, 122, -1, 119, 75, -1, -1, 119, 75, + 78, 46, 79, 47, -1, 57, 80, 45, 79, -1, + 1, 45, 79, -1, 57, 80, -1, -1, 88, -1, + 4, 33, -1, 4, 122, -1, 119, 81, -1, -1, + 119, 81, 85, 86, 84, 46, 87, 47, -1, 12, + 115, -1, -1, 13, 99, -1, -1, 57, 94, 45, + 87, -1, 1, 45, 87, -1, 57, 94, -1, -1, + 73, -1, 73, 49, 120, -1, 116, 122, -1, 116, + -1, 72, 116, -1, 116, -1, 15, -1, 89, 37, + -1, 30, 89, 37, -1, 89, 38, -1, 30, 89, + 38, -1, -1, 90, 113, 48, 92, 114, -1, -1, + 90, 1, 48, 93, 114, -1, 88, -1, 91, -1, + 5, 33, -1, 5, 122, -1, 119, 95, -1, -1, + 119, 95, 100, 98, 46, 101, 47, -1, 115, 50, + 99, -1, 115, -1, 24, -1, 12, 99, -1, -1, + 57, 102, 45, 101, -1, 1, 45, 101, -1, 57, + 102, -1, -1, 91, -1, 104, 50, 103, -1, 104, + -1, 115, -1, 122, -1, 119, 8, 51, 57, 116, + 52, 33, -1, 119, 8, 51, 57, 116, 52, 122, + -1, 119, 9, 51, 57, 116, 50, 57, 116, 52, + 33, -1, 119, 9, 51, 57, 116, 50, 57, 116, + 52, 122, -1, 10, 33, -1, 10, 122, -1, -1, + 119, 107, 109, 46, 110, 47, -1, 119, 10, 46, + 110, 47, -1, 111, 50, 110, -1, 111, -1, 33, + -1, 122, -1, -1, 11, -1, -1, -1, 112, 57, + 73, -1, 113, 50, 112, 57, 73, -1, 112, 57, + 116, 122, -1, 113, 50, 112, 57, 116, 122, -1, + 112, 57, 116, -1, 113, 50, 112, 57, 116, -1, + 14, 103, -1, -1, 33, -1, 32, 33, -1, 115, + 32, 33, -1, 16, -1, 17, -1, 18, -1, 19, + -1, 20, -1, 21, -1, 22, -1, 23, -1, 24, + -1, 24, 53, -1, 25, -1, 115, -1, 115, 53, + -1, 34, 117, -1, 34, -1, 118, 50, 117, -1, + 117, -1, 26, -1, -1, 35, -1, 36, -1, 115, + -1, 34, -1, 28, -1, 29, -1, 27, 57, 116, + 33, 49, 120, -1, 27, 57, 116, 49, 120, -1, + 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, + 8, -1, 9, -1, 10, -1, 11, -1, 12, -1, + 13, -1, 14, -1, 15, -1, 16, -1, 17, -1, + 18, -1, 19, -1, 20, -1, 21, -1, 22, -1, + 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, + 28, -1, 29, -1, 30, -1, 31, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -570,21 +605,22 @@ static const yytype_uint16 yyrline[] = 157, 156, 161, 166, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 231, 230, 264, 268, 279, 290, 289, 316, 325, 333, 342, 345, 350, - 357, 370, 393, 466, 477, 488, 503, 509, 513, 524, - 535, 534, 570, 579, 582, 587, 594, 600, 604, 615, - 629, 628, 668, 703, 711, 716, 724, 733, 736, 741, - 748, 770, 797, 819, 845, 846, 855, 879, 903, 927, - 957, 956, 979, 978, 1001, 1002, 1008, 1012, 1023, 1038, - 1037, 1072, 1107, 1142, 1152, 1157, 1165, 1174, 1177, 1182, - 1189, 1195, 1202, 1214, 1226, 1237, 1246, 1261, 1272, 1289, - 1293, 1305, 1304, 1328, 1343, 1349, 1357, 1369, 1377, 1386, - 1393, 1404, 1406, 1424, 1442, 1454, 1466, 1477, 1493, 1498, - 1506, 1509, 1515, 1528, 1532, 1536, 1540, 1544, 1548, 1552, - 1556, 1560, 1564, 1568, 1572, 1591, 1632, 1638, 1646, 1653, - 1665, 1672, 1682, 1695, 1708, 1754, 1765, 1776, 1792, 1801, - 1815, 1818, 1821, 1824, 1827, 1830, 1833, 1836, 1839, 1842, - 1845, 1848, 1851, 1854, 1857, 1860, 1863, 1866, 1869, 1872, - 1875, 1878, 1881, 1884, 1887, 1890, 1893, 1896, 1899 + 357, 370, 390, 460, 468, 481, 489, 504, 510, 514, + 525, 536, 535, 571, 580, 583, 588, 595, 601, 605, + 616, 630, 629, 669, 704, 712, 717, 725, 734, 737, + 742, 749, 771, 798, 820, 846, 852, 860, 872, 896, + 921, 945, 976, 975, 998, 997, 1020, 1021, 1027, 1031, + 1042, 1057, 1056, 1091, 1126, 1161, 1171, 1176, 1184, 1193, + 1196, 1201, 1208, 1214, 1221, 1233, 1245, 1256, 1265, 1280, + 1291, 1308, 1312, 1324, 1323, 1347, 1362, 1368, 1376, 1388, + 1396, 1405, 1412, 1423, 1425, 1441, 1457, 1469, 1481, 1492, + 1508, 1513, 1521, 1524, 1530, 1543, 1547, 1551, 1555, 1559, + 1563, 1567, 1571, 1575, 1579, 1583, 1587, 1606, 1647, 1653, + 1661, 1668, 1680, 1687, 1697, 1710, 1723, 1769, 1780, 1791, + 1807, 1816, 1830, 1833, 1836, 1839, 1842, 1845, 1848, 1851, + 1854, 1857, 1860, 1863, 1866, 1869, 1872, 1875, 1878, 1881, + 1884, 1887, 1890, 1893, 1896, 1899, 1902, 1905, 1908, 1911, + 1914 }; #endif @@ -605,13 +641,13 @@ static const char *const yytname[] = "ICE_OPTIONAL_OP", "ICE_METADATA_OPEN", "ICE_METADATA_CLOSE", "ICE_GLOBAL_METADATA_OPEN", "ICE_GLOBAL_METADATA_CLOSE", "BAD_CHAR", "';'", "'{'", "'}'", "')'", "'='", "','", "'<'", "'>'", "'*'", "$accept", - "start", "global_meta_data", "meta_data", "definitions", "$@1", "$@2", - "$@3", "definition", "module_def", "@4", "exception_id", - "exception_decl", "exception_def", "@5", "exception_extends", - "exception_exports", "type_id", "data_member_type_id", - "exception_export", "struct_id", "struct_decl", "struct_def", "@6", - "struct_exports", "struct_export", "class_id", "class_decl", "class_def", - "@7", "class_extends", "implements", "class_exports", "data_member", + "start", "global_meta_data", "meta_data", "definitions", "@1", "@2", + "@3", "definition", "module_def", "@4", "exception_id", "exception_decl", + "exception_def", "@5", "exception_extends", "exception_exports", + "type_id", "optional", "optional_type_id", "exception_export", + "struct_id", "struct_decl", "struct_def", "@6", "struct_exports", + "struct_export", "class_id", "class_decl", "class_def", "@7", + "class_extends", "implements", "class_exports", "data_member", "return_type", "operation_preamble", "operation", "@8", "@9", "class_export", "interface_id", "interface_decl", "interface_def", "@10", "interface_list", "interface_extends", "interface_exports", @@ -644,21 +680,22 @@ static const yytype_uint8 yyr1[] = 61, 58, 58, 58, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 64, 63, 65, 65, 66, 68, 67, 69, 69, 70, 70, 70, 70, - 71, 72, 72, 72, 72, 72, 73, 74, 74, 75, - 77, 76, 78, 78, 78, 78, 79, 80, 80, 81, - 83, 82, 84, 84, 85, 85, 86, 86, 86, 86, - 87, 87, 87, 87, 88, 88, 89, 89, 89, 89, - 91, 90, 92, 90, 93, 93, 94, 94, 95, 97, - 96, 98, 98, 98, 99, 99, 100, 100, 100, 100, - 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, - 106, 108, 107, 107, 109, 109, 110, 110, 110, 111, - 111, 112, 112, 112, 112, 112, 112, 112, 113, 113, - 114, 114, 114, 115, 115, 115, 115, 115, 115, 115, - 115, 115, 115, 115, 115, 115, 116, 116, 117, 117, - 118, 118, 119, 119, 119, 119, 119, 119, 120, 120, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121 + 71, 72, 72, 72, 72, 73, 73, 74, 75, 75, + 76, 78, 77, 79, 79, 79, 79, 80, 81, 81, + 82, 84, 83, 85, 85, 86, 86, 87, 87, 87, + 87, 88, 88, 88, 88, 89, 89, 89, 90, 90, + 90, 90, 92, 91, 93, 91, 94, 94, 95, 95, + 96, 98, 97, 99, 99, 99, 100, 100, 101, 101, + 101, 101, 102, 103, 103, 104, 104, 105, 105, 106, + 106, 107, 107, 109, 108, 108, 110, 110, 111, 111, + 111, 112, 112, 113, 113, 113, 113, 113, 113, 113, + 114, 114, 115, 115, 115, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 116, 116, 116, 117, 117, + 118, 118, 119, 119, 120, 120, 120, 120, 120, 120, + 121, 121, 122, 122, 122, 122, 122, 122, 122, 122, + 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, + 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, + 122 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -668,21 +705,22 @@ static const yytype_uint8 yyr2[] = 0, 4, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6, 2, 2, 2, 0, 7, 2, 0, 4, 3, 2, 0, - 2, 4, 4, 3, 2, 1, 1, 2, 2, 2, - 0, 6, 4, 3, 2, 0, 1, 2, 2, 2, - 0, 8, 2, 0, 2, 0, 4, 3, 2, 0, - 1, 3, 2, 1, 1, 1, 2, 3, 2, 3, - 0, 5, 0, 5, 1, 1, 2, 2, 2, 0, - 7, 3, 1, 1, 2, 0, 4, 3, 2, 0, - 1, 3, 1, 1, 1, 7, 7, 10, 10, 2, - 2, 0, 6, 5, 3, 1, 1, 1, 0, 1, - 0, 0, 3, 5, 4, 6, 3, 5, 2, 0, - 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 1, 1, 2, 2, 1, 3, 1, - 1, 0, 1, 1, 1, 1, 1, 1, 6, 5, + 2, 3, 3, 2, 1, 2, 1, 1, 2, 2, + 2, 0, 6, 4, 3, 2, 0, 1, 2, 2, + 2, 0, 8, 2, 0, 2, 0, 4, 3, 2, + 0, 1, 3, 2, 1, 2, 1, 1, 2, 3, + 2, 3, 0, 5, 0, 5, 1, 1, 2, 2, + 2, 0, 7, 3, 1, 1, 2, 0, 4, 3, + 2, 0, 1, 3, 1, 1, 1, 7, 7, 10, + 10, 2, 2, 0, 6, 5, 3, 1, 1, 1, + 0, 1, 0, 0, 3, 5, 4, 6, 3, 5, + 2, 0, 1, 2, 3, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, + 3, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 6, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -690,250 +728,257 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 0, 0, 0, 0, 6, 151, 2, 10, 147, - 149, 0, 0, 1, 0, 0, 150, 5, 12, 14, + 0, 0, 0, 0, 0, 6, 153, 2, 10, 149, + 151, 0, 0, 1, 0, 0, 152, 5, 12, 14, 19, 20, 21, 22, 15, 16, 17, 18, 23, 24, - 25, 0, 26, 0, 146, 4, 0, 3, 7, 27, + 25, 0, 26, 0, 148, 4, 0, 3, 7, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, - 49, 59, 88, 111, 11, 148, 0, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 143, 0, 130, 144, - 0, 0, 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, - 188, 57, 58, 86, 87, 29, 30, 47, 48, 5, - 5, 109, 118, 110, 0, 32, 0, 0, 65, 0, - 89, 0, 0, 142, 131, 0, 145, 0, 0, 9, - 0, 0, 116, 0, 115, 117, 34, 0, 0, 62, - 0, 60, 93, 94, 92, 0, 118, 0, 132, 0, - 156, 157, 155, 152, 153, 154, 159, 0, 0, 113, - 118, 0, 0, 0, 0, 64, 0, 0, 0, 0, - 28, 158, 0, 5, 114, 0, 0, 0, 0, 0, - 0, 45, 70, 54, 56, 73, 51, 0, 91, 0, - 0, 0, 112, 105, 106, 0, 0, 38, 46, 33, - 53, 44, 0, 0, 0, 0, 0, 0, 40, 72, - 0, 0, 0, 0, 75, 0, 0, 0, 100, 98, - 74, 90, 0, 37, 0, 0, 43, 0, 71, 52, - 0, 84, 85, 68, 73, 61, 97, 0, 76, 78, - 0, 119, 5, 0, 0, 0, 36, 41, 42, 67, - 0, 77, 79, 82, 0, 80, 120, 96, 107, 108, - 66, 129, 122, 126, 129, 5, 0, 83, 124, 81, - 0, 128, 102, 103, 104, 123, 127, 0, 125, 101 + 50, 60, 90, 113, 11, 150, 0, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 145, 0, 132, 146, + 0, 0, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 58, 59, 88, 89, 29, 30, 48, 49, 5, + 5, 111, 120, 112, 0, 32, 0, 0, 66, 0, + 91, 0, 0, 144, 133, 0, 147, 0, 0, 9, + 0, 0, 118, 0, 117, 119, 34, 0, 0, 63, + 0, 61, 95, 96, 94, 0, 120, 0, 134, 0, + 158, 159, 157, 154, 155, 156, 161, 0, 0, 115, + 120, 0, 0, 0, 0, 65, 0, 0, 0, 0, + 28, 160, 0, 5, 116, 0, 0, 0, 0, 44, + 0, 46, 0, 71, 55, 57, 74, 52, 0, 93, + 0, 0, 0, 114, 107, 108, 0, 0, 38, 47, + 33, 54, 0, 43, 0, 45, 0, 0, 0, 40, + 73, 0, 0, 0, 0, 77, 0, 0, 0, 0, + 102, 100, 76, 92, 0, 37, 0, 41, 42, 72, + 53, 0, 0, 86, 87, 69, 74, 62, 99, 0, + 75, 78, 80, 0, 121, 5, 0, 0, 0, 36, + 68, 75, 0, 79, 81, 84, 0, 82, 122, 98, + 109, 110, 67, 131, 124, 128, 131, 5, 0, 85, + 126, 83, 0, 130, 104, 105, 106, 125, 129, 0, + 127, 103 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 4, 5, 6, 7, 14, 41, 33, 18, 19, - 56, 49, 20, 21, 137, 115, 177, 181, 182, 197, - 50, 22, 23, 116, 164, 183, 51, 24, 25, 166, - 118, 141, 212, 184, 216, 217, 218, 264, 261, 233, - 52, 26, 27, 145, 143, 120, 191, 219, 271, 272, - 28, 29, 53, 30, 121, 133, 134, 242, 243, 267, - 69, 202, 10, 11, 31, 156, 32, 135 + 56, 49, 20, 21, 137, 115, 177, 181, 182, 183, + 198, 50, 22, 23, 116, 164, 184, 51, 24, 25, + 166, 118, 141, 213, 185, 218, 219, 220, 266, 263, + 235, 52, 26, 27, 145, 143, 120, 192, 221, 273, + 274, 28, 29, 53, 30, 121, 133, 134, 245, 246, + 269, 69, 186, 10, 11, 31, 156, 32, 135 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -189 +#define YYPACT_NINF -195 static const yytype_int16 yypact[] = { - 423, 33, -6, -6, 74, -189, 62, -189, -189, -6, - -189, -23, -19, -189, 246, 49, -189, 46, 52, -189, - -189, -189, -189, -189, -189, -189, -189, -189, -189, -189, - -189, 130, -189, 246, -189, -189, -6, -189, -189, -189, - 827, 54, 530, 561, 592, 623, 75, 78, 389, 11, - 85, 9, 17, -189, -189, -189, 96, -189, -189, -189, - -189, -189, -189, -189, -189, 77, -189, 114, -189, -15, - -14, 246, -189, -189, -189, -189, -189, -189, -189, -189, - -189, -189, -189, -189, -189, -189, -189, -189, -189, -189, - -189, -189, -189, -189, -189, -189, -189, -189, -189, -189, - -189, -189, -189, -189, -189, -189, -189, -189, -189, 46, - 46, -189, 654, -189, 1, -189, 103, 1, 137, 90, - -189, 106, 101, -189, -189, 120, -189, 105, 84, -189, - 827, 827, -189, 108, 107, -189, 127, 116, 278, 127, - 90, -189, -189, -189, 35, 117, 654, 119, -189, 84, - -189, -189, -189, -189, -189, 127, -189, 112, 118, -189, - 654, 311, 122, 765, 124, -189, 126, 90, 344, 128, - -189, -189, 685, 46, -189, 129, 765, 131, 278, 827, - 48, -189, 133, 132, -189, 716, -189, 244, -189, 135, - 790, 136, -189, -189, -189, 827, 311, 139, -189, -189, - -189, -189, 140, 138, 827, 36, 84, 278, -189, -189, - 142, 421, 141, 344, -189, 809, 57, 29, -189, 144, - -189, -189, 143, -189, 311, 827, -189, 827, -189, -189, - 244, -189, -189, 146, 463, -189, -189, 87, -189, -189, - 145, -189, 46, 25, 344, 747, -189, -189, -189, -189, - 244, -189, -189, -189, 827, -189, 165, -189, -189, -189, - -189, 178, -189, 716, 178, 46, 499, -189, -189, -189, - 827, -189, 147, 127, -189, -189, 716, 499, -189, -189 + 494, -19, 0, 0, 89, -195, 33, -195, -195, 0, + -195, -18, -21, -195, 38, 61, -195, 56, 65, -195, + -195, -195, -195, -195, -195, -195, -195, -195, -195, -195, + -195, 118, -195, 38, -195, -195, 0, -195, -195, -195, + 116, 68, 601, 632, 663, 694, 64, 66, 460, 5, + 70, 3, 6, -195, -195, -195, 72, -195, -195, -195, + -195, -195, -195, -195, -195, 76, -195, 86, -195, 30, + 41, 38, -195, -195, -195, -195, -195, -195, -195, -195, + -195, -195, -195, -195, -195, -195, -195, -195, -195, -195, + -195, -195, -195, -195, -195, -195, -195, -195, -195, -195, + -195, -195, -195, -195, -195, -195, -195, -195, -195, 56, + 56, -195, 725, -195, 37, -195, 84, 37, 107, 67, + -195, 96, 415, -195, -195, 110, -195, 97, 73, -195, + 116, 116, -195, 100, 102, -195, 121, 104, 337, 121, + 67, -195, -195, -195, 36, 108, 725, 111, -195, 73, + -195, -195, -195, -195, -195, 121, -195, 105, 112, -195, + 725, 370, 115, 836, 119, -195, 117, 67, 271, 120, + -195, -195, 756, 56, -195, 123, 836, 125, 337, -195, + 40, -195, 116, 124, 129, -195, 787, -195, 304, -195, + 130, 413, 131, -195, -195, -195, 116, 370, 132, -195, + -195, -195, 128, -195, 47, -195, 146, 73, 337, -195, + -195, 136, 413, 135, 271, -195, 492, 116, 39, 235, + -195, 138, -195, -195, 113, -195, 370, -195, -195, -195, + -195, 304, 116, -195, -195, 139, 534, -195, -195, 74, + -195, -195, -195, 140, -195, 56, 34, 271, 818, -195, + -195, 146, 304, -195, -195, -195, 836, -195, 175, -195, + -195, -195, -195, 173, -195, 787, 173, 56, 570, -195, + -195, -195, 836, -195, 142, 121, -195, -195, 787, 570, + -195, -195 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -189, -189, -189, -17, -7, -189, -189, -189, -189, -189, - -189, -189, -189, -189, -189, -189, -180, -167, -189, -189, - -189, -189, -189, -189, -164, -189, -189, -189, -189, -189, - -189, -189, -159, -175, -16, -189, -13, -189, -189, -189, - -189, -189, -189, -189, -125, -189, -188, -189, -77, -189, - -189, -189, -189, -189, -189, -70, -189, -55, -189, -62, - -108, -30, 30, 200, -189, -136, -189, -40 + -195, -195, -195, -17, -8, -195, -195, -195, -195, -195, + -195, -195, -195, -195, -195, -195, -170, -171, -179, -175, + -195, -195, -195, -195, -195, -154, -195, -195, -195, -195, + -195, -195, -195, -165, -162, -23, -195, -16, -195, -195, + -195, -195, -195, -195, -195, -112, -195, -194, -195, -85, + -195, -195, -195, -195, -195, -195, -125, -195, -60, -195, + -67, -109, -27, 21, 197, -195, -140, -195, -41 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -122 +#define YYTABLE_NINF -124 static const yytype_int16 yytable[] = { - 40, 198, 102, 104, 106, 108, 136, 38, 113, 139, - 70, 144, 201, 171, 200, 165, 223, 125, 35, 127, - 155, 117, -63, 114, 37, 236, 54, 36, 9, 119, - 240, 36, 144, 67, 68, 128, 231, 226, 126, 34, - 241, 155, 188, 229, 246, -120, -120, -120, -120, -120, - -120, -120, -120, -120, -120, -63, 257, -35, 247, 144, - 248, -120, -120, -95, 129, 15, 55, 125, 125, -120, - 228, 249, 205, 255, 13, 256, 169, -121, 8, -121, - 67, 68, 39, 203, 227, 167, 2, 262, 16, 17, - 174, 260, 130, 131, 238, 239, 204, -8, 155, 71, - 157, 158, 1, 275, -5, -5, -5, -5, -5, -5, - -5, -5, 150, 151, 142, 147, 67, 68, 152, 153, - 154, 163, 67, 68, 251, 252, 109, -5, -5, 110, - 123, -50, 194, 185, 42, 43, 44, 45, 46, 47, - 48, 2, 122, 3, 176, 209, 185, 124, -13, 138, - 140, 190, 146, 148, 149, 159, 195, 160, 273, 125, - 220, 163, 161, 168, 172, 222, 170, 178, 173, 273, - 211, 186, 187, 208, 196, 192, 241, 207, 199, 176, - 213, 234, 206, 221, 224, 220, 225, 230, 235, 244, - 163, 250, 266, 253, 209, 245, 190, 277, 232, 237, - 279, 265, 269, 12, 0, 259, 0, 176, 0, 0, - 0, 0, 0, 211, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 268, 263, 254, 274, 190, 0, 0, - 0, 0, 0, 211, 0, 0, 278, 274, 0, 0, - 276, 0, 0, 0, 0, 210, -13, 1, 270, -5, - -5, -5, -5, -5, -5, -5, -5, 0, 0, -5, - -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, - 0, 0, -5, -5, -5, -5, -5, -5, 0, 162, - 0, 0, 0, -5, 2, 0, 2, 0, 3, 0, - 0, -69, 0, -13, -5, -5, -5, -5, -5, -5, - -5, -5, -5, -5, 0, 0, 0, 0, 0, -5, - -5, -5, 175, 0, 0, 0, 0, -5, 2, 0, - 0, 0, 0, 0, 0, -55, 0, -5, -5, -5, + 40, 102, 104, 106, 108, 136, 38, 113, 139, 171, + 144, 205, 217, 70, 199, 117, -64, 114, 119, 155, + 238, 169, 37, 35, 201, 54, 8, 225, 165, 36, + 34, 144, 36, 232, 9, 174, 15, 217, -13, 1, + 155, -5, -5, -5, -5, -5, -5, -5, -5, -64, + 233, -35, -97, 259, 230, 189, 249, 55, 144, 16, + 17, 205, 125, 129, -5, -5, 250, 229, 125, 67, + 68, 204, 67, 68, 127, 202, 241, 242, 2, 125, + 3, 264, 257, 126, 258, -13, 167, 262, 203, 13, + 128, 142, 130, 131, 39, 228, 2, 277, 155, 67, + 68, 150, 151, 157, 158, 67, 68, 152, 153, 154, + -8, 253, 254, 71, 147, 109, -51, 110, 122, 124, + 140, 163, 42, 43, 44, 45, 46, 47, 48, 123, + 138, 195, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 146, 148, 176, 210, 149, 159, 67, 68, + 161, 191, 160, 125, 168, 206, 196, 172, 170, 275, + 178, 163, 173, 188, 222, 248, 187, 193, 197, 224, + 275, 212, 200, 207, 208, 214, 227, 226, 223, 209, + 176, 231, 237, 247, 252, 236, 244, 268, 255, 222, + 240, 163, 279, 239, 281, 210, 234, 191, 267, 271, + 12, 0, 0, 0, 0, 251, 0, 261, 0, 176, + 0, 0, 0, 0, 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 270, 0, 0, 276, 256, 265, + 191, 0, 0, 0, 0, 212, 243, 280, 276, 0, + 0, 0, 0, 0, 0, 278, 244, 0, 0, 0, + 272, -122, -122, -122, -122, -122, -122, -122, -122, -122, + -122, 0, 0, 0, 0, 0, -122, -122, -122, 0, + 0, 0, 190, 0, -122, -122, 0, 0, 0, 0, + 0, 0, 0, -123, 0, -123, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 0, 0, 0, - 0, 0, -5, -5, -5, 189, 0, 0, 0, 0, - -5, 2, 0, 0, 0, 0, 0, 0, -39, -5, + 0, -5, -5, -5, -5, 211, 0, 0, 0, 0, + -5, 2, 0, 0, 0, 0, 0, 0, -101, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, - 0, 0, 0, 0, -5, 0, -5, -5, 0, 0, - 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, - 0, -99, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 0, 111, -13, 1, 0, -5, -5, -5, -5, - -5, -5, -5, -5, 0, 112, 214, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 0, 0, -5, - -5, 215, 179, 67, 68, 0, 0, 0, 0, 0, - 180, 0, 0, 2, 0, 3, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 0, 208, 0, 0, 0, - -74, -74, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 67, 68, 72, 73, 74, 75, 76, 77, 78, + 0, 0, 0, 0, -5, -5, -5, -5, 162, 0, + 0, 0, 0, -5, 2, 0, 0, 0, 0, 0, + 0, -70, 0, -5, -5, -5, -5, -5, -5, -5, + -5, -5, -5, 0, 0, 0, 0, 0, -5, -5, + -5, 175, 0, 0, 0, 0, -5, 2, 0, 0, + 0, 0, 0, 0, -56, 0, -5, -5, -5, -5, + -5, -5, -5, -5, -5, -5, 0, 0, 0, 0, + 0, -5, -5, -5, 0, 0, 0, 0, 0, -5, + 2, 0, 0, 0, 0, 0, 1, -39, -5, -5, + -5, -5, -5, -5, -5, -5, 0, 0, 215, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 0, + 0, -5, -5, 216, 179, 67, 68, 0, 0, 0, + 0, 0, 180, 0, 0, 2, 0, 3, 0, 0, + 0, 0, -13, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 100, 0, 101, 72, 73, 74, 75, 76, 77, + 99, 100, 0, 111, -13, 1, 0, -5, -5, -5, + -5, -5, -5, -5, -5, 0, 112, 215, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 0, 0, + -5, -5, 0, 179, 67, 68, 0, 0, 0, 0, + 0, 180, 0, 0, 2, 0, 3, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 0, 209, 0, 0, + 0, -76, -76, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, + 99, 100, 67, 68, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - 98, 99, 100, 0, 103, 72, 73, 74, 75, 76, + 98, 99, 100, 0, 101, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 0, 105, 72, 73, 74, 75, + 97, 98, 99, 100, 0, 103, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 0, 107, 72, 73, 74, + 96, 97, 98, 99, 100, 0, 105, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 0, 132, 72, 73, + 95, 96, 97, 98, 99, 100, 0, 107, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 0, 193, 72, + 94, 95, 96, 97, 98, 99, 100, 0, 132, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 0, 208, + 93, 94, 95, 96, 97, 98, 99, 100, 0, 194, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 0, - 258, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 0, 0, 0, 0, 0, 179, 67, 68, 0, - 0, 0, 0, 0, 180, 214, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 0, 0, 0, 0, - 215, 0, 67, 68, 214, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 0, 0, 0, 0, 0, - 0, 67, 68, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 0, 0, 0, 0, 0, 0, 67, - 68 + 209, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 0, 260, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 0, 0, 0, 0, 0, 179, 67, 68, + 0, 0, 0, 0, 0, 180 }; static const yytype_int16 yycheck[] = { - 17, 176, 42, 43, 44, 45, 114, 14, 48, 117, - 40, 119, 179, 149, 178, 140, 196, 32, 41, 33, - 128, 12, 13, 12, 43, 213, 33, 50, 34, 12, - 1, 50, 140, 32, 33, 49, 211, 204, 53, 9, - 11, 149, 167, 207, 224, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 46, 244, 46, 225, 167, - 227, 32, 33, 46, 71, 3, 36, 32, 32, 40, - 206, 230, 180, 48, 0, 50, 146, 48, 45, 50, - 32, 33, 33, 35, 48, 50, 40, 254, 26, 27, - 160, 250, 109, 110, 37, 38, 48, 45, 206, 45, - 130, 131, 1, 270, 3, 4, 5, 6, 7, 8, - 9, 10, 28, 29, 24, 122, 32, 33, 34, 35, - 36, 138, 32, 33, 37, 38, 51, 26, 27, 51, - 53, 46, 172, 163, 4, 5, 6, 7, 8, 9, - 10, 40, 46, 42, 161, 185, 176, 33, 47, 46, - 13, 168, 46, 33, 49, 47, 173, 50, 266, 32, - 190, 178, 46, 46, 52, 195, 47, 45, 50, 277, - 187, 47, 46, 33, 45, 47, 11, 45, 47, 196, - 45, 211, 49, 47, 45, 215, 48, 45, 47, 45, - 207, 45, 14, 48, 234, 52, 213, 50, 211, 215, - 277, 256, 264, 3, -1, 245, -1, 224, -1, -1, - -1, -1, -1, 230, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 263, 254, 242, 266, 244, -1, -1, - -1, -1, -1, 250, -1, -1, 276, 277, -1, -1, - 270, -1, -1, -1, -1, 1, 0, 1, 265, 3, - 4, 5, 6, 7, 8, 9, 10, -1, -1, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - -1, -1, 26, 27, 30, 31, 32, 33, -1, 1, - -1, -1, -1, 39, 40, -1, 40, -1, 42, -1, - -1, 47, -1, 47, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, -1, -1, -1, -1, -1, 31, - 32, 33, 1, -1, -1, -1, -1, 39, 40, -1, - -1, -1, -1, -1, -1, 47, -1, 16, 17, 18, + 17, 42, 43, 44, 45, 114, 14, 48, 117, 149, + 119, 182, 191, 40, 176, 12, 13, 12, 12, 128, + 214, 146, 43, 41, 178, 33, 45, 197, 140, 50, + 9, 140, 50, 212, 34, 160, 3, 216, 0, 1, + 149, 3, 4, 5, 6, 7, 8, 9, 10, 46, + 212, 46, 46, 247, 208, 167, 226, 36, 167, 26, + 27, 232, 32, 71, 26, 27, 231, 207, 32, 32, + 33, 180, 32, 33, 33, 35, 37, 38, 40, 32, + 42, 256, 48, 53, 50, 47, 50, 252, 48, 0, + 49, 24, 109, 110, 33, 48, 40, 272, 207, 32, + 33, 28, 29, 130, 131, 32, 33, 34, 35, 36, + 45, 37, 38, 45, 122, 51, 46, 51, 46, 33, + 13, 138, 4, 5, 6, 7, 8, 9, 10, 53, + 46, 172, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 46, 33, 161, 186, 49, 47, 32, 33, + 46, 168, 50, 32, 46, 182, 173, 52, 47, 268, + 45, 178, 50, 46, 191, 52, 47, 47, 45, 196, + 279, 188, 47, 49, 45, 45, 48, 45, 47, 33, + 197, 45, 47, 45, 45, 212, 11, 14, 48, 216, + 217, 208, 50, 216, 279, 236, 212, 214, 258, 266, + 3, -1, -1, -1, -1, 232, -1, 248, -1, 226, + -1, -1, -1, -1, 231, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 265, -1, -1, 268, 245, 256, + 247, -1, -1, -1, -1, 252, 1, 278, 279, -1, + -1, -1, -1, -1, -1, 272, 11, -1, -1, -1, + 267, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, -1, -1, -1, -1, -1, 31, 32, 33, -1, + -1, -1, 1, -1, 39, 40, -1, -1, -1, -1, + -1, -1, -1, 48, -1, 50, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, - -1, -1, 31, 32, 33, 1, -1, -1, -1, -1, + -1, 30, 31, 32, 33, 1, -1, -1, -1, -1, 39, 40, -1, -1, -1, -1, -1, -1, 47, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - -1, -1, -1, -1, 30, -1, 32, 33, -1, -1, - -1, -1, -1, -1, 40, -1, -1, -1, -1, -1, - -1, 47, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, -1, 33, 0, 1, -1, 3, 4, 5, 6, - 7, 8, 9, 10, -1, 46, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, -1, -1, 26, - 27, 30, 31, 32, 33, -1, -1, -1, -1, -1, - 39, -1, -1, 40, -1, 42, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, -1, 33, -1, -1, -1, - 37, 38, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 3, 4, 5, 6, 7, 8, 9, + -1, -1, -1, -1, 30, 31, 32, 33, 1, -1, + -1, -1, -1, 39, 40, -1, -1, -1, -1, -1, + -1, 47, -1, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, -1, -1, -1, -1, -1, 31, 32, + 33, 1, -1, -1, -1, -1, 39, 40, -1, -1, + -1, -1, -1, -1, 47, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, + -1, 31, 32, 33, -1, -1, -1, -1, -1, 39, + 40, -1, -1, -1, -1, -1, 1, 47, 3, 4, + 5, 6, 7, 8, 9, 10, -1, -1, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, + -1, 26, 27, 30, 31, 32, 33, -1, -1, -1, + -1, -1, 39, -1, -1, 40, -1, 42, -1, -1, + -1, -1, 47, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, -1, 33, 0, 1, -1, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 46, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, + 26, 27, -1, 31, 32, 33, -1, -1, -1, -1, + -1, 39, -1, -1, 40, -1, 42, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, -1, 33, -1, -1, + -1, 37, 38, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, -1, 33, 3, 4, 5, 6, 7, 8, + 30, 31, 32, 33, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, 33, 3, 4, 5, 6, 7, @@ -955,15 +1000,12 @@ static const yytype_int16 yycheck[] = 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, - 33, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, -1, -1, -1, -1, -1, 31, 32, 33, -1, - -1, -1, -1, -1, 39, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, - 30, -1, 32, 33, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, - -1, 32, 33, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, -1, -1, -1, -1, -1, -1, 32, - 33 + 33, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, -1, -1, -1, -1, -1, 31, 32, 33, + -1, -1, -1, -1, -1, 39 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -971,33 +1013,34 @@ static const yytype_int16 yycheck[] = static const yytype_uint8 yystos[] = { 0, 1, 40, 42, 55, 56, 57, 58, 45, 34, - 116, 117, 117, 0, 59, 3, 26, 27, 62, 63, - 66, 67, 75, 76, 81, 82, 95, 96, 104, 105, - 107, 118, 120, 61, 116, 41, 50, 43, 58, 33, + 117, 118, 118, 0, 59, 3, 26, 27, 62, 63, + 66, 67, 76, 77, 82, 83, 96, 97, 105, 106, + 108, 119, 121, 61, 117, 41, 50, 43, 58, 33, 57, 60, 4, 5, 6, 7, 8, 9, 10, 65, - 74, 80, 94, 106, 58, 116, 64, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 32, 33, 114, - 115, 45, 3, 4, 5, 6, 7, 8, 9, 10, + 75, 81, 95, 107, 58, 117, 64, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 32, 33, 115, + 116, 45, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 33, 121, 33, 121, 33, 121, 33, 121, 51, - 51, 33, 46, 121, 12, 69, 77, 12, 84, 12, - 99, 108, 46, 53, 33, 32, 53, 33, 49, 58, - 57, 57, 33, 109, 110, 121, 114, 68, 46, 114, - 13, 85, 24, 98, 114, 97, 46, 58, 33, 49, - 28, 29, 34, 35, 36, 114, 119, 115, 115, 47, - 50, 46, 1, 57, 78, 98, 83, 50, 46, 109, - 47, 119, 52, 50, 109, 1, 57, 70, 45, 31, - 39, 71, 72, 79, 87, 115, 47, 46, 98, 1, - 57, 100, 47, 33, 121, 57, 45, 73, 87, 47, - 78, 71, 115, 35, 48, 114, 49, 45, 33, 121, - 1, 57, 86, 45, 15, 30, 88, 89, 90, 101, - 115, 47, 115, 70, 45, 48, 71, 48, 119, 78, - 45, 87, 90, 93, 115, 47, 100, 88, 37, 38, - 1, 11, 111, 112, 45, 52, 70, 71, 71, 86, - 45, 37, 38, 48, 57, 48, 50, 100, 33, 121, - 86, 92, 71, 115, 91, 111, 14, 113, 121, 113, - 57, 102, 103, 114, 121, 71, 115, 50, 121, 102 + 31, 33, 122, 33, 122, 33, 122, 33, 122, 51, + 51, 33, 46, 122, 12, 69, 78, 12, 85, 12, + 100, 109, 46, 53, 33, 32, 53, 33, 49, 58, + 57, 57, 33, 110, 111, 122, 115, 68, 46, 115, + 13, 86, 24, 99, 115, 98, 46, 58, 33, 49, + 28, 29, 34, 35, 36, 115, 120, 116, 116, 47, + 50, 46, 1, 57, 79, 99, 84, 50, 46, 110, + 47, 120, 52, 50, 110, 1, 57, 70, 45, 31, + 39, 71, 72, 73, 80, 88, 116, 47, 46, 99, + 1, 57, 101, 47, 33, 122, 57, 45, 74, 88, + 47, 79, 35, 48, 115, 71, 116, 49, 45, 33, + 122, 1, 57, 87, 45, 15, 30, 72, 89, 90, + 91, 102, 116, 47, 116, 70, 45, 48, 48, 120, + 79, 45, 72, 88, 91, 94, 116, 47, 101, 89, + 116, 37, 38, 1, 11, 112, 113, 45, 52, 70, + 87, 116, 45, 37, 38, 48, 57, 48, 50, 101, + 33, 122, 87, 93, 73, 116, 92, 112, 14, 114, + 122, 114, 57, 103, 104, 115, 122, 73, 116, 50, + 122, 103 }; #define yyerrok (yyerrstatus = 0) @@ -1071,7 +1114,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1182,20 +1225,17 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -1229,11 +1269,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - YYFPRINTF (stderr, " $%d = ", yyi + 1); + fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - YYFPRINTF (stderr, "\n"); + fprintf (stderr, "\n"); } } @@ -1513,8 +1553,10 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } + /* Prevent warnings from -Wmissing-prototypes. */ + #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1533,9 +1575,10 @@ int yyparse (); -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ + +/*----------. +| yyparse. | +`----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1559,46 +1602,22 @@ yyparse () #endif #endif { -/* The lookahead symbol. */ + /* The look-ahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +/* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; +/* Number of syntax errors so far. */ +int yynerrs; + int yystate; int yyn; int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1606,28 +1625,51 @@ YYSTYPE yylval; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ + yyssp = yyss; yyvsp = yyvs; @@ -1657,6 +1699,7 @@ YYSTYPE yylval; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; + /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1664,6 +1707,7 @@ YYSTYPE yylval; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); yyss = yyss1; @@ -1686,8 +1730,9 @@ YYSTYPE yylval; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1698,6 +1743,7 @@ YYSTYPE yylval; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1707,9 +1753,6 @@ YYSTYPE yylval; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - if (yystate == YYFINAL) - YYACCEPT; - goto yybackup; /*-----------. @@ -1718,16 +1761,16 @@ YYSTYPE yylval; yybackup: /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ + look-ahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a look-ahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1759,16 +1802,20 @@ yybackup: goto yyreduce; } + if (yyn == YYFINAL) + YYACCEPT; + /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the lookahead token. */ + /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token. */ - yychar = YYEMPTY; + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1808,16 +1855,12 @@ yyreduce: switch (yyn) { case 2: - -/* Line 1455 of yacc.c */ #line 108 "../Slice/Grammar.y" { ;} break; case 3: - -/* Line 1455 of yacc.c */ #line 116 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (3)]); @@ -1825,8 +1868,6 @@ yyreduce: break; case 4: - -/* Line 1455 of yacc.c */ #line 125 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (3)]); @@ -1834,8 +1875,6 @@ yyreduce: break; case 5: - -/* Line 1455 of yacc.c */ #line 129 "../Slice/Grammar.y" { (yyval) = new StringListTok; @@ -1843,8 +1882,6 @@ yyreduce: break; case 6: - -/* Line 1455 of yacc.c */ #line 138 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -1856,8 +1893,6 @@ yyreduce: break; case 8: - -/* Line 1455 of yacc.c */ #line 147 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (2)])); @@ -1870,8 +1905,6 @@ yyreduce: break; case 10: - -/* Line 1455 of yacc.c */ #line 157 "../Slice/Grammar.y" { yyerrok; @@ -1879,8 +1912,6 @@ yyreduce: break; case 12: - -/* Line 1455 of yacc.c */ #line 162 "../Slice/Grammar.y" { unit->error("`;' missing after definition"); @@ -1888,16 +1919,12 @@ yyreduce: break; case 13: - -/* Line 1455 of yacc.c */ #line 166 "../Slice/Grammar.y" { ;} break; case 14: - -/* Line 1455 of yacc.c */ #line 174 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ModulePtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1905,8 +1932,6 @@ yyreduce: break; case 15: - -/* Line 1455 of yacc.c */ #line 178 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ClassDeclPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1914,8 +1939,6 @@ yyreduce: break; case 16: - -/* Line 1455 of yacc.c */ #line 182 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ClassDefPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1923,8 +1946,6 @@ yyreduce: break; case 17: - -/* Line 1455 of yacc.c */ #line 186 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ClassDeclPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1932,8 +1953,6 @@ yyreduce: break; case 18: - -/* Line 1455 of yacc.c */ #line 190 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ClassDefPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1941,8 +1960,6 @@ yyreduce: break; case 19: - -/* Line 1455 of yacc.c */ #line 194 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0); @@ -1950,8 +1967,6 @@ yyreduce: break; case 20: - -/* Line 1455 of yacc.c */ #line 198 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ExceptionPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1959,8 +1974,6 @@ yyreduce: break; case 21: - -/* Line 1455 of yacc.c */ #line 202 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0); @@ -1968,8 +1981,6 @@ yyreduce: break; case 22: - -/* Line 1455 of yacc.c */ #line 206 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || StructPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1977,8 +1988,6 @@ yyreduce: break; case 23: - -/* Line 1455 of yacc.c */ #line 210 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || SequencePtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1986,8 +1995,6 @@ yyreduce: break; case 24: - -/* Line 1455 of yacc.c */ #line 214 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || DictionaryPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -1995,8 +2002,6 @@ yyreduce: break; case 25: - -/* Line 1455 of yacc.c */ #line 218 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || EnumPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -2004,8 +2009,6 @@ yyreduce: break; case 26: - -/* Line 1455 of yacc.c */ #line 222 "../Slice/Grammar.y" { assert((yyvsp[(1) - (1)]) == 0 || ConstPtr::dynamicCast((yyvsp[(1) - (1)]))); @@ -2013,8 +2016,6 @@ yyreduce: break; case 27: - -/* Line 1455 of yacc.c */ #line 231 "../Slice/Grammar.y" { unit->setSeenDefinition(); @@ -2035,8 +2036,6 @@ yyreduce: break; case 28: - -/* Line 1455 of yacc.c */ #line 248 "../Slice/Grammar.y" { if((yyvsp[(3) - (6)])) @@ -2052,8 +2051,6 @@ yyreduce: break; case 29: - -/* Line 1455 of yacc.c */ #line 265 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); @@ -2061,8 +2058,6 @@ yyreduce: break; case 30: - -/* Line 1455 of yacc.c */ #line 269 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -2072,8 +2067,6 @@ yyreduce: break; case 31: - -/* Line 1455 of yacc.c */ #line 280 "../Slice/Grammar.y" { unit->error("exceptions cannot be forward declared"); @@ -2082,8 +2075,6 @@ yyreduce: break; case 32: - -/* Line 1455 of yacc.c */ #line 290 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); @@ -2101,8 +2092,6 @@ yyreduce: break; case 33: - -/* Line 1455 of yacc.c */ #line 304 "../Slice/Grammar.y" { if((yyvsp[(4) - (7)])) @@ -2114,8 +2103,6 @@ yyreduce: break; case 34: - -/* Line 1455 of yacc.c */ #line 317 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -2127,8 +2114,6 @@ yyreduce: break; case 35: - -/* Line 1455 of yacc.c */ #line 325 "../Slice/Grammar.y" { (yyval) = 0; @@ -2136,8 +2121,6 @@ yyreduce: break; case 36: - -/* Line 1455 of yacc.c */ #line 334 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); @@ -2150,16 +2133,12 @@ yyreduce: break; case 37: - -/* Line 1455 of yacc.c */ #line 343 "../Slice/Grammar.y" { ;} break; case 38: - -/* Line 1455 of yacc.c */ #line 346 "../Slice/Grammar.y" { unit->error("`;' missing after definition"); @@ -2167,16 +2146,12 @@ yyreduce: break; case 39: - -/* Line 1455 of yacc.c */ #line 350 "../Slice/Grammar.y" { ;} break; case 40: - -/* Line 1455 of yacc.c */ #line 358 "../Slice/Grammar.y" { TypePtr type = TypePtr::dynamicCast((yyvsp[(1) - (2)])); @@ -2188,17 +2163,14 @@ yyreduce: break; case 41: - -/* Line 1455 of yacc.c */ #line 371 "../Slice/Grammar.y" { - IntegerTokPtr i = IntegerTokPtr::dynamicCast((yyvsp[(2) - (4)])); - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast((yyvsp[(4) - (4)])); + IntegerTokPtr i = IntegerTokPtr::dynamicCast((yyvsp[(2) - (3)])); int tag; if(i->v < 0 || i->v > Int32Max) { - unit->error("tag for optional member `" + ts->v.second + "' is out of range"); + unit->error("tag for optional is out of range"); tag = -1; } else @@ -2206,9 +2178,7 @@ yyreduce: tag = static_cast<int>(i->v); } - DataMemberDefTokPtr m = new DataMemberDefTok; - m->v.type = ts->v.first; - m->v.name = ts->v.second; + OptionalDefTokPtr m = new OptionalDefTok; m->v.optional = tag >= 0; m->v.tag = tag; (yyval) = m; @@ -2216,12 +2186,9 @@ yyreduce: break; case 42: - -/* Line 1455 of yacc.c */ -#line 394 "../Slice/Grammar.y" +#line 391 "../Slice/Grammar.y" { - StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(2) - (4)])); - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast((yyvsp[(4) - (4)])); + StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(2) - (3)])); ContainerPtr cont = unit->currentContainer(); assert(cont); @@ -2250,7 +2217,7 @@ yyreduce: IceUtil::Int64 l = IceUtilInternal::strToInt64(constant->value().c_str(), 0, 0); if(l < 0 || l > Int32Max) { - unit->error("tag for optional member `" + ts->v.second + "' is out of range"); + unit->error("tag for optional is out of range"); } tag = static_cast<int>(l); break; @@ -2281,12 +2248,10 @@ yyreduce: if(tag < 0) { - unit->error("invalid tag `" + scoped->v + "' for optional member `" + ts->v.second + "'"); + unit->error("invalid tag `" + scoped->v + "' for optional"); } - DataMemberDefTokPtr m = new DataMemberDefTok; - m->v.type = ts->v.first; - m->v.name = ts->v.second; + OptionalDefTokPtr m = new OptionalDefTok; m->v.optional = tag >= 0; m->v.tag = tag; (yyval) = m; @@ -2294,15 +2259,10 @@ yyreduce: break; case 43: - -/* Line 1455 of yacc.c */ -#line 467 "../Slice/Grammar.y" +#line 461 "../Slice/Grammar.y" { - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast((yyvsp[(3) - (3)])); - unit->error("missing tag for optional member `" + ts->v.second + "'"); - DataMemberDefTokPtr m = new DataMemberDefTok; // Dummy - m->v.type = ts->v.first; - m->v.name = ts->v.second; + unit->error("missing tag for optional"); + OptionalDefTokPtr m = new OptionalDefTok; // Dummy m->v.optional = false; m->v.tag = -1; (yyval) = m; @@ -2310,15 +2270,10 @@ yyreduce: break; case 44: - -/* Line 1455 of yacc.c */ -#line 478 "../Slice/Grammar.y" +#line 469 "../Slice/Grammar.y" { - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast((yyvsp[(2) - (2)])); - unit->error("missing tag for optional member `" + ts->v.second + "'"); - DataMemberDefTokPtr m = new DataMemberDefTok; // Dummy - m->v.type = ts->v.first; - m->v.name = ts->v.second; + unit->error("missing tag for optional"); + OptionalDefTokPtr m = new OptionalDefTok; // Dummy m->v.optional = false; m->v.tag = -1; (yyval) = m; @@ -2326,12 +2281,21 @@ yyreduce: break; case 45: +#line 482 "../Slice/Grammar.y" + { + OptionalDefTokPtr m = OptionalDefTokPtr::dynamicCast((yyvsp[(1) - (2)])); + TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast((yyvsp[(2) - (2)])); + m->v.type = ts->v.first; + m->v.name = ts->v.second; + (yyval) = m; +;} + break; -/* Line 1455 of yacc.c */ -#line 489 "../Slice/Grammar.y" + case 46: +#line 490 "../Slice/Grammar.y" { TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast((yyvsp[(1) - (1)])); - DataMemberDefTokPtr m = new DataMemberDefTok; + OptionalDefTokPtr m = new OptionalDefTok; m->v.type = ts->v.first; m->v.name = ts->v.second; m->v.optional = false; @@ -2340,19 +2304,15 @@ yyreduce: ;} break; - case 47: - -/* Line 1455 of yacc.c */ -#line 510 "../Slice/Grammar.y" + case 48: +#line 511 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 48: - -/* Line 1455 of yacc.c */ -#line 514 "../Slice/Grammar.y" + case 49: +#line 515 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as struct name"); @@ -2360,20 +2320,16 @@ yyreduce: ;} break; - case 49: - -/* Line 1455 of yacc.c */ -#line 525 "../Slice/Grammar.y" + case 50: +#line 526 "../Slice/Grammar.y" { unit->error("structs cannot be forward declared"); (yyval) = 0; // Dummy ;} break; - case 50: - -/* Line 1455 of yacc.c */ -#line 535 "../Slice/Grammar.y" + case 51: +#line 536 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -2388,10 +2344,8 @@ yyreduce: ;} break; - case 51: - -/* Line 1455 of yacc.c */ -#line 548 "../Slice/Grammar.y" + case 52: +#line 549 "../Slice/Grammar.y" { if((yyvsp[(3) - (6)])) { @@ -2411,10 +2365,8 @@ yyreduce: ;} break; - case 52: - -/* Line 1455 of yacc.c */ -#line 571 "../Slice/Grammar.y" + case 53: +#line 572 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); @@ -2425,44 +2377,34 @@ yyreduce: ;} break; - case 53: - -/* Line 1455 of yacc.c */ -#line 580 "../Slice/Grammar.y" + case 54: +#line 581 "../Slice/Grammar.y" { ;} break; - case 54: - -/* Line 1455 of yacc.c */ -#line 583 "../Slice/Grammar.y" + case 55: +#line 584 "../Slice/Grammar.y" { unit->error("`;' missing after definition"); ;} break; - case 55: - -/* Line 1455 of yacc.c */ -#line 587 "../Slice/Grammar.y" + case 56: +#line 588 "../Slice/Grammar.y" { ;} break; - case 57: - -/* Line 1455 of yacc.c */ -#line 601 "../Slice/Grammar.y" + case 58: +#line 602 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 58: - -/* Line 1455 of yacc.c */ -#line 605 "../Slice/Grammar.y" + case 59: +#line 606 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as class name"); @@ -2470,10 +2412,8 @@ yyreduce: ;} break; - case 59: - -/* Line 1455 of yacc.c */ -#line 616 "../Slice/Grammar.y" + case 60: +#line 617 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -2483,10 +2423,8 @@ yyreduce: ;} break; - case 60: - -/* Line 1455 of yacc.c */ -#line 629 "../Slice/Grammar.y" + case 61: +#line 630 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (4)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (4)])); @@ -2511,10 +2449,8 @@ yyreduce: ;} break; - case 61: - -/* Line 1455 of yacc.c */ -#line 652 "../Slice/Grammar.y" + case 62: +#line 653 "../Slice/Grammar.y" { if((yyvsp[(5) - (8)])) { @@ -2528,10 +2464,8 @@ yyreduce: ;} break; - case 62: - -/* Line 1455 of yacc.c */ -#line 669 "../Slice/Grammar.y" + case 63: +#line 670 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ContainerPtr cont = unit->currentContainer(); @@ -2567,37 +2501,29 @@ yyreduce: ;} break; - case 63: - -/* Line 1455 of yacc.c */ -#line 703 "../Slice/Grammar.y" + case 64: +#line 704 "../Slice/Grammar.y" { (yyval) = 0; ;} break; - case 64: - -/* Line 1455 of yacc.c */ -#line 712 "../Slice/Grammar.y" + case 65: +#line 713 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 65: - -/* Line 1455 of yacc.c */ -#line 716 "../Slice/Grammar.y" + case 66: +#line 717 "../Slice/Grammar.y" { (yyval) = new ClassListTok; ;} break; - case 66: - -/* Line 1455 of yacc.c */ -#line 725 "../Slice/Grammar.y" + case 67: +#line 726 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); @@ -2608,37 +2534,29 @@ yyreduce: ;} break; - case 67: - -/* Line 1455 of yacc.c */ -#line 734 "../Slice/Grammar.y" + case 68: +#line 735 "../Slice/Grammar.y" { ;} break; - case 68: - -/* Line 1455 of yacc.c */ -#line 737 "../Slice/Grammar.y" + case 69: +#line 738 "../Slice/Grammar.y" { unit->error("`;' missing after definition"); ;} break; - case 69: - -/* Line 1455 of yacc.c */ -#line 741 "../Slice/Grammar.y" + case 70: +#line 742 "../Slice/Grammar.y" { ;} break; - case 70: - -/* Line 1455 of yacc.c */ -#line 749 "../Slice/Grammar.y" + case 71: +#line 750 "../Slice/Grammar.y" { - DataMemberDefTokPtr def = DataMemberDefTokPtr::dynamicCast((yyvsp[(1) - (1)])); + OptionalDefTokPtr def = OptionalDefTokPtr::dynamicCast((yyvsp[(1) - (1)])); ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); DataMemberPtr dm; if(cl) @@ -2660,12 +2578,10 @@ yyreduce: ;} break; - case 71: - -/* Line 1455 of yacc.c */ -#line 771 "../Slice/Grammar.y" + case 72: +#line 772 "../Slice/Grammar.y" { - DataMemberDefTokPtr def = DataMemberDefTokPtr::dynamicCast((yyvsp[(1) - (3)])); + OptionalDefTokPtr def = OptionalDefTokPtr::dynamicCast((yyvsp[(1) - (3)])); ConstDefTokPtr value = ConstDefTokPtr::dynamicCast((yyvsp[(3) - (3)])); ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); @@ -2692,10 +2608,8 @@ yyreduce: ;} break; - case 72: - -/* Line 1455 of yacc.c */ -#line 798 "../Slice/Grammar.y" + case 73: +#line 799 "../Slice/Grammar.y" { TypePtr type = TypePtr::dynamicCast((yyvsp[(1) - (2)])); string name = StringTokPtr::dynamicCast((yyvsp[(2) - (2)]))->v; @@ -2719,10 +2633,8 @@ yyreduce: ;} break; - case 73: - -/* Line 1455 of yacc.c */ -#line 820 "../Slice/Grammar.y" + case 74: +#line 821 "../Slice/Grammar.y" { TypePtr type = TypePtr::dynamicCast((yyvsp[(1) - (1)])); ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); @@ -2746,25 +2658,44 @@ yyreduce: break; case 75: - -/* Line 1455 of yacc.c */ #line 847 "../Slice/Grammar.y" { - (yyval) = 0; + OptionalDefTokPtr m = OptionalDefTokPtr::dynamicCast((yyvsp[(1) - (2)])); + m->v.type = TypePtr::dynamicCast((yyvsp[(2) - (2)])); + (yyval) = m; ;} break; case 76: +#line 853 "../Slice/Grammar.y" + { + OptionalDefTokPtr m = new OptionalDefTok(); + m->v.type = TypePtr::dynamicCast((yyvsp[(1) - (1)])); + m->v.optional = false; + m->v.tag = -1; + (yyval) = m; +;} + break; + + case 77: +#line 861 "../Slice/Grammar.y" + { + OptionalDefTokPtr m = new OptionalDefTok; + m->v.optional = false; + m->v.tag = -1; + (yyval) = m; +;} + break; -/* Line 1455 of yacc.c */ -#line 856 "../Slice/Grammar.y" + case 78: +#line 873 "../Slice/Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast((yyvsp[(1) - (2)])); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast((yyvsp[(1) - (2)])); string name = StringTokPtr::dynamicCast((yyvsp[(2) - (2)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag); if(op) { cl->checkIntroduced(name, op); @@ -2783,17 +2714,16 @@ yyreduce: ;} break; - case 77: - -/* Line 1455 of yacc.c */ -#line 880 "../Slice/Grammar.y" + case 79: +#line 897 "../Slice/Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast((yyvsp[(2) - (3)])); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast((yyvsp[(2) - (3)])); string name = StringTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType, Operation::Idempotent); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag, + Operation::Idempotent); if(op) { cl->checkIntroduced(name, op); @@ -2812,17 +2742,15 @@ yyreduce: ;} break; - case 78: - -/* Line 1455 of yacc.c */ -#line 904 "../Slice/Grammar.y" + case 80: +#line 922 "../Slice/Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast((yyvsp[(1) - (2)])); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast((yyvsp[(1) - (2)])); string name = StringTokPtr::dynamicCast((yyvsp[(2) - (2)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag); if(op) { unit->pushContainer(op); @@ -2841,17 +2769,16 @@ yyreduce: ;} break; - case 79: - -/* Line 1455 of yacc.c */ -#line 928 "../Slice/Grammar.y" + case 81: +#line 946 "../Slice/Grammar.y" { - TypePtr returnType = TypePtr::dynamicCast((yyvsp[(2) - (3)])); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast((yyvsp[(2) - (3)])); string name = StringTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType, Operation::Idempotent); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag, + Operation::Idempotent); if(op) { unit->pushContainer(op); @@ -2870,10 +2797,8 @@ yyreduce: ;} break; - case 80: - -/* Line 1455 of yacc.c */ -#line 957 "../Slice/Grammar.y" + case 82: +#line 976 "../Slice/Grammar.y" { if((yyvsp[(1) - (3)])) { @@ -2887,10 +2812,8 @@ yyreduce: ;} break; - case 81: - -/* Line 1455 of yacc.c */ -#line 969 "../Slice/Grammar.y" + case 83: +#line 988 "../Slice/Grammar.y" { OperationPtr op = OperationPtr::dynamicCast((yyvsp[(4) - (5)])); ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast((yyvsp[(5) - (5)])); @@ -2902,10 +2825,8 @@ yyreduce: ;} break; - case 82: - -/* Line 1455 of yacc.c */ -#line 979 "../Slice/Grammar.y" + case 84: +#line 998 "../Slice/Grammar.y" { if((yyvsp[(1) - (3)])) { @@ -2915,10 +2836,8 @@ yyreduce: ;} break; - case 83: - -/* Line 1455 of yacc.c */ -#line 987 "../Slice/Grammar.y" + case 85: +#line 1006 "../Slice/Grammar.y" { OperationPtr op = OperationPtr::dynamicCast((yyvsp[(4) - (5)])); ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast((yyvsp[(5) - (5)])); @@ -2930,19 +2849,15 @@ yyreduce: ;} break; - case 86: - -/* Line 1455 of yacc.c */ -#line 1009 "../Slice/Grammar.y" + case 88: +#line 1028 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 87: - -/* Line 1455 of yacc.c */ -#line 1013 "../Slice/Grammar.y" + case 89: +#line 1032 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -2950,10 +2865,8 @@ yyreduce: ;} break; - case 88: - -/* Line 1455 of yacc.c */ -#line 1024 "../Slice/Grammar.y" + case 90: +#line 1043 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -2964,10 +2877,8 @@ yyreduce: ;} break; - case 89: - -/* Line 1455 of yacc.c */ -#line 1038 "../Slice/Grammar.y" + case 91: +#line 1057 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (3)])); @@ -2987,10 +2898,8 @@ yyreduce: ;} break; - case 90: - -/* Line 1455 of yacc.c */ -#line 1056 "../Slice/Grammar.y" + case 92: +#line 1075 "../Slice/Grammar.y" { if((yyvsp[(4) - (7)])) { @@ -3004,10 +2913,8 @@ yyreduce: ;} break; - case 91: - -/* Line 1455 of yacc.c */ -#line 1073 "../Slice/Grammar.y" + case 93: +#line 1092 "../Slice/Grammar.y" { ClassListTokPtr intfs = ClassListTokPtr::dynamicCast((yyvsp[(3) - (3)])); StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (3)])); @@ -3044,10 +2951,8 @@ yyreduce: ;} break; - case 92: - -/* Line 1455 of yacc.c */ -#line 1108 "../Slice/Grammar.y" + case 94: +#line 1127 "../Slice/Grammar.y" { ClassListTokPtr intfs = new ClassListTok; StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -3084,38 +2989,30 @@ yyreduce: ;} break; - case 93: - -/* Line 1455 of yacc.c */ -#line 1143 "../Slice/Grammar.y" + case 95: +#line 1162 "../Slice/Grammar.y" { unit->error("illegal inheritance from type Object"); (yyval) = new ClassListTok; // Dummy ;} break; - case 94: - -/* Line 1455 of yacc.c */ -#line 1153 "../Slice/Grammar.y" + case 96: +#line 1172 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 95: - -/* Line 1455 of yacc.c */ -#line 1157 "../Slice/Grammar.y" + case 97: +#line 1176 "../Slice/Grammar.y" { (yyval) = new ClassListTok; ;} break; - case 96: - -/* Line 1455 of yacc.c */ -#line 1166 "../Slice/Grammar.y" + case 98: +#line 1185 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(1) - (4)])); ContainedPtr contained = ContainedPtr::dynamicCast((yyvsp[(2) - (4)])); @@ -3126,35 +3023,27 @@ yyreduce: ;} break; - case 97: - -/* Line 1455 of yacc.c */ -#line 1175 "../Slice/Grammar.y" + case 99: +#line 1194 "../Slice/Grammar.y" { ;} break; - case 98: - -/* Line 1455 of yacc.c */ -#line 1178 "../Slice/Grammar.y" + case 100: +#line 1197 "../Slice/Grammar.y" { unit->error("`;' missing after definition"); ;} break; - case 99: - -/* Line 1455 of yacc.c */ -#line 1182 "../Slice/Grammar.y" + case 101: +#line 1201 "../Slice/Grammar.y" { ;} break; - case 101: - -/* Line 1455 of yacc.c */ -#line 1196 "../Slice/Grammar.y" + case 103: +#line 1215 "../Slice/Grammar.y" { ExceptionPtr exception = ExceptionPtr::dynamicCast((yyvsp[(1) - (3)])); ExceptionListTokPtr exceptionList = ExceptionListTokPtr::dynamicCast((yyvsp[(3) - (3)])); @@ -3163,10 +3052,8 @@ yyreduce: ;} break; - case 102: - -/* Line 1455 of yacc.c */ -#line 1203 "../Slice/Grammar.y" + case 104: +#line 1222 "../Slice/Grammar.y" { ExceptionPtr exception = ExceptionPtr::dynamicCast((yyvsp[(1) - (1)])); ExceptionListTokPtr exceptionList = new ExceptionListTok; @@ -3175,10 +3062,8 @@ yyreduce: ;} break; - case 103: - -/* Line 1455 of yacc.c */ -#line 1215 "../Slice/Grammar.y" + case 105: +#line 1234 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ContainerPtr cont = unit->currentContainer(); @@ -3192,10 +3077,8 @@ yyreduce: ;} break; - case 104: - -/* Line 1455 of yacc.c */ -#line 1227 "../Slice/Grammar.y" + case 106: +#line 1246 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); unit->error("keyword `" + ident->v + "' cannot be used as exception name"); @@ -3203,10 +3086,8 @@ yyreduce: ;} break; - case 105: - -/* Line 1455 of yacc.c */ -#line 1238 "../Slice/Grammar.y" + case 107: +#line 1257 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (7)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(7) - (7)])); @@ -3217,10 +3098,8 @@ yyreduce: ;} break; - case 106: - -/* Line 1455 of yacc.c */ -#line 1247 "../Slice/Grammar.y" + case 108: +#line 1266 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (7)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(7) - (7)])); @@ -3232,10 +3111,8 @@ yyreduce: ;} break; - case 107: - -/* Line 1455 of yacc.c */ -#line 1262 "../Slice/Grammar.y" + case 109: +#line 1281 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (10)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(10) - (10)])); @@ -3248,10 +3125,8 @@ yyreduce: ;} break; - case 108: - -/* Line 1455 of yacc.c */ -#line 1273 "../Slice/Grammar.y" + case 110: +#line 1292 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (10)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(10) - (10)])); @@ -3265,19 +3140,15 @@ yyreduce: ;} break; - case 109: - -/* Line 1455 of yacc.c */ -#line 1290 "../Slice/Grammar.y" + case 111: +#line 1309 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 110: - -/* Line 1455 of yacc.c */ -#line 1294 "../Slice/Grammar.y" + case 112: +#line 1313 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); unit->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -3285,10 +3156,8 @@ yyreduce: ;} break; - case 111: - -/* Line 1455 of yacc.c */ -#line 1305 "../Slice/Grammar.y" + case 113: +#line 1324 "../Slice/Grammar.y" { BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (2)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -3299,10 +3168,8 @@ yyreduce: ;} break; - case 112: - -/* Line 1455 of yacc.c */ -#line 1314 "../Slice/Grammar.y" + case 114: +#line 1333 "../Slice/Grammar.y" { EnumPtr en = EnumPtr::dynamicCast((yyvsp[(3) - (6)])); if(en) @@ -3318,10 +3185,8 @@ yyreduce: ;} break; - case 113: - -/* Line 1455 of yacc.c */ -#line 1329 "../Slice/Grammar.y" + case 115: +#line 1348 "../Slice/Grammar.y" { unit->error("missing enumeration name"); BoolTokPtr local = BoolTokPtr::dynamicCast((yyvsp[(1) - (5)])); @@ -3333,10 +3198,8 @@ yyreduce: ;} break; - case 114: - -/* Line 1455 of yacc.c */ -#line 1344 "../Slice/Grammar.y" + case 116: +#line 1363 "../Slice/Grammar.y" { EnumeratorListTokPtr ens = EnumeratorListTokPtr::dynamicCast((yyvsp[(1) - (3)])); ens->v.splice(ens->v.end(), EnumeratorListTokPtr::dynamicCast((yyvsp[(3) - (3)]))->v); @@ -3344,18 +3207,14 @@ yyreduce: ;} break; - case 115: - -/* Line 1455 of yacc.c */ -#line 1350 "../Slice/Grammar.y" + case 117: +#line 1369 "../Slice/Grammar.y" { ;} break; - case 116: - -/* Line 1455 of yacc.c */ -#line 1358 "../Slice/Grammar.y" + case 118: +#line 1377 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); EnumeratorListTokPtr ens = new EnumeratorListTok; @@ -3369,10 +3228,8 @@ yyreduce: ;} break; - case 117: - -/* Line 1455 of yacc.c */ -#line 1370 "../Slice/Grammar.y" + case 119: +#line 1389 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); unit->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -3381,20 +3238,16 @@ yyreduce: ;} break; - case 118: - -/* Line 1455 of yacc.c */ -#line 1377 "../Slice/Grammar.y" + case 120: +#line 1396 "../Slice/Grammar.y" { EnumeratorListTokPtr ens = new EnumeratorListTok; (yyval) = ens; // Dummy ;} break; - case 119: - -/* Line 1455 of yacc.c */ -#line 1387 "../Slice/Grammar.y" + case 121: +#line 1406 "../Slice/Grammar.y" { BoolTokPtr out = new BoolTok; out->v = true; @@ -3402,10 +3255,8 @@ yyreduce: ;} break; - case 120: - -/* Line 1455 of yacc.c */ -#line 1393 "../Slice/Grammar.y" + case 122: +#line 1412 "../Slice/Grammar.y" { BoolTokPtr out = new BoolTok; out->v = false; @@ -3413,28 +3264,22 @@ yyreduce: ;} break; - case 121: - -/* Line 1455 of yacc.c */ -#line 1404 "../Slice/Grammar.y" + case 123: +#line 1423 "../Slice/Grammar.y" { ;} break; - case 122: - -/* Line 1455 of yacc.c */ -#line 1407 "../Slice/Grammar.y" + case 124: +#line 1426 "../Slice/Grammar.y" { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); - TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast((yyvsp[(3) - (3)])); - TypePtr type = tsp->v.first; - string ident = tsp->v.second; + OptionalDefTokPtr tsp = OptionalDefTokPtr::dynamicCast((yyvsp[(3) - (3)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); - unit->currentContainer()->checkIntroduced(ident, pd); + ParamDeclPtr pd = op->createParamDecl(tsp->v.name, tsp->v.type, isOutParam->v, tsp->v.optional, tsp->v.tag); + unit->currentContainer()->checkIntroduced(tsp->v.name, pd); StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(2) - (3)])); if(!metaData->v.empty()) { @@ -3444,20 +3289,16 @@ yyreduce: ;} break; - case 123: - -/* Line 1455 of yacc.c */ -#line 1425 "../Slice/Grammar.y" + case 125: +#line 1442 "../Slice/Grammar.y" { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(3) - (5)])); - TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast((yyvsp[(5) - (5)])); - TypePtr type = tsp->v.first; - string ident = tsp->v.second; + OptionalDefTokPtr tsp = OptionalDefTokPtr::dynamicCast((yyvsp[(5) - (5)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); - unit->currentContainer()->checkIntroduced(ident, pd); + ParamDeclPtr pd = op->createParamDecl(tsp->v.name, tsp->v.type, isOutParam->v, tsp->v.optional, tsp->v.tag); + unit->currentContainer()->checkIntroduced(tsp->v.name, pd); StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(4) - (5)])); if(!metaData->v.empty()) { @@ -3467,10 +3308,8 @@ yyreduce: ;} break; - case 124: - -/* Line 1455 of yacc.c */ -#line 1443 "../Slice/Grammar.y" + case 126: +#line 1458 "../Slice/Grammar.y" { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(1) - (4)])); TypePtr type = TypePtr::dynamicCast((yyvsp[(3) - (4)])); @@ -3478,16 +3317,14 @@ yyreduce: OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(ident->v, type, isOutParam->v); // Dummy + op->createParamDecl(ident->v, type, isOutParam->v, false, 0); // Dummy unit->error("keyword `" + ident->v + "' cannot be used as parameter name"); } ;} break; - case 125: - -/* Line 1455 of yacc.c */ -#line 1455 "../Slice/Grammar.y" + case 127: +#line 1470 "../Slice/Grammar.y" { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(3) - (6)])); TypePtr type = TypePtr::dynamicCast((yyvsp[(5) - (6)])); @@ -3495,74 +3332,62 @@ yyreduce: OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(ident->v, type, isOutParam->v); // Dummy + op->createParamDecl(ident->v, type, isOutParam->v, false, 0); // Dummy unit->error("keyword `" + ident->v + "' cannot be used as parameter name"); } ;} break; - case 126: - -/* Line 1455 of yacc.c */ -#line 1467 "../Slice/Grammar.y" + case 128: +#line 1482 "../Slice/Grammar.y" { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(1) - (3)])); TypePtr type = TypePtr::dynamicCast((yyvsp[(3) - (3)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v); // Dummy + op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v, false, 0); // Dummy unit->error("missing parameter name"); } ;} break; - case 127: - -/* Line 1455 of yacc.c */ -#line 1478 "../Slice/Grammar.y" + case 129: +#line 1493 "../Slice/Grammar.y" { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast((yyvsp[(3) - (5)])); TypePtr type = TypePtr::dynamicCast((yyvsp[(5) - (5)])); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v); // Dummy + op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v, false, 0); // Dummy unit->error("missing parameter name"); } ;} break; - case 128: - -/* Line 1455 of yacc.c */ -#line 1494 "../Slice/Grammar.y" + case 130: +#line 1509 "../Slice/Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; - case 129: - -/* Line 1455 of yacc.c */ -#line 1498 "../Slice/Grammar.y" + case 131: +#line 1513 "../Slice/Grammar.y" { (yyval) = new ExceptionListTok; ;} break; - case 130: - -/* Line 1455 of yacc.c */ -#line 1507 "../Slice/Grammar.y" + case 132: +#line 1522 "../Slice/Grammar.y" { ;} break; - case 131: - -/* Line 1455 of yacc.c */ -#line 1510 "../Slice/Grammar.y" + case 133: +#line 1525 "../Slice/Grammar.y" { StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); ident->v = "::" + ident->v; @@ -3570,10 +3395,8 @@ yyreduce: ;} break; - case 132: - -/* Line 1455 of yacc.c */ -#line 1516 "../Slice/Grammar.y" + case 134: +#line 1531 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (3)])); StringTokPtr ident = StringTokPtr::dynamicCast((yyvsp[(3) - (3)])); @@ -3583,109 +3406,85 @@ yyreduce: ;} break; - case 133: - -/* Line 1455 of yacc.c */ -#line 1529 "../Slice/Grammar.y" + case 135: +#line 1544 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindByte); ;} break; - case 134: - -/* Line 1455 of yacc.c */ -#line 1533 "../Slice/Grammar.y" + case 136: +#line 1548 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindBool); ;} break; - case 135: - -/* Line 1455 of yacc.c */ -#line 1537 "../Slice/Grammar.y" + case 137: +#line 1552 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindShort); ;} break; - case 136: - -/* Line 1455 of yacc.c */ -#line 1541 "../Slice/Grammar.y" + case 138: +#line 1556 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindInt); ;} break; - case 137: - -/* Line 1455 of yacc.c */ -#line 1545 "../Slice/Grammar.y" + case 139: +#line 1560 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindLong); ;} break; - case 138: - -/* Line 1455 of yacc.c */ -#line 1549 "../Slice/Grammar.y" + case 140: +#line 1564 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindFloat); ;} break; - case 139: - -/* Line 1455 of yacc.c */ -#line 1553 "../Slice/Grammar.y" + case 141: +#line 1568 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindDouble); ;} break; - case 140: - -/* Line 1455 of yacc.c */ -#line 1557 "../Slice/Grammar.y" + case 142: +#line 1572 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindString); ;} break; - case 141: - -/* Line 1455 of yacc.c */ -#line 1561 "../Slice/Grammar.y" + case 143: +#line 1576 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindObject); ;} break; - case 142: - -/* Line 1455 of yacc.c */ -#line 1565 "../Slice/Grammar.y" + case 144: +#line 1580 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindObjectProxy); ;} break; - case 143: - -/* Line 1455 of yacc.c */ -#line 1569 "../Slice/Grammar.y" + case 145: +#line 1584 "../Slice/Grammar.y" { (yyval) = unit->builtin(Builtin::KindLocalObject); ;} break; - case 144: - -/* Line 1455 of yacc.c */ -#line 1573 "../Slice/Grammar.y" + case 146: +#line 1588 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ContainerPtr cont = unit->currentContainer(); @@ -3706,10 +3505,8 @@ yyreduce: ;} break; - case 145: - -/* Line 1455 of yacc.c */ -#line 1592 "../Slice/Grammar.y" + case 147: +#line 1607 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (2)])); ContainerPtr cont = unit->currentContainer(); @@ -3747,10 +3544,8 @@ yyreduce: ;} break; - case 146: - -/* Line 1455 of yacc.c */ -#line 1633 "../Slice/Grammar.y" + case 148: +#line 1648 "../Slice/Grammar.y" { StringTokPtr str1 = StringTokPtr::dynamicCast((yyvsp[(1) - (2)])); StringTokPtr str2 = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); @@ -3758,18 +3553,14 @@ yyreduce: ;} break; - case 147: - -/* Line 1455 of yacc.c */ -#line 1639 "../Slice/Grammar.y" + case 149: +#line 1654 "../Slice/Grammar.y" { ;} break; - case 148: - -/* Line 1455 of yacc.c */ -#line 1647 "../Slice/Grammar.y" + case 150: +#line 1662 "../Slice/Grammar.y" { StringTokPtr str = StringTokPtr::dynamicCast((yyvsp[(3) - (3)])); StringListTokPtr stringList = StringListTokPtr::dynamicCast((yyvsp[(1) - (3)])); @@ -3778,10 +3569,8 @@ yyreduce: ;} break; - case 149: - -/* Line 1455 of yacc.c */ -#line 1654 "../Slice/Grammar.y" + case 151: +#line 1669 "../Slice/Grammar.y" { StringTokPtr str = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); StringListTokPtr stringList = new StringListTok; @@ -3790,10 +3579,8 @@ yyreduce: ;} break; - case 150: - -/* Line 1455 of yacc.c */ -#line 1666 "../Slice/Grammar.y" + case 152: +#line 1681 "../Slice/Grammar.y" { BoolTokPtr local = new BoolTok; local->v = true; @@ -3801,10 +3588,8 @@ yyreduce: ;} break; - case 151: - -/* Line 1455 of yacc.c */ -#line 1672 "../Slice/Grammar.y" + case 153: +#line 1687 "../Slice/Grammar.y" { BoolTokPtr local = new BoolTok; local->v = false; @@ -3812,10 +3597,8 @@ yyreduce: ;} break; - case 152: - -/* Line 1455 of yacc.c */ -#line 1683 "../Slice/Grammar.y" + case 154: +#line 1698 "../Slice/Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindLong); IntegerTokPtr intVal = IntegerTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -3830,10 +3613,8 @@ yyreduce: ;} break; - case 153: - -/* Line 1455 of yacc.c */ -#line 1696 "../Slice/Grammar.y" + case 155: +#line 1711 "../Slice/Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindDouble); FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -3848,10 +3629,8 @@ yyreduce: ;} break; - case 154: - -/* Line 1455 of yacc.c */ -#line 1709 "../Slice/Grammar.y" + case 156: +#line 1724 "../Slice/Grammar.y" { StringTokPtr scoped = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); ConstDefTokPtr def = new ConstDefTok; @@ -3899,10 +3678,8 @@ yyreduce: ;} break; - case 155: - -/* Line 1455 of yacc.c */ -#line 1755 "../Slice/Grammar.y" + case 157: +#line 1770 "../Slice/Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindString); StringTokPtr literal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -3915,10 +3692,8 @@ yyreduce: ;} break; - case 156: - -/* Line 1455 of yacc.c */ -#line 1766 "../Slice/Grammar.y" + case 158: +#line 1781 "../Slice/Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindBool); StringTokPtr literal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -3931,10 +3706,8 @@ yyreduce: ;} break; - case 157: - -/* Line 1455 of yacc.c */ -#line 1777 "../Slice/Grammar.y" + case 159: +#line 1792 "../Slice/Grammar.y" { BuiltinPtr type = unit->builtin(Builtin::KindBool); StringTokPtr literal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); @@ -3947,10 +3720,8 @@ yyreduce: ;} break; - case 158: - -/* Line 1455 of yacc.c */ -#line 1793 "../Slice/Grammar.y" + case 160: +#line 1808 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(2) - (6)])); TypePtr const_type = TypePtr::dynamicCast((yyvsp[(3) - (6)])); @@ -3961,10 +3732,8 @@ yyreduce: ;} break; - case 159: - -/* Line 1455 of yacc.c */ -#line 1802 "../Slice/Grammar.y" + case 161: +#line 1817 "../Slice/Grammar.y" { StringListTokPtr metaData = StringListTokPtr::dynamicCast((yyvsp[(2) - (5)])); TypePtr const_type = TypePtr::dynamicCast((yyvsp[(3) - (5)])); @@ -3975,242 +3744,183 @@ yyreduce: ;} break; - case 160: - -/* Line 1455 of yacc.c */ -#line 1816 "../Slice/Grammar.y" - { -;} - break; - - case 161: - -/* Line 1455 of yacc.c */ -#line 1819 "../Slice/Grammar.y" - { -;} - break; - case 162: - -/* Line 1455 of yacc.c */ -#line 1822 "../Slice/Grammar.y" +#line 1831 "../Slice/Grammar.y" { ;} break; case 163: - -/* Line 1455 of yacc.c */ -#line 1825 "../Slice/Grammar.y" +#line 1834 "../Slice/Grammar.y" { ;} break; case 164: - -/* Line 1455 of yacc.c */ -#line 1828 "../Slice/Grammar.y" +#line 1837 "../Slice/Grammar.y" { ;} break; case 165: - -/* Line 1455 of yacc.c */ -#line 1831 "../Slice/Grammar.y" +#line 1840 "../Slice/Grammar.y" { ;} break; case 166: - -/* Line 1455 of yacc.c */ -#line 1834 "../Slice/Grammar.y" +#line 1843 "../Slice/Grammar.y" { ;} break; case 167: - -/* Line 1455 of yacc.c */ -#line 1837 "../Slice/Grammar.y" +#line 1846 "../Slice/Grammar.y" { ;} break; case 168: - -/* Line 1455 of yacc.c */ -#line 1840 "../Slice/Grammar.y" +#line 1849 "../Slice/Grammar.y" { ;} break; case 169: - -/* Line 1455 of yacc.c */ -#line 1843 "../Slice/Grammar.y" +#line 1852 "../Slice/Grammar.y" { ;} break; case 170: - -/* Line 1455 of yacc.c */ -#line 1846 "../Slice/Grammar.y" +#line 1855 "../Slice/Grammar.y" { ;} break; case 171: - -/* Line 1455 of yacc.c */ -#line 1849 "../Slice/Grammar.y" +#line 1858 "../Slice/Grammar.y" { ;} break; case 172: - -/* Line 1455 of yacc.c */ -#line 1852 "../Slice/Grammar.y" +#line 1861 "../Slice/Grammar.y" { ;} break; case 173: - -/* Line 1455 of yacc.c */ -#line 1855 "../Slice/Grammar.y" +#line 1864 "../Slice/Grammar.y" { ;} break; case 174: - -/* Line 1455 of yacc.c */ -#line 1858 "../Slice/Grammar.y" +#line 1867 "../Slice/Grammar.y" { ;} break; case 175: - -/* Line 1455 of yacc.c */ -#line 1861 "../Slice/Grammar.y" +#line 1870 "../Slice/Grammar.y" { ;} break; case 176: - -/* Line 1455 of yacc.c */ -#line 1864 "../Slice/Grammar.y" +#line 1873 "../Slice/Grammar.y" { ;} break; case 177: - -/* Line 1455 of yacc.c */ -#line 1867 "../Slice/Grammar.y" +#line 1876 "../Slice/Grammar.y" { ;} break; case 178: - -/* Line 1455 of yacc.c */ -#line 1870 "../Slice/Grammar.y" +#line 1879 "../Slice/Grammar.y" { ;} break; case 179: - -/* Line 1455 of yacc.c */ -#line 1873 "../Slice/Grammar.y" +#line 1882 "../Slice/Grammar.y" { ;} break; case 180: - -/* Line 1455 of yacc.c */ -#line 1876 "../Slice/Grammar.y" +#line 1885 "../Slice/Grammar.y" { ;} break; case 181: - -/* Line 1455 of yacc.c */ -#line 1879 "../Slice/Grammar.y" +#line 1888 "../Slice/Grammar.y" { ;} break; case 182: - -/* Line 1455 of yacc.c */ -#line 1882 "../Slice/Grammar.y" +#line 1891 "../Slice/Grammar.y" { ;} break; case 183: - -/* Line 1455 of yacc.c */ -#line 1885 "../Slice/Grammar.y" +#line 1894 "../Slice/Grammar.y" { ;} break; case 184: - -/* Line 1455 of yacc.c */ -#line 1888 "../Slice/Grammar.y" +#line 1897 "../Slice/Grammar.y" { ;} break; case 185: - -/* Line 1455 of yacc.c */ -#line 1891 "../Slice/Grammar.y" +#line 1900 "../Slice/Grammar.y" { ;} break; case 186: - -/* Line 1455 of yacc.c */ -#line 1894 "../Slice/Grammar.y" +#line 1903 "../Slice/Grammar.y" { ;} break; case 187: - -/* Line 1455 of yacc.c */ -#line 1897 "../Slice/Grammar.y" +#line 1906 "../Slice/Grammar.y" { ;} break; case 188: +#line 1909 "../Slice/Grammar.y" + { +;} + break; -/* Line 1455 of yacc.c */ -#line 1900 "../Slice/Grammar.y" + case 189: +#line 1912 "../Slice/Grammar.y" { ;} break; + case 190: +#line 1915 "../Slice/Grammar.y" + { +;} + break; -/* Line 1455 of yacc.c */ -#line 4214 "Grammar.tab.c" +/* Line 1267 of yacc.c. */ +#line 3924 "Grammar.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -4221,6 +3931,7 @@ yyreduce: *++yyvsp = yyval; + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -4285,7 +3996,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an + /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -4302,7 +4013,7 @@ yyerrlab: } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; @@ -4359,6 +4070,9 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } + if (yyn == YYFINAL) + YYACCEPT; + *++yyvsp = yylval; @@ -4383,7 +4097,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -4394,7 +4108,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEMPTY) + if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered @@ -4420,8 +4134,6 @@ yyreturn: } - -/* Line 1675 of yacc.c */ -#line 1904 "../Slice/Grammar.y" +#line 1919 "../Slice/Grammar.y" diff --git a/cpp/src/Slice/Grammar.h b/cpp/src/Slice/Grammar.h index 0ee3d141315..8b0f1aff09f 100644 --- a/cpp/src/Slice/Grammar.h +++ b/cpp/src/Slice/Grammar.h @@ -1,23 +1,24 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -28,11 +29,10 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ - /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -83,16 +83,59 @@ BAD_CHAR = 299 }; #endif +/* Tokens. */ +#define ICE_MODULE 258 +#define ICE_CLASS 259 +#define ICE_INTERFACE 260 +#define ICE_EXCEPTION 261 +#define ICE_STRUCT 262 +#define ICE_SEQUENCE 263 +#define ICE_DICTIONARY 264 +#define ICE_ENUM 265 +#define ICE_OUT 266 +#define ICE_EXTENDS 267 +#define ICE_IMPLEMENTS 268 +#define ICE_THROWS 269 +#define ICE_VOID 270 +#define ICE_BYTE 271 +#define ICE_BOOL 272 +#define ICE_SHORT 273 +#define ICE_INT 274 +#define ICE_LONG 275 +#define ICE_FLOAT 276 +#define ICE_DOUBLE 277 +#define ICE_STRING 278 +#define ICE_OBJECT 279 +#define ICE_LOCAL_OBJECT 280 +#define ICE_LOCAL 281 +#define ICE_CONST 282 +#define ICE_FALSE 283 +#define ICE_TRUE 284 +#define ICE_IDEMPOTENT 285 +#define ICE_OPTIONAL 286 +#define ICE_SCOPE_DELIMITER 287 +#define ICE_IDENTIFIER 288 +#define ICE_STRING_LITERAL 289 +#define ICE_INTEGER_LITERAL 290 +#define ICE_FLOATING_POINT_LITERAL 291 +#define ICE_IDENT_OP 292 +#define ICE_KEYWORD_OP 293 +#define ICE_OPTIONAL_OP 294 +#define ICE_METADATA_OPEN 295 +#define ICE_METADATA_CLOSE 296 +#define ICE_GLOBAL_METADATA_OPEN 297 +#define ICE_GLOBAL_METADATA_CLOSE 298 +#define BAD_CHAR 299 + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif - diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y index 9d127bf115b..4a57da869df 100644 --- a/cpp/src/Slice/Grammar.y +++ b/cpp/src/Slice/Grammar.y @@ -365,17 +365,16 @@ type_id ; // ---------------------------------------------------------------------- -data_member_type_id +optional // ---------------------------------------------------------------------- -: ICE_OPTIONAL_OP ICE_INTEGER_LITERAL ')' type_id +: ICE_OPTIONAL_OP ICE_INTEGER_LITERAL ')' { IntegerTokPtr i = IntegerTokPtr::dynamicCast($2); - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast($4); int tag; if(i->v < 0 || i->v > Int32Max) { - unit->error("tag for optional member `" + ts->v.second + "' is out of range"); + unit->error("tag for optional is out of range"); tag = -1; } else @@ -383,17 +382,14 @@ data_member_type_id tag = static_cast<int>(i->v); } - DataMemberDefTokPtr m = new DataMemberDefTok; - m->v.type = ts->v.first; - m->v.name = ts->v.second; + OptionalDefTokPtr m = new OptionalDefTok; m->v.optional = tag >= 0; m->v.tag = tag; $$ = m; } -| ICE_OPTIONAL_OP scoped_name ')' type_id +| ICE_OPTIONAL_OP scoped_name ')' { StringTokPtr scoped = StringTokPtr::dynamicCast($2); - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast($4); ContainerPtr cont = unit->currentContainer(); assert(cont); @@ -422,7 +418,7 @@ data_member_type_id IceUtil::Int64 l = IceUtilInternal::strToInt64(constant->value().c_str(), 0, 0); if(l < 0 || l > Int32Max) { - unit->error("tag for optional member `" + ts->v.second + "' is out of range"); + unit->error("tag for optional is out of range"); } tag = static_cast<int>(l); break; @@ -453,42 +449,47 @@ data_member_type_id if(tag < 0) { - unit->error("invalid tag `" + scoped->v + "' for optional member `" + ts->v.second + "'"); + unit->error("invalid tag `" + scoped->v + "' for optional"); } - DataMemberDefTokPtr m = new DataMemberDefTok; - m->v.type = ts->v.first; - m->v.name = ts->v.second; + OptionalDefTokPtr m = new OptionalDefTok; m->v.optional = tag >= 0; m->v.tag = tag; $$ = m; } -| ICE_OPTIONAL_OP ')' type_id +| ICE_OPTIONAL_OP ')' { - TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast($3); - unit->error("missing tag for optional member `" + ts->v.second + "'"); - DataMemberDefTokPtr m = new DataMemberDefTok; // Dummy - m->v.type = ts->v.first; - m->v.name = ts->v.second; + unit->error("missing tag for optional"); + OptionalDefTokPtr m = new OptionalDefTok; // Dummy + m->v.optional = false; + m->v.tag = -1; + $$ = m; +} +| ICE_OPTIONAL +{ + unit->error("missing tag for optional"); + OptionalDefTokPtr m = new OptionalDefTok; // Dummy m->v.optional = false; m->v.tag = -1; $$ = m; } -| ICE_OPTIONAL type_id +; + +// ---------------------------------------------------------------------- +optional_type_id +// ---------------------------------------------------------------------- +: optional type_id { + OptionalDefTokPtr m = OptionalDefTokPtr::dynamicCast($1); TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast($2); - unit->error("missing tag for optional member `" + ts->v.second + "'"); - DataMemberDefTokPtr m = new DataMemberDefTok; // Dummy m->v.type = ts->v.first; m->v.name = ts->v.second; - m->v.optional = false; - m->v.tag = -1; $$ = m; } | type_id { TypeStringTokPtr ts = TypeStringTokPtr::dynamicCast($1); - DataMemberDefTokPtr m = new DataMemberDefTok; + OptionalDefTokPtr m = new OptionalDefTok; m->v.type = ts->v.first; m->v.name = ts->v.second; m->v.optional = false; @@ -745,9 +746,9 @@ class_exports // ---------------------------------------------------------------------- data_member // ---------------------------------------------------------------------- -: data_member_type_id +: optional_type_id { - DataMemberDefTokPtr def = DataMemberDefTokPtr::dynamicCast($1); + OptionalDefTokPtr def = OptionalDefTokPtr::dynamicCast($1); ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); DataMemberPtr dm; if(cl) @@ -767,9 +768,9 @@ data_member unit->currentContainer()->checkIntroduced(def->v.name, dm); $$ = dm; } -| data_member_type_id '=' const_initializer +| optional_type_id '=' const_initializer { - DataMemberDefTokPtr def = DataMemberDefTokPtr::dynamicCast($1); + OptionalDefTokPtr def = OptionalDefTokPtr::dynamicCast($1); ConstDefTokPtr value = ConstDefTokPtr::dynamicCast($3); ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); @@ -842,10 +843,26 @@ data_member // ---------------------------------------------------------------------- return_type // ---------------------------------------------------------------------- -: type +: optional type +{ + OptionalDefTokPtr m = OptionalDefTokPtr::dynamicCast($1); + m->v.type = TypePtr::dynamicCast($2); + $$ = m; +} +| type +{ + OptionalDefTokPtr m = new OptionalDefTok(); + m->v.type = TypePtr::dynamicCast($1); + m->v.optional = false; + m->v.tag = -1; + $$ = m; +} | ICE_VOID { - $$ = 0; + OptionalDefTokPtr m = new OptionalDefTok; + m->v.optional = false; + m->v.tag = -1; + $$ = m; } ; @@ -854,12 +871,12 @@ operation_preamble // ---------------------------------------------------------------------- : return_type ICE_IDENT_OP { - TypePtr returnType = TypePtr::dynamicCast($1); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast($1); string name = StringTokPtr::dynamicCast($2)->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag); if(op) { cl->checkIntroduced(name, op); @@ -878,12 +895,13 @@ operation_preamble } | ICE_IDEMPOTENT return_type ICE_IDENT_OP { - TypePtr returnType = TypePtr::dynamicCast($2); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast($2); string name = StringTokPtr::dynamicCast($3)->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType, Operation::Idempotent); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag, + Operation::Idempotent); if(op) { cl->checkIntroduced(name, op); @@ -902,12 +920,12 @@ operation_preamble } | return_type ICE_KEYWORD_OP { - TypePtr returnType = TypePtr::dynamicCast($1); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast($1); string name = StringTokPtr::dynamicCast($2)->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag); if(op) { unit->pushContainer(op); @@ -926,12 +944,13 @@ operation_preamble } | ICE_IDEMPOTENT return_type ICE_KEYWORD_OP { - TypePtr returnType = TypePtr::dynamicCast($2); + OptionalDefTokPtr returnType = OptionalDefTokPtr::dynamicCast($2); string name = StringTokPtr::dynamicCast($3)->v; ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); if(cl) { - OperationPtr op = cl->createOperation(name, returnType, Operation::Idempotent); + OperationPtr op = cl->createOperation(name, returnType->v.type, returnType->v.optional, returnType->v.tag, + Operation::Idempotent); if(op) { unit->pushContainer(op); @@ -1403,17 +1422,15 @@ parameters : // empty { } -| out_qualifier meta_data type_id +| out_qualifier meta_data optional_type_id { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast($1); - TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast($3); - TypePtr type = tsp->v.first; - string ident = tsp->v.second; + OptionalDefTokPtr tsp = OptionalDefTokPtr::dynamicCast($3); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); - unit->currentContainer()->checkIntroduced(ident, pd); + ParamDeclPtr pd = op->createParamDecl(tsp->v.name, tsp->v.type, isOutParam->v, tsp->v.optional, tsp->v.tag); + unit->currentContainer()->checkIntroduced(tsp->v.name, pd); StringListTokPtr metaData = StringListTokPtr::dynamicCast($2); if(!metaData->v.empty()) { @@ -1421,17 +1438,15 @@ parameters } } } -| parameters ',' out_qualifier meta_data type_id +| parameters ',' out_qualifier meta_data optional_type_id { BoolTokPtr isOutParam = BoolTokPtr::dynamicCast($3); - TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast($5); - TypePtr type = tsp->v.first; - string ident = tsp->v.second; + OptionalDefTokPtr tsp = OptionalDefTokPtr::dynamicCast($5); OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); - unit->currentContainer()->checkIntroduced(ident, pd); + ParamDeclPtr pd = op->createParamDecl(tsp->v.name, tsp->v.type, isOutParam->v, tsp->v.optional, tsp->v.tag); + unit->currentContainer()->checkIntroduced(tsp->v.name, pd); StringListTokPtr metaData = StringListTokPtr::dynamicCast($4); if(!metaData->v.empty()) { @@ -1447,7 +1462,7 @@ parameters OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(ident->v, type, isOutParam->v); // Dummy + op->createParamDecl(ident->v, type, isOutParam->v, false, 0); // Dummy unit->error("keyword `" + ident->v + "' cannot be used as parameter name"); } } @@ -1459,7 +1474,7 @@ parameters OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(ident->v, type, isOutParam->v); // Dummy + op->createParamDecl(ident->v, type, isOutParam->v, false, 0); // Dummy unit->error("keyword `" + ident->v + "' cannot be used as parameter name"); } } @@ -1470,7 +1485,7 @@ parameters OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v); // Dummy + op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v, false, 0); // Dummy unit->error("missing parameter name"); } } @@ -1481,7 +1496,7 @@ parameters OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); if(op) { - op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v); // Dummy + op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v, false, 0); // Dummy unit->error("missing parameter name"); } } diff --git a/cpp/src/Slice/GrammarUtil.h b/cpp/src/Slice/GrammarUtil.h index f71e0dc961f..c803152dd24 100644 --- a/cpp/src/Slice/GrammarUtil.h +++ b/cpp/src/Slice/GrammarUtil.h @@ -26,7 +26,8 @@ class ExceptionListTok; class ClassListTok; class EnumeratorListTok; class ConstDefTok; -class DataMemberDefTok; +class OptionalDefTok; +class OptionalTypeDefTok; typedef ::IceUtil::Handle<StringTok> StringTokPtr; typedef ::IceUtil::Handle<StringListTok> StringListTokPtr; @@ -39,7 +40,7 @@ typedef ::IceUtil::Handle<ExceptionListTok> ExceptionListTokPtr; typedef ::IceUtil::Handle<ClassListTok> ClassListTokPtr; typedef ::IceUtil::Handle<EnumeratorListTok> EnumeratorListTokPtr; typedef ::IceUtil::Handle<ConstDefTok> ConstDefTokPtr; -typedef ::IceUtil::Handle<DataMemberDefTok> DataMemberDefTokPtr; +typedef ::IceUtil::Handle<OptionalDefTok> OptionalDefTokPtr; // ---------------------------------------------------------------------- // StringTok @@ -177,15 +178,15 @@ public: }; // ---------------------------------------------------------------------- -// DataMemberDefTok +// OptionalDefTok // ---------------------------------------------------------------------- -class SLICE_API DataMemberDefTok : public GrammarBase +class SLICE_API OptionalDefTok : public GrammarBase { public: - DataMemberDefTok() { } - DataMemberDef v; + OptionalDefTok() { } + OptionalDef v; }; } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 50b1e68101d..e7ecd451617 100755 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -40,6 +40,30 @@ string readWriteAttribute[] = { "read", "write" }; string txAttribute[] = { "supports", "mandatory", "required", "never" }; enum { Supports, Mandatory, Required, Never }; +DataMemberList +filterOrderedOptionalDataMembers(const DataMemberList& members) +{ + class SortFn + { + public: + static bool compare(const DataMemberPtr& lhs, const DataMemberPtr& rhs) + { + return lhs->tag() < rhs->tag(); + } + }; + + DataMemberList result; + for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p) + { + if((*p)->optional()) + { + result.push_back(*p); + } + } + result.sort(SortFn::compare); + return result; +} + } namespace Slice @@ -2939,6 +2963,8 @@ Slice::ClassDef::destroy() OperationPtr Slice::ClassDef::createOperation(const string& name, const TypePtr& returnType, + bool optional, + int tag, Operation::Mode mode) { checkIdentifier(name); @@ -3037,7 +3063,7 @@ Slice::ClassDef::createOperation(const string& name, } _hasOperations = true; - OperationPtr op = new Operation(this, name, returnType, mode); + OperationPtr op = new Operation(this, name, returnType, optional, tag, mode); _contents.push_back(op); return op; } @@ -3282,6 +3308,12 @@ Slice::ClassDef::dataMembers() const return result; } +DataMemberList +Slice::ClassDef::orderedOptionalDataMembers() const +{ + return filterOrderedOptionalDataMembers(dataMembers()); +} + // // Return the data members of this class and its parent classes, in base-to-derived order. // @@ -3753,6 +3785,12 @@ Slice::Exception::dataMembers() const return result; } +DataMemberList +Slice::Exception::orderedOptionalDataMembers() const +{ + return filterOrderedOptionalDataMembers(dataMembers()); +} + // // Return the data members of this exception and its parent exceptions, in base-to-derived order. // @@ -4556,22 +4594,13 @@ Slice::Enum::usesClasses() const size_t Slice::Enum::minWireSize() const { - size_t sz = _enumerators.size(); - if(sz <= 0x7f) - { - return 1; - } - if(sz <= 0x7fff) - { - return 2; - } - return 4; + return 1; } bool Slice::Enum::isVariableLength() const { - return false; + return true; } string @@ -4716,6 +4745,18 @@ Slice::Operation::returnType() const return _returnType; } +bool +Slice::Operation::returnIsOptional() const +{ + return _returnIsOptional; +} + +int +Slice::Operation::returnTag() const +{ + return _returnTag; +} + Operation::Mode Slice::Operation::mode() const { @@ -4736,7 +4777,7 @@ Slice::Operation::sendMode() const } ParamDeclPtr -Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool isOutParam) +Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool isOutParam, bool optional, int tag) { checkIdentifier(name); @@ -4835,7 +4876,7 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool _unit->error(msg); } - ParamDeclPtr p = new ParamDecl(this, name, type, isOutParam); + ParamDeclPtr p = new ParamDecl(this, name, type, isOutParam, optional, tag); _contents.push_back(p); return p; } @@ -5121,11 +5162,15 @@ Slice::Operation::visit(ParserVisitor* visitor, bool) Slice::Operation::Operation(const ContainerPtr& container, const string& name, const TypePtr& returnType, + bool returnIsOptional, + int returnTag, Mode mode) : SyntaxTreeBase(container->unit()), Contained(container, name), Container(container->unit()), _returnType(returnType), + _returnIsOptional(returnIsOptional), + _returnTag(returnTag), _mode(mode) { if(_unit->profile() == IceE) @@ -5166,6 +5211,18 @@ Slice::ParamDecl::isOutParam() const return _isOutParam; } +bool +Slice::ParamDecl::optional() const +{ + return _optional; +} + +int +Slice::ParamDecl::tag() const +{ + return _tag; +} + Contained::ContainedType Slice::ParamDecl::containedType() const { @@ -5196,11 +5253,14 @@ Slice::ParamDecl::visit(ParserVisitor* visitor, bool) visitor->visitParamDecl(this); } -Slice::ParamDecl::ParamDecl(const ContainerPtr& container, const string& name, const TypePtr& type, bool isOutParam) : +Slice::ParamDecl::ParamDecl(const ContainerPtr& container, const string& name, const TypePtr& type, bool isOutParam, + bool optional, int tag) : SyntaxTreeBase(container->unit()), Contained(container, name), _type(type), - _isOutParam(isOutParam) + _isOutParam(isOutParam), + _optional(optional), + _tag(tag) { } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 021ee80172c..54091b39450 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -26,7 +26,10 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; -static string +namespace +{ + +string getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2) { string deprecateMetadata, deprecateSymbol; @@ -38,7 +41,7 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2) return deprecateSymbol; } -static void +void writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const SyntaxTreeBasePtr& valueType, const string& value, int useWstring, const StringList& metaData) { @@ -126,7 +129,32 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt } } -static void +void +writeMarshalUnmarshalDataMember(IceUtilInternal::Output& C, const DataMemberPtr& p, bool marshal) +{ + writeMarshalUnmarshalCode(C, p->type(), p->optional(), p->tag(), fixKwd(p->name()), marshal, p->getMetaData()); +} + +void +writeMarshalUnmarshalDataMembers(IceUtilInternal::Output& C, + const DataMemberList& dataMembers, + const DataMemberList& optionalDataMembers, + bool marshal) +{ + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + { + if(!(*q)->optional()) + { + writeMarshalUnmarshalDataMember(C, *q, marshal); + } + } + for(DataMemberList::const_iterator q = optionalDataMembers.begin(); q != optionalDataMembers.end(); ++q) + { + writeMarshalUnmarshalDataMember(C, *q, marshal); + } +} + +void writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& members, int useWstring) { bool first = true; @@ -152,6 +180,8 @@ writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& me } } +} + Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension, const vector<string>& extraHeaders, const string& include, const vector<string>& includePaths, const string& dllExport, const string& dir, @@ -327,6 +357,7 @@ Slice::Gen::generate(const UnitPtr& p) H << "\n#include <Ice/ObjectF.h>"; H << "\n#include <Ice/Exception.h>"; H << "\n#include <Ice/LocalObject.h>"; + H << "\n#include <Ice/StreamTraits.h>"; if(p->usesProxies()) { @@ -358,7 +389,9 @@ Slice::Gen::generate(const UnitPtr& p) { H << "\n#include <Ice/FactoryTableInit.h>"; } + H << "\n#include <IceUtil/ScopedArray.h>"; + H << "\n#include <IceUtil/Optional.h>"; if(p->usesNonLocals()) { @@ -454,12 +487,12 @@ Slice::Gen::generate(const UnitPtr& p) ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport); p->visit(&objectDeclVisitor, false); - HandleVisitor handleVisitor(H, C, _dllExport, _stream); - p->visit(&handleVisitor, false); - TypesVisitor typesVisitor(H, C, _dllExport, _stream); p->visit(&typesVisitor, false); + StreamVisitor streamVistor(H, C); + p->visit(&streamVistor, false); + AsyncVisitor asyncVisitor(H, C, _dllExport); p->visit(&asyncVisitor, false); @@ -490,12 +523,6 @@ Slice::Gen::generate(const UnitPtr& p) ObjectVisitor objectVisitor(H, C, _dllExport, _stream); p->visit(&objectVisitor, false); - if(_stream) - { - StreamVisitor streamVistor(H, C); - p->visit(&streamVistor, false); - } - // // We need to delay generating the template after the proxy // definition, because __completed calls the begin_ method in the @@ -635,8 +662,6 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) ExceptionPtr base = p->base(); DataMemberList dataMembers = p->dataMembers(); DataMemberList allDataMembers = p->allDataMembers(); - bool basePreserved = p->inheritsMetaData("preserve-slice"); - bool preserved = basePreserved || p->hasMetaData("preserve-slice"); bool hasDefaultValues = p->hasDefaultValues(); DataMemberList::const_iterator q; @@ -653,7 +678,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring); + string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring); allTypes.push_back(typeName); allParamDecls.push_back(typeName + " __ice_" + fixKwd((*q)->name())); } @@ -667,16 +692,6 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) } } - // - // We declare a __usingClasses member for the initial preserved type in a hierarchy - // if neither that type nor its base class uses classes. - // - bool initUsingClasses = false; - if(preserved && !basePreserved && !p->usesClasses() && (!base || (base && !base->usesClasses()))) - { - initUsingClasses = true; - } - H << sp << nl << "class " << _dllExport << name << " : "; H.useCurrentPosAsIndent(); H << "public "; @@ -701,7 +716,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << "const char*" << "int"; } H << epar; - if(!p->isLocal() && !hasDefaultValues && !initUsingClasses) + if(!p->isLocal() && !hasDefaultValues) { H << " {}"; } @@ -741,19 +756,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) C << sb; C << eb; } - else if(hasDefaultValues || initUsingClasses) + else if(hasDefaultValues) { C << sp << nl << scoped.substr(2) << "::" << name << "() :"; C.inc(); writeDataMemberInitializers(C, dataMembers, _useWstring); - if(initUsingClasses) - { - if(hasDefaultValues) - { - C << ","; - } - C << nl << "__usingClasses(false)"; - } C.dec(); C << sb; C << eb; @@ -804,14 +811,6 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) } C << nl << *pi << "(__ice_" << *pi << ')'; } - if(initUsingClasses) - { - if(!baseParams.empty() || !params.empty()) - { - C << ","; - } - C << nl << "__usingClasses(false)"; - } if(p->isLocal() || !baseParams.empty() || !params.empty()) { C.dec(); @@ -873,9 +872,6 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) string name = fixKwd(p->name()); string scope = fixKwd(p->scope()); string scoped = fixKwd(p->scoped()); - DataMemberList dataMembers = p->dataMembers(); - DataMemberList::const_iterator q; - string factoryName; if(!p->isLocal()) @@ -914,10 +910,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) C << sp << nl << "void" << nl << scoped.substr(2) << "::__writeImpl(::IceInternal::BasicStream* __os) const"; C << sb; C << nl << "__os->startWriteSlice(\"" << p->scoped() << "\", " << (!base ? "true" : "false") << ");"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData()); - } + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true); C << nl << "__os->endWriteSlice();"; if(base) { @@ -942,10 +935,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) C << sp << nl << "void" << nl << scoped.substr(2) << "::__readImpl(::IceInternal::BasicStream* __is)"; C << sb; C << nl << "__is->startReadSlice();"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData()); - } + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false); C << nl << "__is->endReadSlice();"; if(base) { @@ -955,65 +945,55 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(_stream) { - C << sp << nl << "void" << nl << scoped.substr(2) - << "::__write(const ::Ice::OutputStreamPtr& __outS) const"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const"; C << sb; if(preserved) { - C << nl << "__outS->startException(__slicedData);"; + C << nl << "__os->startException(__slicedData);"; } else { - C << nl << "__outS->startException(0);"; + C << nl << "__os->startException(0);"; } - C << nl << "__writeImpl(__outS);"; - C << nl << "__outS->endException();"; + C << nl << "__writeImpl(__os);"; + C << nl << "__os->endException();"; C << eb; - C << sp << nl << "void" << nl << scoped.substr(2) - << "::__writeImpl(const ::Ice::OutputStreamPtr& __outS) const"; + C << sp << nl << "void" << nl << scoped.substr(2) + << "::__writeImpl(const ::Ice::OutputStreamPtr& __os) const"; C << sb; - C << nl << "__outS->startSlice(\"" << p->scoped() << "\", " << (!base ? "true" : "false") << ");"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData(), - _useWstring); - } - C << nl << "__outS->endSlice();"; + C << nl << "__os->startSlice(\"" << p->scoped() << "\", " << (!base ? "true" : "false") << ");"; + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true); + C << nl << "__os->endSlice();"; if(base) { - emitUpcall(base, "::__writeImpl(__outS);"); + emitUpcall(base, "::__writeImpl(__os);"); } C << eb; - C << sp << nl << "void" << nl << scoped.substr(2) - << "::__read(const ::Ice::InputStreamPtr& __inS)"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)"; C << sb; - C << nl << "__inS->startException();"; - C << nl << "__readImpl(__inS);"; + C << nl << "__is->startException();"; + C << nl << "__readImpl(__is);"; if(preserved) { - C << nl << "__slicedData = __inS->endException(true);"; + C << nl << "__slicedData = __is->endException(true);"; } else { - C << nl << "__inS->endException(false);"; + C << nl << "__is->endException(false);"; } C << eb; C << sp << nl << "void" << nl << scoped.substr(2) - << "::__readImpl(const ::Ice::InputStreamPtr& __inS)"; + << "::__readImpl(const ::Ice::InputStreamPtr& __is)"; C << sb; - C << nl << "__inS->startSlice();"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData(), - _useWstring); - } - C << nl << "__inS->endSlice();"; + C << nl << "__is->startSlice();"; + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false); + C << nl << "__is->endSlice();"; if(base) { - emitUpcall(base, "::__readImpl(__inS);"); + emitUpcall(base, "::__readImpl(__is);"); } C << eb; } @@ -1037,53 +1017,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) C << eb; } - // - // Override __usesClasses() if necessary. - // - if(p->usesClasses()) - { - if(!base || (base && !base->usesClasses())) - { - H << nl << "virtual bool __usesClasses() const;"; - - C << sp << nl << "bool"; - C << nl << scoped.substr(2) << "::__usesClasses() const"; - C << sb; - C << nl << "return true;"; - C << eb; - } - } - else if(preserved && !basePreserved) - { - if(!base || (base && !base->usesClasses())) - { - // - // Although a preserved exception may not contain any class data members, - // the preserved slices of derived exceptions may contain class data members. - // - H << sp << nl << "virtual bool __usesClasses() const;"; - H << nl << "virtual void __usesClasses(bool);"; - C << sp << nl << "bool" << nl << scoped.substr(2) << "::__usesClasses() const"; - C << sb; - C << nl << "return __usingClasses;"; - C << eb; - C << sp << nl << "void" << nl << scoped.substr(2) << "::__usesClasses(bool __b)"; - C << sb; - C << nl << "__usingClasses = __b;"; - C << eb; - } - } - if(preserved && !basePreserved) { H.zeroIndent(); H << sp << nl << "protected:"; H.restoreIndent(); H << sp << nl << "::Ice::SlicedDataPtr __slicedData;"; - if(!p->usesClasses() && (!base || (base && !base->usesClasses()))) - { - H << nl << "bool __usingClasses;"; - } } factoryName = "__F" + p->flattenedScope() + p->name(); @@ -1216,7 +1155,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) vector<string> types; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring); + string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring); types.push_back(typeName); paramDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -1340,15 +1279,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) if(_stream) { - H << nl << dllExport << "void ice_write(const ::Ice::OutputStreamPtr&) const;"; - H << nl << dllExport << "void ice_read(const ::Ice::InputStreamPtr&);"; + 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(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData()); + writeMarshalUnmarshalDataMember(C, *q, true); } C << eb; @@ -1356,78 +1295,35 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData()); + writeMarshalUnmarshalDataMember(C, *q, false); } C << eb; if(_stream) { - C << sp << nl << "void" << nl << scoped.substr(2) - << "::ice_write(const ::Ice::OutputStreamPtr& __outS) const"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const"; C << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData(), - _useWstring); + C << nl << "__os->write(" << fixKwd((*q)->name()) << ");"; } C << eb; - C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_read(const ::Ice::InputStreamPtr& __inS)"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)"; C << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData(), - _useWstring); + C << nl << "__is->read(" << fixKwd((*q)->name()) << ");"; } C << eb; } } H << eb << ';'; + if(findMetaData(p->getMetaData()) == "class") { H << sp << nl << "typedef ::IceUtil::Handle< " << scoped << "> " << p->name() + "Ptr;"; - - if(!p->isLocal() && _stream) - { - H << sp << nl << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const " - << p->name() << "Ptr&);"; - H << nl << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << p->name() - << "Ptr&);"; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr& __outS, const " << fixKwd(p->scoped() + "Ptr") << "& __v)"; - C << sb; - C << nl << "__v->ice_write(__outS);"; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name() - << "(const ::Ice::InputStreamPtr& __inS, " << fixKwd(p->scoped() + "Ptr") << "& __v)"; - C << sb; - C << nl << "__v->ice_read(__inS);"; - C << eb; - } - } - else - { - if(!p->isLocal() && _stream) - { - H << sp << nl << dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const " - << name << "&);"; - H << nl << dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);"; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& __v)"; - C << sb; - C << nl << "__v.ice_write(__outS);"; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name() - << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& __v)"; - C << sb; - C << nl << "__v.ice_read(__inS);"; - C << eb; - } } _useWstring = resetUseWstring(_useWstringHist); @@ -1438,7 +1334,8 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) { string name = fixKwd(p->name()); TypePtr type = p->type(); - if(p->container() != 0 && (StructPtr::dynamicCast(p->container()) || ExceptionPtr::dynamicCast(p->container())) && + if(p->container() != 0 && + (StructPtr::dynamicCast(p->container()) || ExceptionPtr::dynamicCast(p->container())) && SequencePtr::dynamicCast(type)) { SequencePtr s = SequencePtr::dynamicCast(type); @@ -1457,8 +1354,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) } } - string s = typeToString(p->type(), p->getMetaData(), _useWstring); - H << nl << s << ' ' << name << ';'; + H << nl << typeToString(p->type(), p->optional(), p->getMetaData(), _useWstring) << ' ' << name << ';'; } void @@ -1483,201 +1379,6 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) H << nl << "typedef ::std::vector<" << (s[0] == ':' ? " " : "") << s << "> " << name << ';'; } } - - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(!p->isLocal()) - { - string scoped = fixKwd(p->scoped()); - string scope = fixKwd(p->scope()); - - if(protobuf || !seqType.empty()) - { - string typeName = name; - string scopedName = scoped; - if(protobuf && !seqType.empty()) - { - typeName = seqType; - scopedName = seqType; - } - H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const " - << typeName << "&);"; - H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, " - << typeName << "&);"; - - if(_stream) - { - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr&, const " << typeName << "&);"; - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() - << "(const ::Ice::InputStreamPtr&, " << typeName << "&);"; - } - - C << sp << nl << "void" << nl << scope.substr(2) << "__write" << name << - "(::IceInternal::BasicStream* __os, const " << scopedName << "& v)"; - C << sb; - if(protobuf) - { - C << nl << "::std::vector< ::Ice::Byte> data(v.ByteSize());"; - C << nl << "if(!v.IsInitialized())"; - C << sb; - C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"type not fully initialized: \" + v.InitializationErrorString());"; - C << eb; - C << nl << "if(!v.SerializeToArray(&data[0], data.size()))"; - C << sb; - C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"SerializeToArray failed\");"; - C << eb; - C << nl << "__os->write(&data[0], &data[0] + data.size());"; - } - else - { - C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(v.size());"; - C << nl << "__os->writeSize(size);"; - C << nl << "for(" << name << "::const_iterator p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeMarshalUnmarshalCode(C, type, "(*p)", true); - C << eb; - } - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "__read" << name - << "(::IceInternal::BasicStream* __is, " << scopedName << "& v)"; - C << sb; - if(protobuf) - { - C << nl << "::std::pair<const ::Ice::Byte*, const ::Ice::Byte*> data;"; - C << nl << "__is->read(data);"; - C << nl << "if(!v.ParseFromArray(data.first, data.second - data.first))"; - C << sb; - C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"ParseFromArray failed\");"; - C << eb; - } - else - { - C << nl << "::Ice::Int sz;"; - C << nl << "__is->readAndCheckSeqSize(" << type->minWireSize() << ", sz);"; - C << nl << name << "(sz).swap(v);"; - C << nl << "for(" << name << "::iterator p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeMarshalUnmarshalCode(C, type, "(*p)", false); - C << eb; - } - C << eb; - - if(_stream) - { - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr& __outS, const " << scopedName << "& v)"; - C << sb; - if(protobuf) - { - C << nl << "::std::vector< ::Ice::Byte> data(v.ByteSize());"; - C << nl << "if(!v.IsInitialized())"; - C << sb; - C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"type not fully initialized: \" + v.InitializationErrorString());"; - C << eb; - C << nl << "v.SerializeToArray(&data[0], data.size());"; - - C << nl << "__outS->write(data);"; - } - else - { - C << nl << "__outS->writeSize(::Ice::Int(v.size()));"; - C << nl << scopedName << "::const_iterator p;"; - C << nl << "for(p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeStreamMarshalUnmarshalCode(C, type, "(*p)", true, "", StringList(), _useWstring); - C << eb; - } - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name() - << "(const ::Ice::InputStreamPtr& __inS, " << scopedName << "& v)"; - C << sb; - if(protobuf) - { - C << nl << "::std::pair<const ::Ice::Byte*, const ::Ice::Byte*> data;"; - C << nl << "__inS->readByteSeq(data);"; - C << nl << "if(!v.ParseFromArray(data.first, data.second - data.first))"; - C << sb; - C << nl << "throw ::Ice::MarshalException(__FILE__, __LINE__, \"ParseFromArray failed\");"; - C << eb; - } - else - { - C << nl << "::Ice::Int sz = __inS->readAndCheckSeqSize(" << type->minWireSize() << ");"; - C << nl << scopedName << "(sz).swap(v);"; - C << nl << scopedName << "::iterator p;"; - C << nl << "for(p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeStreamMarshalUnmarshalCode(C, type, "(*p)", false, "", StringList(), _useWstring); - C << eb; - } - C << eb; - } - } - else if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy) - { - H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const " << s - << "*, const " << s << "*);"; - H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, " << name << "&);"; - - if(_stream) - { - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr&, const " << name << "&);"; - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() - << "(const ::Ice::InputStreamPtr&, " << name << "&);"; - } - - C << sp << nl << "void" << nl << scope.substr(2) << "__write" << name - << "(::IceInternal::BasicStream* __os, const " << s << "* begin, const " << s << "* end)"; - C << sb; - C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(end - begin);"; - C << nl << "__os->writeSize(size);"; - C << nl << "for(int i = 0; i < size; ++i)"; - C << sb; - writeMarshalUnmarshalCode(C, type, "begin[i]", true); - C << eb; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "__read" << name - << "(::IceInternal::BasicStream* __is, " << scoped << "& v)"; - C << sb; - C << nl << "::Ice::Int sz;"; - C << nl << "__is->readAndCheckSeqSize(" << type->minWireSize() << ", sz);"; - C << nl << "v.resize(sz);"; - C << nl << "for(int i = 0; i < sz; ++i)"; - C << sb; - writeMarshalUnmarshalCode(C, type, "v[i]", false); - C << eb; - C << eb; - - if(_stream) - { - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& v)"; - C << sb; - C << nl << "__outS->writeSize(::Ice::Int(v.size()));"; - C << nl << scoped << "::const_iterator p;"; - C << nl << "for(p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeStreamMarshalUnmarshalCode(C, type, "(*p)", true, "", StringList(), _useWstring); - C << eb; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name() - << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)"; - C << sb; - C << nl << "::Ice::Int sz = __inS->readAndCheckSeqSize(" << type->minWireSize() << ");"; - C << nl << "v.resize(sz);"; - C << nl << "for(int i = 0; i < sz; ++i)"; - C << sb; - writeStreamMarshalUnmarshalCode(C, type, "v[i]", false, "", StringList(), _useWstring); - C << eb; - C << eb; - } - } - } } void @@ -1709,78 +1410,6 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) } string vs = typeToString(valueType, p->valueMetaData(), _useWstring); H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';'; - - if(!p->isLocal()) - { - string scoped = fixKwd(p->scoped()); - string scope = fixKwd(p->scope()); - - H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const " << name << "&);"; - H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, " << name << "&);"; - - if(_stream) - { - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr&, const " << name << "&);"; - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() - << "(const ::Ice::InputStreamPtr&, " << name << "&);"; - } - - C << sp << nl << "void" << nl << scope.substr(2) << "__write" << name - << "(::IceInternal::BasicStream* __os, const " << scoped << "& v)"; - C << sb; - C << nl << "__os->writeSize(::Ice::Int(v.size()));"; - C << nl << scoped << "::const_iterator p;"; - C << nl << "for(p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeMarshalUnmarshalCode(C, keyType, "p->first", true); - writeMarshalUnmarshalCode(C, valueType, "p->second", true); - C << eb; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "__read" << name - << "(::IceInternal::BasicStream* __is, " << scoped << "& v)"; - C << sb; - C << nl << "::Ice::Int sz;"; - C << nl << "__is->readSize(sz);"; - C << nl << "while(sz--)"; - C << sb; - C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;"; - const string pf = string("const_cast<") + ks + "&>(pair.first)"; - writeMarshalUnmarshalCode(C, keyType, pf, false); - C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);"; - writeMarshalUnmarshalCode(C, valueType, "__i->second", false); - C << eb; - C << eb; - - if(_stream) - { - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& v)"; - C << sb; - C << nl << "__outS->writeSize(::Ice::Int(v.size()));"; - C << nl << scoped << "::const_iterator p;"; - C << nl << "for(p = v.begin(); p != v.end(); ++p)"; - C << sb; - writeStreamMarshalUnmarshalCode(C, keyType, "p->first", true, "", p->keyMetaData(), _useWstring); - writeStreamMarshalUnmarshalCode(C, valueType, "p->second", true, "", p->valueMetaData(), _useWstring); - C << eb; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name() - << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)"; - C << sb; - C << nl << "::Ice::Int sz = __inS->readSize();"; - C << nl << "while(sz--)"; - C << sb; - C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;"; - writeStreamMarshalUnmarshalCode(C, keyType, pf, false, "", p->keyMetaData(), _useWstring); - C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);"; - writeStreamMarshalUnmarshalCode(C, valueType, "__i->second", false, "", p->valueMetaData(), _useWstring); - C << eb; - C << eb; - } - } } void @@ -1800,77 +1429,6 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) } } H << eb << ';'; - - string scoped = fixKwd(p->scoped()); - string scope = fixKwd(p->scope()); - - if(!p->isLocal()) - { - size_t sz = enumerators.size(); - assert(sz <= 0x7fffffff); // 64-bit enums are not supported - - H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");"; - H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);"; - - if(_stream) - { - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr&, " << name << ");"; - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << p->name() - << "(const ::Ice::InputStreamPtr&, " << name << "&);"; - } - - C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped - << " v)"; - C << sb; - if(sz <= 0x7f) - { - C << nl << "__os->write(static_cast< ::Ice::Byte>(v), " << sz << ");"; - } - else if(sz <= 0x7fff) - { - C << nl << "__os->write(static_cast< ::Ice::Short>(v), " << sz << ");"; - } - else - { - C << nl << "__os->write(static_cast< ::Ice::Int>(v), " << sz << ");"; - } - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped - << "& v)"; - C << sb; - if(sz <= 0x7f) - { - C << nl << "::Ice::Byte val;"; - } - else if(sz <= 0x7fff) - { - C << nl << "::Ice::Short val;"; - } - else - { - C << nl << "::Ice::Int val;"; - } - C << nl << "__is->read(val, " << sz << ");"; - C << nl << "v = static_cast< " << scoped << ">(val);"; - C << eb; - - if(_stream) - { - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name() - << "(const ::Ice::OutputStreamPtr& __outS, " << scoped << " v)"; - C << sb; - C << nl << "__outS->write(v);"; - C << eb; - - C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name() - << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)"; - C << sb; - C << nl << "__inS->read(v);"; - C << eb; - } - } } void @@ -1957,6 +1515,8 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p) string scoped = fixKwd(p->scoped()); H << sp << nl << "class " << name << ';'; + H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, ::IceInternal::ProxyHandle< ::IceProxy" + << scoped << ">&);"; H << nl << _dllExport << "::IceProxy::Ice::Object* upCast(::IceProxy" << scoped << "*);"; } @@ -2066,6 +1626,23 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) << "::IceProxy::Ice::Object* ::IceProxy" << scope << "upCast(::IceProxy" << scoped << "* p) { return p; }"; + C << sp; + C << nl << "void" << nl << "::IceProxy" << scope << "__read(::IceInternal::BasicStream* __is, " + << "::IceInternal::ProxyHandle< ::IceProxy" << scoped << ">& v)"; + C << sb; + C << nl << "::Ice::ObjectPrx proxy;"; + C << nl << "__is->read(proxy);"; + C << nl << "if(!proxy)"; + C << sb; + C << nl << "v = 0;"; + C << eb; + C << nl << "else"; + C << sb; + C << nl << "v = new ::IceProxy" << scoped << ';'; + C << nl << "v->__copyFrom(proxy);"; + C << eb; + C << eb; + return true; } @@ -2444,8 +2021,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIEnd); - string retSEndAMI = returnTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd); + bool retIsOpt = p->returnIsOptional(); + string retS = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIEnd); + string retSEndAMI = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd); ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); @@ -2476,12 +2054,13 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string typeStringEndAMI; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData, _useWstring | TypeContextAMIEnd); - typeStringEndAMI = outputTypeToString((*q)->type(), metaData, _useWstring | TypeContextAMIPrivateEnd); + typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring | TypeContextAMIEnd); + typeStringEndAMI = outputTypeToString((*q)->type(), (*q)->optional(), metaData, + _useWstring | TypeContextAMIPrivateEnd); } else { - typeString = inputTypeToString((*q)->type(), metaData, _useWstring); + typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } params.push_back(typeString); @@ -2517,7 +2096,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) bool generatePrivateEnd = retS != retSEndAMI || outParamsDeclAMI != outParamsDeclEndAMI; if(ret && generatePrivateEnd) { - string typeStringEndAMI = outputTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd); + string typeStringEndAMI = outputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), + _useWstring | TypeContextAMIPrivateEnd); outParamsDeclEndAMI.push_back(typeStringEndAMI + ' ' + "__ret"); } @@ -2680,7 +2260,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { C << nl << "__os->format(" << formatTypeToString(format) << ");"; } - writeMarshalCode(C, inParams, 0, StringList(), TypeContextInParam); + writeMarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__result->__endWriteParams();"; } C << nl << "__result->__send(true);"; @@ -2705,7 +2285,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) // access violations errors with the test/Ice/slicing/objects test on VC9 // and Windows 64 bits when compiled with optimization (see bug 4400). // - writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring | TypeContextAMIEnd); + writeAllocateCode(C, ParamDeclList(), p, _useWstring | TypeContextAMIEnd); C << nl << "if(!__result->__wait())"; C << sb; @@ -2741,7 +2321,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if(ret || !outParams.empty()) { C << nl << "::IceInternal::BasicStream* __is = __result->__startReadParams();"; - writeUnmarshalCode(C, outParams, ret, p->getMetaData(), _useWstring | TypeContextAMIEnd); + writeUnmarshalCode(C, outParams, p, _useWstring | TypeContextAMIEnd); C << nl << "__result->__endReadParams();"; } else @@ -2801,7 +2381,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if(ret || !outParams.empty()) { C << nl << "::IceInternal::BasicStream* __is = __result->__startReadParams();"; - writeUnmarshalCode(C, outParams, ret, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd); + writeUnmarshalCode(C, outParams, p, _useWstring | TypeContextAMIPrivateEnd); C << nl << "__result->__endReadParams();"; } else @@ -3036,7 +2616,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) string name = fixKwd(p->name()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData(), _useWstring); + string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); vector<string> params; @@ -3044,24 +2624,15 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { StringList metaData = (*q)->getMetaData(); -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData, _useWstring); + typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } else { - typeString = inputTypeToString((*q)->type(), metaData, _useWstring); + typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } -#else - string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring) - : inputTypeToString((*q)->type(), metaData, _useWstring); -#endif - params.push_back(typeString); } @@ -3176,7 +2747,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData(), _useWstring); + string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); vector<string> params; vector<string> paramsDecl; @@ -3194,12 +2765,12 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) if(isOutParam) { outParams.push_back(*q); - typeString = outputTypeToString(type, metaData, _useWstring); + typeString = outputTypeToString(type, (*q)->optional(), metaData, _useWstring); } else { inParams.push_back(*q); - typeString = inputTypeToString(type, metaData, _useWstring); + typeString = inputTypeToString(type, (*q)->optional(), metaData, _useWstring); } params.push_back(typeString); @@ -3233,7 +2804,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << nl << "__os->format(" << formatTypeToString(format) << ");"; } } - writeMarshalCode(C, inParams, 0, StringList(), TypeContextInParam); + writeMarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__og.endWriteParams();"; C << eb; C << nl << "catch(const ::Ice::LocalException& __ex)"; @@ -3248,7 +2819,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) // Declare the return __ret variable at the top-level scope to // enable NRVO with GCC (see also bug #3619). // - writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring); + writeAllocateCode(C, ParamDeclList(), p, _useWstring); if(!p->returnsData()) { C << nl << "if(__og.hasResponse())"; @@ -3312,19 +2883,10 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; - for(ParamDeclList::const_iterator opi = outParams.begin(); opi != outParams.end(); ++opi) - { - StructPtr st = StructPtr::dynamicCast((*opi)->type()); - if(st && findMetaData(st->getMetaData()) == "class") - { - C << nl << fixKwd((*opi)->name()) << " = new " << fixKwd(st->scoped()) << ";"; - } - } - if(ret || !outParams.empty()) { C << nl << "::IceInternal::BasicStream* __is = __og.startReadParams();"; - writeUnmarshalCode(C, outParams, ret, p->getMetaData()); + writeUnmarshalCode(C, outParams, p); C << nl << "__og.endReadParams();"; } else @@ -3454,7 +3016,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData(), _useWstring); + string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); vector<string> params; vector<string> paramsDecl; @@ -3468,23 +3030,15 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) string paramName = fixKwd((*q)->name()); StringList metaData = (*q)->getMetaData(); -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData, _useWstring); + typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } else { - typeString = inputTypeToString((*q)->type(), metaData, _useWstring); + typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } -#else - string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring) - : inputTypeToString((*q)->type(), metaData, _useWstring); -#endif params.push_back(typeString); paramsDecl.push_back(typeString + ' ' + paramName); @@ -3533,7 +3087,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << sp << nl << "_DirectI" << spar; if(ret) { - string resultRef = outputTypeToString(ret, p->getMetaData(), _useWstring); + string resultRef = outputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); C << resultRef + " __result"; } C << directParamsDecl << "const ::Ice::Current& __current" << epar << " : "; @@ -3610,7 +3164,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << nl; if(ret) { - string resultRef= outputTypeToString(ret, p->getMetaData(), _useWstring); + string resultRef= outputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); C << nl << resultRef << " _result;"; } @@ -3741,6 +3295,7 @@ Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p) H << nl << _dllExport << "::Ice::Object* upCast(" << scoped << "*);"; H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << p->name() << "Ptr;"; H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << p->name() << "Prx;"; + H << nl << _dllExport << "void __patch(" << p->name() << "Ptr&, ::Ice::ObjectPtr&);"; } else { @@ -3873,7 +3428,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring); + string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring); allTypes.push_back(typeName); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -3882,7 +3437,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) { if(p->hasDefaultValues()) { - H << name << "() :"; + H << sp << nl << name << "() :"; H.inc(); writeDataMemberInitializers(H, dataMembers, _useWstring); H.dec(); @@ -4326,12 +3881,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) << "::__writeImpl(::IceInternal::BasicStream* __os) const"; C << sb; C << nl << "__os->startWriteSlice(ice_staticId(), " << (!base ? "true" : "false") << ");"; - DataMemberList dataMembers = p->dataMembers(); - DataMemberList::const_iterator q; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData()); - } + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true); C << nl << "__os->endWriteSlice();"; if(base) { @@ -4358,10 +3908,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "void" << nl << scoped.substr(2) << "::__readImpl(::IceInternal::BasicStream* __is)"; C << sb; C << nl << "__is->startReadSlice();"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData()); - } + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false); C << nl << "__is->endReadSlice();"; if(base) { @@ -4371,63 +3918,54 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) if(_stream) { - C << sp << nl << "void" << nl << scoped.substr(2) - << "::__write(const ::Ice::OutputStreamPtr& __outS) const"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __os) const"; C << sb; if(preserved) { - C << nl << "__outS->startObject(__slicedData);"; + C << nl << "__os->startObject(__slicedData);"; } else { - C << nl << "__outS->startObject(0);"; + C << nl << "__os->startObject(0);"; } - C << nl << "__writeImpl(__outS);"; - C << nl << "__outS->endObject();"; + C << nl << "__writeImpl(__os);"; + C << nl << "__os->endObject();"; C << eb; C << sp << nl << "void" << nl << scoped.substr(2) - << "::__writeImpl(const ::Ice::OutputStreamPtr& __outS) const"; + << "::__writeImpl(const ::Ice::OutputStreamPtr& __os) const"; C << sb; - C << nl << "__outS->startSlice(ice_staticId(), " << (!base ? "true" : "false") << ");"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData(), - _useWstring); - } - C << nl << "__outS->endSlice();"; + C << nl << "__os->startSlice(ice_staticId(), " << (!base ? "true" : "false") << ");"; + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), true); + C << nl << "__os->endSlice();"; if(base) { - emitUpcall(base, "::__writeImpl(__outS);"); + emitUpcall(base, "::__writeImpl(__os);"); } C << eb; - C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __inS)"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __is)"; C << sb; - C << nl << "__inS->startObject();"; - C << nl << "__readImpl(__inS);"; + C << nl << "__is->startObject();"; + C << nl << "__readImpl(__is);"; if(preserved) { - C << nl << "__slicedData = __inS->endObject(true);"; + C << nl << "__slicedData = __is->endObject(true);"; } else { - C << nl << "__inS->endObject(false);"; + C << nl << "__is->endObject(false);"; } C << eb; - C << sp << nl << "void" << nl << scoped.substr(2) << "::__readImpl(const ::Ice::InputStreamPtr& __inS)"; + C << sp << nl << "void" << nl << scoped.substr(2) << "::__readImpl(const ::Ice::InputStreamPtr& __is)"; C << sb; - C << nl << "__inS->startSlice();"; - for(q = dataMembers.begin(); q != dataMembers.end(); ++q) - { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData(), - _useWstring); - } - C << nl << "__inS->endSlice();"; + C << nl << "__is->startSlice();"; + writeMarshalUnmarshalDataMembers(C, p->dataMembers(), p->orderedOptionalDataMembers(), false); + C << nl << "__is->endSlice();"; if(base) { - emitUpcall(base, "::__readImpl(__inS);"); + emitUpcall(base, "::__readImpl(__is);"); } C << eb; } @@ -4517,51 +4055,15 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) } } - bool inProtected = false; - - if(!p->isAbstract()) - { - // - // We add a protected destructor to force heap instantiation of the class. - // - H.dec(); - H << sp << nl << "protected:"; - H.inc(); - H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}"; - - if(!_doneStaticSymbol) - { - H << sp << nl << "friend class " << p->name() << "__staticInit;"; - } - - inProtected = true; - } - // // Emit data members. Access visibility may be specified by metadata. // + bool inProtected = false; DataMemberList dataMembers = p->dataMembers(); DataMemberList::const_iterator q; bool prot = p->hasMetaData("protected"); for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - TypePtr type = (*q)->type(); - if(SequencePtr::dynamicCast(type)) - { - SequencePtr s = SequencePtr::dynamicCast(type); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(s->type()); - if(builtin && builtin->kind() == Builtin::KindByte) - { - StringList metaData = s->getMetaData(); - bool protobuf; - findMetaData(s, metaData, protobuf); - if(protobuf) - { - emitWarning((*q)->file(), (*q)->line(), "protobuf cannot be used as a class member in C++"); - } - } - } - if(prot || (*q)->hasMetaData("protected")) { if(!inProtected) @@ -4583,9 +4085,27 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) } } - string name = fixKwd((*q)->name()); - string s = typeToString((*q)->type(), (*q)->getMetaData(), _useWstring); - H << sp << nl << s << ' ' << name << ';'; + emitDataMember(*q); + } + + if(!p->isAbstract()) + { + // + // We add a protected destructor to force heap instantiation of the class. + // + if(!inProtected) + { + H.dec(); + H << sp << nl << "protected:"; + H.inc(); + inProtected = true; + } + H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}"; + + if(!_doneStaticSymbol) + { + H << sp << nl << "friend class " << p->name() << "__staticInit;"; + } } if(!p->isLocal() && preserved && !basePreserved) @@ -4640,12 +4160,10 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) { C << sp << nl << "void " << (_dllExport.empty() ? "" : "ICE_DECLSPEC_EXPORT "); - C << nl << scope.substr(2) << "__patch__" << p->name() << "Ptr(void* __addr, ::Ice::ObjectPtr& v)"; + C << nl << scope.substr(2) << "__patch(" << p->name() << "Ptr& handle, ::Ice::ObjectPtr& v)"; C << sb; - C << nl << scope << p->name() << "Ptr* p = static_cast< " << scope << p->name() << "Ptr*>(__addr);"; - C << nl << "assert(p);"; - C << nl << "*p = " << scope << p->name() << "Ptr::dynamicCast(v);"; - C << nl << "if(v && !*p)"; + C << nl << "handle = " << scope << p->name() << "Ptr::dynamicCast(v);"; + C << nl << "if(v && !handle)"; C << sb; C << nl << "IceInternal::Ex::throwUOE(" << scoped << "::ice_staticId(), v->ice_id());"; C << eb; @@ -4686,7 +4204,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData(), _useWstring); + string retS = returnTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); string params = "("; string paramsDecl = "("; @@ -4714,12 +4232,12 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) if(isOutParam) { outParams.push_back(*q); - typeString = outputTypeToString(type, (*q)->getMetaData(), _useWstring); + typeString = outputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring); } else { inParams.push_back(*q); - typeString = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring); + typeString = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring); } if(q != paramList.begin()) @@ -4823,8 +4341,8 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) if(!inParams.empty()) { C << nl << "::IceInternal::BasicStream* __is = __inS.startReadParams();"; - writeAllocateCode(C, inParams, 0, StringList(), _useWstring | TypeContextInParam); - writeUnmarshalCode(C, inParams, 0, StringList(), TypeContextInParam); + writeAllocateCode(C, inParams, 0, _useWstring | TypeContextInParam); + writeUnmarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__inS.endReadParams();"; } else @@ -4832,7 +4350,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << nl << "__inS.readEmptyParams();"; } - writeAllocateCode(C, outParams, 0, StringList(), _useWstring); + writeAllocateCode(C, outParams, 0, _useWstring); if(!throws.empty()) { C << nl << "try"; @@ -4852,7 +4370,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) { C << nl << "__os->format(" << formatTypeToString(format) << ");"; } - writeMarshalCode(C, outParams, ret, p->getMetaData()); + writeMarshalCode(C, outParams, p); C << nl << "__inS.__endWriteParams(true);"; } else @@ -4887,8 +4405,8 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) if(!inParams.empty()) { C << nl << "::IceInternal::BasicStream* __is = __inS.startReadParams();"; - writeAllocateCode(C, inParams, 0, StringList(), _useWstring | TypeContextInParam); - writeUnmarshalCode(C, inParams, 0, StringList(), TypeContextInParam); + writeAllocateCode(C, inParams, 0, _useWstring | TypeContextInParam); + writeUnmarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__inS.endReadParams();"; } else @@ -4929,11 +4447,12 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) string typeString; if((*r)->isOutParam()) { - typeString = outputTypeToString((*r)->type(), metaData, _useWstring | TypeContextAMIEnd); + typeString = outputTypeToString((*r)->type(), (*r)->optional(), metaData, + _useWstring | TypeContextAMIEnd); } else { - typeString = inputTypeToString((*r)->type(), metaData, _useWstring); + typeString = inputTypeToString((*r)->type(), (*r)->optional(), metaData, _useWstring); } if(!(*r)->isOutParam()) @@ -4966,6 +4485,30 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) } void +Slice::Gen::ObjectVisitor::emitDataMember(const DataMemberPtr& p) +{ + TypePtr type = p->type(); + if(SequencePtr::dynamicCast(type)) + { + SequencePtr s = SequencePtr::dynamicCast(type); + BuiltinPtr builtin = BuiltinPtr::dynamicCast(s->type()); + if(builtin && builtin->kind() == Builtin::KindByte) + { + StringList metaData = s->getMetaData(); + bool protobuf; + findMetaData(s, metaData, protobuf); + if(protobuf) + { + emitWarning(p->file(), p->line(), "protobuf cannot be used as a class member in C++"); + } + } + } + + string name = fixKwd(p->name()); + H << sp << nl << typeToString(p->type(), p->optional(), p->getMetaData(), _useWstring) << ' ' << name << ';'; +} + +void Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) { string scoped = fixKwd(p->scoped()); @@ -5050,7 +4593,7 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) { if((*i)->type()->usesClasses()) { - emitGCInsertCode((*i)->type(), fixKwd((*i)->name()), "", 0); + emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0); } } C << eb; @@ -5086,7 +4629,7 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) { if((*j)->type()->usesClasses()) { - emitGCClearCode((*j)->type(), fixKwd((*j)->name()), "", 0); + emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0); } } C << eb; @@ -5096,8 +4639,8 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) void Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& prefix, const string& name, int level) { - if((BuiltinPtr::dynamicCast(p) && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject) - || ClassDeclPtr::dynamicCast(p)) + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); + if((builtin && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) { C << nl << "if(" << prefix << name << ')'; C << sb; @@ -5160,8 +4703,8 @@ Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& pref void Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefix, const string& name, int level) { - if((BuiltinPtr::dynamicCast(p) && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject) - || ClassDeclPtr::dynamicCast(p)) + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); + if((builtin && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) { C << nl << "if(" << prefix << name << ")"; C << sb; @@ -5294,7 +4837,7 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring); + string typeName = inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -5466,8 +5009,9 @@ bool usePrivateEnd(const OperationPtr& p) { TypePtr ret = p->returnType(); - string retSEnd = returnTypeToString(ret, p->getMetaData(), TypeContextAMIEnd); - string retSPrivateEnd = returnTypeToString(ret, p->getMetaData(), TypeContextAMIPrivateEnd); + bool retIsOpt = p->returnIsOptional(); + string retSEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIEnd); + string retSPrivateEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIPrivateEnd); ParamDeclList outParams; vector<string> outDeclsEnd; @@ -5478,8 +5022,10 @@ usePrivateEnd(const OperationPtr& p) { if((*q)->isOutParam()) { - outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->getMetaData(), TypeContextAMIEnd)); - outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->getMetaData(), TypeContextAMIPrivateEnd)); + outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), + TypeContextAMIEnd)); + outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), + TypeContextAMIPrivateEnd)); } } @@ -5510,7 +5056,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr& string delTmplName = (withCookie ? "Callback_" : "CallbackNC_") + clName + "_" + p->name(); TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret, p->getMetaData(), _useWstring); + string retS = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); string retEndArg = getEndArg(ret, p->getMetaData(), "__ret"); ParamDeclList outParams; @@ -5527,7 +5073,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr& outParams.push_back(*q); outArgs.push_back(fixKwd((*q)->name())); outEndArgs.push_back(getEndArg((*q)->type(), (*q)->getMetaData(), outArgs.back())); - outDecls.push_back(inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring)); + outDecls.push_back(inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring)); } } @@ -5616,8 +5162,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr& H << sb; H << nl << clScope << clName << "Prx __proxy = " << clScope << clName << "Prx::uncheckedCast(__result->getProxy());"; - writeAllocateCode(H, outParams, ret, p->getMetaData(), - _useWstring | TypeContextInParam | TypeContextAMICallPrivateEnd); + writeAllocateCode(H, outParams, p, _useWstring | TypeContextInParam | TypeContextAMICallPrivateEnd); H << nl << "try"; H << sb; H << nl; @@ -5638,7 +5183,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr& } H << "__result" << epar << ';'; } - writeEndCode(H, outParams, ret, p->getMetaData()); + writeEndCode(H, outParams, p); H << eb; H << nl << "catch(::Ice::Exception& ex)"; H << sb; @@ -5770,134 +5315,6 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr& } } -Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, const string& dllExport, bool stream) : - H(h), C(c), _dllExport(dllExport), _stream(stream) -{ -} - -bool -Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p) -{ - if(!p->hasClassDecls()) - { - return false; - } - - string name = fixKwd(p->name()); - - H << sp; - H << nl << "namespace " << name << nl << '{'; - - return true; -} - -void -Slice::Gen::HandleVisitor::visitModuleEnd(const ModulePtr& p) -{ - H << sp; - H << nl << '}'; -} - -void -Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) -{ - string name = p->name(); - string scoped = fixKwd(p->scoped()); - - if(!p->isLocal()) - { - H << sp; - H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);"; - H << nl << _dllExport << "void __patch__" << name << "Ptr(void*, ::Ice::ObjectPtr&);"; - if(_stream) - { - H << sp << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << name - << "Prx(const ::Ice::OutputStreamPtr&, const " << name << "Prx&);"; - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << name - << "Prx(const ::Ice::InputStreamPtr&, " << name << "Prx&);"; - - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_write" << name - << "(const ::Ice::OutputStreamPtr&, const " - << name << "Ptr&);"; - H << nl << _dllExport << "ICE_DEPRECATED_API void ice_read" << name << "(const ::Ice::InputStreamPtr&, " - << name << "Ptr&);"; - } - } -} - -bool -Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - if(!p->isLocal()) - { - string name = p->name(); - string scoped = fixKwd(p->scoped()); - string scope = fixKwd(p->scope()); - - string factory; - string type; - if(!p->isAbstract()) - { - type = scoped + "::ice_staticId()"; - factory = scoped + "::ice_factory()"; - } - else - { - type = "\"\""; - factory = "0"; - } - - C << sp; - C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " - << scope << name << "Prx& v)"; - C << sb; - C << nl << "::Ice::ObjectPrx proxy;"; - C << nl << "__is->read(proxy);"; - C << nl << "if(!proxy)"; - C << sb; - C << nl << "v = 0;"; - C << eb; - C << nl << "else"; - C << sb; - C << nl << "v = new ::IceProxy" << scoped << ';'; - C << nl << "v->__copyFrom(proxy);"; - C << eb; - C << eb; - - if(_stream) - { - C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << name - << "Prx(const ::Ice::OutputStreamPtr& __outS, const " << scope << name << "Prx& v)"; - C << sb; - C << nl << "__outS->write(v);"; - C << eb; - - C << sp; - C << nl << "void" << nl << scope.substr(2) << "ice_read" << name - << "Prx(const ::Ice::InputStreamPtr& __inS, " << scope << name << "Prx& v)"; - C << sb; - C << nl << "__inS->read(v);"; - C << eb; - - C << sp; - C << nl << "void" << nl << scope.substr(2) << "ice_write" << name - << "(const ::Ice::OutputStreamPtr& __outS, const " << scope << name << "Ptr& v)"; - C << sb; - C << nl << "__outS->writeObject(v);"; - C << eb; - - C << sp; - C << nl << "void" << nl << scope.substr(2) << "ice_read" << name << "(const ::Ice::InputStreamPtr& __inS, " - << scope << name << "Ptr& __v)"; - C << sb; - C << nl << "__inS->read(__v);"; - C << eb; - } - } - - return true; -} - Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport), _useWstring(false) { @@ -6135,7 +5552,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string opName = op->name(); TypePtr ret = op->returnType(); - string retS = returnTypeToString(ret, op->getMetaData(), _useWstring); + string retS = returnTypeToString(ret, op->returnIsOptional(), op->getMetaData(), _useWstring); if(!p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"))) { @@ -6148,7 +5565,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!(*q)->isOutParam()) { - H << ',' << nl << inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring); + H << ',' << nl << inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), + _useWstring); } } H << ',' << nl << "const Ice::Current&"; @@ -6165,8 +5583,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!(*q)->isOutParam()) { - C << ',' << nl << inputTypeToString((*q)->type(), (*q)->getMetaData(), _useWstring) << ' ' - << fixKwd((*q)->name()); + C << ',' << nl << inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), + _useWstring) << ' ' << fixKwd((*q)->name()); } } C << ',' << nl << "const Ice::Current& current"; @@ -6228,23 +5646,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) H << ',' << nl; } StringList metaData = (*q)->getMetaData(); -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData, _useWstring); + typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } else { - typeString = inputTypeToString((*q)->type(), metaData, _useWstring); + typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } -#else - string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring) - : inputTypeToString((*q)->type(), metaData, _useWstring); -#endif H << typeString; } if(!p->isLocal()) @@ -6271,23 +5681,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) C << ',' << nl; } StringList metaData = (*q)->getMetaData(); -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), _useWstring, metaData); + typeString = outputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } else { - typeString = inputTypeToString((*q)->type(), _useWstring, metaData); + typeString = inputTypeToString((*q)->type(), (*q)->optional(), metaData, _useWstring); } -#else - string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), metaData, _useWstring) - : inputTypeToString((*q)->type(), metaData, _useWstring); -#endif C << typeString << ' ' << fixKwd((*q)->name()); } if(!p->isLocal()) @@ -6396,12 +5798,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) paramsDeclInvoke.push_back("const " + proxyName + "& __prx"); TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret, p->getMetaData(), _useWstring); + string retS = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); if(ret) { params.push_back(retS); - paramsAMD.push_back(inputTypeToString(ret, p->getMetaData(), _useWstring)); + paramsAMD.push_back(inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring)); paramsDecl.push_back(retS + " __ret"); args.push_back("__ret"); } @@ -6413,12 +5815,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) { string paramName = fixKwd((*q)->name()); TypePtr type = (*q)->type(); - string typeString = inputTypeToString(type, (*q)->getMetaData(), _useWstring); + string typeString = inputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring); if((*q)->isOutParam()) { params.push_back(typeString); - paramsAMD.push_back(inputTypeToString(type, (*q)->getMetaData(), _useWstring)); + paramsAMD.push_back(inputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring)); paramsDecl.push_back(typeString + ' ' + paramName); args.push_back(paramName); @@ -6589,7 +5991,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) #endif TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret, p->getMetaData(), _useWstring); + string retS = inputTypeToString(ret, p->returnIsOptional(), p->getMetaData(), _useWstring); if(ret) { @@ -6608,7 +6010,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) { string paramName = fixKwd((*q)->name()); TypePtr type = (*q)->type(); - string typeString = inputTypeToString(type, (*q)->getMetaData(), _useWstring); + string typeString = inputTypeToString(type, (*q)->optional(), (*q)->getMetaData(), _useWstring); if(ret || !outParams.empty()) { @@ -6682,11 +6084,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) { C << nl << "__os->format(" << formatTypeToString(format) << ");"; } - writeMarshalCode(C, outParams, 0, StringList(), TypeContextInParam); - if(ret) - { - writeMarshalUnmarshalCode(C, ret, "__ret", true, "", true, p->getMetaData(), TypeContextInParam); - } + writeMarshalCode(C, outParams, p, TypeContextInParam); C << nl << "__endWriteParams(true);"; C << eb; C << nl << "catch(const ::Ice::Exception& __ex)"; @@ -6772,10 +6170,6 @@ Slice::Gen::StreamVisitor::visitModuleStart(const ModulePtr& m) // Only emit this for the top-level module. // H << sp; - H.zeroIndent(); - H << nl << "#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug"; // COMPILERFIX - H << nl << "#else"; - H.restoreIndent(); H << nl << "namespace Ice" << nl << '{'; } @@ -6791,9 +6185,6 @@ Slice::Gen::StreamVisitor::visitModuleEnd(const ModulePtr& m) // Only emit this for the top-level module. // H << nl << '}'; - H.zeroIndent(); - H << nl << "#endif"; - H.restoreIndent(); } } @@ -6838,6 +6229,15 @@ Slice::Gen::StreamVisitor::visitStructStart(const StructPtr& p) H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeStruct;"; } H << nl << "static const int minWireSize = " << p->minWireSize() << ";"; + H << nl << "static const bool isVariableLength = " << p->isVariableLength() << ";"; + if(p->isVariableLength()) + { + H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeFSize;"; + } + else + { + H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeVSize;"; + } H << eb << ";" << nl; } return false; @@ -6850,22 +6250,11 @@ Slice::Gen::StreamVisitor::visitEnum(const EnumPtr& p) H << nl << "template<>"; H << nl << "struct StreamTrait< " << scoped << ">"; H << sb; - H << nl << "static const ::Ice::StreamTraitType type = "; - size_t sz = p->getEnumerators().size(); - if(sz <= 127) - { - H << "::Ice::StreamTraitTypeByteEnum;"; - } - else if(sz <= 32767) - { - H << "::Ice::StreamTraitTypeShortEnum;"; - } - else - { - H << "::Ice::StreamTraitTypeIntEnum;"; - } - H << nl << "static const int enumLimit = " << sz << ";"; + H << nl << "static const ::Ice::StreamTraitType type = ::Ice::StreamTraitTypeEnum;"; + H << nl << "static const int enumLimit = " << p->getEnumerators().size() << ";"; H << nl << "static const int minWireSize = " << p->minWireSize() << ";"; + H << nl << "static const bool isVariableLength = true;"; + H << nl << "static const ::Ice::OptionalType optionalType = ::Ice::OptionalTypeSize;"; H << eb << ";" << nl; } diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 6e217075c10..9d05ca2a8b5 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -255,6 +255,7 @@ private: private: + void emitDataMember(const DataMemberPtr&); void emitGCFunctions(const ClassDefPtr&); void emitGCInsertCode(const TypePtr&, const std::string&, const std::string&, int); void emitGCClearCode(const TypePtr&, const std::string&, const std::string&, int); @@ -320,26 +321,6 @@ private: std::list<int> _useWstringHist; }; - class HandleVisitor : private ::IceUtil::noncopyable, public ParserVisitor - { - public: - - HandleVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual void visitClassDecl(const ClassDeclPtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - - private: - - ::IceUtilInternal::Output& H; - ::IceUtilInternal::Output& C; - - std::string _dllExport; - bool _stream; - }; - class ImplVisitor : private ::IceUtil::noncopyable, public ParserVisitor { public: diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 14ff61bc8c2..04026196d4f 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -319,7 +319,7 @@ writeCodecH(const TypePtr& type, const StringList& metaData, const string& name, H << sp << nl << "public:"; H << sp; H.inc(); - H << nl << "static void write(" << inputTypeToString(type, metaData) + H << nl << "static void write(" << inputTypeToString(type, false, metaData) << ", Freeze::" << freezeType << "&, const ::Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; H << nl << "static void read(" << typeToString(type, metaData) << "&, const Freeze::" << freezeType << "&, " << "const ::Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; @@ -333,7 +333,7 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name, { string quotedFreezeType = "\"" + freezeType + "\""; - C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type, metaData) << " v, " + C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type, false, metaData) << " v, " << "Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator, " << "const Ice::EncodingVersion& encoding)"; C << sb; @@ -343,7 +343,7 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name, { C << nl << "stream.startWriteEncaps();"; } - writeMarshalUnmarshalCode(C, type, "v", true, "stream", false, metaData); + writeMarshalUnmarshalCode(C, type, false, 0, "v", true, metaData, 0, "stream", false); if(type->usesClasses()) { C << nl << "stream.writePendingObjects();"; @@ -372,7 +372,7 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name, { C << nl << "stream.startReadEncaps();"; } - writeMarshalUnmarshalCode(C, type, "v", false, "stream", false, metaData); + writeMarshalUnmarshalCode(C, type, false, 0, "v", false, metaData, 0, "stream", false); if(type->usesClasses()) { C << nl << "stream.readPendingObjects();"; @@ -501,7 +501,7 @@ writeDictWithIndicesH(const string& name, const Dict& dict, // // Codec // - H << nl << "static void write(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + H << nl << "static void write(" << inputTypeToString(indexTypes[i].type, 0, indexTypes[i].metaData) << ", Freeze::Key&, const Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; H << nl << "static void read(" @@ -572,9 +572,9 @@ writeDictWithIndicesH(const string& name, const Dict& dict, { H << sp; H << nl << "iterator findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ", bool = true);"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true);"; H << nl << "const_iterator findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ", bool = true) const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true) const;"; H << nl << "iterator beginFor" << capitalizedMembers[i] << "();"; H << nl << "const_iterator beginFor" << capitalizedMembers[i] << "() const;"; @@ -583,28 +583,28 @@ writeDictWithIndicesH(const string& name, const Dict& dict, H << nl << "const_iterator endFor" << capitalizedMembers[i] << "() const;"; H << nl << "iterator lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ");"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");"; H << nl << "const_iterator lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ") const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; H << nl << "iterator upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ");"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");"; H << nl << "const_iterator upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ") const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; H << nl << "std::pair<iterator, iterator> equalRangeFor" - << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");"; H << nl << "std::pair<const_iterator, const_iterator> equalRangeFor" - << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; string countFunction = dict.indices[i].member.empty() ? string("valueCount") : dict.indices[i].member + "Count"; H << nl << "int " << countFunction - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ") const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; } @@ -623,8 +623,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di + typeToString(valueType, valueMetaData) + ", " + name + "KeyCodec, " + name + "ValueCodec, " + compare + " >"; - string keyCompareParams = - string("< ") + typeToString(keyType, keyMetaData) + ", " + string keyCompareParams = string("< ") + typeToString(keyType, keyMetaData) + ", " + name + "KeyCodec, " + compare + " >"; vector<string> capitalizedMembers; @@ -708,7 +707,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "void" << nl << absolute << "::" << className << "::" - << "write(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << "write(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index, Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator, " << "const Ice::EncodingVersion& __encoding)"; C << sb; @@ -736,7 +735,8 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di valueS = "__lowerCaseIndex"; } - writeMarshalUnmarshalCode(C, indexTypes[i].type, valueS, true, "__stream", false, indexTypes[i].metaData); + writeMarshalUnmarshalCode(C, indexTypes[i].type, false, 0, valueS, true, indexTypes[i].metaData, 0, + "__stream", false); C << nl << "::std::vector<Ice::Byte>(__stream.b.begin(), __stream.b.end()).swap(__bytes);"; } C << eb; @@ -760,8 +760,8 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << nl << "__stream.b.resize(__bytes.size());"; C << nl << "::memcpy(&__stream.b[0], &__bytes[0], __bytes.size());"; C << nl << "__stream.i = __stream.b.begin();"; - writeMarshalUnmarshalCode(C, indexTypes[i].type, "__index", false, "__stream", false, - indexTypes[i].metaData); + writeMarshalUnmarshalCode(C, indexTypes[i].type, false, 0, "__index", false, indexTypes[i].metaData, 0, + "__stream", false); } C << eb; } @@ -839,7 +839,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index, bool __onlyDups)"; C << sb; C << nl << "Freeze::Key __bytes;"; @@ -850,7 +850,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index, bool __onlyDups) const"; C << sb; C << nl << "Freeze::Key __bytes;"; @@ -885,7 +885,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index)"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; @@ -895,7 +895,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; @@ -905,7 +905,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index)"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; @@ -915,7 +915,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; @@ -926,7 +926,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "std::pair<" << absolute << "::iterator, " << absolute << "::iterator>" << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index)"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)"; C << sb; C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i] << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));"; @@ -935,7 +935,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "std::pair<" << absolute << "::const_iterator, " << absolute << "::const_iterator>" << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i] << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));"; @@ -946,7 +946,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "int" << nl << absolute << "::" << countFunction - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; @@ -1202,7 +1202,7 @@ void writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& memberName, bool caseSensitive, const string& fullName, const string& name, Output& C) { - string inputType = inputTypeToString(memberType); + string inputType = inputTypeToString(memberType, false); C << sp << nl << fullName << "::" << name << "(const ::std::string& __name, const ::std::string& __facet)"; @@ -1270,7 +1270,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member valueS = "__lowerCaseIndex"; } - writeMarshalUnmarshalCode(C, memberType, valueS, true, "__stream", false); + writeMarshalUnmarshalCode(C, memberType, false, 0, valueS, true, StringList(), 0, "__stream", false); if(memberType->usesClasses()) { C << nl << "__stream.writePendingObjects();"; @@ -1363,7 +1363,7 @@ writeIndex(const string& n, const UnitPtr& u, const Index& index, Output& H, Out H << nl << "namespace " << *q << nl << '{'; } - writeIndexH(inputTypeToString(dataMember->type()), name, H, dllExport); + writeIndexH(inputTypeToString(dataMember->type(), false), name, H, dllExport); for(q = scope.begin(); q != scope.end(); ++q) { |