test for struct containing pointers
This commit is contained in:
parent
445cfcf15a
commit
19f4b1293d
@ -320,3 +320,18 @@ void manyargs(ManyArgs0 a0, int8_t (*a1)[7], int8_t a2[4], int8_t* mut) {
|
||||
*mut++ = a2[0];
|
||||
*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]}
|
||||
};
|
||||
}
|
||||
@ -123,6 +123,15 @@ Section "# nested"
|
||||
•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,3‿4⟩⊸+⚇0 ⟨10, 20‿30⟩
|
||||
}
|
||||
|
||||
|
||||
# erroring:
|
||||
|
||||
|
||||
@ -133,3 +133,6 @@ text
|
||||
# nested
|
||||
⟨ 3 4 5 6 0 ⟩
|
||||
⟨ 123 ⟨ 0 1 2 30 4 5 6 7 8 9 ⟩ ⟩
|
||||
|
||||
# Struct of pointers
|
||||
⟨ 12 21 ⟨ 13 34 ⟩ ⟩
|
||||
|
||||
Loading…
Reference in New Issue
Block a user