2003-12-31 10:40:26 -05:00
|
|
|
(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)
|
2003-12-31 10:40:26 -05:00
|
|
|
(begin
|
|
|
|
|
2004-02-11 11:20:27 -05:00
|
|
|
(define-exported-binding "length" length)
|
|
|
|
(define-exported-binding "boolean?" boolean?)
|
|
|
|
(define-exported-binding "integer?" integer?)
|
|
|
|
|
2003-12-31 10:40:26 -05:00
|
|
|
(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)
|
2003-12-31 10:40:26 -05:00
|
|
|
(else
|
|
|
|
(error "Could not map value to finite type "
|
|
|
|
finite-type-name id))))))
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|