|
|
@ -1,5 +1,8 @@ |
|
|
|
(import "FileUtilities.cake" |
|
|
|
"CHelpers.cake" "ComptimeHelpers.cake") |
|
|
|
(comptime-cond |
|
|
|
('Unix |
|
|
|
(c-preprocessor-define __USE_XOPEN_EXTENDED))) ;; for strdup |
|
|
|
(c-import "<stdlib.h>" ;; atoi, atof |
|
|
|
"<string.h>" ;; strcmp |
|
|
|
"<ctype.h>" ;; For isspace |
|
|
@ -1829,9 +1832,12 @@ |
|
|
|
(ignore)) |
|
|
|
|
|
|
|
(defun test--introspection (&return int) |
|
|
|
;; (declare-extern-function strdup (str (addr (const char)) &return (addr char))) |
|
|
|
(var another-name (addr char) (strdup "Another name")) |
|
|
|
(defer (free another-name)) |
|
|
|
(var a my-struct |
|
|
|
(array #"#"Hello!" This is a naughty |
|
|
|
naughty string with \\ backslashes and such \\#"# "Other name" (strdup "Another name") null |
|
|
|
naughty string with \\ backslashes and such \\#"# "Other name" another-name null |
|
|
|
42 -0.33f (array 0.f 1.f 2.f) (array 10.f 20.f 30.f) |
|
|
|
(array (array "Hi" true) (array "Bye" false)) |
|
|
|
false 'a' |
|
|
@ -1906,7 +1912,7 @@ |
|
|
|
|
|
|
|
(scope ;; Copy structs |
|
|
|
(var a-2 my-struct |
|
|
|
(array "Test struct" "Other name" (strdup "Another name") null |
|
|
|
(array "Test struct" "Other name" another-name null |
|
|
|
42 -0.33f (array 0.f 1.f 2.f) (array 10.f 20.f 30.f) |
|
|
|
(array (array "Hi" true) (array "Bye" false)) |
|
|
|
false 'a' |
|
|
@ -1925,8 +1931,7 @@ |
|
|
|
(fprintf stderr "error: copied struct does not equal baseline\n") |
|
|
|
(return 1)) |
|
|
|
(free-introspect-struct-fields |
|
|
|
my-struct--metadata (addr b) free) |
|
|
|
(free (field a-2 yet-another-name))) |
|
|
|
my-struct--metadata (addr b) free)) |
|
|
|
|
|
|
|
(scope ;; Test errors |
|
|
|
(var read-struct my-struct (array 0)) |
|
|
@ -1948,6 +1953,4 @@ |
|
|
|
(free-introspect-struct-fields |
|
|
|
my-struct--metadata (addr read-struct) free))) |
|
|
|
|
|
|
|
(free (field a yet-another-name)) |
|
|
|
|
|
|
|
(return 0)))) |
|
|
|