- (bind-type TYPENAME SCHEMETYPE [CONVERTARGUMENT [CONVERTRESULT]])syntax
Declares a foreign type transformation, similar to define-foreign-type. There should be two to four arguments: a C typename, a Scheme foreign type specifier and optional argument- and result-value conversion procedures.
;;;; foreign type that converts to unicode (assumes 4-byte wchar_t): ; ; - Note: this is rather kludgy and is only meant to demonstrate the `bind-type' ; syntax
(require-extension srfi-4 bind)
(define mbstowcs (foreign-lambda int "mbstowcs" nonnull-u32vector c-string int))
(define (str->ustr str) (let* ([len (string-length str)] [us (make-u32vector (add1 len) 0)] ) (mbstowcs us str len) us) )
(bind-type unicode nonnull-u32vector str->ustr)
(bind* #<<EOF static void foo(unicode ws) { printf("%ls\n", ws); } EOF )
(foo "this is a test!")