From 8465d27df3fef6089ea122914a0c6b0cf7b82e85 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 21 May 2022 05:20:03 -0700 Subject: 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. --- tests/017/flexstruct.tl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/017/flexstruct.tl') 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"))) -- cgit v1.2.3