From 05c28f754f389311dc6b38b24b0aac7a6e715142 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Fri, 22 Apr 2005 15:46:41 +0000 Subject: [PATCH] added ffi-obj-ref original commit: d5ae83a9339a8af4c3ab40175913ca8295be809b --- collects/mzlib/foreign.ss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/collects/mzlib/foreign.ss b/collects/mzlib/foreign.ss index db523ac..34d9d4d 100644 --- a/collects/mzlib/foreign.ss +++ b/collects/mzlib/foreign.ss @@ -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.