WriteStringSlice writes []string to buffer using LIST protocol. When hasGenerics is true (element type known from TypeDef/generics), uses IS_DECL_ELEMENT_TYPE and doesn't write element type ID. When false, writes element type ID.
(buf *ByteBuffer, value []string, hasGenerics bool)
| 1404 | // When hasGenerics is true (element type known from TypeDef/generics), uses IS_DECL_ELEMENT_TYPE |
| 1405 | // and doesn't write element type ID. When false, writes element type ID. |
| 1406 | func WriteStringSlice(buf *ByteBuffer, value []string, hasGenerics bool) { |
| 1407 | length := len(value) |
| 1408 | buf.WriteVarUint32(uint32(length)) |
| 1409 | if length > 0 { |
| 1410 | // Use CollectionDeclSameType when element type is known from TypeDef/generics |
| 1411 | // This matches Java's writeNullabilityHeader behavior for monomorphic types |
| 1412 | if hasGenerics { |
| 1413 | buf.WriteInt8(int8(CollectionDeclSameType)) |
| 1414 | } else { |
| 1415 | buf.WriteInt8(int8(CollectionIsSameType)) |
| 1416 | buf.WriteUint8(uint8(STRING)) |
| 1417 | } |
| 1418 | for i := 0; i < length; i++ { |
| 1419 | writeString(buf, value[i]) |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | // ReadStringSlice reads []string from buffer using LIST protocol |
| 1425 | func ReadStringSlice(buf *ByteBuffer, err *Error) []string { |
no test coverage detected