Example #1
0
        public void FinishVTables_Random()
        {
            context.Reset(ScratchLength);

            var random = this.RandomVTables;

            for (int i = 0; i < random.Length; ++i)
            {
                context.FinishVTable(Scratch, random[i]);
            }
        }
Example #2
0
            private static void WriteInlineValueOf_7b5996bec77f4c71928769dd75748853 <TSpanWriter>(
                TSpanWriter spanWriter,
                Span <byte> span,
                BenchmarkCore.SortedVectorTable value,
                int offset,
                SerializationContext context) where TSpanWriter : ISpanWriter
            {
                checked
                {
                    int tableStart = context.AllocateSpace(11, sizeof(int));
                    spanWriter.WriteUOffset(span, offset, tableStart, context);
                    int currentOffset = tableStart + sizeof(int); // skip past vtable soffset_t.

                    int         vtableLength = 4;
                    Span <byte> vtable       = stackalloc byte[6];

                    var index0Value  = value.Vector;
                    var index0Offset = tableStart;

                    if (!(index0Value is null))
                    {
                        currentOffset += SerializationHelpers.GetAlignmentError(currentOffset, 4);
                        index0Offset   = currentOffset;
                        currentOffset += 4;


                        if (6 > vtableLength)
                        {
                            vtableLength = 6;
                        }
                    }
                    spanWriter.WriteUShort(vtable, (ushort)(index0Offset - tableStart), 4, context);
                    int tableLength = currentOffset - tableStart;
                    context.Offset -= 11 - tableLength;
                    spanWriter.WriteUShort(vtable, (ushort)vtableLength, 0, context);
                    spanWriter.WriteUShort(vtable, (ushort)tableLength, sizeof(ushort), context);
                    int vtablePosition = context.FinishVTable(span, vtable.Slice(0, vtableLength));
                    spanWriter.WriteInt(span, tableStart - vtablePosition, tableStart, context);

                    if (index0Offset != tableStart)
                    {
                        WriteInlineValueOf_36d43cc8bc8e4fbd92e5d1e6822467b6(
                            spanWriter,
                            span,
                            index0Value !,
                            index0Offset,
                            context);

                        context.AddPostSerializeAction(
                            (tempSpan, ctx) =>
                            SortedVectorHelpers.SortVector(
                                tempSpan,
                                index0Offset,
                                0,
                                4,
                                new FlatSharp.IntSpanComparer(default(System.Int32))));
                    }
                }
            }
Example #3
0
            private static void WriteInlineValueOf_96c3a6fa438049bf89a78192c2c3e4aa <TSpanWriter>(
                TSpanWriter spanWriter,
                Span <byte> span,
                BenchmarkCore.SortedVectorTableItem value,
                int offset,
                SerializationContext context) where TSpanWriter : ISpanWriter
            {
                checked
                {
                    int tableStart = context.AllocateSpace(11, sizeof(int));
                    spanWriter.WriteUOffset(span, offset, tableStart, context);
                    int currentOffset = tableStart + sizeof(int); // skip past vtable soffset_t.

                    int         vtableLength = 4;
                    Span <byte> vtable       = stackalloc byte[6];

                    var index0Value  = value.Key;
                    var index0Offset = tableStart;

                    if (index0Value != default(System.Int32))
                    {
                        currentOffset += SerializationHelpers.GetAlignmentError(currentOffset, 4);
                        index0Offset   = currentOffset;
                        currentOffset += 4;

                        WriteInlineValueOf_2c1d694fadee47f08ebfecc7f8090de6(
                            spanWriter,
                            span,
                            index0Value,
                            index0Offset,
                            context);


                        if (6 > vtableLength)
                        {
                            vtableLength = 6;
                        }
                    }
                    spanWriter.WriteUShort(vtable, (ushort)(index0Offset - tableStart), 4, context);
                    int tableLength = currentOffset - tableStart;
                    context.Offset -= 11 - tableLength;
                    spanWriter.WriteUShort(vtable, (ushort)vtableLength, 0, context);
                    spanWriter.WriteUShort(vtable, (ushort)tableLength, sizeof(ushort), context);
                    int vtablePosition = context.FinishVTable(span, vtable.Slice(0, vtableLength));
                    spanWriter.WriteInt(span, tableStart - vtablePosition, tableStart, context);
                }
            }
 public int FinishVTable_Zero()
 {
     context.Reset(ScratchLength);
     return(context.FinishVTable(default(SpanWriter), 30, Scratch, ZeroByteVTable));
 }