general update, updated cimport so it parses struct definitions from imported headers, improved the error reporting, added ifdef and ifndef, added proper support for extern variadic functions, added some new sections and pages to the doc tool and added --check to only check the program corectness and run compile time defs without producing a binary
This commit is contained in:
31
tests/cimport_structs.sl
Normal file
31
tests/cimport_structs.sl
Normal file
@@ -0,0 +1,31 @@
|
||||
import stdlib.sl
|
||||
|
||||
# Test cimport: extract struct definitions and extern functions from a C header.
|
||||
cimport "cimport_structs.h"
|
||||
|
||||
word main
|
||||
# Verify that cstruct Point was generated with correct layout
|
||||
Point.size puti cr # 16 bytes (two i64 = 8+8)
|
||||
|
||||
# Allocate a Point, set fields, read them back
|
||||
Point.size alloc dup >r
|
||||
r@ 10 Point.x!
|
||||
r@ 20 Point.y!
|
||||
r@ Point.x@ puti cr # 10
|
||||
r@ Point.y@ puti cr # 20
|
||||
|
||||
# Call C helper that takes a pointer (simple scalar ABI)
|
||||
r@ point_sum_ptr puti cr # 30
|
||||
r> Point.size free
|
||||
|
||||
# Verify Pair struct layout
|
||||
Pair.size puti cr # 16
|
||||
|
||||
Pair.size alloc dup >r
|
||||
r@ 100 Pair.a!
|
||||
r@ 200 Pair.b!
|
||||
r@ pair_sum_ptr puti cr # 300
|
||||
r> Pair.size free
|
||||
|
||||
0
|
||||
end
|
||||
Reference in New Issue
Block a user