morph lenpfx to valterm: make item type generic

This commit is contained in:
Michael Sippel 2025-05-16 13:51:45 +02:00
parent 0eb8074644
commit 76c005ac8b
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 7 additions and 4 deletions

View file

@ -13,9 +13,9 @@ morph_array_as_valterm_to_lenpfx (Terminator:native.UInt8)
```
morph_array_as_lenpfx_to_valterm (Terminator:native.UInt8)
<Seq~<LengthPrefix native.UInt64> native.UInt8>
--> <Seq~<ValueTerminated Terminator> native.UInt8>
morph_array_as_lenpfx_to_valterm (T: Type, Terminator: T)
<Seq~<LengthPrefix native.UInt64> T>
--> <Seq~<ValueTerminated Terminator> T>
```
for( uint64_t i = 0; i < src->len; ++i )
*dst++ = src->items[i];

View file

@ -3,7 +3,7 @@
#include <stdlib.h>
```
morph_seqseq_valsep_uint8 (T: Type, SrcDelim: T, DstDelim: T)
morph_valsep_delim (T: Type, SrcDelim: T, DstDelim: T)
< Seq <Seq T> >
~ < ValueSep SrcDelim T >
~ < Seq~<LengthPrefix native.UInt64> T >
@ -22,6 +22,9 @@ morph_seqseq_valsep_uint8 (T: Type, SrcDelim: T, DstDelim: T)
if( DstDelim == '\n' ) {
PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, '\\' );
PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, 'n' );
} else {
PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, '\\' );
PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, DstDelim );
}
} else {
PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, src->items[i] );