Add element size parameter to __vector_as_arraysegment [c#] (#5512)

* Add element size parameter to __vector_as_arraysegment

Add element size parameter to __vector_as_arraysegment fixing issue where VectorAsBytes returns incorrect size span for multibyte element types.

* Update codegen

Update codegen and Table to return typed span.

* update test files

update test files
This commit is contained in:
Kevin Fort
2019-09-10 19:07:46 -05:00
committed by Wouter van Oortmerssen
parent b5560fcd52
commit 2706381eef
8 changed files with 38 additions and 24 deletions

View File

@@ -38,7 +38,7 @@ public struct MonsterExtra : IFlatbufferObject
public double Dvec(int j) { int o = __p.__offset(20); return o != 0 ? __p.bb.GetDouble(__p.__vector(o) + j * 8) : (double)0; }
public int DvecLength { get { int o = __p.__offset(20); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
public Span<byte> GetDvecBytes() { return __p.__vector_as_span(20); }
public Span<double> GetDvecBytes() { return __p.__vector_as_span<double>(20, 8); }
#else
public ArraySegment<byte>? GetDvecBytes() { return __p.__vector_as_arraysegment(20); }
#endif
@@ -47,7 +47,7 @@ public struct MonsterExtra : IFlatbufferObject
public float Fvec(int j) { int o = __p.__offset(22); return o != 0 ? __p.bb.GetFloat(__p.__vector(o) + j * 4) : (float)0; }
public int FvecLength { get { int o = __p.__offset(22); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
public Span<byte> GetFvecBytes() { return __p.__vector_as_span(22); }
public Span<float> GetFvecBytes() { return __p.__vector_as_span<float>(22, 4); }
#else
public ArraySegment<byte>? GetFvecBytes() { return __p.__vector_as_arraysegment(22); }
#endif