(ctx *WriteContext, value reflect.Value)
| 768 | } |
| 769 | |
| 770 | func (s float16ArraySerializer) WriteData(ctx *WriteContext, value reflect.Value) { |
| 771 | buf := ctx.Buffer() |
| 772 | length := value.Len() |
| 773 | size := length * 2 |
| 774 | buf.WriteLength(size) |
| 775 | if length > 0 { |
| 776 | if value.CanAddr() && isLittleEndian { |
| 777 | ptr := value.Addr().UnsafePointer() |
| 778 | buf.WriteBinary(unsafe.Slice((*byte)(ptr), size)) |
| 779 | } else { |
| 780 | for i := 0; i < length; i++ { |
| 781 | // We can't easily cast the whole array if not addressable/little-endian |
| 782 | // So we iterate. |
| 783 | // value.Index(i) is Float16, we cast to uint16 |
| 784 | val := value.Index(i).Interface().(float16.Float16) |
| 785 | buf.WriteUint16(val.Bits()) |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | func (s float16ArraySerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) { |
| 792 | writeArrayRefAndType(ctx, refMode, writeType, value, FLOAT16_ARRAY) |
no test coverage detected