aboutsummaryrefslogtreecommitdiff
path: root/tests/i/extern-c-struct/program.cps
diff options
context:
space:
mode:
Diffstat (limited to 'tests/i/extern-c-struct/program.cps')
-rw-r--r--tests/i/extern-c-struct/program.cps22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/i/extern-c-struct/program.cps b/tests/i/extern-c-struct/program.cps
new file mode 100644
index 0000000..1954d29
--- /dev/null
+++ b/tests/i/extern-c-struct/program.cps
@@ -0,0 +1,22 @@
+// Records whose fields are C types pass to C functions through pointer types.
+INCLUDE_OBJ "lib.o"
+TYPE Sample
+ DECLARE Tag : C_CHAR
+ DECLARE Value : C_DOUBLE
+ DECLARE Count : C_INT
+ENDTYPE
+TYPE PSample = ^Sample
+EXTERN "C" EXTERN_PROCEDURE scale_sample(PSample, C_INT)
+EXTERN "C" EXTERN_FUNCTION shared_sample() RETURNS PSample
+EXTERN "C" EXTERN_FUNCTION shared_count() RETURNS C_INT
+DECLARE S : Sample
+DECLARE P : PSample
+S.Tag <- (C_CHAR)'S'
+S.Value <- (C_DOUBLE)1.5
+S.Count <- (C_INT)5
+CALL scale_sample(^S, (C_INT)3)
+OUTPUT S.Tag, " ", S.Value, " ", S.Count
+P <- shared_sample()
+OUTPUT P^.Tag, " ", P^.Value, " ", P^.Count
+P^.Count <- (C_INT)9
+OUTPUT shared_count()