diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-21 05:20:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-21 05:20:03 -0700 |
commit | 8465d27df3fef6089ea122914a0c6b0cf7b82e85 (patch) | |
tree | 73da2bc6f0be7e726db7c7080776c4c80aef9395 /tests/017 | |
parent | 8f9697ed8f42681ab0df16ab38859d61ea05412e (diff) | |
download | txr-8465d27df3fef6089ea122914a0c6b0cf7b82e85.tar.gz txr-8465d27df3fef6089ea122914a0c6b0cf7b82e85.tar.bz2 txr-8465d27df3fef6089ea122914a0c6b0cf7b82e85.zip |
ffi: flex structs: minor refactor.
* ffi.c (ffi_flex_struct_in): Function renamed to ffi_flex_array_len,
because its responsibility is determining the length of a flexible
array that is not null terminated. We don't pass in the structure's
type's descriptor any more, but the member descriptor.
(ffi_struct_in, ffi_struct_get): Follow rename and changed parameter
conventions.
* tests/017/flexstruct.tl: Added test case with nested flexible
structure.
Diffstat (limited to 'tests/017')
-rw-r--r-- | tests/017/flexstruct.tl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/017/flexstruct.tl b/tests/017/flexstruct.tl index c8feedef..8f91096e 100644 --- a/tests/017/flexstruct.tl +++ b/tests/017/flexstruct.tl @@ -62,3 +62,12 @@ (mtest (ffi-get #b'0300010002000300' (ffi fs3)) #S(fs3 a 3 b #(1 2 3))) + +(typedef fs4 (struct fs4 + (c int8) + (s fs0))) + +(mtest + (sizeof fs4) 2 + (ffi-put #S(fs4 c 93 s #S(fs0 a 4 b "ABCD")) (ffi fs4)) #b'5d0441424344' + (ffi-get #b'5d0441424344' (ffi fs4)) #S(fs4 c 93 s #S(fs0 a 4 b "ABCD"))) |