예제 #1
0
        unsafe bool FillBuffers()
        {
            if (m_Parser.TokenNextIndex < m_Tokenizer.TokenNextIndex || m_Parser.NodeType != NodeType.None)
            {
                return(false);
            }

            if (null != m_StreamBlockReader)
            {
                m_Block = m_StreamBlockReader.GetNextBlock();

                if (IsEmpty(m_Block))
                {
                    m_Block = default;
                    return(false);
                }
            }

            m_Tokenizer.DiscardCompleted();
            m_Parser.Seek(m_Tokenizer.TokenNextIndex, m_Tokenizer.TokenParentIndex);
            m_BinaryWriter.Seek(m_Tokenizer.TokenNextIndex, m_BinaryWriter.TokenParentIndex != -1
                                    ? m_Tokenizer.DiscardRemap[m_BinaryWriter.TokenParentIndex]
                                    : -1);

            m_Tokenizer.Write(m_Block, 0, m_Block.Length);
            return(true);
        }
예제 #2
0
        unsafe bool FillBuffers()
        {
            if (m_Parser.TokenNextIndex < m_Tokenizer.TokenNextIndex || m_Parser.NodeType != NodeType.None)
            {
                return(false);
            }

            bool isFinalBlock;

            if (null != m_StreamBlockReader)
            {
                var info = m_StreamBlockReader.GetNextBlock();
                m_CurrentBlock = info.Block;
                isFinalBlock   = info.IsFinal;
            }
            else
            {
                m_CurrentBlock = m_InitialBlock;
                m_InitialBlock = default;
                isFinalBlock   = true;
            }

            if (IsEmpty(m_CurrentBlock))
            {
                m_CurrentBlock = default;

                // We need to perform off one final write call to trigger validation.
                m_Tokenizer.Write(m_CurrentBlock, 0, 0, true);
                return(false);
            }

            m_Tokenizer.DiscardCompleted();
            m_Parser.Seek(m_Tokenizer.TokenNextIndex, m_Tokenizer.TokenParentIndex);
            m_BinaryWriter.Seek(m_Tokenizer.TokenNextIndex, m_BinaryWriter.TokenParentIndex != -1
                                    ? m_Tokenizer.DiscardRemap[m_BinaryWriter.TokenParentIndex]
                                    : -1);

            m_Tokenizer.Write(m_CurrentBlock, 0, m_CurrentBlock.Length, isFinalBlock);
            return(true);
        }