Beispiel #1
0
 internal EncapsDecoder10(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f,
                          ClassResolver cr)
     : base(stream, encaps, sliceValues, f, cr)
 {
     _sliceType = SliceType.NoSlice;
 }
Beispiel #2
0
            private int _valueIdIndex; // The ID of the next instance to unmarshal.

            #endregion Fields

            #region Constructors

            internal EncapsDecoder11(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f,
                                     ClassResolver cr, CompactIdResolver r)
                : base(stream, encaps, sliceValues, f, cr)
            {
                _compactIdResolver = r;
                _current = null;
                _valueIdIndex = 1;
            }
Beispiel #3
0
 internal EncapsDecoder(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f,
                        ClassResolver cr)
 {
     _stream = stream;
     _encaps = encaps;
     _sliceValues = sliceValues;
     _valueFactoryManager = f;
     _classResolver = cr;
     _typeIdIndex = 0;
     _unmarshaledMap = new Dictionary<int, Ice.Object>();
 }
Beispiel #4
0
        /// <summary>
        /// Ends the previous encapsulation.
        /// </summary>
        public void endEncapsulation()
        {
            Debug.Assert(_encapsStack != null);

            if(!_encapsStack.encoding_1_0)
            {
                skipOptionals();
                if(_buf.b.position() != _encapsStack.start + _encapsStack.sz)
                {
                    throw new EncapsulationException();
                }
            }
            else if(_buf.b.position() != _encapsStack.start + _encapsStack.sz)
            {
                if(_buf.b.position() + 1 != _encapsStack.start + _encapsStack.sz)
                {
                    throw new EncapsulationException();
                }

                //
                // Ice version < 3.3 had a bug where user exceptions with
                // class members could be encoded with a trailing byte
                // when dispatched with AMD. So we tolerate an extra byte
                // in the encapsulation.
                //
                try
                {
                    _buf.b.get();
                }
                catch(InvalidOperationException ex)
                {
                    throw new UnmarshalOutOfBoundsException(ex);
                }
            }

            Encaps curr = _encapsStack;
            _encapsStack = curr.next;
            curr.next = _encapsCache;
            _encapsCache = curr;
            _encapsCache.reset();
        }
Beispiel #5
0
        /// <summary>
        /// Releases any data retained by encapsulations. Internally calls clear().
        /// </summary>
        public void clear()
        {
            if(_encapsStack != null)
            {
                Debug.Assert(_encapsStack.next == null);
                _encapsStack.next = _encapsCache;
                _encapsCache = _encapsStack;
                _encapsStack = null;
                _encapsCache.reset();
            }

            _startSeq = -1;
            _sliceValues = true;
        }
Beispiel #6
0
 private void resetEncapsulation()
 {
     _encapsStack = null;
 }
Beispiel #7
0
 private void initialize(EncodingVersion encoding)
 {
     instance_ = null;
     _encoding = encoding;
     _encapsStack = null;
     _encapsCache = null;
     _traceSlicing = false;
     _closure = null;
     _sliceValues = true;
     _startSeq = -1;
     _minSeqSize = 0;
 }
Beispiel #8
0
        private void initEncaps()
        {
            if(_encapsStack == null) // Lazy initialization
            {
                _encapsStack = _encapsCache;
                if(_encapsStack != null)
                {
                    _encapsCache = _encapsCache.next;
                }
                else
                {
                    _encapsStack = new Encaps();
                }
                _encapsStack.setEncoding(_encoding);
                _encapsStack.sz = _buf.b.limit();
            }

            if(_encapsStack.decoder == null) // Lazy initialization.
            {
                if(_encapsStack.encoding_1_0)
                {
                    _encapsStack.decoder = new EncapsDecoder10(this, _encapsStack, _sliceValues, _valueFactoryManager,
                                                               _classResolver);
                }
                else
                {
                    _encapsStack.decoder = new EncapsDecoder11(this, _encapsStack, _sliceValues, _valueFactoryManager,
                                                               _classResolver, _compactIdResolver);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Reads the start of an encapsulation.
        /// </summary>
        /// <returns>The encapsulation encoding version.</returns>
        public EncodingVersion startEncapsulation()
        {
            Encaps curr = _encapsCache;
            if(curr != null)
            {
                curr.reset();
                _encapsCache = _encapsCache.next;
            }
            else
            {
                curr = new Encaps();
            }
            curr.next = _encapsStack;
            _encapsStack = curr;

            _encapsStack.start = _buf.b.position();

            //
            // I don't use readSize() for encapsulations, because when creating an encapsulation,
            // I must know in advance how many bytes the size information will require in the data
            // stream. If I use an Int, it is always 4 bytes. For readSize(), it could be 1 or 5 bytes.
            //
            int sz = readInt();
            if(sz < 6)
            {
                throw new UnmarshalOutOfBoundsException();
            }
            if(sz - 4 > _buf.b.remaining())
            {
                throw new UnmarshalOutOfBoundsException();
            }
            _encapsStack.sz = sz;

            EncodingVersion encoding = new EncodingVersion();
            encoding.read__(this);
            Protocol.checkSupportedEncoding(encoding); // Make sure the encoding is supported.
            _encapsStack.setEncoding(encoding);

            return encoding;
        }