Skip to content

Commit 8ac8887

Browse files
committed
Initial test added for pointers to structs
1 parent 49a65ea commit 8ac8887

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

integration_tests/structs_02.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from ltypes import i32, f32, dataclass, CPtr, Pointer, c_p_pointer, pointer
2+
3+
@dataclass
4+
class A:
5+
x: i32
6+
y: f32
7+
8+
@ccallable
9+
def f(a: CPtr) -> None:
10+
x: i32
11+
y: f32
12+
a1: A
13+
a2: Pointer[A]
14+
a1 = A(3, 3.25)
15+
a2 = pointer(a1)
16+
x = a2.x
17+
y = a2.y
18+
assert x == 3
19+
assert y == 3.25
20+
c_p_pointer(a, a2)
21+
print(a, a2)
22+
23+
def g():
24+
b: CPtr
25+
f(b)
26+
27+
g()

0 commit comments

Comments
 (0)