(ctx *WriteContext, value reflect.Value)
| 838 | } |
| 839 | |
| 840 | func (s bfloat16ArraySerializer) WriteData(ctx *WriteContext, value reflect.Value) { |
| 841 | buf := ctx.Buffer() |
| 842 | length := value.Len() |
| 843 | size := length * 2 |
| 844 | buf.WriteLength(size) |
| 845 | if length > 0 { |
| 846 | if value.CanAddr() && isLittleEndian { |
| 847 | ptr := value.Addr().UnsafePointer() |
| 848 | buf.WriteBinary(unsafe.Slice((*byte)(ptr), size)) |
| 849 | } else { |
| 850 | for i := 0; i < length; i++ { |
| 851 | // We can't easily cast the whole array if not addressable/little-endian |
| 852 | // So we iterate. |
| 853 | val := value.Index(i).Interface().(bfloat16.BFloat16) |
| 854 | buf.WriteUint16(val.Bits()) |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | func (s bfloat16ArraySerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) { |
| 861 | writeArrayRefAndType(ctx, refMode, writeType, value, BFLOAT16_ARRAY) |
no test coverage detected