added ffi-obj-ref

original commit: d5ae83a9339a8af4c3ab40175913ca8295be809b
This commit is contained in:
Eli Barzilay 2005-04-22 15:46:41 +00:00
parent 2b55585b3a
commit 05c28f754f

View File

@ -184,6 +184,17 @@
(hash-table-put! ffi-objects-ref-table ffi-obj new)
(ptr-set! ffi-obj type new)))
(provide* ffi-obj-ref)
(define ffi-obj-ref
(case-lambda
[(name lib) (ffi-obj-ref name lib #f)]
[(name lib failure)
(let ([name (get-ffi-obj-name 'ffi-obj-ref name)]
[lib (get-ffi-lib lib)])
(with-handlers ([exn:fail:filesystem?
(lambda (e) (if failure (failure) (raise e)))])
(ffi-obj name lib)))]))
;; get-ffi-obj is implemented as a syntax only to be able to propagate the
;; foreign name into the type syntax, which allows generated wrappers to have a
;; proper name.