test for struct containing pointers

This commit is contained in:
dzaima 2024-02-05 21:52:19 +02:00
parent 445cfcf15a
commit 19f4b1293d
3 changed files with 27 additions and 0 deletions

View File

@ -320,3 +320,18 @@ void manyargs(ManyArgs0 a0, int8_t (*a1)[7], int8_t a2[4], int8_t* mut) {
*mut++ = a2[0]; *mut++ = a2[0];
*mut++ = a2[3]; *mut++ = a2[3];
} }
typedef struct StructOfPtrs {
void* ptr1;
int32_t* ptr2;
int32_t* ptrs[2];
} StructOfPtrs;
StructOfPtrs operateOnStructOfPtrs(StructOfPtrs arg, StructOfPtrs ptr[2]) {
return (StructOfPtrs) {
.ptr1 = arg.ptr2,
.ptr2 = ptr[0].ptr1,
.ptrs = {arg.ptrs[0], ptr[1].ptrs[1]}
};
}

View File

@ -123,6 +123,15 @@ Section "# nested"
•Show F fn, 10 •Show F fn, 10
} }
Section "# Struct of pointers"
{
malloc "lib.so" •FFI "*u8", "malloc", ">u64"
p Malloc 100
sop "{*,*i32,[2]*}"
f "lib.so"•FFI sop, "operateOnStructOfPtrs", sop, "[2]"sop
•Show {(𝕩.Cast "u8").Sub p}0 F {(p.Add 𝕩).Cast ""}0 1,2,34+0 10, 2030
}
# erroring: # erroring:

View File

@ -133,3 +133,6 @@ text
# nested # nested
⟨ 3 4 5 6 0 ⟩ ⟨ 3 4 5 6 0 ⟩
⟨ 123 ⟨ 0 1 2 30 4 5 6 7 8 9 ⟩ ⟩ ⟨ 123 ⟨ 0 1 2 30 4 5 6 7 8 9 ⟩ ⟩
# Struct of pointers
⟨ 12 21 ⟨ 13 34 ⟩ ⟩