1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 12:20:20 +02:00

Add string->pointer' and pointer->string' to the FFI.

* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): New
  functions.

* libguile/foreign.h (scm_string_to_pointer, scm_pointer_to_string): New
  declarations.

* module/system/foreign.scm: Export `string->pointer' and
  `pointer->string'.

* test-suite/tests/foreign.test ("pointer<->string"): New test prefix.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Add
  `string->pointer' and `pointer->string'.
This commit is contained in:
Ludovic Courtès 2010-08-15 16:42:33 +02:00
parent 61d1d4a83a
commit fa2a89a6d1
5 changed files with 85 additions and 16 deletions

View file

@ -78,6 +78,18 @@
0
bytes)))))
(with-test-prefix "pointer<->string"
(pass-if "bijection"
(let ((s "hello, world"))
(string=? s (pointer->string (string->pointer s)))))
(pass-if "bijection [latin1]"
(with-latin1-locale
(let ((s "Szép jó napot!"))
(string=? s (pointer->string (string->pointer s)))))))
(with-test-prefix "structs"