change _fpointer handling to work with function pointers in structs and other such uses; add 'function-ptr' casting operation

svn: r12913

original commit: 82ead03b92f7288fede1aaf6679312fc5d2093f2
This commit is contained in:
Matthew Flatt 2008-12-20 05:09:35 +00:00
parent 0a87e4bd26
commit 90abe67ff6

View File

@ -62,7 +62,7 @@
_void _int8 _uint8 _int16 _uint16 _int32 _uint32 _int64 _uint64 _void _int8 _uint8 _int16 _uint16 _int32 _uint32 _int64 _uint64
_fixint _ufixint _fixnum _ufixnum _fixint _ufixint _fixnum _ufixnum
_float _double _double* _float _double _double*
_bool _pointer _scheme _fpointer _bool _pointer _scheme _fpointer function-ptr
(unsafe memcpy) (unsafe memmove) (unsafe memset) (unsafe memcpy) (unsafe memmove) (unsafe memset)
(unsafe malloc-immobile-cell) (unsafe free-immobile-cell)) (unsafe malloc-immobile-cell) (unsafe free-immobile-cell))
@ -676,6 +676,13 @@
(syntax-case stx () (syntax-case stx ()
[(_ x ...) (begin (set! xs (syntax->list #'(x ...))) (do-fun))])) [(_ x ...) (begin (set! xs (syntax->list #'(x ...))) (do-fun))]))
(define (function-ptr p fun-ctype)
(if (cpointer? p)
(if (eq? (ctype->layout fun-ctype) 'fpointer)
((ctype-c->scheme fun-ctype) p)
(raise-type-error 'function-ptr "function ctype" fun-ctype))
(raise-type-error 'function-ptr "cpointer" p)))
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
;; String types ;; String types