diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-03-21 06:16:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-03-21 06:16:43 -0700 |
commit | af8b7db50fcc3ed34bfe1136d1664d59e89ba1a9 (patch) | |
tree | 14a7981e70ecc67f165e848dd4e3d0a7349d8671 /tests/017/str-s.tl | |
parent | 3ce67812ebbbb8c0a82d77a72f565cda40bdec73 (diff) | |
download | txr-af8b7db50fcc3ed34bfe1136d1664d59e89ba1a9.tar.gz txr-af8b7db50fcc3ed34bfe1136d1664d59e89ba1a9.tar.bz2 txr-af8b7db50fcc3ed34bfe1136d1664d59e89ba1a9.zip |
New FFI types str-s, bstr-s and wstr-s.
These types actually make it possible to receive a string by
pointer from a C function, without trying to free it.
It is now possible to write a FFI wrapper for strtol or
wcstol, which is done in the new test case.
* ffi.c (str_s_s, bstr_s_s, wstr_s_s): New symbol variables.
(ffi_init_types): Register the types str-s, bstr-s and wstr-s.
(ffi_init): Intern the new symbols.
* tests/017/str-s.tl: New file.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/017/str-s.tl')
-rw-r--r-- | tests/017/str-s.tl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/017/str-s.tl b/tests/017/str-s.tl new file mode 100644 index 00000000..bb9dc38a --- /dev/null +++ b/tests/017/str-s.tl @@ -0,0 +1,11 @@ +(load "../common") + +(with-dyn-lib nil + (deffi strtol "strtol" long (str (ptr-out (array 1 str-s)) int)) + (deffi bcstol "strtol" long (bstr (ptr-out (array 1 bstr-s)) int)) + (deffi wcstol "wcstol" long (wstr (ptr-out (array 1 wstr-s)) int))) + +(mtest + (let ((v (vec nil))) (list (strtol "-345x" v 0) v)) (-345 #("x")) + (let ((v (vec nil))) (list (bcstol "-345x" v 0) v)) (-345 #("x")) + (let ((v (vec nil))) (list (wcstol "-345x" v 0) v)) (-345 #("x"))) |