diff options
author | Pjotr Prins | 2025-02-11 02:19:49 -0600 |
---|---|---|
committer | Pjotr Prins | 2025-02-11 02:19:49 -0600 |
commit | 83d5d1535754016500af6854aab26c1fbdde73d0 (patch) | |
tree | 33f31b3d1f1e11d0f3376e3120eb1f29e4fd214c /guile-zig-local/test.c | |
parent | 648ae2851d515e6b0e003d1ddb25d7b1f1e21c1f (diff) | |
download | presentations-83d5d1535754016500af6854aab26c1fbdde73d0.tar.gz |
Copied guile-zig talk from FOSDEM-2023
Diffstat (limited to 'guile-zig-local/test.c')
-rw-r--r-- | guile-zig-local/test.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/guile-zig-local/test.c b/guile-zig-local/test.c new file mode 100644 index 0000000..c0d1809 --- /dev/null +++ b/guile-zig-local/test.c @@ -0,0 +1,36 @@ +// Testing guile bindings, see README.md and +// https://www.gnu.org/savannah-checkouts/gnu/guile/docs/docs-2.0/guile-ref/Dynamic-Types.html + +#include <stdio.h> +#include <libguile.h> +#include <libguile/boolean.h> +#include <libguile/numbers.h> + +extern void hello_zig(); + +extern SCM my_incrementing_zig_function (SCM a, SCM flag); + +SCM my_incrementing_function (SCM a, SCM flag) +{ + SCM result; + + if (scm_is_true (flag)) + result = scm_sum (a, scm_from_int (1)); + else + result = a; + + return result; +} + + +int main() { + hello_zig(); + SCM test = scm_from_int(3); + SCM b = scm_from_bool(1); + SCM result = my_incrementing_function(test,b); + printf(" from %d to %d\n",scm_to_int(test),scm_to_int(result)); + hello_zig(); + SCM result2 = my_incrementing_zig_function(result,b); + printf(" from %d to %d\n",scm_to_int(result),scm_to_int(result2)); + return 0; +} |