figured out how to serialize nested structures

This commit is contained in:
Folkert 2022-07-27 23:52:11 +02:00
parent fc01a0ee44
commit 8e5b0daa94
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 136 additions and 45 deletions

View file

@ -2541,14 +2541,14 @@ pub fn strCloneTo(
const slice = string.asSlice();
var relative = string;
relative.str_bytes = @intToPtr(?[*]u8, offset + WIDTH); // i.e. just after the string struct
relative.str_bytes = @intToPtr(?[*]u8, extra_offset); // i.e. just after the string struct
// write the string struct
const array = relative.asArray();
@memcpy(ptr + offset, &array, WIDTH);
// write the string bytes just after the struct
@memcpy(ptr + extra_offset + WIDTH, slice.ptr, slice.len);
@memcpy(ptr + extra_offset, slice.ptr, slice.len);
return extra_offset + slice.len;
}