scsh-ldap/ffi-tools/ffi-tools-rts.scm

39 lines
979 B
Scheme
Raw Normal View History

(define-interface ffi-tools-rts-interface
(export
(lookup-shared-value :syntax)
make-finite-type-import-function))
(define-structure ffi-tools-rts ffi-tools-rts-interface
2004-01-15 11:32:58 -05:00
(open scheme srfi-23 external-calls)
(begin
(define-exported-binding "length" length)
(define-exported-binding "boolean?" boolean?)
(define-exported-binding "integer?" integer?)
(define-syntax lookup-shared-value
(syntax-rules ()
((lookup-shared-value %s)
(shared-binding-ref
(lookup-imported-binding %s)))))
(define (make-finite-type-alist elements id-proc)
(map
(lambda (e) (cons (id-proc e) e))
(vector->list elements)))
(define (make-finite-type-import-function finite-type-name elements id-proc)
(let ((alist (make-finite-type-alist elements id-proc)))
(lambda (id)
(cond
2004-01-15 11:32:58 -05:00
((assoc id alist) => cdr)
(else
(error "Could not map value to finite type "
finite-type-name id))))))
))