scheme/foreign: allow #f as NULL function pointer, allow callback as cpointer

svn: r12992

original commit: d596401804242ca39007e56d798e12f3852810f0
This commit is contained in:
Matthew Flatt 2009-01-03 18:51:15 +00:00
parent 0dc7813924
commit 2e250514c6

View File

@ -477,6 +477,7 @@
(define-syntax-rule (make-it wrap)
(make-ctype _fpointer
(lambda (x)
(and x
(let ([cb (ffi-callback (wrap x) itypes otype abi)])
(cond [(eq? keep #t) (hash-set! held-callbacks x cb)]
[(box? keep)
@ -484,8 +485,8 @@
(set-box! keep
(if (or (null? x) (pair? x)) (cons cb x) cb)))]
[(procedure? keep) (keep cb)])
cb))
(lambda (x) (wrap (ffi-call x itypes otype abi)))))
cb)))
(lambda (x) (and x (wrap (ffi-call x itypes otype abi))))))
(if wrapper (make-it wrapper) (make-it begin)))
;; Syntax for the special _fun type: